From 440da3b4a0f13c817a8088f6abab6551ab63bfe6 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 13 May 2012 18:06:56 +0000 Subject: [PATCH] OSystem now controls loading and saving of settings, by calling Settings::loadConfig() and Settings::saveConfig() when required. This fixes an issue with OSX in particular, or any port where those methods are overrided. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2471 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/mainSDL.cxx | 4 ++-- src/emucore/OSystem.cxx | 16 ++++++++++++++++ src/emucore/OSystem.hxx | 35 ++++++++++++++++++++++++++++------- src/emucore/Settings.cxx | 4 ---- src/emucore/Settings.hxx | 23 +++++++++++++---------- src/gui/FileSnapDialog.cxx | 2 +- 6 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/common/mainSDL.cxx b/src/common/mainSDL.cxx index 771609ab3..8fe2336a0 100644 --- a/src/common/mainSDL.cxx +++ b/src/common/mainSDL.cxx @@ -66,7 +66,7 @@ OSystem* theOSystem = (OSystem*) NULL; int Cleanup() { theOSystem->logMessage("Cleanup from mainSDL\n", 2); - theOSystem->settings().saveConfig(); + theOSystem->saveConfig(); if(theOSystem) delete theOSystem; @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) #error Unsupported platform! #endif - theOSystem->settings().loadConfig(); + theOSystem->loadConfig(); theOSystem->logMessage("Loading config options ...\n", 2); // Take care of commandline arguments diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 15843901d..36766b052 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -308,6 +308,22 @@ bool OSystem::create() return true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OSystem::loadConfig() +{ + mySettings->loadConfig(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OSystem::saveConfig() +{ + // Ask all subsystems to save their settings + if(myFrameBuffer) + myFrameBuffer->ntsc().saveConfig(*mySettings); + + mySettings->saveConfig(); +} + #ifdef DEBUGGER_SUPPORT // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystem::createDebugger(Console& console) diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index fb122e664..cba23ed26 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -50,6 +50,14 @@ struct Resolution { }; typedef Common::Array ResolutionList; +struct TimingInfo { + uInt64 start; + uInt64 current; + uInt64 virt; + uInt64 totalTime; + uInt64 totalFrames; +}; + /** This class provides an interface for accessing operating system specific functions. It also comprises an overall parent object, to which all the @@ -164,6 +172,20 @@ class OSystem */ StateManager& state() const { return *myStateManager; } + /** + This method should be called to load the current settings from an rc file. + It first loads the settings from the config file, then informs subsystems + about the new settings. + */ + void loadConfig(); + + /** + This method should be called to save the current settings to an rc file. + It first asks each subsystem to update its settings, then it saves all + settings to the config file. + */ + void saveConfig(); + #ifdef DEBUGGER_SUPPORT /** Create all child objects which belong to this OSystem @@ -409,6 +431,12 @@ class OSystem */ const string& logMessages() const { return myLogMessages; } + /** + Return timing information (start time of console, current + number of frames rendered, etc. + */ + const TimingInfo& timingInfo() const { return myTimingInfo; } + public: ////////////////////////////////////////////////////////////////////// // The following methods are system-specific and can be overrided in @@ -584,13 +612,6 @@ class OSystem GUI::Font* myConsoleFont; // Indicates whether the main processing loop should proceed - struct TimingInfo { - uInt64 start; - uInt64 current; - uInt64 virt; - uInt64 totalTime; - uInt64 totalFrames; - }; TimingInfo myTimingInfo; // Table of RGB values for GUI elements diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 42632fee7..b3cac06e8 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -469,10 +469,6 @@ void Settings::usage() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::saveConfig() { - // Ask all subsystems to save their settings - if(&(myOSystem->frameBuffer())) - myOSystem->frameBuffer().ntsc().saveConfig(*this); - // Do a quick scan of the internal settings to see if any have // changed. If not, we don't need to save them at all. bool settingsChanged = false; diff --git a/src/emucore/Settings.hxx b/src/emucore/Settings.hxx index f1b177e0f..c65cb3e6b 100644 --- a/src/emucore/Settings.hxx +++ b/src/emucore/Settings.hxx @@ -33,6 +33,8 @@ class OSystem; */ class Settings { + friend class OSystem; + public: /** Create a new settings abstract class @@ -45,16 +47,6 @@ class Settings virtual ~Settings(); public: - /** - This method should be called to load the current settings from an rc file. - */ - virtual void loadConfig(); - - /** - This method should be called to save the current settings to an rc file. - */ - virtual void saveConfig(); - /** This method should be called to load the arguments from the commandline. @@ -158,6 +150,17 @@ class Settings */ void setSize(const string& key, const int value1, const int value2); + protected: + /** + This method will be called to load the current settings from an rc file. + */ + virtual void loadConfig(); + + /** + This method will be called to save the current settings to an rc file. + */ + virtual void saveConfig(); + private: // Copy constructor isn't supported by this class so make it private Settings(const Settings&); diff --git a/src/gui/FileSnapDialog.cxx b/src/gui/FileSnapDialog.cxx index f72ed3000..a0ec86931 100644 --- a/src/gui/FileSnapDialog.cxx +++ b/src/gui/FileSnapDialog.cxx @@ -214,7 +214,7 @@ void FileSnapDialog::saveConfig() instance().settings().setString("ssinterval", mySnapInterval->getSelectedTag()); // Flush changes to disk and inform the OSystem - instance().settings().saveConfig(); + instance().saveConfig(); instance().setConfigPaths(); }