Added 'Variant' class, which is basically a variable type. Reimplemented

the Settings class to use Variant.  Still TODO is modify various UI elements
that currently accept StringMap to use Variant instead.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2726 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-05-08 23:34:42 +00:00
parent 0929adc20d
commit 7de6bbd99b
25 changed files with 306 additions and 349 deletions

View File

@ -300,7 +300,7 @@ void CheatManager::loadCheats(const string& md5sum)
// (and remove the key from the settings, so they won't get set again) // (and remove the key from the settings, so they won't get set again)
const string& cheats = myOSystem->settings().getString("cheat"); const string& cheats = myOSystem->settings().getString("cheat");
if(cheats != "") if(cheats != "")
myOSystem->settings().setString("cheat", ""); myOSystem->settings().setValue("cheat", "");
CheatCodeMap::iterator iter = myCheatMap.find(md5sum); CheatCodeMap::iterator iter = myCheatMap.find(md5sum);
if(iter == myCheatMap.end() && cheats == "") if(iter == myCheatMap.end() && cheats == "")

View File

@ -106,7 +106,7 @@ SoundSDL::~SoundSDL()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL::setEnabled(bool state) void SoundSDL::setEnabled(bool state)
{ {
myOSystem->settings().setBool("sound", state); myOSystem->settings().setValue("sound", state);
myOSystem->logMessage(state ? "SoundSDL::setEnabled(true)" : myOSystem->logMessage(state ? "SoundSDL::setEnabled(true)" :
"SoundSDL::setEnabled(false)", 2); "SoundSDL::setEnabled(false)", 2);
@ -193,7 +193,7 @@ void SoundSDL::setVolume(Int32 percent)
{ {
if(myIsInitializedFlag && (percent >= 0) && (percent <= 100)) if(myIsInitializedFlag && (percent >= 0) && (percent <= 100))
{ {
myOSystem->settings().setInt("volume", percent); myOSystem->settings().setValue("volume", percent);
SDL_LockAudio(); SDL_LockAudio();
myVolume = percent; myVolume = percent;
myTIASound.volume(percent); myTIASound.volume(percent);

79
src/common/Variant.hxx Normal file
View File

@ -0,0 +1,79 @@
//============================================================================
//
// 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-2013 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 VARIANT_HXX
#define VARIANT_HXX
#include "bspf.hxx"
#include "Rect.hxx"
/**
This class implements a very simple variant type, which is convertible
to several other types. It stores the actual data as a string, and
converts to other types as required. Eventually, this class may be
extended to use templates and become a more full-featured variant type.
@author Stephen Anthony
*/
class Variant
{
private:
// Underlying data store is (currently) always a string
string data;
// Use singleton so we use only one ostringstream object
inline ostringstream& buf() {
static ostringstream buf;
return buf;
}
public:
Variant() : data("") { }
Variant(const string& s) : data(s) { }
Variant(const char* s) : data(s) { }
Variant(int i) { buf().str(""); buf() << i; data = buf().str(); }
Variant(unsigned int i) { buf().str(""); buf() << i; data = buf().str(); }
Variant(float f) { buf().str(""); buf() << f; data = buf().str(); }
Variant(double d) { buf().str(""); buf() << d; data = buf().str(); }
Variant(bool b) { buf().str(""); buf() << b; data = buf().str(); }
Variant(const GUI::Size& s) { buf().str(""); buf() << s; data = buf().str(); }
// Conversion methods
const string& toString() const { return data; }
const char* toCString() const { return data.c_str(); }
const int toInt() const { return atoi(data.c_str()); }
const float toFloat() const { return atof(data.c_str()); }
const bool toBool() const { return data == "1" || data == "true"; }
const GUI::Size toSize() const { return GUI::Size(data); }
// Comparison
bool operator==(const Variant& v) const { return data == v.data; };
bool operator!=(const Variant& v) const { return data != v.data; };
friend ostream& operator<<(ostream& os, const Variant& v) {
os << v.data;
return os;
}
};
static const Variant EmptyVariant("");
#endif

View File

@ -195,7 +195,7 @@ int main(int argc, char* argv[])
Debugger& dbg = theOSystem->debugger(); Debugger& dbg = theOSystem->debugger();
int bp = dbg.stringToValue(initBreak); int bp = dbg.stringToValue(initBreak);
dbg.setBreakPoint(bp, true); dbg.setBreakPoint(bp, true);
theOSystem->settings().setString("break", ""); theOSystem->settings().setValue("break", "");
} }
if(theOSystem->settings().getBool("debug")) if(theOSystem->settings().getBool("debug"))

View File

@ -210,16 +210,16 @@ void NTSCFilter::loadConfig(const Settings& settings)
void NTSCFilter::saveConfig(Settings& settings) const void NTSCFilter::saveConfig(Settings& settings) const
{ {
// Save adjustables for custom mode // Save adjustables for custom mode
settings.setFloat("tv_hue", myCustomSetup.hue); settings.setValue("tv_hue", myCustomSetup.hue);
settings.setFloat("tv_saturation", myCustomSetup.saturation); settings.setValue("tv_saturation", myCustomSetup.saturation);
settings.setFloat("tv_contrast", myCustomSetup.contrast); settings.setValue("tv_contrast", myCustomSetup.contrast);
settings.setFloat("tv_brightness", myCustomSetup.brightness); settings.setValue("tv_brightness", myCustomSetup.brightness);
settings.setFloat("tv_sharpness", myCustomSetup.sharpness); settings.setValue("tv_sharpness", myCustomSetup.sharpness);
settings.setFloat("tv_gamma", myCustomSetup.gamma); settings.setValue("tv_gamma", myCustomSetup.gamma);
settings.setFloat("tv_resolution", myCustomSetup.resolution); settings.setValue("tv_resolution", myCustomSetup.resolution);
settings.setFloat("tv_artifacts", myCustomSetup.artifacts); settings.setValue("tv_artifacts", myCustomSetup.artifacts);
settings.setFloat("tv_fringing", myCustomSetup.fringing); settings.setValue("tv_fringing", myCustomSetup.fringing);
settings.setFloat("tv_bleed", myCustomSetup.bleed); settings.setValue("tv_bleed", myCustomSetup.bleed);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -166,13 +166,12 @@ Debugger::~Debugger()
void Debugger::initialize() void Debugger::initialize()
{ {
// Get the dialog size // Get the dialog size
int w, h; const GUI::Size& size = myOSystem->settings().getSize("debuggerres");
myOSystem->settings().getSize("debuggerres", w, h); myWidth = BSPF_max(size.w, 0);
myWidth = BSPF_max(w, 0); myHeight = BSPF_max(size.h, 0);
myHeight = BSPF_max(h, 0);
myWidth = BSPF_max(myWidth, 1080u); myWidth = BSPF_max(myWidth, 1080u);
myHeight = BSPF_max(myHeight, 720u); myHeight = BSPF_max(myHeight, 720u);
myOSystem->settings().setSize("debuggerres", myWidth, myHeight); myOSystem->settings().setValue("debuggerres", GUI::Size(myWidth, myHeight));
const GUI::Rect& r = getDialogBounds(); const GUI::Rect& r = getDialogBounds();

View File

@ -174,7 +174,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
else if(rmb == "pcaddr") else if(rmb == "pcaddr")
{ {
DiStella::settings.show_addresses = !DiStella::settings.show_addresses; DiStella::settings.show_addresses = !DiStella::settings.show_addresses;
instance().settings().setBool("dis.showaddr", instance().settings().setValue("dis.showaddr",
DiStella::settings.show_addresses); DiStella::settings.show_addresses);
invalidate(); invalidate();
} }
@ -183,19 +183,19 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
if(DiStella::settings.gfx_format == kBASE_16) if(DiStella::settings.gfx_format == kBASE_16)
{ {
DiStella::settings.gfx_format = kBASE_2; DiStella::settings.gfx_format = kBASE_2;
instance().settings().setString("dis.gfxformat", "2"); instance().settings().setValue("dis.gfxformat", "2");
} }
else else
{ {
DiStella::settings.gfx_format = kBASE_16; DiStella::settings.gfx_format = kBASE_16;
instance().settings().setString("dis.gfxformat", "16"); instance().settings().setValue("dis.gfxformat", "16");
} }
invalidate(); invalidate();
} }
else if(rmb == "relocate") else if(rmb == "relocate")
{ {
DiStella::settings.rflag = !DiStella::settings.rflag; DiStella::settings.rflag = !DiStella::settings.rflag;
instance().settings().setBool("dis.relocate", instance().settings().setValue("dis.relocate",
DiStella::settings.rflag); DiStella::settings.rflag);
invalidate(); invalidate();
} }
@ -207,7 +207,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
break; break;
case kResolveDataChanged: case kResolveDataChanged:
instance().settings().setString("dis.resolvedata", myResolveData->getSelectedTag()); instance().settings().setValue("dis.resolvedata", myResolveData->getSelectedTag());
invalidate(); invalidate();
loadConfig(); loadConfig();
break; break;

View File

@ -262,7 +262,7 @@ string Cartridge::createFromMultiCart(const uInt8*& image, uInt32& size,
id = buf.str(); id = buf.str();
// Move to the next game the next time this ROM is loaded // Move to the next game the next time this ROM is loaded
settings.setInt("romloadcount", (i+1)%numroms); settings.setValue("romloadcount", (i+1)%numroms);
if(size <= 2048) return "2K"; if(size <= 2048) return "2K";
else if(size == 4096) return "4K"; else if(size == 4096) return "4K";

View File

@ -119,7 +119,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
// will take over 250 frames! // will take over 250 frames!
// The 'fastscbios' option must be changed before the system is reset // The 'fastscbios' option must be changed before the system is reset
bool fastscbios = myOSystem->settings().getBool("fastscbios"); bool fastscbios = myOSystem->settings().getBool("fastscbios");
myOSystem->settings().setBool("fastscbios", true); myOSystem->settings().setValue("fastscbios", true);
mySystem->reset(true); // autodetect in reset enabled mySystem->reset(true); // autodetect in reset enabled
for(int i = 0; i < 60; ++i) for(int i = 0; i < 60; ++i)
myTIA->update(); myTIA->update();
@ -131,7 +131,7 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
} }
// Don't forget to reset the SC progress bars again // Don't forget to reset the SC progress bars again
myOSystem->settings().setBool("fastscbios", fastscbios); myOSystem->settings().setValue("fastscbios", fastscbios);
} }
myConsoleInfo.DisplayFormat = myDisplayFormat + autodetected; myConsoleInfo.DisplayFormat = myDisplayFormat + autodetected;
@ -286,7 +286,7 @@ void Console::toggleFormat(int direction)
void Console::toggleColorLoss() void Console::toggleColorLoss()
{ {
bool colorloss = !myOSystem->settings().getBool("colorloss"); bool colorloss = !myOSystem->settings().getBool("colorloss");
myOSystem->settings().setBool("colorloss", colorloss); myOSystem->settings().setValue("colorloss", colorloss);
myTIA->enableColorLoss(colorloss); myTIA->enableColorLoss(colorloss);
string message = string("PAL color-loss ") + string message = string("PAL color-loss ") +
@ -337,7 +337,7 @@ void Console::togglePalette()
message = "Standard Stella palette"; message = "Standard Stella palette";
} }
myOSystem->settings().setString("palette", palette); myOSystem->settings().setValue("palette", palette);
myOSystem->frameBuffer().showMessage(message); myOSystem->frameBuffer().showMessage(message);
setPalette(palette); setPalette(palette);

View File

@ -274,7 +274,7 @@ void EventHandler::mapStelladaptors(const string& saport)
} }
} }
} }
myOSystem->settings().setString("saport", saport); myOSystem->settings().setValue("saport", saport);
// We're potentially swapping out an input device behind the back of // We're potentially swapping out an input device behind the back of
// the Event system, so we make sure all Stelladaptor-generated events // the Event system, so we make sure all Stelladaptor-generated events
@ -1721,7 +1721,7 @@ void EventHandler::saveKeyMapping()
for(int i = 0; i < KBDK_LAST; ++i) for(int i = 0; i < KBDK_LAST; ++i)
keybuf << ":" << myKeyTable[i][mode]; keybuf << ":" << myKeyTable[i][mode];
myOSystem->settings().setString("keymap", keybuf.str()); myOSystem->settings().setValue("keymap", keybuf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1756,7 +1756,7 @@ void EventHandler::saveJoyMapping()
for(iter = myJoystickMap.begin(); iter != myJoystickMap.end(); ++iter) for(iter = myJoystickMap.begin(); iter != myJoystickMap.end(); ++iter)
joybuf << "^" << iter->second; joybuf << "^" << iter->second;
myOSystem->settings().setString("joymap", joybuf.str()); myOSystem->settings().setValue("joymap", joybuf.str());
#endif #endif
} }
@ -1774,7 +1774,7 @@ void EventHandler::saveComboMapping()
for(int j = 1; j < kEventsPerCombo; ++j) for(int j = 1; j < kEventsPerCombo; ++j)
buf << "," << myComboTable[i][j]; buf << "," << myComboTable[i][j];
} }
myOSystem->settings().setString("combomap", buf.str()); myOSystem->settings().setValue("combomap", buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -152,7 +152,7 @@ FBInitStatus FrameBuffer::initialize(const string& title,
// Did we get the requested fullscreen state? // Did we get the requested fullscreen state?
const string& fullscreen = myOSystem->settings().getString("fullscreen"); const string& fullscreen = myOSystem->settings().getString("fullscreen");
if(fullscreen != "-1") if(fullscreen != "-1")
myOSystem->settings().setString("fullscreen", fullScreen() ? "1" : "0"); myOSystem->settings().setValue("fullscreen", fullScreen() ? "1" : "0");
setCursorState(); setCursorState();
} }
else else
@ -335,7 +335,7 @@ void FrameBuffer::toggleFrameStats()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showFrameStats(bool enable) void FrameBuffer::showFrameStats(bool enable)
{ {
myOSystem->settings().setBool("stats", enable); myOSystem->settings().setValue("stats", enable);
myStatsMsg.enabled = enable; myStatsMsg.enabled = enable;
refresh(); refresh();
} }
@ -533,7 +533,7 @@ void FrameBuffer::setNTSC(NTSCFilter::Preset preset, bool show)
const string& mode = myNTSCFilter.setPreset(preset); const string& mode = myNTSCFilter.setPreset(preset);
buf << "TV filtering (" << mode << " mode)"; buf << "TV filtering (" << mode << " mode)";
} }
myOSystem->settings().setInt("tv_filter", (int)preset); myOSystem->settings().setValue("tv_filter", (int)preset);
} }
else else
buf << "TV filtering not available in software mode"; buf << "TV filtering not available in software mode";
@ -551,7 +551,7 @@ void FrameBuffer::setScanlineIntensity(int amount)
{ {
uInt32 intensity = enableScanlines(amount); uInt32 intensity = enableScanlines(amount);
buf << "Scanline intensity at " << intensity << "%"; buf << "Scanline intensity at " << intensity << "%";
myOSystem->settings().setInt("tv_scanlines", intensity); myOSystem->settings().setValue("tv_scanlines", intensity);
} }
else else
buf << "Scanlines only available in TV filtering mode"; buf << "Scanlines only available in TV filtering mode";
@ -573,7 +573,7 @@ void FrameBuffer::toggleScanlineInterpolation()
bool enable = !myOSystem->settings().getBool("tv_scaninter"); bool enable = !myOSystem->settings().getBool("tv_scaninter");
enableScanlineInterpolation(enable); enableScanlineInterpolation(enable);
buf << "Scanline interpolation " << (enable ? "enabled" : "disabled"); buf << "Scanline interpolation " << (enable ? "enabled" : "disabled");
myOSystem->settings().setBool("tv_scaninter", enable); myOSystem->settings().setValue("tv_scaninter", enable);
} }
else else
buf << "Scanlines only available in TV filtering mode"; buf << "Scanlines only available in TV filtering mode";
@ -779,7 +779,7 @@ bool FrameBuffer::changeVidMode(int direction)
// Did we get the requested fullscreen state? // Did we get the requested fullscreen state?
const string& fullscreen = myOSystem->settings().getString("fullscreen"); const string& fullscreen = myOSystem->settings().getString("fullscreen");
if(fullscreen != "-1") if(fullscreen != "-1")
myOSystem->settings().setString("fullscreen", fullScreen() ? "1" : "0"); myOSystem->settings().setValue("fullscreen", fullScreen() ? "1" : "0");
setCursorState(); setCursorState();
if(!inUIMode) if(!inUIMode)
@ -788,7 +788,7 @@ bool FrameBuffer::changeVidMode(int direction)
showMessage(vidmode.gfxmode.description); showMessage(vidmode.gfxmode.description);
} }
if(saveModeChange) if(saveModeChange)
myOSystem->settings().setString("tia_filter", vidmode.gfxmode.name); myOSystem->settings().setValue("tia_filter", vidmode.gfxmode.name);
refresh(); refresh();
} }
@ -826,7 +826,7 @@ void FrameBuffer::setCursorState()
void FrameBuffer::toggleGrabMouse() void FrameBuffer::toggleGrabMouse()
{ {
bool state = myOSystem->settings().getBool("grabmouse"); bool state = myOSystem->settings().getBool("grabmouse");
myOSystem->settings().setBool("grabmouse", !state); myOSystem->settings().setValue("grabmouse", !state);
setCursorState(); setCursorState();
} }
@ -1156,15 +1156,14 @@ const FrameBuffer::VideoMode FrameBuffer::
if(isFullscreen && !BSPF_equalsIgnoreCase(settings.getString("fullres"), "auto")) if(isFullscreen && !BSPF_equalsIgnoreCase(settings.getString("fullres"), "auto"))
{ {
// Only use 'fullres' if it's *bigger* than the requested mode // Only use 'fullres' if it's *bigger* than the requested mode
int w, h; const GUI::Size& s = settings.getSize("fullres");
settings.getSize("fullres", w, h);
if(w != -1 && h != -1 && (uInt32)w >= myModeList[myIdx].screen_w && if(s.w != -1 && s.h != -1 && (uInt32)s.w >= myModeList[myIdx].screen_w &&
(uInt32)h >= myModeList[myIdx].screen_h) (uInt32)s.h >= myModeList[myIdx].screen_h)
{ {
VideoMode mode = myModeList[myIdx]; VideoMode mode = myModeList[myIdx];
mode.screen_w = w; mode.screen_w = s.w;
mode.screen_h = h; mode.screen_h = s.h;
mode.image_x = (mode.screen_w - mode.image_w) >> 1; mode.image_x = (mode.screen_w - mode.image_w) >> 1;
mode.image_y = (mode.screen_h - mode.image_h) >> 1; mode.image_y = (mode.screen_h - mode.image_h) >> 1;

View File

@ -357,19 +357,19 @@ void OSystem::setConfigPaths()
if(s == "") s = myBaseDir + "stella.cht"; if(s == "") s = myBaseDir + "stella.cht";
node = FilesystemNode(s); node = FilesystemNode(s);
myCheatFile = node.getPath(); myCheatFile = node.getPath();
mySettings->setString("cheatfile", node.getShortPath()); mySettings->setValue("cheatfile", node.getShortPath());
s = mySettings->getString("palettefile"); s = mySettings->getString("palettefile");
if(s == "") s = myBaseDir + "stella.pal"; if(s == "") s = myBaseDir + "stella.pal";
node = FilesystemNode(s); node = FilesystemNode(s);
myPaletteFile = node.getPath(); myPaletteFile = node.getPath();
mySettings->setString("palettefile", node.getShortPath()); mySettings->setValue("palettefile", node.getShortPath());
s = mySettings->getString("propsfile"); s = mySettings->getString("propsfile");
if(s == "") s = myBaseDir + "stella.pro"; if(s == "") s = myBaseDir + "stella.pro";
node = FilesystemNode(s); node = FilesystemNode(s);
myPropertiesFile = node.getPath(); myPropertiesFile = node.getPath();
mySettings->setString("propsfile", node.getShortPath()); mySettings->setValue("propsfile", node.getShortPath());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -477,7 +477,7 @@ fallback:
{ {
logMessage("ERROR: OpenGL mode failed, fallback to software", 0); logMessage("ERROR: OpenGL mode failed, fallback to software", 0);
delete myFrameBuffer; myFrameBuffer = NULL; delete myFrameBuffer; myFrameBuffer = NULL;
mySettings->setString("video", "soft"); mySettings->setValue("video", "soft");
FBInitStatus newstatus = createFrameBuffer(); FBInitStatus newstatus = createFrameBuffer();
if(newstatus == kSuccess) if(newstatus == kSuccess)
{ {
@ -497,7 +497,7 @@ void OSystem::createSound()
if(!mySound) if(!mySound)
mySound = MediaFactory::createAudio(this); mySound = MediaFactory::createAudio(this);
#ifndef SOUND_SUPPORT #ifndef SOUND_SUPPORT
mySettings->setBool("sound", false); mySettings->setValue("sound", false);
#endif #endif
} }
@ -523,7 +523,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
// Each time a new console is loaded, we simulate a cart removal // Each time a new console is loaded, we simulate a cart removal
// Some carts need knowledge of this, as they behave differently // Some carts need knowledge of this, as they behave differently
// based on how many power-cycles they've been through since plugged in // based on how many power-cycles they've been through since plugged in
mySettings->setInt("romloadcount", 0); mySettings->setValue("romloadcount", 0);
} }
// Create an instance of the 2600 game console // Create an instance of the 2600 game console
@ -633,7 +633,7 @@ bool OSystem::reloadConsole()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystem::createLauncher(const string& startdir) bool OSystem::createLauncher(const string& startdir)
{ {
mySettings->setString("tmpromdir", startdir); mySettings->setValue("tmpromdir", startdir);
bool status = false; bool status = false;
myEventHandler->reset(EventHandler::S_LAUNCHER); myEventHandler->reset(EventHandler::S_LAUNCHER);
@ -829,7 +829,7 @@ void OSystem::validatePath(string& path, const string& setting,
node.makeDir(); node.makeDir();
path = node.getPath(); path = node.getPath();
mySettings->setString(setting, node.getShortPath()); mySettings->setValue(setting, node.getShortPath());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -982,9 +982,8 @@ bool OSystem::queryVideoHardware()
// Check the 'maxres' setting, which is an undocumented developer feature // Check the 'maxres' setting, which is an undocumented developer feature
// that specifies the desktop size // that specifies the desktop size
// Normally, this wouldn't be set, and we ask SDL directly // Normally, this wouldn't be set, and we ask SDL directly
int w, h; const GUI::Size& s = mySettings->getSize("maxres");
mySettings->getSize("maxres", w, h); if(s.w <= 0 || s.h <= 0)
if(w <= 0 || h <= 0)
{ {
const SDL_VideoInfo* info = SDL_GetVideoInfo(); const SDL_VideoInfo* info = SDL_GetVideoInfo();
myDesktopWidth = info->current_w; myDesktopWidth = info->current_w;
@ -992,8 +991,8 @@ bool OSystem::queryVideoHardware()
} }
else else
{ {
myDesktopWidth = BSPF_max(w, 320); myDesktopWidth = BSPF_max(s.w, 320);
myDesktopHeight = BSPF_max(h, 240); myDesktopHeight = BSPF_max(s.h, 240);
} }
// Various parts of the codebase assume a minimum screen size of 320x240 // Various parts of the codebase assume a minimum screen size of 320x240

View File

@ -468,6 +468,28 @@ void Settings::usage()
<< endl << flush; << endl << flush;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Variant& Settings::value(const string& key) const
{
// Try to find the named setting and answer its value
int idx = -1;
if((idx = getInternalPos(key)) != -1)
return myInternalSettings[idx].value;
else if((idx = getExternalPos(key)) != -1)
return myExternalSettings[idx].value;
else
return EmptyVariant;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setValue(const string& key, const Variant& value)
{
if(int idx = getInternalPos(key) != -1)
setInternal(key, value, idx);
else
setExternal(key, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::saveConfig() void Settings::saveConfig()
{ {
@ -518,139 +540,6 @@ void Settings::saveConfig()
out.close(); out.close();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setInt(const string& key, const int value)
{
ostringstream stream;
stream << value;
if(int idx = getInternalPos(key) != -1)
setInternal(key, stream.str(), idx);
else
setExternal(key, stream.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setFloat(const string& key, const float value)
{
ostringstream stream;
stream << value;
if(int idx = getInternalPos(key) != -1)
setInternal(key, stream.str(), idx);
else
setExternal(key, stream.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setBool(const string& key, const bool value)
{
ostringstream stream;
stream << value;
if(int idx = getInternalPos(key) != -1)
setInternal(key, stream.str(), idx);
else
setExternal(key, stream.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setString(const string& key, const string& value)
{
if(int idx = getInternalPos(key) != -1)
setInternal(key, value, idx);
else
setExternal(key, value);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::getSize(const string& key, int& x, int& y) const
{
char c = '\0';
x = y = -1;
string size = getString(key);
istringstream buf(size);
buf >> x >> c >> y;
if(c != 'x')
x = y = -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Settings::getInt(const string& key) const
{
// Try to find the named setting and answer its value
int idx = -1;
if((idx = getInternalPos(key)) != -1)
return (int) atoi(myInternalSettings[idx].value.c_str());
else if((idx = getExternalPos(key)) != -1)
return (int) atoi(myExternalSettings[idx].value.c_str());
else
return -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float Settings::getFloat(const string& key) const
{
// Try to find the named setting and answer its value
int idx = -1;
if((idx = getInternalPos(key)) != -1)
return (float) atof(myInternalSettings[idx].value.c_str());
else if((idx = getExternalPos(key)) != -1)
return (float) atof(myExternalSettings[idx].value.c_str());
else
return -1.0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Settings::getBool(const string& key) const
{
// Try to find the named setting and answer its value
int idx = -1;
if((idx = getInternalPos(key)) != -1)
{
const string& value = myInternalSettings[idx].value;
if(value == "1" || value == "true")
return true;
else if(value == "0" || value == "false")
return false;
else
return false;
}
else if((idx = getExternalPos(key)) != -1)
{
const string& value = myExternalSettings[idx].value;
if(value == "1" || value == "true")
return true;
else if(value == "0" || value == "false")
return false;
else
return false;
}
else
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& Settings::getString(const string& key) const
{
// Try to find the named setting and answer its value
int idx = -1;
if((idx = getInternalPos(key)) != -1)
return myInternalSettings[idx].value;
else if((idx = getExternalPos(key)) != -1)
return myExternalSettings[idx].value;
else
return EmptyString;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Settings::setSize(const string& key, const int value1, const int value2)
{
ostringstream buf;
buf << value1 << "x" << value2;
setString(key, buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Settings::getInternalPos(const string& key) const int Settings::getInternalPos(const string& key) const
{ {
@ -672,7 +561,7 @@ int Settings::getExternalPos(const string& key) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Settings::setInternal(const string& key, const string& value, int Settings::setInternal(const string& key, const Variant& value,
int pos, bool useAsInitial) int pos, bool useAsInitial)
{ {
int idx = -1; int idx = -1;
@ -727,7 +616,7 @@ int Settings::setInternal(const string& key, const string& value,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Settings::setExternal(const string& key, const string& value, int Settings::setExternal(const string& key, const Variant& value,
int pos, bool useAsInitial) int pos, bool useAsInitial)
{ {
int idx = -1; int idx = -1;

View File

@ -23,6 +23,7 @@
class OSystem; class OSystem;
#include "Array.hxx" #include "Array.hxx"
#include "Variant.hxx"
#include "bspf.hxx" #include "bspf.hxx"
/** /**
@ -66,89 +67,32 @@ class Settings
void usage(); void usage();
/** /**
Get the value assigned to the specified key. If the key does Get the value assigned to the specified key.
not exist then -1 is returned.
@param key The key of the setting to lookup @param key The key of the setting to lookup
@return The integer value of the setting @return The (variant) value of the setting
*/ */
int getInt(const string& key) const; const Variant& value(const string& key) const;
/** /**
Get the value assigned to the specified key. If the key does Set the value associated with the specified key.
not exist then -1.0 is returned.
@param key The key of the setting
@param value The (variant) value to assign to the setting
*/
void setValue(const string& key, const Variant& value);
/**
Convenience methods to return specific types.
@param key The key of the setting to lookup @param key The key of the setting to lookup
@return The floating point value of the setting @return The specific type value of the setting
*/ */
float getFloat(const string& key) const; 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(); }
Get the value assigned to the specified key. If the key does const string& getString(const string& key) const { return value(key).toString(); }
not exist then false is returned. const GUI::Size getSize(const string& key) const { return value(key).toSize(); }
@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;
/**
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);
/**
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);
protected: protected:
/** /**
@ -184,8 +128,8 @@ class Settings
struct Setting struct Setting
{ {
string key; string key;
string value; Variant value;
string initialValue; Variant initialValue;
}; };
typedef Common::Array<Setting> SettingsArray; typedef Common::Array<Setting> SettingsArray;
@ -199,9 +143,9 @@ class Settings
int getExternalPos(const string& key) const; int getExternalPos(const string& key) const;
/** Add key,value pair to specified array at specified position */ /** Add key,value pair to specified array at specified position */
int setInternal(const string& key, const string& value, int setInternal(const string& key, const Variant& value,
int pos = -1, bool useAsInitial = false); int pos = -1, bool useAsInitial = false);
int setExternal(const string& key, const string& value, int setExternal(const string& key, const Variant& value,
int pos = -1, bool useAsInitial = false); int pos = -1, bool useAsInitial = false);
private: private:

View File

@ -155,14 +155,14 @@ void AudioDialog::saveConfig()
Settings& settings = instance().settings(); Settings& settings = instance().settings();
// Volume // Volume
settings.setInt("volume", myVolumeSlider->getValue()); settings.setValue("volume", myVolumeSlider->getValue());
instance().sound().setVolume(myVolumeSlider->getValue()); instance().sound().setVolume(myVolumeSlider->getValue());
// Fragsize // Fragsize
settings.setString("fragsize", myFragsizePopup->getSelectedTag()); settings.setValue("fragsize", myFragsizePopup->getSelectedTag());
// Output frequency // Output frequency
settings.setString("freq", myFreqPopup->getSelectedTag()); settings.setValue("freq", myFreqPopup->getSelectedTag());
// Enable/disable sound (requires a restart to take effect) // Enable/disable sound (requires a restart to take effect)
instance().sound().setEnabled(mySoundEnableCheckbox->getState()); instance().sound().setEnabled(mySoundEnableCheckbox->getState());

View File

@ -213,17 +213,17 @@ void FileSnapDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::saveConfig() void FileSnapDialog::saveConfig()
{ {
instance().settings().setString("romdir", myRomPath->getEditString()); instance().settings().setValue("romdir", myRomPath->getEditString());
instance().settings().setString("snapsavedir", mySnapSavePath->getEditString()); instance().settings().setValue("snapsavedir", mySnapSavePath->getEditString());
instance().settings().setString("snaploaddir", mySnapLoadPath->getEditString()); instance().settings().setValue("snaploaddir", mySnapLoadPath->getEditString());
instance().settings().setString("cheatfile", myCheatFile->getEditString()); instance().settings().setValue("cheatfile", myCheatFile->getEditString());
instance().settings().setString("palettefile", myPaletteFile->getEditString()); instance().settings().setValue("palettefile", myPaletteFile->getEditString());
instance().settings().setString("propsfile", myPropsFile->getEditString()); instance().settings().setValue("propsfile", myPropsFile->getEditString());
instance().settings().setString("statedir", myStatePath->getEditString()); instance().settings().setValue("statedir", myStatePath->getEditString());
instance().settings().setString("nvramdir", myNVRamPath->getEditString()); instance().settings().setValue("nvramdir", myNVRamPath->getEditString());
instance().settings().setBool("sssingle", mySnapSingle->getState()); instance().settings().setValue("sssingle", mySnapSingle->getState());
instance().settings().setBool("ss1x", mySnap1x->getState()); instance().settings().setValue("ss1x", mySnap1x->getState());
instance().settings().setString("ssinterval", mySnapInterval->getSelectedTag()); instance().settings().setValue("ssinterval", mySnapInterval->getSelectedTag());
// Flush changes to disk and inform the OSystem // Flush changes to disk and inform the OSystem
instance().saveConfig(); instance().saveConfig();

View File

@ -202,23 +202,23 @@ void GlobalPropsDialog::saveConfig()
s = myBSType->getSelectedTag(); s = myBSType->getSelectedTag();
if(s == "AUTO") s = ""; if(s == "AUTO") s = "";
settings.setString("bs", s); settings.setValue("bs", s);
s = myLeftDiff->getSelectedTag(); s = myLeftDiff->getSelectedTag();
if(s == "DEFAULT") s = ""; if(s == "DEFAULT") s = "";
settings.setString("ld", s); settings.setValue("ld", s);
s = myRightDiff->getSelectedTag(); s = myRightDiff->getSelectedTag();
if(s == "DEFAULT") s = ""; if(s == "DEFAULT") s = "";
settings.setString("rd", s); settings.setValue("rd", s);
s = myTVType->getSelectedTag(); s = myTVType->getSelectedTag();
if(s == "DEFAULT") s = ""; if(s == "DEFAULT") s = "";
settings.setString("tv", s); settings.setValue("tv", s);
settings.setBool("holdselect", myHoldSelect->getState()); settings.setValue("holdselect", myHoldSelect->getState());
settings.setBool("holdreset", myHoldReset->getState()); settings.setValue("holdreset", myHoldReset->getState());
settings.setBool("holdbutton0", myHoldButton0->getState()); settings.setValue("holdbutton0", myHoldButton0->getState());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -238,32 +238,32 @@ void InputDialog::saveConfig()
// Joystick deadzone // Joystick deadzone
int deadzone = myDeadzone->getValue(); int deadzone = myDeadzone->getValue();
instance().settings().setInt("joydeadzone", deadzone); instance().settings().setValue("joydeadzone", deadzone);
Joystick::setDeadZone(deadzone); Joystick::setDeadZone(deadzone);
// Grab mouse // Grab mouse
instance().settings().setBool("grabmouse", myGrabMouse->getState()); instance().settings().setValue("grabmouse", myGrabMouse->getState());
instance().frameBuffer().setCursorState(); instance().frameBuffer().setCursorState();
// Paddle speed (digital and mouse) // Paddle speed (digital and mouse)
int sensitivity = myDPaddleSpeed->getValue(); int sensitivity = myDPaddleSpeed->getValue();
instance().settings().setInt("dsense", sensitivity); instance().settings().setValue("dsense", sensitivity);
Paddles::setDigitalSensitivity(sensitivity); Paddles::setDigitalSensitivity(sensitivity);
sensitivity = myMPaddleSpeed->getValue(); sensitivity = myMPaddleSpeed->getValue();
instance().settings().setInt("msense", sensitivity); instance().settings().setValue("msense", sensitivity);
Paddles::setMouseSensitivity(sensitivity); Paddles::setMouseSensitivity(sensitivity);
// AtariVox serial port // AtariVox serial port
instance().settings().setString("avoxport", myAVoxPort->getEditString()); instance().settings().setValue("avoxport", myAVoxPort->getEditString());
// Allow all 4 joystick directions // Allow all 4 joystick directions
bool allowall4 = myAllowAll4->getState(); bool allowall4 = myAllowAll4->getState();
instance().settings().setBool("joyallow4", allowall4); instance().settings().setValue("joyallow4", allowall4);
instance().eventHandler().allowAllDirections(allowall4); instance().eventHandler().allowAllDirections(allowall4);
// Use mouse as a controller // Use mouse as a controller
bool usemouse = myMouseControl->getState(); bool usemouse = myMouseControl->getState();
instance().settings().setBool("usemouse", usemouse); instance().settings().setValue("usemouse", usemouse);
instance().eventHandler().setMouseControllerMode(usemouse); instance().eventHandler().setMouseControllerMode(usemouse);
} }

View File

@ -31,7 +31,8 @@
Launcher::Launcher(OSystem* osystem) Launcher::Launcher(OSystem* osystem)
: DialogContainer(osystem) : DialogContainer(osystem)
{ {
myOSystem->settings().getSize("launcherres", (int&)myWidth, (int&)myHeight); const GUI::Size& s = myOSystem->settings().getSize("launcherres");
myWidth = s.w; myHeight = s.h;
// The launcher dialog is resizable, within certain bounds // The launcher dialog is resizable, within certain bounds
// We check those bounds now // We check those bounds now
@ -40,7 +41,8 @@ Launcher::Launcher(OSystem* osystem)
myWidth = BSPF_min(myWidth, osystem->desktopWidth()); myWidth = BSPF_min(myWidth, osystem->desktopWidth());
myHeight = BSPF_min(myHeight, osystem->desktopHeight()); myHeight = BSPF_min(myHeight, osystem->desktopHeight());
myOSystem->settings().setSize("launcherres", myWidth, myHeight); myOSystem->settings().setValue("launcherres",
GUI::Size(myWidth, myHeight));
myBaseDialog = new LauncherDialog(myOSystem, this, 0, 0, myWidth, myHeight); myBaseDialog = new LauncherDialog(myOSystem, this, 0, 0, myWidth, myHeight);
} }

View File

@ -526,7 +526,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
const string& result = const string& result =
instance().createConsole(romnode, myGameList->md5(item)); instance().createConsole(romnode, myGameList->md5(item));
if(result == EmptyString) if(result == EmptyString)
instance().settings().setString("lastrom", myList->getSelectedString()); instance().settings().setValue("lastrom", myList->getSelectedString());
else else
instance().frameBuffer().showMessage(result, kMiddleCenter, true); instance().frameBuffer().showMessage(result, kMiddleCenter, true);
} }
@ -569,7 +569,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
case kStartupRomDirChosenCmd: case kStartupRomDirChosenCmd:
{ {
FilesystemNode dir(myRomDir->getResult()); FilesystemNode dir(myRomDir->getResult());
instance().settings().setString("romdir", dir.getShortPath()); instance().settings().setValue("romdir", dir.getShortPath());
// fall through to the next case // fall through to the next case
} }
case kRomDirChosenCmd: case kRomDirChosenCmd:

View File

@ -175,7 +175,7 @@ void LauncherFilterDialog::saveConfig()
{ {
const string& type = myFileType->getSelectedTag(); const string& type = myFileType->getSelectedTag();
if(type == "allfiles" || type == "allroms") if(type == "allfiles" || type == "allroms")
instance().settings().setString("launcherexts", type); instance().settings().setValue("launcherexts", type);
else else
{ {
ostringstream buf; ostringstream buf;
@ -185,9 +185,9 @@ void LauncherFilterDialog::saveConfig()
// No ROMs selected means use all files // No ROMs selected means use all files
if(buf.str() == "") if(buf.str() == "")
instance().settings().setString("launcherexts", "allfiles"); instance().settings().setValue("launcherexts", "allfiles");
else else
instance().settings().setString("launcherexts", buf.str()); instance().settings().setValue("launcherexts", buf.str());
} }
// Let parent know about the changes // Let parent know about the changes

View File

@ -107,9 +107,9 @@ void LoggerDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LoggerDialog::saveConfig() void LoggerDialog::saveConfig()
{ {
instance().settings().setString("loglevel", instance().settings().setValue("loglevel",
myLogLevel->getSelectedTag()); myLogLevel->getSelectedTag());
instance().settings().setBool("logtoconsole", myLogToConsole->getState()); instance().settings().setValue("logtoconsole", myLogToConsole->getState());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -40,9 +40,48 @@ struct Point
Point() : x(0), y(0) {}; Point() : x(0), y(0) {};
Point(const Point & p) : x(p.x), y(p.y) {}; Point(const Point & p) : x(p.x), y(p.y) {};
explicit Point(int x1, int y1) : x(x1), y(y1) {}; explicit Point(int x1, int y1) : x(x1), y(y1) {};
Point(const string& p) {
char c = '\0';
x = y = -1;
istringstream buf(p);
buf >> x >> c >> y;
if(c != 'x')
x = y = 0;
}
Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; }; Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; };
bool operator==(const Point & p) const { return x == p.x && y == p.y; }; bool operator==(const Point & p) const { return x == p.x && y == p.y; };
bool operator!=(const Point & p) const { return x != p.x || y != p.y; }; bool operator!=(const Point & p) const { return x != p.x || y != p.y; };
friend ostream& operator<<(ostream& os, const Point& p) {
os << p.x << "x" << p.y;
return os;
}
};
struct Size
{
int w; //!< The width part of the size
int h; //!< The height part of the size
Size() : w(0), h(0) {};
Size(const Size & s) : w(s.w), h(s.h) {};
explicit Size(int w1, int h1) : w(w1), h(h1) {};
Size(const string& s) {
char c = '\0';
w = h = -1;
istringstream buf(s);
buf >> w >> c >> h;
if(c != 'x')
w = h = -1;
}
Size & operator=(const Size & s) { w = s.w; h = s.h; return *this; };
bool operator==(const Size & s) const { return w == s.w && h == s.h; };
bool operator!=(const Size & s) const { return w != s.w || h != s.h; };
friend ostream& operator<<(ostream& os, const Size& s) {
os << s.w << "x" << s.h;
return os;
}
}; };
/* /*
@ -73,13 +112,18 @@ struct Rect
{ {
assert(isValidRect()); assert(isValidRect());
} }
int x() const { return left; } int x() const { return left; }
int y() const { return top; } int y() const { return top; }
Point point() const { return Point(x(), y()); }
int width() const { return right - left; } int width() const { return right - left; }
int height() const { return bottom - top; } int height() const { return bottom - top; }
Size size() const { return Size(width(), height()); }
void setWidth(int aWidth) { right = left + aWidth; } void setWidth(int aWidth) { right = left + aWidth; }
void setHeight(int aHeight) { bottom = top + aHeight; } void setHeight(int aHeight) { bottom = top + aHeight; }
void setSize(const Size& size) { setWidth(size.w); setHeight(size.h); }
/* /*
@param x the horizontal position to check @param x the horizontal position to check
@ -166,8 +210,7 @@ struct Rect
} }
friend ostream& operator<<(ostream& os, const Rect& r) { friend ostream& operator<<(ostream& os, const Rect& r) {
os << "x=" << r.x() << ", y=" << r.y() os << "Point: " << r.point() << ", Size: " << r.size();
<< ", w=" << r.width() << ", h=" << r.height();
return os; return os;
} }
}; };

View File

@ -285,10 +285,10 @@ UIDialog::~UIDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UIDialog::loadConfig() void UIDialog::loadConfig()
{ {
int w, h;
// Launcher size // Launcher size
instance().settings().getSize("launcherres", w, h); const GUI::Size& ls = instance().settings().getSize("launcherres");
int w = ls.w, h = ls.h;
w = BSPF_max(w, 320); w = BSPF_max(w, 320);
h = BSPF_max(h, 240); h = BSPF_max(h, 240);
w = BSPF_min(w, 1920); w = BSPF_min(w, 1920);
@ -313,7 +313,8 @@ void UIDialog::loadConfig()
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
// Debugger size // Debugger size
instance().settings().getSize("debuggerres", w, h); const GUI::Size& ds = instance().settings().getSize("debuggerres");
w = ds.w, h = ds.h;
w = BSPF_max(w, 1080); w = BSPF_max(w, 1080);
h = BSPF_max(h, 720); h = BSPF_max(h, 720);
w = BSPF_min(w, 1920); w = BSPF_min(w, 1920);
@ -344,36 +345,38 @@ void UIDialog::loadConfig()
void UIDialog::saveConfig() void UIDialog::saveConfig()
{ {
// Launcher size // Launcher size
instance().settings().setSize("launcherres", instance().settings().setValue("launcherres",
myLauncherWidthSlider->getValue(), myLauncherHeightSlider->getValue()); GUI::Size(myLauncherWidthSlider->getValue(),
myLauncherHeightSlider->getValue()));
// Launcher font // Launcher font
instance().settings().setString("launcherfont", instance().settings().setValue("launcherfont",
myLauncherFontPopup->getSelectedTag()); myLauncherFontPopup->getSelectedTag());
// ROM launcher info viewer // ROM launcher info viewer
instance().settings().setString("romviewer", instance().settings().setValue("romviewer",
myRomViewerPopup->getSelectedTag()); myRomViewerPopup->getSelectedTag());
// Exit to Launcher // Exit to Launcher
instance().settings().setString("exitlauncher", instance().settings().setValue("exitlauncher",
myLauncherExitPopup->getSelectedTag()); myLauncherExitPopup->getSelectedTag());
// Debugger size // Debugger size
instance().settings().setSize("debuggerres", instance().settings().setValue("debuggerres",
myDebuggerWidthSlider->getValue(), myDebuggerHeightSlider->getValue()); GUI::Size(myDebuggerWidthSlider->getValue(),
myDebuggerHeightSlider->getValue()));
// UI palette // UI palette
instance().settings().setString("uipalette", instance().settings().setValue("uipalette",
myPalettePopup->getSelectedTag()); myPalettePopup->getSelectedTag());
// Listwidget quick delay // Listwidget quick delay
instance().settings().setString("listdelay", instance().settings().setValue("listdelay",
myListDelayPopup->getSelectedTag()); myListDelayPopup->getSelectedTag());
ListWidget::setQuickSelectDelay(atoi(myListDelayPopup->getSelectedTag().c_str())); ListWidget::setQuickSelectDelay(atoi(myListDelayPopup->getSelectedTag().c_str()));
// Mouse wheel lines // Mouse wheel lines
instance().settings().setString("mwheel", instance().settings().setValue("mwheel",
myWheelLinesPopup->getSelectedTag()); myWheelLinesPopup->getSelectedTag());
ScrollBarWidget::setWheelLines(atoi(myWheelLinesPopup->getSelectedTag().c_str())); ScrollBarWidget::setWheelLines(atoi(myWheelLinesPopup->getSelectedTag().c_str()));
} }

View File

@ -495,31 +495,31 @@ void VideoDialog::loadConfig()
void VideoDialog::saveConfig() void VideoDialog::saveConfig()
{ {
// Renderer setting // Renderer setting
instance().settings().setString("video", myRendererPopup->getSelectedTag()); instance().settings().setValue("video", myRendererPopup->getSelectedTag());
// TIA Filter // TIA Filter
instance().settings().setString("tia_filter", myTIAFilterPopup->getSelectedTag()); instance().settings().setValue("tia_filter", myTIAFilterPopup->getSelectedTag());
// TIA Palette // TIA Palette
instance().settings().setString("palette", myTIAPalettePopup->getSelectedTag()); instance().settings().setValue("palette", myTIAPalettePopup->getSelectedTag());
// Fullscreen resolution // Fullscreen resolution
instance().settings().setString("fullres", myFSResPopup->getSelectedTag()); instance().settings().setValue("fullres", myFSResPopup->getSelectedTag());
// Wait between frames // Wait between frames
instance().settings().setString("timing", myFrameTimingPopup->getSelectedTag()); instance().settings().setValue("timing", myFrameTimingPopup->getSelectedTag());
// GL Filter setting // GL Filter setting
instance().settings().setBool("gl_inter", instance().settings().setValue("gl_inter",
myGLFilterPopup->getSelectedTag() == "linear" ? true : false); myGLFilterPopup->getSelectedTag() == "linear" ? true : false);
// GL aspect ratio setting (NTSC and PAL) // GL aspect ratio setting (NTSC and PAL)
instance().settings().setString("gl_aspectn", myNAspectRatioLabel->getLabel()); instance().settings().setValue("gl_aspectn", myNAspectRatioLabel->getLabel());
instance().settings().setString("gl_aspectp", myPAspectRatioLabel->getLabel()); instance().settings().setValue("gl_aspectp", myPAspectRatioLabel->getLabel());
// Framerate // Framerate
int i = myFrameRateSlider->getValue(); int i = myFrameRateSlider->getValue();
instance().settings().setInt("framerate", i); instance().settings().setValue("framerate", i);
if(&instance().console()) if(&instance().console())
{ {
// Make sure auto-frame calculation is only enabled when necessary // Make sure auto-frame calculation is only enabled when necessary
@ -528,30 +528,30 @@ void VideoDialog::saveConfig()
} }
// Fullscreen // Fullscreen
instance().settings().setString("fullscreen", myFullscreenPopup->getSelectedTag()); instance().settings().setValue("fullscreen", myFullscreenPopup->getSelectedTag());
// PAL color-loss effect // PAL color-loss effect
instance().settings().setBool("colorloss", myColorLossCheckbox->getState()); instance().settings().setValue("colorloss", myColorLossCheckbox->getState());
if(&instance().console()) if(&instance().console())
instance().console().toggleColorLoss(myColorLossCheckbox->getState()); instance().console().toggleColorLoss(myColorLossCheckbox->getState());
// GL stretch setting // GL stretch setting
instance().settings().setBool("gl_fsscale", myGLStretchCheckbox->getState()); instance().settings().setValue("gl_fsscale", myGLStretchCheckbox->getState());
// Use sync to vertical blank (GL mode only) // Use sync to vertical blank (GL mode only)
instance().settings().setBool("gl_vsync", myUseVSyncCheckbox->getState()); instance().settings().setValue("gl_vsync", myUseVSyncCheckbox->getState());
// Show UI messages // Show UI messages
instance().settings().setBool("uimessages", myUIMessagesCheckbox->getState()); instance().settings().setValue("uimessages", myUIMessagesCheckbox->getState());
// Center window // Center window
instance().settings().setBool("center", myCenterCheckbox->getState()); instance().settings().setValue("center", myCenterCheckbox->getState());
// Fast loading of Supercharger BIOS // Fast loading of Supercharger BIOS
instance().settings().setBool("fastscbios", myFastSCBiosCheckbox->getState()); instance().settings().setValue("fastscbios", myFastSCBiosCheckbox->getState());
// TV Mode // TV Mode
instance().settings().setString("tv_filter", myTVMode->getSelectedTag()); instance().settings().setValue("tv_filter", myTVMode->getSelectedTag());
// TV Custom adjustables // TV Custom adjustables
NTSCFilter::Adjustable adj; NTSCFilter::Adjustable adj;
@ -568,8 +568,8 @@ void VideoDialog::saveConfig()
instance().frameBuffer().ntsc().setCustomAdjustables(adj); instance().frameBuffer().ntsc().setCustomAdjustables(adj);
// TV scanline intensity and interpolation // TV scanline intensity and interpolation
instance().settings().setString("tv_scanlines", myTVScanIntenseLabel->getLabel()); instance().settings().setValue("tv_scanlines", myTVScanIntenseLabel->getLabel());
instance().settings().setBool("tv_scaninter", myTVScanInterpolate->getState()); instance().settings().setValue("tv_scaninter", myTVScanInterpolate->getState());
// Finally, issue a complete framebuffer re-initialization // Finally, issue a complete framebuffer re-initialization
instance().createFrameBuffer(); instance().createFrameBuffer();