It's alive! Somewhat at least. Entering menu mode with the TAB key

actually draws the Options Dialog box.  No events are handled yet, but
at least it's a start.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@380 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-03-12 01:47:15 +00:00
parent bed46fe840
commit b0ec277a94
9 changed files with 227 additions and 80 deletions

View File

@ -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: makefile,v 1.63 2005-03-10 22:59:39 stephena Exp $
## $Id: makefile,v 1.64 2005-03-12 01:47:14 stephena Exp $
##============================================================================
##============================================================================
@ -81,7 +81,7 @@ else
SMP = -j$(NUMBER_CPU)
endif
FLAGS = $(OPTIMIZATIONS) -Wall -Wunused $(INCLUDES) $(SYS_INCLUDES)
FLAGS = $(OPTIMIZATIONS) -Wall -Wno-multichar -Wunused $(INCLUDES) $(SYS_INCLUDES)
ifdef JOYSTICK_SUPPORT
OPTIONS += -DJOYSTICK_SUPPORT

View File

@ -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: FrameBufferSoft.cxx,v 1.9 2005-02-22 18:40:55 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.10 2005-03-12 01:47:14 stephena Exp $
//============================================================================
#include <SDL.h>
@ -410,6 +410,79 @@ void FrameBufferSoft::scanline(uInt32 row, uInt8* data)
SDL_UnlockSurface(myScreen);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
{
SDL_Rect tmp;
// Horizontal line
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = (x2 - x + 1) * theZoomLevel;
tmp.h = theZoomLevel;
SDL_FillRect(myScreen, &tmp, myPalette[myFGColor]); // top
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
{
SDL_Rect tmp;
// Vertical line
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = theZoomLevel;
tmp.h = (y2 - y + 1) * theZoomLevel;
SDL_FillRect(myScreen, &tmp, myPalette[myFGColor]); // left
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::blendRect(int x, int y, int w, int h,
OverlayColor color, int level)
{
// FIXME - make this do alpha-blending
SDL_Rect tmp;
// Fill the rectangle
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = w * theZoomLevel;
tmp.h = h * theZoomLevel;
myRectList->add(&tmp);
SDL_FillRect(myScreen, &tmp, myPalette[myBGColor]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color)
{
SDL_Rect tmp;
// Fill the rectangle
tmp.x = x * theZoomLevel;
tmp.y = y * theZoomLevel;
tmp.w = w * theZoomLevel;
tmp.h = h * theZoomLevel;
myRectList->add(&tmp);
SDL_FillRect(myScreen, &tmp, myPalette[myBGColor]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color)
{
cerr << "FrameBufferSoft::frameRect()\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::drawString(const string& str, Int32 x, Int32 y, Int32 w,
OverlayColor color, TextAlignment align,
Int32 deltax, bool useEllipsis)
{
// FIXME - implement this correctly
drawText(x, y, str);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RectList::RectList(Uint32 size)
{

View File

@ -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: FrameBufferSoft.hxx,v 1.7 2005-02-22 18:40:55 stephena Exp $
// $Id: FrameBufferSoft.hxx,v 1.8 2005-03-12 01:47:15 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_SOFT_HXX
@ -34,7 +34,7 @@ class RectList;
This class implements an SDL software framebuffer.
@author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.7 2005-02-22 18:40:55 stephena Exp $
@version $Id: FrameBufferSoft.hxx,v 1.8 2005-03-12 01:47:15 stephena Exp $
*/
class FrameBufferSoft : public FrameBuffer
{
@ -64,16 +64,6 @@ class FrameBufferSoft : public FrameBuffer
*/
virtual bool createScreen();
/**
This routine is called to map a given r,g,b triple to the screen palette.
@param r The red component of the color.
@param g The green component of the color.
@param b The blue component of the color.
*/
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
{ return SDL_MapRGB(myScreen->format, r, g, b); }
/**
Switches between the filtering options in software mode.
Currently, none exist.
@ -86,6 +76,107 @@ class FrameBufferSoft : public FrameBuffer
*/
virtual void drawMediaSource();
/**
This routine is called before any drawing is done (per-frame).
*/
virtual void preFrameUpdate();
/**
This routine is called after any drawing is done (per-frame).
*/
virtual void postFrameUpdate();
/**
This routine is called to get the specified scanline data.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
virtual void scanline(uInt32 row, uInt8* data);
/**
This routine is called to map a given r,g,b triple to the screen palette.
@param r The red component of the color.
@param g The green component of the color.
@param b The blue component of the color.
*/
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b)
{ return SDL_MapRGB(myScreen->format, r, g, b); }
/**
This routine is called to draw a horizontal line.
@param x The first x coordinate
@param y The y coordinate
@param x2 The second x coordinate
@param color The color of the line
*/
virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color);
/**
This routine is called to draw a vertical line.
@param x The x coordinate
@param y The first y coordinate
@param y2 The second y coordinate
@param color The color of the line
*/
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color);
/**
This routine is called to draw a blended rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the box
@param h The height of the box
@param color FIXME
@param level FIXME
*/
virtual void blendRect(int x, int y, int w, int h,
OverlayColor color, int level = 3);
/**
This routine is called to draw a filled rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the area
*/
virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color);
/**
This routine is called to draw a framed rectangle.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the surrounding frame
*/
virtual void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color);
/**
This routine is called to draw the specified string.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the surrounding frame
*/
virtual void drawString(const string& str, Int32 x, Int32 y, Int32 w,
OverlayColor color, TextAlignment align = kTextAlignLeft,
Int32 deltax = 0, bool useEllipsis = true);
/**
This routine should be called to draw a rectangular box with sides
at the specified coordinates.
@ -115,24 +206,6 @@ class FrameBufferSoft : public FrameBuffer
*/
virtual void drawChar(uInt32 x, uInt32 y, uInt32 c);
/**
This routine is called before any drawing is done (per-frame).
*/
virtual void preFrameUpdate();
/**
This routine is called after any drawing is done (per-frame).
*/
virtual void postFrameUpdate();
/**
This routine is called to get the specified scanline data.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
virtual void scanline(uInt32 row, uInt8* data);
private:
// Used in the dirty update of the SDL surface
RectList* myRectList;

View File

@ -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.36 2005-03-10 22:59:40 stephena Exp $
// $Id: EventHandler.cxx,v 1.37 2005-03-12 01:47:15 stephena Exp $
//============================================================================
#include <algorithm>
@ -112,6 +112,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
if(myState == S_EMULATE)
{
myState = S_MENU;
myOSystem->menu().reset();
myOSystem->frameBuffer().refresh();
myOSystem->sound().mute(true);
return;
@ -119,6 +120,7 @@ void EventHandler::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
else if(myState == S_MENU)
{
myState = S_EMULATE;
myOSystem->menu().reset();
myOSystem->frameBuffer().refresh();
myOSystem->sound().mute(false);
return;

View File

@ -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.18 2005-03-11 23:36:30 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.19 2005-03-12 01:47:15 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -47,7 +47,7 @@ enum TextAlignment {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.18 2005-03-11 23:36:30 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.19 2005-03-12 01:47:15 stephena Exp $
*/
class FrameBuffer
{
@ -324,7 +324,7 @@ FIXME
@param y2 The second y coordinate
@param color The color of the line
*/
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color);
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color) = 0;
/**
This routine should be called to draw a blended rectangle.

View File

@ -13,14 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Dialog.cxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
// $Id: Dialog.cxx,v 1.4 2005-03-12 01:47:15 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include <SDL.h>
#include <ctype.h>
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
@ -41,13 +40,16 @@ Dialog::Dialog(OSystem* instance, uInt16 x, uInt16 y, uInt16 w, uInt16 h)
: GuiObject(instance, x, y, w, h),
_mouseWidget(0),
_focusedWidget(0),
_visible(false)
_visible(true)
{
cerr << "Dialog::Dialog()\n";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog::~Dialog()
{
cerr << "Dialog::~Dialog()\n";
delete _firstWidget;
_firstWidget = 0;
}
@ -68,11 +70,9 @@ int Dialog::runModal() // FIXME
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::open()
{
Widget* w = _firstWidget;
_result = 0;
_visible = true;
instance()->menu().addDialog(this);
Widget* w = _firstWidget;
// Search for the first objects that wantsFocus() (if any) and give it the focus
while(w && !w->wantsFocus())
@ -88,9 +88,6 @@ void Dialog::open()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::close()
{
_visible = false;
instance()->menu().removeDialog();
if (_mouseWidget) {
_mouseWidget->handleMouseLeft(0);
_mouseWidget = 0;
@ -207,6 +204,8 @@ void Dialog::handleMouseWheel(int x, int y, int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers)
{
cerr << "Dialog::handleKeyDown()\n";
if(_focusedWidget)
if (_focusedWidget->handleKeyDown(ascii, keycode, modifiers))
return;

View File

@ -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: Dialog.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
// $Id: Dialog.hxx,v 1.4 2005-03-12 01:47:15 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -39,7 +39,7 @@ enum {
This is the base class for all dialog boxes.
@author Stephen Anthony
@version $Id: Dialog.hxx,v 1.3 2005-03-11 23:36:30 stephena Exp $
@version $Id: Dialog.hxx,v 1.4 2005-03-12 01:47:15 stephena Exp $
*/
class Dialog : public GuiObject
{
@ -52,17 +52,16 @@ class Dialog : public GuiObject
bool isVisible() const { return _visible; }
void releaseFocus();
virtual void open();
virtual void close();
virtual void drawDialog();
virtual void handleKeyDown(uInt16 ascii, Int32 keycode, Int32 modifiers);
virtual void handleKeyUp(uInt16 ascii, Int32 keycode, Int32 modifiers);
protected:
virtual void open();
virtual void close();
virtual void draw();
void releaseFocus();
virtual void handleTickle(); // Called periodically (in every guiloop() )
virtual void handleMouseDown(int x, int y, int button, int clickCount);

View File

@ -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: Menu.cxx,v 1.2 2005-03-10 22:59:40 stephena Exp $
// $Id: Menu.cxx,v 1.3 2005-03-12 01:47:15 stephena Exp $
//============================================================================
#include <SDL.h>
@ -30,14 +30,10 @@ Menu::Menu(OSystem* osystem)
: myOSystem(osystem),
myOptionsDialog(NULL)
{
#ifdef DEBUG
cerr << "Menu::Menu()\n";
#endif
myOSystem->attach(this);
// Create a stack to hold the various dialog boxes
// Create the top-level menu
myOptionsDialog = new OptionsDialog(myOSystem);
}
@ -45,9 +41,7 @@ Menu::Menu(OSystem* osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Menu::~Menu()
{
#ifdef DEBUG
cerr << "Menu::~Menu()\n";
#endif
delete myOptionsDialog;
}
@ -55,13 +49,12 @@ Menu::~Menu()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Menu::draw()
{
#ifdef DEBUG
cerr << "Menu::draw()\n";
#endif
// Draw all the dialogs on the stack
for(Int32 i = 0; i < myDialogStack.size(); i++)
{
myDialogStack[i]->open();
myDialogStack[i]->drawDialog();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -82,7 +75,10 @@ void Menu::reset()
{
// Pop all items from the stack, and then add the base menu
for(Int32 i = 0; i < myDialogStack.size(); i++)
myDialogStack.pop();
{
Dialog* d = myDialogStack.pop();
d->close();
}
myDialogStack.push(myOptionsDialog);
}
@ -90,11 +86,19 @@ void Menu::reset()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Menu::handleKeyEvent(SDLKey key, SDLMod mod, uInt8 state)
{
if(myDialogStack.empty())
return;
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
// Convert SDL values to ascii so the ScummVM subsystem can work with it
// FIXME - convert SDLKey and SDLMod to int values
uInt16 ascii = 0;
Int32 keycode = 0, modifiers = 0;
if(state == 1)
activeDialog->handleKeyDown(key, mod);
activeDialog->handleKeyDown(ascii, keycode, modifiers);
else
activeDialog->handleKeyUp(key, mod);
activeDialog->handleKeyUp(ascii, keycode, modifiers);
}

View File

@ -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: OptionsDialog.cxx,v 1.2 2005-03-11 23:36:30 stephena Exp $
// $Id: OptionsDialog.cxx,v 1.3 2005-03-12 01:47:15 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -51,10 +51,10 @@ enum {
};
enum {
kRowHeight = 18,
kBigButtonWidth = 90,
kRowHeight = 20,
kBigButtonWidth = 140,
kMainMenuWidth = (kBigButtonWidth + 2 * 8),
kMainMenuHeight = 7 * kRowHeight + 3 * 5 + 7 + 5
kMainMenuHeight = 6 * kRowHeight + 10,
};
#define addBigButton(label, cmd, hotkey) \
@ -63,20 +63,17 @@ enum {
OptionsDialog::OptionsDialog(OSystem* osystem)
: Dialog(osystem, (320 - kMainMenuWidth) / 2, (200 - kMainMenuHeight)/2, kMainMenuWidth, kMainMenuHeight)
{
cerr << "OptionsDialog::OptionsDialog()\n";
int y = 7;
const int x = (_w - kBigButtonWidth) / 2;
addBigButton("Video", kVidCmd, 'V');
y += 5;
addBigButton("Audio", kAudCmd, 'A');
addBigButton("Video Settings", kVidCmd, 'V');
addBigButton("Audio Settings", kAudCmd, 'A');
addBigButton("Event Remapping", kEMapCmd, 'E');
y += 5;
addBigButton("Misc", kMiscCmd, 'M');
addBigButton("Game Info", kInfoCmd, 'I');
addBigButton("Miscellaneous", kMiscCmd, 'M');
addBigButton("Game Information", kInfoCmd, 'I');
addBigButton("Help", kHelpCmd, 'H');
y += 5;
/*
// Now create all the dialogs attached to each menu button