diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index 8ade555a2..4f4a31bd8 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.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: Console.cxx,v 1.66 2005-08-24 22:54:30 stephena Exp $ +// $Id: Console.cxx,v 1.67 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #include @@ -45,6 +45,7 @@ #include "FrameBuffer.hxx" #include "OSystem.hxx" #include "Menu.hxx" +#include "CommandMenu.hxx" #include "Version.hxx" #ifdef SNAPSHOT_SUPPORT @@ -186,10 +187,13 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem) myOSystem->sound().setFrameRate(framerate); myOSystem->sound().initialize(); - // Initialize the menuing system with updated values from the framebuffer + // Initialize the options menu system with updated values from the framebuffer myOSystem->menu().initialize(); myOSystem->menu().setGameProfile(myProperties); + // Initialize the command menu system with updated values from the framebuffer + myOSystem->commandMenu().initialize(); + #ifdef DEVELOPER_SUPPORT // Finally, initialize the debugging system, since it depends on the current ROM myOSystem->debugger().setConsole(this); diff --git a/stella/src/emucore/Event.hxx b/stella/src/emucore/Event.hxx index 68d001c49..2a0e9ccd2 100644 --- a/stella/src/emucore/Event.hxx +++ b/stella/src/emucore/Event.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: Event.hxx,v 1.12 2005-06-28 03:34:41 urchlay Exp $ +// $Id: Event.hxx,v 1.13 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #ifndef EVENT_HXX @@ -25,7 +25,7 @@ class Event; /** @author Bradford W. Mott - @version $Id: Event.hxx,v 1.12 2005-06-28 03:34:41 urchlay Exp $ + @version $Id: Event.hxx,v 1.13 2005-08-29 18:36:41 stephena Exp $ */ class Event { @@ -72,7 +72,7 @@ class Event DrivingOneFire, ChangeState, LoadState, SaveState, TakeSnapshot, Pause, Quit, - MenuMode, DebuggerMode, LauncherMode, Fry, + MenuMode, CmdMenuMode, DebuggerMode, LauncherMode, Fry, LastType }; diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 659ea3f60..0bd2ba27e 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.88 2005-08-25 16:29:52 stephena Exp $ +// $Id: EventHandler.cxx,v 1.89 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #include @@ -29,6 +29,7 @@ #include "Sound.hxx" #include "OSystem.hxx" #include "Menu.hxx" +#include "CommandMenu.hxx" #include "Launcher.hxx" #include "GuiUtils.hxx" #include "bspf.hxx" @@ -143,19 +144,10 @@ void EventHandler::reset(State state) switch(myState) { - case S_EMULATE: - break; - - case S_MENU: - break; - case S_LAUNCHER: myUseLauncherFlag = true; break; - case S_DEBUGGER: - break; - default: break; } @@ -175,6 +167,11 @@ void EventHandler::refreshDisplay() myOSystem->menu().refresh(); break; + case S_CMDMENU: + myOSystem->frameBuffer().refresh(); + myOSystem->commandMenu().refresh(); + break; + case S_LAUNCHER: myOSystem->launcher().refresh(); break; @@ -642,6 +639,10 @@ void EventHandler::poll(uInt32 time) myOSystem->menu().updateTime(time); break; + case S_CMDMENU: + myOSystem->commandMenu().updateTime(time); + break; + case S_LAUNCHER: myOSystem->launcher().updateTime(time); break; @@ -670,6 +671,11 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta enterMenuMode(); return; } + else if(myKeyTable[key] == Event::CmdMenuMode && state == 1 && !myPauseFlag) + { + enterCmdMenuMode(); + return; + } else if(myKeyTable[key] == Event::DebuggerMode && state == 1 && !myPauseFlag) { enterDebugMode(); @@ -693,6 +699,15 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta myOSystem->menu().handleKeyEvent(unicode, key, mod, state); break; + case S_CMDMENU: + if(myKeyTable[key] == Event::CmdMenuMode && state == 1) + { + leaveCmdMenuMode(); + return; + } + myOSystem->commandMenu().handleKeyEvent(unicode, key, mod, state); + break; + case S_LAUNCHER: myOSystem->launcher().handleKeyEvent(unicode, key, mod, state); break; @@ -742,6 +757,10 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event) myOSystem->menu().handleMouseMotionEvent(x, y, 0); break; + case S_CMDMENU: + myOSystem->commandMenu().handleMouseMotionEvent(x, y, 0); + break; + case S_LAUNCHER: myOSystem->launcher().handleMouseMotionEvent(x, y, 0); break; @@ -769,6 +788,7 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, uInt8 state) break; case S_MENU: + case S_CMDMENU: case S_LAUNCHER: case S_DEBUGGER: { @@ -804,6 +824,8 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, uInt8 state) if(myState == S_MENU) myOSystem->menu().handleMouseButtonEvent(button, x, y, state); + else if(myState == S_CMDMENU) + myOSystem->commandMenu().handleMouseButtonEvent(button, x, y, state); else if(myState == S_LAUNCHER) myOSystem->launcher().handleMouseButtonEvent(button, x, y, state); #ifdef DEVELOPER_SUPPORT @@ -949,6 +971,8 @@ void EventHandler::handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state) handleEvent(myJoyTable[stick*kNumJoyButtons + code], state); break; +// FIXME - remove handleJoyEvent from DialogContainer, have it pass +// mouse events instead case S_MENU: myOSystem->menu().handleJoyEvent(stick, code, state); break; @@ -1036,7 +1060,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 state) void EventHandler::setActionMappings() { // Fill the ActionList with the current key and joystick mappings - for(Int32 i = 0; i < 61; ++i) + for(Int32 i = 0; i < 62; ++i) { Event::Type event = ourActionList[i].event; ourActionList[i].key = "None"; @@ -1277,6 +1301,7 @@ void EventHandler::setDefaultKeymap() myKeyTable[ SDLK_F12 ] = Event::TakeSnapshot; myKeyTable[ SDLK_PAUSE ] = Event::Pause; myKeyTable[ SDLK_TAB ] = Event::MenuMode; + myKeyTable[ SDLK_BACKSLASH ] = Event::CmdMenuMode; myKeyTable[ SDLK_BACKQUOTE ] = Event::DebuggerMode; myKeyTable[ SDLK_ESCAPE ] = Event::LauncherMode; myKeyTable[ SDLK_BACKSPACE ] = Event::Fry; @@ -1517,6 +1542,31 @@ void EventHandler::leaveMenuMode() myEvent->clear(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::enterCmdMenuMode() +{ + myState = S_CMDMENU; + myOSystem->commandMenu().reStack(); + + refreshDisplay(); + + myOSystem->frameBuffer().setCursorState(); + myOSystem->sound().mute(true); + myEvent->clear(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void EventHandler::leaveCmdMenuMode() +{ + myState = S_EMULATE; + + refreshDisplay(); + + myOSystem->frameBuffer().setCursorState(); + myOSystem->sound().mute(false); + myEvent->clear(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool EventHandler::enterDebugMode() { @@ -1803,7 +1853,7 @@ void EventHandler::setSDLMappings() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ActionList EventHandler::ourActionList[61] = { +ActionList EventHandler::ourActionList[62] = { { Event::ConsoleSelect, "Select", "" }, { Event::ConsoleReset, "Reset", "" }, { Event::ConsoleColor, "Color TV", "" }, @@ -1817,7 +1867,8 @@ ActionList EventHandler::ourActionList[61] = { { Event::LoadState, "Load State", "" }, { Event::TakeSnapshot, "Snapshot", "" }, { Event::Pause, "Pause", "" }, - { Event::MenuMode, "Toggle menu/options mode", "" }, + { Event::MenuMode, "Toggle options menu mode", "" }, + { Event::CmdMenuMode, "Toggle command menu mode", "" }, { Event::DebuggerMode, "Toggle debugger mode", "" }, { Event::LauncherMode, "Enter ROM launcher", "" }, { Event::Quit, "Quit", "" }, diff --git a/stella/src/emucore/EventHandler.hxx b/stella/src/emucore/EventHandler.hxx index 81bac837b..f4bc2b5b5 100644 --- a/stella/src/emucore/EventHandler.hxx +++ b/stella/src/emucore/EventHandler.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: EventHandler.hxx,v 1.46 2005-08-25 15:19:17 stephena Exp $ +// $Id: EventHandler.hxx,v 1.47 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #ifndef EVENTHANDLER_HXX @@ -74,7 +74,7 @@ struct Stella_Joystick { mapping can take place. @author Stephen Anthony - @version $Id: EventHandler.hxx,v 1.46 2005-08-25 15:19:17 stephena Exp $ + @version $Id: EventHandler.hxx,v 1.47 2005-08-29 18:36:41 stephena Exp $ */ class EventHandler { @@ -90,7 +90,7 @@ class EventHandler virtual ~EventHandler(); // Enumeration representing the different states of operation - enum State { S_NONE, S_EMULATE, S_LAUNCHER, S_MENU, S_DEBUGGER }; + enum State { S_NONE, S_EMULATE, S_LAUNCHER, S_MENU, S_CMDMENU, S_DEBUGGER }; /** Returns the event object associated with this handler class. @@ -220,11 +220,13 @@ class EventHandler void enterMenuMode(); void leaveMenuMode(); + void enterCmdMenuMode(); + void leaveCmdMenuMode(); bool enterDebugMode(); void leaveDebugMode(); // Holds static strings for the remap menu - static ActionList ourActionList[61]; + static ActionList ourActionList[62]; // Lookup table for paddle resistance events static const Event::Type Paddle_Resistance[4]; diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 8c5aadda0..b0b7eff38 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.cxx,v 1.65 2005-08-25 15:19:17 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.66 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #include @@ -28,6 +28,7 @@ #include "Font.hxx" #include "GuiUtils.hxx" #include "Menu.hxx" +#include "CommandMenu.hxx" #include "Launcher.hxx" #include "OSystem.hxx" @@ -173,28 +174,7 @@ void FrameBuffer::update() // Draw any pending messages if(myMessageTime > 0 && !myPauseStatus) - { - int w = myOSystem->font().getStringWidth(myMessageText) + 10; - int h = myOSystem->font().getFontHeight() + 8; - int x = (myBaseDim.w >> 1) - (w >> 1); - int y = myBaseDim.h - h - 10/2; - - // Draw the bounded box and text - fillRect(x+1, y+2, w-2, h-4, kBGColor); - box(x, y+1, w, h-2, kColor, kColor); - drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); - myMessageTime--; - - // Either erase the entire message (when time is reached), - // or show again this frame - if(myMessageTime == 0) - { - theRedrawTIAIndicator = true; - drawMediaSource(); - } - else - addDirtyRect(x, y, w, h); - } + drawMessage(); break; // S_EMULATE } @@ -208,6 +188,20 @@ void FrameBuffer::update() break; // S_MENU } + case EventHandler::S_CMDMENU: + { + // Only update the screen if it's been invalidated + if(theRedrawTIAIndicator) + drawMediaSource(); + + myOSystem->commandMenu().draw(); + + // Draw any pending messages + if(myMessageTime > 0 && !myPauseStatus) + drawMessage(); + break; // S_CMDMENU + } + case EventHandler::S_LAUNCHER: { myOSystem->launcher().draw(); @@ -260,6 +254,14 @@ void FrameBuffer::showMessage(const string& message) myMessageTime = myFrameRate << 1; // Show message for 2 seconds } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBuffer::hideMessage() +{ + // Erase old messages on the screen + if(myMessageTime > 0) + refresh(true); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::pause(bool status) { @@ -487,6 +489,31 @@ void FrameBuffer::setWindowIcon() #endif } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +inline void FrameBuffer::drawMessage() +{ + int w = myOSystem->font().getStringWidth(myMessageText) + 10; + int h = myOSystem->font().getFontHeight() + 8; + int x = (myBaseDim.w >> 1) - (w >> 1); + int y = myBaseDim.h - h - 10/2; + + // Draw the bounded box and text + fillRect(x+1, y+2, w-2, h-4, kBGColor); + box(x, y+1, w, h-2, kColor, kColor); + drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); + myMessageTime--; + + // Either erase the entire message (when time is reached), + // or show again this frame + if(myMessageTime == 0) + { + theRedrawTIAIndicator = true; + drawMediaSource(); + } + else + addDirtyRect(x, y, w, h); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h, OverlayColor colorA, OverlayColor colorB) diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 4de6ade5d..d19978462 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.hxx,v 1.54 2005-08-11 19:12:38 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.55 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -52,7 +52,7 @@ enum FrameStyle { All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.54 2005-08-11 19:12:38 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.55 2005-08-29 18:36:41 stephena Exp $ */ class FrameBuffer { @@ -92,6 +92,11 @@ class FrameBuffer */ void showMessage(const string& message); + /** + Hides any onscreen messages. + */ + void hideMessage(); + /** Returns the current width of the framebuffer *before* any scaling. @@ -441,6 +446,11 @@ class FrameBuffer */ void setWindowIcon(); + /** + Set the icon for the main SDL window. + */ + void drawMessage(); + private: // Indicates the current framerate of the system uInt32 myFrameRate; diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 95db7a621..62f4f9c7e 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.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: OSystem.cxx,v 1.33 2005-08-25 15:19:17 stephena Exp $ +// $Id: OSystem.cxx,v 1.34 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #include @@ -43,6 +43,7 @@ #include "PropsSet.hxx" #include "EventHandler.hxx" #include "Menu.hxx" +#include "CommandMenu.hxx" #include "Launcher.hxx" #include "Font.hxx" #include "StellaFont.hxx" @@ -59,6 +60,7 @@ OSystem::OSystem() myPropSet(NULL), myConsole(NULL), myMenu(NULL), + myCommandMenu(NULL), myLauncher(NULL), myDebugger(NULL), myRomFile(""), @@ -68,6 +70,7 @@ OSystem::OSystem() { // Create menu and launcher GUI objects myMenu = new Menu(this); + myCommandMenu = new CommandMenu(this); myLauncher = new Launcher(this); #ifdef DEVELOPER_SUPPORT myDebugger = new Debugger(this); @@ -101,6 +104,7 @@ OSystem::~OSystem() myDriverList.clear(); delete myMenu; + delete myCommandMenu; delete myLauncher; delete myFont; delete myConsoleFont; @@ -207,6 +211,7 @@ bool OSystem::createFrameBuffer(bool showmessage) { case EventHandler::S_EMULATE: case EventHandler::S_MENU: + case EventHandler::S_CMDMENU: myConsole->initializeVideo(); if(showmessage) { @@ -221,7 +226,7 @@ bool OSystem::createFrameBuffer(bool showmessage) else // a driver that doesn't exist was requested, so use software mode myFrameBuffer->showMessage("Software mode"); } - break; // S_EMULATE, S_MENU + break; // S_EMULATE, S_MENU, S_CMDMENU case EventHandler::S_LAUNCHER: myLauncher->initializeVideo(); @@ -278,14 +283,12 @@ void OSystem::createSound() { case EventHandler::S_EMULATE: case EventHandler::S_MENU: + case EventHandler::S_CMDMENU: case EventHandler::S_DEBUGGER: myConsole->initializeAudio(); break; // S_EMULATE, S_MENU, S_DEBUGGER - case EventHandler::S_LAUNCHER: - break; // S_LAUNCHER - - case EventHandler::S_NONE: + default: break; } } diff --git a/stella/src/emucore/OSystem.hxx b/stella/src/emucore/OSystem.hxx index 439d5dcc0..5cd688c6c 100644 --- a/stella/src/emucore/OSystem.hxx +++ b/stella/src/emucore/OSystem.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: OSystem.hxx,v 1.27 2005-08-24 22:54:30 stephena Exp $ +// $Id: OSystem.hxx,v 1.28 2005-08-29 18:36:41 stephena Exp $ //============================================================================ #ifndef OSYSTEM_HXX @@ -22,6 +22,7 @@ class PropertiesSet; class Menu; +class CommandMenu; class Launcher; class Debugger; @@ -42,7 +43,7 @@ class Debugger; other objects belong. @author Stephen Anthony - @version $Id: OSystem.hxx,v 1.27 2005-08-24 22:54:30 stephena Exp $ + @version $Id: OSystem.hxx,v 1.28 2005-08-29 18:36:41 stephena Exp $ */ class OSystem { @@ -128,6 +129,13 @@ class OSystem */ Menu& menu(void) const { return *myMenu; } + /** + Get the command menu of the system. + + @return The command menu object + */ + CommandMenu& commandMenu(void) const { return *myCommandMenu; } + /** Get the ROM launcher of the system. @@ -351,6 +359,9 @@ class OSystem // Pointer to the Menu object Menu* myMenu; + // Pointer to the CommandMenu object + CommandMenu* myCommandMenu; + // Pointer to the Launcher object Launcher* myLauncher; diff --git a/stella/src/gui/CommandDialog.cxx b/stella/src/gui/CommandDialog.cxx new file mode 100644 index 000000000..3493515b4 --- /dev/null +++ b/stella/src/gui/CommandDialog.cxx @@ -0,0 +1,177 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// 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 +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CommandDialog.cxx,v 1.1 2005-08-29 18:36:42 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include "OSystem.hxx" +#include "Dialog.hxx" +#include "DialogContainer.hxx" +#include "Widget.hxx" +#include "CommandDialog.hxx" +#include "EventHandler.hxx" + +enum { + kSelectCmd = 'Csel', + kResetCmd = 'Cres', + kColorCmd = 'Ccol', + kBWCmd = 'Cbwt', + kLeftDiffACmd = 'Clda', + kLeftDiffBCmd = 'Cldb', + kRightDiffACmd = 'Crda', + kRightDiffBCmd = 'Crdb', + kSaveStateCmd = 'Csst', + kStateSlotCmd = 'Ccst', + kLoadStateCmd = 'Clst', + kSnapshotCmd = 'Csnp' +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CommandDialog::CommandDialog(OSystem* osystem, DialogContainer* parent) + : Dialog(osystem, parent, 0, 0, 16, 16) +{ + int lineHeight = osystem->font().getLineHeight(), + buttonWidth = 60, + buttonHeight = lineHeight + 2, + xoffset = 5, + yoffset = 5, + lwidth = buttonWidth + 5; + + // Set real dimensions + _w = 4 * (lwidth) + 5; + _h = 3 * (buttonHeight+5) + 5; + _x = (osystem->frameBuffer().baseWidth() - _w) / 2; + _y = (osystem->frameBuffer().baseHeight() - _h) / 2; + + + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Select", kSelectCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Reset", kResetCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Color TV", kColorCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "B/W TV", kBWCmd, 0); + + xoffset = 5; yoffset += buttonHeight + 5; + + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Left Diff A", kLeftDiffACmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Left Diff B", kLeftDiffBCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Right Diff A", kRightDiffACmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Right Diff B", kRightDiffBCmd, 0); + + xoffset = 5; yoffset += buttonHeight + 5; + + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Save State", kSaveStateCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "State Slot", kStateSlotCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Load State", kLoadStateCmd, 0); + xoffset += lwidth; + new ButtonWidget(this, xoffset, yoffset, buttonWidth, buttonHeight, + "Snapshot", kSnapshotCmd, 0); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CommandDialog::~CommandDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CommandDialog::handleCommand(CommandSender* sender, int cmd, + int data, int id) +{ + bool execute = true; + Event::Type event = Event::NoType; + + switch(cmd) + { + case kSelectCmd: + event = Event::ConsoleSelect; + break; + + case kResetCmd: + event = Event::ConsoleReset; + break; + + case kColorCmd: + event = Event::ConsoleColor; + break; + + case kBWCmd: + event = Event::ConsoleBlackWhite; + break; + + case kLeftDiffACmd: + event = Event::ConsoleLeftDifficultyA; + break; + + case kLeftDiffBCmd: + event = Event::ConsoleLeftDifficultyB; + break; + + case kRightDiffACmd: + event = Event::ConsoleRightDifficultyA; + break; + + case kRightDiffBCmd: + event = Event::ConsoleRightDifficultyB; + break; + + case kSaveStateCmd: + event = Event::SaveState; + break; + + case kStateSlotCmd: + event = Event::ChangeState; + break; + + case kLoadStateCmd: + event = Event::LoadState; + break; + + case kSnapshotCmd: + event = Event::TakeSnapshot; + break; + + default: + execute = false; + } + + // Show changes onscreen + if(execute) + { + instance()->eventHandler().leaveCmdMenuMode(); + instance()->eventHandler().handleEvent(event, 1); + instance()->console().mediaSource().update(); + instance()->eventHandler().handleEvent(event, 0); + } +} diff --git a/stella/src/gui/CommandDialog.hxx b/stella/src/gui/CommandDialog.hxx new file mode 100644 index 000000000..6cc1aeeb1 --- /dev/null +++ b/stella/src/gui/CommandDialog.hxx @@ -0,0 +1,41 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// 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 +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CommandDialog.hxx,v 1.1 2005-08-29 18:36:42 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef COMMAND_DIALOG_HXX +#define COMMAND_DIALOG_HXX + +class Properties; +class CommandSender; +class DialogContainer; + +#include "OSystem.hxx" +#include "Dialog.hxx" + +class CommandDialog : public Dialog +{ + public: + CommandDialog(OSystem* osystem, DialogContainer* parent); + ~CommandDialog(); + + virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); +}; + +#endif diff --git a/stella/src/gui/CommandMenu.cxx b/stella/src/gui/CommandMenu.cxx new file mode 100644 index 000000000..ea52075da --- /dev/null +++ b/stella/src/gui/CommandMenu.cxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// 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 +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CommandMenu.cxx,v 1.1 2005-08-29 18:36:42 stephena Exp $ +//============================================================================ + +#include "Dialog.hxx" +#include "CommandDialog.hxx" +#include "CommandMenu.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CommandMenu::CommandMenu(OSystem* osystem) + : DialogContainer(osystem) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CommandMenu::~CommandMenu() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void CommandMenu::initialize() +{ + delete myBaseDialog; + myBaseDialog = new CommandDialog(myOSystem, this); +} diff --git a/stella/src/gui/CommandMenu.hxx b/stella/src/gui/CommandMenu.hxx new file mode 100644 index 000000000..2da06310e --- /dev/null +++ b/stella/src/gui/CommandMenu.hxx @@ -0,0 +1,53 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// 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 +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: CommandMenu.hxx,v 1.1 2005-08-29 18:36:42 stephena Exp $ +//============================================================================ + +#ifndef COMMAND_MENU_HXX +#define COMMAND_MENU_HXX + +class Properties; +class OSystem; + +#include "DialogContainer.hxx" + +/** + The base dialog for common commands in Stella. + + @author Stephen Anthony + @version $Id: CommandMenu.hxx,v 1.1 2005-08-29 18:36:42 stephena Exp $ +*/ +class CommandMenu : public DialogContainer +{ + public: + /** + Create a new menu stack + */ + CommandMenu(OSystem* osystem); + + /** + Destructor + */ + virtual ~CommandMenu(); + + public: + /** + Updates the basedialog to be of the type defined for this derived class. + */ + void initialize(); +}; + +#endif diff --git a/stella/src/gui/DialogContainer.cxx b/stella/src/gui/DialogContainer.cxx index 513391248..5b672827a 100644 --- a/stella/src/gui/DialogContainer.cxx +++ b/stella/src/gui/DialogContainer.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: DialogContainer.cxx,v 1.16 2005-08-11 19:12:39 stephena Exp $ +// $Id: DialogContainer.cxx,v 1.17 2005-08-29 18:36:42 stephena Exp $ //============================================================================ #include "OSystem.hxx" @@ -121,6 +121,9 @@ void DialogContainer::reStack() myDialogStack.pop(); addDialog(myBaseDialog); + // Erase any previous messages + myOSystem->frameBuffer().hideMessage(); + // Reset all continuous events myCurrentKeyDown.keycode = 0; myCurrentMouseDown.button = -1; diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index c42866452..6366de7c4 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -6,6 +6,8 @@ MODULE_OBJS := \ src/gui/BrowserDialog.o \ src/gui/ColorWidget.o \ src/gui/CheatCodeDialog.o \ + src/gui/CommandDialog.o \ + src/gui/CommandMenu.o \ src/gui/DataGridWidget.o \ src/gui/DataGridOpsWidget.o \ src/gui/DebuggerDialog.o \