mirror of https://github.com/stella-emu/stella.git
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:
parent
dbe02b2af4
commit
b9f5cbb1fe
|
@ -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.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>
|
||||
|
@ -259,14 +259,12 @@ void Console::toggleFormat()
|
|||
|
||||
if(format == "NTSC")
|
||||
{
|
||||
message = "PAL Mode";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("PAL Mode");
|
||||
myProperties.set("Display.Format", "PAL");
|
||||
}
|
||||
else if(format == "PAL")
|
||||
{
|
||||
message = "NTSC Mode";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("NTSC Mode");
|
||||
myProperties.set("Display.Format", "NTSC");
|
||||
}
|
||||
}
|
||||
|
@ -284,14 +282,12 @@ void Console::changeXStart(const uInt32 direction)
|
|||
xstart += 4;
|
||||
if(xstart > 80)
|
||||
{
|
||||
message = "XStart at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("XStart at maximum");
|
||||
return;
|
||||
}
|
||||
else if((width + xstart) > 160)
|
||||
{
|
||||
message = "XStart no effect";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("XStart no effect");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -300,8 +296,7 @@ void Console::changeXStart(const uInt32 direction)
|
|||
xstart -= 4;
|
||||
if(xstart < 0)
|
||||
{
|
||||
message = "XStart at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("XStart at minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +307,7 @@ void Console::changeXStart(const uInt32 direction)
|
|||
|
||||
message = "XStart ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage(message);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -327,8 +322,7 @@ void Console::changeYStart(const uInt32 direction)
|
|||
ystart++;
|
||||
if(ystart > 64)
|
||||
{
|
||||
message = "YStart at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("YStart at maximum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -337,8 +331,7 @@ void Console::changeYStart(const uInt32 direction)
|
|||
ystart--;
|
||||
if(ystart < 0)
|
||||
{
|
||||
message = "YStart at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("YStart at minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +342,7 @@ void Console::changeYStart(const uInt32 direction)
|
|||
|
||||
message = "YStart ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage(message);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -365,14 +358,12 @@ void Console::changeWidth(const uInt32 direction)
|
|||
width += 4;
|
||||
if((width > 160) || ((width % 4) != 0))
|
||||
{
|
||||
message = "Width at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Width at maximum");
|
||||
return;
|
||||
}
|
||||
else if((width + xstart) > 160)
|
||||
{
|
||||
message = "Width no effect";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Width no effect");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -381,8 +372,7 @@ void Console::changeWidth(const uInt32 direction)
|
|||
width -= 4;
|
||||
if(width < 80)
|
||||
{
|
||||
message = "Width at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Width at minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +383,7 @@ void Console::changeWidth(const uInt32 direction)
|
|||
|
||||
message = "Width ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage(message);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -408,8 +398,7 @@ void Console::changeHeight(const uInt32 direction)
|
|||
height++;
|
||||
if(height > 256)
|
||||
{
|
||||
message = "Height at maximum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Height at maximum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -418,8 +407,7 @@ void Console::changeHeight(const uInt32 direction)
|
|||
height--;
|
||||
if(height < 100)
|
||||
{
|
||||
message = "Height at minimum";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Height at minimum");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -430,27 +418,19 @@ void Console::changeHeight(const uInt32 direction)
|
|||
|
||||
message = "Height ";
|
||||
message += strval.str();
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage(message);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::saveProperties(string filename, bool merge)
|
||||
{
|
||||
string message;
|
||||
|
||||
// Merge the current properties into the PropertiesSet file
|
||||
if(merge)
|
||||
{
|
||||
if(myPropSet.merge(myProperties, filename))
|
||||
{
|
||||
message = "Properties merged";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
myUserInterface->showMessage("Properties merged");
|
||||
else
|
||||
{
|
||||
message = "Properties not merged";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
}
|
||||
myUserInterface->showMessage("Properties not merged");
|
||||
}
|
||||
else // Save to the specified file directly
|
||||
{
|
||||
|
@ -460,13 +440,11 @@ void Console::saveProperties(string filename, bool merge)
|
|||
{
|
||||
myProperties.save(out);
|
||||
out.close();
|
||||
message = "Properties saved";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Properties saved");
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "Properties not saved";
|
||||
myMediaSource->showMessage(message, 120);
|
||||
myUserInterface->showMessage("Properties not saved");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.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>
|
||||
|
@ -157,7 +157,7 @@ void EventHandler::sendEvent(Event::Type event, Int32 state)
|
|||
}
|
||||
|
||||
if(ourMessageTable[event] != "")
|
||||
myConsole->mediaSource().showMessage(ourMessageTable[event], 120);
|
||||
myConsole->gui().showMessage(ourMessageTable[event]);
|
||||
}
|
||||
|
||||
// Otherwise, pass it to the emulation core
|
||||
|
@ -361,8 +361,7 @@ void EventHandler::saveState()
|
|||
else if(result == 3)
|
||||
buf << "Invalid state " << myCurrentState << " file";
|
||||
|
||||
string message = buf.str();
|
||||
myConsole->mediaSource().showMessage(message, 120);
|
||||
myConsole->gui().showMessage(buf.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -376,8 +375,8 @@ void EventHandler::changeState()
|
|||
// Print appropriate message
|
||||
ostringstream buf;
|
||||
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)
|
||||
buf << "Invalid state " << myCurrentState << " file";
|
||||
|
||||
string message = buf.str();
|
||||
myConsole->mediaSource().showMessage(message, 120);
|
||||
myConsole->gui().showMessage(buf.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::takeSnapshot()
|
||||
{
|
||||
#ifdef SNAPSHOT_SUPPORT
|
||||
string message, filename;
|
||||
|
||||
// Now save the snapshot file
|
||||
filename = myConsole->settings().snapshotFilename();
|
||||
string filename = myConsole->settings().snapshotFilename();
|
||||
myConsole->snapshot().savePNG(filename, myConsole->mediaSource(),
|
||||
myConsole->settings().getInt("zoom"));
|
||||
|
||||
message = "Snapshot saved";
|
||||
myConsole->mediaSource().showMessage(message, 120);
|
||||
myConsole->gui().showMessage("Snapshot saved");
|
||||
#else
|
||||
string message = "Snapshots unsupported";
|
||||
myConsole->mediaSource().showMessage(message, 120);
|
||||
myConsole->gui().showMessage("Snapshots unsupported");
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -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: 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
|
||||
|
@ -29,7 +29,7 @@ class MediaSource;
|
|||
This class provides an interface for accessing graphics and audio data.
|
||||
|
||||
@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
|
||||
{
|
||||
|
@ -63,12 +63,6 @@ class MediaSource
|
|||
*/
|
||||
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
|
||||
|
||||
|
|
|
@ -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: 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>
|
||||
|
@ -37,8 +37,6 @@
|
|||
TIA::TIA(const Console& console, uInt32 sampleRate)
|
||||
: myConsole(console),
|
||||
myPauseState(false),
|
||||
myMessageTime(0),
|
||||
myMessageText(""),
|
||||
myLastSoundUpdateCycle(0),
|
||||
myColorLossEnabled(false),
|
||||
myCOLUBK(myColor[0]),
|
||||
|
@ -575,7 +573,6 @@ void TIA::update()
|
|||
myScanlineCountForLastFrame = totalClocks / 228;
|
||||
|
||||
// Draw any pending user interface elements to the framebuffer
|
||||
if(myConsole.gui().drawPending())
|
||||
myConsole.gui().update();
|
||||
}
|
||||
|
||||
|
@ -3112,46 +3109,6 @@ const uInt32 TIA::ourPALPalette[256] = {
|
|||
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)
|
||||
: myConsole(c.myConsole),
|
||||
|
|
|
@ -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: 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"
|
||||
|
@ -23,16 +23,65 @@
|
|||
#include "MediaSrc.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)
|
||||
: myConsole(console),
|
||||
myMediaSource(mediasrc),
|
||||
myCurrentWidget(NONE),
|
||||
myCurrentWidget(W_NONE),
|
||||
myRemapEventSelectedFlag(false),
|
||||
mySelectedEvent(Event::NoType),
|
||||
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,39 +92,43 @@ UserInterface::~UserInterface(void)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void UserInterface::showMainMenu(bool show)
|
||||
{
|
||||
myCurrentWidget = show ? MAIN_MENU : NONE;
|
||||
myCurrentWidget = show ? MAIN_MENU : W_NONE;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void UserInterface::sendKeyEvent(StellaEvent::KeyCode key, Int32 state)
|
||||
{
|
||||
if(myCurrentWidget == NONE || state != 1)
|
||||
if(myCurrentWidget == W_NONE || state != 1)
|
||||
return;
|
||||
else if(myCurrentWidget == MAIN_MENU)
|
||||
|
||||
// Check which type of widget is pending
|
||||
switch(myCurrentWidget)
|
||||
{
|
||||
case 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)
|
||||
{
|
||||
|
||||
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;
|
||||
cerr << "delete binding for " << mySelectedEvent << endl;
|
||||
else
|
||||
// associate this stellaevent with the selected event
|
||||
cerr << "add binding " << key << " for " << mySelectedEvent << endl;
|
||||
cerr << "add binding " << key << " for " << mySelectedEvent << endl;
|
||||
|
||||
myRemapEventSelectedFlag = false;
|
||||
}
|
||||
else if(key == StellaEvent::KCODE_RETURN)
|
||||
{
|
||||
cerr << "event selected for remapping\n";
|
||||
cerr << "event selected for remapping\n";
|
||||
mySelectedEvent = currentSelectedEvent();
|
||||
myRemapEventSelectedFlag = true;
|
||||
}
|
||||
|
@ -85,12 +138,18 @@ cerr << "event selected for remapping\n";
|
|||
moveCursorDown();
|
||||
else if(key == StellaEvent::KCODE_ESCAPE)
|
||||
myCurrentWidget = MAIN_MENU;
|
||||
}
|
||||
else if(myCurrentWidget == INFO_MENU)
|
||||
{
|
||||
cerr << "key received while in info menu\n";
|
||||
|
||||
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()
|
||||
{
|
||||
uInt8* frontbuffer = myMediaSource->currentFrameBuffer();
|
||||
uInt32 width, height;
|
||||
|
||||
if(myCurrentWidget == NONE)
|
||||
switch(myCurrentWidget)
|
||||
{
|
||||
case W_NONE:
|
||||
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)
|
||||
{
|
||||
cerr << "W_NONE\n";
|
||||
break; // NONE
|
||||
|
||||
// FIXME - this will disappear soon ...
|
||||
// First, draw the surrounding box
|
||||
for(uInt32 x = 0; x < 100; ++x)
|
||||
{
|
||||
for(uInt32 y = 0; y < 100; ++y)
|
||||
{
|
||||
uInt32 position = ((20 + y) * myMediaSource->width()) + x + 20;
|
||||
case MAIN_MENU:
|
||||
// draw main menu
|
||||
cerr << "MAIN_MENU\n";
|
||||
break; // MAIN_MENU
|
||||
|
||||
if((x == 0) || (x == 200 - 1) || (y == 0) || (y == 200 - 1))
|
||||
frontbuffer[position] = 10;
|
||||
else
|
||||
frontbuffer[position] = 0;
|
||||
}
|
||||
case REMAP_MENU:
|
||||
// draw remap menu
|
||||
cerr << "REMAP_MENU\n";
|
||||
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()
|
||||
{
|
||||
return REMAP_MENU; // FIXME
|
||||
return INFO_MENU; // FIXME
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -161,19 +230,48 @@ void UserInterface::moveCursorDown()
|
|||
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
|
||||
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
|
||||
uInt32 xBoxOffSet = 2 + myXStart;
|
||||
uInt32 yBoxOffSet = myHeight - 18;
|
||||
|
@ -198,7 +296,7 @@ void UserInterface::drawMessageText(string& message)
|
|||
backColor = 0;
|
||||
|
||||
// Clip the length if its wider than the screen
|
||||
// uInt8 length = message.length();
|
||||
uInt8 length = message.length();
|
||||
if(((length * 5) + xTextOffSet) >= myWidth)
|
||||
length = (myWidth - xTextOffSet) / 5;
|
||||
|
||||
|
@ -220,8 +318,18 @@ void UserInterface::drawMessageText(string& message)
|
|||
else
|
||||
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
|
||||
for(uInt8 x = 0; x < length; ++x)
|
||||
{
|
||||
|
@ -233,7 +341,7 @@ void UserInterface::drawMessageText(string& message)
|
|||
data = ourFontData[(int)letter - 48 + 26];
|
||||
else // unknown character or space
|
||||
{
|
||||
xTextOffSet += 3;
|
||||
xTextOffSet += 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -250,7 +358,7 @@ void UserInterface::drawMessageText(string& message)
|
|||
if((data >> y) & 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const uInt32 UserInterface::ourFontData[36] = {
|
||||
|
@ -316,16 +423,4 @@ const uInt32 UserInterface::ourFontData[36] = {
|
|||
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]);
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -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: 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
|
||||
|
@ -31,7 +31,7 @@ class MediaSource;
|
|||
can be changed.
|
||||
|
||||
@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
|
||||
{
|
||||
|
@ -71,14 +71,13 @@ class UserInterface
|
|||
void sendJoymap(Event::Type table[StellaEvent::LastJSTICK][StellaEvent::LastJCODE]);
|
||||
|
||||
public:
|
||||
bool drawPending() { return myCurrentWidget != NONE; }
|
||||
void showMainMenu(bool show);
|
||||
void showMessage(string& message);
|
||||
void showMessage(const string& message);
|
||||
void update();
|
||||
|
||||
private:
|
||||
// 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();
|
||||
Event::Type currentSelectedEvent();
|
||||
|
@ -89,6 +88,9 @@ class UserInterface
|
|||
// Draw a bounded box centered horizontally
|
||||
void drawBoundedBox(uInt32 width, uInt32 height);
|
||||
|
||||
// Draw message text at specified coordinates
|
||||
void drawText(const string& message, uInt32 x, uInt32 y);
|
||||
|
||||
private:
|
||||
// The Console for the system
|
||||
Console* myConsole;
|
||||
|
@ -116,6 +118,12 @@ class UserInterface
|
|||
|
||||
// Message text
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue