[Scummvm-cvs-logs] SF.net SVN: scummvm: [28675] tools/branches/gsoc2007-toolsgui

lightcast at users.sourceforge.net lightcast at users.sourceforge.net
Mon Aug 20 06:07:46 CEST 2007


Revision: 28675
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28675&view=rev
Author:   lightcast
Date:     2007-08-19 21:07:46 -0700 (Sun, 19 Aug 2007)

Log Message:
-----------
Rewrote process creation.  The GUI is now much more responsive.

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/TODO
    tools/branches/gsoc2007-toolsgui/tools_gui.cpp
    tools/branches/gsoc2007-toolsgui/tools_gui.h

Modified: tools/branches/gsoc2007-toolsgui/TODO
===================================================================
--- tools/branches/gsoc2007-toolsgui/TODO	2007-08-19 23:57:12 UTC (rev 28674)
+++ tools/branches/gsoc2007-toolsgui/TODO	2007-08-20 04:07:46 UTC (rev 28675)
@@ -11,16 +11,14 @@
 * Default Options
     - Things like default games path, default LAME path, default compression 
       type, etc. could be added to a menu and saved to an *.ini file.
-* Enhanced Batch Processing
-    - Batch processing now consists of compressing/extracting multiple files
-      from the same game.  It can be enhanced holding a list of jobs to done
-      from multiple games.  This would involve adding a 'Start Batch' and a 
-      'Add to Batch' button and holding a copy of the compressionPanel and
-      compressionOptions classes associated with a job.  This would allow for
-      the user to modify waiting jobs since we would just replace the current
-      compressionPanel and compressionOptions panels with the saved copies.
-      The 'Start Batch' button would just iterate through each job, build
-      the command line string, and perform the resulting operation.
+* Batch Processing
+    - Batch processing can be performed by holding a list of jobs to done in
+      the ProcessArray already used in MainFrame.  To accomplish this we would
+      need to modify the Process class to add a wxString class member to hold
+      the command line string, add wxButtons and a wxListBox to facilitate
+      adding, removing, and starting batch jobs, and adding a function which
+      would iterate through the ProcessArray and perform each job, starting
+      subsequent jobs in the OnTerminate function of the previous job.
 * Encode DXA Improvements
     - The current implementation of 'Encode DXA' compression only performs the
       final step of the process.  There are already Windows and Unix scripts to
@@ -30,4 +28,4 @@
     - Another tab could be added that would automatically compress an original
       CD.  This would involve identifying the game, either by using filenames
       or md5 hashes, copying all of the files needed to play the game to a
-      specified directory, and compressing any applicable files.
\ No newline at end of file
+      specified directory, and compressing any applicable files.

Modified: tools/branches/gsoc2007-toolsgui/tools_gui.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/tools_gui.cpp	2007-08-19 23:57:12 UTC (rev 28674)
+++ tools/branches/gsoc2007-toolsgui/tools_gui.cpp	2007-08-20 04:07:46 UTC (rev 28675)
@@ -33,7 +33,6 @@
 	EVT_CHOICE(kCompressionTypeChoice, CompressionPanel::OnCompressionTypeChange)
 	EVT_BUTTON(kCompressionInputBrowse, CompressionPanel::OnCompressionInputBrowse)
 	EVT_BUTTON(kCompressionOutputBrowse, CompressionPanel::OnCompressionOutputBrowse)
-	EVT_BUTTON(kCompressionStartButton, CompressionPanel::OnCompressionStart)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE( ExtractionPanel, wxPanel )
@@ -41,11 +40,13 @@
 	EVT_BUTTON(kExtractionInput1Browse, ExtractionPanel::OnExtractionInput1Browse)
 	EVT_BUTTON(kExtractionInput2Browse, ExtractionPanel::OnExtractionInput2Browse)
 	EVT_BUTTON(kExtractionOutputBrowse, ExtractionPanel::OnExtractionOutputBrowse)
-	EVT_BUTTON(kExtractionStartButton, ExtractionPanel::OnExtractionStart)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE( MainFrame, wxFrame)
 	EVT_CHECKBOX(kCompressionOptionsToggle, MainFrame::OnCompressionOptionsToggle)
+	EVT_BUTTON(kCompressionStartButton, MainFrame::OnCompressionStart)
+	EVT_BUTTON(kExtractionStartButton, MainFrame::OnExtractionStart)
+    EVT_IDLE(MainFrame::OnIdle)
 END_EVENT_TABLE()
 
 bool ToolsGui::OnInit() {
@@ -57,6 +58,8 @@
 	return true;
 }
 
+/* ----- Main Frame ----- */
+
 MainFrame::MainFrame(const wxString& title) : wxFrame((wxFrame *)NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600, 450)) {
 	wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
 	this->SetSizer(mainSizer);
@@ -84,6 +87,38 @@
 	this->SetMinSize(wxSize(600, 450));
 }
 
+/* ----- Common ----- */
+
+Process::Process(MainFrame *parent, wxTextCtrl *target) : wxProcess(parent) {
+	_parent = parent;
+	_target = target;
+	this->Redirect();
+}
+
+bool Process::HasInput() {
+	if (this->IsInputAvailable()) {
+		wxTextInputStream stream(*this->GetInputStream());
+
+		wxString output;
+		output << stream.ReadLine() << wxT("\n");
+
+		this->_target->AppendText(output);
+
+		return true;
+	}
+
+	return false;
+}
+
+void Process::OnTerminate(int pid, int status) {
+	while (this->HasInput());
+	this->_target->AppendText(wxT("\n\n-------------------------"));
+	this->_target->AppendText(wxT("\nOperation Finished."));
+	this->_target->AppendText(wxT("\n-------------------------"));
+	_parent->OnProcessTerminated(this);
+	delete this;
+}
+
 LocationDialog::LocationDialog(wxTextCtrl *target, bool isFileChooser, wxString wildcard) {
 	_isFileChooser = isFileChooser;
 	_target = target;
@@ -103,22 +138,12 @@
 			wxArrayString filenames;
 			dialog->GetPaths(filenames);
 
-			if (!this->_target->GetValue().empty()) {
-				this->_target->AppendText(wxT(" "));
-			}
-
-			for (size_t i = 0; i < filenames.GetCount(); i++) {
-				this->_target->AppendText(wxT("\""));
-				this->_target->AppendText(filenames[i]);
-				this->_target->AppendText(wxT("\""));
-
-				if (i != filenames.GetCount() - 1) {
-					this->_target->AppendText(wxT(" "));
-				}
-			}
+			this->_target->SetValue(wxT("\""));
+			this->_target->AppendText(filenames.Item(0));
+			this->_target->AppendText(wxT("\""));
+	
+			this->_target->SetInsertionPoint(0);
 		}
-
-		this->_target->SetInsertionPoint(0);
 	} else {
 		wxDirDialog *dialog = dynamic_cast<wxDirDialog*>(_dialog);
 
@@ -126,9 +151,9 @@
 			this->_target->SetValue(wxT("\""));
 			this->_target->AppendText(dialog->GetPath());
 			this->_target->AppendText(wxT("\""));
+	
+			this->_target->SetInsertionPoint(0);
 		}
-
-		this->_target->SetInsertionPoint(0);
 	}
 }
 
@@ -140,26 +165,10 @@
 
 bool FileDrop::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) {
 	if (_target->IsEnabled()) {
-		if (_isFileChooser) {
-			if (!_target->GetValue().empty()) {
-				_target->AppendText(wxT(" "));
-			}
-
-			for (size_t i = 0; i < filenames.GetCount(); i++) {
-				_target->AppendText(wxT("\""));
-				_target->AppendText(filenames[i]);
-				_target->AppendText(wxT("\""));
-
-				if (i != filenames.GetCount() - 1) {
-					_target->AppendText(wxT(" "));
-				}
-			}
-		} else {
-			_target->SetValue(wxT("\""));
-			_target->AppendText(filenames[0]);
-			_target->AppendText(wxT("\""));
-		}
-
+		_target->SetValue(wxT("\""));
+		_target->AppendText(filenames[0]);
+		_target->AppendText(wxT("\""));
+	
 		_target->SetInsertionPoint(0);
 	}
 
@@ -619,175 +628,6 @@
 	delete dialog;
 }
 
-void CompressionPanel::OnCompressionStart(wxCommandEvent &event) {
-	this->_startButton->Enable(false);
-	this->_toolOutput->Clear();
-
-	bool done = false;
-	size_t start = 1;
-	size_t end;
-
-	wxString selectedTool = kCompressionToolFilenames[this->_compressionToolChooserBox->_choice->GetSelection()];
-	wxString compressionType = kCompressionTypeArguments[this->_compressionTypeBox->_choice->GetSelection()];
-	wxString inputPath = this->_inputPanel->_text->GetValue();
-	wxString outputPath = this->_outputPanel->_text->GetValue();
-	wxArrayString inputFiles;
-
-	wxString avgBitrate = this->_compressionOptionsPanel->_avgBitrateChooser->GetStringSelection();
-	wxString blocksize = this->_compressionOptionsPanel->_blockSize->GetStringSelection();
-	wxString compressionLevel = this->_compressionOptionsPanel->_compressionLevelChooser->GetStringSelection();
-	wxString maxBitrate = this->_compressionOptionsPanel->_maxBitrateChooser->GetStringSelection();
-	wxString minBitrate = this->_compressionOptionsPanel->_minBitrateChooser->GetStringSelection();
-	wxString mode = this->_compressionOptionsPanel->_modeChooser->GetStringSelection();
-	wxString mpegQuality = this->_compressionOptionsPanel->_mpegQualityChooser->GetStringSelection();
-	bool isSilent = this->_compressionOptionsPanel->_silentChooser->IsChecked();
-	wxString vbrQuality = this->_compressionOptionsPanel->_vbrQualityChooser->GetStringSelection();
-	bool isVerify = this->_compressionOptionsPanel->_verifyChooser->IsChecked();
-
-	if (!inputPath.IsEmpty()) {
-		while (!done) {
-			end = inputPath.find(wxT('"'), start);
-			inputFiles.Add(inputPath.Mid(start - 1, end - start + 2));
-			start = end + 3;
-
-			if ((end + 1) == inputPath.Len()) {
-				done = true;
-			}
-		}
-
-		for (size_t x = 0; x < inputFiles.Count(); x++) {
-			wxString commandString = wxT("");
-
-#ifndef __WXMSW__
-			commandString += wxT("./");
-#endif
-			commandString += selectedTool;
-			commandString += wxT(" ");
-			commandString += compressionType;
-			commandString += wxT(" ");
-
-			if (compressionType.IsSameAs(kCompressionTypeArguments[0])) { /* MP3 */
-				if (mode.IsSameAs(kMP3ModeNames[0])) { /* VBR */
-					commandString += wxT("--vbr ");
-					commandString += wxT("-V ");
-					commandString += vbrQuality;
-					commandString += wxT(" ");
-					commandString += wxT("-q ");
-					commandString += mpegQuality;
-					commandString += wxT(" ");
-
-					if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
-						commandString += wxT("-b ");
-						commandString += minBitrate;
-						commandString += wxT(" ");
-					}
-
-					if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
-						commandString += wxT("-B ");
-						commandString += maxBitrate;
-						commandString += wxT(" ");
-					}
-				} else { /* ABR */
-					commandString += wxT("--abr ");
-
-					if (avgBitrate.IsSameAs(kValidBitrateNames[0])) {
-						commandString += kDefaultMP3ABRAvgBitrate;
-					} else {
-						commandString += avgBitrate;
-					}
-
-					commandString += wxT(" ");
-					commandString += wxT("-q ");
-					commandString += mpegQuality;
-					commandString += wxT(" ");
-
-					if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
-						commandString += wxT("-b ");
-						commandString += minBitrate;
-						commandString += wxT(" ");
-					}
-
-					if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
-						commandString += wxT("-B ");
-						commandString += maxBitrate;
-						commandString += wxT(" ");
-					}
-				}
-
-				commandString += wxT("--silent ");
-			} else if (compressionType.IsSameAs(kCompressionTypeArguments[1])) { /* Vorbis */
-				commandString += wxT("-q ");
-				commandString += vbrQuality;
-				commandString += wxT(" ");
-
-				if (!avgBitrate.IsSameAs(kValidBitrateNames[0])) {
-					commandString += wxT("-b ");
-					commandString += avgBitrate;
-					commandString += wxT(" ");
-				}
-
-				if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
-					commandString += wxT("-m ");
-					commandString += minBitrate;
-					commandString += wxT(" ");
-				}
-
-				if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
-					commandString += wxT("-M ");
-					commandString += maxBitrate;
-					commandString += wxT(" ");
-				}
-
-				if (isSilent) {
-					commandString += wxT("--silent ");
-				}
-			} else { /* FLAC */
-				commandString += wxT("-");
-				commandString += compressionLevel;
-				commandString += wxT(" ");
-				commandString += wxT("-b ");
-				commandString += blocksize;
-				commandString += wxT(" ");
-
-				if (isVerify) {
-					commandString += wxT("--verify ");
-				}
-
-				if (isSilent) {
-					commandString += wxT("--silent ");
-				}
-			}
-
-			commandString += inputFiles.Item(x);
-			if (!outputPath.IsEmpty()) {
-				commandString += wxT(" ");
-				commandString += outputPath;
-			}
-
-			this->_toolOutput->AppendText(commandString);
-			this->_toolOutput->AppendText(wxT("\n\n"));
-
-			wxProcess *command = new wxProcess(wxPROCESS_REDIRECT);
-
-			wxExecute(commandString, wxEXEC_ASYNC, command);
-
-			while (!command->GetInputStream()->Eof()) {
-				wxChar outputChar = command->GetInputStream()->GetC();
-				if (command->GetInputStream()->LastRead() != 0) {
-					this->_toolOutput->AppendText(outputChar);
-				}
-			}
-
-			this->_toolOutput->AppendText(wxT("\n------------------------------\n"));
-			this->_toolOutput->AppendText(wxT("Operation Finished\n"));
-			this->_toolOutput->AppendText(wxT("------------------------------\n"));
-			this->_toolOutput->AppendText(wxT("\n"));
-		}
-	}
-
-	this->_startButton->Enable(true);
-}
-
 /* ----- Extraction Events ----- */
 
 void ExtractionPanel::OnExtractionToolChange(wxCommandEvent &event) {
@@ -934,110 +774,228 @@
 	delete dialog;
 }
 
-void ExtractionPanel::OnExtractionStart(wxCommandEvent &event) {
-	this->_startButton->Enable(false);
-	this->_toolOutput->Clear();
+/* ----- MainFrame Events ----- */
 
-	bool done = false;
-	size_t start = 1;
-	size_t end;
+void MainFrame::OnCompressionOptionsToggle(wxCommandEvent &event) {
+	this->_compressionTools->_compressionOptionsPanel->Show(!this->_compressionTools->_compressionOptionsPanel->IsShown());
 
-	wxString selectedTool = kExtractionToolFilenames[this->_extractionToolChooserPanel->_choice->GetSelection()];
-	wxString input1Path = this->_input1Panel->_text->GetValue();
-	wxString input2Path = this->_input2Panel->_text->GetValue();
-	wxString outputPath = this->_outputPanel->_text->GetValue();
-	wxArrayString inputFiles;
+	this->_compressionTools->Fit();
+	this->_compressionTools->SetSize(this->_mainNotebook->GetPage(0)->GetSize());
 
-	bool kyraAllFiles = this->_extractionOptionsPanel->_kyraAllFiles->IsChecked();
-	bool kyraAmiga = this->_extractionOptionsPanel->_kyraAmiga->IsChecked();
-	wxString kyraFilename = this->_extractionOptionsPanel->_kyraFilename->GetValue();
-	bool kyraSingleFile = this->_extractionOptionsPanel->_kyraSingleFile->IsChecked();
-	bool parallactionSmall = this->_extractionOptionsPanel->_parallactionSmall->IsChecked();
+	this->_extractionTools->Fit();
+	this->_extractionTools->SetSize(this->_mainNotebook->GetPage(1)->GetSize());
+}
 
-	if (!input1Path.IsEmpty()) {
-		while (!done) {
-			end = input1Path.find(wxT('"'), start);
-			inputFiles.Add(input1Path.Mid(start - 1, end - start + 2));
-			start = end + 3;
+void MainFrame::OnCompressionStart(wxCommandEvent &event) {
+	this->_compressionTools->_toolOutput->Clear();
 
-			if ((end + 1) == input1Path.Len()) {
-				done = true;
-			}
-		}
+	wxString selectedTool = kCompressionToolFilenames[this->_compressionTools->_compressionToolChooserBox->_choice->GetSelection()];
+	wxString compressionType = kCompressionTypeArguments[this->_compressionTools->_compressionTypeBox->_choice->GetSelection()];
+	wxString inputPath = this->_compressionTools->_inputPanel->_text->GetValue();
+	wxString outputPath = this->_compressionTools->_outputPanel->_text->GetValue();
 
-		for (size_t x = 0; x < inputFiles.Count(); x++) {
-			wxString commandString = wxT("");
+	wxString avgBitrate = this->_compressionTools->_compressionOptionsPanel->_avgBitrateChooser->GetStringSelection();
+	wxString blocksize = this->_compressionTools->_compressionOptionsPanel->_blockSize->GetStringSelection();
+	wxString compressionLevel = this->_compressionTools->_compressionOptionsPanel->_compressionLevelChooser->GetStringSelection();
+	wxString maxBitrate = this->_compressionTools->_compressionOptionsPanel->_maxBitrateChooser->GetStringSelection();
+	wxString minBitrate = this->_compressionTools->_compressionOptionsPanel->_minBitrateChooser->GetStringSelection();
+	wxString mode = this->_compressionTools->_compressionOptionsPanel->_modeChooser->GetStringSelection();
+	wxString mpegQuality = this->_compressionTools->_compressionOptionsPanel->_mpegQualityChooser->GetStringSelection();
+	bool isSilent = this->_compressionTools->_compressionOptionsPanel->_silentChooser->IsChecked();
+	wxString vbrQuality = this->_compressionTools->_compressionOptionsPanel->_vbrQualityChooser->GetStringSelection();
+	bool isVerify = this->_compressionTools->_compressionOptionsPanel->_verifyChooser->IsChecked();
 
+	if (!inputPath.IsEmpty()) {
+		wxString commandString = wxT("");
+
 #ifndef __WXMSW__
-			commandString += wxT("./");
+		commandString += wxT("./");
 #endif
-			commandString += selectedTool;
-			commandString += wxT(" ");
+		commandString += selectedTool;
+		commandString += wxT(" ");
+		commandString += compressionType;
+		commandString += wxT(" ");
 
-			if (kyraAllFiles) {
-				commandString += wxT("-x ");
-			}
+		if (compressionType.IsSameAs(kCompressionTypeArguments[0])) { /* MP3 */
+			if (mode.IsSameAs(kMP3ModeNames[0])) { /* VBR */
+				commandString += wxT("--vbr ");
+				commandString += wxT("-V ");
+				commandString += vbrQuality;
+				commandString += wxT(" ");
+				commandString += wxT("-q ");
+				commandString += mpegQuality;
+				commandString += wxT(" ");
 
-			if (kyraAmiga) {
-				commandString += wxT("-a ");
-			}
+				if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
+					commandString += wxT("-b ");
+					commandString += minBitrate;
+					commandString += wxT(" ");
+				}
 
-			if (kyraSingleFile) {
-				commandString += wxT("-o ");
-				commandString += kyraFilename;
+				if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
+					commandString += wxT("-B ");
+					commandString += maxBitrate;
+					commandString += wxT(" ");
+				}
+			} else { /* ABR */
+				commandString += wxT("--abr ");
+
+				if (avgBitrate.IsSameAs(kValidBitrateNames[0])) {
+					commandString += kDefaultMP3ABRAvgBitrate;
+				} else {
+					commandString += avgBitrate;
+				}
+
 				commandString += wxT(" ");
-			}
+				commandString += wxT("-q ");
+				commandString += mpegQuality;
+				commandString += wxT(" ");
 
-			if (parallactionSmall) {
-				commandString += wxT("--small");
+				if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
+					commandString += wxT("-b ");
+					commandString += minBitrate;
+					commandString += wxT(" ");
+				}
+
+				if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
+					commandString += wxT("-B ");
+					commandString += maxBitrate;
+					commandString += wxT(" ");
+				}
 			}
 
-			commandString += inputFiles.Item(x);
+			commandString += wxT("--silent ");
+		} else if (compressionType.IsSameAs(kCompressionTypeArguments[1])) { /* Vorbis */
+			commandString += wxT("-q ");
+			commandString += vbrQuality;
+			commandString += wxT(" ");
 
-			if (!input2Path.IsEmpty()) {
+			if (!avgBitrate.IsSameAs(kValidBitrateNames[0])) {
+				commandString += wxT("-b ");
+				commandString += avgBitrate;
 				commandString += wxT(" ");
-				commandString += input2Path;
 			}
-			if (!outputPath.IsEmpty()) {
+
+			if (!minBitrate.IsSameAs(kValidBitrateNames[0])) {
+				commandString += wxT("-m ");
+				commandString += minBitrate;
 				commandString += wxT(" ");
-				commandString += outputPath;
 			}
 
-			this->_toolOutput->AppendText(commandString);
-			this->_toolOutput->AppendText(wxT("\n\n"));
+			if (!maxBitrate.IsSameAs(kValidBitrateNames[0])) {
+				commandString += wxT("-M ");
+				commandString += maxBitrate;
+				commandString += wxT(" ");
+			}
 
-			wxProcess *command = new wxProcess(wxPROCESS_REDIRECT);
-			wxExecute(commandString, wxEXEC_ASYNC, command);
+			if (isSilent) {
+				commandString += wxT("--silent ");
+			}
+		} else { /* FLAC */
+			commandString += wxT("-");
+			commandString += compressionLevel;
+			commandString += wxT(" ");
+			commandString += wxT("-b ");
+			commandString += blocksize;
+			commandString += wxT(" ");
 
-			while (!command->GetInputStream()->Eof()) {
-				wxChar outputChar = command->GetInputStream()->GetC();
-				if (command->GetInputStream()->LastRead() != 0) {
-#ifdef __WXMSW__
-					if (outputChar != 10) {
-						this->_toolOutput->AppendText(outputChar);
-					}
-#else
-					this->_toolOutput->AppendText(outputChar);
-#endif
-				}
+			if (isVerify) {
+				commandString += wxT("--verify ");
 			}
 
-			this->_toolOutput->AppendText(wxT("\n------------------------------\n"));
-			this->_toolOutput->AppendText(wxT("Operation Finished\n"));
-			this->_toolOutput->AppendText(wxT("------------------------------\n"));
-			this->_toolOutput->AppendText(wxT("\n"));
+			if (isSilent) {
+				commandString += wxT("--silent ");
+			}
 		}
+
+		commandString += inputPath;
+		if (!outputPath.IsEmpty()) {
+			commandString += wxT(" ");
+			commandString += outputPath;
+		}
+
+		this->_compressionTools->_toolOutput->AppendText(commandString);
+		this->_compressionTools->_toolOutput->AppendText(wxT("\n\n"));
+
+		Process *command = new Process(this, this->_compressionTools->_toolOutput);
+		this->_processList.Add(command);
+		wxExecute(commandString, wxEXEC_ASYNC, command);
 	}
+}
 
-	this->_startButton->Enable(true);
+void MainFrame::OnExtractionStart(wxCommandEvent &event) {
+	this->_extractionTools->_toolOutput->Clear();
+
+	wxString selectedTool = kExtractionToolFilenames[this->_extractionTools->_extractionToolChooserPanel->_choice->GetSelection()];
+	wxString input1Path = this->_extractionTools->_input1Panel->_text->GetValue();
+	wxString input2Path = this->_extractionTools->_input2Panel->_text->GetValue();
+	wxString outputPath = this->_extractionTools->_outputPanel->_text->GetValue();
+
+	bool kyraAllFiles = this->_extractionTools->_extractionOptionsPanel->_kyraAllFiles->IsChecked();
+	bool kyraAmiga = this->_extractionTools->_extractionOptionsPanel->_kyraAmiga->IsChecked();
+	wxString kyraFilename = this->_extractionTools->_extractionOptionsPanel->_kyraFilename->GetValue();
+	bool kyraSingleFile = this->_extractionTools->_extractionOptionsPanel->_kyraSingleFile->IsChecked();
+	bool parallactionSmall = this->_extractionTools->_extractionOptionsPanel->_parallactionSmall->IsChecked();
+
+	if (!input1Path.IsEmpty()) {
+		wxString commandString = wxT("");
+
+#ifndef __WXMSW__
+		commandString += wxT("./");
+#endif
+		commandString += selectedTool;
+		commandString += wxT(" ");
+
+		if (kyraAllFiles) {
+			commandString += wxT("-x ");
+		}
+
+		if (kyraAmiga) {
+			commandString += wxT("-a ");
+		}
+
+		if (kyraSingleFile) {
+			commandString += wxT("-o ");
+			commandString += kyraFilename;
+			commandString += wxT(" ");
+		}
+
+		if (parallactionSmall) {
+			commandString += wxT("--small");
+		}
+
+		commandString += input1Path;
+
+		if (!input2Path.IsEmpty()) {
+			commandString += wxT(" ");
+			commandString += input2Path;
+		}
+		if (!outputPath.IsEmpty()) {
+			commandString += wxT(" ");
+			commandString += outputPath;
+		}
+
+		this->_extractionTools->_toolOutput->AppendText(commandString);
+		this->_extractionTools->_toolOutput->AppendText(wxT("\n\n"));
+
+		Process *command = new Process(this, this->_extractionTools->_toolOutput);
+		this->_processList.Add(command);
+		wxExecute(commandString, wxEXEC_ASYNC, command);
+	}
 }
 
-void MainFrame::OnCompressionOptionsToggle(wxCommandEvent &event) {
-	this->_compressionTools->_compressionOptionsPanel->Show(!this->_compressionTools->_compressionOptionsPanel->IsShown());
+void MainFrame::OnIdle(wxIdleEvent& event) {
+	for (size_t x = 0; x < this->_processList.GetCount(); x++) {
+		if (this->_processList[x]->HasInput()) {
+			event.RequestMore();
+		}
 
-	this->_compressionTools->Fit();
-	this->_compressionTools->SetSize(this->_mainNotebook->GetPage(0)->GetSize());
+		if (this->_processList[x]->HasInput()) {
+			event.RequestMore();
+		}
+	}
+}
 
-	this->_extractionTools->Fit();
-	this->_extractionTools->SetSize(this->_mainNotebook->GetPage(1)->GetSize());
+void MainFrame::OnProcessTerminated(Process* process) {
+	this->_processList.Remove(process);
 }

Modified: tools/branches/gsoc2007-toolsgui/tools_gui.h
===================================================================
--- tools/branches/gsoc2007-toolsgui/tools_gui.h	2007-08-19 23:57:12 UTC (rev 28674)
+++ tools/branches/gsoc2007-toolsgui/tools_gui.h	2007-08-20 04:07:46 UTC (rev 28675)
@@ -22,12 +22,23 @@
 
 #include <wx/wx.h>
 #include <wx/dnd.h>
-#include <wx/filedlg.h>
 #include <wx/notebook.h>
 #include <wx/process.h>
-#include <wx/statbox.h>
-#include <wx/textctrl.h>
+#include <wx/txtstrm.h>
 
+class Process;
+class LocationDialog;
+class FileDrop;
+class IOChooser;
+class DropDownBox;
+class CompressionOptions;
+class CompressionPanel;
+class ExtractionOptions;
+class ExtractionPanel;
+class MainFrame;
+
+WX_DEFINE_ARRAY_PTR(Process *, ProcessArray);
+
 /* Default MP3 parameters */
 wxString kDefaultMP3ABRAvgBitrate = wxT("24");
 wxString kDefaultMP3CompressionType = wxT("VBR");
@@ -98,6 +109,39 @@
 	virtual bool OnInit();
 };
 
+/* ----- Main Frame ----- */
+
+class MainFrame : public wxFrame {
+public:
+	MainFrame(const wxString& title);
+
+	wxNotebook *_mainNotebook;
+	CompressionPanel *_compressionTools;
+	ExtractionPanel *_extractionTools;
+	ProcessArray _processList;
+
+	void OnCompressionOptionsToggle(wxCommandEvent &event);
+	void OnCompressionStart(wxCommandEvent &event);
+	void OnExtractionStart(wxCommandEvent &event);
+	void OnIdle(wxIdleEvent& event);
+    void OnProcessTerminated(Process *process);
+
+	DECLARE_EVENT_TABLE()
+};
+
+/* ----- Common ----- */
+
+class Process : public wxProcess {
+public:
+    Process(MainFrame *parent, wxTextCtrl *target);
+
+    MainFrame *_parent;
+	wxTextCtrl *_target;
+
+	virtual void OnTerminate(int pid, int status);
+    virtual bool HasInput();
+};
+
 class LocationDialog {
 public:
 	LocationDialog(wxTextCtrl *target, bool isFileChooser, wxString wildcard);
@@ -175,7 +219,6 @@
 	void OnCompressionTypeChange(wxCommandEvent &event);
 	void OnCompressionInputBrowse(wxCommandEvent &event);
 	void OnCompressionOutputBrowse(wxCommandEvent &event);
-	void OnCompressionStart(wxCommandEvent &event);
 
 	DECLARE_EVENT_TABLE()
 };
@@ -209,22 +252,7 @@
 	void OnExtractionInput1Browse(wxCommandEvent &event);
 	void OnExtractionInput2Browse(wxCommandEvent &event);
 	void OnExtractionOutputBrowse(wxCommandEvent &event);
-	void OnExtractionStart(wxCommandEvent &event);
 
 	DECLARE_EVENT_TABLE()
 };
 
-/* ----- Main Panel ----- */
-
-class MainFrame : public wxFrame {
-public:
-	MainFrame(const wxString& title);
-
-	wxNotebook *_mainNotebook;
-	CompressionPanel *_compressionTools;
-	ExtractionPanel *_extractionTools;
-
-	void OnCompressionOptionsToggle(wxCommandEvent &event);
-
-	DECLARE_EVENT_TABLE()
-};


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list