From c917e2ee93fe6c5188c1a6a433c0b97567fd9fd4 Mon Sep 17 00:00:00 2001 From: urchlay Date: Sun, 25 Sep 2005 18:35:26 +0000 Subject: [PATCH] CheatCodeDialog work in progress. TIA greyout work in progress. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@793 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/DebuggerParser.cxx | 4 +-- stella/src/emucore/TIA.cxx | 10 ++++-- stella/src/gui/CheatCodeDialog.cxx | 50 ++++++++++++++------------ stella/src/gui/CheatCodeDialog.hxx | 7 ++-- stella/src/gui/OptionsDialog.cxx | 4 +-- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 92fd33584..7f58afdb7 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.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: DebuggerParser.cxx,v 1.80 2005-09-23 23:35:02 stephena Exp $ +// $Id: DebuggerParser.cxx,v 1.81 2005-09-25 18:35:26 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -1225,7 +1225,7 @@ bool DebuggerParser::saveScriptFile(string file) { FunctionDefMap funcs = debugger->getFunctionDefMap(); for(FunctionDefMap::const_iterator i = funcs.begin(); i != funcs.end(); ++i) - out << "function " << i->first << " " << i->second << endl; + out << "function " << i->first << " { " << i->second << " }" << endl; for(unsigned int i=0; i @@ -516,8 +516,14 @@ void TIA::update() uInt32 totalClocks = (mySystem->cycles() * 3) - myClockWhenFrameStarted; myCurrentScanline = totalClocks / 228; - if(!myPartialFrameFlag) + if(myPartialFrameFlag) { + // grey out old frame contents + if(!myFrameGreyed) greyOutFrame(); + myFrameGreyed = true; + } else { endFrame(); + myFrameGreyed = false; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/CheatCodeDialog.cxx b/stella/src/gui/CheatCodeDialog.cxx index dec9cfdd8..4f6936f46 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.2 2005-08-16 18:34:12 stephena Exp $ +// $Id: CheatCodeDialog.cxx,v 1.3 2005-09-25 18:35:26 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -38,14 +38,14 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent, int x, int y, int w, int h) : Dialog(osystem, parent, x, y, w, h) { - const GUI::Font& font = instance()->font(); + // const GUI::Font& font = instance()->font(); - myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Codes", kTextAlignCenter); + myTitle = new StaticTextWidget(this, 10, 5, w - 20, kFontHeight, "Cheat Code", kTextAlignCenter); + myError = new StaticTextWidget(this, 10, 32, w - 20, kFontHeight, "Invalid Code", kTextAlignLeft); + myError->setFlags(WIDGET_INVISIBLE); + myInput = new EditTextWidget(this, 10, 20, 48, kFontHeight, ""); + addFocusWidget(myInput); addButton(w - (kButtonWidth + 10), h - 24, "Close", kCloseCmd, 'C'); - addButton(w - (kButtonWidth + 10), h - 48, "Load", kLoadCmd, 'C'); - myEnableCheat = new CheckboxWidget(this, font, 10, 20, "Enabled", kEnableCheat); - myEnableCheat->setState(false); - myCheat = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -59,30 +59,36 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd, { switch(cmd) { - case kLoadCmd: - myCheat = Cheat::parse("db000f"); - loadConfig(); + case kEditAcceptCmd: + cerr << myInput->getEditString() << endl; + myCheat = Cheat::parse(myInput->getEditString()); + if(myCheat) { + myError->setFlags(WIDGET_INVISIBLE); + loadConfig(); + draw(); + myCheat->enable(); + delete myCheat; // TODO: keep and add to list + Dialog::handleCommand(sender, kCloseCmd, data, id); + } else { + cerr << "bad cheat code" << endl; + myInput->setEditString(""); + myError->clearFlags(WIDGET_INVISIBLE); + loadConfig(); + draw(); + Dialog::handleCommand(sender, cmd, data, 0); + } break; - case kEnableCheat: - if(!myCheat) - myEnableCheat->setState(false); - else if(myCheat->enabled()) - myCheat->disable(); - else - myCheat->enable(); - + case kEditCancelCmd: + Dialog::handleCommand(sender, kCloseCmd, data, id); break; default: Dialog::handleCommand(sender, cmd, data, 0); + break; } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheatCodeDialog::loadConfig() { - cerr << "CheatCodeDialog::loadConfig()" << endl; - - myEnableCheat->setState(myCheat && myCheat->enabled()); - myEnableCheat->setEnabled(myCheat != 0); } diff --git a/stella/src/gui/CheatCodeDialog.hxx b/stella/src/gui/CheatCodeDialog.hxx index 3c1a7c938..b70dab622 100644 --- a/stella/src/gui/CheatCodeDialog.hxx +++ b/stella/src/gui/CheatCodeDialog.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: CheatCodeDialog.hxx,v 1.1 2005-08-05 02:28:22 urchlay Exp $ +// $Id: CheatCodeDialog.hxx,v 1.2 2005-09-25 18:35:26 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -31,6 +31,7 @@ class StaticTextWidget; #include "Dialog.hxx" #include "Widget.hxx" #include "Cheat.hxx" +#include "EditTextWidget.hxx" #include "Props.hxx" #include "bspf.hxx" @@ -45,12 +46,14 @@ class CheatCodeDialog : public Dialog protected: ButtonWidget *myExitButton; StaticTextWidget *myTitle; - CheckboxWidget *myEnableCheat; + StaticTextWidget *myError; + // CheckboxWidget *myEnableCheat; private: virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); void loadConfig(); Cheat *myCheat; + EditTextWidget *myInput; }; #endif diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index a92c22313..6be607177 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.26 2005-09-06 22:25:40 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.27 2005-09-25 18:35:26 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -83,7 +83,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent) addBigButton("Event Mapping", kEMapCmd, 0); addBigButton("Game Information", kInfoCmd, 0); b = addBigButton("Cheat Code", kCheatCmd, 0); - b->clearFlags(WIDGET_ENABLED); // TODO - finish after next release + // b->clearFlags(WIDGET_ENABLED); // TODO - finish after next release addBigButton("Help", kHelpCmd, 0); addBigButton("About", kAboutCmd, 0); addBigButton("Exit Menu", kExitCmd, 0);