Reworked overlaid messages in the framebuffer; you can now select the

region of the screen in a 9x9 grid (top/middle/bottom by left/center/right),
as well as the color of the message text.

Updated some strings on the ROM launcher, since it doesn't make sense
to 'Play' a directory.

Disabled display of 'Note' while in rom browse mode in the ROM launcher.
It ends up taking too much CPU time to parse all the ROMs in a directory
each time it changes, so there are now two options: (1) don't browse the
filesystem, and precompute the folder contents/see all the ROM info
or (2) browse the filesystem, allowing selection of folders, etc, but
not seeing ROM names and notes as defined in the properties file.  For
performance reasons, it's going to have to be an either/or thing.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1056 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-03-19 18:17:48 +00:00
parent 0da30905ee
commit 79c815afc6
6 changed files with 122 additions and 53 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 <assert.h> #include <assert.h>
@ -94,7 +94,8 @@ Console::Console(const uInt8* image, uInt32 size, const string& md5,
iHeight = atoi(myProperties.get(Display_Height).c_str()); iHeight = atoi(myProperties.get(Display_Height).c_str());
if(iWidth > sWidth || iHeight > sHeight) 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; return;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 <sstream> #include <sstream>
@ -52,10 +52,7 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
myUsePhosphor(false), myUsePhosphor(false),
myPhosphorBlend(77), myPhosphorBlend(77),
myFrameRate(0), myFrameRate(0),
myPauseStatus(false), myPauseStatus(false)
myMessageTime(0),
myMessageText(""),
myNumRedraws(0)
{ {
myBaseDim.x = myBaseDim.y = myBaseDim.w = myBaseDim.h = 0; myBaseDim.x = myBaseDim.y = myBaseDim.w = myBaseDim.h = 0;
myImageDim = myScreenDim = myDesktopDim = myBaseDim; myImageDim = myScreenDim = myDesktopDim = myBaseDim;
@ -143,7 +140,7 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
// Erase any messages from a previous run // Erase any messages from a previous run
myMessageTime = 0; myMessage.counter = 0;
myUseDirtyRects = myOSystem->settings().getBool("dirtyrects"); myUseDirtyRects = myOSystem->settings().getBool("dirtyrects");
} }
@ -177,7 +174,7 @@ void FrameBuffer::update()
drawMediaSource(); drawMediaSource();
// Draw any pending messages // Draw any pending messages
if(myMessageTime > 0 && !myPauseStatus) if(myMessage.counter > 0 && !myPauseStatus)
drawMessage(); drawMessage();
break; // S_EMULATE break; // S_EMULATE
@ -202,7 +199,7 @@ void FrameBuffer::update()
myOSystem->commandMenu().draw(); myOSystem->commandMenu().draw();
// Draw any pending messages // Draw any pending messages
if(myMessageTime > 0 && !myPauseStatus) if(myMessage.counter > 0 && !myPauseStatus)
drawMessage(); drawMessage();
break; // S_CMDMENU break; // S_CMDMENU
} }
@ -212,7 +209,7 @@ void FrameBuffer::update()
myOSystem->launcher().draw(); myOSystem->launcher().draw();
// Draw any pending messages // Draw any pending messages
if(myMessageTime > 0) if(myMessage.counter > 0)
drawMessage(); drawMessage();
break; // S_LAUNCHER 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 // Erase old messages on the screen
if(myMessageTime > 0) if(myMessage.counter > 0)
{ {
theRedrawTIAIndicator = true; theRedrawTIAIndicator = true;
myOSystem->eventHandler().refreshDisplay(); myOSystem->eventHandler().refreshDisplay();
} }
myMessageText = message; // Precompute the message coordinates
myMessageTime = myFrameRate << 1; // Show message for 2 seconds 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() void FrameBuffer::hideMessage()
{ {
// Erase old messages on the screen // Erase old messages on the screen
if(myMessageTime > 0) if(myMessage.counter > 0)
myOSystem->eventHandler().refreshDisplay(); myOSystem->eventHandler().refreshDisplay();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void FrameBuffer::drawMessage() 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 // Draw the bounded box and text
fillRect(x+1, y+2, w-2, h-4, kBGColor); fillRect(myMessage.x+1, myMessage.y+2, myMessage.w-2, myMessage.h-4, kBGColor);
box(x, y+1, w, h-2, kColor, kColor); box(myMessage.x, myMessage.y+1, myMessage.w, myMessage.h-2, kColor, kColor);
drawString(&myOSystem->font(), myMessageText, x+1, y+4, w, kTextColor, kTextAlignCenter); drawString(&myOSystem->font(), myMessage.text, myMessage.x+1, myMessage.y+4,
myMessageTime--; myMessage.w, myMessage.color, kTextAlignCenter);
myMessage.counter--;
// Either erase the entire message (when time is reached), // Either erase the entire message (when time is reached),
// or show again this frame // or show again this frame
if(myMessageTime == 0) if(myMessage.counter == 0)
{ {
// Force an immediate update // Force an immediate update
myOSystem->eventHandler().refreshDisplay(true); myOSystem->eventHandler().refreshDisplay(true);
} }
else else
addDirtyRect(x, y, w, h); addDirtyRect(myMessage.x, myMessage.y, myMessage.w, myMessage.h);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 #ifndef FRAMEBUFFER_HXX
@ -49,6 +49,19 @@ enum BufferType {
kGLBuffer 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 This class encapsulates the MediaSource and is the basis for the video
display in Stella. All graphics ports should derive from this class for 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. All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony @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 class FrameBuffer
{ {
@ -94,8 +107,12 @@ class FrameBuffer
Shows a message onscreen. Shows a message onscreen.
@param message The message to be shown @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. Hides any onscreen messages.
@ -144,7 +161,7 @@ class FrameBuffer
Indicates that the TIA area is dirty, and certain areas need Indicates that the TIA area is dirty, and certain areas need
to be redrawn. to be redrawn.
*/ */
void refresh() { theRedrawTIAIndicator = true; myMessageTime = 0; } void refresh() { theRedrawTIAIndicator = true; }
/** /**
Toggles between fullscreen and window mode. Toggles between fullscreen and window mode.
@ -494,15 +511,14 @@ class FrameBuffer
// Indicates the current pause status // Indicates the current pause status
bool myPauseStatus; bool myPauseStatus;
// Message timer // Used for onscreen messages
Int32 myMessageTime; struct Message {
string text;
// Message text int counter;
string myMessageText; int x, y, w, h;
OverlayColor color;
// Indicates how many times the framebuffer has been redrawn };
// Used only for debugging purposes Message myMessage;
uInt32 myNumRedraws;
}; };
#endif #endif

View File

@ -16,9 +16,11 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 <fstream>
#include "MD5.hxx" #include "MD5.hxx"
/* /*

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -64,12 +64,12 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
WidgetArray wid; WidgetArray wid;
// Show game name // 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; xpos += 10; ypos += 8;
new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, 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; xpos = _w - lwidth - 10;
myRomCount = new StaticTextWidget(this, font, xpos, ypos, myRomCount = new StaticTextWidget(this, font, xpos, ypos,
lwidth, fontHeight, lwidth, fontHeight,
@ -89,8 +89,8 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// Add note textwidget to show any notes for the currently selected ROM // Add note textwidget to show any notes for the currently selected ROM
xpos += 5; ypos += myList->getHeight() + 4; xpos += 5; ypos += myList->getHeight() + 4;
lwidth = font.getStringWidth("Note:"); lwidth = font.getStringWidth("Note:");
new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight, myNoteLabel = new StaticTextWidget(this, font, xpos, ypos, lwidth, fontHeight,
"Note:", kTextAlignLeft); "Note:", kTextAlignLeft);
xpos += lwidth + 5; xpos += lwidth + 5;
myNote = new StaticTextWidget(this, font, xpos, ypos, myNote = new StaticTextWidget(this, font, xpos, ypos,
_w - xpos - 10, fontHeight, _w - xpos - 10, fontHeight,
@ -100,7 +100,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
xpos = 10; ypos += myNote->getHeight() + 4; xpos = 10; ypos += myNote->getHeight() + 4;
#ifndef MAC_OSX #ifndef MAC_OSX
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Play", kStartCmd, 0); "Select", kStartCmd, 0);
myStartButton->setEditable(true); myStartButton->setEditable(true);
wid.push_back(myStartButton); wid.push_back(myStartButton);
xpos += bwidth + 8; xpos += bwidth + 8;
@ -119,7 +119,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
myQuitButton->setEditable(true); myQuitButton->setEditable(true);
wid.push_back(myQuitButton); wid.push_back(myQuitButton);
xpos += bwidth + 8; xpos += bwidth + 8;
mySelectedItem = 0; // Highlight 'Play' button mySelectedItem = 0; // Highlight 'Select' button
#else #else
myQuitButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, myQuitButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Quit", kQuitCmd, 0); "Quit", kQuitCmd, 0);
@ -137,11 +137,11 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
wid.push_back(myRelPrevButton); wid.push_back(myRelPrevButton);
xpos += bwidth + 8; xpos += bwidth + 8;
myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, myStartButton = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight,
"Play", kStartCmd, 0); "Select", kStartCmd, 0);
myStartButton->setEditable(true); myStartButton->setEditable(true);
wid.push_back(myStartButton); wid.push_back(myStartButton);
xpos += bwidth + 8; xpos += bwidth + 8;
mySelectedItem = 3; // Highlight 'Play' button mySelectedItem = 3; // Highlight 'Select' button
#endif #endif
// Create the launcher options dialog, where you can change ROM // Create the launcher options dialog, where you can change ROM
@ -158,6 +158,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// (De)activate browse mode // (De)activate browse mode
myBrowseModeFlag = instance()->settings().getBool("rombrowse"); myBrowseModeFlag = instance()->settings().getBool("rombrowse");
myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload"); myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload");
myNoteLabel->setEnabled(!myBrowseModeFlag);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -241,7 +242,7 @@ void LauncherDialog::updateListing(bool fullReload)
// Indicate how many files were found // Indicate how many files were found
ostringstream buf; ostringstream buf;
buf << myGameList->size() << " files found"; buf << myGameList->size() << " items found";
myRomCount->setLabel(buf.str()); myRomCount->setLabel(buf.str());
enableButtons(true); enableButtons(true);
@ -538,6 +539,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
case kBrowseChangedCmd: case kBrowseChangedCmd:
myBrowseModeFlag = instance()->settings().getBool("rombrowse"); myBrowseModeFlag = instance()->settings().getBool("rombrowse");
myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload"); myRelPrevButton->setLabel(myBrowseModeFlag ? "Go Up" : "Reload");
myNoteLabel->setEnabled(!myBrowseModeFlag);
break; break;
default: default:

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // 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 // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -67,6 +67,7 @@ class LauncherDialog : public Dialog
ButtonWidget* myQuitButton; ButtonWidget* myQuitButton;
StringListWidget* myList; StringListWidget* myList;
StaticTextWidget* myNoteLabel;
StaticTextWidget* myNote; StaticTextWidget* myNote;
StaticTextWidget* myRomCount; StaticTextWidget* myRomCount;
GameList* myGameList; GameList* myGameList;