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

Remere at users.sourceforge.net Remere at users.sourceforge.net
Thu Jul 9 00:54:18 CEST 2009


Revision: 42272
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42272&view=rev
Author:   Remere
Date:     2009-07-08 22:54:18 +0000 (Wed, 08 Jul 2009)

Log Message:
-----------
*Changed the pages so that you first select the input files, let some (yet to be coded) heuristic decide what tool to use and then select additional input / go directly to output. In advanced mode, you first select the tool, then input files.

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-08 21:12:03 UTC (rev 42271)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-07-08 22:54:18 UTC (rev 42272)
@@ -110,7 +110,7 @@
 	sizer->Add(new wxStaticText(panel, wxID_ANY, 
 		wxT("Welcome to the ScummVM extraction and compression utility.")));
 	sizer->Add(new wxStaticText(panel, wxID_ANY,
-		wxT("Please select what you want to do, or drop a file or folder on this window for automatic .")));
+		wxT("Please select what you want to do, or drop a file or folder on this window for automatic detection.")));
 	
 	wxString choices[] = {
 		wxT("Extract from game data files"),
@@ -152,152 +152,152 @@
 
 void IntroPage::onNext(wxWindow *panel) {
 	wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("ChooseActivity")))->GetStringSelection().Lower();
-	if (selected_option.Find(wxT("extract")) != wxNOT_FOUND) {
-		// extract
-		switchPage(new ChooseExtractionPage(_topframe));
-	} else if (selected_option.Find(wxT("advanced")) != wxNOT_FOUND) {
+	if (selected_option.Find(wxT("advanced")) != wxNOT_FOUND) {
 		// advanced
 		switchPage(new ChooseToolPage(_topframe));
 	} else {
-		// compress
-		switchPage(new ChooseCompressionPage(_topframe));
+		// extract / compress
+		switchPage(new ChooseInPage(_topframe));
 	}
 }
 
-// Page to choose what game files to compress
+// Page to choose the tool to use
 
-ChooseCompressionPage::ChooseCompressionPage(ScummToolsFrame* frame)
-	: WizardPage(frame)
+ChooseToolPage::ChooseToolPage(ScummToolsFrame* frame, const wxArrayString &options)
+	: WizardPage(frame),
+	  _options(options)
 {
 }
 
-wxWindow *ChooseCompressionPage::CreatePanel(wxWindow *parent) {
+wxWindow *ChooseToolPage::CreatePanel(wxWindow *parent) {
 	wxWindow *panel = WizardPage::CreatePanel(parent);
 
 	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
 
 	sizer->AddSpacer(15);
 
-	sizer->Add(new wxStaticText(panel, wxID_ANY, 
-		wxT("Please select for what game/engine you'd like to compress files.")));
-	
-	wxArrayString choices = g_tools.getGameList(TOOLTYPE_COMPRESSION);
+	wxArrayString choices;
 
-	wxChoice *game = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
-		choices, 0, wxDefaultValidator, wxT("GameSelection"));
-	sizer->Add(game);
-	game->SetSelection(0);
+	if(_options.size()) {
+		sizer->Add(new wxStaticText(panel, wxID_ANY, 
+			wxT("There are multiple possible tools for this input, please select the correct one.")));
+		choices = _options;
+	} else {
+		sizer->Add(new wxStaticText(panel, wxID_ANY, 
+			wxT("Select what tool you'd like to use.")));
+		choices = g_tools.getToolList(TOOLTYPE_ALL);
+	}
 
+	wxChoice *tool = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
+		choices, 0, wxDefaultValidator, wxT("ToolSelection"));
+	sizer->Add(tool);
+	tool->SetSelection(0);
+
 	SetAlignedSizer(panel, sizer);
 
-	// Load already set values
-	game->SetStringSelection(_configuration.selectedGame);
+	// Load configuration
+	if (_configuration.selectedTool != NULL)
+		tool->SetStringSelection(_configuration.selectedTool->_name);
 
-
 	return panel;
 }
 
-void ChooseCompressionPage::save(wxWindow *panel) {
-	wxString game = static_cast<wxChoice *>(panel->FindWindowByName(wxT("GameSelection")))->GetStringSelection();
-	_configuration.selectedGame = game;
-	_configuration.selectedTool = g_tools.getByGame(game, TOOLTYPE_COMPRESSION);
+void ChooseToolPage::save(wxWindow *panel) {
+	_configuration.selectedTool = 
+		g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
 }
 
-void ChooseCompressionPage::onNext(wxWindow *panel) {
-	switchPage(new ChooseInOutPage(_topframe));
+void ChooseToolPage::onNext(wxWindow *panel) {
+	if(_configuration.advanced)
+		switchPage(new ChooseInPage(_topframe));
+	else
+		// TODO: Display extra input page
+		switchPage(new ChooseOutPage(_topframe));
 }
 
-// Page to choose what game files to extract, 
-// VERY similar to the above, could be made into one class?
+// Page to choose input directory or file
 
-ChooseExtractionPage::ChooseExtractionPage(ScummToolsFrame* frame)
+ChooseInPage::ChooseInPage(ScummToolsFrame* frame)
 	: WizardPage(frame)
 {
 }
 
-wxWindow *ChooseExtractionPage::CreatePanel(wxWindow *parent) {
+wxWindow *ChooseInPage::CreatePanel(wxWindow *parent) {
 	wxWindow *panel = WizardPage::CreatePanel(parent);
 
 	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
 
 	sizer->AddSpacer(15);
-
-	sizer->Add(new wxStaticText(panel, wxID_ANY, 
-		wxT("Please select for what game/engine you'd like to extract files from.")));
 	
-	wxArrayString choices = g_tools.getGameList(TOOLTYPE_EXTRACTION);
+	// some help perhaps?
+	sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Select an input file")));
 
-	wxChoice *game = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
-		choices, 0, wxDefaultValidator, wxT("GameSelection"));
-	sizer->Add(game);
-	game->SetSelection(0);
+	sizer->AddSpacer(10);
 
-	SetAlignedSizer(panel, sizer);
+	// Create input selection
+	wxStaticBoxSizer *inputbox = new wxStaticBoxSizer(wxVERTICAL, panel, wxT("Input file"));
 
-	// Load already set values
-	game->SetStringSelection(_configuration.selectedGame);
 
+	//if (input._file) {
+		inputbox->Add(new wxFilePickerCtrl(
+				panel, wxID_ANY, wxEmptyString, wxT("Select a file"), 
+				wxT("*.*"), 
+				wxDefaultPosition, wxDefaultSize, 
+				wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator, 
+				wxT("InputPicker")),
+			wxSizerFlags().Expand());
+	/* 
+	// TODO: There is no way to select directory input, yet
+	} else {
+		inputbox->Add(new wxDirPickerCtrl(
+				panel, wxID_ANY, wxEmptyString, wxT("Select a folder"), 
+				wxDefaultPosition, wxDefaultSize, 
+				wxFLP_USE_TEXTCTRL | wxFLP_OPEN, wxDefaultValidator, 
+				wxT("InputPicker")),
+			wxSizerFlags().Expand());
+	
+	}
+	*/
+	
+	sizer->Add(inputbox, wxSizerFlags().Expand());
+	
+	SetAlignedSizer(panel, sizer);
+	
 	return panel;
 }
 
-void ChooseExtractionPage::save(wxWindow *panel) {
-	wxString game = static_cast<wxChoice *>(panel->FindWindowByName(wxT("GameSelection")))->GetStringSelection();
-	_configuration.selectedTool = g_tools.getByGame(game, TOOLTYPE_EXTRACTION);
-}
+void ChooseInPage::save(wxWindow *panel) {
+	wxWindow *outputWindow = panel->FindWindowByName(wxT("OutputPicker"));
+	wxDirPickerCtrl *outDirWindow = dynamic_cast<wxDirPickerCtrl *>(outputWindow);
+	wxFilePickerCtrl *outFileWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
 
-void ChooseExtractionPage::onNext(wxWindow *panel) {
-	switchPage(new ChooseInOutPage(_topframe));
-}
+	_configuration.inputFilePaths.clear();
 
-// Page to choose ANY tool to use
+	wxDirPickerCtrl *inDirWindow = dynamic_cast<wxDirPickerCtrl *>(panel->FindWindowByName(wxT("InputPicker")));
+	wxFilePickerCtrl *inFileWindow = dynamic_cast<wxFilePickerCtrl *>(panel->FindWindowByName(wxT("InputPicker")));
 
-ChooseToolPage::ChooseToolPage(ScummToolsFrame* frame)
-	: WizardPage(frame)
-{
+	if (inDirWindow)
+		_configuration.inputFilePaths.Add(inDirWindow ->GetPath());
+	if (inFileWindow)
+		_configuration.inputFilePaths.Add(inFileWindow->GetPath());
 }
 
-wxWindow *ChooseToolPage::CreatePanel(wxWindow *parent) {
-	wxWindow *panel = WizardPage::CreatePanel(parent);
-
-	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-
-	sizer->AddSpacer(15);
-
-	sizer->Add(new wxStaticText(panel, wxID_ANY, 
-		wxT("Select what tool you'd like to use.")));
-	wxArrayString choices = g_tools.getToolList(TOOLTYPE_ALL);
-
-	wxChoice *tool = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
-		choices, 0, wxDefaultValidator, wxT("ToolSelection"));
-	sizer->Add(tool);
-	tool->SetSelection(0);
-
-	SetAlignedSizer(panel, sizer);
-
-	// Load configuration
-	if (_configuration.selectedTool != NULL)
-		tool->SetStringSelection(_configuration.selectedTool->_name);
-
-	return panel;
+void ChooseInPage::onNext(wxWindow *panel) {
+	if(_configuration.advanced)
+		// TODO: Display extra input page
+		switchPage(new ChooseOutPage(_topframe));
+	else
+		switchPage(new ChooseToolPage(_topframe, g_tools.getToolList()));
 }
 
-void ChooseToolPage::save(wxWindow *panel) {
-	_configuration.selectedTool = 
-		g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
-}
-
-void ChooseToolPage::onNext(wxWindow *panel) {
-	switchPage(new ChooseInOutPage(_topframe));
-}
-
 // Page to choose input and output directory or file
 
-ChooseInOutPage::ChooseInOutPage(ScummToolsFrame* frame)
+ChooseExtraInPage::ChooseExtraInPage(ScummToolsFrame* frame)
 	: WizardPage(frame)
 {
 }
 
-wxWindow *ChooseInOutPage::CreatePanel(wxWindow *parent) {
+wxWindow *ChooseExtraInPage::CreatePanel(wxWindow *parent) {
 	wxWindow *panel = WizardPage::CreatePanel(parent);
 
 	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
@@ -307,7 +307,7 @@
 	const ToolGUI &tool = *_configuration.selectedTool;
 
 	// some help perhaps?
-	sizer->Add(new wxStaticText(panel, wxID_ANY, tool._inoutHelpText));
+	sizer->Add(new wxStaticText(panel, wxID_ANY, tool._inHelpText));
 
 	sizer->AddSpacer(10);
 
@@ -315,7 +315,8 @@
 	wxStaticBoxSizer *inputbox = new wxStaticBoxSizer(wxVERTICAL, panel, wxT("Input files"));
 
 	int i = 1;
-	for (ToolInputs::const_iterator iter = tool._inputs.begin(); iter != tool._inputs.end(); ++iter) {
+	wxASSERT_MSG(tool._inputs.size() > 1, wxT("Extra input page should not display with only one input"));
+	for (ToolInputs::const_iterator iter = tool._inputs.begin() + 1; iter != tool._inputs.end(); ++iter) {
 		const ToolInput &input = *iter;
 
 		wxString windowName = wxT("InputPicker");
@@ -342,7 +343,69 @@
 	
 	sizer->Add(inputbox, wxSizerFlags().Expand());
 
+	SetAlignedSizer(panel, sizer);
 
+	return panel;
+}
+
+void ChooseExtraInPage::save(wxWindow *panel) {
+	wxWindow *outputWindow = panel->FindWindowByName(wxT("OutputPicker"));
+	wxDirPickerCtrl *outDirWindow = dynamic_cast<wxDirPickerCtrl *>(outputWindow);
+	wxFilePickerCtrl *outFileWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
+
+	if (outDirWindow)
+		_configuration.outputPath = outDirWindow->GetPath();
+	if (outFileWindow)
+		_configuration.outputPath = outFileWindow->GetPath();
+
+	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;
+
+		wxString windowName = wxT("InputPicker");
+		windowName << i;
+
+		wxDirPickerCtrl *inDirWindow = dynamic_cast<wxDirPickerCtrl *>(panel->FindWindowByName(windowName));
+		wxFilePickerCtrl *inFileWindow = dynamic_cast<wxFilePickerCtrl *>(panel->FindWindowByName(windowName));
+
+		if (inDirWindow)
+			_configuration.inputFilePaths.Add(inDirWindow ->GetPath());
+		if (inFileWindow)
+			_configuration.inputFilePaths.Add(inFileWindow->GetPath());
+
+		++i;
+	}
+}
+
+void ChooseExtraInPage::onNext(wxWindow *panel) {
+	switchPage(new ChooseOutPage(_topframe));
+}
+
+// Page to choose input and output directory or file
+
+ChooseOutPage::ChooseOutPage(ScummToolsFrame* frame)
+	: WizardPage(frame)
+{
+}
+
+wxWindow *ChooseOutPage::CreatePanel(wxWindow *parent) {
+	wxWindow *panel = WizardPage::CreatePanel(parent);
+
+	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+	sizer->AddSpacer(15);
+	
+	const ToolGUI &tool = *_configuration.selectedTool;
+
+	// some help perhaps?
+	sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Select output directory / file")));
+
+	// Create input selection	
+
 	sizer->AddSpacer(10);
 
 	// Create output selection
@@ -354,18 +417,18 @@
 			panel, wxID_ANY, _configuration.outputPath, wxT("Select a folder"), 
 			wxDefaultPosition, wxDefaultSize, 
 			wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator, 
-			wxT("OutputPicker")), wxSizerFlags(1).Expand());
+			wxT("OutputPicker")));
 
 		sizer->Add(box, wxSizerFlags().Expand());
 	} else {
 		wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination file"));
 
-		sizer->Add(new wxFilePickerCtrl(
+		box->Add(new wxFilePickerCtrl(
 			panel, wxID_ANY, _configuration.outputPath, wxT("Select a file"), 
 			wxT("*.*"),
 			wxDefaultPosition, wxDefaultSize, 
 			wxFLP_USE_TEXTCTRL | wxFLP_OVERWRITE_PROMPT | wxFLP_SAVE, wxDefaultValidator, 
-			wxT("OutputPicker")), wxSizerFlags(1).Expand());
+			wxT("OutputPicker")));
 		
 		sizer->Add(box, wxSizerFlags().Expand());
 	}
@@ -375,7 +438,7 @@
 	return panel;
 }
 
-void ChooseInOutPage::save(wxWindow *panel) {
+void ChooseOutPage::save(wxWindow *panel) {
 	wxWindow *outputWindow = panel->FindWindowByName(wxT("OutputPicker"));
 	wxDirPickerCtrl *outDirWindow = dynamic_cast<wxDirPickerCtrl *>(outputWindow);
 	wxFilePickerCtrl *outFileWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
@@ -384,31 +447,9 @@
 		_configuration.outputPath = outDirWindow->GetPath();
 	if (outFileWindow)
 		_configuration.outputPath = outFileWindow->GetPath();
-
-	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;
-
-		wxString windowName = wxT("InputPicker");
-		windowName << i;
-
-		wxDirPickerCtrl *inDirWindow = dynamic_cast<wxDirPickerCtrl *>(panel->FindWindowByName(windowName));
-		wxFilePickerCtrl *inFileWindow = dynamic_cast<wxFilePickerCtrl *>(panel->FindWindowByName(windowName));
-
-		if (inDirWindow)
-			_configuration.inputFilePaths.Add(inDirWindow ->GetPath());
-		if (inFileWindow)
-			_configuration.inputFilePaths.Add(inFileWindow->GetPath());
-
-		++i;
-	}
 }
 
-void ChooseInOutPage::onNext(wxWindow *panel) {
+void ChooseOutPage::onNext(wxWindow *panel) {
 	if (_configuration.selectedTool->_type == TOOLTYPE_COMPRESSION)
 		switchPage(new ChooseAudioFormatPage(_topframe));
 	else

Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h	2009-07-08 21:12:03 UTC (rev 42271)
+++ tools/branches/gsoc2009-gui/gui/pages.h	2009-07-08 22:54:18 UTC (rev 42272)
@@ -148,33 +148,35 @@
 };
 
 /**
- * Presents a list of games that are supported for compression.
- * 
- * @todo Possibly merge with ChooseExtractionPage
+ * Presents a list of all supported tools, the "advanced route"
+ * OR, if the second parameter is supplied to a construction
+ * it offers that list of tools instead (and the help text says
+ * "multiple tools matched that input file..."
  */
 
-class ChooseCompressionPage : public WizardPage
+class ChooseToolPage : public WizardPage
 {
 public:
-	ChooseCompressionPage(ScummToolsFrame* frame);
+	ChooseToolPage(ScummToolsFrame* frame, const wxArrayString &options = wxArrayString());
 
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
 
 	void save(wxWindow *panel);
+
+protected:
+	wxArrayString _options;
 };
 
 /**
- * Presents a list of games that are supported for extraction.
- * 
- * @todo Possibly merge with ChooseCompressionPage
+ * Offers the user to input a file or directory
  */
 
-class ChooseExtractionPage : public WizardPage
+class ChooseInPage : public WizardPage
 {
 public:
-	ChooseExtractionPage(ScummToolsFrame* frame);
+	ChooseInPage(ScummToolsFrame* frame);
 
 	wxWindow *CreatePanel(wxWindow *parent);
 
@@ -184,13 +186,13 @@
 };
 
 /**
- * Presents a list of all supported tools, the "advanced route"
+ * If the tool requires more than one input, the additional will be presented here
  */
 
-class ChooseToolPage : public WizardPage
+class ChooseExtraInPage : public WizardPage
 {
 public:
-	ChooseToolPage(ScummToolsFrame* frame);
+	ChooseExtraInPage(ScummToolsFrame* frame);
 
 	wxWindow *CreatePanel(wxWindow *parent);
 
@@ -206,10 +208,10 @@
  * @todo Make it look better and save state
  */
 
-class ChooseInOutPage : public WizardPage
+class ChooseOutPage : public WizardPage
 {
 public:
-	ChooseInOutPage(ScummToolsFrame* frame);
+	ChooseOutPage(ScummToolsFrame* frame);
 
 	wxWindow *CreatePanel(wxWindow *parent);
 

Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-08 21:12:03 UTC (rev 42271)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp	2009-07-08 22:54:18 UTC (rev 42272)
@@ -281,7 +281,7 @@
 	input._file = input_extensions != wxT("/");
 	_inputs.push_back(input);
 
-	_inoutHelpText = wxT("Output files produced by the tool will be put in this directory.");
+	_inHelpText = wxT("Please select any additional input files.");
 }
 
 ToolGUI::~ToolGUI() {

Modified: tools/branches/gsoc2009-gui/gui/tools.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.h	2009-07-08 21:12:03 UTC (rev 42271)
+++ tools/branches/gsoc2009-gui/gui/tools.h	2009-07-08 22:54:18 UTC (rev 42272)
@@ -127,7 +127,7 @@
 	/** List of all inputs this tool expects */
 	ToolInputs _inputs;
 	/** The help text displayed on the input/output page */
-	wxString _inoutHelpText;
+	wxString _inHelpText;
 	/** A list of all games supported by this tool */
 	wxArrayString _games;
 };


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