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

Remere at users.sourceforge.net Remere at users.sourceforge.net
Tue Aug 11 02:28:40 CEST 2009


Revision: 43243
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43243&view=rev
Author:   Remere
Date:     2009-08-11 00:28:39 +0000 (Tue, 11 Aug 2009)

Log Message:
-----------
*Added menu bar, only visible on OSX.
*Added a Help button, that displays a short help message about the current page (could be improved).
*Fixed a bug with buttons not refreshing properly.
*Other small GUI tweaks.

Modified Paths:
--------------
    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

Modified: tools/branches/gsoc2009-gui/gui/main.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.cpp	2009-08-11 00:18:42 UTC (rev 43242)
+++ tools/branches/gsoc2009-gui/gui/main.cpp	2009-08-11 00:28:39 UTC (rev 43243)
@@ -38,9 +38,16 @@
 #include "pages.h"
 #include "gui_tools.h"
 
+
+/**
+ * The application class, main entry point for wxWidgets applications.
+ */
 class ScummVMToolsApp : public wxApp
 {
 	virtual bool OnInit();
+
+public:
+	void OnAbout();
 };
 
 IMPLEMENT_APP(ScummVMToolsApp)
@@ -52,6 +59,9 @@
 
 	// Create window & display
 	ScummToolsFrame *frame = new ScummToolsFrame(wxT("ScummVM Tools"), wxDefaultPosition, wxSize(600,400));
+#ifdef __WXMAC__ // Menu bar looks ugly when it's part of the window, on OSX it's not
+	frame->CreateMenuBar();
+#endif
 	frame->SetMinSize(wxSize(600, 400));
 	SetTopWindow(frame);
 	
@@ -72,8 +82,33 @@
 	return true;
 }
 
+void ScummVMToolsApp::OnAbout() {
+	wxAboutDialogInfo about = wxAboutDialogInfo();
+	about.SetVersion(wxT("Development Version"));
+	about.SetCopyright(wxT("ScummVM Team 2009"));
+	about.SetLicense(
+		wxT("Published under the GNU General Public License\n")
+		wxT("This program comes with ABSOLUTELY NO WARRANTY\n")
+		wxT("This is free software, and you are welcome to redistribute it ")
+		wxT("under certain conditions"));
+	about.SetDescription(
+		wxT("This tool allows you to extract data files from several different games \n")
+		wxT("to be used by ScummVM, it can also compress audio data files into a more \n")
+		wxT("compact format than the original."));
+	::wxAboutBox(about);
+}
+
+
+// Event table for the top frame
 BEGIN_EVENT_TABLE(ScummToolsFrame, wxFrame)
+	//EVT_MENU(wxID_PREFERENCES, ScummToolsFrame::onMenuPreferences)
+	EVT_BUTTON(ID_HELP, ScummToolsFrame::onMenuHelp)
+	EVT_MENU(wxID_HELP, ScummToolsFrame::onMenuHelp)
+	EVT_BUTTON(ID_ABOUT, ScummToolsFrame::onMenuAbout)
+	EVT_MENU(wxID_EXIT, ScummToolsFrame::onMenuExit)
+
 	EVT_IDLE(ScummToolsFrame::onIdle)
+	EVT_CLOSE(ScummToolsFrame::onClose)
 END_EVENT_TABLE()
 
 ScummToolsFrame::ScummToolsFrame(const wxString &title, const wxPoint &pos, const wxSize& size)
@@ -127,6 +162,21 @@
 		delete *iter;
 }
 
+void ScummToolsFrame::CreateMenuBar() {
+	wxMenuBar* menubar = new wxMenuBar();
+	// Name of this seems really inappropriate
+	wxMenu* testmenu = new  wxMenu(wxT("File"));
+
+	//testmenu->Append(wxID_PREFERENCES, wxT("&Preferences"));
+	testmenu->Append(wxID_HELP, wxT("&Help"));
+	testmenu->Append(wxID_ABOUT, wxT("&About"));
+	testmenu->Append(wxID_EXIT, wxT("&Exit"));
+	
+	menubar->Append(testmenu, wxT("File"));
+
+	SetMenuBar(menubar);
+}
+
 void ScummToolsFrame::switchPage(WizardPage *next, bool moveback) {
 	// Find the old page
 	wxPanel *oldPanel = dynamic_cast<wxPanel *>(_wizardpane->FindWindow(wxT("Wizard Page")));
@@ -160,6 +210,24 @@
 	_buttons->setPage(_pages.back(), newPanel);
 }
 
+wxString ScummToolsFrame::GetHelpText() {
+	return _pages.back()->getHelp();
+}
+
+void ScummToolsFrame::onMenuHelp(wxCommandEvent &evt) {
+	wxString help = _pages.back()->getHelp();
+	wxMessageDialog dlg(this, help, wxT("Help"));
+	dlg.ShowModal();
+}
+
+void ScummToolsFrame::onMenuAbout(wxCommandEvent &evt) {
+	wxGetApp().OnAbout();
+}
+
+void ScummToolsFrame::onMenuExit(wxCommandEvent &evt) {
+	Close();
+}
+
 void ScummToolsFrame::onIdle(wxIdleEvent &evt) {
 	if (_pages.back()->onIdle(dynamic_cast<wxPanel *>(_wizardpane->FindWindow(wxT("Wizard Page"))))) {
 		// We want more!
@@ -169,10 +237,16 @@
 	}
 }
 
-//
+void ScummToolsFrame::onClose(wxCloseEvent &evt) {
+	if (!evt.CanVeto() || _pages.back()->onCancel(dynamic_cast<wxPanel *>(_wizardpane->FindWindow(wxT("Wizard Page")))))
+		wxFrame::OnCloseWindow(evt);
+}
 
+
+// Event table for the WizardButtons window
 BEGIN_EVENT_TABLE(WizardButtons, wxPanel)
-	EVT_BUTTON(ID_ABOUT, WizardButtons::onClickAbout)
+	//EVT_BUTTON(ID_HELP, WizardButtons::onClickHelp)
+	//EVT_BUTTON(ID_ABOUT, WizardButtons::onClickAbout)
 	EVT_BUTTON(ID_NEXT, WizardButtons::onClickNext)
 	EVT_BUTTON(ID_PREV, WizardButtons::onClickPrevious)
 	EVT_BUTTON(ID_CANCEL, WizardButtons::onClickCancel)
@@ -192,6 +266,12 @@
 	_prev->SetSize(80, -1);
 	sizer->Add(_prev, wxSizerFlags().Left().ReserveSpaceEvenIfHidden());
 
+	sizer->AddSpacer(10);
+
+	_help = new wxButton(this, ID_HELP, wxT("Help"));
+	_help->SetSize(80, -1);
+	sizer->Add(_help, wxSizerFlags().Left().ReserveSpaceEvenIfHidden());
+
 	// Insert space between the buttons
 	topsizer->Add(sizer, wxSizerFlags().Left());
 	topsizer->Add(10, 10, 1, wxEXPAND);
@@ -278,21 +358,6 @@
 }
 
 // wx event handlers
-void WizardButtons::onClickAbout(wxCommandEvent &e) {
-	wxAboutDialogInfo about = wxAboutDialogInfo();
-	about.SetVersion(wxT("Development Version"));
-	about.SetCopyright(wxT("ScummVM Team 2009"));
-	about.SetLicense(
-		wxT("Published under the GNU General Public License\n")
-		wxT("This program comes with ABSOLUTELY NO WARRANTY\n")
-		wxT("This is free software, and you are welcome to redistribute it ")
-		wxT("under certain conditions"));
-	about.SetDescription(
-		wxT("This tool allows you to extract data files from several different games \n")
-		wxT("to be used by ScummVM, it can also compress audio data files into a more \n")
-		wxT("compact format than the original."));
-	::wxAboutBox(about);
-}
 
 void WizardButtons::onClickNext(wxCommandEvent &e) {
 	wxASSERT(_currentPage);

Modified: tools/branches/gsoc2009-gui/gui/main.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.h	2009-08-11 00:18:42 UTC (rev 43242)
+++ tools/branches/gsoc2009-gui/gui/main.h	2009-08-11 00:28:39 UTC (rev 43243)
@@ -37,6 +37,7 @@
 	ID_NEXT,
 	ID_PREV,
 	ID_CANCEL,
+	ID_HELP,
 	ID_ABOUT,
 };
 
@@ -58,6 +59,12 @@
 	~ScummToolsFrame();
 
 	/**
+	 * Creates the menu bar for the application
+	 * only called when running under mac osx (as menu bars are ugly in wizards when they are part of the window)
+	 */
+	void CreateMenuBar();
+
+	/**
 	 * Switches page, old page is stored on a stack for going backwards
 	 * Buttons are reset, and state is saved
 	 *
@@ -75,10 +82,26 @@
 		switchPage(NULL, true);}
 
 	/**
+	 * Get help text of this window
+	 */
+	virtual wxString GetHelpText();
+
+	/**
 	 * Handle wx OnIdle events
 	 */
 	void onIdle(wxIdleEvent &evt);
 
+	/**
+	 * Handle application close event
+	 */
+	void onClose(wxCloseEvent &evt);
+
+	void onMenuHelp(wxCommandEvent &evt);
+	void onMenuAbout(wxCommandEvent &evt);
+	void onMenuExit(wxCommandEvent &evt);
+
+
+
 	/** The state of the wizard so far */
 	Configuration _configuration;
 
@@ -156,6 +179,7 @@
 	void showAbort(bool show);
 
 	// wx event handlers
+	void onClickHelp(wxCommandEvent &e);
 	void onClickAbout(wxCommandEvent &e);
 	void onClickNext(wxCommandEvent &e);
 	void onClickPrevious(wxCommandEvent &e);
@@ -168,6 +192,8 @@
 	wxButton *_next;
 	/** 'Previous' button. */
 	wxButton *_prev;
+	/** 'Help' button. */
+	wxButton *_help;
 	/** 'Cancel' button. */
 	wxButton *_cancel;
 	/** The static text on the line seperating the page area and the buttons. */

Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-11 00:18:42 UTC (rev 43242)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-11 00:28:39 UTC (rev 43243)
@@ -76,14 +76,14 @@
 	_topframe->switchToPreviousPage();
 }
 
-void WizardPage::onCancel(wxWindow *panel) {
+bool WizardPage::onCancel(wxWindow *panel) {
 	wxMessageDialog dlg(panel, wxT("Are you sure you want to abort the wizard?"), wxT("Abort"), wxYES | wxNO);
 	wxWindowID ret = dlg.ShowModal();
 	if (ret == wxID_YES) {
 		_topframe->Close(true);
-	} else {
-		// Do nothing
+		return true;
 	}
+	return false;
 }
 
 // Load/Save settings
@@ -94,6 +94,11 @@
 	return false;
 }
 
+// Get the help text
+wxString WizardPage::getHelp() {
+	return wxT("Sorry.\nThere is no additional help for this page.");
+}
+
 // Introduction page
 
 IntroPage::IntroPage(ScummToolsFrame *frame)
@@ -144,6 +149,10 @@
 	_configuration.compressing = selected_option.Find(wxT("extract")) == wxNOT_FOUND;
 }
 
+wxString IntroPage::getHelp() {
+	return wxT("Select the activity you would like to do. In order to play your game.\nMost common usage is compression of game files.");
+}
+
 void IntroPage::onNext(wxWindow *panel) {
 	wxString selected_option = static_cast<wxRadioBox *>(panel->FindWindowByName(wxT("ChooseActivity")))->GetStringSelection().Lower();
 	if (selected_option.Find(wxT("advanced")) != wxNOT_FOUND) {
@@ -157,6 +166,8 @@
 
 void IntroPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
 	buttons->setLineLabel(wxT("ScummVM Tools"));
+
+	WizardPage::updateButtons(panel, buttons);
 }
 
 
@@ -179,7 +190,8 @@
 
 	if (!_options.empty()) {
 		sizer->Add(new wxStaticText(panel, wxID_ANY, 
-			wxT("There are multiple possible tools for this input, please select the correct one.")));
+			wxT("There are multiple possible tools for this input, please select the correct one.\n\n")
+			wxT("If none of the tools appear to match, you probably supplied the wrong file.")));
 		choices = _options;
 	} else {
 		sizer->Add(new wxStaticText(panel, wxID_ANY, 
@@ -228,6 +240,10 @@
 		g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
 }
 
+wxString ChooseToolPage::getHelp() {
+	return wxT("Select the tool you want to use.\nRead the short description below the dropdown box for a short hint on what the tool does.");
+}
+
 void ChooseToolPage::onNext(wxWindow *panel) {
 	const ToolGUI *tool = g_tools.get(static_cast<wxChoice *>(panel->FindWindowByName(wxT("ToolSelection")))->GetStringSelection());
 
@@ -248,6 +264,8 @@
 
 void ChooseToolPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
 	buttons->setLineLabel(wxT("ScummVM Tools"));
+	
+	WizardPage::updateButtons(panel, buttons);
 }
 
 // Common base class for the IO pages
@@ -290,6 +308,8 @@
 	buttons->enableNext(
 		(inDirWindow && inDirWindow->GetPath().size() > 0) || 
 		(inFileWindow && inFileWindow->GetPath().size() > 0));
+	
+	WizardPage::updateButtons(panel, buttons);
 }
 
 // Page to choose input directory or file
@@ -397,9 +417,17 @@
 	}
 }
 
+wxString ChooseInPage::getHelp() {
+	return wxT("Choose the input file.\n\nIf you are unsure, a general hint ")
+		wxT("is to select the file with an extension that is different from ")
+		wxT("all other files in the selected directory.");
+}
+
 void ChooseInPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
 	if (!_configuration.advanced)
 		buttons->setLineLabel(wxT("ScummVM Tools"));
+
+	ChooseIOPage::updateButtons(panel, buttons);
 }
 
 // Page to choose input and output directory or file
@@ -506,6 +534,10 @@
 	}
 }
 
+wxString ChooseExtraInPage::getHelp() {
+	return wxT("Select any additional input files (usually extra disks) for this tool.");
+}
+
 void ChooseExtraInPage::onNext(wxWindow *panel) {
 	switchPage(new ChooseOutPage(_topframe));
 }
@@ -591,6 +623,13 @@
 		_configuration.outputPath = outFileWindow->GetPath();
 }
 
+wxString ChooseOutPage::getHelp() {
+	return wxT("Select the output path.\t\nIn most cases it's enough to select an output ")
+		wxT("directory, and the tool will fill it with files.\nIf you must supply a file, ")
+		wxT("the filename is not important.\nOther files in the directory will be overwritten ")
+		wxT("without warnings the user.");
+}
+
 void ChooseOutPage::onNext(wxWindow *panel) {
 	if (_configuration.selectedTool->getType() == TOOLTYPE_COMPRESSION)
 		switchPage(new ChooseTargetPlatformPage(_topframe));
@@ -641,6 +680,11 @@
 	_configuration.setPlatformDefaults();
 }
 
+wxString ChooseTargetPlatformPage::getHelp() {
+	return wxT("Choose the target platform.\n\nIf you do not know the target platform, ")
+		wxT("simply select PC.\nThis only effects the audio settings (optimized defaults).");
+}
+
 void ChooseTargetPlatformPage::onNext(wxWindow *panel) {
 	switchPage(new ChooseAudioFormatPage(_topframe));
 }
@@ -701,6 +745,11 @@
 	return panel;
 }
 
+wxString ChooseAudioFormatPage::getHelp() {
+	return wxT("Select audio format, for most platforms, Ogg Vorbis is preferred, as it's license free ")
+		wxT("and GPL based will still offer great quality.\nNintendo DS and Dremcast platforms only work with MP3 compression.");
+}
+
 void ChooseAudioFormatPage::save(wxWindow *panel) {
 	wxChoice *format = static_cast<wxChoice *>(panel->FindWindowByName(wxT("AudioSelection")));
 	wxCheckBox *advanced = static_cast<wxCheckBox *>(panel->FindWindowByName(wxT("AdvancedAudio")));
@@ -713,7 +762,6 @@
 		_configuration.selectedAudioFormat = AUDIO_MP3;
 
 	_configuration.advancedAudioSettings = advanced->GetValue();
-	
 }
 
 void ChooseAudioFormatPage::onNext(wxWindow *panel) {
@@ -1138,6 +1186,11 @@
 	_thread->Run();
 }
 
+wxString ProcessPage::getHelp() {
+	return wxT("The tool is running, wait for the progress to finish then click the next button.\n")
+		wxT("If you did an error with your input, or want to abort execution, press the abort button.");
+}
+
 bool ProcessPage::onIdle(wxPanel *panel) {
 	const ToolGUI *tool = _configuration.selectedTool;
 	
@@ -1214,11 +1267,13 @@
 		switchPage(new FailurePage(_topframe));
 }
 
-void ProcessPage::onCancel(wxWindow *panel) {
+bool ProcessPage::onCancel(wxWindow *panel) {
 	if (_finished)
-		WizardPage::onCancel(panel);
-	else
+		return WizardPage::onCancel(panel);
+	else {
 		_thread->abort();
+		return false;
+	}
 }
 
 void ProcessPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
@@ -1242,6 +1297,8 @@
 		buttons->enableNext(false);
 		buttons->showAbort(true);
 	}
+
+	WizardPage::updateButtons(panel, buttons);
 }
 
 // The thread a tool is run in
@@ -1353,15 +1410,23 @@
 		// On windows we can simply spawn an explorer instance
 #ifdef __WINDOWS__
 		wxExecute(wxT("explorer.exe \"") + _configuration.outputPath + wxT("\""));
+#elif __WXMAC__
+		wxExecute(wxT("open \"") + _configuration.outputPath + wxT("\""));
 #else
 #endif
 	}
 	_topframe->Close(true);
 }
 
+wxString FinishPage::getHelp() {
+	return wxT("You have finished the wizard!\n\nJust click the finish button and enjoy your outputted files, if you compressed, you can now import the compressed file into ScummVM to get access to your data.");
+}
+
 void FinishPage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
 	buttons->enablePrevious(false);
 	buttons->showFinish(true);
+	
+	WizardPage::updateButtons(panel, buttons);
 }
 
 
@@ -1395,5 +1460,7 @@
 void FailurePage::updateButtons(wxWindow *panel, WizardButtons *buttons) {
 	buttons->enablePrevious(false);
 	buttons->showFinish(true);
+	
+	WizardPage::updateButtons(panel, buttons);
 }
 

Modified: tools/branches/gsoc2009-gui/gui/pages.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.h	2009-08-11 00:18:42 UTC (rev 43242)
+++ tools/branches/gsoc2009-gui/gui/pages.h	2009-08-11 00:28:39 UTC (rev 43243)
@@ -65,6 +65,13 @@
 	 */ 
 	virtual void save(wxWindow *panel);
 	
+	/**
+	 * Returns the associated help text with this page
+	 *
+	 * @return Returns the help text.
+	 */
+	virtual wxString getHelp();
+
 	// Event handlers
 	
 	/**
@@ -90,8 +97,9 @@
 	 * the wizard.
 	 *
 	 * @param panel The panel associated with this page, should have bene created by CreatePanel previously.
+	 * @return Return true to make the application close (false does nothing)
 	 */
-	virtual void onCancel(wxWindow *panel); // Default is to display 'Are you sure' and quit if you click 'Yes'
+	virtual bool onCancel(wxWindow *panel); // Default is to display 'Are you sure' and return true if you click 'Yes'
 
 	/**
 	 * Update state of the next/prev/cancel buttons, by default all buttons are shown, and the next button
@@ -139,6 +147,8 @@
 
 	void save(wxWindow *panel);
 
+	wxString getHelp();
+
 	void onNext(wxWindow *panel);
 	
 	void updateButtons(wxWindow *panel, WizardButtons *buttons);
@@ -160,6 +170,8 @@
 	void onNext(wxWindow *panel);
 
 	void save(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void onChangeTool(wxCommandEvent &evt);
 	
@@ -193,6 +205,8 @@
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void save(wxWindow *panel);
 	
@@ -210,6 +224,8 @@
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void save(wxWindow *panel);
 };
@@ -228,6 +244,8 @@
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void save(wxWindow *panel);
 };
@@ -245,6 +263,8 @@
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void save(wxWindow *panel);
 };
@@ -260,6 +280,8 @@
 	wxWindow *CreatePanel(wxWindow *parent);
 
 	void onNext(wxWindow *panel);
+	
+	wxString getHelp();
 
 	void save(wxWindow *panel);
 };
@@ -432,11 +454,13 @@
 	 * @param outwin Text control to redirect output to
 	 */
 	void runTool();
+	
+	wxString getHelp();
 
 	bool onIdle(wxPanel *panel);
 
 	void onNext(wxWindow *panel);
-	void onCancel(wxWindow *panel);
+	bool onCancel(wxWindow *panel);
 
 	void updateButtons(wxWindow *panel, WizardButtons *buttons);
 };
@@ -451,6 +475,8 @@
 	FinishPage(ScummToolsFrame *frame);
 
 	wxWindow *CreatePanel(wxWindow *parent);
+	
+	wxString getHelp();
 
 	void onNext(wxWindow *panel);
 


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