stella/src/emucore/Settings.hxx

215 lines
6.0 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-2012 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef SETTINGS_HXX
#define SETTINGS_HXX
class OSystem;
#include "Array.hxx"
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"
/**
This class provides an interface for accessing frontend specific settings.
@author Stephen Anthony
@version $Id$
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(OSystem* osystem);
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
*/
virtual 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.
*/
virtual void saveConfig();
/**
This method should be called to load the arguments from the commandline.
@return Name of the ROM to load, otherwise empty string
*/
string loadCommandLine(int argc, char** argv);
/**
This method should be called *after* settings have been read,
to validate (and change, if necessary) any improper settings.
*/
void validate();
/**
This method should be called to display usage information.
*/
void usage();
/**
Get the value assigned to the specified key. If the key does
Added 'WINDOWED_SUPPORT' compile-time argument, which can be used for those systems which don't actually have a windowing environment. When this is set, toggling from fullscreen will not be possible, and certain window-related UI functions will not be accessible. Completely revamped video subsystem. Windowed and fullscreen modes are now dealt with separately. Windows can be zoomed using the 'zoom_ui' and 'zoom_tia' arguments. Fullscreen modes are now set by resolution, not zoom, so you can specify to always use a certain fullscreen resolution, and the images will be scaled appropriately. This also fixes the fullscreen issues on widescreen monitors; just select a widescreen video mode, and the aspect ratio will always be correct. Removed dirty-rect support for software rendering of the TIA image, as it ended up being slower than just updating the entire image. For those resolutions where it will start to slow down (1024x768 or higher), one should be using OpenGL. Fixed issue in Windows when returning from fullscreen mode made the window constantly 'shrink' in size. It was related to auto-detecting the desktop resolution, which is really the job of SDL. As such, all further releases of Stella will require SDL 1.2.10, which includes this auto-detection code internally. Made ROM launcher resizable, configurable in sizes from 320x240 to 800x600. Updated the UIDialog to change these quantities from the UI (Stella will need to be restarted for it to take effect). Removed aspect ratio support, since it was causing problems, and the new fullscreen mode work has made it obsolete. i *may* consider it again in the future, if there's sufficient demand. Added 'fullres' commandline argument, used to set the fullscreen resolution. Added 'launcherres' commandline argument, used to set the ROM launcher resolution. This replaces 'launchersize' argument, which has been removed. Changed 'scale_ui' and 'scale_tia' to 'zoom_ui' and 'zoom_tia', respectively. Their function remains the same. Changed meaning of 'gl_fsmax' argument to specify what modes to use fullscreen OpenGL scaling (previously, this was a boolean, and didn't consider different modes). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1323 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-06-20 16:33:23 +00:00
not exist then -1 is returned.
@param key The key of the setting to lookup
@return The integer value of the setting
*/
int getInt(const string& key) const;
/**
Get the value assigned to the specified key. If the key does
not exist then -1.0 is returned.
@param key The key of the setting to lookup
@return The floating point value of the setting
*/
float getFloat(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
*/
const string& getString(const string& key) const;
Added 'WINDOWED_SUPPORT' compile-time argument, which can be used for those systems which don't actually have a windowing environment. When this is set, toggling from fullscreen will not be possible, and certain window-related UI functions will not be accessible. Completely revamped video subsystem. Windowed and fullscreen modes are now dealt with separately. Windows can be zoomed using the 'zoom_ui' and 'zoom_tia' arguments. Fullscreen modes are now set by resolution, not zoom, so you can specify to always use a certain fullscreen resolution, and the images will be scaled appropriately. This also fixes the fullscreen issues on widescreen monitors; just select a widescreen video mode, and the aspect ratio will always be correct. Removed dirty-rect support for software rendering of the TIA image, as it ended up being slower than just updating the entire image. For those resolutions where it will start to slow down (1024x768 or higher), one should be using OpenGL. Fixed issue in Windows when returning from fullscreen mode made the window constantly 'shrink' in size. It was related to auto-detecting the desktop resolution, which is really the job of SDL. As such, all further releases of Stella will require SDL 1.2.10, which includes this auto-detection code internally. Made ROM launcher resizable, configurable in sizes from 320x240 to 800x600. Updated the UIDialog to change these quantities from the UI (Stella will need to be restarted for it to take effect). Removed aspect ratio support, since it was causing problems, and the new fullscreen mode work has made it obsolete. i *may* consider it again in the future, if there's sufficient demand. Added 'fullres' commandline argument, used to set the fullscreen resolution. Added 'launcherres' commandline argument, used to set the ROM launcher resolution. This replaces 'launchersize' argument, which has been removed. Changed 'scale_ui' and 'scale_tia' to 'zoom_ui' and 'zoom_tia', respectively. Their function remains the same. Changed meaning of 'gl_fsmax' argument to specify what modes to use fullscreen OpenGL scaling (previously, this was a boolean, and didn't consider different modes). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1323 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-06-20 16:33:23 +00:00
/**
Get the x*y size assigned to the specified key. If the key does
not exist (or is invalid) then results are -1 for each item.
@param key The key of the setting to lookup
@return The x and y values encoded in the key
*/
void getSize(const string& key, int& x, int& y) 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
*/
void setInt(const string& key, const int value);
/**
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
*/
void setFloat(const string& key, const float value);
/**
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
*/
void setBool(const string& key, const bool value);
/**
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
*/
void setString(const string& key, const string& value);
Added 'WINDOWED_SUPPORT' compile-time argument, which can be used for those systems which don't actually have a windowing environment. When this is set, toggling from fullscreen will not be possible, and certain window-related UI functions will not be accessible. Completely revamped video subsystem. Windowed and fullscreen modes are now dealt with separately. Windows can be zoomed using the 'zoom_ui' and 'zoom_tia' arguments. Fullscreen modes are now set by resolution, not zoom, so you can specify to always use a certain fullscreen resolution, and the images will be scaled appropriately. This also fixes the fullscreen issues on widescreen monitors; just select a widescreen video mode, and the aspect ratio will always be correct. Removed dirty-rect support for software rendering of the TIA image, as it ended up being slower than just updating the entire image. For those resolutions where it will start to slow down (1024x768 or higher), one should be using OpenGL. Fixed issue in Windows when returning from fullscreen mode made the window constantly 'shrink' in size. It was related to auto-detecting the desktop resolution, which is really the job of SDL. As such, all further releases of Stella will require SDL 1.2.10, which includes this auto-detection code internally. Made ROM launcher resizable, configurable in sizes from 320x240 to 800x600. Updated the UIDialog to change these quantities from the UI (Stella will need to be restarted for it to take effect). Removed aspect ratio support, since it was causing problems, and the new fullscreen mode work has made it obsolete. i *may* consider it again in the future, if there's sufficient demand. Added 'fullres' commandline argument, used to set the fullscreen resolution. Added 'launcherres' commandline argument, used to set the ROM launcher resolution. This replaces 'launchersize' argument, which has been removed. Changed 'scale_ui' and 'scale_tia' to 'zoom_ui' and 'zoom_tia', respectively. Their function remains the same. Changed meaning of 'gl_fsmax' argument to specify what modes to use fullscreen OpenGL scaling (previously, this was a boolean, and didn't consider different modes). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1323 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-06-20 16:33:23 +00:00
/**
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
*/
void setSize(const string& key, const int value1, const int value2);
private:
// Copy constructor isn't supported by this class so make it private
Settings(const Settings&);
// Assignment operator isn't supported by this class so make it private
Settings& operator = (const Settings&);
// Trim leading and following whitespace from a string
static string trim(string& str)
{
string::size_type first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString :
str.substr(first, str.find_last_not_of(' ')-first+1);
}
protected:
// The parent OSystem object
OSystem* myOSystem;
// Structure used for storing settings
struct Setting
{
string key;
string value;
string initialValue;
};
typedef Common::Array<Setting> SettingsArray;
const SettingsArray& getInternalSettings() const
{ return myInternalSettings; }
const SettingsArray& getExternalSettings() const
{ return myExternalSettings; }
/** Get position in specified array of 'key' */
int getInternalPos(const string& key) const;
int getExternalPos(const string& key) const;
/** Add key,value pair to specified array at specified position */
int setInternal(const string& key, const string& value,
int pos = -1, bool useAsInitial = false);
int setExternal(const string& key, const string& value,
int pos = -1, bool useAsInitial = false);
private:
// Holds key,value pairs that are necessary for Stella to
// function and must be saved on each program exit.
SettingsArray myInternalSettings;
// Holds auxiliary key,value pairs that shouldn't be saved on
// program exit.
SettingsArray myExternalSettings;
};
#endif