2002-03-21 22:47:00 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2015-12-29 19:22:46 +00:00
|
|
|
// Copyright (c) 1995-2016 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.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2002-03-21 22:47:00 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef SETTINGS_HXX
|
|
|
|
#define SETTINGS_HXX
|
|
|
|
|
2005-02-21 02:23:57 +00:00
|
|
|
class OSystem;
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
/**
|
|
|
|
This class provides an interface for accessing frontend specific settings.
|
|
|
|
|
|
|
|
@author Stephen Anthony
|
2009-05-13 13:55:40 +00:00
|
|
|
@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
|
|
|
*/
|
2002-03-21 22:47:00 +00:00
|
|
|
class Settings
|
|
|
|
{
|
2012-05-13 18:06:56 +00:00
|
|
|
friend class OSystem;
|
|
|
|
|
2002-03-21 22:47:00 +00:00
|
|
|
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
|
|
|
|
*/
|
2014-05-12 23:34:25 +00:00
|
|
|
Settings(OSystem& osystem);
|
2002-03-21 22:47:00 +00:00
|
|
|
|
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();
|
2002-03-21 22:47:00 +00:00
|
|
|
|
|
|
|
public:
|
2003-09-19 15:45:01 +00:00
|
|
|
/**
|
|
|
|
This method should be called to load the arguments from the commandline.
|
2004-07-05 00:53:48 +00:00
|
|
|
|
2007-07-27 13:49:16 +00:00
|
|
|
@return Name of the ROM to load, otherwise empty string
|
2003-09-19 15:45:01 +00:00
|
|
|
*/
|
2007-07-27 13:49:16 +00:00
|
|
|
string loadCommandLine(int argc, char** argv);
|
2003-09-19 15:45:01 +00:00
|
|
|
|
2005-05-02 19:36:05 +00:00
|
|
|
/**
|
|
|
|
This method should be called *after* settings have been read,
|
|
|
|
to validate (and change, if necessary) any improper settings.
|
|
|
|
*/
|
|
|
|
void validate();
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
@param key The key of the setting to lookup
|
2013-05-08 23:34:42 +00:00
|
|
|
@return The (variant) value of the setting
|
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
|
2013-05-08 23:34:42 +00:00
|
|
|
@param value The (variant) value to assign to the setting
|
2003-11-24 01:14:38 +00:00
|
|
|
*/
|
2013-05-08 23:34:42 +00:00
|
|
|
void setValue(const string& key, const Variant& value);
|
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
|
|
|
|
2013-05-08 23:34:42 +00:00
|
|
|
@param key The key of the setting to lookup
|
|
|
|
@return The specific type value of the setting
|
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(); }
|
|
|
|
const GUI::Size getSize(const string& key) const { return value(key).toSize(); }
|
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:
|
|
|
|
/**
|
|
|
|
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();
|
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
// Trim leading and following whitespace from a string
|
|
|
|
static string trim(string& str)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
protected:
|
2005-02-22 18:41:16 +00:00
|
|
|
// The parent OSystem object
|
2014-05-12 23:34:25 +00:00
|
|
|
OSystem& myOSystem;
|
2005-02-21 02:23:57 +00:00
|
|
|
|
2003-09-23 17:27:11 +00:00
|
|
|
// Structure used for storing settings
|
2003-09-23 00:58:31 +00:00
|
|
|
struct Setting
|
|
|
|
{
|
|
|
|
string key;
|
2013-05-08 23:34:42 +00:00
|
|
|
Variant value;
|
|
|
|
Variant initialValue;
|
2003-09-23 00:58:31 +00:00
|
|
|
};
|
2014-11-19 12:10:45 +00:00
|
|
|
using SettingsArray = vector<Setting>;
|
2003-09-23 00:58:31 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
const SettingsArray& getInternalSettings() const
|
|
|
|
{ return myInternalSettings; }
|
|
|
|
const SettingsArray& getExternalSettings() const
|
|
|
|
{ return myExternalSettings; }
|
2003-09-23 00:58:31 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
/** Get position in specified array of 'key' */
|
|
|
|
int getInternalPos(const string& key) const;
|
|
|
|
int getExternalPos(const string& key) const;
|
2004-04-21 16:27:34 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
/** Add key,value pair to specified array at specified position */
|
2013-05-08 23:34:42 +00:00
|
|
|
int setInternal(const string& key, const Variant& value,
|
2006-03-06 02:26:16 +00:00
|
|
|
int pos = -1, bool useAsInitial = false);
|
2013-05-08 23:34:42 +00:00
|
|
|
int setExternal(const string& key, const Variant& value,
|
2006-03-06 02:26:16 +00:00
|
|
|
int pos = -1, bool useAsInitial = false);
|
2004-04-21 16:27:34 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
private:
|
|
|
|
// Holds key,value pairs that are necessary for Stella to
|
|
|
|
// function and must be saved on each program exit.
|
|
|
|
SettingsArray myInternalSettings;
|
2004-07-09 00:27:39 +00:00
|
|
|
|
2006-03-06 02:26:16 +00:00
|
|
|
// Holds auxiliary key,value pairs that shouldn't be saved on
|
|
|
|
// program exit.
|
|
|
|
SettingsArray myExternalSettings;
|
2015-04-26 19:02:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
Settings() = delete;
|
|
|
|
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
|