Some more interface-related stuff. I realized that the last commit

didn't compile.  This one does.

Removed reference to TIA::showMessage, and added
UserInterface::showMessage, since it was always meant to be a
GUI element.  Having it in the TIA class was a temporary hack.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@192 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-09-26 22:39:36 +00:00
parent dbe02b2af4
commit b9f5cbb1fe
6 changed files with 239 additions and 213 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.16 2003-09-25 16:20:33 stephena Exp $ // $Id: Console.cxx,v 1.17 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -259,14 +259,12 @@ void Console::toggleFormat()
if(format == "NTSC") if(format == "NTSC")
{ {
message = "PAL Mode"; myUserInterface->showMessage("PAL Mode");
myMediaSource->showMessage(message, 120);
myProperties.set("Display.Format", "PAL"); myProperties.set("Display.Format", "PAL");
} }
else if(format == "PAL") else if(format == "PAL")
{ {
message = "NTSC Mode"; myUserInterface->showMessage("NTSC Mode");
myMediaSource->showMessage(message, 120);
myProperties.set("Display.Format", "NTSC"); myProperties.set("Display.Format", "NTSC");
} }
} }
@ -284,14 +282,12 @@ void Console::changeXStart(const uInt32 direction)
xstart += 4; xstart += 4;
if(xstart > 80) if(xstart > 80)
{ {
message = "XStart at maximum"; myUserInterface->showMessage("XStart at maximum");
myMediaSource->showMessage(message, 120);
return; return;
} }
else if((width + xstart) > 160) else if((width + xstart) > 160)
{ {
message = "XStart no effect"; myUserInterface->showMessage("XStart no effect");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -300,8 +296,7 @@ void Console::changeXStart(const uInt32 direction)
xstart -= 4; xstart -= 4;
if(xstart < 0) if(xstart < 0)
{ {
message = "XStart at minimum"; myUserInterface->showMessage("XStart at minimum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -312,7 +307,7 @@ void Console::changeXStart(const uInt32 direction)
message = "XStart "; message = "XStart ";
message += strval.str(); message += strval.str();
myMediaSource->showMessage(message, 120); myUserInterface->showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -327,8 +322,7 @@ void Console::changeYStart(const uInt32 direction)
ystart++; ystart++;
if(ystart > 64) if(ystart > 64)
{ {
message = "YStart at maximum"; myUserInterface->showMessage("YStart at maximum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -337,8 +331,7 @@ void Console::changeYStart(const uInt32 direction)
ystart--; ystart--;
if(ystart < 0) if(ystart < 0)
{ {
message = "YStart at minimum"; myUserInterface->showMessage("YStart at minimum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -349,7 +342,7 @@ void Console::changeYStart(const uInt32 direction)
message = "YStart "; message = "YStart ";
message += strval.str(); message += strval.str();
myMediaSource->showMessage(message, 120); myUserInterface->showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -365,14 +358,12 @@ void Console::changeWidth(const uInt32 direction)
width += 4; width += 4;
if((width > 160) || ((width % 4) != 0)) if((width > 160) || ((width % 4) != 0))
{ {
message = "Width at maximum"; myUserInterface->showMessage("Width at maximum");
myMediaSource->showMessage(message, 120);
return; return;
} }
else if((width + xstart) > 160) else if((width + xstart) > 160)
{ {
message = "Width no effect"; myUserInterface->showMessage("Width no effect");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -381,8 +372,7 @@ void Console::changeWidth(const uInt32 direction)
width -= 4; width -= 4;
if(width < 80) if(width < 80)
{ {
message = "Width at minimum"; myUserInterface->showMessage("Width at minimum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -393,7 +383,7 @@ void Console::changeWidth(const uInt32 direction)
message = "Width "; message = "Width ";
message += strval.str(); message += strval.str();
myMediaSource->showMessage(message, 120); myUserInterface->showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -408,8 +398,7 @@ void Console::changeHeight(const uInt32 direction)
height++; height++;
if(height > 256) if(height > 256)
{ {
message = "Height at maximum"; myUserInterface->showMessage("Height at maximum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -418,8 +407,7 @@ void Console::changeHeight(const uInt32 direction)
height--; height--;
if(height < 100) if(height < 100)
{ {
message = "Height at minimum"; myUserInterface->showMessage("Height at minimum");
myMediaSource->showMessage(message, 120);
return; return;
} }
} }
@ -430,27 +418,19 @@ void Console::changeHeight(const uInt32 direction)
message = "Height "; message = "Height ";
message += strval.str(); message += strval.str();
myMediaSource->showMessage(message, 120); myUserInterface->showMessage(message);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::saveProperties(string filename, bool merge) void Console::saveProperties(string filename, bool merge)
{ {
string message;
// Merge the current properties into the PropertiesSet file // Merge the current properties into the PropertiesSet file
if(merge) if(merge)
{ {
if(myPropSet.merge(myProperties, filename)) if(myPropSet.merge(myProperties, filename))
{ myUserInterface->showMessage("Properties merged");
message = "Properties merged";
myMediaSource->showMessage(message, 120);
}
else else
{ myUserInterface->showMessage("Properties not merged");
message = "Properties not merged";
myMediaSource->showMessage(message, 120);
}
} }
else // Save to the specified file directly else // Save to the specified file directly
{ {
@ -460,13 +440,11 @@ void Console::saveProperties(string filename, bool merge)
{ {
myProperties.save(out); myProperties.save(out);
out.close(); out.close();
message = "Properties saved"; myUserInterface->showMessage("Properties saved");
myMediaSource->showMessage(message, 120);
} }
else else
{ {
message = "Properties not saved"; myUserInterface->showMessage("Properties not saved");
myMediaSource->showMessage(message, 120);
} }
} }
} }

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: EventHandler.cxx,v 1.12 2003-09-26 17:35:05 stephena Exp $ // $Id: EventHandler.cxx,v 1.13 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -157,7 +157,7 @@ void EventHandler::sendEvent(Event::Type event, Int32 state)
} }
if(ourMessageTable[event] != "") if(ourMessageTable[event] != "")
myConsole->mediaSource().showMessage(ourMessageTable[event], 120); myConsole->gui().showMessage(ourMessageTable[event]);
} }
// Otherwise, pass it to the emulation core // Otherwise, pass it to the emulation core
@ -361,8 +361,7 @@ void EventHandler::saveState()
else if(result == 3) else if(result == 3)
buf << "Invalid state " << myCurrentState << " file"; buf << "Invalid state " << myCurrentState << " file";
string message = buf.str(); myConsole->gui().showMessage(buf.str());
myConsole->mediaSource().showMessage(message, 120);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -376,8 +375,8 @@ void EventHandler::changeState()
// Print appropriate message // Print appropriate message
ostringstream buf; ostringstream buf;
buf << "Changed to slot " << myCurrentState; buf << "Changed to slot " << myCurrentState;
string message = buf.str();
myConsole->mediaSource().showMessage(message, 120); myConsole->gui().showMessage(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -397,25 +396,20 @@ void EventHandler::loadState()
else if(result == 3) else if(result == 3)
buf << "Invalid state " << myCurrentState << " file"; buf << "Invalid state " << myCurrentState << " file";
string message = buf.str(); myConsole->gui().showMessage(buf.str());
myConsole->mediaSource().showMessage(message, 120);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::takeSnapshot() void EventHandler::takeSnapshot()
{ {
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
string message, filename;
// Now save the snapshot file // Now save the snapshot file
filename = myConsole->settings().snapshotFilename(); string filename = myConsole->settings().snapshotFilename();
myConsole->snapshot().savePNG(filename, myConsole->mediaSource(), myConsole->snapshot().savePNG(filename, myConsole->mediaSource(),
myConsole->settings().getInt("zoom")); myConsole->settings().getInt("zoom"));
message = "Snapshot saved"; myConsole->gui().showMessage("Snapshot saved");
myConsole->mediaSource().showMessage(message, 120);
#else #else
string message = "Snapshots unsupported"; myConsole->gui().showMessage("Snapshots unsupported");
myConsole->mediaSource().showMessage(message, 120);
#endif #endif
} }

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: MediaSrc.hxx,v 1.4 2002-10-09 04:38:11 bwmott Exp $ // $Id: MediaSrc.hxx,v 1.5 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#ifndef MEDIASOURCE_HXX #ifndef MEDIASOURCE_HXX
@ -29,7 +29,7 @@ class MediaSource;
This class provides an interface for accessing graphics and audio data. This class provides an interface for accessing graphics and audio data.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: MediaSrc.hxx,v 1.4 2002-10-09 04:38:11 bwmott Exp $ @version $Id: MediaSrc.hxx,v 1.5 2003-09-26 22:39:36 stephena Exp $
*/ */
class MediaSource class MediaSource
{ {
@ -63,12 +63,6 @@ class MediaSource
*/ */
virtual bool pause(bool state) = 0; virtual bool pause(bool state) = 0;
/**
Inserts the given message into the framebuffer for the given
number of frames.
*/
virtual void showMessage(string& message, Int32 duration) = 0;
/** /**
Answers the current frame buffer Answers the current frame buffer

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: TIA.cxx,v 1.22 2003-09-26 17:35:05 stephena Exp $ // $Id: TIA.cxx,v 1.23 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -37,8 +37,6 @@
TIA::TIA(const Console& console, uInt32 sampleRate) TIA::TIA(const Console& console, uInt32 sampleRate)
: myConsole(console), : myConsole(console),
myPauseState(false), myPauseState(false),
myMessageTime(0),
myMessageText(""),
myLastSoundUpdateCycle(0), myLastSoundUpdateCycle(0),
myColorLossEnabled(false), myColorLossEnabled(false),
myCOLUBK(myColor[0]), myCOLUBK(myColor[0]),
@ -575,8 +573,7 @@ void TIA::update()
myScanlineCountForLastFrame = totalClocks / 228; myScanlineCountForLastFrame = totalClocks / 228;
// Draw any pending user interface elements to the framebuffer // Draw any pending user interface elements to the framebuffer
if(myConsole.gui().drawPending()) myConsole.gui().update();
myConsole.gui().update();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -3112,46 +3109,6 @@ const uInt32 TIA::ourPALPalette[256] = {
0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec 0xd2d2d2, 0xd2d2d2, 0xececec, 0xececec
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TIA::ourFontData[36] = {
0x699f999, // A
0xe99e99e, // B
0x6988896, // C
0xe99999e, // D
0xf88e88f, // E
0xf88e888, // F
0x698b996, // G
0x999f999, // H
0x7222227, // I
0x72222a4, // J
0x9accaa9, // K
0x888888f, // L
0x9ff9999, // M
0x9ddbb99, // N
0x6999996, // O
0xe99e888, // P
0x69999b7, // Q
0xe99ea99, // R
0x6986196, // S
0x7222222, // T
0x9999996, // U
0x9999966, // V
0x9999ff9, // W
0x99fff99, // X
0x9996244, // Y
0xf12488f, // Z
0x69bd996, // 0
0x2622227, // 1
0x691248f, // 2
0x6916196, // 3
0xaaaf222, // 4
0xf88e11e, // 5
0x698e996, // 6
0xf112244, // 7
0x6996996, // 8
0x6997196 // 9
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TIA::TIA(const TIA& c) TIA::TIA(const TIA& c)
: myConsole(c.myConsole), : myConsole(c.myConsole),

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: UserInterface.cxx,v 1.3 2003-09-26 17:35:05 stephena Exp $ // $Id: UserInterface.cxx,v 1.4 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#include "bspf.hxx" #include "bspf.hxx"
@ -23,16 +23,65 @@
#include "MediaSrc.hxx" #include "MediaSrc.hxx"
#include "UserInterface.hxx" #include "UserInterface.hxx"
// Eventually, these may become variables
#define FGCOLOR 10
#define BGCOLOR 0
#define FONTWIDTH 8
#define FONTHEIGHT 8
#define YOFFSET 12 // FONTHEIGHT + 2 pixels on top and bottom
#define XBOXOFFSET 8 // 4 pixels to the left and right of text
#define YBOXOFFSET 8 // 4 pixels to the top and bottom of text
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UserInterface::UserInterface(Console* console, MediaSource* mediasrc) UserInterface::UserInterface(Console* console, MediaSource* mediasrc)
: myConsole(console), : myConsole(console),
myMediaSource(mediasrc), myMediaSource(mediasrc),
myCurrentWidget(NONE), myCurrentWidget(W_NONE),
myRemapEventSelectedFlag(false), myRemapEventSelectedFlag(false),
mySelectedEvent(Event::NoType), mySelectedEvent(Event::NoType),
myMessageTime(0), myMessageTime(0),
myMessageText("") myMessageText(""),
myInfoMenuWidth(0)
{ {
myXStart = atoi(myConsole->properties().get("Display.XStart").c_str());
myWidth = atoi(myConsole->properties().get("Display.Width").c_str());
myYStart = atoi(myConsole->properties().get("Display.YStart").c_str());
myHeight = atoi(myConsole->properties().get("Display.Height").c_str());
// Make sure the starting x and width values are reasonable
if((myXStart + myWidth) > 160)
{
// Values are illegal so reset to default values
myXStart = 0;
myWidth = 160;
}
// Fill the properties info array with game information
string info;
info = "NAME: " + myConsole->properties().get("Cartridge.Name");
ourPropertiesInfo[0] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
info = "MANUFACTURER: " + myConsole->properties().get("Cartridge.Manufacturer");
ourPropertiesInfo[1] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
info = "RARITY: " + myConsole->properties().get("Cartridge.Rarity");
ourPropertiesInfo[2] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
info = "MD5SUM: " + myConsole->properties().get("Cartridge.MD5");
ourPropertiesInfo[3] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
info = "MODEL NO: " + myConsole->properties().get("Cartridge.ModelNo");
ourPropertiesInfo[4] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
info = "TYPE: " + myConsole->properties().get("Cartridge.Type");
ourPropertiesInfo[5] = info;
if(info.length() > myInfoMenuWidth) myInfoMenuWidth = info.length();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -43,54 +92,64 @@ UserInterface::~UserInterface(void)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::showMainMenu(bool show) void UserInterface::showMainMenu(bool show)
{ {
myCurrentWidget = show ? MAIN_MENU : NONE; myCurrentWidget = show ? MAIN_MENU : W_NONE;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::sendKeyEvent(StellaEvent::KeyCode key, Int32 state) void UserInterface::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
{ {
if(myCurrentWidget == NONE || state != 1) if(myCurrentWidget == W_NONE || state != 1)
return; return;
else if(myCurrentWidget == MAIN_MENU)
{
if(key == StellaEvent::KCODE_RETURN)
myCurrentWidget = currentSelectedWidget();
else if(key == StellaEvent::KCODE_UP)
moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
moveCursorDown();
}
else if(myCurrentWidget == REMAP_MENU)
{
if(myRemapEventSelectedFlag)
{
if(key == StellaEvent::KCODE_ESCAPE)
// associate nothing with the selected event
cerr << "delete binding for " << mySelectedEvent << endl;
else
// associate this stellaevent with the selected event
cerr << "add binding " << key << " for " << mySelectedEvent << endl;
myRemapEventSelectedFlag = false; // Check which type of widget is pending
} switch(myCurrentWidget)
else if(key == StellaEvent::KCODE_RETURN)
{
cerr << "event selected for remapping\n";
mySelectedEvent = currentSelectedEvent();
myRemapEventSelectedFlag = true;
}
else if(key == StellaEvent::KCODE_UP)
moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
moveCursorDown();
else if(key == StellaEvent::KCODE_ESCAPE)
myCurrentWidget = MAIN_MENU;
}
else if(myCurrentWidget == INFO_MENU)
{ {
cerr << "key received while in info menu\n"; case MAIN_MENU:
if(key == StellaEvent::KCODE_ESCAPE) if(key == StellaEvent::KCODE_RETURN)
myCurrentWidget = MAIN_MENU; myCurrentWidget = currentSelectedWidget();
else if(key == StellaEvent::KCODE_UP)
moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
moveCursorDown();
break; // MAIN_MENU
case REMAP_MENU:
if(myRemapEventSelectedFlag)
{
if(key == StellaEvent::KCODE_ESCAPE)
// associate nothing with the selected event
cerr << "delete binding for " << mySelectedEvent << endl;
else
// associate this stellaevent with the selected event
cerr << "add binding " << key << " for " << mySelectedEvent << endl;
myRemapEventSelectedFlag = false;
}
else if(key == StellaEvent::KCODE_RETURN)
{
cerr << "event selected for remapping\n";
mySelectedEvent = currentSelectedEvent();
myRemapEventSelectedFlag = true;
}
else if(key == StellaEvent::KCODE_UP)
moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
moveCursorDown();
else if(key == StellaEvent::KCODE_ESCAPE)
myCurrentWidget = MAIN_MENU;
break; // REMAP_MENU
case INFO_MENU:
cerr << "key received while in info menu\n";
if(key == StellaEvent::KCODE_ESCAPE)
myCurrentWidget = MAIN_MENU;
break; // INFO_MENU
default:
break;
} }
} }
@ -103,44 +162,54 @@ void UserInterface::sendJoyEvent(StellaEvent::JoyStick stick,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::update() void UserInterface::update()
{ {
uInt8* frontbuffer = myMediaSource->currentFrameBuffer(); uInt32 width, height;
if(myCurrentWidget == NONE) switch(myCurrentWidget)
{
return; // this shouldn't happen
}
else if(myCurrentWidget == MAIN_MENU)
{
; // draw main menu
}
else if(myCurrentWidget == REMAP_MENU)
{
; // draw remap menu
}
else if(myCurrentWidget == INFO_MENU)
{ {
case W_NONE:
return; // this shouldn't happen
cerr << "W_NONE\n";
break; // NONE
// FIXME - this will disappear soon ... case MAIN_MENU:
// First, draw the surrounding box // draw main menu
for(uInt32 x = 0; x < 100; ++x) cerr << "MAIN_MENU\n";
{ break; // MAIN_MENU
for(uInt32 y = 0; y < 100; ++y)
{
uInt32 position = ((20 + y) * myMediaSource->width()) + x + 20;
if((x == 0) || (x == 200 - 1) || (y == 0) || (y == 200 - 1)) case REMAP_MENU:
frontbuffer[position] = 10; // draw remap menu
else cerr << "REMAP_MENU\n";
frontbuffer[position] = 0; break; // REMAP_MENU
}
} case INFO_MENU:
// Calculate the bounds for the box
width = myInfoMenuWidth * FONTWIDTH + XBOXOFFSET;
height = 6 * YOFFSET + YBOXOFFSET;
drawBoundedBox(width, height);
drawText("HELLO", width, height);
break; // INFO_MENU
case MESSAGE:
if(myMessageTime > 0)
{
drawText(myMessageText, 0, 0); // FIXME - change to draw bounding box and text at correct coords
myMessageTime--;
cerr << "MESSAGE = " << myMessageText << ": " << myMessageTime << endl;
}
break; // MESSAGE
default:
cerr << "NOT DEFINED\n";
break;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UserInterface::Widget UserInterface::currentSelectedWidget() UserInterface::Widget UserInterface::currentSelectedWidget()
{ {
return REMAP_MENU; // FIXME return INFO_MENU; // FIXME
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -161,19 +230,48 @@ void UserInterface::moveCursorDown()
cerr << "cursor down\n"; cerr << "cursor down\n";
} }
/*
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::drawMessageText(string& message) void UserInterface::showMessage(const string& message)
{
myCurrentWidget = MESSAGE;
myMessageText = message;
myMessageTime = 120; // FIXME - changes to 2 * framerate
// Make message uppercase, since there are no lowercase fonts defined
uInt32 length = myMessageText.length();
for(uInt32 i = 0; i < length; ++i)
myMessageText[i] = toupper(myMessageText[i]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::drawBoundedBox(uInt32 width, uInt32 height)
{
// Center the box horizontally
uInt32 xBoxOffSet = (myWidth >> 1) - (width >> 1);
uInt32 yBoxOffSet = (myHeight >> 1) - (height >> 1);
uInt8* buffer = myMediaSource->currentFrameBuffer();
for(uInt32 x = 0; x < width; ++x)
{
for(uInt32 y = 0; y < height; ++y)
{
uInt32 position = ((yBoxOffSet + y) * myWidth) + x + xBoxOffSet;
if((x == 0) || (x == width - 1) || (y == 0) || (y == height - 1))
buffer[position] = FGCOLOR;
else
buffer[position] = BGCOLOR;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::drawText(const string& message, uInt32 xorig, uInt32 yorig)
{ {
// First, get access to the framebuffer // First, get access to the framebuffer
uInt8* buffer = myMediaSource->currentFrameBuffer(); uInt8* buffer = myMediaSource->currentFrameBuffer();
/*
// Make message uppercase, since there are no lowercase fonts defined
uInt8 length = message.length();
for(uInt32 i = 0; i < length; ++i)
message[i] = toupper(message[i]);
// Set up the correct coordinates to draw the surrounding box // Set up the correct coordinates to draw the surrounding box
uInt32 xBoxOffSet = 2 + myXStart; uInt32 xBoxOffSet = 2 + myXStart;
uInt32 yBoxOffSet = myHeight - 18; uInt32 yBoxOffSet = myHeight - 18;
@ -198,7 +296,7 @@ void UserInterface::drawMessageText(string& message)
backColor = 0; backColor = 0;
// Clip the length if its wider than the screen // Clip the length if its wider than the screen
// uInt8 length = message.length(); uInt8 length = message.length();
if(((length * 5) + xTextOffSet) >= myWidth) if(((length * 5) + xTextOffSet) >= myWidth)
length = (myWidth - xTextOffSet) / 5; length = (myWidth - xTextOffSet) / 5;
@ -220,8 +318,18 @@ void UserInterface::drawMessageText(string& message)
else else
buffer[position] = backColor; buffer[position] = backColor;
} }
} }*/
// Used to indicate the current x/y position of a pixel
uInt32 xPos, yPos;
// The actual font data for a letter
uInt32 data;
uInt32 xTextOffSet = xorig + 4;
uInt32 yTextOffSet = yorig + 4;
uInt8 length = message.length();
// Then, draw the text // Then, draw the text
for(uInt8 x = 0; x < length; ++x) for(uInt8 x = 0; x < length; ++x)
{ {
@ -233,7 +341,7 @@ void UserInterface::drawMessageText(string& message)
data = ourFontData[(int)letter - 48 + 26]; data = ourFontData[(int)letter - 48 + 26];
else // unknown character or space else // unknown character or space
{ {
xTextOffSet += 3; xTextOffSet += 4;
continue; continue;
} }
@ -250,7 +358,7 @@ void UserInterface::drawMessageText(string& message)
if((data >> y) & 1) if((data >> y) & 1)
{ {
uInt32 position = (yPos + yTextOffSet) * myWidth + (4 - xPos) + xTextOffSet; uInt32 position = (yPos + yTextOffSet) * myWidth + (4 - xPos) + xTextOffSet;
buffer[position] = fontColor; buffer[position] = FGCOLOR;
} }
} }
@ -258,7 +366,6 @@ void UserInterface::drawMessageText(string& message)
xTextOffSet += 5; xTextOffSet += 5;
} }
} }
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 UserInterface::ourFontData[36] = { const uInt32 UserInterface::ourFontData[36] = {
@ -316,16 +423,4 @@ const uInt32 UserInterface::ourFontData[36] = {
frontbuffer[position] = backbuffer[position] = 0; frontbuffer[position] = backbuffer[position] = 0;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::showMessage(string& message, Int32 duration)
{
myMessageText = message;
myMessageTime = duration;
// Make message uppercase, since there are no lowercase fonts defined
uInt32 length = myMessageText.length();
for(uInt32 i = 0; i < length; ++i)
myMessageText[i] = toupper(myMessageText[i]);
}
*/ */

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: UserInterface.hxx,v 1.3 2003-09-26 17:35:05 stephena Exp $ // $Id: UserInterface.hxx,v 1.4 2003-09-26 22:39:36 stephena Exp $
//============================================================================ //============================================================================
#ifndef USERINTERFACE_HXX #ifndef USERINTERFACE_HXX
@ -31,7 +31,7 @@ class MediaSource;
can be changed. can be changed.
@author Stephen Anthony @author Stephen Anthony
@version $Id: UserInterface.hxx,v 1.3 2003-09-26 17:35:05 stephena Exp $ @version $Id: UserInterface.hxx,v 1.4 2003-09-26 22:39:36 stephena Exp $
*/ */
class UserInterface class UserInterface
{ {
@ -71,14 +71,13 @@ class UserInterface
void sendJoymap(Event::Type table[StellaEvent::LastJSTICK][StellaEvent::LastJCODE]); void sendJoymap(Event::Type table[StellaEvent::LastJSTICK][StellaEvent::LastJCODE]);
public: public:
bool drawPending() { return myCurrentWidget != NONE; }
void showMainMenu(bool show); void showMainMenu(bool show);
void showMessage(string& message); void showMessage(const string& message);
void update(); void update();
private: private:
// Enumeration representing the different types of user interface widgets // Enumeration representing the different types of user interface widgets
enum Widget { NONE, MAIN_MENU, REMAP_MENU, INFO_MENU, MESSAGE }; enum Widget { W_NONE, MAIN_MENU, REMAP_MENU, INFO_MENU, MESSAGE };
Widget currentSelectedWidget(); Widget currentSelectedWidget();
Event::Type currentSelectedEvent(); Event::Type currentSelectedEvent();
@ -89,6 +88,9 @@ class UserInterface
// Draw a bounded box centered horizontally // Draw a bounded box centered horizontally
void drawBoundedBox(uInt32 width, uInt32 height); void drawBoundedBox(uInt32 width, uInt32 height);
// Draw message text at specified coordinates
void drawText(const string& message, uInt32 x, uInt32 y);
private: private:
// The Console for the system // The Console for the system
Console* myConsole; Console* myConsole;
@ -116,6 +118,12 @@ class UserInterface
// Message text // Message text
string myMessageText; string myMessageText;
// Holds information about the current selected ROM image
string ourPropertiesInfo[6];
// The width of the information menu, determined by the longest string
uInt32 myInfoMenuWidth;
}; };
#endif #endif