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

Remere at users.sourceforge.net Remere at users.sourceforge.net
Thu Jul 2 03:38:06 CEST 2009


Revision: 42016
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42016&view=rev
Author:   Remere
Date:     2009-07-02 01:38:06 +0000 (Thu, 02 Jul 2009)

Log Message:
-----------
*All main functions are now on the form int(int, char **)
*ProcessPage now calls the main function of the tool directly, instead of spawning a subprocess.

NOTE: Since input arguments are not saved yet, the tool will simply exit() once run, and make the tool leak a ton of memory. Set the value manually using a debugger to see the real output (which is hardly impressive yet, it's a work in progress)

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/compress.h
    tools/branches/gsoc2009-gui/compress_gob.cpp
    tools/branches/gsoc2009-gui/extract_gob_stk.cpp
    tools/branches/gsoc2009-gui/extract_kyra.cpp
    tools/branches/gsoc2009-gui/extract_loom_tg16.cpp
    tools/branches/gsoc2009-gui/extract_mm_apple.cpp
    tools/branches/gsoc2009-gui/extract_mm_c64.cpp
    tools/branches/gsoc2009-gui/extract_mm_nes.cpp
    tools/branches/gsoc2009-gui/extract_zak_c64.cpp
    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
    tools/branches/gsoc2009-gui/tool_entry_points.h

Modified: tools/branches/gsoc2009-gui/compress.h
===================================================================
--- tools/branches/gsoc2009-gui/compress.h	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/compress.h	2009-07-02 01:38:06 UTC (rev 42016)
@@ -67,7 +67,7 @@
 
 
 /*
- * Stuff which is in compress.c
+ * Stuff which is in compress.cpp
  */
 
 const extern char *tempEncoded;

Modified: tools/branches/gsoc2009-gui/compress_gob.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_gob.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/compress_gob.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -45,7 +45,7 @@
 
 byte *packData(byte *src, uint32 &size);
 
-int export_main(compress_gob)(int argc, char **argv) {
+int export_main(compress_gob)(int argc, char *argv[]) {
 	const char *helptext = "\nUsage: %s [-o <output> = out.stk] <input file>\n";
 
 	Chunk *chunks;

Modified: tools/branches/gsoc2009-gui/extract_gob_stk.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_gob_stk.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_gob_stk.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -43,7 +43,7 @@
 byte *unpackData(byte *src, uint32 &size);
 byte *unpackPreGobData(byte *src, uint32 &size, uint32 &compSize);
 
-int export_main(extract_gob_stk)(int argc, char **argv) {
+int export_main(extract_gob_stk)(int argc, char *argv[]) {
 	char signature[7];
 	Chunk *chunks;
 	FILE *stk;

Modified: tools/branches/gsoc2009-gui/extract_kyra.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_kyra.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_kyra.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -24,7 +24,7 @@
 #include "kyra_pak.h"
 #include "kyra_ins.h"
 
-int export_main(extract_kyra)(int argc, char **argv) {
+int export_main(extract_kyra)(int argc, char *argv[]) {
 	const char *helptext = "\n"
 		"Usage: %s [params] [-o output] <archivefile> [-o output]\n"
 		"Default output path is ./out/\n"

Modified: tools/branches/gsoc2009-gui/extract_loom_tg16.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_loom_tg16.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_loom_tg16.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -1224,7 +1224,7 @@
 	return CRC ^ 0xFFFFFFFF;
 }
 
-int export_main(extract_loom_tg16)(int argc, char **argv) {
+int export_main(extract_loom_tg16)(int argc, char *argv[]) {
 #ifdef MAKE_LFLS
 	FILE *input, *output;
 	int i, j;

Modified: tools/branches/gsoc2009-gui/extract_mm_apple.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_mm_apple.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_mm_apple.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -52,7 +52,7 @@
 	 3, 10,  1,  0,  0
 };
 
-int export_main(extract_mm_apple)(int argc, char **argv) {
+int export_main(extract_mm_apple)(int argc, char *argv[]) {
 	const char *helptext = "\nUsage: %s [-o <output dir> = out/] <disk1.dsk> <disk2.dsk>\n";
 
 	FILE *input1, *input2, *output;

Modified: tools/branches/gsoc2009-gui/extract_mm_c64.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_mm_c64.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_mm_c64.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -53,7 +53,7 @@
 	 3, 10,  1,  0,  0
 };
 
-int export_main(extract_mm_c64)(int argc, char **argv) {
+int export_main(extract_mm_c64)(int argc, char *argv[]) {
 	const char *helptext = "\nUsage: %s [-o <output dir> = out/] <disk1.d64> <disk2.d64>\n";
 	
 	FILE *input1, *input2, *output;

Modified: tools/branches/gsoc2009-gui/extract_mm_nes.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_mm_nes.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_mm_nes.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -1165,7 +1165,7 @@
 	return CRC ^ 0xFFFFFFFF;
 }
 
-int export_main(extract_mm_nes)(int argc, char **argv) {
+int export_main(extract_mm_nes)(int argc, char *argv[]) {
 	const char *helptext =
 		"\nUsage: %s [-o <output dir> = out/] <infile.PRG>\n"
 		"\tSupported versions: USA, Europe, Sweden, France, Germany, Spain\n"

Modified: tools/branches/gsoc2009-gui/extract_zak_c64.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_zak_c64.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/extract_zak_c64.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -53,7 +53,7 @@
 	 3,  1,  2,  1,  2,  1, 10,  1,  1
 };
 
-int export_main(extract_zak_c64)(int argc, char **argv) {
+int export_main(extract_zak_c64)(int argc, char *argv[]) {
 	const char *helptext = "\nUsage: %s [-o <output dir> = out/] <disk1.d64> <disk2.d64>\n";
 
 	FILE *input1, *input2, *output;

Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -827,15 +827,10 @@
 
 // Page to choose ANY tool to use
 
-BEGIN_EVENT_TABLE(ProcessPage, WizardPage)
-	EVT_END_PROCESS(wxID_ANY, ProcessPage::onTerminate)
-END_EVENT_TABLE()
-
 ProcessPage::ProcessPage(ScummToolsFrame* frame)
 	: WizardPage(frame),
-	  _finished(false),
 	  _success(false),
-	  _process(NULL)
+	  _finished(false)
 {
 }
 
@@ -855,123 +850,103 @@
 
 	panel->SetSizer(sizer);
 
-	// This should NOT be called from the 'constructor' (once it runs the subprocess)
-	runProcess(outwin);
+	// Run the tool
+	runTool(outwin);
 
 	return panel;
 }
 
-void ProcessPage::save(wxWindow *panel) {
-	//_configuration.selectedTool = 
-	//	g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
-}
-
-wxString ProcessPage::createCommandLine() {
-	wxString cli;
+std::pair<int, char **> ProcessPage::createCommandLine() {
 	Configuration &conf = _topframe->_configuration;
+
+	// Contruct the arguments in unicode mode first
+	wxArrayString cli;
+
+	cli.Add(conf.selectedTool->getExecutable());
 	
-	// Executable
-	cli << conf.selectedTool->getExecutable();
-	
 	// Audio format args
 	if(conf.compressing) {
-		cli << wxT(" --mp3");
+		cli.Add(wxT("--mp3"));
 		if(conf.selectedAudioFormat == AUDIO_VORBIS) {
-			cli << wxT(" --vorbis");
-			cli << wxT(" -b ") << conf.oggAvgBitrate;
-			cli << wxT(" -m ") << conf.oggMinBitrate;
-			cli << wxT(" -M ") << conf.oggMaxBitrate;
-			cli << wxT(" -q ") << conf.oggQuality;
+			cli.Add(wxT("--vorbis"));
+			cli.Add(wxT("-b"));
+			cli.Add(conf.oggAvgBitrate);
+			cli.Add(wxT("-m"));
+			cli.Add(conf.oggMinBitrate);
+			cli.Add(wxT("-M"));
+			cli.Add(conf.oggMaxBitrate);
+			cli.Add(wxT("-q"));
+			cli.Add(conf.oggQuality);
 		} else if(conf.selectedAudioFormat == AUDIO_FLAC) {
-			cli << wxT(" --flac");
-			cli << wxT(" -") << conf.flacCompressionLevel;
-			cli << wxT(" -b ")<< conf.flacBlockSize;
+			cli.Add(wxT("--flac"));
+			cli.Add(wxT("-"));
+			cli.Add(conf.flacCompressionLevel);
+			cli.Add(wxT("-b"));
+			cli.Add(conf.flacBlockSize);
 		} else if(conf.selectedAudioFormat == AUDIO_MP3) {
 			if(conf.mp3CompressionType == wxT("ABR")) {
-				cli << wxT(" --abr");
-				cli << wxT(" -b ") << conf.mp3ABRBitrate;
-				cli << wxT(" -b ") << conf.mp3VBRMinBitrate;
+				cli.Add(wxT("--abr"));
+				cli.Add(wxT("-b"));
+				cli.Add(conf.mp3ABRBitrate);
+				cli.Add(wxT("-b"));
+				cli.Add(conf.mp3VBRMinBitrate);
 			} else {
-				cli << wxT(" --vbr");
-				cli << wxT(" -b ") << conf.mp3VBRMinBitrate;
-				cli << wxT(" -B ") << conf.mp3VBRMaxBitrate;
+				cli.Add(wxT("--vbr"));
+				cli.Add(wxT("-b"));
+				cli.Add(conf.mp3VBRMinBitrate);
+				cli.Add(wxT("-B"));
+				cli.Add(conf.mp3VBRMaxBitrate);
 			}
-					
-			cli << wxT(" -q ") << conf.mp3MpegQuality;
+			
+			cli.Add(wxT("-q"));
+			cli.Add(conf.mp3MpegQuality);
 		}
 	}
 
-	cli << wxT(" -o ") << conf.outputPath;
-	for(wxArrayString::const_iterator i = conf.inputFilePaths.begin(); i != conf.inputFilePaths.end(); ++i)
-		cli << *i << wxT(" ");
+	cli.Add(wxT("-o"));
+	cli.Add(conf.outputPath);
+	for (wxArrayString::const_iterator iter = conf.inputFilePaths.begin(); iter != conf.inputFilePaths.end(); ++iter)
+		cli.Add(*iter);
 
-	cli << wxT("\n");
-	return cli;
+	// And now convert to a plain char * string
+	char **real_cli = new char *[cli.size()];
+	int i = 0;
+	for (wxArrayString::const_iterator iter = cli.begin(); iter != cli.end(); ++iter, ++i) {
+		const char *in = (const char *)iter->mb_str();
+		real_cli[i] = new char[strlen(in)];
+		strcpy(real_cli[i], in);
+	}
+
+	return std::make_pair(i, real_cli);
 }
 
-void ProcessPage::runProcess(wxTextCtrl *outwin) {
-	wxString cli = createCommandLine();
-	outwin->WriteText(cli + wxT("\n"));
+void ProcessPage::runTool(wxTextCtrl *outwin) {
+	// Build command line arguments...
+	std::pair<int, char **> cli = createCommandLine();
+	
+	// TODO
+	// Redirect output
 
-	if(wxFile::Exists(_topframe->_configuration.selectedTool->getExecutable())) {
-		_process = new wxProcess(this);
-		bool success = wxExecute(cli, wxEXEC_ASYNC, _process) != 0;
+	// Run the tool
+	int ret = _topframe->_configuration.selectedTool->invoke(cli.first, cli.second);
+	_finished = true;
+	_success = (ret == 0);
 
-		if(!success) {
-			outwin->WriteText(wxT("Could not run process."));
-			return;
-		}
-
-		_process->Redirect();
-	} else {
-		_finished = true;
-		outwin->WriteText(wxT("Subprocess exited successfully!"));
-		//outwin->WriteText(wxT("Could not find executable file on the current path. Check that the executable for the selected tool is available and place in the correct directory."));
+	// Free memory in use by the CLI args
+	for(int i = 0; i != cli.first; ++i) {
+		delete[] cli.second[i];
 	}
+	delete[] cli.second;
 
+	// Cancel output redirection
 }
 
 bool ProcessPage::onIdle(wxPanel *panel) {
-	if(_process) {
-		wxInputStream *stream = _process->GetInputStream();
-		wxTextCtrl *outwin = static_cast<wxTextCtrl *>(panel->FindWindowByName(wxT("OutputWindow")));
-
-		wxASSERT_MSG(stream, wxT("Could not bind input stream!"));
-
-		while(stream && stream->CanRead()) {
-			wxFileOffset off = stream->GetLength();
-			if(off == wxInvalidOffset) {
-				return false;
-			}
-			char *buf = new char[(size_t)off];
-			stream->Read(buf, (size_t)off);
-			outwin->WriteText(wxString(buf, wxConvUTF8, (size_t)off));
-			delete[] buf;
-		}
-
-		return true;
-	}
+	// TODO
+	// Possibly write stdout to outwin here?
 	return false;
 }
 
-void ProcessPage::onTerminate(wxProcessEvent &evt) {
-	// Ugly hack, should not find the panel this way...
-	wxWindow *panel = _topframe->FindWindowByName(wxT("WizardPage"));
-	wxTextCtrl *outwin = static_cast<wxTextCtrl *>(panel->FindWindowByName(wxT("OutputWindow")));
-
-	_success = evt.GetExitCode() == 0;
-	if(_success) {
-		outwin->WriteText(wxT("Subprocess exited sucessfully!"));
-	} else {
-		outwin->WriteText(wxT("Subprocess exited sucessfully!"));
-	}
-	_finished = true;
-	_process = NULL;
-
-	updateButtons(panel, static_cast<WizardButtons *>(_topframe->FindWindowByName(wxT("WizardButtonPanel"))));
-}
-
-
 void ProcessPage::onNext(wxWindow *panel) {
 	switchPage(new FinishPage(_topframe));
 }
@@ -1022,7 +997,7 @@
 	if(display->GetValue())
 		// Haven't found the function to do this yet...
 		//wxOpenExplorer(_topframe->_configuration.outputPath);
-		;
+		(void)0;
 	_topframe->Close(true);
 }
 

Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/gui/pages.h	2009-07-02 01:38:06 UTC (rev 42016)
@@ -308,28 +308,36 @@
 
 class ProcessPage : public WizardPage
 {
+	/** True if the tool exited with success */
+	bool _success;
+	/** True if the tool has exited */
 	bool _finished;
-	bool _success;
-	wxProcess *_process;
 public:
 	ProcessPage(ScummToolsFrame* frame);
 
 	wxWindow *CreatePanel(wxWindow *parent);
 
-	wxString createCommandLine();
-	void runProcess(wxTextCtrl *outwin);
+	/**
+	 * Creates a list of command line arguments
+	 * The list is allocated, and needed to be looped through and delete[] ed
+	 * and then the list itself delete[]ed
+	 *
+	 * @return A pair containing number of args, and the list of CLI args themselves
+	 */
+	std::pair<int, char **> createCommandLine();
 
-	void onTerminate(wxProcessEvent &evt);
+	/**
+	 * Runs the specified tool, output will be put in outwin
+	 *
+	 * @param outwin Text control to redirect output to
+	 */
+	void runTool(wxTextCtrl *outwin);
 
 	bool onIdle(wxPanel *panel);
 
 	void onNext(wxWindow *panel);
 
 	void updateButtons(wxWindow *panel, WizardButtons *buttons);
-
-	void save(wxWindow *panel);
-
-	DECLARE_EVENT_TABLE()
 };
 
 /**

Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-02 01:38:06 UTC (rev 42016)
@@ -41,17 +41,17 @@
 	// Compression tools
 
 	// Compress agos also has a --mac parameter, need to add an additional page / option for this
-	Tool compress_agos(wxT("compress_agos"), wxT("*."));
+	Tool compress_agos(wxT("compress_agos"), main_compress_agos, wxT("*."));
 	compress_agos.addGame(wxT("Feeble Files")),
 	compress_agos.addGame(wxT("Simon the Sorcerer I/II")),
 	addTool(compress_agos);
 
 	// compress_gob
-	Tool compress_gob(wxT("compress_gob"), wxT("*.*"));
+	Tool compress_gob(wxT("compress_gob"), main_compress_gob, wxT("*.*"));
 	addTool(compress_gob);
 
 	// compress_kyra
-	Tool compress_kyra(wxT("compress_kyra"), wxT("*.*"));
+	Tool compress_kyra(wxT("compress_kyra"), main_compress_kyra, wxT("*.*"));
 	compress_kyra.addGame(wxT("The Legend of Kyrandia")),
 	compress_kyra.addGame(wxT("The Legend of Kyrandia: Hand of Fate")),
 	compress_kyra.addGame(wxT("The Legend of Kyrandia: Malcolm's Revenge")),
@@ -59,67 +59,67 @@
 	addTool(compress_kyra);
 
 	// compress_queen
-	Tool compress_queen(wxT("compress_queen"), wxT("queen.1"));
+	Tool compress_queen(wxT("compress_queen"), main_compress_queen, wxT("queen.1"));
 	compress_queen.addGame(wxT("Flight of the Amazon Queen")),
 	addTool(compress_queen);
 
 	// compress_saga
-	Tool compress_saga(wxT("compress_saga"), wxT("*.*"));
+	Tool compress_saga(wxT("compress_saga"), main_compress_saga, wxT("*.*"));
 	compress_saga.addGame(wxT("SAGA: Inherit The Earth")),
 	compress_saga.addGame(wxT("I Have No Mouth and I Must Scream")),
 	addTool(compress_saga);
 
 	// compress_scumm_bun
-	Tool compress_scumm_bun(wxT("compress_scumm_bun"), wxT("*.*"));
+	Tool compress_scumm_bun(wxT("compress_scumm_bun"), main_compress_scumm_bun,  wxT("*.*"));
 	compress_scumm_bun.addGame(wxT("The Secret of Monkey Island")),
 	compress_scumm_bun.addGame(wxT("Monkey Island 2: LeChuck's Revenge")),
 	compress_scumm_bun.addGame(wxT("The Curse of Monkey Island")),
 	addTool(compress_scumm_bun);
 
 	// compress_scumm_san
-	Tool compress_scumm_san(wxT("compress_scumm_san"), wxT("*.*"));
+	Tool compress_scumm_san(wxT("compress_scumm_san"), main_compress_scumm_san, wxT("*.*"));
 	// Unsure of exact games...
 	addTool(compress_scumm_san);
 
 	// compress_scumm_sou
-	Tool compress_scumm_sou(wxT("compress_scumm_san"), wxT("*.*"));
+	Tool compress_scumm_sou(wxT("compress_scumm_sou"), main_compress_scumm_sou, wxT("*.*"));
 	// Unsure of exact games...
 	addTool(compress_scumm_sou);
 
 	// compress_sword1
-	Tool compress_sword1(wxT("compress_sword1"), wxT("*.*"));
+	Tool compress_sword1(wxT("compress_sword1"), main_compress_sword1, wxT("*.*"));
 	compress_sword1.addGame(wxT("Broken Sword 1")),
 	addTool(compress_sword1);
 
 	// compress_sword2
-	Tool compress_sword2(wxT("compress_sword2"), wxT("*.*"));
+	Tool compress_sword2(wxT("compress_sword2"), main_compress_sword2, wxT("*.*"));
 	compress_sword2.addGame(wxT("Broken Sword 2")),
 	addTool(compress_sword2);
 
 	// compress_touche
-	Tool compress_touche(wxT("compress_touche"), wxT("*.*"));
+	Tool compress_touche(wxT("compress_touche"), main_compress_touche, wxT("*.*"));
 	compress_touche.addGame(wxT("Touche: The Adventures of the Fifth Musketeer")),
 	addTool(compress_touche);
 
 	// compress_tucker
-	Tool compress_tucker(wxT("compress_tucker"), wxT("*.*"));
+	Tool compress_tucker(wxT("compress_tucker"), main_compress_tucker, wxT("*.*"));
 	compress_tucker.addGame(wxT("Bud Tucker in Double Trouble")),
 	addTool(compress_tucker);
 
 	// Extraction tools
 
 	// Compress agos also has a --mac parameter, need to add an additional page / option for this
-	Tool extract_agos(wxT("extract_agos"), wxT("*."));
+	Tool extract_agos(wxT("extract_agos"), main_extract_agos, wxT("*."));
 	extract_agos.addGame(wxT("Feeble Files")),
 	extract_agos.addGame(wxT("Simon the Sorcerer I/II")),
 	addTool(extract_agos);
 
 	// extract_gob_stk
-	Tool extract_gob_stk(wxT("extract_gob_stk"), wxT("*.*"));
+	Tool extract_gob_stk(wxT("extract_gob_stk"), main_extract_gob_stk, wxT("*.*"));
 	addTool(extract_gob_stk);
 
 	// extract_kyra
-	Tool extract_kyra(wxT("extract_kyra"), wxT("*.*"));
+	Tool extract_kyra(wxT("extract_kyra"), main_extract_kyra, wxT("*.*"));
 	extract_kyra.addGame(wxT("The Legend of Kyrandia")),
 	extract_kyra.addGame(wxT("The Legend of Kyrandia: Hand of Fate")),
 	extract_kyra.addGame(wxT("The Legend of Kyrandia: Malcolm's Revenge")),
@@ -127,38 +127,38 @@
 	addTool(extract_kyra);
 
 	// extract_loom_tg16
-	Tool extract_loom_tg16(wxT("extract_loom_tg16"), wxT("*.iso")); // Unsure of extension?
+	Tool extract_loom_tg16(wxT("extract_loom_tg16"), main_extract_loom_tg16, wxT("*.iso")); // Unsure of extension?
 	extract_loom_tg16.addGame(wxT("Loom")),
 	addTool(extract_loom_tg16);
 
 	// extract_mm_apple
-	Tool extract_mm_apple(wxT("extract_mm_apple"), wxT("*.dsk"));
+	Tool extract_mm_apple(wxT("extract_mm_apple"), main_extract_mm_apple, wxT("*.dsk"));
 	extract_mm_apple.addGame(wxT("Maniac Mansion (Apple)")),
 	addTool(extract_mm_apple);
 
 	// extract_mm_nes
-	Tool extract_mm_c64(wxT("extract_mm_c64"), wxT("*.d64"));
+	Tool extract_mm_c64(wxT("extract_mm_c64"), main_extract_mm_c64, wxT("*.d64"));
 	extract_mm_c64.addGame(wxT("Maniac Mansion (Commodore 64)")),
 	addTool(extract_mm_c64);
 
 	// extract_mm_nes
-	Tool extract_mm_nes(wxT("extract_mm_nes"), wxT("*.PRG"));
+	Tool extract_mm_nes(wxT("extract_mm_nes"), main_extract_mm_nes, wxT("*.PRG"));
 	extract_mm_nes.addGame(wxT("Maniac Mansion (NES)")),
 	addTool(extract_mm_nes);
 
 	// extract_sword2
-	Tool extract_parallaction(wxT("extract_parallaction"), wxT("*.*"));
+	Tool extract_parallaction(wxT("extract_parallaction"), main_extract_parallaction, wxT("*.*"));
 	extract_parallaction.addGame(wxT("Parallaction")),
 	addTool(extract_parallaction);
 
 	// extract_scumm_mac
-	Tool extract_scumm_mac(wxT("extract_scumm_mac"));
+	Tool extract_scumm_mac(wxT("extract_scumm_mac"), main_extract_scumm_mac);
 	// Required for alot of games, but as ScummVM 0.6 + can read 
 	// these files natively, it can remain an advanced option
 	addTool(extract_scumm_mac);
 
 	// extract_zak_c64
-	Tool extract_zak_c64(wxT("extract_zak_c64"), wxT(".d64"));
+	Tool extract_zak_c64(wxT("extract_zak_c64"), main_extract_zak_c64, wxT(".d64"));
 	extract_zak_c64.addGame(wxT("Bud Tucker in Double Trouble")),
 	addTool(extract_zak_c64);
 }
@@ -222,8 +222,9 @@
 	//wxLogError(wxT("Created empty tool, should never happened."));
 }
 
-Tool::Tool(wxString name, wxString input_extensions) {
+Tool::Tool(wxString name, MainFunction main, wxString input_extensions) {
 	_name = name;
+	invoke = main;
 
 	if(name.Find(wxT("extract")) != wxNOT_FOUND)
 		_type = TOOLTYPE_EXTRACTION;

Modified: tools/branches/gsoc2009-gui/gui/tools.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.h	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/gui/tools.h	2009-07-02 01:38:06 UTC (rev 42016)
@@ -29,6 +29,7 @@
 #include <vector>
 
 #include "configuration.h"
+#include "../tool_entry_points.h"
 
 
 /** Different types of tools, used to differentiate them when 
@@ -73,9 +74,10 @@
 	 * you must set the type manually.
 	 *
 	 * @param name The name of the tool, should match the executable name (without the extension)
+	 * @param main The tool entry point, defined in tool_entry_point.h
 	 * @param input_extenion Filename filter of the input  to expect.
 	 */
-	Tool(wxString name, wxString input_extension = wxT("*.*"));
+	Tool(wxString name, MainFunction main, wxString input_extension = wxT("*.*"));
 
 	/**
 	 * Adds a supported game to this tool
@@ -101,6 +103,8 @@
 
 	/** Name of the tool */
 	wxString _name;
+	/** Entry point of the tool, for invoking it, accepts CLI in the same format as the classic main function */
+	MainFunction invoke;
 	/** Type of tool, either extract, compress or unknown */
 	ToolType _type;
 	/* Formats supported by the tool, bitwise ORed */

Modified: tools/branches/gsoc2009-gui/tool_entry_points.h
===================================================================
--- tools/branches/gsoc2009-gui/tool_entry_points.h	2009-07-01 23:46:13 UTC (rev 42015)
+++ tools/branches/gsoc2009-gui/tool_entry_points.h	2009-07-02 01:38:06 UTC (rev 42016)
@@ -23,32 +23,32 @@
 #ifndef TOOL_ENTRY_POINTS_H
 #define TOOL_ENTRY_POINTS_H
 
-typedef int (MainFunction*)(int argc, char **argv);
+typedef int (*MainFunction)(int argc, char *argv[]);
 #define import_main(tool_name) main_ ## tool_name
 
-extern int import_main(compress_agos)(int argc, char **argv);
-extern int import_main(compress_gob)(int argc, char **argv);
-extern int import_main(compress_kyra)(int argc, char **argv);
-extern int import_main(compress_queen)(int argc, char **argv);
-extern int import_main(compress_saga)(int argc, char **argv);
-extern int import_main(compress_scumm_bun)(int argc, char **argv);
-extern int import_main(compress_scumm_san)(int argc, char **argv);
-extern int import_main(compress_scumm_sou)(int argc, char **argv);
-extern int import_main(compress_sword1)(int argc, char **argv);
-extern int import_main(compress_sword2)(int argc, char **argv);
-extern int import_main(compress_touche)(int argc, char **argv);
-extern int import_main(compress_tucker)(int argc, char **argv);
-extern int import_main(encode_dxa)(int argc, char **argv);
-extern int import_main(extract_agos)(int argc, char **argv);
-extern int import_main(extract_gob_stk)(int argc, char **argv);
-extern int import_main(extract_kyra)(int argc, char **argv);
-extern int import_main(extract_loom_tg16)(int argc, char **argv);
-extern int import_main(extract_mm_apple)(int argc, char **argv);
-extern int import_main(extract_mm_c64)(int argc, char **argv);
-extern int import_main(extract_mm_nes)(int argc, char **argv);
-extern int import_main(extract_parallaction)(int argc, char **argv);
-extern int import_main(extract_scumm_mac)(int argc, char **argv);
-extern int import_main(extract_zak_c64)(int argc, char **argv);
+extern int import_main(compress_agos)(int argc, char *argv[]);
+extern int import_main(compress_gob)(int argc, char *argv[]);
+extern int import_main(compress_kyra)(int argc, char *argv[]);
+extern int import_main(compress_queen)(int argc, char *argv[]);
+extern int import_main(compress_saga)(int argc, char *argv[]);
+extern int import_main(compress_scumm_bun)(int argc, char *argv[]);
+extern int import_main(compress_scumm_san)(int argc, char *argv[]);
+extern int import_main(compress_scumm_sou)(int argc, char *argv[]);
+extern int import_main(compress_sword1)(int argc, char *argv[]);
+extern int import_main(compress_sword2)(int argc, char *argv[]);
+extern int import_main(compress_touche)(int argc, char *argv[]);
+extern int import_main(compress_tucker)(int argc, char *argv[]);
+extern int import_main(encode_dxa)(int argc, char *argv[]);
+extern int import_main(extract_agos)(int argc, char *argv[]);
+extern int import_main(extract_gob_stk)(int argc, char *argv[]);
+extern int import_main(extract_kyra)(int argc, char *argv[]);
+extern int import_main(extract_loom_tg16)(int argc, char *argv[]);
+extern int import_main(extract_mm_apple)(int argc, char *argv[]);
+extern int import_main(extract_mm_c64)(int argc, char *argv[]);
+extern int import_main(extract_mm_nes)(int argc, char *argv[]);
+extern int import_main(extract_parallaction)(int argc, char *argv[]);
+extern int import_main(extract_scumm_mac)(int argc, char *argv[]);
+extern int import_main(extract_zak_c64)(int argc, char *argv[]);
 
 #endif
 


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