diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index ef7dbb8ba..75c123490 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.86 2006-03-16 16:10:47 stephena Exp $ +// $Id: Console.cxx,v 1.87 2006-03-19 18:17:48 stephena Exp $ //============================================================================ #include @@ -94,7 +94,8 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5, iHeight = atoi(myProperties.get(Display_Height).c_str()); if(iWidth > sWidth || iHeight > sHeight) { - myOSystem->frameBuffer().showMessage("PAL ROMS not supported, screen too small"); + myOSystem->frameBuffer().showMessage("PAL ROMS not supported, screen too small", + kMiddleCenter, kTextColorEm); return; } diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index b68eb479b..3947c0b1d 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.82 2006-03-18 00:00:30 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.83 2006-03-19 18:17:48 stephena Exp $ //============================================================================ #include @@ -52,10 +52,7 @@ FrameBuffer::FrameBuffer(OSystem* osystem) myUsePhosphor(false), myPhosphorBlend(77), myFrameRate(0), - myPauseStatus(false), - myMessageTime(0), - myMessageText(""), - myNumRedraws(0) + myPauseStatus(false) { myBaseDim.x = myBaseDim.y = myBaseDim.w = myBaseDim.h = 0; myImageDim = myScreenDim = myDesktopDim = myBaseDim; @@ -143,7 +140,7 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height, SDL_EnableUNICODE(1); // Erase any messages from a previous run - myMessageTime = 0; + myMessage.counter = 0; myUseDirtyRects = myOSystem->settings().getBool("dirtyrects"); } @@ -177,7 +174,7 @@ void FrameBuffer::update() drawMediaSource(); // Draw any pending messages - if(myMessageTime > 0 && !myPauseStatus) + if(myMessage.counter > 0 && !myPauseStatus) drawMessage(); break; // S_EMULATE @@ -202,7 +199,7 @@ void FrameBuffer::update() myOSystem->commandMenu().draw(); // Draw any pending messages - if(myMessageTime > 0 && !myPauseStatus) + if(myMessage.counter > 0 && !myPauseStatus) drawMessage(); break; // S_CMDMENU } @@ -212,7 +209,7 @@ void FrameBuffer::update() myOSystem->launcher().draw(); // Draw any pending messages - if(myMessageTime > 0) + if(myMessage.counter > 0) drawMessage(); break; // S_LAUNCHER @@ -239,50 +236,100 @@ void FrameBuffer::update() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FrameBuffer::showMessage(const string& message) +void FrameBuffer::showMessage(const string& message, MessagePosition position, + OverlayColor color) { // Erase old messages on the screen - if(myMessageTime > 0) + if(myMessage.counter > 0) { theRedrawTIAIndicator = true; myOSystem->eventHandler().refreshDisplay(); } - myMessageText = message; - myMessageTime = myFrameRate << 1; // Show message for 2 seconds + // Precompute the message coordinates + myMessage.text = message; + myMessage.counter = myFrameRate << 1; // Show message for 2 seconds + myMessage.color = color; + + myMessage.w = myOSystem->font().getStringWidth(myMessage.text) + 10; + myMessage.h = myOSystem->font().getFontHeight() + 8; + + switch(position) + { + case kTopLeft: + myMessage.x = 5; + myMessage.y = 5; + break; + + case kTopCenter: + myMessage.x = (myBaseDim.w >> 1) - (myMessage.w >> 1); + myMessage.y = 5; + break; + + case kTopRight: + myMessage.x = myBaseDim.w - myMessage.w - 5; + myMessage.y = 5; + break; + + case kMiddleLeft: + myMessage.x = 5; + myMessage.y = (myBaseDim.h >> 1) - (myMessage.h >> 1); + break; + + case kMiddleCenter: + myMessage.x = (myBaseDim.w >> 1) - (myMessage.w >> 1); + myMessage.y = (myBaseDim.h >> 1) - (myMessage.h >> 1); + break; + + case kMiddleRight: + myMessage.x = myBaseDim.w - myMessage.w - 5; + myMessage.y = (myBaseDim.h >> 1) - (myMessage.h >> 1); + break; + + case kBottomLeft: + myMessage.x = 5;//(myMessage.w >> 1); + myMessage.y = myBaseDim.h - myMessage.h - 5; + break; + + case kBottomCenter: + myMessage.x = (myBaseDim.w >> 1) - (myMessage.w >> 1); + myMessage.y = myBaseDim.h - myMessage.h - 5; + break; + + case kBottomRight: + myMessage.x = myBaseDim.w - myMessage.w - 5; + myMessage.y = myBaseDim.h - myMessage.h - 5; + break; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::hideMessage() { // Erase old messages on the screen - if(myMessageTime > 0) + if(myMessage.counter > 0) myOSystem->eventHandler().refreshDisplay(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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--; + fillRect(myMessage.x+1, myMessage.y+2, myMessage.w-2, myMessage.h-4, kBGColor); + box(myMessage.x, myMessage.y+1, myMessage.w, myMessage.h-2, kColor, kColor); + drawString(&myOSystem->font(), myMessage.text, myMessage.x+1, myMessage.y+4, + myMessage.w, myMessage.color, kTextAlignCenter); + myMessage.counter--; // Either erase the entire message (when time is reached), // or show again this frame - if(myMessageTime == 0) + if(myMessage.counter == 0) { // Force an immediate update myOSystem->eventHandler().refreshDisplay(true); } else - addDirtyRect(x, y, w, h); + addDirtyRect(myMessage.x, myMessage.y, myMessage.w, myMessage.h); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 56f9750c5..9e22d4d8c 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.66 2006-03-18 00:00:30 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.67 2006-03-19 18:17:48 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -49,6 +49,19 @@ enum BufferType { kGLBuffer }; +// Positions for onscreen/overlaid messages +enum MessagePosition { + kTopLeft, + kTopCenter, + kTopRight, + kMiddleLeft, + kMiddleCenter, + kMiddleRight, + kBottomLeft, + kBottomCenter, + kBottomRight +}; + /** This class encapsulates the MediaSource and is the basis for the video display in Stella. All graphics ports should derive from this class for @@ -57,7 +70,7 @@ enum BufferType { All GUI elements (ala ScummVM) are drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.66 2006-03-18 00:00:30 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.67 2006-03-19 18:17:48 stephena Exp $ */ class FrameBuffer { @@ -94,8 +107,12 @@ class FrameBuffer Shows a message onscreen. @param message The message to be shown + @param position Onscreen position for the message + @param color Color of text in the message */ - void showMessage(const string& message); + void showMessage(const string& message, + MessagePosition position = kBottomCenter, + OverlayColor color = kTextColor); /** Hides any onscreen messages. @@ -144,7 +161,7 @@ class FrameBuffer Indicates that the TIA area is dirty, and certain areas need to be redrawn. */ - void refresh() { theRedrawTIAIndicator = true; myMessageTime = 0; } + void refresh() { theRedrawTIAIndicator = true; } /** Toggles between fullscreen and window mode. @@ -494,15 +511,14 @@ class FrameBuffer // Indicates the current pause status bool myPauseStatus; - // Message timer - Int32 myMessageTime; - - // Message text - string myMessageText; - - // Indicates how many times the framebuffer has been redrawn - // Used only for debugging purposes - uInt32 myNumRedraws; + // Used for onscreen messages + struct Message { + string text; + int counter; + int x, y, w, h; + OverlayColor color; + }; + Message myMessage; }; #endif diff --git a/stella/src/emucore/MD5.cxx b/stella/src/emucore/MD5.cxx index 74d5a63fb..342cc2e7c 100644 --- a/stella/src/emucore/MD5.cxx +++ b/stella/src/emucore/MD5.cxx @@ -16,9 +16,11 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: MD5.cxx,v 1.3 2005-10-19 00:59:51 stephena Exp $ +// $Id: MD5.cxx,v 1.4 2006-03-19 18:17:48 stephena Exp $ //============================================================================ +#include + #include "MD5.hxx" /* diff --git a/stella/src/gui/LauncherDialog.cxx b/stella/src/gui/LauncherDialog.cxx index 20b3e209c..674ffc1ec 100644 --- a/stella/src/gui/LauncherDialog.cxx +++ b/stella/src/gui/LauncherDialog.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: LauncherDialog.cxx,v 1.47 2006-03-10 01:20:04 markgrebe Exp $ +// $Id: LauncherDialog.cxx,v 1.48 2006-03-19 18:17:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -64,12 +64,12 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, WidgetArray wid; // Show game name - lwidth = font.getStringWidth("Select a game from the list ..."); + lwidth = font.getStringWidth("Select an item from the list ..."); xpos += 10; ypos += 8; new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, - "Select a game from the list ...", kTextAlignLeft); + "Select an item from the list ...", kTextAlignLeft); - lwidth = font.getStringWidth("XXXX files found"); + lwidth = font.getStringWidth("XXXX items found"); xpos = _w - lwidth - 10; myRomCount = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, @@ -89,8 +89,8 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, // Add note textwidget to show any notes for the currently selected ROM xpos += 5; ypos += myList->getHeight() + 4; lwidth = font.getStringWidth("Note:"); - new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, - "Note:", kTextAlignLeft); + myNoteLabel = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, + "Note:", kTextAlignLeft); xpos += lwidth + 5; myNote = new StaticTextWidget(this, font, xpos, ypos, _w - xpos - 10, fontHeight, @@ -100,7 +100,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, xpos = 10; ypos += myNote->getHeight() + 4; #ifndef MAC_OSX myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, - "Play", kStartCmd, 0); + "Select", kStartCmd, 0); myStartButton->setEditable(true); wid.push_back(myStartButton); xpos += bwidth + 8; @@ -119,7 +119,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, myQuitButton->setEditable(true); wid.push_back(myQuitButton); xpos += bwidth + 8; - mySelectedItem = 0; // Highlight 'Play' button + mySelectedItem = 0; // Highlight 'Select' button #else myQuitButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Quit", kQuitCmd, 0); @@ -137,11 +137,11 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, wid.push_back(myRelPrevButton); xpos += bwidth + 8; myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, - "Play", kStartCmd, 0); + "Select", kStartCmd, 0); myStartButton->setEditable(true); wid.push_back(myStartButton); xpos += bwidth + 8; - mySelectedItem = 3; // Highlight 'Play' button + mySelectedItem = 3; // Highlight 'Select' button #endif // Create the launcher options dialog, where you can change ROM @@ -158,6 +158,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, // (De)activate browse mode myBrowseModeFlag = instance()->settings().getBool("rombrowse"); myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload"); + myNoteLabel->setEnabled(!myBrowseModeFlag); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -241,7 +242,7 @@ void LauncherDialog::updateListing(bool fullReload) // Indicate how many files were found ostringstream buf; - buf << myGameList->size() << " files found"; + buf << myGameList->size() << " items found"; myRomCount->setLabel(buf.str()); enableButtons(true); @@ -538,6 +539,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, case kBrowseChangedCmd: myBrowseModeFlag = instance()->settings().getBool("rombrowse"); myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload"); + myNoteLabel->setEnabled(!myBrowseModeFlag); break; default: diff --git a/stella/src/gui/LauncherDialog.hxx b/stella/src/gui/LauncherDialog.hxx index db74174b9..755cce54b 100644 --- a/stella/src/gui/LauncherDialog.hxx +++ b/stella/src/gui/LauncherDialog.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: LauncherDialog.hxx,v 1.17 2006-03-09 17:04:01 stephena Exp $ +// $Id: LauncherDialog.hxx,v 1.18 2006-03-19 18:17:48 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -67,6 +67,7 @@ class LauncherDialog : public Dialog ButtonWidget* myQuitButton; StringListWidget* myList; + StaticTextWidget* myNoteLabel; StaticTextWidget* myNote; StaticTextWidget* myRomCount; GameList* myGameList;