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
This commit is contained in:
stephena 2012-05-13 18:06:56 +00:00
parent ceaae994ae
commit 440da3b4a0
6 changed files with 60 additions and 24 deletions

View File

@ -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

View File

@ -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)

View File

@ -50,6 +50,14 @@ struct Resolution {
};
typedef Common::Array<Resolution> 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

View File

@ -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;

View File

@ -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&);

View File

@ -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();
}