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

Remere at users.sourceforge.net Remere at users.sourceforge.net
Mon Aug 24 05:41:32 CEST 2009


Revision: 43681
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43681&view=rev
Author:   Remere
Date:     2009-08-24 03:41:32 +0000 (Mon, 24 Aug 2009)

Log Message:
-----------
*Configuration now saves, and defaults are set, does not affect the current configuration yet, however.
*Multiple layout fixes.

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

Modified: tools/branches/gsoc2009-gui/gui/configuration.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/configuration.h	2009-08-24 01:59:58 UTC (rev 43680)
+++ tools/branches/gsoc2009-gui/gui/configuration.h	2009-08-24 03:41:32 UTC (rev 43681)
@@ -38,6 +38,19 @@
 	~Configuration();
 	
 	/**
+	 * Fills this config object with values loaded from the permanent storage method
+	 */
+	void load();
+
+	/**
+	 * Saves configuration to a more permanent storage
+	 * (registry under unix, .ini like file under other OSes)
+	 *
+	 * @param all True if all parameters should be saved, including audio parameters.
+	 */
+	void save(bool all = true);
+
+	/**
 	 * Returns a list of all supported (as in, we have some defaults for it) platforms
 	 */
 	static wxArrayString getTargetPlatforms();
@@ -121,15 +134,63 @@
 	oggAvgBitrate = wxT("24");
 	oggMaxBitrate = wxT("64");
 
+}
+
+inline Configuration::~Configuration() {
+}
+
+inline void Configuration::load() {
 	wxConfig *filecnf = new wxConfig(wxT("ScummVMTools"));
+
 	filecnf->Read(wxT("outputpath"), &outputPath);
+
+	// mp3 params
+	filecnf->Read(wxT("mp3CompressionType"), &mp3CompressionType, mp3CompressionType);
+	filecnf->Read(wxT("mp3MpegQuality"), &mp3MpegQuality, mp3MpegQuality);
+	filecnf->Read(wxT("mp3ABRBitrate"), &mp3ABRBitrate, mp3ABRBitrate);
+	filecnf->Read(wxT("mp3VBRMinBitrate"), &mp3VBRMinBitrate, mp3VBRMinBitrate);
+	filecnf->Read(wxT("mp3VBRMaxBitrate"), &mp3VBRMaxBitrate, mp3VBRMaxBitrate);
+	filecnf->Read(wxT("mp3VBRQuality"), &mp3VBRQuality, mp3VBRQuality);
+
+	// flac params
+	filecnf->Read(wxT("flacCompressionLevel"), &flacCompressionLevel, flacCompressionLevel);
+	filecnf->Read(wxT("flacBlockSize"), &flacBlockSize, flacBlockSize);
+
+	// flac params
+	filecnf->Read(wxT("oggQuality"), &oggQuality, oggQuality);
+	filecnf->Read(wxT("oggMinBitrate"), &oggMinBitrate, oggMinBitrate);
+	filecnf->Read(wxT("oggAvgBitrate"), &oggAvgBitrate, oggAvgBitrate);
+	filecnf->Read(wxT("oggMaxBitrate"), &oggMaxBitrate, oggMaxBitrate);
+
 	delete filecnf;
 }
 
-inline Configuration::~Configuration() {
+inline void Configuration::save(bool all) {
 	wxConfig *filecnf = new wxConfig(wxT("ScummVMTools"));
+
 	wxFileName op(outputPath);
 	filecnf->Write(wxT("outputpath"), op.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
+	
+	if (all) {
+		// mp3 params
+		filecnf->Write(wxT("mp3CompressionType"), mp3CompressionType);
+		filecnf->Write(wxT("mp3MpegQuality"), mp3MpegQuality);
+		filecnf->Write(wxT("mp3ABRBitrate"), mp3ABRBitrate);
+		filecnf->Write(wxT("mp3VBRMinBitrate"), mp3VBRMinBitrate);
+		filecnf->Write(wxT("mp3VBRMaxBitrate"), mp3VBRMaxBitrate);
+		filecnf->Write(wxT("mp3VBRQuality"), mp3VBRQuality);
+
+		// flac params
+		filecnf->Write(wxT("flacCompressionLevel"), flacCompressionLevel);
+		filecnf->Write(wxT("flacBlockSize"), flacBlockSize);
+
+		// flac params
+		filecnf->Write(wxT("oggQuality"), oggQuality);
+		filecnf->Write(wxT("oggMinBitrate"), oggMinBitrate);
+		filecnf->Write(wxT("oggAvgBitrate"), oggAvgBitrate);
+		filecnf->Write(wxT("oggMaxBitrate"), oggMaxBitrate);
+	}
+	
 	delete filecnf;
 }
 

Modified: tools/branches/gsoc2009-gui/gui/main.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.cpp	2009-08-24 01:59:58 UTC (rev 43680)
+++ tools/branches/gsoc2009-gui/gui/main.cpp	2009-08-24 03:41:32 UTC (rev 43681)
@@ -49,6 +49,11 @@
 	virtual bool OnInit();
 
 public:
+	/**
+	 * Essentially a global function to display the about dialog
+	 * We keep it here since there is no good place to stick it since it's called
+	 * from many different classes.
+	 */
 	void OnAbout();
 };
 
@@ -61,13 +66,14 @@
 	SetAppName(wxT("ScummVM Tools"));
 
 	// Create window & display
-	ScummToolsFrame *frame = new ScummToolsFrame(GetAppName(), wxDefaultPosition, wxSize(600,400));
+	ScummToolsFrame *frame = new ScummToolsFrame(GetAppName(), wxDefaultPosition, wxSize(600,420));
 #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));
+	frame->SetMinSize(wxSize(600, 420));
 	SetTopWindow(frame);
 	
+	// Create and load configuration
 	Configuration &configuration = frame->_configuration;
 
 	if (argc == 2) {
@@ -167,10 +173,13 @@
 ScummToolsFrame::ScummToolsFrame(const wxString &title, const wxPoint &pos, const wxSize& size)
 		: wxFrame((wxFrame *)NULL, -1, title, pos, size)
 {
+	// Load the default configuration
+	_configuration.load();
+
+
 	// We need a parent frame for correct background color (default frame looks 'disabled' in the background)
 	wxPanel *main = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE, wxT("Wizard Main Panel"));
 
-
 	wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
 	
 	// Add the top header, it's sweet!
@@ -213,6 +222,10 @@
 }
 
 ScummToolsFrame::~ScummToolsFrame() {
+	// Save the current configuration
+	// false means we don't save audio settings
+	_configuration.save(false);
+
 	for (std::vector<WizardPage *>::iterator iter = _pages.begin(); iter != _pages.end(); ++iter)
 		delete *iter;
 }
@@ -285,9 +298,25 @@
 }
 
 void ScummToolsFrame::onMenuAdvanced(wxCommandEvent &evt) {
+	// We fill the temporary object with the current standard settings
 	Configuration defaults;
-	AdvancedSettingsDialog dlg(this, defaults);
-	dlg.ShowModal();
+	defaults.load();
+
+	// Display the dialog with options
+	int ok;
+	{
+		AdvancedSettingsDialog dlg(this, defaults);
+		ok = dlg.ShowModal();
+		// Settings are saved once the window is closed
+	}
+
+	// Save the settings
+	if (ok == wxID_OK) {
+		defaults.save();
+		// Fill in values from the defaults, note that this overrides
+		// current settings!
+		_configuration.load();
+	}
 }
 
 void ScummToolsFrame::onMenuManual(wxCommandEvent &evt) {
@@ -361,8 +390,8 @@
 #endif
 
 	// Insert space between the buttons
-	topsizer->Add(sizer, wxSizerFlags().Left());
-	topsizer->Add(10, 10, 1, wxEXPAND);
+	topsizer->Add(sizer, wxSizerFlags().Left().Border());
+	topsizer->Add(new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize), wxSizerFlags(1).Expand());
 	sizer = new wxBoxSizer(wxHORIZONTAL);
 
 
@@ -545,13 +574,13 @@
 {
 	wxNotebook *notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
 	
-	mp3 = new ChooseAudioOptionsMp3Page(defaults);
-	flac = new ChooseAudioOptionsFlacPage(defaults);
-	vorbis = new ChooseAudioOptionsVorbisPage(defaults);
+	_mp3 = new ChooseAudioOptionsMp3Page(defaults);
+	_flac = new ChooseAudioOptionsFlacPage(defaults);
+	_vorbis = new ChooseAudioOptionsVorbisPage(defaults);
 
-	notebook->AddPage(mp3->CreatePanel(notebook), wxT("MP3"));
-	notebook->AddPage(flac->CreatePanel(notebook), wxT("Flac"));
-	notebook->AddPage(vorbis->CreatePanel(notebook), wxT("Vorbis"));
+	notebook->AddPage(_mp3panel = _mp3->CreatePanel(notebook), wxT("MP3"));
+	notebook->AddPage(_flacpanel = _flac->CreatePanel(notebook), wxT("Flac"));
+	notebook->AddPage(_vorbispanel = _vorbis->CreatePanel(notebook), wxT("Vorbis"));
 	
 	wxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
 
@@ -562,7 +591,10 @@
 }
 
 AdvancedSettingsDialog::~AdvancedSettingsDialog() {
-	delete mp3;
-	delete flac;
-	delete vorbis;
+	_mp3->save(_mp3panel);
+	_flac->save(_flacpanel);
+	_vorbis->save(_vorbispanel);
+	delete _mp3;
+	delete _flac;
+	delete _vorbis;
 }

Modified: tools/branches/gsoc2009-gui/gui/main.h
===================================================================
--- tools/branches/gsoc2009-gui/gui/main.h	2009-08-24 01:59:58 UTC (rev 43680)
+++ tools/branches/gsoc2009-gui/gui/main.h	2009-08-24 03:41:32 UTC (rev 43681)
@@ -260,9 +260,12 @@
 protected:
 	Configuration &_defaults;
 
-	ChooseAudioOptionsMp3Page *mp3;
-	ChooseAudioOptionsFlacPage *flac;
-	ChooseAudioOptionsVorbisPage *vorbis;
+	ChooseAudioOptionsMp3Page *_mp3;
+	wxWindow *_mp3panel;
+	ChooseAudioOptionsFlacPage *_flac;
+	wxWindow *_flacpanel;
+	ChooseAudioOptionsVorbisPage *_vorbis;
+	wxWindow *_vorbispanel;
 };
 
 #endif

Modified: tools/branches/gsoc2009-gui/gui/pages.cpp
===================================================================
--- tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-24 01:59:58 UTC (rev 43680)
+++ tools/branches/gsoc2009-gui/gui/pages.cpp	2009-08-24 03:41:32 UTC (rev 43681)
@@ -67,7 +67,7 @@
 void WizardPage::SetAlignedSizer(wxWindow *panel, wxSizer *sizer) {
 	wxSizer *topsizer = new wxBoxSizer(wxHORIZONTAL);
 	topsizer->AddSpacer(100);
-	topsizer->Add(sizer, 1, wxEXPAND);
+	topsizer->Add(sizer, wxSizerFlags(1).Expand().Border());
 	panel->SetSizer(topsizer);
 }
 
@@ -869,7 +869,7 @@
 	const int possibleBitrateCount = 160 / 8;
 	wxString possibleBitrates[possibleBitrateCount + 1];
 	for (int i = 0; i <= possibleBitrateCount; ++i) {
-		possibleBitrates[i] << i*8;
+		possibleBitrates[i] << (i+1)*8;
 	}
 
 	sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Minimum Bitrate:")));
@@ -1021,7 +1021,7 @@
 	// 
 
 	// Compression Level
-	const int possibleLevelCount = 8;
+	const int possibleLevelCount = 9;
 	wxString possibleLevels[possibleLevelCount + 1];
 	for (int i = 0; i <= possibleLevelCount; ++i) {
 		possibleLevels[i] << i;
@@ -1101,7 +1101,7 @@
 	const int possibleBitrateCount = 160 / 8;
 	wxString possibleBitrates[possibleBitrateCount + 1];
 	for (int i = 0; i <= possibleBitrateCount; ++i) {
-		possibleBitrates[i] << i*8;
+		possibleBitrates[i] << (i+1)*8;
 	}
 
 	sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Minimum Bitrate:")));
@@ -1128,7 +1128,7 @@
 	sizer->Add(MaxBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
 
 	// Quality
-	const int possibleQualityCount = 10;
+	const int possibleQualityCount = 11;
 	wxString possibleQualities[possibleQualityCount + 1];
 	for (int i = 0; i <= possibleQualityCount; ++i) {
 		possibleQualities[i] << i;


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