2005-08-05 02:28:22 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2005-08-05 02:28:22 +00:00
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2005-08-05 02:28:22 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2005-08-05 02:28:22 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
2007-09-03 18:37:24 +00:00
|
|
|
#include "bspf.hxx"
|
|
|
|
|
2010-10-18 18:39:57 +00:00
|
|
|
#include "Cheat.hxx"
|
2005-11-27 15:48:06 +00:00
|
|
|
#include "CheatManager.hxx"
|
2007-09-03 18:37:24 +00:00
|
|
|
#include "CheckListWidget.hxx"
|
|
|
|
#include "DialogContainer.hxx"
|
|
|
|
#include "Dialog.hxx"
|
2005-11-27 22:37:25 +00:00
|
|
|
#include "InputTextDialog.hxx"
|
2007-09-03 18:37:24 +00:00
|
|
|
#include "OSystem.hxx"
|
|
|
|
#include "Props.hxx"
|
|
|
|
#include "Widget.hxx"
|
2005-08-05 02:28:22 +00:00
|
|
|
|
2007-09-03 18:37:24 +00:00
|
|
|
#include "CheatCodeDialog.hxx"
|
2005-08-05 02:28:22 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-10-26 17:45:42 +00:00
|
|
|
CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
|
2009-01-04 22:27:44 +00:00
|
|
|
const GUI::Font& font)
|
2014-11-09 04:01:31 +00:00
|
|
|
: Dialog(osystem, parent)
|
2005-08-05 02:28:22 +00:00
|
|
|
{
|
2008-12-25 23:05:16 +00:00
|
|
|
const int lineHeight = font.getLineHeight(),
|
2009-01-04 22:27:44 +00:00
|
|
|
fontWidth = font.getMaxCharWidth(),
|
2008-12-25 23:05:16 +00:00
|
|
|
buttonWidth = font.getStringWidth("Defaults") + 20,
|
|
|
|
buttonHeight = font.getLineHeight() + 4;
|
2005-09-26 19:10:37 +00:00
|
|
|
int xpos, ypos;
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
WidgetArray wid;
|
|
|
|
ButtonWidget* b;
|
2005-08-16 18:34:12 +00:00
|
|
|
|
2009-01-04 22:27:44 +00:00
|
|
|
// Set real dimensions
|
|
|
|
_w = 46 * fontWidth + 10;
|
|
|
|
_h = 11 * (lineHeight + 4) + 10;
|
|
|
|
|
2005-11-26 21:23:35 +00:00
|
|
|
// List of cheats, with checkboxes to enable/disable
|
2005-09-26 19:10:37 +00:00
|
|
|
xpos = 10; ypos = 10;
|
2008-12-25 23:05:16 +00:00
|
|
|
myCheatList =
|
|
|
|
new CheckListWidget(this, font, xpos, ypos, _w - buttonWidth - 25,
|
2009-01-04 22:27:44 +00:00
|
|
|
_h - 2*buttonHeight - 10);
|
2005-11-26 21:23:35 +00:00
|
|
|
myCheatList->setEditable(false);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
wid.push_back(myCheatList);
|
2005-11-26 21:23:35 +00:00
|
|
|
|
2009-01-04 02:28:12 +00:00
|
|
|
xpos += myCheatList->getWidth() + 5; ypos = 15;
|
2008-12-25 23:05:16 +00:00
|
|
|
|
|
|
|
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
|
|
|
|
"Add", kAddCheatCmd);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
wid.push_back(b);
|
2008-12-25 23:05:16 +00:00
|
|
|
ypos += lineHeight + 10;
|
|
|
|
|
|
|
|
myEditButton =
|
|
|
|
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
|
|
|
|
"Edit", kEditCheatCmd);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
wid.push_back(myEditButton);
|
2008-12-25 23:05:16 +00:00
|
|
|
ypos += lineHeight + 10;
|
|
|
|
|
|
|
|
myRemoveButton =
|
|
|
|
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
|
|
|
|
"Remove", kRemCheatCmd);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
wid.push_back(myRemoveButton);
|
2008-12-25 23:05:16 +00:00
|
|
|
ypos += lineHeight + 10;
|
|
|
|
|
|
|
|
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
|
|
|
|
"One shot", kAddOneShotCmd);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
wid.push_back(b);
|
2005-11-26 21:23:35 +00:00
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
// Inputbox which will pop up when adding/editing a cheat
|
|
|
|
StringList labels;
|
2017-07-15 14:18:15 +00:00
|
|
|
labels.push_back("Name ");
|
|
|
|
labels.push_back("Code (hex) ");
|
2017-07-21 23:40:13 +00:00
|
|
|
myCheatInput = make_unique<InputTextDialog>(this, font, labels);
|
2005-11-27 22:37:25 +00:00
|
|
|
myCheatInput->setTarget(this);
|
2005-11-26 21:23:35 +00:00
|
|
|
|
2015-02-09 17:14:28 +00:00
|
|
|
// Add filtering for each textfield
|
|
|
|
EditableWidget::TextFilter f0 = [](char c) {
|
|
|
|
return isprint(c) && c != '\"' && c != ':';
|
|
|
|
};
|
|
|
|
myCheatInput->setTextFilter(f0, 0);
|
|
|
|
|
|
|
|
EditableWidget::TextFilter f1 = [](char c) {
|
|
|
|
return (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9');
|
|
|
|
};
|
|
|
|
myCheatInput->setTextFilter(f1, 1);
|
|
|
|
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
addToFocusList(wid);
|
2008-06-19 19:15:44 +00:00
|
|
|
|
|
|
|
// Add OK and Cancel buttons
|
|
|
|
wid.clear();
|
|
|
|
addOKCancelBGroup(wid, font);
|
|
|
|
addBGroupToFocusList(wid);
|
2005-08-05 02:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-09-26 19:10:37 +00:00
|
|
|
void CheatCodeDialog::loadConfig()
|
2005-08-05 02:28:22 +00:00
|
|
|
{
|
2005-11-27 15:48:06 +00:00
|
|
|
// Load items from CheatManager
|
|
|
|
// Note that the items are always in the same order/number as given in
|
|
|
|
// the CheatManager, so the arrays will be one-to-one
|
2005-11-26 21:23:35 +00:00
|
|
|
StringList l;
|
|
|
|
BoolArray b;
|
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
const CheatList& list = instance().cheat().list();
|
2014-11-10 21:59:56 +00:00
|
|
|
for(const auto& c: list)
|
2005-11-26 21:23:35 +00:00
|
|
|
{
|
2014-11-10 21:59:56 +00:00
|
|
|
l.push_back(c->name());
|
|
|
|
b.push_back(bool(c->enabled()));
|
2005-11-26 21:23:35 +00:00
|
|
|
}
|
|
|
|
myCheatList->setList(l, b);
|
2005-11-27 22:37:25 +00:00
|
|
|
|
2006-03-23 16:16:33 +00:00
|
|
|
// Redraw the list, auto-selecting the first item if possible
|
|
|
|
myCheatList->setSelected(l.size() > 0 ? 0 : -1);
|
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
bool enabled = (list.size() > 0);
|
|
|
|
myEditButton->setEnabled(enabled);
|
|
|
|
myRemoveButton->setEnabled(enabled);
|
2005-11-26 21:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CheatCodeDialog::saveConfig()
|
|
|
|
{
|
2005-11-27 15:48:06 +00:00
|
|
|
// Inspect checkboxes for enable/disable codes
|
2008-06-13 13:14:52 +00:00
|
|
|
const CheatList& list = instance().cheat().list();
|
2014-11-17 14:17:19 +00:00
|
|
|
for(uInt32 i = 0; i < myCheatList->getList().size(); ++i)
|
2005-11-27 15:48:06 +00:00
|
|
|
{
|
|
|
|
if(myCheatList->getState(i))
|
2005-11-27 22:37:25 +00:00
|
|
|
list[i]->enable();
|
2005-11-27 15:48:06 +00:00
|
|
|
else
|
2005-11-27 22:37:25 +00:00
|
|
|
list[i]->disable();
|
2005-11-27 15:48:06 +00:00
|
|
|
}
|
2005-11-26 21:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CheatCodeDialog::addCheat()
|
|
|
|
{
|
2008-12-24 01:20:06 +00:00
|
|
|
myCheatInput->show(); // Center input dialog over entire screen
|
2013-05-29 16:27:12 +00:00
|
|
|
myCheatInput->setText("", 0);
|
|
|
|
myCheatInput->setText("", 1);
|
2005-11-27 22:37:25 +00:00
|
|
|
myCheatInput->setTitle("");
|
2005-12-20 00:56:31 +00:00
|
|
|
myCheatInput->setFocus(0);
|
2005-11-27 22:37:25 +00:00
|
|
|
myCheatInput->setEmitSignal(kCheatAdded);
|
2005-11-26 21:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-11-27 22:37:25 +00:00
|
|
|
void CheatCodeDialog::editCheat()
|
2005-11-26 21:23:35 +00:00
|
|
|
{
|
2005-11-27 22:37:25 +00:00
|
|
|
int idx = myCheatList->getSelected();
|
|
|
|
if(idx < 0)
|
|
|
|
return;
|
|
|
|
|
2008-06-13 13:14:52 +00:00
|
|
|
const CheatList& list = instance().cheat().list();
|
2005-11-27 22:37:25 +00:00
|
|
|
const string& name = list[idx]->name();
|
|
|
|
const string& code = list[idx]->code();
|
|
|
|
|
2008-12-24 01:20:06 +00:00
|
|
|
myCheatInput->show(); // Center input dialog over entire screen
|
2013-05-29 16:27:12 +00:00
|
|
|
myCheatInput->setText(name, 0);
|
|
|
|
myCheatInput->setText(code, 1);
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
myCheatInput->setTitle("");
|
2005-12-20 00:56:31 +00:00
|
|
|
myCheatInput->setFocus(1);
|
2005-11-27 22:37:25 +00:00
|
|
|
myCheatInput->setEmitSignal(kCheatEdited);
|
2005-11-26 21:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-11-27 22:37:25 +00:00
|
|
|
void CheatCodeDialog::removeCheat()
|
2005-11-26 21:23:35 +00:00
|
|
|
{
|
2008-06-13 13:14:52 +00:00
|
|
|
instance().cheat().remove(myCheatList->getSelected());
|
2005-11-27 22:37:25 +00:00
|
|
|
loadConfig(); // reload the cheat list
|
2005-08-05 02:28:22 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 18:37:03 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CheatCodeDialog::addOneShotCheat()
|
|
|
|
{
|
2008-12-24 01:20:06 +00:00
|
|
|
myCheatInput->show(); // Center input dialog over entire screen
|
2013-05-29 16:27:12 +00:00
|
|
|
myCheatInput->setText("One-shot cheat", 0);
|
|
|
|
myCheatInput->setText("", 1);
|
2005-12-18 18:37:03 +00:00
|
|
|
myCheatInput->setTitle("");
|
2005-12-20 00:56:31 +00:00
|
|
|
myCheatInput->setFocus(1);
|
2005-12-18 18:37:03 +00:00
|
|
|
myCheatInput->setEmitSignal(kOneShotCheatAdded);
|
|
|
|
}
|
|
|
|
|
2005-08-05 02:28:22 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-09-26 19:10:37 +00:00
|
|
|
void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|
|
|
int data, int id)
|
|
|
|
{
|
|
|
|
switch(cmd)
|
|
|
|
{
|
2005-11-26 21:23:35 +00:00
|
|
|
case kOKCmd:
|
|
|
|
saveConfig();
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCloseCmd:
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
|
2013-04-21 20:02:55 +00:00
|
|
|
case ListWidget::kDoubleClickedCmd:
|
2005-11-27 22:37:25 +00:00
|
|
|
editCheat();
|
2005-11-26 21:23:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kAddCheatCmd:
|
|
|
|
addCheat();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEditCheatCmd:
|
2005-11-27 22:37:25 +00:00
|
|
|
editCheat();
|
2005-11-26 21:23:35 +00:00
|
|
|
break;
|
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
case kCheatAdded:
|
2005-11-13 03:55:24 +00:00
|
|
|
{
|
2005-11-27 22:37:25 +00:00
|
|
|
const string& name = myCheatInput->getResult(0);
|
|
|
|
const string& code = myCheatInput->getResult(1);
|
2008-06-13 13:14:52 +00:00
|
|
|
if(instance().cheat().isValidCode(code))
|
2005-09-26 19:10:37 +00:00
|
|
|
{
|
2008-08-04 20:12:23 +00:00
|
|
|
myCheatInput->close();
|
2008-06-13 13:14:52 +00:00
|
|
|
instance().cheat().add(name, code);
|
2005-11-27 22:37:25 +00:00
|
|
|
loadConfig(); // show changes onscreen
|
2005-09-26 19:10:37 +00:00
|
|
|
}
|
2005-11-27 22:37:25 +00:00
|
|
|
else
|
|
|
|
myCheatInput->setTitle("Invalid code");
|
|
|
|
break;
|
|
|
|
}
|
2005-09-26 19:10:37 +00:00
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
case kCheatEdited:
|
|
|
|
{
|
|
|
|
const string& name = myCheatInput->getResult(0);
|
|
|
|
const string& code = myCheatInput->getResult(1);
|
|
|
|
bool enable = myCheatList->getSelectedState();
|
|
|
|
int idx = myCheatList->getSelected();
|
2008-06-13 13:14:52 +00:00
|
|
|
if(instance().cheat().isValidCode(code))
|
2005-11-27 22:37:25 +00:00
|
|
|
{
|
2008-08-04 20:12:23 +00:00
|
|
|
myCheatInput->close();
|
2008-06-13 13:14:52 +00:00
|
|
|
instance().cheat().add(name, code, enable, idx);
|
2005-11-27 22:37:25 +00:00
|
|
|
loadConfig(); // show changes onscreen
|
2005-09-26 19:10:37 +00:00
|
|
|
}
|
2005-11-27 22:37:25 +00:00
|
|
|
else
|
|
|
|
myCheatInput->setTitle("Invalid code");
|
2005-09-26 19:10:37 +00:00
|
|
|
break;
|
2005-11-13 03:55:24 +00:00
|
|
|
}
|
2005-09-26 19:10:37 +00:00
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
case kRemCheatCmd:
|
|
|
|
removeCheat();
|
2005-09-26 19:10:37 +00:00
|
|
|
break;
|
|
|
|
|
2005-11-27 22:37:25 +00:00
|
|
|
case kAddOneShotCmd:
|
2005-12-18 18:37:03 +00:00
|
|
|
addOneShotCheat();
|
2005-09-30 00:40:34 +00:00
|
|
|
break;
|
2005-11-27 22:37:25 +00:00
|
|
|
|
2005-12-18 18:37:03 +00:00
|
|
|
case kOneShotCheatAdded:
|
|
|
|
{
|
|
|
|
const string& name = myCheatInput->getResult(0);
|
|
|
|
const string& code = myCheatInput->getResult(1);
|
2008-06-13 13:14:52 +00:00
|
|
|
if(instance().cheat().isValidCode(code))
|
2005-12-18 18:37:03 +00:00
|
|
|
{
|
2008-08-04 20:12:23 +00:00
|
|
|
myCheatInput->close();
|
2008-06-13 13:14:52 +00:00
|
|
|
instance().cheat().addOneShot(name, code);
|
2005-12-18 18:37:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
myCheatInput->setTitle("Invalid code");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-09-26 19:10:37 +00:00
|
|
|
default:
|
|
|
|
Dialog::handleCommand(sender, cmd, data, 0);
|
|
|
|
break;
|
|
|
|
}
|
2005-08-05 02:28:22 +00:00
|
|
|
}
|