diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index e55d5dbaa..45b15bb66 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -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 @@ -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; diff --git a/stella/src/gui/CheatCodeDialog.cxx b/stella/src/gui/CheatCodeDialog.cxx index 3759f2499..754233de4 100644 --- a/stella/src/gui/CheatCodeDialog.cxx +++ b/stella/src/gui/CheatCodeDialog.cxx @@ -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: diff --git a/stella/src/gui/Menu.cxx b/stella/src/gui/Menu.cxx index f549abee4..4ceb23372 100644 --- a/stella/src/gui/Menu.cxx +++ b/stella/src/gui/Menu.cxx @@ -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(); +} diff --git a/stella/src/gui/Menu.hxx b/stella/src/gui/Menu.hxx index b17aaae6b..5e51ea6b1 100644 --- a/stella/src/gui/Menu.hxx +++ b/stella/src/gui/Menu.hxx @@ -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 diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index 6be607177..243ce45ca 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.cxx @@ -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); +} diff --git a/stella/src/gui/OptionsDialog.hxx b/stella/src/gui/OptionsDialog.hxx index 22d3d4197..cf043d28b 100644 --- a/stella/src/gui/OptionsDialog.hxx +++ b/stella/src/gui/OptionsDialog.hxx @@ -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;