Control-C is hotkey for cheat code dialog, non-remappable. After entering

a valid cheat code, we go back to emulation mode. Ideally, we'd keep
track of whether CheatCodeDialog was called by the menu or the hotkey,
and stay in the menu if it was called by the menu...

Unfortunately, Alt-C isn't available for our cheat hotkey (it's used
for enable/disable missile 0), and Ctrl doubles as the joystick 0 fire
button, so pressing Ctrl-C fires a shot (or starts a game, or whatever)
as well as entering cheat code mode. Not a big deal, I guess.

Currently there's no way to list or disable the cheat codes you've
entered. You can press Control-R to reload the ROM, which kills all the
cheats at once. I tried to figure out how to use the CheckListWidget to
do a cheat list with disable/enable toggles, but got horribly confused.
I think GUI programming in C++ is always going to feel like a foreign
language to me :(


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@795 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-09-25 23:14:00 +00:00
parent 8f035f8e3f
commit 2f55b27695
6 changed files with 55 additions and 19 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EventHandler.cxx,v 1.98 2005-09-24 21:43:59 stephena Exp $
// $Id: EventHandler.cxx,v 1.99 2005-09-25 23:14:00 urchlay Exp $
//============================================================================
#include <algorithm>
@ -427,6 +427,11 @@ void EventHandler::poll(uInt32 time)
{
switch(int(key))
{
case SDLK_c:
enterMenuMode();
myOSystem->menu().enterCheatMode();
break;
case SDLK_0: // Ctrl-0 sets the mouse to paddle 0
setPaddleMode(0, true);
break;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: CheatCodeDialog.cxx,v 1.4 2005-09-25 20:18:46 urchlay Exp $
// $Id: CheatCodeDialog.cxx,v 1.5 2005-09-25 23:14:00 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -40,12 +40,12 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
{
// const GUI::Font& font = instance()->font();
myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Code", kTextAlignCenter);
myError = new StaticTextWidget(this, 10, 32, w - 20, kFontHeight, "Invalid Code", kTextAlignLeft);
myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Code", kTextAlignLeft);
myError = new StaticTextWidget(this, 10, 5 + kFontHeight + 2, w - 20, kFontHeight, "Invalid Code", kTextAlignLeft);
myError->setFlags(WIDGET_INVISIBLE);
myInput = new EditTextWidget(this, 10, 20, 48, kFontHeight, "");
myInput = new EditTextWidget(this, 80, 5, 48, kFontHeight, "");
addFocusWidget(myInput);
addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C');
// addButton(w - (kButtonWidth + 10), 5, "Close", kCloseCmd, 'C');
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -60,27 +60,40 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
switch(cmd)
{
case kEditAcceptCmd:
cerr << myInput->getEditString() << endl;
// cerr << myInput->getEditString() << endl;
myCheat = Cheat::parse(instance(), myInput->getEditString());
if(myCheat) {
// make sure "invalid code" isn't showing any more:
myError->setFlags(WIDGET_INVISIBLE);
loadConfig();
draw();
myError->setDirty();
myError->draw();
// set up the cheat
myCheat->enable();
delete myCheat; // TODO: keep and add to list
// get out of menu mode (back to emulation):
Dialog::handleCommand(sender, kCloseCmd, data, id);
} else {
cerr << "bad cheat code" << endl;
instance()->eventHandler().leaveMenuMode();
} else { // parse() returned 0 (null)
// cerr << "bad cheat code" << endl;
// show error message "invalid code":
myInput->setEditString("");
myError->clearFlags(WIDGET_INVISIBLE);
loadConfig();
draw();
myError->setDirty();
myError->draw();
// 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;
default:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Menu.cxx,v 1.10 2005-06-16 00:55:59 stephena Exp $
// $Id: Menu.cxx,v 1.11 2005-09-25 23:14:00 urchlay Exp $
//============================================================================
#include "Dialog.hxx"
@ -46,3 +46,9 @@ void Menu::setGameProfile(Properties& props)
{
((OptionsDialog*)myBaseDialog)->setGameProfile(props);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Menu::enterCheatMode()
{
((OptionsDialog*)myBaseDialog)->enterCheatMode();
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Menu.hxx,v 1.9 2005-06-16 00:56:00 stephena Exp $
// $Id: Menu.hxx,v 1.10 2005-09-25 23:14:00 urchlay Exp $
//============================================================================
#ifndef MENU_HXX
@ -28,7 +28,7 @@ class OSystem;
The base dialog for all configuration menus in Stella.
@author Stephen Anthony
@version $Id: Menu.hxx,v 1.9 2005-06-16 00:56:00 stephena Exp $
@version $Id: Menu.hxx,v 1.10 2005-09-25 23:14:00 urchlay Exp $
*/
class Menu : public DialogContainer
{
@ -55,6 +55,11 @@ class Menu : public DialogContainer
@param props The properties of the current game
*/
void setGameProfile(Properties& props);
/**
Ugly hack: enter cheat mode
*/
void enterCheatMode();
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OptionsDialog.cxx,v 1.27 2005-09-25 18:35:26 urchlay Exp $
// $Id: OptionsDialog.cxx,v 1.28 2005-09-25 23:14:00 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -110,7 +110,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent)
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
myGameInfoDialog = new GameInfoDialog(myOSystem, parent, x, y, w, h);
w = 255; h = 150;
w = 140; h = 35;
checkBounds(fbWidth, fbHeight, &x, &y, &w, &h);
myCheatCodeDialog = new CheatCodeDialog(myOSystem, parent, x, y, w, h);
@ -187,3 +187,9 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
Dialog::handleCommand(sender, cmd, data, 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void OptionsDialog::enterCheatMode()
{
parent()->addDialog(myCheatCodeDialog);
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: OptionsDialog.hxx,v 1.13 2005-08-11 19:12:39 stephena Exp $
// $Id: OptionsDialog.hxx,v 1.14 2005-09-25 23:14:00 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -46,6 +46,7 @@ class OptionsDialog : public Dialog
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id);
void setGameProfile(Properties& props) { myGameInfoDialog->setGameProfile(props); }
void enterCheatMode();
protected:
VideoDialog* myVideoDialog;