1
//============================================================================
5
// SS tttttt eeee ll ll aaaa
6
// SSSS tt ee ee ll ll aa
7
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8
// SS SS tt ee ll ll aa aa
9
// SSSS ttt eeeee llll llll aaaaa
11
// Copyright (c) 1995-2013 by Bradford W. Mott, Stephen Anthony
12
// and the Stella Team
14
// See the file "License.txt" for information on usage and redistribution of
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
17
// $Id: SnapshotDialog.cxx 2753 2013-06-21 12:15:32Z stephena $
18
//============================================================================
22
#include "BrowserDialog.hxx"
23
#include "EditTextWidget.hxx"
25
#include "LauncherDialog.hxx"
26
#include "PopUpWidget.hxx"
27
#include "Settings.hxx"
29
#include "SnapshotDialog.hxx"
31
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
32
SnapshotDialog::SnapshotDialog(
33
OSystem* osystem, DialogContainer* parent,
34
const GUI::Font& font, GuiObject* boss,
36
: Dialog(osystem, parent, 0, 0, 0, 0),
39
const int lineHeight = font.getLineHeight(),
40
fontWidth = font.getMaxCharWidth(),
41
buttonWidth = font.getStringWidth("Save path:") + 20,
42
buttonHeight = font.getLineHeight() + 4;
43
const int vBorder = 10;
44
int xpos, ypos, lwidth, fwidth;
48
// Set real dimensions
49
_w = 53 * fontWidth + 8;
50
_h = 10 * (lineHeight + 4) + 10;
52
xpos = vBorder; ypos = vBorder;
54
// Snapshot path (save files)
55
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
56
"Save path:", kChooseSnapSaveDirCmd);
58
xpos += buttonWidth + 10;
59
mySnapSavePath = new EditTextWidget(this, font, xpos, ypos + 2,
60
_w - xpos - 10, lineHeight, "");
61
wid.push_back(mySnapSavePath);
63
// Snapshot path (load files)
64
xpos = vBorder; ypos += buttonHeight + 3;
65
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
66
"Load path:", kChooseSnapLoadDirCmd);
68
xpos += buttonWidth + 10;
69
mySnapLoadPath = new EditTextWidget(this, font, xpos, ypos + 2,
70
_w - xpos - 10, lineHeight, "");
71
wid.push_back(mySnapLoadPath);
74
lwidth = font.getStringWidth("Continuous snapshot interval: ");
75
fwidth = font.getStringWidth("internal database");
77
items.push_back("actual ROM name", "rom");
78
items.push_back("internal database", "int");
79
xpos = vBorder+10; ypos += buttonHeight + 8;
81
new PopUpWidget(this, font, xpos, ypos, fwidth, lineHeight, items,
82
"Save snapshots according to: ", lwidth);
83
wid.push_back(mySnapName);
85
// Snapshot interval (continuous mode)
87
items.push_back("1 second", "1");
88
items.push_back("2 seconds", "2");
89
items.push_back("3 seconds", "3");
90
items.push_back("4 seconds", "4");
91
items.push_back("5 seconds", "5");
92
items.push_back("6 seconds", "6");
93
items.push_back("7 seconds", "7");
94
items.push_back("8 seconds", "8");
95
items.push_back("9 seconds", "9");
96
items.push_back("10 seconds", "10");
99
new PopUpWidget(this, font, xpos, ypos, fwidth, lineHeight, items,
100
"Continuous snapshot interval: ", lwidth);
101
wid.push_back(mySnapInterval);
103
// Booleans for saving snapshots
104
fwidth = font.getStringWidth("When saving snapshots:");
105
xpos = vBorder; ypos += buttonHeight + 5;
106
new StaticTextWidget(this, font, xpos, ypos, fwidth, lineHeight,
107
"When saving snapshots:", kTextAlignLeft);
109
// Snapshot single or multiple saves
110
xpos += 30; ypos += lineHeight + 3;
111
mySnapSingle = new CheckboxWidget(this, font, xpos, ypos,
112
"Overwrite existing files");
113
wid.push_back(mySnapSingle);
115
// Snapshot in 1x mode (ignore scaling)
116
ypos += mySnapSingle->getHeight() + 4;
117
mySnap1x = new CheckboxWidget(this, font, xpos, ypos,
118
"Disable image filtering (1x mode)");
119
wid.push_back(mySnap1x);
121
// Add Defaults, OK and Cancel buttons
122
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
123
font.getStringWidth("Defaults") + 20, buttonHeight,
124
"Defaults", kDefaultsCmd);
126
addOKCancelBGroup(wid, font);
130
// Create file browser dialog
131
myBrowser = new BrowserDialog(this, font, max_w, max_h);
134
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135
SnapshotDialog::~SnapshotDialog()
140
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141
void SnapshotDialog::loadConfig()
143
const Settings& settings = instance().settings();
144
mySnapSavePath->setText(settings.getString("snapsavedir"));
145
mySnapLoadPath->setText(settings.getString("snaploaddir"));
146
mySnapName->setSelected(instance().settings().getString("snapname"), "int");
147
mySnapInterval->setSelected(instance().settings().getString("ssinterval"), "2");
148
mySnapSingle->setState(settings.getBool("sssingle"));
149
mySnap1x->setState(settings.getBool("ss1x"));
152
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
153
void SnapshotDialog::saveConfig()
155
instance().settings().setValue("snapsavedir", mySnapSavePath->getText());
156
instance().settings().setValue("snaploaddir", mySnapLoadPath->getText());
157
instance().settings().setValue("snapname",
158
mySnapName->getSelectedTag().toString());
159
instance().settings().setValue("sssingle", mySnapSingle->getState());
160
instance().settings().setValue("ss1x", mySnap1x->getState());
161
instance().settings().setValue("ssinterval",
162
mySnapInterval->getSelectedTag().toString());
164
// Flush changes to disk and inform the OSystem
165
instance().saveConfig();
166
instance().setConfigPaths();
169
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
170
void SnapshotDialog::setDefaults()
172
mySnapSavePath->setText(instance().defaultSnapSaveDir());
173
mySnapLoadPath->setText(instance().defaultSnapLoadDir());
175
mySnapSingle->setState(false);
176
mySnap1x->setState(false);
177
mySnapInterval->setSelected("2", "2");
180
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181
void SnapshotDialog::handleCommand(CommandSender* sender, int cmd,
195
case kChooseSnapSaveDirCmd:
196
myBrowser->show("Select snapshot save directory:", mySnapSavePath->getText(),
197
BrowserDialog::Directories, kSnapSaveDirChosenCmd);
200
case kChooseSnapLoadDirCmd:
201
myBrowser->show("Select snapshot load directory:", mySnapLoadPath->getText(),
202
BrowserDialog::Directories, kSnapLoadDirChosenCmd);
205
case kSnapSaveDirChosenCmd:
206
mySnapSavePath->setText(myBrowser->getResult().getShortPath());
209
case kSnapLoadDirChosenCmd:
210
mySnapLoadPath->setText(myBrowser->getResult().getShortPath());
214
Dialog::handleCommand(sender, cmd, data, 0);