stella/stella/src/emucore/Settings.hxx

228 lines
6.2 KiB
C++
Raw Normal View History

//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-1999 by Bradford W. Mott
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.hxx,v 1.9 2003-11-06 22:22:32 stephena Exp $
//============================================================================
#ifndef SETTINGS_HXX
#define SETTINGS_HXX
#ifdef DEVELOPER_SUPPORT
#include "Props.hxx"
#endif
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
#include "bspf.hxx"
class Console;
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony
@version $Id: Settings.hxx,v 1.9 2003-11-06 22:22:32 stephena Exp $
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
*/
class Settings
{
public:
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
Create a new settings abstract class
*/
Settings();
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
Destructor
*/
virtual ~Settings();
public:
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
This method should be called to load the current settings from an rc file.
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
*/
void loadConfig();
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
This method should be called to save the current settings to an rc file.
*/
void saveConfig();
/**
This method should be called to load the arguments from the commandline.
*/
bool loadCommandLine(Int32 argc, char** argv);
/**
Get the value assigned to the specified key. If the key does
not exist then -1 is returned.
@param key The key of the setting to lookup
@return The integer value of the setting
*/
Int32 getInt(const string& key) const;
/**
Get the value assigned to the specified key. If the key does
not exist then false is returned.
@param key The key of the setting to lookup
@return The boolean value of the setting
*/
bool getBool(const string& key) const;
/**
Get the value assigned to the specified key. If the key does
not exist then the empty string is returned.
@param key The key of the setting to lookup
@return The string value of the setting
*/
string getString(const string& key) const;
/**
Set the value associated with key to the given value.
@param key The key of the setting
@param value The value to assign to the setting
@param save Whether this setting should be saved to the rc-file.
*/
void set(const string& key, const string& value, bool save = true);
public:
//////////////////////////////////////////////////////////////////////
// The following methods are system-specific and must be implemented
// in derived classes.
//////////////////////////////////////////////////////////////////////
/**
This method should be called to get the filename of a state file
given the state number.
@return String representing the full path of the state filename.
*/
virtual string stateFilename(uInt32 state) = 0;
/**
This method should be called to get the filename of a snapshot.
@return String representing the full path of the snapshot filename.
*/
virtual string snapshotFilename() = 0;
/**
This method should be called to display usage information.
@param message A short message about this version of Stella
*/
virtual void usage(string& message) = 0;
public:
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
/**
This method should be called when the emulation core sets
the console object.
*/
void setConsole(Console* console) { myConsole = console; }
/**
This method should be called to get the filename of the users'
properties (stella.pro) file.
@return String representing the full path of the user properties filename.
*/
string userPropertiesFilename() { return myUserPropertiesFile; }
/**
This method should be called to get the filename of the system
properties (stella.pro) file.
@return String representing the full path of the system properties filename.
*/
string systemPropertiesFilename() { return mySystemPropertiesFile; }
/**
This method should be called to get the filename of the users'
config (stellarc) file.
@return String representing the full path of the user config filename.
*/
string userConfigFilename() { return myUserConfigFile; }
/**
This method should be called to get the filename of the system
config (stellarc) file.
@return String representing the full path of the system config filename.
*/
string systemConfigFilename() { return mySystemConfigFile; }
/**
Return the default directory for storing data.
*/
string baseDir() { return myBaseDir; }
public:
#ifdef DEVELOPER_SUPPORT
// User-modified properties
Properties userDefinedProperties;
#endif
protected:
string myBaseDir;
string myStateDir;
string myStateFile;
string mySnapshotFile;
string myUserPropertiesFile;
string mySystemPropertiesFile;
string myUserConfigFile;
string mySystemConfigFile;
// The global Console object
Console* myConsole;
// The full pathname of the settings file for input
string mySettingsInputFilename;
// The full pathname of the settings file for output
string mySettingsOutputFilename;
private:
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
// Copy constructor isn't supported by this class so make it private
Settings(const Settings&);
X11 and SDL versions now fully compile and fully support the new EventHandler class. All thats left to do there is integrate the Snapshot code into the core, but that will have to wait until I rewrite the PNG handler to not need the PNG library ... Changed the Settings class to a virtual abstract class, and created a SettingsUNIX class to derive from it and work with the X11 and SDL versions. Some notes on updating the DOS and Windows ports (which I will probably do eventually), and on porting to other toolkits: A port needs the following: - a main function which takes native events and converts to the core format, and generally acts as the dispatcher (mainXXX.cxx) - a specific frontend, derived from Frontend.hxx, which sets up port specific filename and locations (FrontendXXX.hxx) - a specific settings class, derived from Settings.hxx, which deals with settings/commandline arguments specific to that port (SettingsXXX.hxx) - probably some other stuff that I've forgotten The next step is get the DOS port working with the new EventHandler (easy) and attempt to bring the Windows port into the year 2003 (it hasn't been touched for almost a year, quite hard). I also have to write a GUI class that will draw menus, etc. and actually let you remap keys from the emulator itself. And that may have to wait until the fabled graphics rewrite that Brad and I will be working on. It never ends ... git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@181 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-09-11 20:53:51 +00:00
// Assignment operator isn't supported by this class so make it private
Settings& operator = (const Settings&);
// Test whether the given setting is present in the array
bool contains(const string& key);
// Structure used for storing settings
struct Setting
{
string key;
string value;
bool save;
};
// Pointer to a dynamically allocated array of settings
Setting* mySettings;
// Current capacity of the settings array
unsigned int myCapacity;
// Size of the settings array (i.e. the number of <key,value> pairs)
unsigned int mySize;
};
#endif