[Scummvm-cvs-logs] SF.net SVN: scummvm:[41824] tools/branches/gsoc2009-gui/gui
Remere at users.sourceforge.net
Remere at users.sourceforge.net
Wed Jun 24 02:36:49 CEST 2009
Revision: 41824
http://scummvm.svn.sourceforge.net/scummvm/?rev=41824&view=rev
Author: Remere
Date: 2009-06-24 00:36:49 +0000 (Wed, 24 Jun 2009)
Log Message:
-----------
*Added choose extraction page.
*Added select input / output page (needs more work)
*Added select audio format page, no advanced options yet.
Modified Paths:
--------------
tools/branches/gsoc2009-gui/gui/configuration.h
tools/branches/gsoc2009-gui/gui/main.cpp
tools/branches/gsoc2009-gui/gui/main.h
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/configuration.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/configuration.h 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/configuration.h 2009-06-24 00:36:49 UTC (rev 41824)
@@ -25,6 +25,17 @@
#include <wx/string.h>
+class Tool;
+
+// Different audio formats
+// They're used for bitwise operations
+enum AudioFormat {
+ AUDIO_VORBIS = 1,
+ AUDIO_FLAC = 2,
+ AUDIO_MP3 = 4,
+ AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
+};
+
struct Configuration {
Configuration();
@@ -34,8 +45,12 @@
bool advanced;
bool compressing;
+ bool advancedAudioSettings;
wxString selectedGame;
- wxString selectedTool;
+ const Tool* selectedTool;
+ wxArrayString inputFilePaths;
+ wxString outputPath;
+ AudioFormat selectedAudioFormat;
};
inline Configuration::Configuration() {
@@ -43,9 +58,11 @@
advanced = false;
compressing = false;
+ advancedAudioSettings = false;
- selectedGame = wxT("");
- selectedTool = wxT("");
+ selectedTool = NULL;
+
+ selectedAudioFormat = AUDIO_VORBIS;
}
#endif
Modified: tools/branches/gsoc2009-gui/gui/main.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.cpp 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/main.cpp 2009-06-24 00:36:49 UTC (rev 41824)
@@ -124,7 +124,7 @@
// Find the old page
wxPanel *oldPanel = dynamic_cast<wxPanel *>(_wizardpane->FindWindow(wxT("Wizard Page")));
- _pages.back()->save(oldPanel, configuration);
+ _pages.back()->save(oldPanel);
if(moveback) {
// Don't save the old page (which is ontop of the stack already)
Modified: tools/branches/gsoc2009-gui/gui/main.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.h 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/main.h 2009-06-24 00:36:49 UTC (rev 41824)
@@ -53,7 +53,7 @@
// Switches to the previous page
void switchToPreviousPage();
- Configuration configuration;
+ Configuration _configuration;
private:
wxPanel *_wizardpane;
Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp 2009-06-24 00:36:49 UTC (rev 41824)
@@ -30,12 +30,15 @@
#include "wx/wx.h"
#endif
+#include <wx/filepicker.h>
+
#include "main.h"
#include "pages.h"
#include "tools.h"
WizardPage::WizardPage(ScummToolsFrame *frame)
- : _topframe(frame)
+ : _topframe(frame),
+ _configuration(frame->_configuration)
{
}
@@ -54,7 +57,7 @@
void WizardPage::SetAlignedSizer(wxWindow *panel, wxSizer *sizer) {
wxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL);
topsizer->AddSpacer(100);
- topsizer->Add(sizer);
+ topsizer->Add(sizer, 0, wxEXPAND);
panel->SetSizer(topsizer);
}
@@ -78,7 +81,7 @@
}
// Load/Save settings
-void WizardPage::save(wxWindow *panel, Configuration &configuration) {
+void WizardPage::save(wxWindow *panel) {
}
// Introduction page
@@ -115,7 +118,7 @@
SetAlignedSizer(panel, sizer);
// Load options
- Configuration &config = _topframe->configuration;
+ Configuration &config = _configuration;
if(config.advanced)
options->SetSelection(2);
else if(config.compressing)
@@ -131,17 +134,18 @@
buttons->enableNext(true);
}
-void IntroPage::save(wxWindow *panel, Configuration &config) {
- wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("")))->GetStringSelection().Lower();
+void IntroPage::save(wxWindow *panel) {
+ wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("ChooseActivity")))->GetStringSelection().Lower();
- config.advanced = selected_option.Find(wxT("advanced")) != wxNOT_FOUND;
- config.compressing = selected_option.Find(wxT("extract")) == wxNOT_FOUND;
+ _configuration.advanced = selected_option.Find(wxT("advanced")) != wxNOT_FOUND;
+ _configuration.compressing = selected_option.Find(wxT("extract")) == wxNOT_FOUND;
}
void IntroPage::onNext(wxWindow *panel) {
- wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("")))->GetStringSelection().Lower();
+ wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("ChooseActivity")))->GetStringSelection().Lower();
if(selected_option.Find(wxT("extract")) != wxNOT_FOUND) {
// extract
+ _topframe->switchPage(new ChooseExtractionPage(_topframe));
} else if(selected_option.Find(wxT("advanced")) != wxNOT_FOUND) {
// advanced
_topframe->switchPage(new ChooseToolPage(_topframe));
@@ -178,19 +182,65 @@
SetAlignedSizer(panel, sizer);
// Load already set values
- game->SetStringSelection(_topframe->configuration.selectedGame);
+ game->SetStringSelection(_configuration.selectedGame);
return panel;
}
-// Load/Save settings
-
-void ChooseCompressionPage::save(wxWindow *panel, Configuration &config) {
+void ChooseCompressionPage::save(wxWindow *panel) {
wxString game = static_cast<wxChoice *>(panel->FindWindowByName(wxT("GameSelection")))->GetStringSelection();
- config.selectedGame = game;
+ _configuration.selectedGame = game;
+ _configuration.selectedTool = g_tools.getByGame(game);
}
+void ChooseCompressionPage::onNext(wxWindow *panel) {
+ _topframe->switchPage(new ChooseInOutPage(_topframe));
+}
+
+// Page to choose what game files to extract,
+// VERY similar to the above, could be made into one class?
+
+ChooseExtractionPage::ChooseExtractionPage(ScummToolsFrame* frame)
+ : WizardPage(frame)
+{
+}
+
+wxWindow *ChooseExtractionPage::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);
+
+ wxChoice *game = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
+ choices, 0, wxDefaultValidator, wxT("GameSelection"));
+ sizer->Add(game);
+ game->SetSelection(0);
+
+ SetAlignedSizer(panel, sizer);
+
+ // Load already set values
+ game->SetStringSelection(_configuration.selectedGame);
+
+ return panel;
+}
+
+void ChooseExtractionPage::save(wxWindow *panel) {
+ wxString game =
+ static_cast<wxChoice *>(panel->FindWindowByName(wxT("GameSelection")))->GetStringSelection();
+ _configuration.selectedTool = g_tools.getByGame(game);
+}
+
+void ChooseExtractionPage::onNext(wxWindow *panel) {
+ _topframe->switchPage(new ChooseInOutPage(_topframe));
+}
+
// Page to choose ANY tool to use
ChooseToolPage::ChooseToolPage(ScummToolsFrame* frame)
@@ -207,13 +257,8 @@
sizer->Add(new wxStaticText(panel, wxID_ANY,
wxT("Select what tool you'd like to use.")));
-
wxArrayString choices = g_tools.getToolList(TOOLTYPE_ALL);
- // Sort the array for display (it should actually always be sorted since
- // they're stored in a ordered tree but you can never be too safe)
- choices.Sort();
-
wxChoice *tool = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
choices, 0, wxDefaultValidator, wxT("ToolSelection"));
sizer->Add(tool);
@@ -222,12 +267,187 @@
SetAlignedSizer(panel, sizer);
// Load configuration
- tool->SetStringSelection(_topframe->configuration.selectedTool);
+ if(_configuration.selectedTool != NULL)
+ tool->SetStringSelection(_configuration.selectedTool->_name);
return panel;
}
-// Load/Save settings
-void ChooseToolPage::save(wxWindow *panel, Configuration &config) {
- config.selectedTool = static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection();
+void ChooseToolPage::save(wxWindow *panel) {
+ _configuration.selectedTool =
+ g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
}
+
+void ChooseToolPage::onNext(wxWindow *panel) {
+ _topframe->switchPage(new ChooseInOutPage(_topframe));
+}
+
+// Page to choose input and output directory or file
+
+ChooseInOutPage::ChooseInOutPage(ScummToolsFrame* frame)
+ : WizardPage(frame)
+{
+}
+
+wxWindow *ChooseInOutPage::CreatePanel(wxWindow *parent) {
+ wxWindow *panel = WizardPage::CreatePanel(parent);
+
+ wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+ sizer->AddSpacer(15);
+
+ const Tool &tool = *_configuration.selectedTool;
+
+ // some help perhaps?
+ sizer->Add(new wxStaticText(panel, wxID_ANY, tool._inoutHelpText));
+
+ sizer->AddSpacer(10);
+
+ // Create input selection
+ 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) {
+ const ToolInput &input = *iter;
+
+ wxString windowName = wxT("InputPicker");
+ windowName << i;
+
+ if(input._file) {
+ inputbox->Add(new wxFilePickerCtrl(
+ panel, wxID_ANY, wxEmptyString, wxT("Select a file"),
+ input._extension,
+ wxDefaultPosition, wxDefaultSize,
+ wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator,
+ windowName), wxSizerFlags().Expand());
+
+ } else {
+ inputbox->Add(new wxDirPickerCtrl(
+ panel, wxID_ANY, wxEmptyString, wxT("Select a folder"),
+ wxDefaultPosition, wxDefaultSize,
+ wxFLP_USE_TEXTCTRL | wxFLP_OPEN, wxDefaultValidator,
+ windowName), wxSizerFlags().Expand());
+
+ }
+ ++i;
+ }
+
+ sizer->Add(inputbox, wxSizerFlags().Expand());
+
+
+ sizer->AddSpacer(10);
+
+ // Create output selection
+
+ if(tool._outputToDirectory) {
+ wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination folder"));
+
+ box->Add(new wxDirPickerCtrl(
+ panel, wxID_ANY, _configuration.outputPath, wxT("Select a folder"),
+ wxDefaultPosition, wxDefaultSize,
+ wxFLP_USE_TEXTCTRL | wxDIRP_DIR_MUST_EXIST, wxDefaultValidator,
+ wxT("OutputPicker")), wxSizerFlags(1).Expand());
+
+ sizer->Add(box, wxSizerFlags().Expand());
+ } else {
+ wxStaticBoxSizer *box = new wxStaticBoxSizer(wxHORIZONTAL, panel, wxT("Destination file"));
+
+ sizer->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());
+
+ sizer->Add(box, wxSizerFlags().Expand());
+ }
+
+ SetAlignedSizer(panel, sizer);
+
+ return panel;
+}
+
+void ChooseInOutPage::save(wxWindow *panel) {
+ wxWindow *outputWindow = panel->FindWindowByName(wxT("OutputPicker"));
+ wxDirPickerCtrl *outDirWindow = dynamic_cast<wxDirPickerCtrl *>(outputWindow);
+ wxFilePickerCtrl *inDirWindow = dynamic_cast<wxFilePickerCtrl *>(outputWindow);
+
+ if(outDirWindow)
+ _configuration.outputPath = outDirWindow->GetPath();
+ if(inDirWindow)
+ _configuration.outputPath = inDirWindow->GetPath();
+
+ // TODO: save input, unsure of exact format
+}
+
+void ChooseInOutPage::onNext(wxWindow *panel) {
+ if(_configuration.compressing)
+ _topframe->switchPage(new ChooseAudioFormatPage(_topframe));
+}
+
+// Page to choose input and output directory or file
+
+ChooseAudioFormatPage::ChooseAudioFormatPage(ScummToolsFrame* frame)
+ : WizardPage(frame)
+{
+}
+
+wxWindow *ChooseAudioFormatPage::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;
+
+ choices.Add(wxT("Ogg"));
+ choices.Add(wxT("FLAC"));
+ choices.Add(wxT("MP3"));
+
+ sizer->AddSpacer(10);
+
+ wxChoice *format = new wxChoice(panel, wxID_ANY, wxDefaultPosition, wxSize(80, -1),
+ choices, 0, wxDefaultValidator, wxT("AudioSelection"));
+ sizer->Add(format);
+
+ sizer->AddSpacer(10);
+
+ wxCheckBox *advanced = new wxCheckBox(panel, wxID_ANY, wxT("Select advanced audio settings"),
+ wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("AdvancedAudio"));
+ sizer->Add(advanced);
+
+ SetAlignedSizer(panel, sizer);
+
+ // Load already set values
+ if(_configuration.selectedAudioFormat == AUDIO_VORBIS)
+ format->SetSelection(0);
+ else if(_configuration.selectedAudioFormat == AUDIO_FLAC)
+ format->SetSelection(1);
+ else if(_configuration.selectedAudioFormat == AUDIO_MP3)
+ format->SetSelection(2);
+
+ advanced->SetValue(_configuration.advancedAudioSettings);
+
+
+ return panel;
+}
+
+void ChooseAudioFormatPage::save(wxWindow *panel) {
+ wxChoice *format = static_cast<wxChoice *>(panel->FindWindowByName(wxT("AudioSelection")));
+ wxCheckBox *advanced = static_cast<wxCheckBox *>(panel->FindWindowByName(wxT("AdvancedAudio")));
+
+ if(format->GetStringSelection() == wxT("Ogg"))
+ _configuration.selectedAudioFormat = AUDIO_VORBIS;
+ else if(format->GetStringSelection() == wxT("FLAC"))
+ _configuration.selectedAudioFormat = AUDIO_FLAC;
+ else if(format->GetStringSelection() == wxT("MP3"))
+ _configuration.selectedAudioFormat = AUDIO_MP3;
+
+ _configuration.advancedAudioSettings = advanced->GetValue();
+
+}
+
Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/pages.h 2009-06-24 00:36:49 UTC (rev 41824)
@@ -41,7 +41,7 @@
void switchPage(WizardPage *next);
// Load/Save configuration, reads data from the panel supplied
- virtual void save(wxWindow *panel, Configuration &configuration);
+ virtual void save(wxWindow *panel);
// Event handlers
// overload these to handle prev/next/cancel clicks
@@ -58,9 +58,11 @@
void SetAlignedSizer(wxWindow *panel, wxSizer *sizer);
ScummToolsFrame* _topframe;
+ Configuration &_configuration;
};
// Introduction page, with options to extract/compress
+// Step 1
class IntroPage : public WizardPage
{
@@ -69,13 +71,15 @@
wxWindow *CreatePanel(wxWindow *parent);
- void save(wxWindow *panel, Configuration &configuration);
+ void save(wxWindow *panel);
void onNext(wxWindow *panel);
void updateButtons(wxWindow *panel, WizardButtons *buttons);
};
+// Step 2, choose tool / game
+
class ChooseCompressionPage : public WizardPage
{
public:
@@ -83,9 +87,23 @@
wxWindow *CreatePanel(wxWindow *parent);
- void save(wxWindow *panel, Configuration &configuration);
+ void onNext(wxWindow *panel);
+
+ void save(wxWindow *panel);
};
+class ChooseExtractionPage : public WizardPage
+{
+public:
+ ChooseExtractionPage(ScummToolsFrame* frame);
+
+ wxWindow *CreatePanel(wxWindow *parent);
+
+ void onNext(wxWindow *panel);
+
+ void save(wxWindow *panel);
+};
+
class ChooseToolPage : public WizardPage
{
public:
@@ -93,5 +111,35 @@
wxWindow *CreatePanel(wxWindow *parent);
- void save(wxWindow *panel, Configuration &configuration);
+ void onNext(wxWindow *panel);
+
+ void save(wxWindow *panel);
};
+
+// Step 3, choose input & output directory/file
+
+class ChooseInOutPage : public WizardPage
+{
+public:
+ ChooseInOutPage(ScummToolsFrame* frame);
+
+ wxWindow *CreatePanel(wxWindow *parent);
+
+ void onNext(wxWindow *panel);
+
+ void save(wxWindow *panel);
+};
+
+// Step 4, choose audio format
+
+class ChooseAudioFormatPage : public WizardPage
+{
+public:
+ ChooseAudioFormatPage(ScummToolsFrame* frame);
+
+ wxWindow *CreatePanel(wxWindow *parent);
+
+ //void onNext(wxWindow *panel);
+
+ void save(wxWindow *panel);
+};
Modified: tools/branches/gsoc2009-gui/gui/tools.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.cpp 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/tools.cpp 2009-06-24 00:36:49 UTC (rev 41824)
@@ -196,7 +196,24 @@
return iter->second;
}
+const Tool *Tools::get(const wxString& name) const {
+ std::map<wxString, Tool>::const_iterator iter = tools.find(name);
+ if(iter == tools.end())
+ return NULL;
+
+ return &iter->second;
+}
+
+const Tool *Tools::getByGame(const wxString &gamename) const {
+ for(std::map<wxString, Tool>::const_iterator iter = tools.begin(); iter != tools.end(); ++iter)
+ for(wxArrayString::const_iterator citer = iter->second._games.begin(); citer != iter->second._games.end(); ++citer)
+ if(*citer == gamename)
+ return &iter->second;
+ return NULL;
+}
+
+
// The Tool class
Tool::Tool() {
@@ -222,6 +239,9 @@
input._extension = input_extensions;
input._file = true;
_inputs.push_back(input);
+
+ _outputToDirectory = true;
+ _inoutHelpText = wxT("Output files produced by the tool will be put in this directory.");
}
void Tool::addGame(const wxString &game_name) {
Modified: tools/branches/gsoc2009-gui/gui/tools.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/tools.h 2009-06-23 23:55:48 UTC (rev 41823)
+++ tools/branches/gsoc2009-gui/gui/tools.h 2009-06-24 00:36:49 UTC (rev 41824)
@@ -28,14 +28,7 @@
#include <map>
#include <vector>
-// Different audio formats
-// They're used for bitwise operations
-enum AudioFormat {
- AUDIO_VORBIS = 1,
- AUDIO_FLAC = 2,
- AUDIO_MP3 = 4,
- AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
-};
+#include "configuration.h"
// Different types of tools, used to differentiate them when
// fetching lists of games & tools
@@ -51,9 +44,12 @@
// some a dir and some a single file
struct ToolInput {
wxString _extension;
+ wxString _description;
bool _file; // dir otherwise
};
+typedef std::vector<ToolInput> ToolInputs;
+
// A tool, contains all info necessary to run it
class Tool {
public:
@@ -72,8 +68,9 @@
wxString _name;
ToolType _type;
AudioFormat _supportedFormats;
- typedef std::vector<ToolInput> ToolInputs;
ToolInputs _inputs;
+ bool _outputToDirectory;
+ wxString _inoutHelpText;
wxArrayString _games;
};
@@ -83,6 +80,8 @@
Tools();
const Tool &operator[](const wxString &name) const;
+ const Tool *get(const wxString &name) const;
+ const Tool *getByGame(const wxString &game) const;
// Returns all tool/game names in a list
// conveinent for creating the choose tool page
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