[Scummvm-cvs-logs] SF.net SVN: scummvm:[42109] tools/branches/gsoc2009-gui/gui

Remere at users.sourceforge.net Remere at users.sourceforge.net
Sat Jul 4 22:04:44 CEST 2009


Revision: 42109
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42109&view=rev
Author:   Remere
Date:     2009-07-04 20:04:43 +0000 (Sat, 04 Jul 2009)

Log Message:
-----------
*GUI now runs the tool, displaying proper output to the text window. Only supports the three C++ tools now (compress_agos, extract_gob_stk, compress_gob), you have to use advanced mode for now.

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/gui/pages.cpp
    tools/branches/gsoc2009-gui/gui/pages.h
    tools/branches/gsoc2009-gui/gui/tools.cpp
    tools/branches/gsoc2009-gui/gui/tools.h

Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp	2009-07-04 20:03:12 UTC (rev 42108)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-07-04 20:04:43 UTC (rev 42109)
@@ -387,6 +387,8 @@
 
 	const ToolGUI &tool = *_configuration.selectedTool;
 
+	_configuration.inputFilePaths.clear();
+
 	int i = 1;
 	for (ToolInputs::const_iterator iter = tool._inputs.begin(); iter != tool._inputs.end(); ++iter) {
 		const ToolInput &input = *iter;
@@ -861,7 +863,7 @@
 
 	sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Processing data...")), wxSizerFlags().Expand().Border(wxLEFT, 20));
 	
-	wxTextCtrl *outwin = new wxTextCtrl(panel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 
+	outwin = new wxTextCtrl(panel, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 
 		wxTE_MULTILINE | wxTE_READONLY, wxDefaultValidator, wxT("OutputWindow"));
 	outwin->Enable(false);
 	sizer->Add(outwin, wxSizerFlags(1).Expand().Border(wxALL, 10));
@@ -869,21 +871,22 @@
 	panel->SetSizer(sizer);
 
 	// Run the tool
-	runTool(outwin);
+	runTool();
 
 	return panel;
 }
 
 void ProcessPage::writeToOutput(void *udata, const char *text) {
-	wxTextCtrl *outwin = reinterpret_cast<wxTextCtrl *>(udata);
-	outwin->WriteText(wxString(text, wxConvUTF8));
+	ProcessPage *self = reinterpret_cast<ProcessPage *>(udata);
+
+	self->outwin->WriteText(wxString(text, wxConvUTF8));
 }
 
-void ProcessPage::runTool(wxTextCtrl *outwin) {
+void ProcessPage::runTool() {
 	const ToolGUI *tool = _topframe->_configuration.selectedTool;
-	tool->_backend->setPrintFunction(writeToOutput, reinterpret_cast<void *>(outwin));
+	tool->_backend->setPrintFunction(writeToOutput, reinterpret_cast<void *>(this));
 	try {
-		tool->run();
+		tool->run(_topframe->_configuration);
 		_success = true;
 	} catch(std::exception &err) {
 		outwin->WriteText(wxString(err.what(), wxConvUTF8));

Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h	2009-07-04 20:03:12 UTC (rev 42108)
+++ tools/branches/gsoc2009-gui/gui/pages.h	2009-07-04 20:04:43 UTC (rev 42109)
@@ -302,8 +302,8 @@
 
 /**
  * Runs the subprocess and displays it's output to the user
- * You really ought to only run one subprocess at the time, as
- * this class keeps internal state.
+ * You can only create one panel from this, unlike the other pages
+ * as the class keeps internal state
  */
 
 class ProcessPage : public WizardPage
@@ -312,6 +312,8 @@
 	bool _success;
 	/** True if the tool has exited */
 	bool _finished;
+	/** Output window */
+	wxTextCtrl *outwin;
 public:
 	ProcessPage(ScummToolsFrame* frame);
 
@@ -327,7 +329,7 @@
 	 *
 	 * @param outwin Text control to redirect output to
 	 */
-	void runTool(wxTextCtrl *outwin);
+	void runTool();
 
 	bool onIdle(wxPanel *panel);
 

Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-04 20:03:12 UTC (rev 42108)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-04 20:04:43 UTC (rev 42109)
@@ -35,6 +35,7 @@
 #include "tools.h"
 
 // Include all tools
+#include "../compress_agos.h"
 #include "../extract_agos.h"
 #include "../extract_gob_stk.h"
 
@@ -48,6 +49,9 @@
 void Tools::init() {
 
 	// Compress agos also has a --mac parameter, need to add an additional page / option for this
+	addTool(new ToolGUI(new CompressAgos()));
+
+	// extract_agos
 	addTool(new ToolGUI(new ExtractAgos()));
 
 	// extract_gob_stk
@@ -256,6 +260,10 @@
 	_inoutHelpText = wxT("Output files produced by the tool will be put in this directory.");
 }
 
+ToolGUI::~ToolGUI() {
+	delete _backend;
+}
+
 void ToolGUI::addGame(const wxString &game_name) {
 	_games.Add(game_name);
 }
@@ -268,7 +276,13 @@
 	return _backend->_outputToDirectory;
 }
 
-void ToolGUI::run() const {
+void ToolGUI::run(const Configuration &conf) const {
+	_backend->_inputPaths.clear();
+	for(wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter)
+		_backend->_inputPaths.push_back((const char *)iter->mb_str());
+	_backend->_outputPath = std::string(conf.outputPath.mb_str());
+
+	_backend->run();
 }
 
 wxString ToolGUI::getExecutable() const {

Modified: tools/branches/gsoc2009-gui/gui/tools.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.h	2009-07-04 20:03:12 UTC (rev 42108)
+++ tools/branches/gsoc2009-gui/gui/tools.h	2009-07-04 20:04:43 UTC (rev 42109)
@@ -81,6 +81,7 @@
 	 * @param input_extenion Filename filter of the input  to expect.
 	 */
 	ToolGUI(Tool *tool, wxString input_extension = wxT("*.*"));
+	~ToolGUI();
 
 	/**
 	 * Adds a supported game to this tool
@@ -112,7 +113,7 @@
 	/**
 	 * Runs the actual tool, will throw errors if it fails
 	 */
-	void run() const;
+	void run(const Configuration &conf) const;
 
 
 	/** Name of the tool */


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