2002-03-21 22:47:00 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2002-03-21 22:47:00 +00:00
|
|
|
// 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
|
|
|
|
//
|
2019-12-31 17:18:56 +00:00
|
|
|
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2002-03-21 22:47:00 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2002-03-21 22:47:00 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef SETTINGS_HXX
|
|
|
|
#define SETTINGS_HXX
|
|
|
|
|
2019-02-21 03:13:29 +00:00
|
|
|
#include <map>
|
|
|
|
|
2013-05-08 23:34:42 +00:00
|
|
|
#include "Variant.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"
|
2019-04-25 22:14:21 +00:00
|
|
|
#include "repository/KeyValueRepository.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
|
|
|
|
|
|
|
/**
|
2019-02-23 18:51:11 +00:00
|
|
|
This class provides an interface for accessing all configurable options,
|
|
|
|
both from the settings file and from the commandline.
|
|
|
|
|
2019-02-23 20:37:50 +00:00
|
|
|
Note that options can be configured as 'permanent' or 'temporary'.
|
|
|
|
Permanent options are ones that the app registers with the system, and
|
|
|
|
always saves when the app exits. Temporary options are those that are
|
|
|
|
used when appropriate, but never saved to the settings file.
|
2019-02-23 18:51:11 +00:00
|
|
|
|
|
|
|
Each c'tor (both in the base class and in any derived classes) are
|
2019-02-23 20:37:50 +00:00
|
|
|
responsible for registering all options as either permanent or temporary.
|
|
|
|
If an option isn't registered as permanent, it will be considered
|
|
|
|
temporary and will not be saved.
|
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
|
|
|
|
|
|
|
@author Stephen Anthony
|
|
|
|
*/
|
2002-03-21 22:47:00 +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
|
|
|
|
*/
|
2019-02-22 01:25:08 +00:00
|
|
|
explicit Settings();
|
2015-12-29 21:28:10 +00:00
|
|
|
virtual ~Settings() = default;
|
2002-03-21 22:47:00 +00:00
|
|
|
|
2019-02-21 03:13:29 +00:00
|
|
|
using Options = std::map<string, Variant>;
|
2005-05-02 19:36:05 +00:00
|
|
|
|
2019-12-16 08:47:56 +00:00
|
|
|
static constexpr int SETTINGS_VERSION = 1;
|
|
|
|
static constexpr const char* SETTINGS_VERSION_KEY = "settings.version";
|
|
|
|
|
2019-02-21 03:13:29 +00:00
|
|
|
public:
|
2004-07-05 00:53:48 +00:00
|
|
|
/**
|
|
|
|
This method should be called to display usage information.
|
|
|
|
*/
|
2014-10-21 23:02:20 +00:00
|
|
|
void usage() const;
|
2004-07-05 00:53:48 +00:00
|
|
|
|
2019-04-25 22:14:21 +00:00
|
|
|
void setRepository(shared_ptr<KeyValueRepository> repository);
|
|
|
|
|
2019-02-22 01:25:08 +00:00
|
|
|
/**
|
|
|
|
This method is called to load settings from the settings file,
|
|
|
|
and apply commandline options specified by the given parameter.
|
|
|
|
|
|
|
|
@param options A list of options that overrides ones in the
|
|
|
|
settings file
|
|
|
|
*/
|
2019-04-25 22:14:21 +00:00
|
|
|
void load(const Options& options);
|
2019-02-22 01:25:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
This method is called to save the current settings to the
|
|
|
|
settings file.
|
|
|
|
*/
|
2019-04-25 22:14:21 +00:00
|
|
|
void save();
|
2019-02-22 01:25:08 +00:00
|
|
|
|
2003-09-23 00:58:31 +00:00
|
|
|
/**
|
2013-05-08 23:34:42 +00:00
|
|
|
Get the value assigned to the specified key.
|
2003-09-23 00:58:31 +00:00
|
|
|
|
2019-02-23 18:51:11 +00:00
|
|
|
@param key The key of the setting to lookup
|
2019-02-23 20:37:50 +00:00
|
|
|
@return The value of the setting; EmptyVariant if none exists
|
2003-09-23 00:58:31 +00:00
|
|
|
*/
|
2013-05-08 23:34:42 +00:00
|
|
|
const Variant& value(const string& key) const;
|
2003-09-19 15:45:01 +00:00
|
|
|
|
Added the ability to change the aspect ratio of the screen in the SDL
OpenGL port. Normally, the window is double the native TIA frame
width, so we always get a ratio of 2.0 (2:1).
Now, if you're using OpenGL mode, the '-gl_aspect' commandline argument
can take a decimal number representing the ratio you want to use.
For example, normal TV mode would be 1.3333 (4:3).
Depending on the resolution you use, you can make the window look much
more like the original Atari. I find that in 1600x1200 mode, an
aspect of 1.6 looks quite authentic.
This is only supported in the SDL OpenGL port for now, since changing
the aspect took only 1 line of code (I love 3D graphics :) It may
never be supported in software SDL, since it is quite a bit harder
to do it in software.
Ditto for the Cyberstella DirectDraw7 code (it will probably never be
implemented, unless hardware scaling is available). If/when I get
around to the Direct3D port, it will be trivial to do there as well.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@211 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2003-11-17 17:43:39 +00:00
|
|
|
/**
|
2013-05-08 23:34:42 +00:00
|
|
|
Set the value associated with the specified key.
|
2003-11-24 01:14:38 +00:00
|
|
|
|
|
|
|
@param key The key of the setting
|
2019-02-23 20:37:50 +00:00
|
|
|
@param value The value to assign to the key
|
2003-11-24 01:14:38 +00:00
|
|
|
*/
|
2019-05-04 08:42:18 +00:00
|
|
|
void setValue(const string& key, const Variant& value, bool persist = true);
|
2003-11-24 01:14:38 +00:00
|
|
|
|
|
|
|
/**
|
2013-05-08 23:34:42 +00:00
|
|
|
Convenience methods to return specific types.
|
2003-09-23 00:58:31 +00:00
|
|
|
|
2019-02-23 18:51:11 +00:00
|
|
|
@param key The key of the setting to lookup
|
2019-02-23 20:37:50 +00:00
|
|
|
@return The specific type value of the variant
|
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
|
|
|
*/
|
2013-05-08 23:34:42 +00:00
|
|
|
int getInt(const string& key) const { return value(key).toInt(); }
|
|
|
|
float getFloat(const string& key) const { return value(key).toFloat(); }
|
|
|
|
bool getBool(const string& key) const { return value(key).toBool(); }
|
|
|
|
const string& getString(const string& key) const { return value(key).toString(); }
|
2019-05-02 20:28:39 +00:00
|
|
|
const Common::Size getSize(const string& key) const { return value(key).toSize(); }
|
2019-05-18 07:04:06 +00:00
|
|
|
const Common::Point getPoint(const string& key) const { return value(key).toPoint(); }
|
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
|
|
|
|
2012-05-13 18:06:56 +00:00
|
|
|
protected:
|
2019-02-23 18:51:11 +00:00
|
|
|
/**
|
|
|
|
Add key/value pair to specified map. Note that these should only be called
|
|
|
|
directly within the c'tor, to register the 'key' and set it to the
|
|
|
|
appropriate 'value'. Elsewhere, any derived classes should call 'setValue',
|
|
|
|
and let it decide where the key/value pair will be saved.
|
|
|
|
*/
|
2019-02-23 20:37:50 +00:00
|
|
|
void setPermanent(const string& key, const Variant& value);
|
|
|
|
void setTemporary(const string& key, const Variant& value);
|
2019-02-23 18:51:11 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
// Trim leading and following whitespace from a string
|
2018-08-31 19:02:12 +00:00
|
|
|
static string trim(const string& str)
|
2006-03-06 02:26:16 +00:00
|
|
|
{
|
|
|
|
string::size_type first = str.find_first_not_of(' ');
|
2012-05-10 15:36:20 +00:00
|
|
|
return (first == string::npos) ? EmptyString :
|
2006-03-06 02:26:16 +00:00
|
|
|
str.substr(first, str.find_last_not_of(' ')-first+1);
|
|
|
|
}
|
2003-11-24 01:14:38 +00:00
|
|
|
|
2019-02-23 20:37:50 +00:00
|
|
|
// FIXME - Rework so that these aren't needed; hence no commenting added
|
2019-02-24 23:33:29 +00:00
|
|
|
const Options& getPermanentSettings() const
|
2019-02-23 20:37:50 +00:00
|
|
|
{ return myPermanentSettings; }
|
2019-02-24 23:33:29 +00:00
|
|
|
const Options& getTemporarySettings() const
|
2019-02-23 20:37:50 +00:00
|
|
|
{ return myTemporarySettings; }
|
2003-09-23 00:58:31 +00:00
|
|
|
|
2019-02-22 01:25:08 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
This method must be called *after* settings have been fully loaded
|
|
|
|
to validate (and change, if necessary) any improper settings.
|
|
|
|
*/
|
|
|
|
void validate();
|
|
|
|
|
2019-12-16 08:47:56 +00:00
|
|
|
/**
|
|
|
|
Migrate settings over one version.
|
|
|
|
*/
|
|
|
|
void migrateOne();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Migrate settings.
|
|
|
|
*/
|
|
|
|
void migrate();
|
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
private:
|
2019-02-23 18:51:11 +00:00
|
|
|
// Holds key/value pairs that are necessary for Stella to
|
2006-03-06 02:26:16 +00:00
|
|
|
// function and must be saved on each program exit.
|
2019-02-23 20:37:50 +00:00
|
|
|
Options myPermanentSettings;
|
2004-07-09 00:27:39 +00:00
|
|
|
|
2019-02-23 18:51:11 +00:00
|
|
|
// Holds auxiliary key/value pairs that shouldn't be saved on
|
2006-03-06 02:26:16 +00:00
|
|
|
// program exit.
|
2019-02-23 20:37:50 +00:00
|
|
|
Options myTemporarySettings;
|
2015-04-26 19:02:42 +00:00
|
|
|
|
2019-04-25 22:14:21 +00:00
|
|
|
shared_ptr<KeyValueRepository> myRespository;
|
|
|
|
|
2015-04-26 19:02:42 +00:00
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
Settings(const Settings&) = delete;
|
|
|
|
Settings(Settings&&) = delete;
|
|
|
|
Settings& operator=(const Settings&) = delete;
|
|
|
|
Settings& operator=(Settings&&) = delete;
|
2002-03-21 22:47:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|