Refactored snapshot-related UI code into a new 'Snapshot Settings' dialog,

since it was getting too unwieldy for 'Config Paths', and didn't properly
belong there anyway.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2751 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-06-19 20:28:41 +00:00
parent f01bd88cfb
commit 125d7542d5
13 changed files with 364 additions and 218 deletions

View File

@ -22,7 +22,7 @@
#include <cstdlib> #include <cstdlib>
#define STELLA_VERSION "3.9_beta1" #define STELLA_VERSION "3.9_beta2"
#define STELLA_BUILD atoi("$Rev$" + 6) #define STELLA_BUILD atoi("$Rev$" + 6)
#endif #endif

View File

@ -15,9 +15,6 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id$ // $Id$
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -29,10 +26,10 @@
#include "PopUpWidget.hxx" #include "PopUpWidget.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "FileSnapDialog.hxx" #include "ConfigPathDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileSnapDialog::FileSnapDialog( ConfigPathDialog::ConfigPathDialog(
OSystem* osystem, DialogContainer* parent, OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, GuiObject* boss, const GUI::Font& font, GuiObject* boss,
int max_w, int max_h) int max_w, int max_h)
@ -43,7 +40,7 @@ FileSnapDialog::FileSnapDialog(
{ {
const int lineHeight = font.getLineHeight(), const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(), fontWidth = font.getMaxCharWidth(),
buttonWidth = font.getStringWidth("Snapshot load path:") + 20, buttonWidth = font.getStringWidth("Properties file:") + 20,
buttonHeight = font.getLineHeight() + 4; buttonHeight = font.getLineHeight() + 4;
const int vBorder = 8; const int vBorder = 8;
int xpos, ypos; int xpos, ypos;
@ -52,7 +49,7 @@ FileSnapDialog::FileSnapDialog(
// Set real dimensions // Set real dimensions
_w = 56 * fontWidth + 8; _w = 56 * fontWidth + 8;
_h = 13 * (lineHeight + 4) + 10; _h = 9 * (lineHeight + 4) + 10;
xpos = vBorder; ypos = vBorder; xpos = vBorder; ypos = vBorder;
@ -66,28 +63,8 @@ FileSnapDialog::FileSnapDialog(
_w - xpos - 10, lineHeight, ""); _w - xpos - 10, lineHeight, "");
wid.push_back(myRomPath); wid.push_back(myRomPath);
// Snapshot path (save files)
xpos = vBorder; ypos += romButton->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Snapshot save path:", kChooseSnapSaveDirCmd);
wid.push_back(b);
xpos += buttonWidth + 10;
mySnapSavePath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, lineHeight, "");
wid.push_back(mySnapSavePath);
// Snapshot path (load files)
xpos = vBorder; ypos += romButton->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Snapshot load path:", kChooseSnapLoadDirCmd);
wid.push_back(b);
xpos += buttonWidth + 10;
mySnapLoadPath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, lineHeight, "");
wid.push_back(mySnapLoadPath);
// Cheat file // Cheat file
xpos = vBorder; ypos += b->getHeight() + 3; xpos = vBorder; ypos += romButton->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Cheat file:", kChooseCheatFileCmd); "Cheat file:", kChooseCheatFileCmd);
wid.push_back(b); wid.push_back(b);
@ -136,37 +113,6 @@ FileSnapDialog::FileSnapDialog(
_w - xpos - 10, lineHeight, ""); _w - xpos - 10, lineHeight, "");
wid.push_back(myNVRamPath); wid.push_back(myNVRamPath);
// Snapshot single or multiple saves
xpos = 30; ypos += b->getHeight() + 5;
mySnapSingle = new CheckboxWidget(this, font, xpos, ypos,
"Overwrite snapshots");
wid.push_back(mySnapSingle);
// Snapshot in 1x mode (ignore scaling)
xpos += mySnapSingle->getWidth() + 20;
mySnap1x = new CheckboxWidget(this, font, xpos, ypos,
"Snapshot in 1x mode");
wid.push_back(mySnap1x);
// Snapshot interval (continuous mode)
VariantList items;
items.clear();
items.push_back("1 second", "1");
items.push_back("2 seconds", "2");
items.push_back("3 seconds", "3");
items.push_back("4 seconds", "4");
items.push_back("5 seconds", "5");
items.push_back("6 seconds", "6");
items.push_back("7 seconds", "7");
items.push_back("8 seconds", "8");
items.push_back("9 seconds", "9");
items.push_back("10 seconds", "10");
xpos = 30; ypos += b->getHeight();
mySnapInterval = new PopUpWidget(this, font, xpos, ypos,
font.getStringWidth("10 seconds"), lineHeight,
items, "Continuous snapshot interval: ");
wid.push_back(mySnapInterval);
// Add Defaults, OK and Cancel buttons // Add Defaults, OK and Cancel buttons
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10, b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
font.getStringWidth("Defaults") + 20, buttonHeight, font.getStringWidth("Defaults") + 20, buttonHeight,
@ -188,43 +134,32 @@ FileSnapDialog::FileSnapDialog(
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileSnapDialog::~FileSnapDialog() ConfigPathDialog::~ConfigPathDialog()
{ {
delete myBrowser; delete myBrowser;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::loadConfig() void ConfigPathDialog::loadConfig()
{ {
const Settings& settings = instance().settings(); const Settings& settings = instance().settings();
myRomPath->setText(settings.getString("romdir")); myRomPath->setText(settings.getString("romdir"));
mySnapSavePath->setText(settings.getString("snapsavedir"));
mySnapLoadPath->setText(settings.getString("snaploaddir"));
myCheatFile->setText(settings.getString("cheatfile")); myCheatFile->setText(settings.getString("cheatfile"));
myPaletteFile->setText(settings.getString("palettefile")); myPaletteFile->setText(settings.getString("palettefile"));
myPropsFile->setText(settings.getString("propsfile")); myPropsFile->setText(settings.getString("propsfile"));
myNVRamPath->setText(settings.getString("nvramdir")); myNVRamPath->setText(settings.getString("nvramdir"));
myStatePath->setText(settings.getString("statedir")); myStatePath->setText(settings.getString("statedir"));
mySnapSingle->setState(settings.getBool("sssingle"));
mySnap1x->setState(settings.getBool("ss1x"));
mySnapInterval->setSelected(instance().settings().getString("ssinterval"), "2");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::saveConfig() void ConfigPathDialog::saveConfig()
{ {
instance().settings().setValue("romdir", myRomPath->getText()); instance().settings().setValue("romdir", myRomPath->getText());
instance().settings().setValue("snapsavedir", mySnapSavePath->getText());
instance().settings().setValue("snaploaddir", mySnapLoadPath->getText());
instance().settings().setValue("cheatfile", myCheatFile->getText()); instance().settings().setValue("cheatfile", myCheatFile->getText());
instance().settings().setValue("palettefile", myPaletteFile->getText()); instance().settings().setValue("palettefile", myPaletteFile->getText());
instance().settings().setValue("propsfile", myPropsFile->getText()); instance().settings().setValue("propsfile", myPropsFile->getText());
instance().settings().setValue("statedir", myStatePath->getText()); instance().settings().setValue("statedir", myStatePath->getText());
instance().settings().setValue("nvramdir", myNVRamPath->getText()); instance().settings().setValue("nvramdir", myNVRamPath->getText());
instance().settings().setValue("sssingle", mySnapSingle->getState());
instance().settings().setValue("ss1x", mySnap1x->getState());
instance().settings().setValue("ssinterval",
mySnapInterval->getSelectedTag().toString());
// Flush changes to disk and inform the OSystem // Flush changes to disk and inform the OSystem
instance().saveConfig(); instance().saveConfig();
@ -232,7 +167,7 @@ void FileSnapDialog::saveConfig()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::setDefaults() void ConfigPathDialog::setDefaults()
{ {
FilesystemNode node; FilesystemNode node;
const string& basedir = instance().baseDir(); const string& basedir = instance().baseDir();
@ -240,9 +175,6 @@ void FileSnapDialog::setDefaults()
node = FilesystemNode("~"); node = FilesystemNode("~");
myRomPath->setText(node.getShortPath()); myRomPath->setText(node.getShortPath());
mySnapSavePath->setText(instance().defaultSnapSaveDir());
mySnapLoadPath->setText(instance().defaultSnapLoadDir());
const string& cheatfile = basedir + "stella.cht"; const string& cheatfile = basedir + "stella.cht";
node = FilesystemNode(cheatfile); node = FilesystemNode(cheatfile);
myCheatFile->setText(node.getShortPath()); myCheatFile->setText(node.getShortPath());
@ -262,14 +194,10 @@ void FileSnapDialog::setDefaults()
const string& statedir = basedir + "state"; const string& statedir = basedir + "state";
node = FilesystemNode(statedir); node = FilesystemNode(statedir);
myStatePath->setText(node.getShortPath()); myStatePath->setText(node.getShortPath());
mySnapSingle->setState(false);
mySnap1x->setState(false);
mySnapInterval->setSelected("2", "2");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::handleCommand(CommandSender* sender, int cmd, void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id) int data, int id)
{ {
switch (cmd) switch (cmd)
@ -277,8 +205,8 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
case kOKCmd: case kOKCmd:
saveConfig(); saveConfig();
close(); close();
if(myIsGlobal) if(myIsGlobal) // Let the boss know romdir has changed
sendCommand(kRomDirChosenCmd, 0, 0); // Let the boss know romdir has changed sendCommand(LauncherDialog::kRomDirChosenCmd, 0, 0);
break; break;
case kDefaultsCmd: case kDefaultsCmd:
@ -287,17 +215,7 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
case kChooseRomDirCmd: case kChooseRomDirCmd:
myBrowser->show("Select ROM directory:", myRomPath->getText(), myBrowser->show("Select ROM directory:", myRomPath->getText(),
BrowserDialog::Directories, kRomDirChosenCmd); BrowserDialog::Directories, LauncherDialog::kRomDirChosenCmd);
break;
case kChooseSnapSaveDirCmd:
myBrowser->show("Select snapshot save directory:", mySnapSavePath->getText(),
BrowserDialog::Directories, kSnapSaveDirChosenCmd);
break;
case kChooseSnapLoadDirCmd:
myBrowser->show("Select snapshot load directory:", mySnapLoadPath->getText(),
BrowserDialog::Directories, kSnapLoadDirChosenCmd);
break; break;
case kChooseCheatFileCmd: case kChooseCheatFileCmd:
@ -325,56 +243,32 @@ void FileSnapDialog::handleCommand(CommandSender* sender, int cmd,
BrowserDialog::Directories, kStateDirChosenCmd); BrowserDialog::Directories, kStateDirChosenCmd);
break; break;
case kRomDirChosenCmd: case LauncherDialog::kRomDirChosenCmd:
{
myRomPath->setText(myBrowser->getResult().getShortPath()); myRomPath->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kSnapSaveDirChosenCmd:
{
mySnapSavePath->setText(myBrowser->getResult().getShortPath());
break;
}
case kSnapLoadDirChosenCmd:
{
mySnapLoadPath->setText(myBrowser->getResult().getShortPath());
break;
}
case kCheatFileChosenCmd: case kCheatFileChosenCmd:
{
myCheatFile->setText(myBrowser->getResult().getShortPath()); myCheatFile->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kPaletteFileChosenCmd: case kPaletteFileChosenCmd:
{
myPaletteFile->setText(myBrowser->getResult().getShortPath()); myPaletteFile->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kPropsFileChosenCmd: case kPropsFileChosenCmd:
{
myPropsFile->setText(myBrowser->getResult().getShortPath()); myPropsFile->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kNVRamDirChosenCmd: case kNVRamDirChosenCmd:
{
myNVRamPath->setText(myBrowser->getResult().getShortPath()); myNVRamPath->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kStateDirChosenCmd: case kStateDirChosenCmd:
{
myStatePath->setText(myBrowser->getResult().getShortPath()); myStatePath->setText(myBrowser->getResult().getShortPath());
break; break;
}
case kReloadRomDirCmd: case LauncherDialog::kReloadRomDirCmd:
sendCommand(kReloadRomDirCmd, 0, 0); sendCommand(LauncherDialog::kReloadRomDirCmd, 0, 0);
break; break;
default: default:

View File

@ -15,13 +15,10 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id$ // $Id$
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================ //============================================================================
#ifndef FILE_SNAP_DIALOG_HXX #ifndef CONFIG_PATH_DIALOG_HXX
#define FILE_SNAP_DIALOG_HXX #define CONFIG_PATH_DIALOG_HXX
class OSystem; class OSystem;
class GuiObject; class GuiObject;
@ -36,13 +33,13 @@ class StaticTextWidget;
#include "Dialog.hxx" #include "Dialog.hxx"
#include "Command.hxx" #include "Command.hxx"
class FileSnapDialog : public Dialog, public CommandSender class ConfigPathDialog : public Dialog, public CommandSender
{ {
public: public:
FileSnapDialog(OSystem* osystem, DialogContainer* parent, ConfigPathDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, GuiObject* boss, const GUI::Font& font, GuiObject* boss,
int max_w, int max_h); int max_w, int max_h);
~FileSnapDialog(); ~ConfigPathDialog();
void handleCommand(CommandSender* sender, int cmd, int data, int id); void handleCommand(CommandSender* sender, int cmd, int data, int id);
@ -58,8 +55,6 @@ class FileSnapDialog : public Dialog, public CommandSender
kChooseCheatFileCmd = 'LOcf', // cheatfile (stella.cht) kChooseCheatFileCmd = 'LOcf', // cheatfile (stella.cht)
kChoosePaletteFileCmd = 'LOpf', // palette file (stella.pal) kChoosePaletteFileCmd = 'LOpf', // palette file (stella.pal)
kChoosePropsFileCmd = 'LOpr', // properties file (stella.pro) kChoosePropsFileCmd = 'LOpr', // properties file (stella.pro)
kChooseSnapSaveDirCmd = 'LOss', // snapshot dir (save files)
kChooseSnapLoadDirCmd = 'LOsl', // snapshot dir (load files)
kChooseNVRamDirCmd = 'LOnv', // nvram (flash/eeprom) dir kChooseNVRamDirCmd = 'LOnv', // nvram (flash/eeprom) dir
kStateDirChosenCmd = 'LOsc', // state dir changed kStateDirChosenCmd = 'LOsc', // state dir changed
kCheatFileChosenCmd = 'LOcc', // cheatfile changed kCheatFileChosenCmd = 'LOcc', // cheatfile changed
@ -77,13 +72,6 @@ class FileSnapDialog : public Dialog, public CommandSender
EditTextWidget* myCheatFile; EditTextWidget* myCheatFile;
EditTextWidget* myPaletteFile; EditTextWidget* myPaletteFile;
EditTextWidget* myPropsFile; EditTextWidget* myPropsFile;
EditTextWidget* mySnapSavePath;
EditTextWidget* mySnapLoadPath;
// Other snapshot settings
CheckboxWidget* mySnapSingle;
CheckboxWidget* mySnap1x;
PopUpWidget* mySnapInterval;
// Indicates if this dialog is used for global (vs. in-game) settings // Indicates if this dialog is used for global (vs. in-game) settings
bool myIsGlobal; bool myIsGlobal;

View File

@ -564,14 +564,6 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
updateListing(); updateListing();
break; break;
case kSnapSaveDirChosenCmd:
// Stub just in case we need it
break;
case kSnapLoadDirChosenCmd:
// Stub just in case we need it
break;
case kReloadRomDirCmd: case kReloadRomDirCmd:
updateListing(); updateListing();
break; break;

View File

@ -47,17 +47,16 @@ class StringListWidget;
#include "Stack.hxx" #include "Stack.hxx"
#include "MessageBox.hxx" #include "MessageBox.hxx"
// These must be accessible from dialogs created by this class
enum {
kRomDirChosenCmd = 'romc', // rom chosen
kSnapSaveDirChosenCmd = 'snsc', // snap chosen (save files)
kSnapLoadDirChosenCmd = 'snlc', // snap chosen (load files)
kReloadRomDirCmd = 'rdrl', // reload the current listing
kReloadFiltersCmd = 'rlfl' // reload filtering options and current listing
};
class LauncherDialog : public Dialog class LauncherDialog : public Dialog
{ {
public:
// These must be accessible from dialogs created by this class
enum {
kRomDirChosenCmd = 'romc', // rom chosen
kReloadRomDirCmd = 'rdrl', // reload the current listing
kReloadFiltersCmd = 'rlfl' // reload filtering options and current listing
};
public: public:
LauncherDialog(OSystem* osystem, DialogContainer* parent, LauncherDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h); int x, int y, int w, int h);

View File

@ -191,7 +191,7 @@ void LauncherFilterDialog::saveConfig()
} }
// Let parent know about the changes // Let parent know about the changes
sendCommand(kReloadFiltersCmd, 0, 0); sendCommand(LauncherDialog::kReloadFiltersCmd, 0, 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -29,7 +29,8 @@
#include "AudioDialog.hxx" #include "AudioDialog.hxx"
#include "InputDialog.hxx" #include "InputDialog.hxx"
#include "UIDialog.hxx" #include "UIDialog.hxx"
#include "FileSnapDialog.hxx" #include "SnapshotDialog.hxx"
#include "ConfigPathDialog.hxx"
#include "RomAuditDialog.hxx" #include "RomAuditDialog.hxx"
#include "GameInfoDialog.hxx" #include "GameInfoDialog.hxx"
#include "LoggerDialog.hxx" #include "LoggerDialog.hxx"
@ -55,7 +56,8 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
myAudioDialog(NULL), myAudioDialog(NULL),
myInputDialog(NULL), myInputDialog(NULL),
myUIDialog(NULL), myUIDialog(NULL),
myFileSnapDialog(NULL), mySnapshotDialog(NULL),
myConfigPathDialog(NULL),
myGameInfoDialog(NULL), myGameInfoDialog(NULL),
myCheatCodeDialog(NULL), myCheatCodeDialog(NULL),
myLoggerDialog(NULL), myLoggerDialog(NULL),
@ -64,34 +66,37 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
myIsGlobal(global) myIsGlobal(global)
{ {
const GUI::Font& font = instance().font(); const GUI::Font& font = instance().font();
const int buttonWidth = font.getStringWidth("Game Properties") + 20, const int buttonWidth = font.getStringWidth("Snapshot Settings") + 20,
buttonHeight = font.getLineHeight() + 6, buttonHeight = font.getLineHeight() + 6,
rowHeight = font.getLineHeight() + 10; rowHeight = font.getLineHeight() + 10;
_w = 2 * buttonWidth + 30; _w = 2 * buttonWidth + 30;
_h = 6 * rowHeight + 15; _h = 7 * rowHeight + 15;
int xoffset = 10, yoffset = 10; int xoffset = 10, yoffset = 10;
WidgetArray wid; WidgetArray wid;
ButtonWidget* b = NULL; ButtonWidget* b = NULL;
myVideoSettingsButton = addODButton("Video Settings", kVidCmd); b = addODButton("Video Settings", kVidCmd);
wid.push_back(myVideoSettingsButton); wid.push_back(b);
myAudioSettingsButton = addODButton("Audio Settings", kAudCmd); b = addODButton("Audio Settings", kAudCmd);
#ifndef SOUND_SUPPORT #ifndef SOUND_SUPPORT
myAudioSettingsButton->clearFlags(WIDGET_ENABLED); b->clearFlags(WIDGET_ENABLED);
#endif #endif
wid.push_back(myAudioSettingsButton); wid.push_back(b);
b = addODButton("Input Settings", kInptCmd); b = addODButton("Input Settings", kInptCmd);
wid.push_back(b); wid.push_back(b);
myUIButton = addODButton("UI Settings", kUsrIfaceCmd); b = addODButton("UI Settings", kUsrIfaceCmd);
wid.push_back(myUIButton); wid.push_back(b);
myFileSnapButton = addODButton("Config Paths", kFileSnapCmd); b = addODButton("Snapshot Settings", kSnapCmd);
wid.push_back(myFileSnapButton); wid.push_back(b);
b = addODButton("Config Paths", kFileSnapCmd);
wid.push_back(b);
myRomAuditButton = addODButton("Audit ROMs", kAuditCmd); myRomAuditButton = addODButton("Audit ROMs", kAuditCmd);
wid.push_back(myRomAuditButton); wid.push_back(myRomAuditButton);
@ -108,33 +113,34 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
#endif #endif
wid.push_back(myCheatCodeButton); wid.push_back(myCheatCodeButton);
myLoggerButton = addODButton("System Logs", kLoggerCmd); b = addODButton("System Logs", kLoggerCmd);
wid.push_back(myLoggerButton); wid.push_back(b);
myHelpButton = addODButton("Help", kHelpCmd); b = addODButton("Help", kHelpCmd);
wid.push_back(myHelpButton); wid.push_back(b);
myAboutButton = addODButton("About", kAboutCmd); b = addODButton("About", kAboutCmd);
wid.push_back(myAboutButton); wid.push_back(b);
b = addODButton("Exit Menu", kExitCmd); b = addODButton("Exit Menu", kExitCmd);
wid.push_back(b); wid.push_back(b);
addCancelWidget(b); addCancelWidget(b);
// Now create all the dialogs attached to each menu button // Now create all the dialogs attached to each menu button
myVideoDialog = new VideoDialog(osystem, parent, font, max_w, max_h); myVideoDialog = new VideoDialog(osystem, parent, font, max_w, max_h);
myAudioDialog = new AudioDialog(osystem, parent, font); myAudioDialog = new AudioDialog(osystem, parent, font);
myInputDialog = new InputDialog(osystem, parent, font, max_w, max_h); myInputDialog = new InputDialog(osystem, parent, font, max_w, max_h);
myUIDialog = new UIDialog(osystem, parent, font); myUIDialog = new UIDialog(osystem, parent, font);
myFileSnapDialog = new FileSnapDialog(osystem, parent, font, boss, max_w, max_h); mySnapshotDialog = new SnapshotDialog(osystem, parent, font, boss, max_w, max_h);
myConfigPathDialog = new ConfigPathDialog(osystem, parent, font, boss, max_w, max_h);
myRomAuditDialog = new RomAuditDialog(osystem, parent, font, max_w, max_h); myRomAuditDialog = new RomAuditDialog(osystem, parent, font, max_w, max_h);
myGameInfoDialog = new GameInfoDialog(osystem, parent, font, this); myGameInfoDialog = new GameInfoDialog(osystem, parent, font, this);
#ifdef CHEATCODE_SUPPORT #ifdef CHEATCODE_SUPPORT
myCheatCodeDialog = new CheatCodeDialog(osystem, parent, font); myCheatCodeDialog = new CheatCodeDialog(osystem, parent, font);
#endif #endif
myLoggerDialog = new LoggerDialog(osystem, parent, font, max_w, max_h); myLoggerDialog = new LoggerDialog(osystem, parent, font, max_w, max_h);
myHelpDialog = new HelpDialog(osystem, parent, font); myHelpDialog = new HelpDialog(osystem, parent, font);
myAboutDialog = new AboutDialog(osystem, parent, font); myAboutDialog = new AboutDialog(osystem, parent, font);
addToFocusList(wid); addToFocusList(wid);
@ -147,9 +153,6 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
{ {
myRomAuditButton->clearFlags(WIDGET_ENABLED); myRomAuditButton->clearFlags(WIDGET_ENABLED);
} }
#ifdef _WIN32_WCE
myAudioSettingsButton->clearFlags(WIDGET_ENABLED); // not honored in wince port
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -159,7 +162,8 @@ OptionsDialog::~OptionsDialog()
delete myAudioDialog; delete myAudioDialog;
delete myInputDialog; delete myInputDialog;
delete myUIDialog; delete myUIDialog;
delete myFileSnapDialog; delete mySnapshotDialog;
delete myConfigPathDialog;
delete myRomAuditDialog; delete myRomAuditDialog;
delete myGameInfoDialog; delete myGameInfoDialog;
#ifdef CHEATCODE_SUPPORT #ifdef CHEATCODE_SUPPORT
@ -214,8 +218,12 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
myUIDialog->open(); myUIDialog->open();
break; break;
case kSnapCmd:
mySnapshotDialog->open();
break;
case kFileSnapCmd: case kFileSnapCmd:
myFileSnapDialog->open(); myConfigPathDialog->open();
break; break;
case kAuditCmd: case kAuditCmd:

View File

@ -30,7 +30,8 @@ class VideoDialog;
class AudioDialog; class AudioDialog;
class InputDialog; class InputDialog;
class UIDialog; class UIDialog;
class FileSnapDialog; class SnapshotDialog;
class ConfigPathDialog;
class RomAuditDialog; class RomAuditDialog;
class GameInfoDialog; class GameInfoDialog;
class CheatCodeDialog; class CheatCodeDialog;
@ -54,28 +55,22 @@ class OptionsDialog : public Dialog
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
private: private:
VideoDialog* myVideoDialog; VideoDialog* myVideoDialog;
AudioDialog* myAudioDialog; AudioDialog* myAudioDialog;
InputDialog* myInputDialog; InputDialog* myInputDialog;
UIDialog* myUIDialog; UIDialog* myUIDialog;
FileSnapDialog* myFileSnapDialog; SnapshotDialog* mySnapshotDialog;
RomAuditDialog* myRomAuditDialog; ConfigPathDialog* myConfigPathDialog;
GameInfoDialog* myGameInfoDialog; RomAuditDialog* myRomAuditDialog;
CheatCodeDialog* myCheatCodeDialog; GameInfoDialog* myGameInfoDialog;
LoggerDialog* myLoggerDialog; CheatCodeDialog* myCheatCodeDialog;
HelpDialog* myHelpDialog; LoggerDialog* myLoggerDialog;
AboutDialog* myAboutDialog; HelpDialog* myHelpDialog;
AboutDialog* myAboutDialog;
ButtonWidget* myVideoSettingsButton;
ButtonWidget* myAudioSettingsButton;
ButtonWidget* myUIButton;
ButtonWidget* myFileSnapButton;
ButtonWidget* myRomAuditButton; ButtonWidget* myRomAuditButton;
ButtonWidget* myGameInfoButton; ButtonWidget* myGameInfoButton;
ButtonWidget* myCheatCodeButton; ButtonWidget* myCheatCodeButton;
ButtonWidget* myLoggerButton;
ButtonWidget* myHelpButton;
ButtonWidget* myAboutButton;
// Indicates if this dialog is used for global (vs. in-game) settings // Indicates if this dialog is used for global (vs. in-game) settings
bool myIsGlobal; bool myIsGlobal;
@ -85,6 +80,7 @@ class OptionsDialog : public Dialog
kAudCmd = 'AUDO', kAudCmd = 'AUDO',
kInptCmd = 'INPT', kInptCmd = 'INPT',
kUsrIfaceCmd = 'URIF', kUsrIfaceCmd = 'URIF',
kSnapCmd = 'SNAP',
kFileSnapCmd = 'FLSN', kFileSnapCmd = 'FLSN',
kAuditCmd = 'RAUD', kAuditCmd = 'RAUD',
kInfoCmd = 'INFO', kInfoCmd = 'INFO',

197
src/gui/SnapshotDialog.cxx Normal file
View File

@ -0,0 +1,197 @@
//============================================================================
//
// 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$
//============================================================================
#include "bspf.hxx"
#include "BrowserDialog.hxx"
#include "EditTextWidget.hxx"
#include "FSNode.hxx"
#include "LauncherDialog.hxx"
#include "PopUpWidget.hxx"
#include "Settings.hxx"
#include "SnapshotDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SnapshotDialog::SnapshotDialog(
OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, GuiObject* boss,
int max_w, int max_h)
: Dialog(osystem, parent, 0, 0, 0, 0),
myBrowser(NULL)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
buttonWidth = font.getStringWidth("Snapshot load path:") + 20,
buttonHeight = font.getLineHeight() + 4;
const int vBorder = 8;
int xpos, ypos;
WidgetArray wid;
ButtonWidget* b;
// Set real dimensions
_w = 56 * fontWidth + 8;
_h = 13 * (lineHeight + 4) + 10;
xpos = vBorder; ypos = vBorder;
// Snapshot path (save files)
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Snapshot save path:", kChooseSnapSaveDirCmd);
wid.push_back(b);
xpos += buttonWidth + 10;
mySnapSavePath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, lineHeight, "");
wid.push_back(mySnapSavePath);
// Snapshot path (load files)
xpos = vBorder; ypos += buttonHeight + 3;
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Snapshot load path:", kChooseSnapLoadDirCmd);
wid.push_back(b);
xpos += buttonWidth + 10;
mySnapLoadPath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, lineHeight, "");
wid.push_back(mySnapLoadPath);
// Snapshot single or multiple saves
xpos = 30; ypos += b->getHeight() + 5;
mySnapSingle = new CheckboxWidget(this, font, xpos, ypos,
"Overwrite snapshots");
wid.push_back(mySnapSingle);
// Snapshot in 1x mode (ignore scaling)
xpos += mySnapSingle->getWidth() + 20;
mySnap1x = new CheckboxWidget(this, font, xpos, ypos,
"Snapshot in 1x mode");
wid.push_back(mySnap1x);
// Snapshot interval (continuous mode)
VariantList items;
items.clear();
items.push_back("1 second", "1");
items.push_back("2 seconds", "2");
items.push_back("3 seconds", "3");
items.push_back("4 seconds", "4");
items.push_back("5 seconds", "5");
items.push_back("6 seconds", "6");
items.push_back("7 seconds", "7");
items.push_back("8 seconds", "8");
items.push_back("9 seconds", "9");
items.push_back("10 seconds", "10");
xpos = 30; ypos += b->getHeight();
mySnapInterval = new PopUpWidget(this, font, xpos, ypos,
font.getStringWidth("10 seconds"), lineHeight,
items, "Continuous snapshot interval: ");
wid.push_back(mySnapInterval);
// Add Defaults, OK and Cancel buttons
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
font.getStringWidth("Defaults") + 20, buttonHeight,
"Defaults", kDefaultsCmd);
wid.push_back(b);
addOKCancelBGroup(wid, font);
addToFocusList(wid);
// Create file browser dialog
myBrowser = new BrowserDialog(this, font, max_w, max_h);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SnapshotDialog::~SnapshotDialog()
{
delete myBrowser;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::loadConfig()
{
const Settings& settings = instance().settings();
mySnapSavePath->setText(settings.getString("snapsavedir"));
mySnapLoadPath->setText(settings.getString("snaploaddir"));
mySnapSingle->setState(settings.getBool("sssingle"));
mySnap1x->setState(settings.getBool("ss1x"));
mySnapInterval->setSelected(instance().settings().getString("ssinterval"), "2");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::saveConfig()
{
instance().settings().setValue("snapsavedir", mySnapSavePath->getText());
instance().settings().setValue("snaploaddir", mySnapLoadPath->getText());
instance().settings().setValue("sssingle", mySnapSingle->getState());
instance().settings().setValue("ss1x", mySnap1x->getState());
instance().settings().setValue("ssinterval",
mySnapInterval->getSelectedTag().toString());
// Flush changes to disk and inform the OSystem
instance().saveConfig();
instance().setConfigPaths();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::setDefaults()
{
mySnapSavePath->setText(instance().defaultSnapSaveDir());
mySnapLoadPath->setText(instance().defaultSnapLoadDir());
mySnapSingle->setState(false);
mySnap1x->setState(false);
mySnapInterval->setSelected("2", "2");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SnapshotDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch (cmd)
{
case kOKCmd:
saveConfig();
close();
break;
case kDefaultsCmd:
setDefaults();
break;
case kChooseSnapSaveDirCmd:
myBrowser->show("Select snapshot save directory:", mySnapSavePath->getText(),
BrowserDialog::Directories, kSnapSaveDirChosenCmd);
break;
case kChooseSnapLoadDirCmd:
myBrowser->show("Select snapshot load directory:", mySnapLoadPath->getText(),
BrowserDialog::Directories, kSnapLoadDirChosenCmd);
break;
case kSnapSaveDirChosenCmd:
mySnapSavePath->setText(myBrowser->getResult().getShortPath());
break;
case kSnapLoadDirChosenCmd:
mySnapLoadPath->setText(myBrowser->getResult().getShortPath());
break;
default:
Dialog::handleCommand(sender, cmd, data, 0);
break;
}
}

View File

@ -0,0 +1,71 @@
//============================================================================
//
// 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 SNAPSHOT_DIALOG_HXX
#define SNAPSHOT_DIALOG_HXX
class OSystem;
class GuiObject;
class DialogContainer;
class BrowserDialog;
class CheckboxWidget;
class PopUpWidget;
class EditTextWidget;
class SliderWidget;
class StaticTextWidget;
#include "Dialog.hxx"
#include "Command.hxx"
class SnapshotDialog : public Dialog
{
public:
SnapshotDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, GuiObject* boss,
int max_w, int max_h);
~SnapshotDialog();
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private:
void loadConfig();
void saveConfig();
void setDefaults();
private:
enum {
kChooseSnapSaveDirCmd = 'LOss', // snapshot dir (save files)
kChooseSnapLoadDirCmd = 'LOsl', // snapshot dir (load files)
kSnapSaveDirChosenCmd = 'snsc', // snap chosen (save files)
kSnapLoadDirChosenCmd = 'snlc' // snap chosen (load files)
};
BrowserDialog* myBrowser;
// Config paths
EditTextWidget* mySnapSavePath;
EditTextWidget* mySnapLoadPath;
// Other snapshot settings
CheckboxWidget* mySnapSingle;
CheckboxWidget* mySnap1x;
PopUpWidget* mySnapInterval;
};
#endif

View File

@ -14,7 +14,8 @@ MODULE_OBJS := \
src/gui/EditTextWidget.o \ src/gui/EditTextWidget.o \
src/gui/EventMappingWidget.o \ src/gui/EventMappingWidget.o \
src/gui/FileListWidget.o \ src/gui/FileListWidget.o \
src/gui/FileSnapDialog.o \ src/gui/ConfigPathDialog.o \
src/gui/SnapshotDialog.o \
src/gui/Font.o \ src/gui/Font.o \
src/gui/GameInfoDialog.o \ src/gui/GameInfoDialog.o \
src/gui/GameList.o \ src/gui/GameList.o \

View File

@ -396,7 +396,7 @@ SDLmain.lib
<ClCompile Include="..\gui\EditableWidget.cxx" /> <ClCompile Include="..\gui\EditableWidget.cxx" />
<ClCompile Include="..\gui\EditTextWidget.cxx" /> <ClCompile Include="..\gui\EditTextWidget.cxx" />
<ClCompile Include="..\gui\EventMappingWidget.cxx" /> <ClCompile Include="..\gui\EventMappingWidget.cxx" />
<ClCompile Include="..\gui\FileSnapDialog.cxx" /> <ClCompile Include="..\gui\ConfigPathDialog.cxx" />
<ClCompile Include="..\gui\Font.cxx" /> <ClCompile Include="..\gui\Font.cxx" />
<ClCompile Include="..\gui\GameInfoDialog.cxx" /> <ClCompile Include="..\gui\GameInfoDialog.cxx" />
<ClCompile Include="..\gui\GameList.cxx" /> <ClCompile Include="..\gui\GameList.cxx" />
@ -651,7 +651,7 @@ SDLmain.lib
<ClInclude Include="..\gui\EditableWidget.hxx" /> <ClInclude Include="..\gui\EditableWidget.hxx" />
<ClInclude Include="..\gui\EditTextWidget.hxx" /> <ClInclude Include="..\gui\EditTextWidget.hxx" />
<ClInclude Include="..\gui\EventMappingWidget.hxx" /> <ClInclude Include="..\gui\EventMappingWidget.hxx" />
<ClInclude Include="..\gui\FileSnapDialog.hxx" /> <ClInclude Include="..\gui\ConfigPathDialog.hxx" />
<ClInclude Include="..\gui\Font.hxx" /> <ClInclude Include="..\gui\Font.hxx" />
<ClInclude Include="..\gui\GameInfoDialog.hxx" /> <ClInclude Include="..\gui\GameInfoDialog.hxx" />
<ClInclude Include="..\gui\GameList.hxx" /> <ClInclude Include="..\gui\GameList.hxx" />
@ -704,4 +704,4 @@ SDLmain.lib
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -405,7 +405,7 @@
<ClCompile Include="..\gui\EventMappingWidget.cxx"> <ClCompile Include="..\gui\EventMappingWidget.cxx">
<Filter>Source Files\gui</Filter> <Filter>Source Files\gui</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\gui\FileSnapDialog.cxx"> <ClCompile Include="..\gui\ConfigPathDialog.cxx">
<Filter>Source Files\gui</Filter> <Filter>Source Files\gui</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\gui\Font.cxx"> <ClCompile Include="..\gui\Font.cxx">
@ -1121,7 +1121,7 @@
<ClInclude Include="..\gui\EventMappingWidget.hxx"> <ClInclude Include="..\gui\EventMappingWidget.hxx">
<Filter>Header Files\gui</Filter> <Filter>Header Files\gui</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\gui\FileSnapDialog.hxx"> <ClInclude Include="..\gui\ConfigPathDialog.hxx">
<Filter>Header Files\gui</Filter> <Filter>Header Files\gui</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\gui\Font.hxx"> <ClInclude Include="..\gui\Font.hxx">
@ -1459,4 +1459,4 @@
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>