mirror of https://github.com/stella-emu/stella.git
The CheatManager now supports adding new cheats, and editing existing
cheats. There's still some error checking to do, to make sure that cheats don't contain characters that are reserved for the cheat file (comma, colon, quote, etc). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@897 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
ca22361007
commit
2be35dd96f
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Cheat.hxx,v 1.1 2005-11-11 21:44:18 stephena Exp $
|
// $Id: Cheat.hxx,v 1.2 2005-11-27 22:37:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef CHEAT_HXX
|
#ifndef CHEAT_HXX
|
||||||
|
@ -29,7 +29,7 @@ class Cheat
|
||||||
: myOSystem(osystem),
|
: myOSystem(osystem),
|
||||||
myName(name),
|
myName(name),
|
||||||
myCode(code),
|
myCode(code),
|
||||||
myEnabled(false) { }
|
myEnabled(false) { if(name == "") myName = code; }
|
||||||
virtual ~Cheat() { }
|
virtual ~Cheat() { }
|
||||||
|
|
||||||
bool enabled() const { return myEnabled; }
|
bool enabled() const { return myEnabled; }
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheatCodeDialog.cxx,v 1.4 2005-11-27 15:48:04 stephena Exp $
|
// $Id: CheatCodeDialog.cxx,v 1.5 2005-11-27 22:37:24 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -25,18 +25,23 @@
|
||||||
#include "Props.hxx"
|
#include "Props.hxx"
|
||||||
#include "Widget.hxx"
|
#include "Widget.hxx"
|
||||||
#include "Dialog.hxx"
|
#include "Dialog.hxx"
|
||||||
|
#include "DialogContainer.hxx"
|
||||||
#include "CheatCodeDialog.hxx"
|
#include "CheatCodeDialog.hxx"
|
||||||
#include "GuiUtils.hxx"
|
#include "GuiUtils.hxx"
|
||||||
#include "CheckListWidget.hxx"
|
#include "CheckListWidget.hxx"
|
||||||
#include "CheatManager.hxx"
|
#include "CheatManager.hxx"
|
||||||
|
#include "InputTextDialog.hxx"
|
||||||
|
#include "StringList.hxx"
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kAddCheatCmd = 'CHTA',
|
kAddCheatCmd = 'CHTa',
|
||||||
kEditCheatCmd = 'CHTE',
|
kEditCheatCmd = 'CHTe',
|
||||||
kRemCheatCmd = 'CHTR',
|
kCheatAdded = 'CHad',
|
||||||
kAddOneShotCmd = 'CHTO'
|
kCheatEdited = 'CHed',
|
||||||
|
kRemCheatCmd = 'CHTr',
|
||||||
|
kAddOneShotCmd = 'CHTo'
|
||||||
};
|
};
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -58,32 +63,25 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
|
||||||
|
|
||||||
xpos += myCheatList->getWidth() + 15; ypos = 15;
|
xpos += myCheatList->getWidth() + 15; ypos = 15;
|
||||||
addButton(xpos, ypos, "Add", kAddCheatCmd, 0);
|
addButton(xpos, ypos, "Add", kAddCheatCmd, 0);
|
||||||
addButton(xpos, ypos+=20, "Edit", kEditCheatCmd, 0);
|
myEditButton = addButton(xpos, ypos+=20, "Edit", kEditCheatCmd, 0);
|
||||||
addButton(xpos, ypos+=20, "Remove", kRemCheatCmd, 0);
|
myRemoveButton = addButton(xpos, ypos+=20, "Remove", kRemCheatCmd, 0);
|
||||||
addButton(xpos, ypos+=30, "One shot", kAddOneShotCmd, 0);
|
addButton(xpos, ypos+=30, "One shot", kAddOneShotCmd, 0);
|
||||||
|
|
||||||
/*
|
// Inputbox which will pop up when adding/editing a cheat
|
||||||
Move this to new dialog
|
StringList labels;
|
||||||
xpos = 10; ypos = 10 + myCheatList->getHeight() + 10;
|
labels.push_back("Name: ");
|
||||||
myTitle = new StaticTextWidget(this, xpos, ypos, lwidth, fontHeight,
|
labels.push_back("Code: ");
|
||||||
"Cheat Code", kTextAlignLeft);
|
myCheatInput = new InputTextDialog(this, font, labels, _x+20, _y+20);
|
||||||
|
myCheatInput->setTarget(this);
|
||||||
xpos += myTitle->getWidth();
|
|
||||||
myInput = new EditTextWidget(this, xpos, ypos-1, 48, fontHeight, "");
|
|
||||||
|
|
||||||
xpos = 10; ypos += fontHeight + 5;
|
|
||||||
myError = new StaticTextWidget(this, xpos, ypos, lwidth, kFontHeight,
|
|
||||||
"", kTextAlignLeft);
|
|
||||||
myError->setColor(kTextColorEm);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Add OK and Cancel buttons
|
// Add OK and Cancel buttons
|
||||||
#ifndef MAC_OSX
|
#ifndef MAC_OSX
|
||||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
|
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd, 0);
|
||||||
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
myCancelButton = addButton(_w - (kButtonWidth + 10), _h - 24,
|
||||||
|
"Cancel", kCloseCmd, 0);
|
||||||
#else
|
#else
|
||||||
addButton(_w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd, 0);
|
myCancelButton = addButton(_w - 2 * (kButtonWidth + 7), _h - 24,
|
||||||
|
"Cancel", kCloseCmd, 0);
|
||||||
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -102,44 +100,65 @@ void CheatCodeDialog::loadConfig()
|
||||||
StringList l;
|
StringList l;
|
||||||
BoolArray b;
|
BoolArray b;
|
||||||
|
|
||||||
const CheatList& list = instance()->cheat().myCheatList;
|
const CheatList& list = instance()->cheat().list();
|
||||||
for(unsigned int i = 0; i < list.size(); ++i)
|
for(unsigned int i = 0; i < list.size(); ++i)
|
||||||
{
|
{
|
||||||
l.push_back(list[i]->name());
|
l.push_back(list[i]->name());
|
||||||
b.push_back(bool(list[i]->enabled()));
|
b.push_back(bool(list[i]->enabled()));
|
||||||
}
|
}
|
||||||
myCheatList->setList(l, b);
|
myCheatList->setList(l, b);
|
||||||
|
|
||||||
|
bool enabled = (list.size() > 0);
|
||||||
|
myEditButton->setEnabled(enabled);
|
||||||
|
myRemoveButton->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatCodeDialog::saveConfig()
|
void CheatCodeDialog::saveConfig()
|
||||||
{
|
{
|
||||||
// Inspect checkboxes for enable/disable codes
|
// Inspect checkboxes for enable/disable codes
|
||||||
|
const CheatList& list = instance()->cheat().list();
|
||||||
for(unsigned int i = 0; i < myCheatList->getList().size(); ++i)
|
for(unsigned int i = 0; i < myCheatList->getList().size(); ++i)
|
||||||
{
|
{
|
||||||
if(myCheatList->getState(i))
|
if(myCheatList->getState(i))
|
||||||
instance()->cheat().myCheatList[i]->enable();
|
list[i]->enable();
|
||||||
else
|
else
|
||||||
instance()->cheat().myCheatList[i]->disable();
|
list[i]->disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatCodeDialog::addCheat()
|
void CheatCodeDialog::addCheat()
|
||||||
{
|
{
|
||||||
cerr << "CheatCodeDialog::addCheat()\n";
|
myCheatInput->setEditString("", 0);
|
||||||
|
myCheatInput->setEditString("", 1);
|
||||||
|
myCheatInput->setTitle("");
|
||||||
|
myCheatInput->setEmitSignal(kCheatAdded);
|
||||||
|
parent()->addDialog(myCheatInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatCodeDialog::editCheat(int cheatNumber)
|
void CheatCodeDialog::editCheat()
|
||||||
{
|
{
|
||||||
cerr << "CheatCodeDialog::editCheat() " << cheatNumber << endl;
|
int idx = myCheatList->getSelected();
|
||||||
|
if(idx < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const CheatList& list = instance()->cheat().list();
|
||||||
|
const string& name = list[idx]->name();
|
||||||
|
const string& code = list[idx]->code();
|
||||||
|
|
||||||
|
myCheatInput->setEditString(name, 0);
|
||||||
|
myCheatInput->setEditString(code, 1);
|
||||||
|
myCheatInput->setEmitSignal(kCheatEdited);
|
||||||
|
parent()->addDialog(myCheatInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatCodeDialog::removeCheat(int cheatNumber)
|
void CheatCodeDialog::removeCheat()
|
||||||
{
|
{
|
||||||
cerr << "CheatCodeDialog::removeCheat() " << cheatNumber << endl;
|
instance()->cheat().remove(myCheatList->getSelected());
|
||||||
|
loadConfig(); // reload the cheat list
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -158,7 +177,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kListItemDoubleClickedCmd:
|
case kListItemDoubleClickedCmd:
|
||||||
editCheat(myCheatList->getSelected());
|
editCheat();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAddCheatCmd:
|
case kAddCheatCmd:
|
||||||
|
@ -166,62 +185,51 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kEditCheatCmd:
|
case kEditCheatCmd:
|
||||||
editCheat(myCheatList->getSelected());
|
editCheat();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kCheatAdded:
|
||||||
|
{
|
||||||
|
const string& name = myCheatInput->getResult(0);
|
||||||
|
const string& code = myCheatInput->getResult(1);
|
||||||
|
if(instance()->cheat().isValidCode(code))
|
||||||
|
{
|
||||||
|
instance()->cheat().add(name, code);
|
||||||
|
parent()->removeDialog();
|
||||||
|
loadConfig(); // show changes onscreen
|
||||||
|
myCancelButton->setEnabled(false); // cannot cancel when a new cheat added
|
||||||
|
}
|
||||||
|
else
|
||||||
|
myCheatInput->setTitle("Invalid code");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kCheatEdited:
|
||||||
|
{
|
||||||
|
const string& name = myCheatInput->getResult(0);
|
||||||
|
const string& code = myCheatInput->getResult(1);
|
||||||
|
bool enable = myCheatList->getSelectedState();
|
||||||
|
int idx = myCheatList->getSelected();
|
||||||
|
if(instance()->cheat().isValidCode(code))
|
||||||
|
{
|
||||||
|
instance()->cheat().add(name, code, enable, idx);
|
||||||
|
parent()->removeDialog();
|
||||||
|
loadConfig(); // show changes onscreen
|
||||||
|
myCancelButton->setEnabled(false); // cannot cancel when a new cheat added
|
||||||
|
}
|
||||||
|
else
|
||||||
|
myCheatInput->setTitle("Invalid code");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kRemCheatCmd:
|
case kRemCheatCmd:
|
||||||
removeCheat(myCheatList->getSelected());
|
removeCheat();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kAddOneShotCmd:
|
case kAddOneShotCmd:
|
||||||
cerr << "add one-shot cheat\n";
|
cerr << "add one-shot cheat\n";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
|
||||||
case kEditAcceptCmd:
|
|
||||||
{
|
|
||||||
// cerr << myInput->getEditString() << endl;
|
|
||||||
const Cheat* cheat =
|
|
||||||
instance()->cheat().add("DLG", myInput->getEditString(), true);
|
|
||||||
|
|
||||||
if(cheat)
|
|
||||||
{
|
|
||||||
// make sure "invalid code" isn't showing any more:
|
|
||||||
myError->setLabel("");
|
|
||||||
myErrorFlag = false;
|
|
||||||
|
|
||||||
// get out of menu mode (back to emulation):
|
|
||||||
Dialog::handleCommand(sender, kCloseCmd, data, id);
|
|
||||||
instance()->eventHandler().leaveMenuMode();
|
|
||||||
}
|
|
||||||
else // parse() returned 0 (null)
|
|
||||||
{
|
|
||||||
myInput->setEditString("");
|
|
||||||
|
|
||||||
// show error message "invalid code":
|
|
||||||
myError->setLabel("Invalid Code");
|
|
||||||
myErrorFlag = true;
|
|
||||||
|
|
||||||
// not sure this does anything useful:
|
|
||||||
Dialog::handleCommand(sender, cmd, data, 0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kEditCancelCmd:
|
|
||||||
Dialog::handleCommand(sender, kCloseCmd, data, id);
|
|
||||||
instance()->eventHandler().leaveMenuMode();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kEditChangedCmd:
|
|
||||||
// Erase the invalid message once editing is restarted
|
|
||||||
if(myErrorFlag)
|
|
||||||
{
|
|
||||||
myError->setLabel("");
|
|
||||||
myErrorFlag = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
default:
|
default:
|
||||||
Dialog::handleCommand(sender, cmd, data, 0);
|
Dialog::handleCommand(sender, cmd, data, 0);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheatCodeDialog.hxx,v 1.2 2005-11-26 21:23:35 stephena Exp $
|
// $Id: CheatCodeDialog.hxx,v 1.3 2005-11-27 22:37:24 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -27,6 +27,7 @@ class CommandSender;
|
||||||
class ButtonWidget;
|
class ButtonWidget;
|
||||||
class StaticTextWidget;
|
class StaticTextWidget;
|
||||||
class CheckListWidget;
|
class CheckListWidget;
|
||||||
|
class InputTextDialog;
|
||||||
|
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "Dialog.hxx"
|
#include "Dialog.hxx"
|
||||||
|
@ -50,19 +51,16 @@ class CheatCodeDialog : public Dialog
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addCheat();
|
void addCheat();
|
||||||
void editCheat(int cheatNumber);
|
void editCheat();
|
||||||
void removeCheat(int cheatNumber);
|
void removeCheat();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CheckListWidget* myCheatList;
|
CheckListWidget* myCheatList;
|
||||||
/*
|
InputTextDialog* myCheatInput;
|
||||||
ButtonWidget* myExitButton;
|
|
||||||
StaticTextWidget* myTitle;
|
|
||||||
StaticTextWidget* myError;
|
|
||||||
EditTextWidget* myInput;
|
|
||||||
|
|
||||||
bool myErrorFlag;
|
ButtonWidget* myEditButton;
|
||||||
*/
|
ButtonWidget* myRemoveButton;
|
||||||
|
ButtonWidget* myCancelButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheatManager.cxx,v 1.3 2005-11-27 15:48:05 stephena Exp $
|
// $Id: CheatManager.cxx,v 1.4 2005-11-27 22:37:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -42,10 +42,9 @@ CheatManager::~CheatManager()
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const Cheat* CheatManager::add(const string& name, const string& code,
|
const Cheat* CheatManager::add(const string& name, const string& code,
|
||||||
bool enable)
|
bool enable, int idx)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < code.size(); i++)
|
if(!isValidCode(code))
|
||||||
if(!isxdigit(code[i]))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Cheat* cheat = (Cheat*) NULL;
|
Cheat* cheat = (Cheat*) NULL;
|
||||||
|
@ -79,7 +78,10 @@ const Cheat* CheatManager::add(const string& name, const string& code,
|
||||||
// Add the cheat to the main cheat list
|
// Add the cheat to the main cheat list
|
||||||
if(cheat)
|
if(cheat)
|
||||||
{
|
{
|
||||||
|
if(idx == -1)
|
||||||
myCheatList.push_back(cheat);
|
myCheatList.push_back(cheat);
|
||||||
|
else
|
||||||
|
myCheatList.insert_at(idx, cheat);
|
||||||
|
|
||||||
// And enable/disable it (the cheat knows how to enable or disable itself)
|
// And enable/disable it (the cheat knows how to enable or disable itself)
|
||||||
if(enable)
|
if(enable)
|
||||||
|
@ -91,6 +93,22 @@ const Cheat* CheatManager::add(const string& name, const string& code,
|
||||||
return cheat;
|
return cheat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void CheatManager::remove(int idx)
|
||||||
|
{
|
||||||
|
if((unsigned int)idx >= myCheatList.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Cheat* c = myCheatList[idx];
|
||||||
|
|
||||||
|
// First remove it from the per-frame list
|
||||||
|
addPerFrame(c, false);
|
||||||
|
|
||||||
|
// Then remove it from the cheatlist entirely
|
||||||
|
myCheatList.remove_at(idx);
|
||||||
|
delete c;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatManager::addPerFrame(Cheat* cheat, bool enable)
|
void CheatManager::addPerFrame(Cheat* cheat, bool enable)
|
||||||
{
|
{
|
||||||
|
@ -124,8 +142,6 @@ void CheatManager::addPerFrame(Cheat* cheat, bool enable)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CheatManager::parse(const string& cheats)
|
void CheatManager::parse(const string& cheats)
|
||||||
{
|
{
|
||||||
cerr << "parsing cheats: " << cheats << endl;
|
|
||||||
|
|
||||||
StringList s;
|
StringList s;
|
||||||
string::size_type lastPos = cheats.find_first_not_of(",", 0);
|
string::size_type lastPos = cheats.find_first_not_of(",", 0);
|
||||||
string::size_type pos = cheats.find_first_of(",", lastPos);
|
string::size_type pos = cheats.find_first_of(",", lastPos);
|
||||||
|
@ -298,3 +314,14 @@ void CheatManager::clear()
|
||||||
delete myCheatList[i];
|
delete myCheatList[i];
|
||||||
myCheatList.clear();
|
myCheatList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool CheatManager::isValidCode(const string& code)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < code.size(); i++)
|
||||||
|
if(!isxdigit(code[i]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int length = code.length();
|
||||||
|
return (length == 4 || length == 6 || length == 8);
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheatManager.hxx,v 1.3 2005-11-27 15:48:05 stephena Exp $
|
// $Id: CheatManager.hxx,v 1.4 2005-11-27 22:37:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef CHEAT_MANAGER_HXX
|
#ifndef CHEAT_MANAGER_HXX
|
||||||
|
@ -36,12 +36,10 @@ typedef map<string,string> CheatCodeMap;
|
||||||
the list of all cheats currently in use.
|
the list of all cheats currently in use.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: CheatManager.hxx,v 1.3 2005-11-27 15:48:05 stephena Exp $
|
@version $Id: CheatManager.hxx,v 1.4 2005-11-27 22:37:24 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class CheatManager
|
class CheatManager
|
||||||
{
|
{
|
||||||
friend class CheatCodeDialog;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheatManager(OSystem* osystem);
|
CheatManager(OSystem* osystem);
|
||||||
virtual ~CheatManager();
|
virtual ~CheatManager();
|
||||||
|
@ -52,10 +50,19 @@ class CheatManager
|
||||||
@param name Name of the cheat (not absolutely required)
|
@param name Name of the cheat (not absolutely required)
|
||||||
@param code The actual cheatcode (in hex)
|
@param code The actual cheatcode (in hex)
|
||||||
@param enable Whether to enable this cheat right away
|
@param enable Whether to enable this cheat right away
|
||||||
|
@param idx Index at which to insert the cheat
|
||||||
|
|
||||||
@return The cheat (if was created), else NULL.
|
@return The cheat (if was created), else NULL.
|
||||||
*/
|
*/
|
||||||
const Cheat* add(const string& name, const string& code, bool enable = true);
|
const Cheat* add(const string& name, const string& code,
|
||||||
|
bool enable = true, int idx = -1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remove the cheat at 'idx' from the cheat list(s).
|
||||||
|
|
||||||
|
@param index Location in myCheatList of the cheat to remove
|
||||||
|
*/
|
||||||
|
void remove(int idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds the specified cheat to the internal per-frame list.
|
Adds the specified cheat to the internal per-frame list.
|
||||||
|
@ -75,6 +82,11 @@ class CheatManager
|
||||||
*/
|
*/
|
||||||
void enable(const string& code, bool enable);
|
void enable(const string& code, bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the game cheatlist.
|
||||||
|
*/
|
||||||
|
const CheatList& list() { return myCheatList; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the per-frame cheatlist (needed to evaluate cheats each frame)
|
Returns the per-frame cheatlist (needed to evaluate cheats each frame)
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +112,11 @@ class CheatManager
|
||||||
*/
|
*/
|
||||||
void saveCheats(const string& md5sum);
|
void saveCheats(const string& md5sum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Checks if a code is valid.
|
||||||
|
*/
|
||||||
|
bool isValidCode(const string& code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
Parses a list of cheats and adds/enables each one.
|
Parses a list of cheats and adds/enables each one.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: RamWidget.cxx,v 1.1 2005-08-30 17:51:26 stephena Exp $
|
// $Id: RamWidget.cxx,v 1.2 2005-11-27 22:37:24 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -140,18 +140,20 @@ RamWidget::RamWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
||||||
myBinValue->setFont(font);
|
myBinValue->setFont(font);
|
||||||
myBinValue->setEditable(false);
|
myBinValue->setEditable(false);
|
||||||
|
|
||||||
|
// Calculate real dimensions
|
||||||
|
_w = lwidth + myRamGrid->getWidth();
|
||||||
|
_h = ypos + lineHeight - y;
|
||||||
|
|
||||||
// Inputbox which will pop up when searching RAM
|
// Inputbox which will pop up when searching RAM
|
||||||
myInputBox = new InputTextDialog(boss, font,
|
StringList label;
|
||||||
|
label.push_back("Search: ");
|
||||||
|
myInputBox = new InputTextDialog(boss, font, label,
|
||||||
x + lwidth + 20, y + 2*lineHeight - 5);
|
x + lwidth + 20, y + 2*lineHeight - 5);
|
||||||
myInputBox->setTarget(this);
|
myInputBox->setTarget(this);
|
||||||
|
|
||||||
// Start with these buttons disabled
|
// Start with these buttons disabled
|
||||||
myCompareButton->clearFlags(WIDGET_ENABLED);
|
myCompareButton->clearFlags(WIDGET_ENABLED);
|
||||||
myRestartButton->clearFlags(WIDGET_ENABLED);
|
myRestartButton->clearFlags(WIDGET_ENABLED);
|
||||||
|
|
||||||
// Calculate real dimensions
|
|
||||||
_w = lwidth + myRamGrid->getWidth();
|
|
||||||
_h = ypos + lineHeight - y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: RomWidget.cxx,v 1.14 2005-10-22 15:43:17 stephena Exp $
|
// $Id: RomWidget.cxx,v 1.15 2005-11-27 22:37:24 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include "PackedBitArray.hxx"
|
#include "PackedBitArray.hxx"
|
||||||
#include "GuiObject.hxx"
|
#include "GuiObject.hxx"
|
||||||
#include "InputTextDialog.hxx"
|
#include "InputTextDialog.hxx"
|
||||||
|
#include "EditTextWidget.hxx"
|
||||||
#include "ContextMenu.hxx"
|
#include "ContextMenu.hxx"
|
||||||
#include "RomListWidget.hxx"
|
#include "RomListWidget.hxx"
|
||||||
#include "RomWidget.hxx"
|
#include "RomWidget.hxx"
|
||||||
|
@ -98,7 +99,9 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
|
||||||
_h = myRomList->getHeight();
|
_h = myRomList->getHeight();
|
||||||
|
|
||||||
// Create dialog box for save ROM (get name)
|
// Create dialog box for save ROM (get name)
|
||||||
mySaveRom = new InputTextDialog(boss, font, _x + 50, _y + 80);
|
StringList label;
|
||||||
|
label.push_back("Filename: ");
|
||||||
|
mySaveRom = new InputTextDialog(boss, font, label, _x + 50, _y + 80);
|
||||||
mySaveRom->setTarget(this);
|
mySaveRom->setTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: Console.cxx,v 1.76 2005-11-27 15:48:06 stephena Exp $
|
// $Id: Console.cxx,v 1.77 2005-11-27 22:37:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -215,10 +215,6 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
|
||||||
myOSystem->debugger().setConsole(this);
|
myOSystem->debugger().setConsole(this);
|
||||||
myOSystem->debugger().initialize();
|
myOSystem->debugger().initialize();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CHEATCODE_SUPPORT
|
|
||||||
myOSystem->cheat().loadCheats(md5);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: OSystem.cxx,v 1.48 2005-11-27 15:48:06 stephena Exp $
|
// $Id: OSystem.cxx,v 1.49 2005-11-27 22:37:24 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -336,6 +336,9 @@ bool OSystem::createConsole(const string& romfile)
|
||||||
// Create an instance of the 2600 game console
|
// Create an instance of the 2600 game console
|
||||||
// The Console c'tor takes care of updating the eventhandler state
|
// The Console c'tor takes care of updating the eventhandler state
|
||||||
myConsole = new Console(image, size, md5, this);
|
myConsole = new Console(image, size, md5, this);
|
||||||
|
#ifdef CHEATCODE_SUPPORT
|
||||||
|
myCheatManager->loadCheats(md5);
|
||||||
|
#endif
|
||||||
|
|
||||||
if(showmessage)
|
if(showmessage)
|
||||||
myFrameBuffer->showMessage("New console created");
|
myFrameBuffer->showMessage("New console created");
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheckListWidget.cxx,v 1.8 2005-11-26 21:23:35 stephena Exp $
|
// $Id: CheckListWidget.cxx,v 1.9 2005-11-27 22:37:25 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -185,7 +185,7 @@ GUI::Rect CheckListWidget::getEditRect() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CheckListWidget::getState(int line)
|
bool CheckListWidget::getState(int line)
|
||||||
{
|
{
|
||||||
if(line < (int)_stateList.size())
|
if(line >= 0 && line < (int)_stateList.size())
|
||||||
return _stateList[line];
|
return _stateList[line];
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: CheckListWidget.hxx,v 1.6 2005-08-26 16:44:17 stephena Exp $
|
// $Id: CheckListWidget.hxx,v 1.7 2005-11-27 22:37:25 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -52,6 +52,7 @@ class CheckListWidget : public ListWidget
|
||||||
void setLine(int line, const string& str, const bool& state);
|
void setLine(int line, const string& str, const bool& state);
|
||||||
|
|
||||||
bool getState(int line);
|
bool getState(int line);
|
||||||
|
bool getSelectedState() { return getState(_selectedItem); }
|
||||||
|
|
||||||
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: InputTextDialog.cxx,v 1.7 2005-10-14 13:50:00 stephena Exp $
|
// $Id: InputTextDialog.cxx,v 1.8 2005-11-27 22:37:25 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -35,38 +35,58 @@ enum {
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
|
InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
|
||||||
int x, int y)
|
const StringList& labels, int x, int y)
|
||||||
: Dialog(boss->instance(), boss->parent(), x, y, 16, 16),
|
: Dialog(boss->instance(), boss->parent(), x, y, 16, 16),
|
||||||
CommandSender(boss),
|
CommandSender(boss),
|
||||||
_errorFlag(false)
|
myErrorFlag(false)
|
||||||
{
|
{
|
||||||
const int fontWidth = font.getMaxCharWidth(),
|
const int fontWidth = font.getMaxCharWidth(),
|
||||||
fontHeight = font.getFontHeight(),
|
fontHeight = font.getFontHeight(),
|
||||||
lineHeight = font.getLineHeight();
|
lineHeight = font.getLineHeight();
|
||||||
int xpos, ypos;
|
unsigned int xpos, ypos, i, lwidth = 0, maxIdx = 0;
|
||||||
|
|
||||||
// Calculate real dimensions
|
// Calculate real dimensions
|
||||||
_w = fontWidth * 30;
|
_w = fontWidth * 25;
|
||||||
_h = lineHeight * 5;
|
_h = lineHeight * 4 + labels.size() * (lineHeight + 5);
|
||||||
|
|
||||||
xpos = 10; ypos = lineHeight;
|
// Determine longest label
|
||||||
int lwidth = font.getStringWidth("Enter Data:");
|
for(i = 0; i < labels.size(); ++i)
|
||||||
|
{
|
||||||
|
if(labels[i].length() > lwidth)
|
||||||
|
{
|
||||||
|
lwidth = labels[i].length();
|
||||||
|
maxIdx = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lwidth = font.getStringWidth(labels[maxIdx]);
|
||||||
|
|
||||||
|
// Create editboxes for all labels
|
||||||
|
WidgetArray wid;
|
||||||
|
ypos = lineHeight;
|
||||||
|
for(i = 0; i < labels.size(); ++i)
|
||||||
|
{
|
||||||
|
xpos = 10;
|
||||||
StaticTextWidget* t =
|
StaticTextWidget* t =
|
||||||
new StaticTextWidget(this, xpos, ypos,
|
new StaticTextWidget(this, xpos, ypos,
|
||||||
lwidth, fontHeight,
|
lwidth, fontHeight,
|
||||||
"Enter Data:", kTextAlignLeft);
|
labels[i], kTextAlignLeft);
|
||||||
t->setFont(font);
|
t->setFont(font);
|
||||||
|
|
||||||
xpos += lwidth + fontWidth;
|
xpos += lwidth + fontWidth;
|
||||||
_input = new EditTextWidget(this, xpos, ypos,
|
EditTextWidget* w = new EditTextWidget(this, xpos, ypos,
|
||||||
_w - xpos - 10, lineHeight, "");
|
_w - xpos - 10, lineHeight, "");
|
||||||
_input->setFont(font);
|
w->setFont(font);
|
||||||
addFocusWidget(_input);
|
wid.push_back(w);
|
||||||
|
|
||||||
xpos = 10; ypos = 2*lineHeight + 5;
|
myInput.push_back(w);
|
||||||
_title = new StaticTextWidget(this, xpos, ypos, _w - 2*xpos, fontHeight,
|
ypos += lineHeight + 5;
|
||||||
|
}
|
||||||
|
addToFocusList(wid);
|
||||||
|
|
||||||
|
xpos = 10;
|
||||||
|
myTitle = new StaticTextWidget(this, xpos, ypos, _w - 2*xpos, fontHeight,
|
||||||
"", kTextAlignCenter);
|
"", kTextAlignCenter);
|
||||||
_title->setColor(kTextColorEm);
|
myTitle->setColor(kTextColorEm);
|
||||||
|
|
||||||
#ifndef MAC_OSX
|
#ifndef MAC_OSX
|
||||||
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "OK", kAcceptCmd, 0);
|
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "OK", kAcceptCmd, 0);
|
||||||
|
@ -77,11 +97,33 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
InputTextDialog::~InputTextDialog()
|
||||||
|
{
|
||||||
|
myInput.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void InputTextDialog::setTitle(const string& title)
|
void InputTextDialog::setTitle(const string& title)
|
||||||
{
|
{
|
||||||
_title->setLabel(title);
|
myTitle->setLabel(title);
|
||||||
_errorFlag = true;
|
myErrorFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
const string& InputTextDialog::getResult(int idx)
|
||||||
|
{
|
||||||
|
if((unsigned int)idx < myInput.size())
|
||||||
|
return myInput[idx]->getEditString();
|
||||||
|
else
|
||||||
|
return EmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void InputTextDialog::setEditString(const string& str, int idx)
|
||||||
|
{
|
||||||
|
if((unsigned int)idx < myInput.size())
|
||||||
|
myInput[idx]->setEditString(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -95,8 +137,8 @@ void InputTextDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
{
|
{
|
||||||
// Send a signal to the calling class that a selection has been made
|
// Send a signal to the calling class that a selection has been made
|
||||||
// Since we aren't derived from a widget, we don't have a 'data' or 'id'
|
// Since we aren't derived from a widget, we don't have a 'data' or 'id'
|
||||||
if(_cmd)
|
if(myCmd)
|
||||||
sendCommand(_cmd, 0, 0);
|
sendCommand(myCmd, 0, 0);
|
||||||
|
|
||||||
// We don't close, but leave the parent to do it
|
// We don't close, but leave the parent to do it
|
||||||
// If the data isn't valid, the parent may wait until it is
|
// If the data isn't valid, the parent may wait until it is
|
||||||
|
@ -105,10 +147,10 @@ void InputTextDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
|
|
||||||
case kEditChangedCmd:
|
case kEditChangedCmd:
|
||||||
// Erase the invalid message once editing is restarted
|
// Erase the invalid message once editing is restarted
|
||||||
if(_errorFlag)
|
if(myErrorFlag)
|
||||||
{
|
{
|
||||||
_title->setLabel("");
|
myTitle->setLabel("");
|
||||||
_errorFlag = false;
|
myErrorFlag = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: InputTextDialog.hxx,v 1.3 2005-10-06 17:28:55 stephena Exp $
|
// $Id: InputTextDialog.hxx,v 1.4 2005-11-27 22:37:25 stephena Exp $
|
||||||
//
|
//
|
||||||
// Based on code from ScummVM - Scumm Interpreter
|
// Based on code from ScummVM - Scumm Interpreter
|
||||||
// Copyright (C) 2002-2004 The ScummVM project
|
// Copyright (C) 2002-2004 The ScummVM project
|
||||||
|
@ -24,31 +24,36 @@
|
||||||
|
|
||||||
class GuiObject;
|
class GuiObject;
|
||||||
class StaticTextWidget;
|
class StaticTextWidget;
|
||||||
|
class EditTextWidget;
|
||||||
|
|
||||||
#include "Dialog.hxx"
|
#include "Dialog.hxx"
|
||||||
#include "Command.hxx"
|
#include "Command.hxx"
|
||||||
#include "EditTextWidget.hxx"
|
|
||||||
|
typedef GUI::Array<EditTextWidget*> InputWidget;
|
||||||
|
|
||||||
class InputTextDialog : public Dialog, public CommandSender
|
class InputTextDialog : public Dialog, public CommandSender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputTextDialog(GuiObject* boss, const GUI::Font& font, int x, int y);
|
InputTextDialog(GuiObject* boss, const GUI::Font& font,
|
||||||
|
const StringList& labels, int x, int y);
|
||||||
|
virtual ~InputTextDialog();
|
||||||
|
|
||||||
const string& getResult() { return _input->getEditString(); }
|
const string& getResult(int idx = 0);
|
||||||
|
|
||||||
void setEditString(const string& str) { _input->setEditString(str); }
|
void setEditString(const string& str, int idx = 0);
|
||||||
void setEmitSignal(int cmd) { _cmd = cmd; }
|
void setEmitSignal(int cmd) { myCmd = cmd; }
|
||||||
void setTitle(const string& title);
|
void setTitle(const string& title);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StaticTextWidget* _title;
|
private:
|
||||||
EditTextWidget* _input;
|
InputWidget myInput;
|
||||||
|
StaticTextWidget* myTitle;
|
||||||
|
|
||||||
int _cmd;
|
bool myErrorFlag;
|
||||||
bool _errorFlag;
|
int myCmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue