Started huge rework of the FrameBuffer UI. The basic idea is that

in-game dialogs are now rendered into separate surfaces, and then layered
onto the SDL screen when necessary.  The biggest advantage of this is
now each 'window' is separate, and won't be affected by the scaling or
filtering of other windows.  For example, zooming the TIA image no longer
changes the size of UI text overlaid on the TIA.  Similarly, eventually
graphical filters will be added, and filters applied to the TIA won't
affect the UI.

There's too many changes to list, so for now I'll list what doesn't work:
 * OpenGL mode (don't even try it)
 * Several popup dialogs in the debugger
 * RomInfo stuff is completely broken
 * Scanline count and FrameBuffer 'messages' aren't shown
 * Larger fonts - fonts are no longer scaled; we have to use larger ones,
   and update the UI accordingly
 * Probably a lot of other stuff I forgot to mention

This is a huge undertaking, similar in scale to when the UI was first
added in 2.0 release.  So it might take some time for this to stabilize ...


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1537 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-06-13 13:14:52 +00:00
parent 340ee7d167
commit 84cd5d1d78
61 changed files with 2118 additions and 2411 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: CheatCodeDialog.cxx,v 1.17 2008-02-06 13:45:19 stephena Exp $
// $Id: CheatCodeDialog.cxx,v 1.18 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -105,7 +105,7 @@ void CheatCodeDialog::loadConfig()
StringList l;
BoolArray b;
const CheatList& list = instance()->cheat().list();
const CheatList& list = instance().cheat().list();
for(unsigned int i = 0; i < list.size(); ++i)
{
l.push_back(list[i]->name());
@ -125,7 +125,7 @@ void CheatCodeDialog::loadConfig()
void CheatCodeDialog::saveConfig()
{
// Inspect checkboxes for enable/disable codes
const CheatList& list = instance()->cheat().list();
const CheatList& list = instance().cheat().list();
for(unsigned int i = 0; i < myCheatList->getList().size(); ++i)
{
if(myCheatList->getState(i))
@ -140,7 +140,7 @@ void CheatCodeDialog::addCheat()
{
// We have to add the dialog first, so it can be centered
// The methods after this depend on the dialog having the correct dimensions
parent()->addDialog(myCheatInput);
parent().addDialog(myCheatInput);
myCheatInput->setEditString("", 0);
myCheatInput->setEditString("", 1);
myCheatInput->setTitle("");
@ -155,13 +155,13 @@ void CheatCodeDialog::editCheat()
if(idx < 0)
return;
const CheatList& list = instance()->cheat().list();
const CheatList& list = instance().cheat().list();
const string& name = list[idx]->name();
const string& code = list[idx]->code();
// We have to add the dialog first, so it can be centered
// The methods after this depend on the dialog having the correct dimensions
parent()->addDialog(myCheatInput);
parent().addDialog(myCheatInput);
myCheatInput->setEditString(name, 0);
myCheatInput->setEditString(code, 1);
myCheatInput->setTitle("");
@ -172,7 +172,7 @@ void CheatCodeDialog::editCheat()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheatCodeDialog::removeCheat()
{
instance()->cheat().remove(myCheatList->getSelected());
instance().cheat().remove(myCheatList->getSelected());
loadConfig(); // reload the cheat list
}
@ -181,7 +181,7 @@ void CheatCodeDialog::addOneShotCheat()
{
// We have to add the dialog first, so it can be centered
// The methods after this depend on the dialog having the correct dimensions
parent()->addDialog(myCheatInput);
parent().addDialog(myCheatInput);
myCheatInput->setEditString("One-shot cheat", 0);
myCheatInput->setEditString("", 1);
myCheatInput->setTitle("");
@ -220,10 +220,10 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
{
const string& name = myCheatInput->getResult(0);
const string& code = myCheatInput->getResult(1);
if(instance()->cheat().isValidCode(code))
if(instance().cheat().isValidCode(code))
{
instance()->cheat().add(name, code);
parent()->removeDialog();
instance().cheat().add(name, code);
parent().removeDialog();
loadConfig(); // show changes onscreen
myCancelButton->setEnabled(false); // cannot cancel when a new cheat added
}
@ -238,10 +238,10 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
const string& code = myCheatInput->getResult(1);
bool enable = myCheatList->getSelectedState();
int idx = myCheatList->getSelected();
if(instance()->cheat().isValidCode(code))
if(instance().cheat().isValidCode(code))
{
instance()->cheat().add(name, code, enable, idx);
parent()->removeDialog();
instance().cheat().add(name, code, enable, idx);
parent().removeDialog();
loadConfig(); // show changes onscreen
myCancelButton->setEnabled(false); // cannot cancel when a new cheat added
}
@ -262,10 +262,10 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
{
const string& name = myCheatInput->getResult(0);
const string& code = myCheatInput->getResult(1);
if(instance()->cheat().isValidCode(code))
if(instance().cheat().isValidCode(code))
{
instance()->cheat().addOneShot(name, code);
parent()->removeDialog();
instance().cheat().addOneShot(name, code);
parent().removeDialog();
}
else
myCheatInput->setTitle("Invalid code");

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: FrameBufferGL.cxx,v 1.102 2008-04-28 15:53:05 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.103 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -423,11 +423,6 @@ void FrameBufferGL::drawMediaSource()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::preFrameUpdate()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::postFrameUpdate()
{
@ -458,14 +453,12 @@ void FrameBufferGL::postFrameUpdate()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::scanline(uInt32 row, uInt8* data) const
void FrameBufferGL::enablePhosphor(bool enable, int blend)
{
// Invert the row, since OpenGL rows start at the bottom
// of the framebuffer
row = myImageDim.h + myImageDim.y - row - 1;
myUsePhosphor = enable;
myPhosphorBlend = blend;
p_glPixelStorei(GL_PACK_ALIGNMENT, 1);
p_glReadPixels(myImageDim.x, row, myImageDim.w, 1, GL_RGB, GL_UNSIGNED_BYTE, data);
theRedrawTIAIndicator = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -495,27 +488,83 @@ void FrameBufferGL::toggleFilter()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
FBSurface* FrameBufferGL::createSurface(int w, int h, bool isBase) const
{
uInt16* buffer = (uInt16*) myTexture->pixels + y * myBuffer.pitch + x;
while(x++ <= x2)
*buffer++ = (uInt16) myDefPalette[color];
return 0;
#if 0
SDL_PixelFormat* fmt = myTexture->format;
SDL_Surface* data =
SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 16,
fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask);
return data ? new GUI::Surface(width, height, data) : NULL;
/*
SDL_Surface* surface = isBase ? myScreen :
SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, myFormat->BitsPerPixel,
myFormat->Rmask, myFormat->Gmask, myFormat->Bmask,
myFormat->Amask);
return new FBSurfaceSoft(*this, surface, w, h, isBase);
*/
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
void FrameBufferGL::scanline(uInt32 row, uInt8* data) const
{
// Invert the row, since OpenGL rows start at the bottom
// of the framebuffer
row = myImageDim.h + myImageDim.y - row - 1;
p_glPixelStorei(GL_PACK_ALIGNMENT, 1);
p_glReadPixels(myImageDim.x, row, myImageDim.w, 1, GL_RGB, GL_UNSIGNED_BYTE, data);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FBSurfaceGL implementation follows ...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceGL::FBSurfaceGL(const FrameBufferGL& buffer, SDL_Surface* surface,
uInt32 w, uInt32 h, bool isBase)
: myFB(buffer)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceGL::~FBSurfaceGL()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
{
/*
uInt16* buffer = (uInt16*) myTexture->pixels + y * myBuffer.pitch + x;
while(x++ <= x2)
*buffer++ = (uInt16) myDefPalette[color];
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
{
/*
uInt16* buffer = (uInt16*) myTexture->pixels + y * myBuffer.pitch + x;
while(y++ <= y2)
{
*buffer = (uInt16) myDefPalette[color];
buffer += myBuffer.pitch;
}
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
void FBSurfaceGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
{
/*
// Fill the rectangle
SDL_Rect tmp;
tmp.x = x;
@ -523,12 +572,14 @@ void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
tmp.w = w;
tmp.h = h;
SDL_FillRect(myTexture, &tmp, myDefPalette[color]);
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 tx, uInt32 ty, int color)
void FBSurfaceGL::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 tx, uInt32 ty, int color)
{
/*
const FontDesc& desc = font->desc();
// If this character is not included in the font, use the default char.
@ -556,12 +607,14 @@ void FrameBufferGL::drawChar(const GUI::Font* font, uInt8 chr,
}
buffer += myBuffer.pitch;
}
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
int color, Int32 h)
void FBSurfaceGL::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
int color, Int32 h)
{
/*
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myBuffer.pitch + tx;
for(int y = 0; y < h; ++y)
@ -573,56 +626,88 @@ void FrameBufferGL::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
buffer += myBuffer.pitch;
}
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::drawSurface(const GUI::Surface* surface, Int32 x, Int32 y)
void FBSurfaceGL::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{
SDL_Rect dstrect;
dstrect.x = x;
dstrect.y = y;
SDL_Rect srcrect;
srcrect.x = 0;
srcrect.y = 0;
srcrect.w = surface->myClipWidth;
srcrect.h = surface->myClipHeight;
SDL_BlitSurface(surface->myData, &srcrect, myTexture, &dstrect);
// myDirtyFlag = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const
void FBSurfaceGL::centerPos()
{
SDL_Surface* s = surface->myData;
uInt16* pixels = (uInt16*) s->pixels;
pixels += (row * s->pitch/2);
#if 0
// Make sure pitch is valid
recalc();
for(int c = 0; c < rowbytes; c += 3)
*pixels++ = SDL_MapRGB(s->format, data[c], data[c+1], data[c+2]);
// X/Y Orig are the coordinates to use when blitting an entire (non-base)
// surface to the screen. As such, they're concerned with the 'usable'
// area of a surface, not its entire size (ie, we use the originally
// requested width & height, which are not necessarily the same as
// the surface width & height).
// These coordinates are not used at all for drawing base surfaces
myXOrig = (myFB.myScreenDim.w - myWidth) >> 1;
myYOrig = (myFB.myScreenDim.h - myHeight) >> 1;
// X/Y/Base Offset determine 'how far' to go into a surface, since base
// surfaces are defined larger than necessary in some cases, and have a
// 'non-usable' area.
if(myIsBaseSurface)
{
myXOffset = myFB.myImageDim.x;
myYOffset = myFB.myImageDim.y;
myBaseOffset = myYOffset * myPitch + myXOffset;
}
else
{
myXOffset = myYOffset = myBaseOffset = 0;
}
//cerr << "center: xorig = " << myXOrig << ", yorig = " << myYOrig << endl
// << " xoffset = " << myXOffset << ", yoffset = " << myYOffset << endl;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::translateCoords(Int32& x, Int32& y) const
void FBSurfaceGL::setPos(uInt32 x, uInt32 y)
{
#if 0
// Only non-base surfaces can be arbitrarily 'moved'
if(!myIsBaseSurface)
{
// Make sure pitch is valid
recalc();
myXOrig = x;
myYOrig = y;
myXOffset = myYOffset = myBaseOffset = 0;
}
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::getPos(uInt32& x, uInt32& y) const
{
#if 0
x = myXOrig;
y = myYOrig;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::translateCoords(Int32& x, Int32& y) const
{
/*
// Wow, what a mess :)
x = (Int32) ((x - myImageDim.x) / myWidthScaleFactor);
y = (Int32) ((y - myImageDim.y) / myHeightScaleFactor);
*/
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
void FBSurfaceGL::update()
{
myDirtyFlag = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::enablePhosphor(bool enable, int blend)
{
myUsePhosphor = enable;
myPhosphorBlend = blend;
theRedrawTIAIndicator = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -731,6 +816,7 @@ bool FrameBufferGL::createTextures()
return true;
}
#if 0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Surface* FrameBufferGL::createSurface(int width, int height) const
{
@ -742,6 +828,35 @@ GUI::Surface* FrameBufferGL::createSurface(int width, int height) const
return data ? new GUI::Surface(width, height, data) : NULL;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::drawSurface(const GUI::Surface* surface, Int32 x, Int32 y)
{
SDL_Rect dstrect;
dstrect.x = x;
dstrect.y = y;
SDL_Rect srcrect;
srcrect.x = 0;
srcrect.y = 0;
srcrect.w = surface->myClipWidth;
srcrect.h = surface->myClipHeight;
SDL_BlitSurface(surface->myData, &srcrect, myTexture, &dstrect);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const
{
SDL_Surface* s = surface->myData;
uInt16* pixels = (uInt16*) s->pixels;
pixels += (row * s->pitch/2);
for(int c = 0; c < rowbytes; c += 3)
*pixels++ = SDL_MapRGB(s->format, data[c], data[c+1], data[c+2]);
}
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FrameBufferGL::myLibraryLoaded = false;

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: FrameBufferGL.hxx,v 1.52 2008-03-13 22:58:06 stephena Exp $
// $Id: FrameBufferGL.hxx,v 1.53 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_GL_HXX
@ -35,10 +35,12 @@ class GUI::Font;
This class implements an SDL OpenGL framebuffer.
@author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.52 2008-03-13 22:58:06 stephena Exp $
@version $Id: FrameBufferGL.hxx,v 1.53 2008-06-13 13:14:50 stephena Exp $
*/
class FrameBufferGL : public FrameBuffer
{
friend class FBSurfaceGL;
public:
/**
Creates a new OpenGL framebuffer
@ -60,13 +62,22 @@ class FrameBufferGL : public FrameBuffer
static bool loadLibrary(const string& library);
//////////////////////////////////////////////////////////////////////
// The following methods are derived from FrameBuffer.hxx
// The following are derived from public methods in FrameBuffer.hxx
//////////////////////////////////////////////////////////////////////
/**
This method is called to initialize OpenGL video mode.
Return false if any operation fails, otherwise return true.
Enable/disable phosphor effect.
*/
bool initSubsystem(VideoMode mode);
void enablePhosphor(bool enable, int blend);
/**
This method 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.
*/
Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) const
{ return SDL_MapRGB(myTexture->format, r, g, b); }
/**
This method is called to query the type of the FrameBuffer.
@ -74,9 +85,32 @@ class FrameBufferGL : public FrameBuffer
BufferType type() const { return kGLBuffer; }
/**
This method is called to provide information about the FrameBuffer.
This method is called to create a surface compatible with the one
currently in use, but having the given dimensions.
@param w The requested width of the new surface.
@param h The requested height of the new surface.
@param useBase Use the base surface instead of creating a new one
*/
string about() const;
FBSurface* createSurface(int w, int h, bool useBase = false) const;
/**
This method is called to get the specified scanline data.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
void scanline(uInt32 row, uInt8* data) const;
protected:
//////////////////////////////////////////////////////////////////////
// The following are derived from protected methods in FrameBuffer.hxx
//////////////////////////////////////////////////////////////////////
/**
This method is called to initialize OpenGL video mode.
Return false if any operation fails, otherwise return true.
*/
bool initSubsystem(VideoMode mode);
/**
This method is called to change to the given video mode.
@ -98,147 +132,21 @@ class FrameBufferGL : public FrameBuffer
void drawMediaSource();
/**
This method is called before any drawing is done (per-frame).
This method is called to provide information about the FrameBuffer.
*/
void preFrameUpdate();
string about() const;
/**
This method is called after any drawing is done (per-frame).
*/
void postFrameUpdate();
/**
This method is called to get the specified scanline data.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
void scanline(uInt32 row, uInt8* data) const;
/**
This method 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.
*/
Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) const
{ return SDL_MapRGB(myTexture->format, r, g, b); }
/**
This method is called to create a surface compatible with the one
currently in use, but having the given dimensions.
@param width The requested width of the new surface.
@param height The requested height of the new surface.
*/
GUI::Surface* createSurface(int width, int height) const;
/**
This method 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
*/
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
/**
This method 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
*/
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
/**
This method 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
*/
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
/**
This method is called to draw the specified character.
@param font The font to use to draw the character
@param c The character to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
*/
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
/**
This method is called to draw the bitmap image.
@param bitmap The data to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
@param h The height of the data image
*/
void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color, Int32 h = 8);
/**
This method should be called to draw an SDL surface.
@param surface The data to draw
@param x The x coordinate
@param y The y coordinate
*/
void drawSurface(const GUI::Surface* surface, Int32 x, Int32 y);
/**
This method should be called to convert and copy a given row of RGB
data into an SDL surface.
@param surface The data to draw
@param row The row of the surface the data should be placed in
@param data The data in uInt8 R/G/B format
@param rowbytes The number of bytes in row of 'data'
*/
void bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const;
/**
This method translates the given coordinates to their
unzoomed/unscaled equivalents.
@param x X coordinate to translate
@param y Y coordinate to translate
*/
void translateCoords(Int32& x, Int32& y) const;
/**
This method adds a dirty rectangle
(ie, an area of the screen that has changed)
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
*/
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
/**
Enable/disable phosphor effect.
*/
void enablePhosphor(bool enable, int blend);
private:
bool loadFuncs();
bool createTextures();
inline uInt32 power_of_two(uInt32 input)
static uInt32 power_of_two(uInt32 input)
{
uInt32 value = 1;
while( value < input )
@ -291,6 +199,47 @@ class FrameBufferGL : public FrameBuffer
static bool myLibraryLoaded;
};
/**
A surface suitable for software rendering mode.
@author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.53 2008-06-13 13:14:50 stephena Exp $
*/
class FBSurfaceGL : public FBSurface
{
public:
FBSurfaceGL(const FrameBufferGL& buffer, SDL_Surface* surface,
uInt32 w, uInt32 h, bool isBase);
virtual ~FBSurfaceGL();
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color, Int32 h = 8);
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
void centerPos();
void setPos(uInt32 x, uInt32 y);
void getPos(uInt32& x, uInt32& y) const;
void translateCoords(Int32& x, Int32& y) const;
void update();
private:
void recalc();
private:
const FrameBufferGL& myFB;
SDL_Surface* myTexture;
uInt32 myWidth, myHeight;
bool myIsBaseSurface;
bool mySurfaceIsDirty;
int myBaseOffset;
int myPitch;
uInt32 myXOrig, myYOrig;
uInt32 myXOffset, myYOffset;
};
#endif // DISPLAY_OPENGL
#endif

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.78 2008-03-24 00:02:16 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.79 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#include <sstream>
@ -34,10 +34,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBufferSoft::FrameBufferSoft(OSystem* osystem)
: FrameBuffer(osystem),
myZoomLevel(1),
myRenderType(kSoftZoom_16),
myDirtyFlag(false),
myInUIMode(false),
myRectList(NULL)
{
}
@ -136,6 +133,8 @@ void FrameBufferSoft::drawMediaSource()
uInt32 width = mediasrc.width();
uInt32 height = mediasrc.height();
bool tiaChanged = false;
switch(myRenderType)
{
case kSoftZoom_16:
@ -165,7 +164,7 @@ void FrameBufferSoft::drawMediaSource()
buffer[pos++] = (uInt16) myDefPalette[v];
buffer[pos++] = (uInt16) myDefPalette[v];
}
myDirtyFlag = true;
tiaChanged = true;
}
else
pos += xstride + xstride;
@ -210,7 +209,7 @@ void FrameBufferSoft::drawMediaSource()
buffer[pos++] = r; buffer[pos++] = g; buffer[pos++] = b;
buffer[pos++] = r; buffer[pos++] = g; buffer[pos++] = b;
}
myDirtyFlag = true;
tiaChanged = true;
}
else // try to eliminate multply whereever possible
pos += xstride + xstride + xstride + xstride + xstride + xstride;
@ -250,7 +249,7 @@ void FrameBufferSoft::drawMediaSource()
buffer[pos++] = (uInt32) myDefPalette[v];
buffer[pos++] = (uInt32) myDefPalette[v];
}
myDirtyFlag = true;
tiaChanged = true;
}
else
pos += xstride + xstride;
@ -294,7 +293,7 @@ void FrameBufferSoft::drawMediaSource()
bufofsY += width;
}
SDL_UnlockSurface(myScreen);
myDirtyFlag = true;
tiaChanged = true;
break; // kPhosphor_16
}
@ -333,7 +332,7 @@ void FrameBufferSoft::drawMediaSource()
bufofsY += width;
}
SDL_UnlockSurface(myScreen);
myDirtyFlag = true;
tiaChanged = true;
break; // kPhosphor_24
}
@ -368,37 +367,63 @@ void FrameBufferSoft::drawMediaSource()
bufofsY += width;
}
SDL_UnlockSurface(myScreen);
myDirtyFlag = true;
tiaChanged = true;
break; // kPhosphor_32
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::preFrameUpdate()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::postFrameUpdate()
{
/*
cerr << "FrameBufferSoft::postFrameUpdate()" << endl
<< " myInUIMode: " << myInUIMode << endl
<< " myRectList->numRects(): " << myRectList->numRects() << endl
<< " myDirtyFlag: " << myDirtyFlag << endl
<< endl;
*/
if(myInUIMode && myRectList->numRects() > 0)
{
SDL_UpdateRects(myScreen, myRectList->numRects(), myRectList->rects());
}
else if(myDirtyFlag || myRectList->numRects() > 0)
if(tiaChanged)
{
SDL_Flip(myScreen);
myDirtyFlag = false;
tiaChanged = false;
}
myRectList->start();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::enablePhosphor(bool enable, int blend)
{
myUsePhosphor = enable;
myPhosphorBlend = blend;
stateChanged(myOSystem->eventHandler().state());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::stateChanged(EventHandler::State state)
{
if(!myScreen)
return;
// Make sure drawMediaSource() knows which renderer to use
switch(myBytesPerPixel)
{
case 2: // 16-bit
myPitch = myScreen->pitch >> 1;
myRenderType = myUsePhosphor ? kPhosphor_16 : kSoftZoom_16;
break;
case 3: // 24-bit
myPitch = myScreen->pitch;
myRenderType = myUsePhosphor ? kPhosphor_24 : kSoftZoom_24;
break;
case 4: // 32-bit
myPitch = myScreen->pitch >> 2;
myRenderType = myUsePhosphor ? kPhosphor_32 : kSoftZoom_32;
break;
}
// Have the changes take effect
myOSystem->eventHandler().refreshDisplay();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurface* FrameBufferSoft::createSurface(int w, int h, bool isBase) const
{
SDL_Surface* surface = isBase ? myScreen :
SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, myFormat->BitsPerPixel,
myFormat->Rmask, myFormat->Gmask, myFormat->Bmask,
myFormat->Amask);
return new FBSurfaceSoft(*this, surface, w, h, isBase);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -450,54 +475,76 @@ void FrameBufferSoft::scanline(uInt32 row, uInt8* data) const
SDL_UnlockSurface(myScreen);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::toggleFilter()
// FBSurfaceSoft implementation follows ...
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSoft::FBSurfaceSoft(const FrameBufferSoft& buffer, SDL_Surface* surface,
uInt32 w, uInt32 h, bool isBase)
: myFB(buffer),
mySurface(surface),
myWidth(w),
myHeight(h),
myIsBaseSurface(isBase),
mySurfaceIsDirty(false),
myBaseOffset(0),
myPitch(0),
myXOrig(0),
myYOrig(0),
myXOffset(0),
myYOffset(0)
{
// No filter added yet ...
recalc();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
FBSurfaceSoft::~FBSurfaceSoft()
{
SDL_Rect tmp;
if(!myIsBaseSurface)
SDL_FreeSurface(mySurface);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
{
// Horizontal line
tmp.x = myImageDim.x + x * myZoomLevel;
tmp.y = myImageDim.y + y * myZoomLevel;
tmp.w = (x2 - x + 1) * myZoomLevel;
tmp.h = myZoomLevel;
SDL_FillRect(myScreen, &tmp, myDefPalette[color]);
SDL_Rect tmp;
tmp.x = x + myXOffset;
tmp.y = y + myYOffset;
tmp.w = x2 - x + 1;
tmp.h = 1;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
void FBSurfaceSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
{
SDL_Rect tmp;
// Vertical line
tmp.x = myImageDim.x + x * myZoomLevel;
tmp.y = myImageDim.y + y * myZoomLevel;
tmp.w = myZoomLevel;
tmp.h = (y2 - y + 1) * myZoomLevel;
SDL_FillRect(myScreen, &tmp, myDefPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
{
SDL_Rect tmp;
// Fill the rectangle
tmp.x = myImageDim.x + x * myZoomLevel;
tmp.y = myImageDim.y + y * myZoomLevel;
tmp.w = w * myZoomLevel;
tmp.h = h * myZoomLevel;
SDL_FillRect(myScreen, &tmp, myDefPalette[color]);
tmp.x = x + myXOffset;
tmp.y = y + myYOffset;
tmp.w = 1;
tmp.h = y2 - y + 1;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 xorig, uInt32 yorig, int color)
void FBSurfaceSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
{
// Fill the rectangle
SDL_Rect tmp;
tmp.x = x + myXOffset;
tmp.y = y + myYOffset;
tmp.w = w;
tmp.h = h;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 tx, uInt32 ty, int color)
{
const FontDesc& desc = font->desc();
@ -513,48 +560,33 @@ void FrameBufferSoft::drawChar(const GUI::Font* font, uInt8 chr,
chr -= desc.firstchar;
const uInt32* tmp = desc.bits + (desc.offset ? desc.offset[chr] : (chr * h));
// Scale the origins to the current zoom
xorig *= myZoomLevel;
yorig *= myZoomLevel;
SDL_LockSurface(mySurface);
SDL_LockSurface(myScreen);
int screenofsY = 0;
switch(myBytesPerPixel)
switch(myFB.myBytesPerPixel)
{
case 2:
{
// Get buffer position where upper-left pixel of the character will be drawn
uInt16* buffer = (uInt16*) myScreen->pixels + myBaseOffset + yorig * myPitch + xorig;
for(int y = h; y; --y)
uInt16* buffer = (uInt16*) mySurface->pixels + myBaseOffset + ty * myPitch + tx;
for(int y = 0; y < h; ++y)
{
const uInt32 fontbuf = *tmp++;
int ystride = myZoomLevel;
while(ystride--)
const uInt32 ptr = *tmp++;
if(ptr)
{
if(fontbuf)
{
uInt32 mask = 0x80000000;
int pos = screenofsY;
for(int x = 0; x < w; x++, mask >>= 1)
{
int xstride = myZoomLevel;
if((fontbuf & mask) != 0)
while(xstride--)
buffer[pos++] = myDefPalette[color];
else
pos += xstride;
}
}
screenofsY += myPitch;
uInt32 mask = 0x80000000;
for(int x = 0; x < w; ++x, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color];
}
buffer += myFB.myPitch;
}
break;
}
case 3:
{
#if 0
// Get buffer position where upper-left pixel of the character will be drawn
uInt8* buffer = (uInt8*) myScreen->pixels + myBaseOffset + yorig * myPitch + xorig;
uInt8* buffer = (uInt8*) surface->pixels + myBaseOffset + yorig * myPitch + xorig;
uInt32 pixel = myDefPalette[color];
uInt8 r = (pixel & myFormat->Rmask) >> myFormat->Rshift;
uInt8 g = (pixel & myFormat->Gmask) >> myFormat->Gshift;
@ -587,46 +619,36 @@ void FrameBufferSoft::drawChar(const GUI::Font* font, uInt8 chr,
screenofsY += myPitch;
}
}
#endif
break;
}
case 4:
{
// Get buffer position where upper-left pixel of the character will be drawn
uInt32* buffer = (uInt32*) myScreen->pixels + myBaseOffset + yorig * myPitch + xorig;
for(int y = h; y; --y)
uInt32* buffer = (uInt32*) mySurface->pixels + myBaseOffset + ty * myPitch + tx;
for(int y = 0; y < h; ++y)
{
const uInt32 fontbuf = *tmp++;
int ystride = myZoomLevel;
while(ystride--)
const uInt32 ptr = *tmp++;
if(ptr)
{
if(fontbuf)
{
uInt32 mask = 0x80000000;
int pos = screenofsY;
for(int x = 0; x < w; x++, mask >>= 1)
{
int xstride = myZoomLevel;
if((fontbuf & mask) != 0)
while(xstride--)
buffer[pos++] = myDefPalette[color];
else
pos += xstride;
}
}
screenofsY += myPitch;
uInt32 mask = 0x80000000;
for(int x = 0; x < w; ++x, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt32) myFB.myDefPalette[color];
}
buffer += myPitch;
}
break;
}
default:
break;
}
SDL_UnlockSurface(myScreen);
SDL_UnlockSurface(mySurface);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::drawBitmap(uInt32* bitmap, Int32 xorig, Int32 yorig,
int color, Int32 h)
void FBSurfaceSoft::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
int color, Int32 h)
{
SDL_Rect rect;
for(int y = 0; y < h; y++)
@ -637,15 +659,152 @@ void FrameBufferSoft::drawBitmap(uInt32* bitmap, Int32 xorig, Int32 yorig,
{
if(bitmap[y] & mask)
{
rect.x = myImageDim.x + (x + xorig) * myZoomLevel;
rect.y = myImageDim.y + (y + yorig) * myZoomLevel;
rect.w = rect.h = myZoomLevel;
SDL_FillRect(myScreen, &rect, myDefPalette[color]);
rect.x = x + tx + myXOffset;
rect.y = y + ty + myYOffset;
rect.w = rect.h = 1;
SDL_FillRect(mySurface, &rect, myFB.myDefPalette[color]);
}
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{
// Base surfaces use dirty-rectangle updates, since they can be quite
// large, and updating the entire surface each frame would be too slow
// Non-base surfaces are usually smaller, and can be updated entirely
if(myIsBaseSurface)
{
// Add a dirty rect to the UI rectangle list
// TODO - intelligent merging of rectangles, to avoid overlap
SDL_Rect temp;
temp.x = x + myXOrig; temp.y = y + myYOrig; temp.w = w; temp.h = h;
myFB.myRectList->add(&temp);
}
else
{
// Indicate that at least one dirty rect has been added
// This is an optimization for the update() method
mySurfaceIsDirty = true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::centerPos()
{
// Make sure pitch is valid
recalc();
// X/Y Orig are the coordinates to use when blitting an entire (non-base)
// surface to the screen. As such, they're concerned with the 'usable'
// area of a surface, not its entire size (ie, we use the originally
// requested width & height, which are not necessarily the same as
// the surface width & height).
// These coordinates are not used at all for drawing base surfaces
myXOrig = (myFB.myScreenDim.w - myWidth) >> 1;
myYOrig = (myFB.myScreenDim.h - myHeight) >> 1;
// X/Y/Base Offset determine 'how far' to go into a surface, since base
// surfaces are defined larger than necessary in some cases, and have a
// 'non-usable' area.
if(myIsBaseSurface)
{
myXOffset = myFB.myImageDim.x;
myYOffset = myFB.myImageDim.y;
myBaseOffset = myYOffset * myPitch + myXOffset;
}
else
{
myXOffset = myYOffset = myBaseOffset = 0;
}
//cerr << "center: xorig = " << myXOrig << ", yorig = " << myYOrig << endl
// << " xoffset = " << myXOffset << ", yoffset = " << myYOffset << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::setPos(uInt32 x, uInt32 y)
{
// Only non-base surfaces can be arbitrarily 'moved'
if(!myIsBaseSurface)
{
// Make sure pitch is valid
recalc();
myXOrig = x;
myYOrig = y;
myXOffset = myYOffset = myBaseOffset = 0;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::getPos(uInt32& x, uInt32& y) const
{
x = myXOrig;
y = myYOrig;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::translateCoords(Int32& x, Int32& y) const
{
x -= myXOrig;
y -= myYOrig;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::update()
{
// Since this method is called each frame, we only blit the surfaces when
// absolutely necessary
if(myIsBaseSurface)
{
if(myFB.myRectList->numRects() > 0)
{
SDL_UpdateRects(mySurface, myFB.myRectList->numRects(), myFB.myRectList->rects());
myFB.myRectList->start();
}
}
else if(mySurfaceIsDirty /* && !myIsBaseSurface */)
{
SDL_Rect dstrect;
dstrect.x = myXOrig;
dstrect.y = myYOrig;
dstrect.w = myWidth;
dstrect.h = myHeight;
/*
cerr << "blit sub-surface:" << endl
<< " src x = " << dstrect.x << endl
<< " src y = " << dstrect.y << endl
<< " dst w = " << dstrect.w << endl
<< " dst h = " << dstrect.h << endl
<< endl;
*/
SDL_BlitSurface(mySurface, NULL, myFB.myScreen, &dstrect);
SDL_UpdateRect(myFB.myScreen, myXOrig, myYOrig, myWidth, myHeight);
mySurfaceIsDirty = false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::recalc()
{
switch(mySurface->format->BytesPerPixel)
{
case 2: // 16-bit
myPitch = mySurface->pitch/2;
break;
case 3: // 24-bit
myPitch = mySurface->pitch;
break;
case 4: // 32-bit
myPitch = mySurface->pitch/4;
break;
}
}
#if 0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::drawSurface(const GUI::Surface* surface, Int32 x, Int32 y)
{
@ -678,95 +837,4 @@ void FrameBufferSoft::bytesToSurface(GUI::Surface* surface, int row,
SDL_FillRect(surface->myData, &rect, pixel);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::translateCoords(Int32& x, Int32& y) const
{
x = (x - myImageDim.x) / myZoomLevel;
y = (y - myImageDim.y) / myZoomLevel;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h)
{
// Add a dirty rect to the UI rectangle list
// TODO - intelligent merging of rectangles, to avoid overlap
SDL_Rect temp;
#if 1
temp.x = myImageDim.x + x * myZoomLevel;
temp.y = myImageDim.y + y * myZoomLevel;
temp.w = w * myZoomLevel;
temp.h = h * myZoomLevel;
#else
temp.x = 0;
temp.y = 0;
temp.w = myScreenDim.w;
temp.h = myScreenDim.h;
#endif
myRectList->add(&temp);
// cerr << "addDirtyRect(): "
// << "x=" << temp.x << ", y=" << temp.y << ", w=" << temp.w << ", h=" << temp.h << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::enablePhosphor(bool enable, int blend)
{
myUsePhosphor = enable;
myPhosphorBlend = blend;
stateChanged(myOSystem->eventHandler().state());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferSoft::stateChanged(EventHandler::State state)
{
if(!myScreen)
return;
myInUIMode = (state == EventHandler::S_LAUNCHER ||
state == EventHandler::S_DEBUGGER);
// Make sure drawMediaSource() knows which renderer to use
switch(myBytesPerPixel)
{
case 2: // 16-bit
myPitch = myScreen->pitch/2;
if(myUsePhosphor)
myRenderType = kPhosphor_16;
else
myRenderType = kSoftZoom_16;
break;
case 3: // 24-bit
myPitch = myScreen->pitch;
if(myUsePhosphor)
myRenderType = kPhosphor_24;
else
myRenderType = kSoftZoom_24;
break;
case 4: // 32-bit
myPitch = myScreen->pitch/4;
if(myUsePhosphor)
myRenderType = kPhosphor_32;
else
myRenderType = kSoftZoom_32;
break;
default:
myRenderType = kSoftZoom_16; // What else should we do here?
break;
}
// Have the changes take effect
myOSystem->eventHandler().refreshDisplay();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GUI::Surface* FrameBufferSoft::createSurface(int width, int height) const
{
SDL_Surface* data =
SDL_CreateRGBSurface(SDL_SWSURFACE, width*myZoomLevel, height*myZoomLevel,
myBytesPerPixel << 3, myFormat->Rmask, myFormat->Gmask,
myFormat->Bmask, myFormat->Amask);
return data ? new GUI::Surface(width, height, data) : NULL;
}

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.50 2008-03-13 22:58:06 stephena Exp $
// $Id: FrameBufferSoft.hxx,v 1.51 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_SOFT_HXX
@ -33,10 +33,12 @@ class RectList;
This class implements an SDL software framebuffer.
@author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.50 2008-03-13 22:58:06 stephena Exp $
@version $Id: FrameBufferSoft.hxx,v 1.51 2008-06-13 13:14:50 stephena Exp $
*/
class FrameBufferSoft : public FrameBuffer
{
friend class FBSurfaceSoft;
public:
/**
Creates a new software framebuffer
@ -49,60 +51,12 @@ class FrameBufferSoft : public FrameBuffer
virtual ~FrameBufferSoft();
//////////////////////////////////////////////////////////////////////
// The following methods are derived from FrameBuffer.hxx
// The following are derived from public methods in FrameBuffer.hxx
//////////////////////////////////////////////////////////////////////
/**
This method is called to initialize software video mode.
Return false if any operation fails, otherwise return true.
Enable/disable phosphor effect.
*/
bool initSubsystem(VideoMode mode);
/**
This method is called to query the type of the FrameBuffer.
*/
BufferType type() const { return kSoftBuffer; }
/**
This method is called to provide information about the FrameBuffer.
*/
string about() const;
/**
This method is called to change to the given videomode type.
@param mode The video mode to use for rendering the mediasource
*/
bool setVidMode(VideoMode mode);
/**
Switches between the filtering options in software mode.
Currently, none exist.
*/
void toggleFilter();
/**
This method should be called anytime the MediaSource needs to be redrawn
to the screen.
*/
void drawMediaSource();
/**
This method is called before any drawing is done (per-frame).
*/
void preFrameUpdate();
/**
This method is called after any drawing is done (per-frame).
*/
void postFrameUpdate();
/**
This method is called to get the specified scanline data.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
void scanline(uInt32 row, uInt8* data) const;
void enablePhosphor(bool enable, int blend);
/**
This method is called to map a given r,g,b triple to the screen palette.
@ -114,113 +68,62 @@ class FrameBufferSoft : public FrameBuffer
Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) const
{ return SDL_MapRGB(myScreen->format, r, g, b); }
/**
This method is called to query the type of the FrameBuffer.
*/
BufferType type() const { return kSoftBuffer; }
/**
This method is called to create a surface compatible with the one
currently in use, but having the given dimensions.
@param width The requested width of the new surface.
@param height The requested height of the new surface.
@param w The requested width of the new surface.
@param h The requested height of the new surface.
@param useBase Use the base surface instead of creating a new one
*/
GUI::Surface* createSurface(int width, int height) const;
FBSurface* createSurface(int w, int h, bool useBase = false) const;
/**
This method is called to draw a horizontal line.
This method is called to get the specified scanline data.
@param x The first x coordinate
@param y The y coordinate
@param x2 The second x coordinate
@param color The color of the line
@param row The row we are looking for
@param data The actual pixel data (in bytes)
*/
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
void scanline(uInt32 row, uInt8* data) const;
protected:
//////////////////////////////////////////////////////////////////////
// The following are derived from protected methods in FrameBuffer.hxx
//////////////////////////////////////////////////////////////////////
/**
This method is called to initialize software video mode.
Return false if any operation fails, otherwise return true.
*/
bool initSubsystem(VideoMode mode);
/**
This method is called to draw a vertical line.
This method is called to change to the given videomode type.
@param x The x coordinate
@param y The first y coordinate
@param y2 The second y coordinate
@param color The color of the line
@param mode The video mode to use for rendering the mediasource
*/
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
bool setVidMode(VideoMode mode);
/**
This method 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
Switches between the filtering options in software mode.
Currently, none exist.
*/
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
void toggleFilter() { /* No filter added yet */ }
/**
This method is called to draw the specified character.
@param font The font to use to draw the character
@param c The character to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
This method should be called anytime the MediaSource needs to be redrawn
to the screen.
*/
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
void drawMediaSource();
/**
This method is called to draw the bitmap image.
@param bitmap The data to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
@param h The height of the data image
This method is called to provide information about the FrameBuffer.
*/
void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color, Int32 h = 8);
/**
This method should be called to draw an SDL surface.
@param surface The data to draw
@param x The x coordinate
@param y The y coordinate
*/
void drawSurface(const GUI::Surface* surface, Int32 x, Int32 y);
/**
This method should be called to convert and copy a given row of RGB
data into an SDL surface.
@param surface The data to draw
@param row The row of the surface the data should be placed in
@param data The data in uInt8 R/G/B format
@param rowbytes The number of bytes in row of 'data'
*/
void bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const;
/**
This method translates the given coordinates to their
unzoomed/unscaled equivalents.
@param x X coordinate to translate
@param y Y coordinate to translate
*/
void translateCoords(Int32& x, Int32& y) const;
/**
This method adds a dirty rectangle
(ie, an area of the screen that has changed)
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
*/
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
/**
Enable/disable phosphor effect.
*/
void enablePhosphor(bool enable, int blend);
string about() const;
/**
Informs the Framebuffer of a change in EventHandler state.
@ -230,8 +133,8 @@ class FrameBufferSoft : public FrameBuffer
private:
int myZoomLevel;
int myBytesPerPixel;
int myPitch;
int myBaseOffset;
int myPitch;
SDL_PixelFormat* myFormat;
enum RenderType {
@ -244,14 +147,49 @@ class FrameBufferSoft : public FrameBuffer
};
RenderType myRenderType;
// Indicates if the TIA image has been modified
bool myDirtyFlag;
// Indicates if we're in a purely UI mode
bool myInUIMode;
// Used in the dirty update of rectangles in non-TIA modes
RectList* myRectList;
};
/**
A surface suitable for software rendering mode.
@author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.51 2008-06-13 13:14:50 stephena Exp $
*/
class FBSurfaceSoft : public FBSurface
{
public:
FBSurfaceSoft(const FrameBufferSoft& buffer, SDL_Surface* surface,
uInt32 w, uInt32 h, bool isBase);
virtual ~FBSurfaceSoft();
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color, Int32 h = 8);
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
void centerPos();
void setPos(uInt32 x, uInt32 y);
void getPos(uInt32& x, uInt32& y) const;
void translateCoords(Int32& x, Int32& y) const;
void update();
private:
void recalc();
private:
const FrameBufferSoft& myFB;
SDL_Surface* mySurface;
uInt32 myWidth, myHeight;
bool myIsBaseSurface;
bool mySurfaceIsDirty;
int myBaseOffset;
int myPitch;
uInt32 myXOrig, myYOrig;
uInt32 myXOffset, myYOffset;
};
#endif

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: AudioWidget.cxx,v 1.7 2008-02-06 13:45:20 stephena Exp $
// $Id: AudioWidget.cxx,v 1.8 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -108,7 +108,7 @@ void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id
int addr, value;
string buf;
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
switch(cmd)
@ -140,7 +140,7 @@ void AudioWidget::fillGrid()
IntArray vlist;
BoolArray blist, changed, grNew, grOld;
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TiaState state = (TiaState&) tia.getState();
TiaState oldstate = (TiaState&) tia.getOldState();

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: ColorWidget.cxx,v 1.8 2008-02-06 13:45:20 stephena Exp $
// $Id: ColorWidget.cxx,v 1.9 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -64,14 +64,14 @@ void ColorWidget::handleMouseDown(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ColorWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
// Draw a thin frame around us.
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y +_h, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y+_h, kColor);
fb.vLine(_x + _w - 1, _y, _y +_h - 1, kShadowColor);
s.hLine(_x, _y, _x + _w - 1, kColor);
s.hLine(_x, _y +_h, _x + _w - 1, kShadowColor);
s.vLine(_x, _y, _y+_h, kColor);
s.vLine(_x + _w - 1, _y, _y +_h - 1, kShadowColor);
// Show the currently selected color
fb.fillRect(_x+1, _y+1, _w-2, _h-1, _color);
s.fillRect(_x+1, _y+1, _w-2, _h-1, _color);
}

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: CpuWidget.cxx,v 1.13 2008-05-15 18:59:56 stephena Exp $
// $Id: CpuWidget.cxx,v 1.14 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -133,7 +133,7 @@ CpuWidget::~CpuWidget()
void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
int addr = -1, value = -1;
CpuDebug& dbg = instance()->debugger().cpuDebug();
CpuDebug& dbg = instance().debugger().cpuDebug();
switch(cmd)
{
@ -159,7 +159,7 @@ void CpuWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// event the rest of the debugger widgets
ostringstream command;
command << "pc #" << value;
instance()->debugger().run(command.str());
instance().debugger().run(command.str());
break;
}
@ -241,7 +241,7 @@ void CpuWidget::fillGrid()
// We push the enumerated items as addresses, and deal with the real
// address in the callback (handleCommand)
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
CpuDebug& cpu = dbg.cpuDebug();
const CpuState& state = (CpuState&) cpu.getState();
const CpuState& oldstate = (CpuState&) cpu.getOldState();

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: DataGridWidget.cxx,v 1.13 2008-02-06 13:45:20 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.14 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -98,7 +98,7 @@ cerr << "alist.size() = " << alist.size()
string temp;
for(int i = 0; i < size; ++i)
{
temp = instance()->debugger().valueToString(_valueList[i], _base);
temp = instance().debugger().valueToString(_valueList[i], _base);
_valueStringList.push_back(temp);
}
@ -156,7 +156,7 @@ void DataGridWidget::setHiliteList(const IntArray& hilitelist)
void DataGridWidget::setSelectedValue(int value)
{
// Correctly format the data for viewing
_editString = instance()->debugger().valueToString(value, _base);
_editString = instance().debugger().valueToString(value, _base);
_valueStringList[_selectedItem] = _editString;
_changedList[_selectedItem] = (_valueList[_selectedItem] != value);
@ -231,8 +231,8 @@ int DataGridWidget::findItem(int x, int y)
bool DataGridWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Ignore all mod keys
if(instance()->eventHandler().kbdControl(modifiers) ||
instance()->eventHandler().kbdAlt(modifiers))
if(instance().eventHandler().kbdControl(modifiers) ||
instance().eventHandler().kbdAlt(modifiers))
return true;
bool handled = true;
@ -481,17 +481,17 @@ void DataGridWidget::handleCommand(CommandSender* sender, int cmd,
void DataGridWidget::drawWidget(bool hilite)
{
//cerr << "DataGridWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int row, col, deltax;
string buffer;
// Draw the internal grid and labels
int linewidth = _cols * _colWidth;
for (row = 0; row <= _rows; row++)
fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
s.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
int lineheight = _rows * _rowHeight;
for (col = 0; col <= _cols; col++)
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
s.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
// Draw the list items
for (row = 0; row < _rows; row++)
@ -505,7 +505,7 @@ void DataGridWidget::drawWidget(bool hilite)
// Draw the selected item inverted, on a highlighted background.
if (_currentRow == row && _currentCol == col &&
_hasFocus && !_editMode)
fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
s.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
if (_selectedItem == pos && _editMode)
{
@ -513,8 +513,8 @@ void DataGridWidget::drawWidget(bool hilite)
adjustOffset();
deltax = -_editScrollOffset;
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor,
kTextAlignLeft, deltax, false);
s.drawString(_font, buffer, x, y, _colWidth, kTextColor,
kTextAlignLeft, deltax, false);
}
else
{
@ -524,7 +524,7 @@ void DataGridWidget::drawWidget(bool hilite)
int color = kTextColor;
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
if(_hiliteList[pos])
color = kDbgColorHi;
@ -534,7 +534,7 @@ void DataGridWidget::drawWidget(bool hilite)
else if(_hiliteList[pos])
color = kDbgColorHi;
fb.drawString(_font, buffer, x, y, _colWidth, color);
s.drawString(_font, buffer, x, y, _colWidth, color);
}
}
}
@ -578,7 +578,7 @@ void DataGridWidget::endEditMode()
_editMode = false;
// Update the both the string representation and the real data
int value = instance()->debugger().stringToValue(_editString);
int value = instance().debugger().stringToValue(_editString);
if(value < _lowerBound || value >= _upperBound)
{
abortEditMode();

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: DebuggerDialog.cxx,v 1.24 2008-04-29 15:13:15 stephena Exp $
// $Id: DebuggerDialog.cxx,v 1.25 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -51,7 +51,7 @@ enum {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebuggerDialog::DebuggerDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h),
: Dialog(osystem, parent, x, y, w, h, true), // use base surface
myTab(NULL)
{
addTiaArea();
@ -85,7 +85,7 @@ void DebuggerDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{
bool handled = instance()->eventHandler().kbdAlt(modifiers);
bool handled = instance().eventHandler().kbdAlt(modifiers);
if(handled)
{
switch(ascii)
@ -147,21 +147,21 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::addTiaArea()
{
GUI::Rect r = instance()->debugger().getTiaBounds();
GUI::Rect r = instance().debugger().getTiaBounds();
myTiaOutput = new TiaOutputWidget(this, instance()->consoleFont(),
myTiaOutput = new TiaOutputWidget(this, instance().consoleFont(),
r.left, r.top, r.width(), r.height());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::addTabArea()
{
GUI::Rect r = instance()->debugger().getTabBounds();
GUI::Rect r = instance().debugger().getTabBounds();
const int vBorder = 4;
// The tab widget
myTab = new TabWidget(this, instance()->consoleFont(), r.left, r.top + vBorder,
myTab = new TabWidget(this, instance().consoleFont(), r.left, r.top + vBorder,
r.width(), r.height() - vBorder);
addTabWidget(myTab);
@ -171,28 +171,28 @@ void DebuggerDialog::addTabArea()
// The Prompt/console tab
tabID = myTab->addTab("Prompt");
myPrompt = new PromptWidget(myTab, instance()->consoleFont(),
myPrompt = new PromptWidget(myTab, instance().consoleFont(),
2, 2, widWidth, widHeight);
myTab->setParentWidget(tabID, myPrompt);
addToFocusList(myPrompt->getFocusList(), tabID);
// The TIA tab
tabID = myTab->addTab("TIA");
TiaWidget* tia = new TiaWidget(myTab, instance()->consoleFont(),
TiaWidget* tia = new TiaWidget(myTab, instance().consoleFont(),
2, 2, widWidth, widHeight);
myTab->setParentWidget(tabID, tia);
addToFocusList(tia->getFocusList(), tabID);
// The input/output tab (includes RIOT and INPTx from TIA)
tabID = myTab->addTab("I/O");
RiotWidget* riot = new RiotWidget(myTab, instance()->consoleFont(),
RiotWidget* riot = new RiotWidget(myTab, instance().consoleFont(),
2, 2, widWidth, widHeight);
myTab->setParentWidget(tabID, riot);
addToFocusList(riot->getFocusList(), tabID);
// The Audio tab
tabID = myTab->addTab("Audio");
AudioWidget* aud = new AudioWidget(myTab, instance()->consoleFont(),
AudioWidget* aud = new AudioWidget(myTab, instance().consoleFont(),
2, 2, widWidth, widHeight);
myTab->setParentWidget(tabID, aud);
addToFocusList(aud->getFocusList(), tabID);
@ -203,21 +203,21 @@ void DebuggerDialog::addTabArea()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::addStatusArea()
{
const GUI::Font& font = instance()->consoleFont();
const GUI::Font& font = instance().consoleFont();
const int lineHeight = font.getLineHeight();
GUI::Rect r = instance()->debugger().getStatusBounds();
GUI::Rect r = instance().debugger().getStatusBounds();
int xpos, ypos;
xpos = r.left; ypos = r.top;
myTiaInfo = new TiaInfoWidget(this, instance()->consoleFont(), xpos, ypos);
myTiaInfo = new TiaInfoWidget(this, instance().consoleFont(), xpos, ypos);
ypos += myTiaInfo->getHeight() + 10;
myTiaZoom = new TiaZoomWidget(this, instance()->consoleFont(), xpos+10, ypos,
myTiaZoom = new TiaZoomWidget(this, instance().consoleFont(), xpos+10, ypos,
r.width()-10, r.height()-lineHeight-ypos-10);
addToFocusList(myTiaZoom->getFocusList());
xpos += 10; ypos += myTiaZoom->getHeight() + 10;
myMessageBox = new EditTextWidget(this, instance()->consoleFont(),
myMessageBox = new EditTextWidget(this, instance().consoleFont(),
xpos, ypos, myTiaZoom->getWidth(),
font.getLineHeight(), "");
myMessageBox->setEditable(false);
@ -228,43 +228,43 @@ void DebuggerDialog::addStatusArea()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::addRomArea()
{
GUI::Rect r = instance()->debugger().getRomBounds();
GUI::Rect r = instance().debugger().getRomBounds();
int xpos, ypos;
xpos = r.left + 10; ypos = 10;
myCpu = new CpuWidget(this, instance()->consoleFont(), xpos, ypos);
myCpu = new CpuWidget(this, instance().consoleFont(), xpos, ypos);
addToFocusList(myCpu->getFocusList());
xpos = r.left + 10; ypos += myCpu->getHeight() + 10;
myRam = new RamWidget(this, instance()->consoleFont(), xpos, ypos);
myRam = new RamWidget(this, instance().consoleFont(), xpos, ypos);
addToFocusList(myRam->getFocusList());
xpos = r.left + 10 + myCpu->getWidth() + 5;
DataGridOpsWidget* ops = new DataGridOpsWidget(this, instance()->consoleFont(),
DataGridOpsWidget* ops = new DataGridOpsWidget(this, instance().consoleFont(),
xpos, 20);
const int bwidth = instance()->consoleFont().getStringWidth("Frame +1 "),
bheight = instance()->consoleFont().getLineHeight() + 2;
const int bwidth = instance().consoleFont().getStringWidth("Frame +1 "),
bheight = instance().consoleFont().getLineHeight() + 2;
int buttonX = r.right - bwidth - 5, buttonY = r.top + 5;
new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
new ButtonWidget(this, instance().consoleFont(), buttonX, buttonY,
bwidth, bheight, "Step", kDDStepCmd);
buttonY += bheight + 4;
new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
new ButtonWidget(this, instance().consoleFont(), buttonX, buttonY,
bwidth, bheight, "Trace", kDDTraceCmd);
buttonY += bheight + 4;
new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
new ButtonWidget(this, instance().consoleFont(), buttonX, buttonY,
bwidth, bheight, "Scan +1", kDDSAdvCmd);
buttonY += bheight + 4;
new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
new ButtonWidget(this, instance().consoleFont(), buttonX, buttonY,
bwidth, bheight, "Frame +1", kDDAdvCmd);
buttonY += bheight + 4;
new ButtonWidget(this, instance()->consoleFont(), buttonX, buttonY,
new ButtonWidget(this, instance().consoleFont(), buttonX, buttonY,
bwidth, bheight, "Exit", kDDExitCmd);
buttonY += bheight + 4;
xpos = r.left + 10; ypos += myRam->getHeight() + 5;
myRom = new RomWidget(this, instance()->consoleFont(), xpos, ypos);
myRom = new RomWidget(this, instance().consoleFont(), xpos, ypos);
addToFocusList(myRom->getFocusList());
// Add the DataGridOpsWidget to any widgets which contain a
@ -276,29 +276,29 @@ void DebuggerDialog::addRomArea()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doStep()
{
instance()->debugger().parser().run("step");
instance().debugger().parser().run("step");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doTrace()
{
instance()->debugger().parser().run("trace");
instance().debugger().parser().run("trace");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doAdvance()
{
instance()->debugger().parser().run("frame #1");
instance().debugger().parser().run("frame #1");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doScanlineAdvance()
{
instance()->debugger().parser().run("scanline #1");
instance().debugger().parser().run("scanline #1");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doExit()
{
instance()->debugger().parser().run("run");
instance().debugger().parser().run("run");
}

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: PromptWidget.cxx,v 1.24 2008-05-01 23:08:24 stephena Exp $
// $Id: PromptWidget.cxx,v 1.25 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -103,7 +103,7 @@ void PromptWidget::drawWidget(bool hilite)
//cerr << "PromptWidget::drawWidget\n";
int fgcolor, bgcolor;
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
// Draw text
int start = _scrollLine - _linesPerPage + 1;
@ -118,11 +118,11 @@ void PromptWidget::drawWidget(bool hilite)
if(c & (1 << 17)) { // inverse video flag
fgcolor = _bgcolor;
bgcolor = (c & 0x1ffff) >> 8;
fb.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor);
s.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor);
} else {
fgcolor = c >> 8;
}
fb.drawChar(&instance()->consoleFont(), c & 0x7f, x, y, fgcolor);
s.drawChar(&instance().consoleFont(), c & 0x7f, x, y, fgcolor);
x += _kConsoleCharWidth;
}
y += _kConsoleLineHeight;
@ -150,7 +150,7 @@ void PromptWidget::handleMouseWheel(int x, int y, int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::printPrompt()
{
string watches = instance()->debugger().showWatches();
string watches = instance().debugger().showWatches();
if(watches.length() > 0)
print(watches);
@ -186,7 +186,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
addToHistory(command.c_str());
// Pass the command to the debugger, and print the result
string result = instance()->debugger().run(command);
string result = instance().debugger().run(command);
// This is a bit of a hack
// Certain commands remove the debugger dialog from underneath us,
@ -239,7 +239,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
if(lastDelimPos < 0)
{
// no delimiters, do command completion:
DebuggerParser& parser = instance()->debugger().parser();
DebuggerParser& parser = instance().debugger().parser();
possibilities = parser.countCompletions(str);
if(possibilities < 1) {
@ -253,7 +253,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
else
{
// we got a delimiter, so this must be a label:
EquateList& equates = instance()->debugger().equates();
EquateList& equates = instance().debugger().equates();
possibilities = equates.countCompletions(str + lastDelimPos + 1);
if(possibilities < 1) {
@ -317,7 +317,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 256 + 24: // pageup
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
// Don't scroll up when at top of buffer
if(_scrollLine < _linesPerPage)
@ -333,7 +333,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 256 + 25: // pagedown
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
// Don't scroll down when at bottom of buffer
if(_scrollLine >= _promptEndPos / _lineWidth)
@ -349,7 +349,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 256 + 22: // home
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
_scrollLine = _firstLineInBuffer + _linesPerPage - 1;
updateScrollBuffer();
@ -361,7 +361,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 256 + 23: // end
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
_scrollLine = _promptEndPos / _lineWidth;
if (_scrollLine < _linesPerPage - 1)
@ -375,7 +375,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 273: // cursor up
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
if(_scrollLine <= _firstLineInBuffer + _linesPerPage - 1)
break;
@ -390,7 +390,7 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 274: // cursor down
if (instance()->eventHandler().kbdShift(modifiers))
if (instance().eventHandler().kbdShift(modifiers))
{
// Don't scroll down when at bottom of buffer
if(_scrollLine >= _promptEndPos / _lineWidth)
@ -420,11 +420,11 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
default:
if (instance()->eventHandler().kbdControl(modifiers))
if (instance().eventHandler().kbdControl(modifiers))
{
specialKeys(keycode);
}
else if (instance()->eventHandler().kbdAlt(modifiers))
else if (instance().eventHandler().kbdAlt(modifiers))
{
}
else if (isprint(ascii))
@ -526,7 +526,7 @@ void PromptWidget::loadConfig()
_exitedEarly = false;
// Take care of one-time debugger stuff
instance()->debugger().autoExec();
instance().debugger().autoExec();
}
else if(_exitedEarly)
{
@ -836,7 +836,7 @@ void PromptWidget::print(const string& str)
void PromptWidget::drawCaret()
{
//cerr << "PromptWidget::drawCaret()\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int line = _currentPos / _lineWidth;
@ -849,8 +849,8 @@ void PromptWidget::drawCaret()
int y = _y + displayLine * _kConsoleLineHeight;
char c = buffer(_currentPos);
fb.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, kTextColor);
fb.drawChar(&_boss->instance()->consoleFont(), c, x, y + 2, kBGColor);
s.fillRect(x, y, _kConsoleCharWidth, _kConsoleLineHeight, kTextColor);
s.drawChar(&_boss->instance().consoleFont(), c, x, y + 2, kBGColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: RamWidget.cxx,v 1.17 2008-05-04 17:16:39 stephena Exp $
// $Id: RamWidget.cxx,v 1.18 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -154,7 +154,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// memory location
int addr, value;
RamDebug& dbg = instance()->debugger().ramDebug();
RamDebug& dbg = instance().debugger().ramDebug();
switch(cmd)
{
case kDGItemDataChangedCmd:
@ -165,8 +165,8 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
myUndoValue = dbg.read(addr);
dbg.write(addr, value);
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
myDecValue->setEditString(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance().debugger().valueToString(value, kBASE_2));
myRevertButton->setEnabled(true);
myUndoButton->setEnabled(true);
break;
@ -177,9 +177,9 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
value = myRamGrid->getSelectedValue();
myLabel->setEditString(
instance()->debugger().equates().getLabel(addr+kRamStart, true));
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
instance().debugger().equates().getLabel(addr+kRamStart, true));
myDecValue->setEditString(instance().debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance().debugger().valueToString(value, kBASE_2));
break;
}
@ -196,14 +196,14 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
break;
case kSearchCmd:
parent()->addDialog(myInputBox);
parent().addDialog(myInputBox);
myInputBox->setEditString("");
myInputBox->setTitle("");
myInputBox->setEmitSignal(kSValEntered);
break;
case kCmpCmd:
parent()->addDialog(myInputBox);
parent().addDialog(myInputBox);
myInputBox->setEditString("");
myInputBox->setTitle("");
myInputBox->setEmitSignal(kCValEntered);
@ -219,7 +219,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
if(result != "")
myInputBox->setTitle(result);
else
parent()->removeDialog();
parent().removeDialog();
break;
}
@ -229,7 +229,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
if(result != "")
myInputBox->setTitle(result);
else
parent()->removeDialog();
parent().removeDialog();
break;
}
}
@ -251,7 +251,7 @@ void RamWidget::fillGrid(bool updateOld)
if(updateOld) myOldValueList.clear();
RamDebug& dbg = instance()->debugger().ramDebug();
RamDebug& dbg = instance().debugger().ramDebug();
RamState state = (RamState&) dbg.getState();
RamState oldstate = (RamState&) dbg.getOldState();
@ -289,7 +289,7 @@ const string RamWidget::doSearch(const string& str)
return "Invalid input +|-";
}
int searchVal = instance()->debugger().stringToValue(str);
int searchVal = instance().debugger().stringToValue(str);
// Clear the search array of previous items
mySearchAddr.clear();
@ -297,7 +297,7 @@ const string RamWidget::doSearch(const string& str)
// Now, search all memory locations for this value, and add it to the
// search array
RamDebug& dbg = instance()->debugger().ramDebug();
RamDebug& dbg = instance().debugger().ramDebug();
for(int addr = 0; addr < kRamSize; ++addr)
{
int value = dbg.read(addr);
@ -351,15 +351,15 @@ const string RamWidget::doCompare(const string& str)
string tmp = str;
tmp.erase(0, 1); // remove the operator
offset = instance()->debugger().stringToValue(tmp);
offset = instance().debugger().stringToValue(tmp);
if(negative)
offset = -offset;
}
else
searchVal = instance()->debugger().stringToValue(str);
searchVal = instance().debugger().stringToValue(str);
// Now, search all memory locations specified in mySearchArray for this value
RamDebug& dbg = instance()->debugger().ramDebug();
RamDebug& dbg = instance().debugger().ramDebug();
IntArray tempAddrList, tempValueList;
for(unsigned int i = 0; i < mySearchAddr.size(); ++i)
{

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: RiotWidget.cxx,v 1.5 2008-05-15 18:59:56 stephena Exp $
// $Id: RiotWidget.cxx,v 1.6 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -91,6 +91,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
lineHeight = font.getLineHeight();
int xpos = 10, ypos = 25, lwidth = 9 * fontWidth, col = 0;
StaticTextWidget* t;
StringList items;
// Set the strings to be used in the various bit registers
// We only do this once because it's the state that changes, not the strings
@ -157,26 +158,26 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font,
int pwidth = font.getStringWidth("B/easy");
lwidth = font.getStringWidth("P0 Diff: ");
xpos = col; ypos += 3 * lineHeight;
myP0Diff = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight,
items.clear();
items.push_back("B/easy");
items.push_back("A/hard");
myP0Diff = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight, items,
"P0 Diff: ", lwidth, kP0DiffChanged);
myP0Diff->appendEntry("B/easy", 0);
myP0Diff->appendEntry("A/hard", 1);
myP0Diff->setTarget(this);
addFocusWidget(myP0Diff);
ypos += myP0Diff->getHeight() + 5;
myP1Diff = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight,
myP1Diff = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight, items,
"P1 Diff: ", lwidth, kP1DiffChanged);
myP1Diff->appendEntry("B/easy", 0);
myP1Diff->appendEntry("A/hard", 1);
myP1Diff->setTarget(this);
addFocusWidget(myP1Diff);
// TV Type
ypos += myP1Diff->getHeight() + 5;
myTVType = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight,
items.clear();
items.push_back("B&W");
items.push_back("Color");
myTVType = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight, items,
"TV Type: ", lwidth, kTVTypeChanged);
myTVType->appendEntry("B&W", 0);
myTVType->appendEntry("Color", 1);
myTVType->setTarget(this);
addFocusWidget(myTVType);
@ -215,7 +216,7 @@ void RiotWidget::loadConfig()
// We push the enumerated items as addresses, and deal with the real
// address in the callback (handleCommand)
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
RiotDebug& riot = dbg.riotDebug();
const RiotState& state = (RiotState&) riot.getState();
const RiotState& oldstate = (RiotState&) riot.getOldState();
@ -269,9 +270,9 @@ void RiotWidget::loadConfig()
myP1Pins[4]->setState(!state.P1_PIN6);
// Console switches (invert reset/select for same reason as the pins)
myP0Diff->setSelectedTag((int)riot.diffP0());
myP1Diff->setSelectedTag((int)riot.diffP1());
myTVType->setSelectedTag((int)riot.tvType());
myP0Diff->setSelected((int)riot.diffP0());
myP1Diff->setSelected((int)riot.diffP1());
myTVType->setSelected((int)riot.tvType());
mySelect->setState(!riot.select());
myReset->setState(!riot.reset());
}
@ -280,7 +281,7 @@ void RiotWidget::loadConfig()
void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
int value = -1;
RiotDebug& riot = instance()->debugger().riotDebug();
RiotDebug& riot = instance().debugger().riotDebug();
switch(cmd)
{
@ -344,15 +345,15 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
break;
case kP0DiffChanged:
riot.diffP0((bool)myP0Diff->getSelectedTag());
riot.diffP0((bool)myP0Diff->getSelected());
break;
case kP1DiffChanged:
riot.diffP1((bool)myP1Diff->getSelectedTag());
riot.diffP1((bool)myP1Diff->getSelected());
break;
case kTVTypeChanged:
riot.tvType((bool)myTVType->getSelectedTag());
riot.tvType((bool)myTVType->getSelected());
break;
}
}

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: RomListWidget.cxx,v 1.12 2008-05-11 21:18:34 stephena Exp $
// $Id: RomListWidget.cxx,v 1.13 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -32,14 +32,11 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font,
{
_type = kRomListWidget;
myMenu = new ContextMenu(this, font);
StringList l;
// l.push_back("Add bookmark");
l.push_back("Save ROM");
l.push_back("Set PC");
myMenu->setList(l);
myMenu = new ContextMenu(this, font, l);
// Take advantage of a wide debugger window when possible
const int fontWidth = font.getMaxCharWidth(),
@ -70,10 +67,7 @@ void RomListWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
// Grab right mouse button for context menu, send left to base class
if(button == 2)
{
myMenu->setPos(x + getAbsX(), y + getAbsY());
myMenu->show();
}
myMenu->show(x + getAbsX(), y + getAbsY());
ListWidget::handleMouseDown(x, y, button, clickCount);
}
@ -88,17 +82,17 @@ bool RomListWidget::handleEvent(Event::Type e)
void RomListWidget::drawWidget(bool hilite)
{
//cerr << "RomListWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int i, pos, len = _list.size();
string buffer;
int deltax;
// Draw a thin frame around the list and to separate columns
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
s.hLine(_x, _y, _x + _w - 1, kColor);
s.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
s.vLine(_x, _y, _y + _h - 1, kColor);
fb.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor);
s.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor);
// Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++)
@ -116,29 +110,27 @@ void RomListWidget::drawWidget(bool hilite)
// Draw highlighted item in a frame
if (_highlightedItem == pos)
{
fb.frameRect(_x + l.left - 3, _y + 1 + _fontHeight * i,
_w - l.left, _fontHeight, kDbgColorHi);
s.frameRect(_x + l.left - 3, _y + 1 + _fontHeight * i,
_w - l.left, _fontHeight, kDbgColorHi);
}
// Draw the selected item inverted, on a highlighted background.
if (_selectedItem == pos && _hasFocus)
{
if (!_editMode)
fb.fillRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
r.width(), _fontHeight,
kTextColorHi);
s.fillRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
r.width(), _fontHeight, kTextColorHi);
else
fb.frameRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
r.width(), _fontHeight,
kTextColorHi);
s.frameRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
r.width(), _fontHeight, kTextColorHi);
}
// Draw labels and actual disassembly
fb.drawString(_font, myLabel[pos], _x + r.left - myLabelWidth, y,
myLabelWidth, kTextColor);
s.drawString(_font, myLabel[pos], _x + r.left - myLabelWidth, y,
myLabelWidth, kTextColor);
fb.drawString(_font, myDisasm[pos], _x + r.right, y,
_w - r.right, kTextColor);
s.drawString(_font, myDisasm[pos], _x + r.right, y,
_w - r.right, kTextColor);
// Draw editable bytes
if (_selectedItem == pos && _editMode)
@ -147,14 +139,14 @@ void RomListWidget::drawWidget(bool hilite)
adjustOffset();
deltax = -_editScrollOffset;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
}
else
{
buffer = _list[pos];
deltax = 0;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
}
}

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: RomWidget.cxx,v 1.24 2008-03-23 17:43:22 stephena Exp $
// $Id: RomWidget.cxx,v 1.25 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -61,8 +61,8 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
myBank = new DataGridWidget(boss, font, xpos, ypos-2,
1, 1, 3, 8, kBASE_10);
myBank->setTarget(this);
myBank->setRange(0, instance()->debugger().bankCount());
if(instance()->debugger().bankCount() <= 1)
myBank->setRange(0, instance().debugger().bankCount());
if(instance().debugger().bankCount() <= 1)
myBank->setEditable(false);
addFocusWidget(myBank);
@ -80,7 +80,7 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& font, int x, int y)
// Create rom listing
xpos = x; ypos += myBank->getHeight() + 4;
GUI::Rect dialog = instance()->debugger().getDialogBounds();
GUI::Rect dialog = instance().debugger().getDialogBounds();
int w = dialog.width() - x - 5, h = dialog.height() - ypos - 3;
myRomList = new RomListWidget(boss, font, xpos, ypos, w, h);
@ -133,7 +133,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
mySaveRom->setTitle("");
mySaveRom->setEmitSignal(kRomNameEntered);
parent()->addDialog(mySaveRom);
parent().addDialog(mySaveRom);
}
else if(rmb == "Set PC")
setPC(myRomList->getSelected());
@ -149,7 +149,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
else
{
saveROM(rom);
parent()->removeDialog();
parent().removeDialog();
}
break;
}
@ -157,7 +157,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kDGItemDataChangedCmd:
{
int bank = myBank->getSelectedValue();
instance()->debugger().setBank(bank);
instance().debugger().setBank(bank);
}
}
}
@ -165,7 +165,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomWidget::loadConfig()
{
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
bool bankChanged = myCurrentBank != dbg.getBank();
// Only reload full bank when necessary
@ -216,7 +216,7 @@ void RomWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomWidget::initialUpdate()
{
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
PackedBitArray& bp = dbg.breakpoints();
// Reading from ROM might trigger a bankswitch, so save the current bank
@ -266,7 +266,7 @@ void RomWidget::incrementalUpdate(int line, int rows)
void RomWidget::setBreak(int data)
{
bool state = myRomList->getState(data);
instance()->debugger().setBreakPoint(myAddrList[data], state);
instance().debugger().setBreakPoint(myAddrList[data], state);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -274,7 +274,7 @@ void RomWidget::setPC(int data)
{
ostringstream command;
command << "pc #" << myAddrList[data];
instance()->debugger().run(command.str());
instance().debugger().run(command.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -285,14 +285,14 @@ void RomWidget::patchROM(int data, const string& bytes)
// Temporarily set to base 16, since that's the format the disassembled
// byte string is in. This eliminates the need to prefix each byte with
// a '$' character
BaseFormat oldbase = instance()->debugger().parser().base();
instance()->debugger().parser().setBase(kBASE_16);
BaseFormat oldbase = instance().debugger().parser().base();
instance().debugger().parser().setBase(kBASE_16);
command << "rom #" << myAddrList[data] << " " << bytes;
instance()->debugger().run(command.str());
instance().debugger().run(command.str());
// Restore previous base
instance()->debugger().parser().setBase(oldbase);
instance().debugger().parser().setBase(oldbase);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -300,5 +300,5 @@ void RomWidget::saveROM(const string& rom)
{
ostringstream command;
command << "saverom " << rom;
instance()->debugger().run(command.str());
instance().debugger().run(command.str());
}

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: TiaInfoWidget.cxx,v 1.9 2008-02-06 13:45:20 stephena Exp $
// $Id: TiaInfoWidget.cxx,v 1.10 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -121,7 +121,7 @@ void TiaInfoWidget::handleCommand(CommandSender* sender, int cmd, int data, int
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaInfoWidget::loadConfig()
{
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
myFrameCount->setEditString(dbg.valueToString(tia.frameCount(), kBASE_10));

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: TiaOutputWidget.cxx,v 1.15 2008-03-23 17:43:22 stephena Exp $
// $Id: TiaOutputWidget.cxx,v 1.16 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -44,14 +44,11 @@ TiaOutputWidget::TiaOutputWidget(GuiObject* boss, const GUI::Font& font,
_type = kTiaOutputWidget;
// Create context menu for commands
myMenu = new ContextMenu(this, font);
StringList l;
l.push_back("Fill to scanline");
l.push_back("Set breakpoint");
l.push_back("Set zoom position");
myMenu->setList(l);
myMenu = new ContextMenu(this, font, l);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -71,7 +68,7 @@ void TiaOutputWidget::advanceScanline(int lines)
{
while(lines)
{
instance()->console().mediaSource().updateScanline();
instance().console().mediaSource().updateScanline();
--lines;
}
}
@ -81,7 +78,7 @@ void TiaOutputWidget::advance(int frames)
{
while(frames)
{
instance()->console().mediaSource().update();
instance().console().mediaSource().update();
--frames;
}
}
@ -95,15 +92,14 @@ void TiaOutputWidget::handleMouseDown(int x, int y, int button, int clickCount)
myClickX = x;
myClickY = y;
myMenu->setPos(x + getAbsX(), y + getAbsY());
myMenu->show();
myMenu->show(x + getAbsX(), y + getAbsY());
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
int ystart = atoi(instance()->console().properties().get(Display_YStart).c_str());
int ystart = atoi(instance().console().properties().get(Display_YStart).c_str());
switch(cmd)
{
@ -114,11 +110,11 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
{
ostringstream command;
int lines = myClickY + ystart -
instance()->debugger().tiaDebug().scanlines();
instance().debugger().tiaDebug().scanlines();
if(lines > 0)
{
command << "scanline #" << lines;
instance()->debugger().parser().run(command.str());
instance().debugger().parser().run(command.str());
}
break;
}
@ -128,7 +124,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
ostringstream command;
int scanline = myClickY + ystart;
command << "breakif _scan==#" << scanline;
instance()->debugger().parser().run(command.str());
instance().debugger().parser().run(command.str());
break;
}
@ -145,6 +141,6 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
void TiaOutputWidget::drawWidget(bool hilite)
{
// FIXME - check if we're in 'greyed out mode' and act accordingly
instance()->frameBuffer().refresh();
instance()->frameBuffer().drawMediaSource();
instance().frameBuffer().refresh();
instance().frameBuffer().drawMediaSource();
}

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: TiaWidget.cxx,v 1.13 2008-05-15 15:07:29 stephena Exp $
// $Id: TiaWidget.cxx,v 1.14 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -589,7 +589,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
int addr, value;
string buf;
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
switch(cmd)
@ -872,7 +872,7 @@ void TiaWidget::fillGrid()
IntArray vlist;
BoolArray blist, changed, grNew, grOld;
Debugger& dbg = instance()->debugger();
Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug();
TiaState& state = (TiaState&) tia.getState();
TiaState& oldstate = (TiaState&) tia.getOldState();
@ -1051,22 +1051,22 @@ void TiaWidget::changeColorRegs()
switch(addr)
{
case kCOLUP0Addr:
instance()->debugger().tiaDebug().coluP0(value);
instance().debugger().tiaDebug().coluP0(value);
myCOLUP0Color->setColor(value);
break;
case kCOLUP1Addr:
instance()->debugger().tiaDebug().coluP1(value);
instance().debugger().tiaDebug().coluP1(value);
myCOLUP1Color->setColor(value);
break;
case kCOLUPFAddr:
instance()->debugger().tiaDebug().coluPF(value);
instance().debugger().tiaDebug().coluPF(value);
myCOLUPFColor->setColor(value);
break;
case kCOLUBKAddr:
instance()->debugger().tiaDebug().coluBK(value);
instance().debugger().tiaDebug().coluBK(value);
myCOLUBKColor->setColor(value);
break;
}

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: TiaZoomWidget.cxx,v 1.15 2008-02-06 13:45:20 stephena Exp $
// $Id: TiaZoomWidget.cxx,v 1.16 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,14 +56,11 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font,
myYCenter = myNumRows >> 1;
// Create context menu for zoom levels
myMenu = new ContextMenu(this, font);
StringList l;
l.push_back("2x zoom");
l.push_back("4x zoom");
l.push_back("8x zoom");
myMenu->setList(l);
myMenu = new ContextMenu(this, font, l);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -107,8 +104,8 @@ void TiaZoomWidget::zoom(int level)
void TiaZoomWidget::recalc()
{
// Don't go past end of framebuffer
const int width = instance()->console().mediaSource().width(),
height = instance()->console().mediaSource().height();
const int width = instance().console().mediaSource().width(),
height = instance().console().mediaSource().height();
// Figure out the bounding rectangle for the current center coords
const int xoff = myNumCols >> 1,
@ -140,10 +137,7 @@ void TiaZoomWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
// Grab right mouse button for zoom context menu
if(button == 2)
{
myMenu->setPos(x + getAbsX(), y + getAbsY());
myMenu->show();
}
myMenu->show(x + getAbsX(), y + getAbsY());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -222,16 +216,16 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int
void TiaZoomWidget::drawWidget(bool hilite)
{
//cerr << "TiaZoomWidget::drawWidget\n";
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
fb.fillRect(_x+1, _y+1, _w-2, _h-2, kBGColor);
fb.box(_x, _y, _w, _h, kColor, kShadowColor);
s.fillRect(_x+1, _y+1, _w-2, _h-2, kBGColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor);
// Draw the zoomed image
// This probably isn't as efficient as it can be, but it's a small area
// and I don't have time to make it faster :)
uInt8* currentFrame = instance()->console().mediaSource().currentFrameBuffer();
const int pitch = instance()->console().mediaSource().width(),
uInt8* currentFrame = instance().console().mediaSource().currentFrameBuffer();
const int pitch = instance().console().mediaSource().width(),
width = myZoomLevel << 1,
height = myZoomLevel;
@ -240,8 +234,8 @@ void TiaZoomWidget::drawWidget(bool hilite)
{
for(x = myXoff, col = 0; x < myNumCols+myXoff; ++x, col += width)
{
fb.fillRect(_x + col + 2, _y + row + 2, width, height,
currentFrame[y*pitch + x]);
s.fillRect(_x + col + 2, _y + row + 2, width, height,
currentFrame[y*pitch + x]);
}
}
}

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: ToggleBitWidget.cxx,v 1.8 2008-02-06 13:45:20 stephena Exp $
// $Id: ToggleBitWidget.cxx,v 1.9 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -74,17 +74,17 @@ void ToggleBitWidget::setState(const BoolArray& state, const BoolArray& changed)
void ToggleBitWidget::drawWidget(bool hilite)
{
//cerr << "ToggleBitWidget::drawWidget\n";
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
int row, col;
string buffer;
// Draw the internal grid and labels
int linewidth = _cols * _colWidth;
for (row = 0; row <= _rows; row++)
fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
s.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
int lineheight = _rows * _rowHeight;
for (col = 0; col <= _cols; col++)
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
s.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
// Draw the list items
for (row = 0; row < _rows; row++)
@ -97,7 +97,7 @@ void ToggleBitWidget::drawWidget(bool hilite)
// Draw the selected item inverted, on a highlighted background.
if (_currentRow == row && _currentCol == col && _hasFocus)
fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
s.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
if(_stateList[pos])
buffer = _onList[pos];
@ -107,11 +107,11 @@ void ToggleBitWidget::drawWidget(bool hilite)
// Highlight changes
if(_changedList[pos])
{
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
fb.drawString(_font, buffer, x, y, _colWidth, kDbgChangedTextColor);
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);
s.drawString(_font, buffer, x, y, _colWidth, kDbgChangedTextColor);
}
else
fb.drawString(_font, buffer, x, y, _colWidth, kTextColor);
s.drawString(_font, buffer, x, y, _colWidth, kTextColor);
}
}
}

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: TogglePixelWidget.cxx,v 1.7 2008-02-06 13:45:20 stephena Exp $
// $Id: TogglePixelWidget.cxx,v 1.8 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -115,16 +115,16 @@ int TogglePixelWidget::getIntState()
void TogglePixelWidget::drawWidget(bool hilite)
{
//cerr << "TogglePixelWidget::drawWidget\n";
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
int row, col;
// Draw the internal grid and labels
int linewidth = _cols * _colWidth;
for (row = 0; row <= _rows; row++)
fb.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
s.hLine(_x, _y + (row * _rowHeight), _x + linewidth, kColor);
int lineheight = _rows * _rowHeight;
for (col = 0; col <= _cols; col++)
fb.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
s.vLine(_x + (col * _colWidth), _y, _y + lineheight, kColor);
// Draw the pixels
for (row = 0; row < _rows; row++)
@ -137,13 +137,13 @@ void TogglePixelWidget::drawWidget(bool hilite)
// Draw the selected item inverted, on a highlighted background.
if (_currentRow == row && _currentCol == col && _hasFocus)
fb.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
s.fillRect(x - 4, y - 2, _colWidth+1, _rowHeight+1, kTextColorHi);
// Either draw the pixel in given color, or erase (show background)
if(_stateList[pos])
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, _pixelColor);
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, _pixelColor);
else
fb.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kBGColor);
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kBGColor);
}
}
}

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: ToggleWidget.cxx,v 1.8 2008-05-14 18:04:58 stephena Exp $
// $Id: ToggleWidget.cxx,v 1.9 2008-06-13 13:14:50 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -99,8 +99,8 @@ int ToggleWidget::findItem(int x, int y)
bool ToggleWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Ignore all mod keys
if(instance()->eventHandler().kbdControl(modifiers) ||
instance()->eventHandler().kbdAlt(modifiers))
if(instance().eventHandler().kbdControl(modifiers) ||
instance().eventHandler().kbdAlt(modifiers))
return true;
bool handled = true;

View File

@ -13,7 +13,6 @@ MODULE_OBJS := \
src/debugger/gui/TiaOutputWidget.o \
src/debugger/gui/TiaZoomWidget.o \
src/debugger/gui/ColorWidget.o \
src/debugger/gui/ContextMenu.o \
src/debugger/gui/DataGridOpsWidget.o \
src/debugger/gui/DataGridWidget.o \
src/debugger/gui/DebuggerDialog.o \

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.225 2008-05-30 19:07:55 stephena Exp $
// $Id: EventHandler.cxx,v 1.226 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#include <sstream>
@ -769,7 +769,6 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
else if(myOverlay)
{
int x = event.motion.x, y = event.motion.y;
myOSystem->frameBuffer().translateCoords(x, y);
myOverlay->handleMouseMotionEvent(x, y, 0);
}
}
@ -784,7 +783,6 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, int state)
{
// Take window zooming into account
Int32 x = event.button.x, y = event.button.y;
myOSystem->frameBuffer().translateCoords(x, y);
MouseButton button;
switch(event.button.button)
@ -1913,6 +1911,7 @@ void EventHandler::leaveDebugMode()
void EventHandler::setEventState(State state)
{
myState = state;
switch(myState)
{
case S_EMULATE:

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.cxx,v 1.132 2008-05-30 19:07:55 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.133 2008-06-13 13:14:50 stephena Exp $
//============================================================================
#include <sstream>
@ -117,9 +117,6 @@ bool FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::update()
{
// Do any pre-frame stuff
preFrameUpdate();
// Determine which mode we are in (from the EventHandler)
// Take care of S_EMULATE mode here, otherwise let the GUI
// figure out what to draw
@ -135,6 +132,7 @@ void FrameBuffer::update()
// And update the screen
drawMediaSource();
#if 0
// Show frame statistics
if(myFrameStatsEnabled)
{
@ -146,7 +144,7 @@ void FrameBuffer::update()
fillRect(3, 3, 95, 9, kBGColor);
drawString(&myOSystem->font(), msg, 3, 3, 95, kBtnTextColor, kTextAlignCenter);
}
#endif
break; // S_EMULATE
}
@ -208,9 +206,6 @@ void FrameBuffer::update()
if(myMessage.counter > 0)
drawMessage();
// Do any post-frame stuff
postFrameUpdate();
// The frame doesn't need to be completely redrawn anymore
theRedrawTIAIndicator = false;
}
@ -321,6 +316,7 @@ void FrameBuffer::enableMessages(bool enable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void FrameBuffer::drawMessage()
{
#if 0
// Draw the bounded box and text
fillRect(myMessage.x+1, myMessage.y+2, myMessage.w-2, myMessage.h-4, kBGColor);
box(myMessage.x, myMessage.y+1, myMessage.w, myMessage.h-2, kColor, kShadowColor);
@ -334,6 +330,7 @@ inline void FrameBuffer::drawMessage()
myOSystem->eventHandler().refreshDisplay(true);
else
addDirtyRect(myMessage.x, myMessage.y, myMessage.w, myMessage.h);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -459,8 +456,8 @@ bool FrameBuffer::changeVidMode(int direction)
if(inTIAMode)
myOSystem->settings().setInt("zoom_tia", newmode.zoom);
else
myOSystem->settings().setInt("zoom_ui", newmode.zoom);
//FIXME else
// myOSystem->settings().setInt("zoom_ui", newmode.zoom);
}
}
return true;
@ -588,133 +585,6 @@ void FrameBuffer::setWindowIcon()
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB)
{
hLine(x + 1, y, x + w - 2, colorA);
hLine(x, y + 1, x + w - 1, colorA);
vLine(x, y + 1, y + h - 2, colorA);
vLine(x + 1, y, y + h - 1, colorA);
hLine(x + 1, y + h - 2, x + w - 1, colorB);
hLine(x + 1, y + h - 1, x + w - 2, colorB);
vLine(x + w - 1, y + 1, y + h - 2, colorB);
vLine(x + w - 2, y + 1, y + h - 1, colorB);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style)
{
switch(style)
{
case kSolidLine:
hLine(x, y, x + w - 1, color);
hLine(x, y + h - 1, x + w - 1, color);
vLine(x, y, y + h - 1, color);
vLine(x + w - 1, y, y + h - 1, color);
break;
case kDashLine:
unsigned int i, skip, lwidth = 1;
for(i = x, skip = 1; i < x+w-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
hLine(i, y, i + lwidth, color);
hLine(i, y + h - 1, i + lwidth, color);
}
}
for(i = y, skip = 1; i < y+h-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
vLine(x, i, i + lwidth, color);
vLine(x + w - 1, i, i + lwidth, color);
}
}
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::drawString(const GUI::Font* font, const string& s,
int x, int y, int w,
int color, TextAlignment align,
int deltax, bool useEllipsis)
{
const int leftX = x, rightX = x + w;
unsigned int i;
int width = font->getStringWidth(s);
string str;
if(useEllipsis && width > w)
{
// String is too wide. So we shorten it "intelligently", by replacing
// parts of it by an ellipsis ("..."). There are three possibilities
// for this: replace the start, the end, or the middle of the string.
// What is best really depends on the context; but unless we want to
// make this configurable, replacing the middle probably is a good
// compromise.
const int ellipsisWidth = font->getStringWidth("...");
// SLOW algorithm to remove enough of the middle. But it is good enough for now.
const int halfWidth = (w - ellipsisWidth) / 2;
int w2 = 0;
for(i = 0; i < s.size(); ++i)
{
int charWidth = font->getCharWidth(s[i]);
if(w2 + charWidth > halfWidth)
break;
w2 += charWidth;
str += s[i];
}
// At this point we know that the first 'i' chars are together 'w2'
// pixels wide. We took the first i-1, and add "..." to them.
str += "...";
// The original string is width wide. Of those we already skipped past
// w2 pixels, which means (width - w2) remain.
// The new str is (w2+ellipsisWidth) wide, so we can accomodate about
// (w - (w2+ellipsisWidth)) more pixels.
// Thus we skip ((width - w2) - (w - (w2+ellipsisWidth))) =
// (width + ellipsisWidth - w)
int skip = width + ellipsisWidth - w;
for(; i < s.size() && skip > 0; ++i)
skip -= font->getCharWidth(s[i]);
// Append the remaining chars, if any
for(; i < s.size(); ++i)
str += s[i];
width = font->getStringWidth(str);
}
else
str = s;
if(align == kTextAlignCenter)
x = x + (w - width - 1)/2;
else if(align == kTextAlignRight)
x = x + w - width;
x += deltax;
for(i = 0; i < str.size(); ++i)
{
w = font->getCharWidth(str[i]);
if(x+w > rightX)
break;
if(x >= leftX)
drawChar(font, str[i], x, y, color);
x += w;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 FrameBuffer::getPhosphor(uInt8 c1, uInt8 c2)
{
@ -851,8 +721,8 @@ VideoMode FrameBuffer::getSavedVidMode()
state == EventHandler::S_PAUSE ||
state == EventHandler::S_MENU ||
state == EventHandler::S_CMDMENU);
int zoom = (inTIAMode ? myOSystem->settings().getInt("zoom_tia") :
myOSystem->settings().getInt("zoom_ui") );
int zoom = (inTIAMode ? myOSystem->settings().getInt("zoom_tia") : 1);
//FIXME myOSystem->settings().getInt("zoom_ui") );
myCurrentModeList = &myWindowedModeList;
myCurrentModeList->setByZoom(zoom);
@ -860,3 +730,130 @@ VideoMode FrameBuffer::getSavedVidMode()
return myCurrentModeList->current();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB)
{
hLine(x + 1, y, x + w - 2, colorA);
hLine(x, y + 1, x + w - 1, colorA);
vLine(x, y + 1, y + h - 2, colorA);
vLine(x + 1, y, y + h - 1, colorA);
hLine(x + 1, y + h - 2, x + w - 1, colorB);
hLine(x + 1, y + h - 1, x + w - 2, colorB);
vLine(x + w - 1, y + 1, y + h - 2, colorB);
vLine(x + w - 2, y + 1, y + h - 1, colorB);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style)
{
switch(style)
{
case kSolidLine:
hLine(x, y, x + w - 1, color);
hLine(x, y + h - 1, x + w - 1, color);
vLine(x, y, y + h - 1, color);
vLine(x + w - 1, y, y + h - 1, color);
break;
case kDashLine:
unsigned int i, skip, lwidth = 1;
for(i = x, skip = 1; i < x+w-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
hLine(i, y, i + lwidth, color);
hLine(i, y + h - 1, i + lwidth, color);
}
}
for(i = y, skip = 1; i < y+h-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
vLine(x, i, i + lwidth, color);
vLine(x + w - 1, i, i + lwidth, color);
}
}
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawString(const GUI::Font* font, const string& s,
int x, int y, int w,
int color, TextAlignment align,
int deltax, bool useEllipsis)
{
const int leftX = x, rightX = x + w;
unsigned int i;
int width = font->getStringWidth(s);
string str;
if(useEllipsis && width > w)
{
// String is too wide. So we shorten it "intelligently", by replacing
// parts of it by an ellipsis ("..."). There are three possibilities
// for this: replace the start, the end, or the middle of the string.
// What is best really depends on the context; but unless we want to
// make this configurable, replacing the middle probably is a good
// compromise.
const int ellipsisWidth = font->getStringWidth("...");
// SLOW algorithm to remove enough of the middle. But it is good enough for now.
const int halfWidth = (w - ellipsisWidth) / 2;
int w2 = 0;
for(i = 0; i < s.size(); ++i)
{
int charWidth = font->getCharWidth(s[i]);
if(w2 + charWidth > halfWidth)
break;
w2 += charWidth;
str += s[i];
}
// At this point we know that the first 'i' chars are together 'w2'
// pixels wide. We took the first i-1, and add "..." to them.
str += "...";
// The original string is width wide. Of those we already skipped past
// w2 pixels, which means (width - w2) remain.
// The new str is (w2+ellipsisWidth) wide, so we can accomodate about
// (w - (w2+ellipsisWidth)) more pixels.
// Thus we skip ((width - w2) - (w - (w2+ellipsisWidth))) =
// (width + ellipsisWidth - w)
int skip = width + ellipsisWidth - w;
for(; i < s.size() && skip > 0; ++i)
skip -= font->getCharWidth(s[i]);
// Append the remaining chars, if any
for(; i < s.size(); ++i)
str += s[i];
width = font->getStringWidth(str);
}
else
str = s;
if(align == kTextAlignCenter)
x = x + (w - width - 1)/2;
else if(align == kTextAlignRight)
x = x + w - width;
x += deltax;
for(i = 0; i < str.size(); ++i)
{
w = font->getCharWidth(str[i]);
if(x+w > rightX)
break;
if(x >= leftX)
drawChar(font, str[i], x, y, color);
x += w;
}
}

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.96 2008-05-30 19:07:55 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.97 2008-06-13 13:14:51 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -21,6 +21,7 @@
#include <SDL.h>
class FBSurface;
class OSystem;
class Console;
@ -33,20 +34,6 @@ namespace GUI {
#include "VideoModeList.hxx"
#include "bspf.hxx"
// Text alignment modes for drawString()
enum TextAlignment {
kTextAlignLeft,
kTextAlignCenter,
kTextAlignRight
};
// Line types for drawing rectangular frames
enum FrameStyle {
kSolidLine,
kDashLine
};
// Different types of framebuffer derived objects
enum BufferType {
kSoftBuffer,
@ -98,10 +85,11 @@ enum {
display in Stella. All graphics ports should derive from this class for
platform-specific video stuff.
All GUI elements (ala ScummVM) are drawn here as well.
All GUI elements (ala ScummVM) are drawn into FBSurfaces, which are in
turn drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.96 2008-05-30 19:07:55 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.97 2008-06-13 13:14:51 stephena Exp $
*/
class FrameBuffer
{
@ -125,8 +113,6 @@ class FrameBuffer
@param title The title of the window
@param width The width of the framebuffer
@param height The height of the framebuffer
@return False on any errors, else true
*/
bool initialize(const string& title, uInt32 width, uInt32 height);
@ -263,51 +249,6 @@ class FrameBuffer
*/
virtual void setUIPalette(const uInt32* palette);
/**
This method should be called to draw a rectangular box with sides
at the specified coordinates.
@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 colorA Lighter color for outside line.
@param colorB Darker color for inside line.
*/
void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB);
/**
This method should be called to draw a framed rectangle.
I'm not exactly sure what it is, so I can't explain it :)
@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
*/
void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style = kSolidLine);
/**
This method should be called to draw the specified string.
@param font The font to draw the string with
@param str The string to draw
@param x The x coordinate
@param y The y coordinate
@param w The width of the string area
@param h The height of the string area
@param color The color of the text
@param align The alignment of the text in the string width area
@param deltax
@param useEllipsis Whether to use '...' when the string is too long
*/
void drawString(const GUI::Font* font, const string& str, int x, int y, int w,
int color, TextAlignment align = kTextAlignLeft,
int deltax = 0, bool useEllipsis = true);
/**
Informs the Framebuffer of a change in EventHandler state.
*/
@ -318,111 +259,6 @@ class FrameBuffer
// in derived classes.
//////////////////////////////////////////////////////////////////////
public:
/**
This method 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) const = 0;
/**
This method should be 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, int color) = 0;
/**
This method should be 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, int color) = 0;
/**
This method should be 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,
int color) = 0;
/**
This method should be called to draw the specified character.
@param font The font to use to draw the character
@param c The character to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
*/
virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y,
int color) = 0;
/**
This method should be called to draw the bitmap image.
@param bitmap The data to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
@param h The height of the data image
*/
virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color,
Int32 h = 8) = 0;
/**
This method should be called to draw an SDL surface.
@param surface The data to draw
@param x The x coordinate
@param y The y coordinate
*/
virtual void drawSurface(const GUI::Surface* surface, Int32 x, Int32 y) = 0;
/**
This method should be called to convert and copy a given row of RGB
data into an SDL surface.
@param surface The data to draw
@param row The row of the surface the data should be placed in
@param data The data in uInt8 R/G/B format
@param rowbytes The number of bytes in row of 'data'
*/
virtual void bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const = 0;
/**
This method should be called to translate the given coordinates
to their unzoomed/unscaled equivalents.
@param x X coordinate to translate
@param y Y coordinate to translate
*/
virtual void translateCoords(Int32& x, Int32& y) const = 0;
/**
This method should be called to add a dirty rectangle
(ie, an area of the screen that has changed)
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
*/
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0;
/**
Enable/disable phosphor effect.
*/
@ -437,20 +273,29 @@ class FrameBuffer
*/
virtual Uint32 mapRGB(Uint8 r, Uint8 g, Uint8 b) const = 0;
/**
This method is called to create a surface compatible with the one
currently in use, but having the given dimensions.
@param width The requested width of the new surface.
@param height The requested height of the new surface.
*/
virtual GUI::Surface* createSurface(int width, int height) const = 0;
/**
This method is called to query the type of the FrameBuffer.
*/
virtual BufferType type() const = 0;
/**
This method is called to create a surface compatible with the one
currently in use, but having the given dimensions.
@param w The requested width of the new surface.
@param h The requested height of the new surface.
@param useBase Use the base surface instead of creating a new one
*/
virtual FBSurface* createSurface(int w, int h, bool useBase = false) const = 0;
/**
This method 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) const = 0;
protected:
/**
This method is called to initialize the video subsystem
@ -476,16 +321,6 @@ class FrameBuffer
*/
virtual void drawMediaSource() = 0;
/**
This method is called before any drawing is done (per-frame).
*/
virtual void preFrameUpdate() = 0;
/**
This method is called after any drawing is done (per-frame).
*/
virtual void postFrameUpdate() = 0;
/**
This method is called to provide information about the FrameBuffer.
*/
@ -495,6 +330,21 @@ class FrameBuffer
// The parent system for the framebuffer
OSystem* myOSystem;
// The SDL video buffer
SDL_Surface* myScreen;
// SDL initialization flags
uInt32 mySDLFlags;
// Indicates if the TIA area should be redrawn
bool theRedrawTIAIndicator;
// Use phosphor effect (aka no flicker on 30Hz screens)
bool myUsePhosphor;
// Amount to blend when using phosphor effect
int myPhosphorBlend;
// Dimensions of the base image, before scaling.
// All external GUI items should refer to these dimensions,
// since this is the *real* size of the image.
@ -507,25 +357,10 @@ class FrameBuffer
// Dimensions of the SDL window (not always the same as the image)
SDL_Rect myScreenDim;
// The SDL video buffer
SDL_Surface* myScreen;
// SDL initialization flags
uInt32 mySDLFlags;
// TIA palettes for normal and phosphor modes
Uint32 myDefPalette[256+kNumColors];
Uint32 myAvgPalette[256][256];
// Indicates if the TIA area should be redrawn
bool theRedrawTIAIndicator;
// Use phosphor effect (aka no flicker on 30Hz screens)
bool myUsePhosphor;
// Amount to blend when using phosphor effect
int myPhosphorBlend;
private:
/**
Set the icon for the main SDL window.
@ -593,4 +428,209 @@ class FrameBuffer
VideoModeList* myCurrentModeList;
};
/**
This class is basically a thin wrapper around an SDL_Surface structure.
We do it this way so the SDL stuff won't be dragged into the depths of
the codebase. All drawing is done into FBSurfaces, which are then
drawn into the FrameBuffer. Each FrameBuffer-derived class is
responsible for extending an FBSurface object suitable to the
FrameBuffer type.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.97 2008-06-13 13:14:51 stephena Exp $
*/
// Text alignment modes for drawString()
enum TextAlignment {
kTextAlignLeft,
kTextAlignCenter,
kTextAlignRight
};
// Line types for drawing rectangular frames
enum FrameStyle {
kSolidLine,
kDashLine
};
class FBSurface
{
public:
/**
Creates a new FBSurface object
*/
FBSurface() { }
/**
Destructor
*/
virtual ~FBSurface() { }
/**
This method should be 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, int color) = 0;
/**
This method should be 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, int color) = 0;
/**
This method should be 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,
int color) = 0;
/**
This method should be called to draw the specified character.
@param font The font to use to draw the character
@param c The character to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
*/
virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y,
int color) = 0;
/**
This method should be called to draw the bitmap image.
@param bitmap The data to draw
@param x The x coordinate
@param y The y coordinate
@param color The color of the character
@param h The height of the data image
*/
virtual void drawBitmap(uInt32* bitmap, Int32 x, Int32 y, int color,
Int32 h = 8) = 0;
/**
This method should be called to add a dirty rectangle
(ie, an area of the screen that has changed)
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
*/
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0;
/**
This method should be called to center the position of the surface.
*/
virtual void centerPos() = 0;
/**
This method should be called to set the position of the surface.
*/
virtual void setPos(uInt32 x, uInt32 y) = 0;
/**
This method answers the current coordinates of the surface.
*/
virtual void getPos(uInt32& x, uInt32& y) const = 0;
/**
This method should be called to translate the given coordinates
to the surface coordinates.
@param x X coordinate to translate
@param y Y coordinate to translate
*/
virtual void translateCoords(Int32& x, Int32& y) const = 0;
/**
This method should be called to draw the surface to the screen.
*/
virtual void update() = 0;
/**
This method should be called to draw a rectangular box with sides
at the specified coordinates.
@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 colorA Lighter color for outside line.
@param colorB Darker color for inside line.
*/
void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB);
/**
This method should be called to draw a framed rectangle.
I'm not exactly sure what it is, so I can't explain it :)
@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
*/
void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style = kSolidLine);
/**
This method should be called to draw the specified string.
@param font The font to draw the string with
@param str The string to draw
@param x The x coordinate
@param y The y coordinate
@param w The width of the string area
@param h The height of the string area
@param color The color of the text
@param align The alignment of the text in the string width area
@param deltax
@param useEllipsis Whether to use '...' when the string is too long
*/
void drawString(const GUI::Font* font, const string& str, int x, int y, int w,
int color, TextAlignment align = kTextAlignLeft,
int deltax = 0, bool useEllipsis = true);
};
#endif
#if 0
/**
This method should be called to draw an SDL surface.
@param surface The data to draw
@param x The x coordinate
@param y The y coordinate
*/
virtual void drawSurface(const GUI::Surface* surface, Int32 x, Int32 y) = 0;
/**
This method should be called to convert and copy a given row of RGB
data into an SDL surface.
@param surface The data to draw
@param row The row of the surface the data should be placed in
@param data The data in uInt8 R/G/B format
@param rowbytes The number of bytes in row of 'data'
*/
virtual void bytesToSurface(GUI::Surface* surface, int row,
uInt8* data, int rowbytes) const = 0;
#endif

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: AboutDialog.cxx,v 1.24 2008-03-23 16:22:45 stephena Exp $
// $Id: AboutDialog.cxx,v 1.25 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -90,7 +90,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title, string* &dsc
case 1:
title = string("Stella ") + STELLA_VERSION;
ADD_ATEXT("\\CA multi-platform Atari 2600 VCS emulator");
ADD_ATEXT(string("\\C\\c2") + instance()->features());
ADD_ATEXT(string("\\C\\c2") + instance().features());
ADD_ALINE;
ADD_ATEXT("\\CCopyright (C) 1995-2008 The Stella team");
ADD_ATEXT("\\Chttp://stella.sourceforge.net");

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: AudioDialog.cxx,v 1.27 2008-03-23 16:22:46 stephena Exp $
// $Id: AudioDialog.cxx,v 1.28 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -29,6 +29,7 @@
#include "Menu.hxx"
#include "OSystem.hxx"
#include "PopUpWidget.hxx"
#include "StringList.hxx"
#include "Settings.hxx"
#include "Sound.hxx"
#include "Widget.hxx"
@ -38,7 +39,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
const GUI::Font& font, int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
: Dialog(osystem, parent, x, y, w, h)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
@ -49,6 +50,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
int lwidth = font.getStringWidth("Fragment Size: "),
pwidth = font.getStringWidth("4096");
WidgetArray wid;
StringList items;
// Set real dimensions
// _w = 35 * fontWidth + 10;
@ -70,39 +72,37 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent,
ypos += lineHeight + 4;
// Fragment size
items.clear();
items.push_back("128");
items.push_back("256");
items.push_back("512");
items.push_back("1024");
items.push_back("2048");
items.push_back("4096");
myFragsizePopup = new PopUpWidget(this, font, xpos, ypos,
pwidth + myVolumeLabel->getWidth() - 4, lineHeight,
"Fragment size: ", lwidth);
myFragsizePopup->appendEntry("128", 1);
myFragsizePopup->appendEntry("256", 2);
myFragsizePopup->appendEntry("512", 3);
myFragsizePopup->appendEntry("1024", 4);
myFragsizePopup->appendEntry("2048", 5);
myFragsizePopup->appendEntry("4096", 6);
items, "Fragment size: ", lwidth);
wid.push_back(myFragsizePopup);
ypos += lineHeight + 4;
// Output frequency
items.clear();
items.push_back("11025");
items.push_back("22050");
items.push_back("31400");
items.push_back("44100");
items.push_back("48000");
myFreqPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth + myVolumeLabel->getWidth() - 4, lineHeight,
"Output freq: ", lwidth);
myFreqPopup->appendEntry("11025", 1);
myFreqPopup->appendEntry("22050", 2);
myFreqPopup->appendEntry("31400", 3);
myFreqPopup->appendEntry("44100", 4);
myFreqPopup->appendEntry("48000", 5);
items, "Output freq: ", lwidth);
wid.push_back(myFreqPopup);
ypos += lineHeight + 4;
// TIA frequency
// ... use same items as above
myTiaFreqPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth + myVolumeLabel->getWidth() - 4, lineHeight,
"TIA freq: ", lwidth);
myTiaFreqPopup->appendEntry("11025", 1);
myTiaFreqPopup->appendEntry("22050", 2);
myTiaFreqPopup->appendEntry("31400", 3);
myTiaFreqPopup->appendEntry("44100", 4);
myTiaFreqPopup->appendEntry("48000", 5);
items, "TIA freq: ", lwidth);
wid.push_back(myTiaFreqPopup);
ypos += lineHeight + 4;
@ -140,45 +140,46 @@ void AudioDialog::loadConfig()
int i;
// Volume
myVolumeSlider->setValue(instance()->settings().getInt("volume"));
myVolumeLabel->setLabel(instance()->settings().getString("volume"));
myVolumeSlider->setValue(instance().settings().getInt("volume"));
myVolumeLabel->setLabel(instance().settings().getString("volume"));
// Fragsize
i = instance()->settings().getInt("fragsize");
if(i == 128) i = 1;
else if(i == 256) i = 2;
else if(i == 512) i = 3;
else if(i == 1024) i = 4;
else if(i == 2048) i = 5;
else if(i == 4096) i = 6;
myFragsizePopup->setSelectedTag(i);
i = instance().settings().getInt("fragsize");
if(i == 128) i = 0;
else if(i == 256) i = 1;
else if(i == 512) i = 2;
else if(i == 1024) i = 3;
else if(i == 2048) i = 4;
else if(i == 4096) i = 5;
else i = 2; // default to '512'
myFragsizePopup->setSelected(i);
// Output frequency
i = instance()->settings().getInt("freq");
if(i == 11025) i = 1;
else if(i == 22050) i = 2;
else if(i == 31400) i = 3;
else if(i == 44100) i = 4;
else if(i == 48000) i = 5;
else i = 3; // default to '31400'
myFreqPopup->setSelectedTag(i);
i = instance().settings().getInt("freq");
if(i == 11025) i = 0;
else if(i == 22050) i = 1;
else if(i == 31400) i = 2;
else if(i == 44100) i = 3;
else if(i == 48000) i = 4;
else i = 2; // default to '31400'
myFreqPopup->setSelected(i);
// TIA frequency
i = instance()->settings().getInt("tiafreq");
if(i == 11025) i = 1;
else if(i == 22050) i = 2;
else if(i == 31400) i = 3;
else if(i == 44100) i = 4;
else if(i == 48000) i = 5;
else i = 3; // default to '31400'
myTiaFreqPopup->setSelectedTag(i);
i = instance().settings().getInt("tiafreq");
if(i == 11025) i = 0;
else if(i == 22050) i = 1;
else if(i == 31400) i = 2;
else if(i == 44100) i = 3;
else if(i == 48000) i = 4;
else i = 2; // default to '31400'
myTiaFreqPopup->setSelected(i);
// Clip volume
b = instance()->settings().getBool("clipvol");
b = instance().settings().getBool("clipvol");
myClipVolumeCheckbox->setState(b);
// Enable sound
b = instance()->settings().getBool("sound");
b = instance().settings().getBool("sound");
mySoundEnableCheckbox->setState(b);
// Make sure that mutually-exclusive items are not enabled at the same time
@ -188,14 +189,14 @@ void AudioDialog::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioDialog::saveConfig()
{
Settings& settings = instance()->settings();
Settings& settings = instance().settings();
string s;
bool b;
int i;
// Volume
i = myVolumeSlider->getValue();
instance()->sound().setVolume(i);
instance().sound().setVolume(i);
// Fragsize
s = myFragsizePopup->getSelectedString();
@ -215,12 +216,12 @@ void AudioDialog::saveConfig()
// Enable/disable sound (requires a restart to take effect)
b = mySoundEnableCheckbox->getState();
instance()->sound().setEnabled(b);
instance().sound().setEnabled(b);
// Only force a re-initialization when necessary, since it can
// be a time-consuming operation
if(&instance()->console())
instance()->console().initializeAudio();
if(&instance().console())
instance().console().initializeAudio();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -229,13 +230,9 @@ void AudioDialog::setDefaults()
myVolumeSlider->setValue(100);
myVolumeLabel->setLabel("100");
#ifdef WIN32
myFragsizePopup->setSelectedTag(5);
#else
myFragsizePopup->setSelectedTag(3);
#endif
myFreqPopup->setSelectedTag(3);
myTiaFreqPopup->setSelectedTag(3);
myFragsizePopup->setSelected(2); // 512 bytes
myFreqPopup->setSelected(2); // 31400 Hz
myTiaFreqPopup->setSelected(2); // 31400 Hz
myClipVolumeCheckbox->setState(true);
mySoundEnableCheckbox->setState(true);

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: BrowserDialog.cxx,v 1.30 2008-03-23 16:22:46 stephena Exp $
// $Id: BrowserDialog.cxx,v 1.31 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -41,7 +41,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: Dialog(boss->instance(), boss->parent(), x, y, w, h),
: Dialog(&boss->instance(), &boss->parent(), x, y, w, h),
CommandSender(boss),
_fileList(NULL),
_currentPath(NULL),

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: CheckListWidget.cxx,v 1.16 2008-02-06 13:45:23 stephena Exp $
// $Id: CheckListWidget.cxx,v 1.17 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -106,17 +106,17 @@ void CheckListWidget::setLine(int line, const string& str, const bool& state)
void CheckListWidget::drawWidget(bool hilite)
{
//cerr << "CheckListWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int i, pos, len = _list.size();
string buffer;
int deltax;
// Draw a thin frame around the list and to separate columns
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
s.hLine(_x, _y, _x + _w - 1, kColor);
s.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
s.vLine(_x, _y, _y + _h - 1, kColor);
fb.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor);
s.vLine(_x + CheckboxWidget::boxSize() + 5, _y, _y + _h - 1, kColor);
// Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++)
@ -134,13 +134,11 @@ void CheckListWidget::drawWidget(bool hilite)
if (_selectedItem == pos)
{
if (_hasFocus && !_editMode)
fb.fillRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
_w - r.left, _fontHeight,
kTextColorHi);
s.fillRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
_w - r.left, _fontHeight, kTextColorHi);
else
fb.frameRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
_w - r.left, _fontHeight,
kTextColorHi);
s.frameRect(_x + r.left - 3, _y + 1 + _fontHeight * i,
_w - r.left, _fontHeight, kTextColorHi);
}
if (_selectedItem == pos && _editMode)
@ -149,14 +147,14 @@ void CheckListWidget::drawWidget(bool hilite)
adjustOffset();
deltax = -_editScrollOffset;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
}
else
{
buffer = _list[pos];
deltax = 0;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
}
}

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: CommandDialog.cxx,v 1.19 2008-05-17 15:16:45 stephena Exp $
// $Id: CommandDialog.cxx,v 1.20 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -190,29 +190,29 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kSnapshotCmd:
instance()->eventHandler().leaveMenuMode();
instance()->eventHandler().refreshDisplay(true);
instance()->eventHandler().handleEvent(Event::TakeSnapshot, 1);
instance().eventHandler().leaveMenuMode();
instance().eventHandler().refreshDisplay(true);
instance().eventHandler().handleEvent(Event::TakeSnapshot, 1);
break;
case kFormatCmd:
instance()->eventHandler().leaveMenuMode();
instance()->console().toggleFormat();
instance().eventHandler().leaveMenuMode();
instance().console().toggleFormat();
break;
case kPaletteCmd:
instance()->eventHandler().leaveMenuMode();
instance()->console().togglePalette();
instance().eventHandler().leaveMenuMode();
instance().console().togglePalette();
break;
case kReloadRomCmd:
instance()->eventHandler().leaveMenuMode();
instance()->deleteConsole();
instance()->createConsole();
instance().eventHandler().leaveMenuMode();
instance().deleteConsole();
instance().createConsole();
break;
case kExitCmd:
instance()->eventHandler().handleEvent(Event::LauncherMode, 1);
instance().eventHandler().handleEvent(Event::LauncherMode, 1);
break;
}
@ -220,14 +220,14 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
// State commands require you to exit the menu manually
if(consoleCmd)
{
instance()->eventHandler().leaveMenuMode();
instance()->eventHandler().handleEvent(event, 1);
instance()->console().switches().update();
instance()->console().mediaSource().update();
instance()->eventHandler().handleEvent(event, 0);
instance().eventHandler().leaveMenuMode();
instance().eventHandler().handleEvent(event, 1);
instance().console().switches().update();
instance().console().mediaSource().update();
instance().eventHandler().handleEvent(event, 0);
}
else if(stateCmd)
{
instance()->eventHandler().handleEvent(event, 1);
instance().eventHandler().handleEvent(event, 1);
}
}

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: ContextMenu.cxx,v 1.11 2008-02-06 13:45:20 stephena Exp $
// $Id: ContextMenu.cxx,v 1.1 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -26,35 +26,17 @@
#include "ContextMenu.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font)
: Dialog(boss->instance(), boss->parent(), 0, 0, 16, 16),
ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font,
const StringList& items, int cmd)
: Dialog(&boss->instance(), &boss->parent(), 0, 0, 16, 16),
CommandSender(boss),
_entries(items),
_currentItem(-1),
_selectedItem(-1),
_rowHeight(font.getLineHeight()),
_font(&font)
_font(&font),
_cmd(cmd)
{
// Context menus pop up wherever the mouse is clicked
setCenter(false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ContextMenu::~ContextMenu()
{
_entries.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::show()
{
_selectedItem = -1;
parent()->addDialog(this);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setList(const StringList& list)
{
_entries = list;
// Resize to largest string
int maxwidth = 0;
for(unsigned int i = 0; i < _entries.size(); ++i)
@ -64,10 +46,67 @@ void ContextMenu::setList(const StringList& list)
maxwidth = length;
}
_x = _y = 0;
_w = maxwidth + 8;
_h = _rowHeight * _entries.size() + 4;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ContextMenu::~ContextMenu()
{
_entries.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::show(uInt32 x, uInt32 y, int item)
{
// Make sure position is set *after* the dialog is added, since the surface
// may not exist before then
parent().addDialog(this);
surface().setPos(x, y);
setSelected(item);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelected(int item)
{
if(item >= 0 && item < (int)_entries.size())
_selectedItem = _currentItem = item;
else
_selectedItem = _currentItem = -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelected(const string& name)
{
for(unsigned int item = 0; item < _entries.size(); ++item)
{
if(_entries[item] == name)
{
setSelected(item);
return;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelectedMax()
{
setSelected(_entries.size() - 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::clearSelection()
{
_selectedItem = _currentItem = -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int ContextMenu::getSelected() const
{
return _selectedItem;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& ContextMenu::getSelectedString() const
{
@ -84,7 +123,7 @@ void ContextMenu::handleMouseDown(int x, int y, int button, int clickCount)
if(x >= _x && x <= _x+_w && y >= _y && y <= _y+_h)
sendSelection();
else
parent()->removeDialog();
parent().removeDialog();
}
}
@ -106,32 +145,61 @@ void ContextMenu::handleMouseMoved(int x, int y, int button)
return;
// ...and update the selection accordingly
setSelection(item);
drawCurrentSelection(item);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleKeyDown(int ascii, int keycode, int modifiers)
{
switch(ascii)
handleEvent(instance().eventHandler().eventForKey(keycode, kMenuMode));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleJoyDown(int stick, int button)
{
handleEvent(instance().eventHandler().eventForJoyButton(stick, button, kMenuMode));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleJoyAxis(int stick, int axis, int value)
{
if(value != 0) // we don't care about 'axis up' events
handleEvent(instance().eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ContextMenu::handleJoyHat(int stick, int hat, int value)
{
handleEvent(instance().eventHandler().eventForJoyHat(stick, hat, value, kMenuMode));
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::handleEvent(Event::Type e)
{
switch(e)
{
case 27: // escape
parent()->removeDialog();
break;
case '\n': // enter/return
case '\r':
case Event::UISelect:
sendSelection();
break;
case 256+17: // up arrow
case Event::UIUp:
case Event::UILeft:
moveUp();
break;
case 256+18: // down arrow
case Event::UIDown:
case Event::UIRight:
moveDown();
break;
case 256+22: // home
setSelection(0);
case Event::UIHome:
drawCurrentSelection(0);
break;
case 256+23: // end
setSelection(_entries.size()-1);
case Event::UIEnd:
drawCurrentSelection(_entries.size()-1);
break;
case Event::UICancel:
parent().removeDialog();
break;
default:
break;
}
}
@ -146,12 +214,12 @@ int ContextMenu::findItem(int x, int y) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::setSelection(int item)
void ContextMenu::drawCurrentSelection(int item)
{
if(item != _selectedItem)
if(item != _currentItem)
{
// Change selection
_selectedItem = item;
_currentItem = item;
setDirty(); draw();
}
}
@ -159,26 +227,36 @@ void ContextMenu::setSelection(int item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::sendSelection()
{
// We remove the dialog when the user has selected an item
parent()->removeDialog();
// Send any command associated with the selection
_selectedItem = _currentItem;
sendCommand(_cmd ? _cmd : kCMenuItemSelectedCmd, _selectedItem, -1);
sendCommand(kCMenuItemSelectedCmd, _selectedItem, -1);
// We remove the dialog when the user has selected an item
parent().removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::moveUp()
{
int item = _selectedItem;
int item = _currentItem;
if(item > 0)
setSelection(--item);
drawCurrentSelection(--item);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::moveDown()
{
int item = _selectedItem;
int item = _currentItem;
if(item < (int)_entries.size() - 1)
setSelection(++item);
drawCurrentSelection(++item);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::center()
{
// Adjust dialog, making sure it doesn't fall outside screen area
// FIXME - add code to do this ...
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -187,29 +265,32 @@ void ContextMenu::drawDialog()
// Normally we add widgets and let Dialog::draw() take care of this
// logic. But for some reason, this Dialog was written differently
// by the ScummVM guys, so I'm not going to mess with it.
FBSurface& s = surface();
if(_dirty)
{
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = surface();
fb.fillRect(_x+1, _y+1, _w-2, _h-2, kWidColor);
fb.box(_x, _y, _w, _h, kColor, kShadowColor);
s.fillRect(_x+1, _y+1, _w-2, _h-2, kWidColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor);
// Draw the entries
int count = _entries.size();
for(int i = 0; i < count; i++)
{
bool hilite = i == _selectedItem;
bool hilite = i == _currentItem;
int x = _x + 2;
int y = _y + 2 + i * _rowHeight;
int w = _w - 4;
string& name = _entries[i];
fb.fillRect(x, y, w, _rowHeight, hilite ? kTextColorHi : kWidColor);
fb.drawString(_font, name, x + 1, y + 2, w - 2,
hilite ? kWidColor : kTextColor);
if(hilite) s.fillRect(x, y, w, _rowHeight, kTextColorHi);
s.drawString(_font, _entries[i], x + 1, y + 2, w - 2,
hilite ? kWidColor : kTextColor);
}
s.addDirtyRect(_x, _y, _w, _h);
_dirty = false;
fb.addDirtyRect(_x, _y, _w, _h);
}
// Commit surface changes to screen
s.update();
}

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: ContextMenu.hxx,v 1.7 2008-02-06 13:45:20 stephena Exp $
// $Id: ContextMenu.hxx,v 1.1 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,27 +36,47 @@ enum {
* Popup context menu which, when clicked, "pop up" a list of items and
* lets the user pick on of them.
*
* Implementation wise, when the user selects an item, then a kCMenuItemSelectedCmd
* Implementation wise, when the user selects an item, then the given 'cmd'
* is broadcast, with data being equal to the tag value of the selected entry.
*/
class ContextMenu : public Dialog, public CommandSender
{
public:
ContextMenu(GuiObject* boss, const GUI::Font& font);
ContextMenu(GuiObject* boss, const GUI::Font& font,
const StringList& items, int cmd = 0);
virtual ~ContextMenu();
/** Show context menu onscreen */
void show();
/** Show context menu onscreen at the specified coordinates */
void show(uInt32 x, uInt32 y, int item = -1);
void setList(const StringList& list);
/** Select the entry at the given index. */
void setSelected(int item);
/** Select the first entry matching the given name. */
void setSelected(const string& name);
/** Select the highest/last entry in the internal list. */
void setSelectedMax();
/** Clear selection (reset to default). */
void clearSelection();
/** Accessor methods for the currently selected item. */
int getSelected() const;
const string& getSelectedString() const;
int getSelected() const { return _selectedItem; }
/** This dialog uses its own positioning, so we override Dialog::center() */
void center();
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);
void handleMouseMoved(int x, int y, int button);
void handleKeyDown(int ascii, int keycode, int modifiers);
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
void handleJoyDown(int stick, int button);
void handleJoyAxis(int stick, int axis, int value);
bool handleJoyHat(int stick, int hat, int value);
void handleEvent(Event::Type e);
void drawDialog();
@ -64,7 +84,7 @@ class ContextMenu : public Dialog, public CommandSender
void drawMenuEntry(int entry, bool hilite);
int findItem(int x, int y) const;
void setSelection(int item);
void drawCurrentSelection(int item);
void moveUp();
void moveDown();
@ -74,11 +94,13 @@ class ContextMenu : public Dialog, public CommandSender
protected:
StringList _entries;
int _currentItem;
int _selectedItem;
int _rowHeight;
private:
const GUI::Font* _font;
int _cmd;
};
#endif

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.cxx,v 1.60 2008-03-25 13:11:34 stephena Exp $
// $Id: Dialog.cxx,v 1.61 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -36,8 +36,8 @@
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog::Dialog(OSystem* instance, DialogContainer* parent,
int x, int y, int w, int h)
: GuiObject(instance, parent, x, y, w, h),
int x, int y, int w, int h, bool isBase)
: GuiObject(*instance, *parent, *this, x, y, w, h),
_mouseWidget(0),
_focusedWidget(0),
_dragWidget(0),
@ -45,7 +45,9 @@ Dialog::Dialog(OSystem* instance, DialogContainer* parent,
_cancelWidget(0),
_visible(true),
_center(true),
_isBase(isBase),
_ourTab(NULL),
_surface(NULL),
_focusID(0)
{
}
@ -60,6 +62,8 @@ Dialog::~Dialog()
_firstWidget = NULL;
_ourButtonGroup.clear();
delete _surface;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,6 +72,17 @@ void Dialog::open()
_result = 0;
_visible = true;
// Make sure we have a valid surface to draw into
// Technically, this shouldn't be needed until drawDialog(), but some
// dialogs cause drawing to occur within loadConfig()
// Base surfaces are typically large, and will probably cause slow
// performance if we update the whole area each frame
// Instead, dirty rectangle updates should be performed
if(_surface == NULL)
_surface = instance().frameBuffer().createSurface(_w, _h, _isBase);
center();
loadConfig();
// (Re)-build the focus list to use for the widgets which are currently
@ -85,18 +100,14 @@ void Dialog::close()
}
releaseFocus();
parent()->removeDialog();
parent().removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::center()
{
FrameBuffer& fb = instance()->frameBuffer();
if(_center && &fb)
{
_x = (fb.baseWidth() - _w) / 2;
_y = (fb.baseHeight() - _h) / 2;
}
if(_center && _surface)
_surface->centerPos();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -225,13 +236,14 @@ void Dialog::drawDialog()
if(!isVisible())
return;
FBSurface& s = surface();
if(_dirty)
{
// cerr << "Dialog::drawDialog()\n";
FrameBuffer& fb = instance()->frameBuffer();
cerr << "Dialog::drawDialog(): w = " << _w << ", h = " << _h << endl << endl;
fb.fillRect(_x+1, _y+1, _w-2, _h-2, kDlgColor);
fb.box(_x, _y, _w, _h, kColor, kShadowColor);
s.fillRect(_x+1, _y+1, _w-2, _h-2, kDlgColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor);
// Make all child widget dirty
Widget* w = _firstWidget;
@ -248,12 +260,13 @@ void Dialog::drawDialog()
// Draw outlines for focused widgets
redrawFocus();
// Tell the framebuffer this area is dirty
fb.addDirtyRect(_x, _y, _w, _h);
//cerr << "dirty: x = " << _x << ", y = " << _y << ", w = " << _w << ", h = " << _h << endl;
// Tell the surface this area is dirty
s.addDirtyRect(_x, _y, _w, _h);
_dirty = false;
}
// Commit surface changes to screen
s.update();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -318,7 +331,7 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
// Detect selection of previous and next tab headers and objects
// For some strange reason, 'tab' needs to be interpreted as keycode,
// not ascii??
if(instance()->eventHandler().kbdShift(modifiers))
if(instance().eventHandler().kbdShift(modifiers))
{
if(ascii == 256+20 && _ourTab) // left arrow
{
@ -339,7 +352,7 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers)
// Check the keytable now, since we might get one of the above events,
// which must always be processed before any widget sees it.
if(e == Event::NoType)
e = instance()->eventHandler().eventForKey(keycode, kMenuMode);
e = instance().eventHandler().eventForKey(keycode, kMenuMode);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
@ -414,7 +427,7 @@ void Dialog::handleMouseMoved(int x, int y, int button)
void Dialog::handleJoyDown(int stick, int button)
{
Event::Type e =
instance()->eventHandler().eventForJoyButton(stick, button, kMenuMode);
instance().eventHandler().eventForJoyButton(stick, button, kMenuMode);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
@ -439,7 +452,7 @@ void Dialog::handleJoyUp(int stick, int button)
void Dialog::handleJoyAxis(int stick, int axis, int value)
{
Event::Type e =
instance()->eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode);
instance().eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.
@ -456,7 +469,7 @@ void Dialog::handleJoyAxis(int stick, int axis, int value)
bool Dialog::handleJoyHat(int stick, int hat, int value)
{
Event::Type e =
instance()->eventHandler().eventForJoyHat(stick, hat, value, kMenuMode);
instance().eventHandler().eventForJoyHat(stick, hat, value, kMenuMode);
// Unless a widget has claimed all responsibility for data, we assume
// that if an event exists for the given data, it should have priority.

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.37 2008-03-23 16:22:46 stephena Exp $
// $Id: Dialog.hxx,v 1.38 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -22,6 +22,7 @@
#ifndef DIALOG_HXX
#define DIALOG_HXX
class FBSurface;
class OSystem;
class DialogContainer;
class TabWidget;
@ -46,7 +47,7 @@ class TabWidget;
This is the base class for all dialog boxes.
@author Stephen Anthony
@version $Id: Dialog.hxx,v 1.37 2008-03-23 16:22:46 stephena Exp $
@version $Id: Dialog.hxx,v 1.38 2008-06-13 13:14:51 stephena Exp $
*/
class Dialog : public GuiObject
{
@ -60,11 +61,12 @@ class Dialog : public GuiObject
public:
Dialog(OSystem* instance, DialogContainer* parent,
int x, int y, int w, int h);
int x, int y, int w, int h, bool isBase = false);
virtual ~Dialog();
bool isVisible() const { return _visible; }
bool isBase() const { return _isBase; }
virtual void open();
virtual void close();
@ -84,6 +86,8 @@ class Dialog : public GuiObject
void setFocus(Widget* w);
void setCenter(bool state) { _center = state; }
inline FBSurface& surface() { return *_surface; }
protected:
virtual void draw();
void releaseFocus();
@ -123,11 +127,13 @@ class Dialog : public GuiObject
Widget* _cancelWidget;
bool _visible;
bool _center;
bool _isBase;
private:
FocusList _ourFocusList;
TabWidget* _ourTab;
WidgetArray _ourButtonGroup;
FBSurface* _surface;
int _result;
int _focusID;

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: DialogContainer.cxx,v 1.44 2008-05-21 14:01:31 stephena Exp $
// $Id: DialogContainer.cxx,v 1.45 2008-06-13 13:14:51 stephena Exp $
//============================================================================
#include "OSystem.hxx"
@ -94,6 +94,7 @@ void DialogContainer::draw()
{
for(int i = 0; i < myDialogStack.size(); i++)
{
myDialogStack[i]->center();
myDialogStack[i]->setDirty();
myDialogStack[i]->drawDialog();
}
@ -101,6 +102,7 @@ void DialogContainer::draw()
}
else if(!myDialogStack.empty())
{
myDialogStack.top()->center();
myDialogStack.top()->drawDialog();
}
}
@ -110,7 +112,6 @@ void DialogContainer::addDialog(Dialog* d)
{
myDialogStack.push(d);
d->center();
d->open();
d->setDirty(); // Next update() will take care of drawing
}
@ -175,6 +176,7 @@ void DialogContainer::handleMouseMotionEvent(int x, int y, int button)
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y);
activeDialog->handleMouseMoved(x - activeDialog->_x,
y - activeDialog->_y,
button);
@ -191,6 +193,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, int x, int y, uInt8
// Send the event to the dialog box on the top of the stack
Dialog* activeDialog = myDialogStack.top();
activeDialog->surface().translateCoords(x, y);
int button = (b == EVENT_LBUTTONDOWN || b == EVENT_LBUTTONUP) ? 1 : 2;
switch(b)

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: EditTextWidget.cxx,v 1.19 2008-02-06 13:45:23 stephena Exp $
// $Id: EditTextWidget.cxx,v 1.20 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -72,18 +72,18 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount)
void EditTextWidget::drawWidget(bool hilite)
{
//cerr << "EditTextWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
// Draw a thin frame around us.
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x +_w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
fb.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor);
s.hLine(_x, _y, _x + _w - 1, kColor);
s.hLine(_x, _y + _h - 1, _x +_w - 1, kShadowColor);
s.vLine(_x, _y, _y + _h - 1, kColor);
s.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor);
// Draw the text
adjustOffset();
fb.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(),
_textcolor, kTextAlignLeft, -_editScrollOffset, false);
s.drawString(_font, _editString, _x + 2, _y + 2, getEditRect().width(),
_textcolor, kTextAlignLeft, -_editScrollOffset, false);
// Draw the caret
drawCaret();

View File

@ -13,12 +13,13 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: EditableWidget.cxx,v 1.27 2008-02-06 13:45:23 stephena Exp $
// $Id: EditableWidget.cxx,v 1.28 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include "Dialog.hxx"
#include "EditableWidget.hxx"
@ -91,7 +92,7 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers)
return true;
// Ignore all alt-mod keys
if(instance()->eventHandler().kbdAlt(modifiers))
if(instance().eventHandler().kbdAlt(modifiers))
return true;
bool handled = true;
@ -122,14 +123,14 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
case 256 + 20: // left arrow
if(instance()->eventHandler().kbdControl(modifiers))
if(instance().eventHandler().kbdControl(modifiers))
dirty = specialKeys(keycode);
else if(_caretPos > 0)
dirty = setCaretPos(_caretPos - 1);
break;
case 256 + 19: // right arrow
if(instance()->eventHandler().kbdControl(modifiers))
if(instance().eventHandler().kbdControl(modifiers))
dirty = specialKeys(keycode);
else if(_caretPos < (int)_editString.size())
dirty = setCaretPos(_caretPos + 1);
@ -144,7 +145,7 @@ bool EditableWidget::handleKeyDown(int ascii, int keycode, int modifiers)
break;
default:
if (instance()->eventHandler().kbdControl(modifiers))
if (instance().eventHandler().kbdControl(modifiers))
{
dirty = specialKeys(keycode);
}
@ -197,8 +198,8 @@ void EditableWidget::drawCaret()
x += _x;
y += _y;
FrameBuffer& fb = _boss->instance()->frameBuffer();
fb.vLine(x, y+2, y + editRect.height() - 3, color);
FBSurface& s = _boss->dialog().surface();
s.vLine(x, y+2, y + editRect.height() - 3, color);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: EventMappingWidget.cxx,v 1.23 2008-03-23 16:22:46 stephena Exp $
// $Id: EventMappingWidget.cxx,v 1.24 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -133,7 +133,7 @@ void EventMappingWidget::startRemapping()
// And show a message indicating which key is being remapped
ostringstream buf;
buf << "Select action for '"
<< instance()->eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< instance().eventHandler().actionAtIndex(myActionSelected, myEventMode)
<< "' event";
myKeyMapping->setTextColor(kTextColorEm);
myKeyMapping->setLabel(buf.str());
@ -150,8 +150,8 @@ void EventMappingWidget::eraseRemapping()
return;
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
instance()->eventHandler().eraseMapping(event, myEventMode);
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
instance().eventHandler().eraseMapping(event, myEventMode);
drawKeyMapping();
}
@ -188,7 +188,7 @@ void EventMappingWidget::drawKeyMapping()
{
ostringstream buf;
buf << "Action: "
<< instance()->eventHandler().keyAtIndex(myActionSelected, myEventMode);
<< instance().eventHandler().keyAtIndex(myActionSelected, myEventMode);
myKeyMapping->setTextColor(kTextColor);
myKeyMapping->setLabel(buf.str());
}
@ -201,8 +201,8 @@ bool EventMappingWidget::handleKeyDown(int ascii, int keycode, int modifiers)
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addKeyMapping(event, myEventMode, keycode))
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance().eventHandler().addKeyMapping(event, myEventMode, keycode))
stopRemapping();
}
return true;
@ -215,8 +215,8 @@ void EventMappingWidget::handleJoyDown(int stick, int button)
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyMapping(event, myEventMode, stick, button))
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance().eventHandler().addJoyMapping(event, myEventMode, stick, button))
stopRemapping();
}
}
@ -228,8 +228,8 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value)
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyAxisMapping(event, myEventMode,
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance().eventHandler().addJoyAxisMapping(event, myEventMode,
stick, axis, value))
stopRemapping();
}
@ -244,8 +244,8 @@ bool EventMappingWidget::handleJoyHat(int stick, int hat, int value)
if(myRemapStatus && myActionSelected >= 0)
{
Event::Type event =
instance()->eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance()->eventHandler().addJoyHatMapping(event, myEventMode,
instance().eventHandler().eventAtIndex(myActionSelected, myEventMode);
if(instance().eventHandler().addJoyHatMapping(event, myEventMode,
stick, hat, value))
{
stopRemapping();
@ -296,7 +296,7 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd,
break;
case kDefaultsCmd:
instance()->eventHandler().setDefaultMapping(myEventMode);
instance().eventHandler().setDefaultMapping(myEventMode);
drawKeyMapping();
break;
}

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: FileSnapDialog.cxx,v 1.18 2008-03-30 15:01:38 stephena Exp $
// $Id: FileSnapDialog.cxx,v 1.19 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -149,35 +149,35 @@ FileSnapDialog::~FileSnapDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::loadConfig()
{
myRomPath->setEditString(instance()->settings().getString("romdir"));
myStatePath->setEditString(instance()->stateDir());
myCheatFile->setEditString(instance()->cheatFile());
myPaletteFile->setEditString(instance()->paletteFile());
myPropsFile->setEditString(instance()->propertiesFile());
mySnapPath->setEditString(instance()->settings().getString("ssdir"));
mySnapSingleCheckbox->setState(!instance()->settings().getBool("sssingle"));
myRomPath->setEditString(instance().settings().getString("romdir"));
myStatePath->setEditString(instance().stateDir());
myCheatFile->setEditString(instance().cheatFile());
myPaletteFile->setEditString(instance().paletteFile());
myPropsFile->setEditString(instance().propertiesFile());
mySnapPath->setEditString(instance().settings().getString("ssdir"));
mySnapSingleCheckbox->setState(!instance().settings().getBool("sssingle"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::saveConfig()
{
instance()->settings().setString("romdir", myRomPath->getEditString());
instance()->settings().setString("statedir", myStatePath->getEditString());
instance()->settings().setString("cheatfile", myCheatFile->getEditString());
instance()->settings().setString("palettefile", myPaletteFile->getEditString());
instance()->settings().setString("propsfile", myPropsFile->getEditString());
instance()->settings().setString("ssdir", mySnapPath->getEditString());
instance()->settings().setBool("sssingle", !mySnapSingleCheckbox->getState());
instance().settings().setString("romdir", myRomPath->getEditString());
instance().settings().setString("statedir", myStatePath->getEditString());
instance().settings().setString("cheatfile", myCheatFile->getEditString());
instance().settings().setString("palettefile", myPaletteFile->getEditString());
instance().settings().setString("propsfile", myPropsFile->getEditString());
instance().settings().setString("ssdir", mySnapPath->getEditString());
instance().settings().setBool("sssingle", !mySnapSingleCheckbox->getState());
// Flush changes to disk and inform the OSystem
instance()->settings().saveConfig();
instance()->setConfigPaths();
instance().settings().saveConfig();
instance().setConfigPaths();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileSnapDialog::setDefaults()
{
const string& basedir = instance()->baseDir();
const string& basedir = instance().baseDir();
const string& romdir = "roms";
const string& statedir = basedir + BSPF_PATH_SEPARATOR + "state";
const string& cheatfile = basedir + BSPF_PATH_SEPARATOR + "stella.cht";
@ -199,7 +199,7 @@ void FileSnapDialog::setDefaults()
void FileSnapDialog::openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd)
{
parent()->addDialog(myBrowser);
parent().addDialog(myBrowser);
myBrowser->setTitle(title);
myBrowser->setEmitSignal(cmd);

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: GameInfoDialog.cxx,v 1.56 2008-05-16 12:17:23 stephena Exp $
// $Id: GameInfoDialog.cxx,v 1.57 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -27,6 +27,7 @@
#include "PopUpWidget.hxx"
#include "Props.hxx"
#include "PropsSet.hxx"
#include "StringList.hxx"
#include "TabWidget.hxx"
#include "Widget.hxx"
@ -49,6 +50,7 @@ GameInfoDialog::GameInfoDialog(
int xpos, ypos, lwidth, fwidth, pwidth, tabID;
unsigned int i;
WidgetArray wid;
StringList items;
// The tab widget
xpos = 2; ypos = vBorder;
@ -108,20 +110,22 @@ GameInfoDialog::GameInfoDialog(
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Sound:", kTextAlignLeft);
pwidth = font.getStringWidth("Stereo");
items.clear();
items.push_back("Mono");
items.push_back("Stereo");
mySound = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
mySound->appendEntry("Mono", 1);
mySound->appendEntry("Stereo", 2);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(mySound);
ypos += lineHeight + 3;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Type:", kTextAlignLeft);
pwidth = font.getStringWidth("SB (128-256k SUPERbanking)");
myType = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
items.clear();
for(i = 0; i < kNumCartTypes; ++i)
myType->appendEntry(ourCartridgeList[i][0], i+1);
items.push_back(ourCartridgeList[i][0]);
myType = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myType);
// Add items for tab 0
@ -137,28 +141,29 @@ GameInfoDialog::GameInfoDialog(
pwidth = font.getStringWidth("B & W");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Left Difficulty:", kTextAlignLeft);
items.clear();
items.push_back("B");
items.push_back("A");
myLeftDiff = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
myLeftDiff->appendEntry("B", 1);
myLeftDiff->appendEntry("A", 2);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myLeftDiff);
ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Right Difficulty:", kTextAlignLeft);
// ... use same items as above
myRightDiff = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
myRightDiff->appendEntry("B", 1);
myRightDiff->appendEntry("A", 2);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myRightDiff);
ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"TV Type:", kTextAlignLeft);
items.clear();
items.push_back("Color");
items.push_back("B & W");
myTVType = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
myTVType->appendEntry("Color", 1);
myTVType->appendEntry("B & W", 2);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myTVType);
// Add items for tab 1
@ -174,49 +179,54 @@ GameInfoDialog::GameInfoDialog(
pwidth = font.getStringWidth("CX-22 Trakball");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"P0 Controller:", kTextAlignLeft);
myP0Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
items.clear();
for(i = 0; i < kNumControllerTypes; ++i)
myP0Controller->appendEntry(ourControllerList[i][0], i+1);
items.push_back(ourControllerList[i][0]);
myP0Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myP0Controller);
xpos += lwidth+myP0Controller->getWidth() + 4;
new StaticTextWidget(myTab, font, xpos, ypos+1, font.getStringWidth("in "),
fontHeight, "in ", kTextAlignLeft);
xpos += font.getStringWidth("in ");
items.clear();
items.push_back("left port");
items.push_back("right port");
myLeftPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"", 0, kLeftCChanged);
myLeftPort->appendEntry("left port", 1);
myLeftPort->appendEntry("right port", 2);
items, "", 0, kLeftCChanged);
wid.push_back(myLeftPort);
xpos = 10; ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"P1 Controller:", kTextAlignLeft);
myP1Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
items.clear();
for(i = 0; i < kNumControllerTypes; ++i)
myP1Controller->appendEntry(ourControllerList[i][0], i+1);
items.push_back(ourControllerList[i][0]);
myP1Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myP1Controller);
xpos += lwidth+myP1Controller->getWidth() + 4;
new StaticTextWidget(myTab, font, xpos, ypos+1, font.getStringWidth("in "),
fontHeight, "in ", kTextAlignLeft);
xpos += font.getStringWidth("in ");
items.clear();
items.push_back("left port");
items.push_back("right port");
myRightPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"", 0, kRightCChanged);
myRightPort->appendEntry("left port", 1);
myRightPort->appendEntry("right port", 2);
items, "", 0, kRightCChanged);
wid.push_back(myRightPort);
xpos = 10; ypos += lineHeight + 5;
pwidth = font.getStringWidth("Yes");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Swap Paddles:", kTextAlignLeft);
items.clear();
items.push_back("Yes");
items.push_back("No");
mySwapPaddles = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
mySwapPaddles->appendEntry("Yes", 1);
mySwapPaddles->appendEntry("No", 2);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(mySwapPaddles);
@ -233,16 +243,16 @@ GameInfoDialog::GameInfoDialog(
pwidth = font.getStringWidth("Auto-detect");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Format:", kTextAlignLeft);
items.clear();
items.push_back("Auto-detect");
items.push_back("NTSC");
items.push_back("PAL");
items.push_back("SECAM");
items.push_back("NTSC50");
items.push_back("PAL60");
items.push_back("SECAM60");
myFormat = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
myFormat->appendEntry("Auto-detect", 1);
myFormat->appendEntry("NTSC", 2);
myFormat->appendEntry("PAL", 3);
myFormat->appendEntry("SECAM", 4);
myFormat->appendEntry("NTSC50", 5);
myFormat->appendEntry("PAL60", 6);
myFormat->appendEntry("SECAM60", 7);
pwidth, lineHeight, items, "", 0, 0);
wid.push_back(myFormat);
ypos += lineHeight + 5;
@ -263,10 +273,11 @@ GameInfoDialog::GameInfoDialog(
pwidth = font.getStringWidth("Yes");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Use Phosphor:", kTextAlignLeft);
myPhosphor = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, kPhosphorChanged);
myPhosphor->appendEntry("Yes", 1);
myPhosphor->appendEntry("No", 2);
items.clear();
items.push_back("Yes");
items.push_back("No");
myPhosphor = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth,
lineHeight, items, "", 0, kPhosphorChanged);
wid.push_back(myPhosphor);
myPPBlend = new SliderWidget(myTab, font, xpos + lwidth + myPhosphor->getWidth() + 10,
@ -285,10 +296,11 @@ GameInfoDialog::GameInfoDialog(
ypos += lineHeight + 5;
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"Use HMBlanks:", kTextAlignLeft);
myHmoveBlanks = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
pwidth, lineHeight, "", 0, 0);
myHmoveBlanks->appendEntry("Yes", 1);
myHmoveBlanks->appendEntry("No", 2);
items.clear();
items.push_back("Yes");
items.push_back("No");
myHmoveBlanks = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth,
lineHeight, items, "", 0, 0);
wid.push_back(myHmoveBlanks);
// Add items for tab 3
@ -322,21 +334,22 @@ GameInfoDialog::~GameInfoDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void GameInfoDialog::loadConfig()
{
// FIXME - check comparisons
myPropertiesLoaded = false;
myDefaultsSelected = false;
if(&myOSystem->console())
if(&instance().console())
{
myGameProperties = myOSystem->console().properties();
myGameProperties = instance().console().properties();
myPropertiesLoaded = true;
loadView();
}
else if(&myOSystem->launcher())
else if(&instance().launcher())
{
const string& md5 = myOSystem->launcher().selectedRomMD5();
const string& md5 = instance().launcher().selectedRomMD5();
if(md5 != "")
{
instance()->propSet().getMD5(md5, myGameProperties);
instance().propSet().getMD5(md5, myGameProperties);
myPropertiesLoaded = true;
loadView();
}
@ -372,96 +385,75 @@ void GameInfoDialog::loadView()
myNote->setEditString(s);
s = myGameProperties.get(Cartridge_Sound);
if(s == "MONO")
mySound->setSelectedTag(1);
else if(s == "STEREO")
mySound->setSelectedTag(2);
else
mySound->setSelectedTag(0);
mySound->clearSelection();
if(s == "MONO") mySound->setSelected(0);
else if(s == "STEREO") mySound->setSelected(1);
s = myGameProperties.get(Cartridge_Type);
myType->clearSelection();
for(i = 0; i < kNumCartTypes; ++i)
{
if(s == ourCartridgeList[i][1])
break;
}
i = (i == kNumCartTypes) ? 0: i + 1;
myType->setSelectedTag(i);
myType->setSelected(i);
// Console properties
s = myGameProperties.get(Console_LeftDifficulty);
if(s == "B")
myLeftDiff->setSelectedTag(1);
else if(s == "A")
myLeftDiff->setSelectedTag(2);
else
myLeftDiff->setSelectedTag(0);
myLeftDiff->clearSelection();
if(s == "B") myLeftDiff->setSelected(0);
else if(s == "A") myLeftDiff->setSelected(1);
s = myGameProperties.get(Console_RightDifficulty);
if(s == "B")
myRightDiff->setSelectedTag(1);
else if(s == "A")
myRightDiff->setSelectedTag(2);
else
myRightDiff->setSelectedTag(0);
myRightDiff->clearSelection();
if(s == "B") myRightDiff->setSelected(0);
else if(s == "A") myRightDiff->setSelected(1);
s = myGameProperties.get(Console_TelevisionType);
if(s == "COLOR")
myTVType->setSelectedTag(1);
else if(s == "BLACKANDWHITE")
myTVType->setSelectedTag(2);
else
myTVType->setSelectedTag(0);
myTVType->clearSelection();
if(s == "COLOR") myTVType->setSelected(0);
else if(s == "BLACKANDWHITE") myTVType->setSelected(1);
s = myGameProperties.get(Console_SwapPorts);
myLeftPort->setSelectedTag(s == "NO" ? 1 : 2);
myRightPort->setSelectedTag(s == "NO" ? 2 : 1);
myLeftPort->clearSelection();
myRightPort->clearSelection();
myLeftPort->setSelected(s == "NO" ? 0 : 1);
myRightPort->setSelected(s == "NO" ? 1 : 0);
// Controller properties
s = myGameProperties.get(Controller_Left);
myP0Controller->clearSelection();
for(i = 0; i < kNumControllerTypes; ++i)
{
if(s == ourControllerList[i][1])
break;
}
i = (i == kNumControllerTypes) ? 0: i + 1;
myP0Controller->setSelectedTag(i);
myP0Controller->setSelected(i);
s = myGameProperties.get(Controller_Right);
myP1Controller->clearSelection();
for(i = 0; i < kNumControllerTypes; ++i)
{
if(s == ourControllerList[i][1])
break;
}
i = (i == kNumControllerTypes) ? 0: i + 1;
myP1Controller->setSelectedTag(i);
myP1Controller->setSelected(i);
s = myGameProperties.get(Controller_SwapPaddles);
if(s == "YES")
mySwapPaddles->setSelectedTag(1);
else if(s == "NO")
mySwapPaddles->setSelectedTag(2);
else
mySwapPaddles->setSelectedTag(0);
mySwapPaddles->clearSelection();
if(s == "YES") mySwapPaddles->setSelected(0);
else if(s == "NO") mySwapPaddles->setSelected(1);
// Display properties
s = myGameProperties.get(Display_Format);
if(s == "AUTO-DETECT")
myFormat->setSelectedTag(1);
else if(s == "NTSC")
myFormat->setSelectedTag(2);
else if(s == "PAL")
myFormat->setSelectedTag(3);
else if(s == "SECAM")
myFormat->setSelectedTag(4);
else if(s == "NTSC50")
myFormat->setSelectedTag(5);
else if(s == "PAL60")
myFormat->setSelectedTag(6);
else if(s == "SECAM60")
myFormat->setSelectedTag(7);
else
myFormat->setSelectedTag(0);
myFormat->clearSelection();
if(s == "AUTO-DETECT") myFormat->setSelected(0);
else if(s == "NTSC") myFormat->setSelected(1);
else if(s == "PAL") myFormat->setSelected(2);
else if(s == "SECAM") myFormat->setSelected(3);
else if(s == "NTSC50") myFormat->setSelected(4);
else if(s == "PAL60") myFormat->setSelected(5);
else if(s == "SECAM60") myFormat->setSelected(6);
s = myGameProperties.get(Display_YStart);
myYStart->setEditString(s);
@ -469,31 +461,27 @@ void GameInfoDialog::loadView()
s = myGameProperties.get(Display_Height);
myHeight->setEditString(s);
s = myGameProperties.get(Display_Phosphor);
myPhosphor->clearSelection();
myPPBlend->setEnabled(false);
myPPBlendLabel->setEnabled(false);
s = myGameProperties.get(Display_Phosphor);
if(s == "YES")
{
myPhosphor->setSelectedTag(1);
myPhosphor->setSelected(0);
myPPBlend->setEnabled(true);
myPPBlendLabel->setEnabled(true);
}
else if(s == "NO")
myPhosphor->setSelectedTag(2);
else
myPhosphor->setSelectedTag(0);
myPhosphor->setSelected(1);
s = myGameProperties.get(Display_PPBlend);
myPPBlend->setValue(atoi(s.c_str()));
myPPBlendLabel->setLabel(s);
s = myGameProperties.get(Emulation_HmoveBlanks);
if(s == "YES")
myHmoveBlanks->setSelectedTag(1);
else if(s == "NO")
myHmoveBlanks->setSelectedTag(2);
else
myHmoveBlanks->setSelectedTag(0);
myHmoveBlanks->clearSelection();
if(s == "YES") myHmoveBlanks->setSelected(0);
else if(s == "NO") myHmoveBlanks->setSelected(1);
myTab->loadConfig();
}
@ -523,14 +511,14 @@ void GameInfoDialog::saveConfig()
s = myNote->getEditString();
myGameProperties.set(Cartridge_Note, s);
tag = mySound->getSelectedTag();
s = (tag == 1) ? "Mono" : "Stereo";
tag = mySound->getSelected();
s = (tag == 0) ? "Mono" : "Stereo";
myGameProperties.set(Cartridge_Sound, s);
tag = myType->getSelectedTag();
tag = myType->getSelected();
for(i = 0; i < kNumCartTypes; ++i)
{
if(i == tag-1)
if(i == tag)
{
myGameProperties.set(Cartridge_Type, ourCartridgeList[i][1]);
break;
@ -538,52 +526,49 @@ void GameInfoDialog::saveConfig()
}
// Console properties
tag = myLeftDiff->getSelectedTag();
s = (tag == 1) ? "B" : "A";
tag = myLeftDiff->getSelected();
s = (tag == 0) ? "B" : "A";
myGameProperties.set(Console_LeftDifficulty, s);
tag = myRightDiff->getSelectedTag();
s = (tag == 1) ? "B" : "A";
tag = myRightDiff->getSelected();
s = (tag == 0) ? "B" : "A";
myGameProperties.set(Console_RightDifficulty, s);
tag = myTVType->getSelectedTag();
s = (tag == 1) ? "Color" : "BlackAndWhite";
tag = myTVType->getSelected();
s = (tag == 0) ? "Color" : "BlackAndWhite";
myGameProperties.set(Console_TelevisionType, s);
// Controller properties
tag = myP0Controller->getSelectedTag();
tag = myP0Controller->getSelected();
for(i = 0; i < kNumControllerTypes; ++i)
{
if(i == tag-1)
if(i == tag)
{
myGameProperties.set(Controller_Left, ourControllerList[i][1]);
break;
}
}
tag = myP1Controller->getSelectedTag();
tag = myP1Controller->getSelected();
for(i = 0; i < kNumControllerTypes; ++i)
{
if(i == tag-1)
if(i == tag)
{
myGameProperties.set(Controller_Right, ourControllerList[i][1]);
break;
}
}
tag = myLeftPort->getSelectedTag();
s = (tag == 1) ? "No" : "Yes";
tag = myLeftPort->getSelected();
s = (tag == 0) ? "No" : "Yes";
myGameProperties.set(Console_SwapPorts, s);
tag = mySwapPaddles->getSelectedTag();
s = (tag == 1) ? "Yes" : "No";
tag = mySwapPaddles->getSelected();
s = (tag == 0) ? "Yes" : "No";
myGameProperties.set(Controller_SwapPaddles, s);
// Display properties
tag = myFormat->getSelectedTag();
s = (tag == 7) ? "SECAM60" : (tag == 6) ? "PAL60" : (tag == 5) ? "NTSC50" :
(tag == 4) ? "SECAM" : (tag == 3) ? "PAL" : (tag == 2) ? "NTSC" :
"AUTO-DETECT";
s = myFormat->getSelectedString(); // use string directly
myGameProperties.set(Display_Format, s);
s = myYStart->getEditString();
@ -592,27 +577,27 @@ void GameInfoDialog::saveConfig()
s = myHeight->getEditString();
myGameProperties.set(Display_Height, s);
tag = myPhosphor->getSelectedTag();
s = (tag == 1) ? "Yes" : "No";
tag = myPhosphor->getSelected();
s = (tag == 0) ? "Yes" : "No";
myGameProperties.set(Display_Phosphor, s);
s = myPPBlendLabel->getLabel();
myGameProperties.set(Display_PPBlend, s);
tag = myHmoveBlanks->getSelectedTag();
s = (tag == 1) ? "Yes" : "No";
tag = myHmoveBlanks->getSelected();
s = (tag == 0) ? "Yes" : "No";
myGameProperties.set(Emulation_HmoveBlanks, s);
// Determine whether to add or remove an entry from the properties set
if(myDefaultsSelected)
instance()->propSet().removeMD5(myGameProperties.get(Cartridge_MD5));
instance().propSet().removeMD5(myGameProperties.get(Cartridge_MD5));
else
instance()->propSet().insert(myGameProperties, true);
instance().propSet().insert(myGameProperties, true);
// In any event, inform the Console and save the properties
if(&myOSystem->console())
instance()->console().setProperties(myGameProperties);
instance()->propSet().save(myOSystem->propertiesFile());
if(&instance().console())
instance().console().setProperties(myGameProperties);
instance().propSet().save(instance().propertiesFile());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -620,7 +605,7 @@ void GameInfoDialog::setDefaults()
{
// Load the default properties
string md5 = myGameProperties.get(Cartridge_MD5);
instance()->propSet().getMD5(md5, myGameProperties, true);
instance().propSet().getMD5(md5, myGameProperties, true);
// Reload the current dialog
loadView();
@ -643,18 +628,18 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kLeftCChanged:
myRightPort->setSelectedTag(
myLeftPort->getSelectedTag() == 2 ? 1 : 2);
myRightPort->setSelected(
myLeftPort->getSelected() == 1 ? 0 : 1);
break;
case kRightCChanged:
myLeftPort->setSelectedTag(
myRightPort->getSelectedTag() == 2 ? 1 : 2);
myLeftPort->setSelected(
myRightPort->getSelected() == 1 ? 0 : 1);
break;
case kPhosphorChanged:
{
bool status = myPhosphor->getSelectedTag() == 1 ? true : false;
bool status = myPhosphor->getSelected() == 0 ? true : false;
myPPBlend->setEnabled(status);
myPPBlendLabel->setEnabled(status);
break;

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: GuiObject.hxx,v 1.24 2008-02-06 13:45:23 stephena Exp $
// $Id: GuiObject.hxx,v 1.25 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -22,6 +22,7 @@
#ifndef GUI_OBJECT_HXX
#define GUI_OBJECT_HXX
class Dialog;
class DialogContainer;
class Widget;
@ -54,7 +55,7 @@ enum {
This is the base class for all GUI objects/widgets.
@author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.24 2008-02-06 13:45:23 stephena Exp $
@version $Id: GuiObject.hxx,v 1.25 2008-06-13 13:14:51 stephena Exp $
*/
class GuiObject : public CommandReceiver
{
@ -62,9 +63,11 @@ class GuiObject : public CommandReceiver
friend class DialogContainer;
public:
GuiObject(OSystem* osystem, DialogContainer* parent, int x, int y, int w, int h)
GuiObject(OSystem& osystem, DialogContainer& parent, Dialog& dialog,
int x, int y, int w, int h)
: myOSystem(osystem),
myParent(parent),
myDialog(dialog),
_x(x),
_y(y),
_w(w),
@ -74,8 +77,9 @@ class GuiObject : public CommandReceiver
virtual ~GuiObject() {}
OSystem* instance() { return myOSystem; }
DialogContainer* parent() { return myParent; }
OSystem& instance() { return myOSystem; }
DialogContainer& parent() { return myParent; }
Dialog& dialog() { return myDialog; }
virtual int getAbsX() const { return _x; }
virtual int getAbsY() const { return _y; }
@ -84,11 +88,10 @@ class GuiObject : public CommandReceiver
virtual int getWidth() const { return _w; }
virtual int getHeight() const { return _h; }
virtual void setPos(int x, int y) { _x = x; _y = y; }
virtual void setWidth(int w) { _w = w; }
virtual void setHeight(int h) { _h = h; }
virtual void setDirty() { _dirty = true; }
virtual void setDirty() { _dirty = true; }
virtual bool isVisible() const = 0;
virtual void draw() = 0;
@ -105,10 +108,12 @@ class GuiObject : public CommandReceiver
protected:
virtual void releaseFocus() = 0;
protected:
OSystem* myOSystem;
DialogContainer* myParent;
private:
OSystem& myOSystem;
DialogContainer& myParent;
Dialog& myDialog;
protected:
int _x, _y;
int _w, _h;
bool _dirty;

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: InputDialog.cxx,v 1.32 2008-05-11 21:18:35 stephena Exp $
// $Id: InputDialog.cxx,v 1.33 2008-06-13 13:14:51 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -23,6 +23,7 @@
#include "Joystick.hxx"
#include "Paddles.hxx"
#include "Settings.hxx"
#include "StringList.hxx"
#include "EventMappingWidget.hxx"
#include "EditTextWidget.hxx"
#include "PopUpWidget.hxx"
@ -55,7 +56,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 1) Event mapper for emulation actions
tabID = myTab->addTab("Emul. Events");
const StringList& eactions = instance()->eventHandler().getActionList(kEmulationMode);
const StringList& eactions = instance().eventHandler().getActionList(kEmulationMode);
myEmulEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(),
myTab->getHeight() - ypos,
@ -65,7 +66,7 @@ InputDialog::InputDialog(OSystem* osystem, DialogContainer* parent,
// 2) Event mapper for UI actions
tabID = myTab->addTab("UI Events");
const StringList& mactions = instance()->eventHandler().getActionList(kMenuMode);
const StringList& mactions = instance().eventHandler().getActionList(kMenuMode);
myMenuEventMapper = new EventMappingWidget(myTab, font, 2, 2,
myTab->getWidth(),
myTab->getHeight() - ypos,
@ -98,6 +99,7 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
fontHeight = font.getFontHeight();
int xpos, ypos, lwidth, pwidth, tabID;
WidgetArray wid;
StringList items;
// Virtual device/ports
tabID = myTab->addTab("Virtual Devs");
@ -107,17 +109,17 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
lwidth = font.getStringWidth("Stelladaptor 2 is: ");
pwidth = font.getStringWidth("right virtual port");
myLeftPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
items.clear();
items.push_back("left virtual port");
items.push_back("right virtual port");
myLeftPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,
"Stelladaptor 1 is: ", lwidth, kLeftChanged);
myLeftPort->appendEntry("left virtual port", 1);
myLeftPort->appendEntry("right virtual port", 2);
wid.push_back(myLeftPort);
ypos += lineHeight + 5;
myRightPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
// ... use items from above
myRightPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,
"Stelladaptor 2 is: ", lwidth, kRightChanged);
myRightPort->appendEntry("left virtual port", 1);
myRightPort->appendEntry("right virtual port", 2);
wid.push_back(myRightPort);
lwidth = font.getStringWidth("Paddle threshold: ");
@ -174,27 +176,27 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
void InputDialog::loadConfig()
{
// Left & right ports
const string& sa1 = instance()->settings().getString("sa1");
int lport = sa1 == "right" ? 2 : 1;
myLeftPort->setSelectedTag(lport);
const string& sa2 = instance()->settings().getString("sa2");
int rport = sa2 == "right" ? 2 : 1;
myRightPort->setSelectedTag(rport);
const string& sa1 = instance().settings().getString("sa1");
int lport = sa1 == "right" ? 1 : 0;
myLeftPort->setSelected(lport);
const string& sa2 = instance().settings().getString("sa2");
int rport = sa2 == "right" ? 1 : 0;
myRightPort->setSelected(rport);
// Joystick deadzone
myDeadzone->setValue(instance()->settings().getInt("joydeadzone"));
myDeadzoneLabel->setLabel(instance()->settings().getString("joydeadzone"));
myDeadzone->setValue(instance().settings().getInt("joydeadzone"));
myDeadzoneLabel->setLabel(instance().settings().getString("joydeadzone"));
// Paddle mode
myPaddleMode->setValue(0);
myPaddleModeLabel->setLabel("0");
// Paddle speed
myPaddleSpeed->setValue(instance()->settings().getInt("pspeed"));
myPaddleLabel->setLabel(instance()->settings().getString("pspeed"));
myPaddleSpeed->setValue(instance().settings().getInt("pspeed"));
myPaddleLabel->setLabel(instance().settings().getString("pspeed"));
// AtariVox serial port
myAVoxPort->setEditString(instance()->settings().getString("avoxport"));
myAVoxPort->setEditString(instance().settings().getString("avoxport"));
myTab->loadConfig();
}
@ -203,13 +205,13 @@ void InputDialog::loadConfig()
void InputDialog::saveConfig()
{
// Left & right ports
const string& sa1 = myLeftPort->getSelectedTag() == 2 ? "right" : "left";
const string& sa2 = myRightPort->getSelectedTag() == 2 ? "right" : "left";
instance()->eventHandler().mapStelladaptors(sa1, sa2);
const string& sa1 = myLeftPort->getSelected() == 1 ? "right" : "left";
const string& sa2 = myRightPort->getSelected() == 1 ? "right" : "left";
instance().eventHandler().mapStelladaptors(sa1, sa2);
// Joystick deadzone
int deadzone = myDeadzone->getValue();
instance()->settings().setInt("joydeadzone", deadzone);
instance().settings().setInt("joydeadzone", deadzone);
Joystick::setDeadZone(deadzone);
// Paddle mode
@ -217,11 +219,11 @@ void InputDialog::saveConfig()
// Paddle speed
int speed = myPaddleSpeed->getValue();
instance()->settings().setInt("pspeed", speed);
instance().settings().setInt("pspeed", speed);
Paddles::setDigitalSpeed(speed);
// AtariVox serial port
instance()->settings().setString("avoxport", myAVoxPort->getEditString());
instance().settings().setString("avoxport", myAVoxPort->getEditString());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -289,13 +291,13 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kLeftChanged:
myRightPort->setSelectedTag(
myLeftPort->getSelectedTag() == 2 ? 1 : 2);
myRightPort->setSelected(
myLeftPort->getSelected() == 1 ? 0 : 1);
break;
case kRightChanged:
myLeftPort->setSelectedTag(
myRightPort->getSelectedTag() == 2 ? 1 : 2);
myLeftPort->setSelected(
myRightPort->getSelected() == 1 ? 0 : 1);
break;
case kDeadzoneChanged:

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: InputTextDialog.cxx,v 1.20 2008-02-06 13:45:23 stephena Exp $
// $Id: InputTextDialog.cxx,v 1.21 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -32,7 +32,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& font,
const StringList& labels, int x, int y)
: Dialog(boss->instance(), boss->parent(), x, y, 16, 16),
: Dialog(&boss->instance(), &boss->parent(), x, y, 16, 16),
CommandSender(boss),
myErrorFlag(false)
{

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: LauncherDialog.cxx,v 1.87 2008-05-30 19:07:55 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.88 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -44,7 +44,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h),
: Dialog(osystem, parent, x, y, w, h, true), // use base surface
myStartButton(NULL),
myPrevDirButton(NULL),
myOptionsButton(NULL),
@ -56,7 +56,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
mySelectedItem(0),
myRomInfoFlag(false)
{
const GUI::Font& font = instance()->launcherFont();
const GUI::Font& font = instance().launcherFont();
const int fontHeight = font.getFontHeight();
const int bwidth = (_w - 2 * 10 - 8 * (4 - 1)) / 4;
@ -66,7 +66,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// Check if we want the ROM info viewer
// Make sure it will fit within the current bounds
myRomInfoFlag = instance()->settings().getBool("romviewer");
myRomInfoFlag = instance().settings().getBool("romviewer");
if((w < 640 || h < 480) && myRomInfoFlag)
{
cerr << "ERROR: ROM launcher too small, deactivating ROM info viewer" << endl;
@ -98,7 +98,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
if(myRomInfoFlag)
{
xpos += myList->getWidth() + 15;
myRomInfoWidget = new RomInfoWidget(this, instance()->font(), xpos, ypos,
myRomInfoWidget = new RomInfoWidget(this, instance().font(), xpos, ypos,
326, myList->getHeight());
wid.push_back(myRomInfoWidget);
}
@ -176,13 +176,13 @@ string LauncherDialog::selectedRomMD5()
string extension;
int item = myList->getSelected();
if(item < 0 || myGameList->isDir(item) ||
!instance()->isValidRomName(myGameList->name(item), extension))
!instance().isValidRomName(myGameList->name(item), extension))
return "";
// Make sure we have a valid md5 for this ROM
if(myGameList->md5(item) == "")
{
const string& md5 = instance()->MD5FromFile(myGameList->path(item));
const string& md5 = instance().MD5FromFile(myGameList->path(item));
myGameList->setMd5(item, md5);
}
return myGameList->md5(item);
@ -196,7 +196,7 @@ void LauncherDialog::loadConfig()
if(myList->getList().isEmpty())
{
myPrevDirButton->setEnabled(false);
myCurrentNode = instance()->settings().getString("romdir");
myCurrentNode = instance().settings().getString("romdir");
updateListing();
}
@ -222,7 +222,7 @@ void LauncherDialog::updateListing(bool fullReload)
myGameList->clear();
myDir->setLabel("");
string romdir = instance()->settings().getString("romdir");
string romdir = instance().settings().getString("romdir");
loadDirListing();
// Only hilite the 'up' button if there's a parent directory
@ -247,7 +247,7 @@ void LauncherDialog::updateListing(bool fullReload)
int selected = -1;
if(!myList->getList().isEmpty())
{
string lastrom = instance()->settings().getString("lastrom");
string lastrom = instance().settings().getString("lastrom");
if(lastrom == "")
selected = 0;
else
@ -306,16 +306,16 @@ void LauncherDialog::loadRomInfo()
string extension;
if(!myGameList->isDir(item) &&
instance()->isValidRomName(myGameList->name(item), extension))
instance().isValidRomName(myGameList->name(item), extension))
{
// Make sure we have a valid md5 for this ROM
if(myGameList->md5(item) == "")
myGameList->setMd5(item, instance()->MD5FromFile(myGameList->path(item)));
myGameList->setMd5(item, instance().MD5FromFile(myGameList->path(item)));
// Get the properties for this entry
Properties props;
const string& md5 = myGameList->md5(item);
instance()->propSet().getMD5(md5, props);
instance().propSet().getMD5(md5, props);
myRomInfoWidget->setProperties(props);
}
@ -349,15 +349,15 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
myCurrentNode = rom;
updateListing();
}
else if(!instance()->isValidRomName(rom, extension) ||
!instance()->createConsole(rom, md5))
else if(!instance().isValidRomName(rom, extension) ||
!instance().createConsole(rom, md5))
{
instance()->frameBuffer().showMessage("Not a valid ROM file", kMiddleCenter);
instance().frameBuffer().showMessage("Not a valid ROM file", kMiddleCenter);
}
else
{
#if !defined(GP2X) // Quick GP2X hack to spare flash-card saves
instance()->settings().setString("lastrom", myList->getSelectedString());
instance().settings().setString("lastrom", myList->getSelectedString());
#endif
}
}
@ -365,7 +365,7 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
}
case kOptionsCmd:
parent()->addDialog(myOptions);
parent().addDialog(myOptions);
break;
case kPrevDirCmd:
@ -379,11 +379,11 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
case kQuitCmd:
close();
instance()->eventHandler().quit();
instance().eventHandler().quit();
break;
case kRomDirChosenCmd:
myCurrentNode = instance()->settings().getString("romdir");
myCurrentNode = instance().settings().getString("romdir");
updateListing();
break;

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: ListWidget.cxx,v 1.50 2008-02-06 13:45:24 stephena Exp $
// $Id: ListWidget.cxx,v 1.51 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -223,7 +223,7 @@ static bool matchingCharsIgnoringCase(string s, string pattern)
bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Ignore all Alt-mod keys
if(instance()->eventHandler().kbdAlt(modifiers))
if(instance().eventHandler().kbdAlt(modifiers))
return true;
bool handled = true;
@ -236,7 +236,7 @@ bool ListWidget::handleKeyDown(int ascii, int keycode, int modifiers)
// Only works in a useful fashion if the list entries are sorted.
// TODO: Maybe this should be off by default, and instead we add a
// method "enableQuickSelect()" or so ?
int time = instance()->getTicks() / 1000;
int time = instance().getTicks() / 1000;
if (_quickSelectTime < time)
_quickSelectStr = (char)ascii;
else

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.69 2008-03-23 16:22:46 stephena Exp $
// $Id: OptionsDialog.cxx,v 1.70 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -60,7 +60,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
myAboutDialog(NULL),
myIsGlobal(global)
{
const GUI::Font& font = instance()->font();
const GUI::Font& font = instance().font();
const int buttonWidth = font.getStringWidth("Game Properties") + 20,
buttonHeight = font.getLineHeight() + 6,
rowHeight = font.getLineHeight() + 10;
@ -120,44 +120,44 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
// Now create all the dialogs attached to each menu button
w = 240; h = 185;
myVideoDialog = new VideoDialog(myOSystem, parent, font, x, y, w, h);
myVideoDialog = new VideoDialog(osystem, parent, font, x, y, w, h);
w = 200; h = 140;
myAudioDialog = new AudioDialog(myOSystem, parent, font, x, y, w, h);
myAudioDialog = new AudioDialog(osystem, parent, font, x, y, w, h);
#ifdef _WIN32_WCE
// we scale the input dialog down a bit in low res devices.
// looks only a little ugly, but the functionality is very welcome
if(myOSystem->desktopWidth() < 320) { w = 220; h = 176; }
if(instance().desktopWidth() < 320) { w = 220; h = 176; }
else { w = 230; h = 185; }
#else
w = 230; h = 185;
#endif
myInputDialog = new InputDialog(myOSystem, parent, font, x, y, w, h);
myInputDialog = new InputDialog(osystem, parent, font, x, y, w, h);
w = 200; h = 155;
myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h);
myUIDialog = new UIDialog(osystem, parent, font, x, y, w, h);
w = 280; h = 180;
myFileSnapDialog = new FileSnapDialog(myOSystem, parent, font,
myFileSnapDialog = new FileSnapDialog(osystem, parent, font,
boss, x, y, w, h);
w = 240; h = 115;
myRomAuditDialog = new RomAuditDialog(myOSystem, parent, font, x, y, w, h);
myRomAuditDialog = new RomAuditDialog(osystem, parent, font, x, y, w, h);
w = 255; h = 190;
myGameInfoDialog = new GameInfoDialog(myOSystem, parent, font, this, x, y, w, h);
myGameInfoDialog = new GameInfoDialog(osystem, parent, font, this, x, y, w, h);
#ifdef CHEATCODE_SUPPORT
w = 230; h = 150;
myCheatCodeDialog = new CheatCodeDialog(myOSystem, parent, font, x, y, w, h);
myCheatCodeDialog = new CheatCodeDialog(osystem, parent, font, x, y, w, h);
#endif
w = 255; h = 150;
myHelpDialog = new HelpDialog(myOSystem, parent, font, x, y, w, h);
myHelpDialog = new HelpDialog(osystem, parent, font, x, y, w, h);
w = 255; h = 150;
myAboutDialog = new AboutDialog(myOSystem, parent, font, x, y, w, h);
myAboutDialog = new AboutDialog(osystem, parent, font, x, y, w, h);
addToFocusList(wid);
@ -173,7 +173,7 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent,
#ifdef _WIN32_WCE
myAudioSettingsButton->clearFlags(WIDGET_ENABLED); // not honored in wince port
#endif
if(myOSystem->desktopWidth() < 320)
if(instance().desktopWidth() < 320)
{
// These cannot be displayed in low res devices
myVideoSettingsButton->clearFlags(WIDGET_ENABLED);
@ -207,13 +207,13 @@ void OptionsDialog::loadConfig()
// Determine whether we should show the 'Game Information' button
// We always show it in emulation mode, or if a valid ROM is selected
// in launcher mode
switch(instance()->eventHandler().state())
switch(instance().eventHandler().state())
{
case EventHandler::S_EMULATE:
myGameInfoButton->setFlags(WIDGET_ENABLED);
break;
case EventHandler::S_LAUNCHER:
if(instance()->launcher().selectedRomMD5() != "")
if(instance().launcher().selectedRomMD5() != "")
myGameInfoButton->setFlags(WIDGET_ENABLED);
else
myGameInfoButton->clearFlags(WIDGET_ENABLED);
@ -230,52 +230,52 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
switch(cmd)
{
case kVidCmd:
parent()->addDialog(myVideoDialog);
parent().addDialog(myVideoDialog);
break;
case kAudCmd:
parent()->addDialog(myAudioDialog);
parent().addDialog(myAudioDialog);
break;
case kInptCmd:
parent()->addDialog(myInputDialog);
parent().addDialog(myInputDialog);
break;
case kUsrIfaceCmd:
parent()->addDialog(myUIDialog);
parent().addDialog(myUIDialog);
break;
case kFileSnapCmd:
parent()->addDialog(myFileSnapDialog);
parent().addDialog(myFileSnapDialog);
break;
case kAuditCmd:
parent()->addDialog(myRomAuditDialog);
parent().addDialog(myRomAuditDialog);
break;
case kInfoCmd:
parent()->addDialog(myGameInfoDialog);
parent().addDialog(myGameInfoDialog);
break;
#ifdef CHEATCODE_SUPPORT
case kCheatCmd:
parent()->addDialog(myCheatCodeDialog);
parent().addDialog(myCheatCodeDialog);
break;
#endif
case kHelpCmd:
parent()->addDialog(myHelpDialog);
parent().addDialog(myHelpDialog);
break;
case kAboutCmd:
parent()->addDialog(myAboutDialog);
parent().addDialog(myAboutDialog);
break;
case kExitCmd:
if(myIsGlobal)
close();
else
instance()->eventHandler().leaveMenuMode();
instance().eventHandler().leaveMenuMode();
break;
default:

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: PopUpWidget.cxx,v 1.39 2008-02-06 13:45:24 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.40 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -21,12 +21,9 @@
#include "bspf.hxx"
#include "DialogContainer.hxx"
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "OSystem.hxx"
#include "Stack.hxx"
#include "StringListWidget.hxx"
#include "ContextMenu.hxx"
#include "DialogContainer.hxx"
#include "PopUpWidget.hxx"
@ -44,390 +41,14 @@ static unsigned int up_down_arrows[8] = {
0x00001000,
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpDialog::PopUpDialog(PopUpWidget* boss, int clickX, int clickY)
: Dialog(boss->instance(), boss->parent(), 0, 0, 16, 16),
_popUpBoss(boss)
{
// Copy the selection index
_selection = _popUpBoss->_selectedItem;
// Calculate real popup dimensions
_x = _popUpBoss->getAbsX() + _popUpBoss->_labelWidth;
_y = _popUpBoss->getAbsY() - _popUpBoss->_selectedItem * _popUpBoss->_fontHeight;
_w = _popUpBoss->_w - _popUpBoss->_labelWidth - 10;
_h = 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::drawDialog()
{
// Normally we add widgets and let Dialog::draw() take care of this
// logic. But for some reason, this Dialog was written differently
// by the ScummVM guys, so I'm not going to mess with it.
if(_dirty)
{
FrameBuffer& fb = instance()->frameBuffer();
// Draw the menu border
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
fb.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor);
// If necessary, draw dividing line
if(_twoColumns)
fb.vLine(_x + _w / 2, _y, _y + _h - 2, kColor);
// Draw the entries
int count = _popUpBoss->_entries.size();
for(int i = 0; i < count; i++)
drawMenuEntry(i, i == _selection);
// The last entry may be empty. Fill it with black.
if(_twoColumns && (count & 1))
fb.fillRect(_x + 1 + _w / 2, _y + 1 + _popUpBoss->_fontHeight * (_entriesPerColumn - 1),
_w / 2 - 1, _popUpBoss->_fontHeight, kWidColor);
_dirty = false;
fb.addDirtyRect(_x, _y, _w, _h);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleMouseDown(int x, int y, int button, int clickCount)
{
// Only make a selection if we're in the dialog area
if(x >= 0 && x < _w && y >= 0 && y < _h)
sendSelection();
else
cancelSelection();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleMouseWheel(int x, int y, int direction)
{
if(direction < 0)
moveUp();
else if(direction > 0)
moveDown();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleMouseMoved(int x, int y, int button)
{
// Compute over which item the mouse is...
int item = findItem(x, y);
if(item >= 0 && _popUpBoss->_entries[item].name.size() == 0)
item = -1;
if(item == -1 && !isMouseDown())
return;
// ...and update the selection accordingly
setSelection(item);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{
if(isMouseDown())
return;
Event::Type e = instance()->eventHandler().eventForKey(keycode, kMenuMode);
handleEvent(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleJoyDown(int stick, int button)
{
Event::Type e =
instance()->eventHandler().eventForJoyButton(stick, button, kMenuMode);
handleEvent(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleJoyAxis(int stick, int axis, int value)
{
if(value != 0) // we don't care about 'axis up' events
{
Event::Type e =
instance()->eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode);
handleEvent(e);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpDialog::handleJoyHat(int stick, int hat, int value)
{
Event::Type e =
instance()->eventHandler().eventForJoyHat(stick, hat, value, kMenuMode);
handleEvent(e);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleEvent(Event::Type e)
{
switch(e)
{
case Event::UISelect:
sendSelection();
break;
case Event::UIUp:
case Event::UILeft:
moveUp();
break;
case Event::UIDown:
case Event::UIRight:
moveDown();
break;
case Event::UIHome:
setSelection(0);
break;
case Event::UIEnd:
setSelection(_popUpBoss->_entries.size()-1);
break;
case Event::UICancel:
cancelSelection();
break;
default:
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::drawMenuEntry(int entry, bool hilite)
{
FrameBuffer& fb = instance()->frameBuffer();
// Draw one entry of the popup menu, including selection
int x, y, w;
if(_twoColumns)
{
int n = _popUpBoss->_entries.size() / 2;
if(_popUpBoss->_entries.size() & 1)
n++;
if (entry >= n)
{
x = _x + 1 + _w / 2;
y = _y + 1 + _popUpBoss->_fontHeight * (entry - n);
}
else
{
x = _x + 1;
y = _y + 1 + _popUpBoss->_fontHeight * entry;
}
w = _w / 2 - 1;
}
else
{
x = _x + 1;
y = _y + 1 + _popUpBoss->_fontHeight * entry;
w = _w - 2;
}
string& name = _popUpBoss->_entries[entry].name;
fb.fillRect(x, y, w, _popUpBoss->_fontHeight, hilite ? kTextColorHi : kWidColor);
if(name.size() == 0)
{
// Draw a separator
fb.hLine(x - 1, y + _popUpBoss->_fontHeight / 2, x + w, kShadowColor);
fb.hLine(x, y + 1 + _popUpBoss->_fontHeight / 2, x + w, kColor);
}
else
fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2,
hilite ? _popUpBoss->_textcolorhi : _popUpBoss->_textcolor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::recalc()
{
// Perform clipping / switch to scrolling mode if we don't fit on the screen
const int height = instance()->frameBuffer().baseHeight();
_x = _popUpBoss->getAbsX() + _popUpBoss->_labelWidth;
_y = _popUpBoss->getAbsY() + _popUpBoss->getHeight();
_h = _popUpBoss->_entries.size() * _popUpBoss->_fontHeight + 2;
// HACK: For now, we do not do scrolling. Instead, we draw the dialog
// in two columns if it's too tall.
if(_h >= height)
{
const int width = instance()->frameBuffer().baseWidth();
_twoColumns = true;
_entriesPerColumn = _popUpBoss->_entries.size() / 2;
if(_popUpBoss->_entries.size() & 1)
_entriesPerColumn++;
_h = _entriesPerColumn * _popUpBoss->_fontHeight + 2;
_w = 0;
// Find width of largest item
for(unsigned int i = 0; i < _popUpBoss->_entries.size(); i++)
{
int width = _popUpBoss->_font->getStringWidth(_popUpBoss->_entries[i].name);
if(width > _w)
_w = width;
}
_w = 2 * _w + 10;
if (!(_w & 1))
_w++;
if(_popUpBoss->_selectedItem >= _entriesPerColumn)
{
_x -= _w / 2;
_y = _popUpBoss->getAbsY() - (_popUpBoss->_selectedItem - _entriesPerColumn) *
_popUpBoss->_fontHeight;
}
if(_w >= width)
_w = width - 1;
if(_x < 0)
_x = 0;
if(_x + _w >= width)
_x = width - 1 - _w;
}
else
_twoColumns = false;
if(_h >= height)
_h = height - 1;
if(_y < 0)
_y = 0;
else if(_y + _h >= height)
_y = height - 1 - _h;
// TODO - implement scrolling if we had to move the menu, or if there are too many entries
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int PopUpDialog::findItem(int x, int y) const
{
if(x >= 0 && x < _w && y >= 0 && y < _h)
{
if(_twoColumns)
{
unsigned int entry = (y - 2) / _popUpBoss->_fontHeight;
if(x > _w / 2)
{
entry += _entriesPerColumn;
if(entry >= _popUpBoss->_entries.size())
return -1;
}
return entry;
}
return (y - 2) / _popUpBoss->_fontHeight;
}
return -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::setSelection(int item)
{
if(item != _selection)
{
// Change selection
_selection = item;
_popUpBoss->_selectedItem = item;
setDirty(); _popUpBoss->setDirty(); _popUpBoss->draw();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::sendSelection()
{
if(_popUpBoss->_cmd)
_popUpBoss->sendCommand(_popUpBoss->_cmd,
_popUpBoss->_entries[_selection].tag,
_popUpBoss->_id);
// We remove the dialog when the user has selected an item
parent()->removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::cancelSelection()
{
setSelection(_oldSelection);
parent()->removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpDialog::isMouseDown()
{
// TODO - need a way to determine whether any mouse buttons are pressed or not.
// Sure, we could just count mouse button up/down events, but that is cumbersome and
// error prone. Would be much nicer to add an API to OSystem for this...
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::moveUp()
{
if(_selection < 0)
{
setSelection(_popUpBoss->_entries.size() - 1);
}
else if(_selection > 0)
{
int item = _selection;
do {
item--;
} while (item >= 0 && _popUpBoss->_entries[item].name.size() == 0);
if(item >= 0)
setSelection(item);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::moveDown()
{
int lastItem = _popUpBoss->_entries.size() - 1;
if(_selection < 0)
{
setSelection(0);
}
else if(_selection < lastItem)
{
int item = _selection;
do {
item++;
} while (item <= lastItem && _popUpBoss->_entries[item].name.size() == 0);
if(item <= lastItem)
setSelection(item);
}
}
//
// PopUpWidget
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
int x, int y, int w, int h, const StringList& list,
const string& label, int labelWidth, int cmd)
: Widget(boss, font, x, y - 1, w, h + 2),
CommandSender(boss),
_label(label),
_labelWidth(labelWidth),
_cmd(cmd)
_labelWidth(labelWidth)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kPopUpWidget;
@ -436,8 +57,6 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
_textcolor = kTextColor;
_textcolorhi = kTextColor;
_selectedItem = -1;
if(!_label.empty() && _labelWidth == 0)
_labelWidth = _font->getStringWidth(_label);
@ -447,14 +66,13 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
myTextY = (_h - _font->getFontHeight()) / 2;
myArrowsY = (_h - 8) / 2;
myPopUpDialog = new PopUpDialog(this, x + getAbsX(), y + getAbsY());
myMenu = new ContextMenu(this, font, list, cmd);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpWidget::~PopUpWidget()
{
delete myPopUpDialog;
myPopUpDialog = NULL;
delete myMenu;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -462,8 +80,13 @@ void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
if(isEnabled())
{
myPopUpDialog->_oldSelection = _selectedItem;
parent()->addDialog(myPopUpDialog);
// Add menu just underneath parent widget
uInt32 x, y;
dialog().surface().getPos(x, y);
x += getAbsX() + _labelWidth;
y += getAbsY() + getHeight();
myMenu->show(x, y, myMenu->getSelected());
}
}
@ -483,102 +106,37 @@ bool PopUpWidget::handleEvent(Event::Type e)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::appendEntry(const string& entry, int tag)
{
Entry e;
e.name = entry;
e.tag = tag;
_entries.push_back(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::clearEntries()
{
_entries.clear();
_selectedItem = -1;
// Reset the height of the popup dialog to be empty
myPopUpDialog->setHeight(2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::setSelected(int item)
{
if(item != _selectedItem)
{
if(item >= 0 && item < (int)_entries.size())
_selectedItem = item;
else
_selectedItem = -1;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::setSelectedName(const string& name)
{
for(unsigned int item = 0; item < _entries.size(); ++item)
{
if(_entries[item].name == name)
{
setSelected(item);
return;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::setSelectedTag(int tag)
{
for(unsigned int item = 0; item < _entries.size(); ++item)
{
if(_entries[item].tag == tag)
{
setSelected(item);
return;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::setSelectedMax()
{
setSelected(_entries.size() - 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::drawWidget(bool hilite)
{
//cerr << "PopUpWidget::drawWidget\n";
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
int x = _x + _labelWidth;
int w = _w - _labelWidth;
// Draw the label, if any
if (_labelWidth > 0)
fb.drawString(_font, _label, _x, _y + myTextY, _labelWidth,
isEnabled() ? _textcolor : kColor, kTextAlignRight);
s.drawString(_font, _label, _x, _y + myTextY, _labelWidth,
isEnabled() ? _textcolor : kColor, kTextAlignRight);
// Draw a thin frame around us.
fb.hLine(x, _y, x + w - 1, kColor);
fb.hLine(x, _y +_h-1, x + w - 1, kShadowColor);
fb.vLine(x, _y, _y+_h-1, kColor);
fb.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor);
s.hLine(x, _y, x + w - 1, kColor);
s.hLine(x, _y +_h-1, x + w - 1, kShadowColor);
s.vLine(x, _y, _y+_h-1, kColor);
s.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor);
// Fill the background
fb.fillRect(x + 1, _y + 1, w - 2, _h - 2, kWidColor);
s.fillRect(x + 1, _y + 1, w - 2, _h - 2, kWidColor);
// Draw an arrow pointing down at the right end to signal this is a dropdown/popup
fb.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY,
!isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor);
s.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY,
!isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor);
// Draw the selected entry, if any
if(_selectedItem >= 0)
{
TextAlignment align = (_font->getStringWidth(_entries[_selectedItem].name) > w-6) ?
kTextAlignRight : kTextAlignLeft;
fb.drawString(_font, _entries[_selectedItem].name, x+2, _y+myTextY, w-6,
!isEnabled() ? kColor : kTextColor, align);
}
const string& name = myMenu->getSelectedString();
TextAlignment align = (_font->getStringWidth(name) > w-6) ?
kTextAlignRight : kTextAlignLeft;
s.drawString(_font, name, x+2, _y+myTextY, w-6,
!isEnabled() ? kColor : kTextColor, align);
}

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: PopUpWidget.hxx,v 1.20 2008-02-06 13:45:24 stephena Exp $
// $Id: PopUpWidget.hxx,v 1.21 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -23,13 +23,13 @@
#define POPUP_WIDGET_HXX
class GUIObject;
class PopUpDialog;
#include "bspf.hxx"
#include "Array.hxx"
#include "Command.hxx"
#include "Dialog.hxx"
#include "ContextMenu.hxx"
#include "StringList.hxx"
#include "Widget.hxx"
@ -42,111 +42,36 @@ class PopUpDialog;
*/
class PopUpWidget : public Widget, public CommandSender
{
friend class PopUpDialog;
struct Entry {
string name;
int tag;
};
typedef Common::Array<Entry> EntryList;
protected:
EntryList _entries;
int _selectedItem;
string _label;
int _labelWidth;
public:
PopUpWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
int x, int y, int w, int h, const StringList& items,
const string& label, int labelWidth = 0, int cmd = 0);
~PopUpWidget();
/** Various selection methods passed directly to the underlying menu
See ContextMenu.hxx for more information. */
void setSelected(int item) { myMenu->setSelected(item); }
void setSelected(const string& name) { myMenu->setSelected(name); }
void setSelectedMax() { myMenu->setSelectedMax(); }
void clearSelection() { myMenu->clearSelection(); }
int getSelected() const { return myMenu->getSelected(); }
const string& getSelectedString() const { return myMenu->getSelectedString(); }
bool wantsFocus() { return true; }
void appendEntry(const string& entry, int tag = (int)-1);
void clearEntries();
/** Select the entry at the given index. */
void setSelected(int item);
/** Select the first entry matching the given name. */
void setSelectedName(const string& name);
/** Select the first entry matching the given tag. */
void setSelectedTag(int tag);
/** Select the highest/last entry in the internal list. */
void setSelectedMax();
int getSelected() const
{ return _selectedItem; }
int getSelectedTag() const
{ return (_selectedItem >= 0) ? _entries[_selectedItem].tag : (int)-1; }
const string& getSelectedString() const
{ return (_selectedItem >= 0) ? _entries[_selectedItem].name : EmptyString; }
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleEvent(Event::Type e);
void drawWidget(bool hilite);
protected:
int _cmd;
private:
PopUpDialog* myPopUpDialog;
ContextMenu* myMenu;
int myArrowsY;
int myTextY;
};
//
// PopUpDialog
//
class PopUpDialog : public Dialog
{
friend class PopUpWidget;
public:
PopUpDialog(PopUpWidget* boss, int clickX, int clickY);
void drawDialog();
void center() { recalc(); }
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);
void handleMouseMoved(int x, int y, int button);
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
void handleJoyDown(int stick, int button);
void handleJoyAxis(int stick, int axis, int value);
bool handleJoyHat(int stick, int hat, int value);
void handleEvent(Event::Type e);
void drawMenuEntry(int entry, bool hilite);
void recalc();
int findItem(int x, int y) const;
void setSelection(int item);
bool isMouseDown();
void moveUp();
void moveDown();
private:
void sendSelection();
void cancelSelection();
protected:
PopUpWidget* _popUpBoss;
int _clickX, _clickY;
uInt8* _buffer;
int _selection;
int _oldSelection;
int _openTime;
bool _twoColumns;
int _entriesPerColumn;
string _label;
int _labelWidth;
};
#endif

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: ProgressDialog.cxx,v 1.12 2008-03-14 23:52:17 stephena Exp $
// $Id: ProgressDialog.cxx,v 1.13 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -30,7 +30,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font,
const string& message)
: Dialog(boss->instance(), boss->parent(), 0, 0, 16, 16),
: Dialog(&boss->instance(), &boss->parent(), 0, 0, 16, 16),
myMessage(NULL),
mySlider(NULL),
myStart(0),
@ -59,8 +59,8 @@ ProgressDialog::ProgressDialog(GuiObject* boss, const GUI::Font& font,
mySlider->setMinValue(1);
mySlider->setMaxValue(100);
parent()->addDialog(this);
instance()->frameBuffer().update();
parent().addDialog(this);
instance().frameBuffer().update();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -71,7 +71,7 @@ ProgressDialog::~ProgressDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ProgressDialog::done()
{
parent()->removeDialog();
parent().removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -98,6 +98,6 @@ void ProgressDialog::setProgress(int progress)
if(progress - mySlider->getValue() > myStep)
{
mySlider->setValue(progress);
instance()->frameBuffer().update();
instance().frameBuffer().update();
}
}

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: RomAuditDialog.cxx,v 1.3 2008-03-14 23:52:17 stephena Exp $
// $Id: RomAuditDialog.cxx,v 1.4 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -111,7 +111,7 @@ RomAuditDialog::~RomAuditDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomAuditDialog::loadConfig()
{
myRomPath->setEditString(instance()->settings().getString("romdir"));
myRomPath->setEditString(instance().settings().getString("romdir"));
myResults1->setLabel("");
myResults2->setLabel("");
}
@ -128,7 +128,7 @@ void RomAuditDialog::auditRoms()
// Create a progress dialog box to show the progress of processing
// the ROMs, since this is usually a time-consuming operation
ProgressDialog progress(this, instance()->launcherFont(),
ProgressDialog progress(this, instance().launcherFont(),
"Auditing ROM files ...");
progress.setRange(0, files.size() - 1, 5);
@ -139,12 +139,12 @@ void RomAuditDialog::auditRoms()
{
string extension;
if(!files[idx].isDirectory() &&
instance()->isValidRomName(files[idx].path(), extension))
instance().isValidRomName(files[idx].path(), extension))
{
// Calculate the MD5 so we can get the rest of the info
// from the PropertiesSet (stella.pro)
const string& md5 = instance()->MD5FromFile(files[idx].path());
instance()->propSet().getMD5(md5, props);
const string& md5 = instance().MD5FromFile(files[idx].path());
instance().propSet().getMD5(md5, props);
const string& name = props.get(Cartridge_Name);
// Only rename the file if we found a valid properties entry
@ -172,7 +172,7 @@ void RomAuditDialog::auditRoms()
void RomAuditDialog::openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd)
{
parent()->addDialog(myBrowser);
parent().addDialog(myBrowser);
myBrowser->setTitle(title);
myBrowser->setEmitSignal(cmd);

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: RomInfoWidget.cxx,v 1.7 2008-03-15 19:11:00 stephena Exp $
// $Id: RomInfoWidget.cxx,v 1.8 2008-06-13 13:14:51 stephena Exp $
//============================================================================
#include <cstring>
@ -70,7 +70,7 @@ void RomInfoWidget::setProperties(const Properties& props)
myProperties = props;
// Decide whether the information should be shown immediately
if(instance()->eventHandler().state() == EventHandler::S_LAUNCHER)
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
{
parseProperties();
setDirty(); draw();
@ -83,7 +83,7 @@ void RomInfoWidget::clearProperties()
myHaveProperties = myDrawSurface = false;
// Decide whether the information should be shown immediately
if(instance()->eventHandler().state() == EventHandler::S_LAUNCHER)
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
{
setDirty(); draw();
}
@ -100,6 +100,8 @@ void RomInfoWidget::initialize()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::parseProperties()
{
// FIXME
#if 0
// Initialize to empty properties entry
mySurfaceErrorMsg = "";
myDrawSurface = false;
@ -109,7 +111,7 @@ void RomInfoWidget::parseProperties()
// The surface will always be the maximum size, but sometimes we'll
// only draw certain parts of it
if(mySurface == NULL)
mySurface = instance()->frameBuffer().createSurface(320, 260);
mySurface = instance().frameBuffer().createSurface(320, 260);
// The input stream for the PNG file
ifstream in;
@ -124,7 +126,7 @@ void RomInfoWidget::parseProperties()
// Get a valid filename representing a snapshot file for this rom
const string& filename =
instance()->settings().getString("ssdir") + BSPF_PATH_SEPARATOR +
instance().settings().getString("ssdir") + BSPF_PATH_SEPARATOR +
myProperties.get(Cartridge_Name) + ".png";
// Open the PNG and check for a valid signature
@ -154,7 +156,7 @@ void RomInfoWidget::parseProperties()
}
else if(type == "IDAT")
{
if(!parseIDATChunk(instance()->frameBuffer(), mySurface,
if(!parseIDATChunk(instance().frameBuffer(), mySurface,
width, height, data, size))
throw "PNG image too large";
}
@ -190,12 +192,15 @@ void RomInfoWidget::parseProperties()
myRomInfo.push_back("Controllers: " + myProperties.get(Controller_Left) +
" (left), " + myProperties.get(Controller_Right) + " (right)");
// TODO - add the PNG tEXt chunks
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = instance()->frameBuffer();
// FIXME
#if 0
FrameBuffer& fb = instance().frameBuffer();
fb.fillRect(_x+2, _y+2, _w-4, _h-4, kWidColor);
fb.box(_x, _y, _w, _h, kColor, kShadowColor);
@ -220,6 +225,7 @@ void RomInfoWidget::drawWidget(bool hilite)
fb.drawString(_font, myRomInfo[i], xpos, ypos, _w - 10, _textcolor);
ypos += _font->getLineHeight();
}
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -278,6 +284,8 @@ bool RomInfoWidget::parseIHDR(int& width, int& height, uInt8* data, int size)
bool RomInfoWidget::parseIDATChunk(const FrameBuffer& fb, GUI::Surface* surface,
int width, int height, uInt8* data, int size)
{
// FIXME
#if 0
// The entire decompressed image data
uLongf bufsize = (width * 3 + 1) * height;
uInt8* buffer = new uInt8[bufsize];
@ -296,6 +304,7 @@ bool RomInfoWidget::parseIDATChunk(const FrameBuffer& fb, GUI::Surface* surface,
}
delete[] buffer;
return false;
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: ScrollBarWidget.cxx,v 1.22 2008-03-02 20:48:51 stephena Exp $
// $Id: ScrollBarWidget.cxx,v 1.23 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -247,37 +247,35 @@ void ScrollBarWidget::recalc()
void ScrollBarWidget::drawWidget(bool hilite)
{
//cerr << "ScrollBarWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int bottomY = _y + _h;
bool isSinglePage = (_numEntries <= _entriesPerPage);
fb.frameRect(_x, _y, _w, _h, kShadowColor);
s.frameRect(_x, _y, _w, _h, kShadowColor);
if(_draggingPart != kNoPart)
_part = _draggingPart;
// Up arrow
fb.frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, kColor);
fb.drawBitmap(up_arrow, _x, _y,
isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kScrollColorHi : kScrollColor);
s.frameRect(_x, _y, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(up_arrow, _x, _y, isSinglePage ? kColor :
(hilite && _part == kUpArrowPart) ? kScrollColorHi : kScrollColor);
// Down arrow
fb.frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, kColor);
fb.drawBitmap(down_arrow, _x, bottomY - UP_DOWN_BOX_HEIGHT,
isSinglePage ? kColor :
(hilite && _part == kDownArrowPart) ? kScrollColorHi : kScrollColor);
s.frameRect(_x, bottomY - UP_DOWN_BOX_HEIGHT, _w, UP_DOWN_BOX_HEIGHT, kColor);
s.drawBitmap(down_arrow, _x, bottomY - UP_DOWN_BOX_HEIGHT, isSinglePage ? kColor :
(hilite && _part == kDownArrowPart) ? kScrollColorHi : kScrollColor);
// Slider
if(!isSinglePage)
{
fb.fillRect(_x, _y + _sliderPos, _w, _sliderHeight,
(hilite && _part == kSliderPart) ? kScrollColorHi : kScrollColor);
fb.frameRect(_x, _y + _sliderPos, _w, _sliderHeight, kColor);
s.fillRect(_x, _y + _sliderPos, _w, _sliderHeight,
(hilite && _part == kSliderPart) ? kScrollColorHi : kScrollColor);
s.frameRect(_x, _y + _sliderPos, _w, _sliderHeight, kColor);
int y = _y + _sliderPos + _sliderHeight / 2;
fb.hLine(_x + 2, y - 2, _x + _w - 3, kWidColor);
fb.hLine(_x + 2, y, _x + _w - 3, kWidColor);
fb.hLine(_x + 2, y + 2, _x + _w - 3, kWidColor);
s.hLine(_x + 2, y - 2, _x + _w - 3, kWidColor);
s.hLine(_x + 2, y, _x + _w - 3, kWidColor);
s.hLine(_x + 2, y + 2, _x + _w - 3, kWidColor);
}
}

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: Stack.hxx,v 1.5 2008-02-06 13:45:24 stephena Exp $
// $Id: Stack.hxx,v 1.6 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,7 +56,7 @@ class FixedStack
return tmp;
}
int size() const { return _size; }
T operator [](int i)
T operator [](int i) const
{
assert(0 <= i && i < MAX_SIZE);
return _stack[i];

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: StringListWidget.cxx,v 1.10 2008-02-06 13:45:24 stephena Exp $
// $Id: StringListWidget.cxx,v 1.11 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -48,15 +48,15 @@ void StringListWidget::setList(const StringList& list)
void StringListWidget::drawWidget(bool hilite)
{
//cerr << "StringListWidget::drawWidget\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
int i, pos, len = _list.size();
string buffer;
int deltax;
// Draw a thin frame around the list.
fb.hLine(_x, _y, _x + _w - 1, kColor);
fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
fb.vLine(_x, _y, _y + _h - 1, kColor);
s.hLine(_x, _y, _x + _w - 1, kColor);
s.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
s.vLine(_x, _y, _y + _h - 1, kColor);
// Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++)
@ -69,9 +69,9 @@ void StringListWidget::drawWidget(bool hilite)
if (_selectedItem == pos)
{
if (_hasFocus && !_editMode)
fb.fillRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);
s.fillRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);
else
fb.frameRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);
s.frameRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi);
}
// If in numbering mode, we first print a number prefix
@ -80,7 +80,7 @@ void StringListWidget::drawWidget(bool hilite)
char temp[10];
sprintf(temp, "%2d. ", (pos + _numberingMode));
buffer = temp;
fb.drawString(_font, buffer, _x + 2, y, _w - 4, textColor);
s.drawString(_font, buffer, _x + 2, y, _w - 4, textColor);
}
GUI::Rect r(getEditRect());
@ -90,14 +90,14 @@ void StringListWidget::drawWidget(bool hilite)
adjustOffset();
deltax = -_editScrollOffset;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor,
kTextAlignLeft, deltax, false);
}
else
{
buffer = _list[pos];
deltax = 0;
fb.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
s.drawString(_font, buffer, _x + r.left, y, r.width(), kTextColor);
}
}

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: TabWidget.cxx,v 1.31 2008-02-06 13:45:24 stephena Exp $
// $Id: TabWidget.cxx,v 1.32 2008-06-13 13:14:51 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -255,20 +255,20 @@ void TabWidget::box(int x, int y, int width, int height,
int colorA, int colorB, bool omitBottom)
{
//cerr << "TabWidget::box\n";
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
fb.hLine(x + 1, y, x + width - 2, colorA);
fb.hLine(x, y + 1, x + width - 1, colorA);
fb.vLine(x, y + 1, y + height - (omitBottom ? 1 : 2), colorA);
fb.vLine(x + 1, y, y + height - (omitBottom ? 2 : 1), colorA);
s.hLine(x + 1, y, x + width - 2, colorA);
s.hLine(x, y + 1, x + width - 1, colorA);
s.vLine(x, y + 1, y + height - (omitBottom ? 1 : 2), colorA);
s.vLine(x + 1, y, y + height - (omitBottom ? 2 : 1), colorA);
if (!omitBottom)
{
fb.hLine(x + 1, y + height - 2, x + width - 1, colorB);
fb.hLine(x + 1, y + height - 1, x + width - 2, colorB);
s.hLine(x + 1, y + height - 2, x + width - 1, colorB);
s.hLine(x + 1, y + height - 1, x + width - 2, colorB);
}
fb.vLine(x + width - 1, y + 1, y + height - (omitBottom ? 1 : 2), colorB);
fb.vLine(x + width - 2, y + 1, y + height - (omitBottom ? 2 : 1), colorB);
s.vLine(x + width - 1, y + 1, y + height - (omitBottom ? 1 : 2), colorB);
s.vLine(x + width - 2, y + 1, y + height - (omitBottom ? 2 : 1), colorB);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -279,7 +279,7 @@ void TabWidget::drawWidget(bool hilite)
// it must assume responsibility for refreshing all its children.
Widget::setDirtyInChain(_tabs[_activeTab].firstWidget);
FrameBuffer& fb = instance()->frameBuffer();
FBSurface& s = dialog().surface();
const int left1 = _x + 1;
const int right1 = _x + kTabLeftOffset + _activeTab * (_tabWidth + kTabSpacing);
@ -287,8 +287,8 @@ void TabWidget::drawWidget(bool hilite)
const int right2 = _x + _w - 2;
// Draw horizontal line
fb.hLine(left1, _y + _tabHeight - 2, right1, kShadowColor);
fb.hLine(left2, _y + _tabHeight - 2, right2, kShadowColor);
s.hLine(left1, _y + _tabHeight - 2, right1, kShadowColor);
s.hLine(left2, _y + _tabHeight - 2, right2, kShadowColor);
// Iterate over all tabs and draw them
int i, x = _x + kTabLeftOffset;
@ -298,19 +298,19 @@ void TabWidget::drawWidget(bool hilite)
int boxcolor = (i == _activeTab) ? kColor : kShadowColor;
int yOffset = (i == _activeTab) ? 0 : 2;
box(x, _y + yOffset, _tabWidth, _tabHeight - yOffset, boxcolor, boxcolor, (i == _activeTab));
fb.drawString(_font, _tabs[i].title, x + kTabPadding,
_y + yOffset / 2 + (_tabHeight - _fontHeight - 1),
_tabWidth - 2 * kTabPadding, fontcolor, kTextAlignCenter);
s.drawString(_font, _tabs[i].title, x + kTabPadding,
_y + yOffset / 2 + (_tabHeight - _fontHeight - 1),
_tabWidth - 2 * kTabPadding, fontcolor, kTextAlignCenter);
x += _tabWidth + kTabSpacing;
}
// Draw a frame around the widget area (belows the tabs)
fb.hLine(left1, _y + _tabHeight - 1, right1, kColor);
fb.hLine(left2, _y + _tabHeight - 1, right2, kColor);
fb.hLine(_x+1, _y + _h - 2, _x + _w - 2, kShadowColor);
fb.hLine(_x+1, _y + _h - 1, _x + _w - 2, kColor);
fb.vLine(_x + _w - 2, _y + _tabHeight - 1, _y + _h - 2, kColor);
fb.vLine(_x + _w - 1, _y + _tabHeight - 1, _y + _h - 2, kShadowColor);
s.hLine(left1, _y + _tabHeight - 1, right1, kColor);
s.hLine(left2, _y + _tabHeight - 1, right2, kColor);
s.hLine(_x+1, _y + _h - 2, _x + _w - 2, kShadowColor);
s.hLine(_x+1, _y + _h - 1, _x + _w - 2, kColor);
s.vLine(_x + _w - 2, _y + _tabHeight - 1, _y + _h - 2, kColor);
s.vLine(_x + _w - 1, _y + _tabHeight - 1, _y + _h - 2, kShadowColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: UIDialog.cxx,v 1.13 2008-03-23 16:22:46 stephena Exp $
// $Id: UIDialog.cxx,v 1.14 2008-06-13 13:14:52 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -28,6 +28,7 @@
#include "PopUpWidget.hxx"
#include "ScrollBarWidget.hxx"
#include "Settings.hxx"
#include "StringList.hxx"
#include "TabWidget.hxx"
#include "Widget.hxx"
@ -47,6 +48,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
int xpos, ypos, tabID;
int lwidth, pwidth = font.getStringWidth("Standard");
WidgetArray wid;
StringList items;
// Set real dimensions
// _w = 36 * fontWidth + 10;
@ -94,10 +96,12 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
ypos += lineHeight + 4;
// Launcher font
myLauncherFontPopup = new PopUpWidget(myTab, font, xpos, ypos+1, pwidth, lineHeight,
"Launcher Font: ", lwidth);
myLauncherFontPopup->appendEntry("Small", 1);
myLauncherFontPopup->appendEntry("Large", 2);
items.clear();
items.push_back("Small");
items.push_back("Large");
myLauncherFontPopup =
new PopUpWidget(myTab, font, xpos, ypos+1, pwidth, lineHeight, items,
"Launcher Font: ", lwidth);
wid.push_back(myLauncherFontPopup);
ypos += lineHeight + 4;
@ -171,10 +175,11 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
// UI Palette
ypos += 1;
items.clear();
items.push_back("Standard");
items.push_back("Classic");
myPalettePopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Interface Palette: ", lwidth);
myPalettePopup->appendEntry("Standard", 1);
myPalettePopup->appendEntry("Classic", 2);
items, "Interface Palette: ", lwidth);
wid.push_back(myPalettePopup);
ypos += lineHeight + 4;
@ -231,7 +236,7 @@ void UIDialog::loadConfig()
int w, h;
// Launcher size
instance()->settings().getSize("launcherres", w, h);
instance().settings().getSize("launcherres", w, h);
w = BSPF_max(w, 320);
h = BSPF_max(h, 240);
w = BSPF_min(w, 1920);
@ -243,15 +248,15 @@ void UIDialog::loadConfig()
myLauncherHeightLabel->setValue(h);
// Launcher font
const string& s = instance()->settings().getString("launcherfont");
myLauncherFontPopup->setSelectedTag(s == "large" ? 2 : 1);
const string& s = instance().settings().getString("launcherfont");
myLauncherFontPopup->setSelected(s == "large" ? 1 : 0);
// ROM launcher info viewer
bool b = instance()->settings().getBool("romviewer");
bool b = instance().settings().getBool("romviewer");
myRomViewerCheckbox->setState(b);
// Debugger size
instance()->settings().getSize("debuggerres", w, h);
instance().settings().getSize("debuggerres", w, h);
w = BSPF_max(w, 1030);
h = BSPF_max(h, 690);
w = BSPF_min(w, 1920);
@ -263,12 +268,12 @@ void UIDialog::loadConfig()
myDebuggerHeightLabel->setValue(h);
// UI palette
int i = instance()->settings().getInt("uipalette");
int i = instance().settings().getInt("uipalette");
if(i < 1 || i > 2) i = 1;
myPalettePopup->setSelectedTag(i);
myPalettePopup->setSelected(i-1);
// Mouse wheel lines
int mw = instance()->settings().getInt("mwheel");
int mw = instance().settings().getInt("mwheel");
if(mw < 1 || mw > 10) mw = 1;
myWheelLinesSlider->setValue(mw);
myWheelLinesLabel->setValue(mw);
@ -280,27 +285,27 @@ void UIDialog::loadConfig()
void UIDialog::saveConfig()
{
// Launcher size
instance()->settings().setSize("launcherres",
instance().settings().setSize("launcherres",
myLauncherWidthSlider->getValue(), myLauncherHeightSlider->getValue());
// Launcher font
instance()->settings().setString("launcherfont",
myLauncherFontPopup->getSelectedTag() == 1 ? "small" : "large");
instance().settings().setString("launcherfont",
myLauncherFontPopup->getSelected() == 1 ? "large" : "small");
// ROM launcher info viewer
instance()->settings().setBool("romviewer", myRomViewerCheckbox->getState());
instance().settings().setBool("romviewer", myRomViewerCheckbox->getState());
// Debugger size
instance()->settings().setSize("debuggerres",
instance().settings().setSize("debuggerres",
myDebuggerWidthSlider->getValue(), myDebuggerHeightSlider->getValue());
// UI palette
instance()->settings().setInt("uipalette",
myPalettePopup->getSelectedTag());
instance().settings().setInt("uipalette",
myPalettePopup->getSelected() + 1);
// Mouse wheel lines
int mw = myWheelLinesSlider->getValue();
instance()->settings().setInt("mwheel", mw);
instance().settings().setInt("mwheel", mw);
ScrollBarWidget::setWheelLines(mw);
}
@ -311,8 +316,8 @@ void UIDialog::setDefaults()
{
case 0: // Launcher options
{
int w = BSPF_min(instance()->desktopWidth(), 640u);
int h = BSPF_min(instance()->desktopHeight(), 480u);
int w = BSPF_min(instance().desktopWidth(), 640u);
int h = BSPF_min(instance().desktopHeight(), 480u);
myLauncherWidthSlider->setValue(w);
myLauncherWidthLabel->setValue(w);
myLauncherHeightSlider->setValue(h);
@ -329,7 +334,7 @@ void UIDialog::setDefaults()
break;
case 2: // Misc. options
myPalettePopup->setSelectedTag(1);
myPalettePopup->setSelected(0);
myWheelLinesSlider->setValue(4);
myWheelLinesLabel->setValue(4);
break;
@ -369,7 +374,7 @@ void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kOKCmd:
saveConfig();
close();
instance()->setUIPalette();
instance().setUIPalette();
break;
case kDefaultsCmd:

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: VideoDialog.cxx,v 1.50 2008-05-21 14:01:31 stephena Exp $
// $Id: VideoDialog.cxx,v 1.51 2008-06-13 13:14:52 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -30,6 +30,7 @@
#include "PopUpWidget.hxx"
#include "Console.hxx"
#include "Settings.hxx"
#include "StringList.hxx"
#include "Widget.hxx"
#include "VideoDialog.hxx"
@ -48,6 +49,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
int lwidth = font.getStringWidth("Dirty Rects: "),
pwidth = font.getStringWidth("1920x1200");
WidgetArray wid;
StringList items;
// Set real dimensions
// _w = 46 * fontWidth + 10;
@ -56,48 +58,53 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent,
xpos = 5; ypos = 10;
// Video renderer
myRendererPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight, "Renderer: ", lwidth,
kRendererChanged);
myRendererPopup->appendEntry("Software", 1);
items.clear();
items.push_back("Software");
#ifdef DISPLAY_OPENGL
myRendererPopup->appendEntry("OpenGL", 2);
items.push_back("OpenGL");
#endif
myRendererPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "Renderer: ", lwidth,
kRendererChanged);
wid.push_back(myRendererPopup);
ypos += lineHeight + 4;
// Video filter
myFilterPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight, "GL Filter: ", lwidth);
myFilterPopup->appendEntry("Linear", 1);
myFilterPopup->appendEntry("Nearest", 2);
items.clear();
items.push_back("Linear");
items.push_back("Nearest");
myFilterPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "GL Filter: ", lwidth);
wid.push_back(myFilterPopup);
ypos += lineHeight + 4;
// GL FS stretch
myFSStretchPopup = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight, "GL Stretch: ", lwidth);
myFSStretchPopup->appendEntry("Never", 1);
myFSStretchPopup->appendEntry("UI mode", 2);
myFSStretchPopup->appendEntry("TIA mode", 3);
myFSStretchPopup->appendEntry("Always", 4);
items.clear();
items.push_back("Never");
items.push_back("UI mode");
items.push_back("TIA mode");
items.push_back("Always");
myFSStretchPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight,
items, "GL Stretch: ", lwidth);
wid.push_back(myFSStretchPopup);
ypos += lineHeight + 4;
// Palette
items.clear();
items.push_back("Standard");
items.push_back("Z26");
items.push_back("User");
myPalettePopup = new PopUpWidget(this, font, xpos, ypos, pwidth,
lineHeight, "Palette: ", lwidth);
myPalettePopup->appendEntry("Standard", 1);
myPalettePopup->appendEntry("Z26", 2);
myPalettePopup->appendEntry("User", 3);
lineHeight, items, "Palette: ", lwidth);
wid.push_back(myPalettePopup);
ypos += lineHeight + 4;
// Fullscreen resolution
items.clear();
for(uInt32 i = 0; i < instance().supportedResolutions().size(); ++i)
items.push_back(instance().supportedResolutions()[i].name);
myFSResPopup = new PopUpWidget(this, font, xpos, ypos, pwidth,
lineHeight, "FS Res: ", lwidth);
for(uInt32 i = 0; i < instance()->supportedResolutions().size(); ++i)
myFSResPopup->appendEntry(instance()->supportedResolutions()[i].name, i+1);
lineHeight, items, "FS Res: ", lwidth);
wid.push_back(myFSResPopup);
ypos += lineHeight + 4;
@ -220,78 +227,82 @@ void VideoDialog::loadConfig()
int i;
// Renderer setting
s = instance()->settings().getString("video");
if(s == "soft") myRendererPopup->setSelectedTag(1);
else if(s == "gl") myRendererPopup->setSelectedTag(2);
s = instance().settings().getString("video");
myRendererPopup->clearSelection();
if(s == "soft") myRendererPopup->setSelected(0);
else if(s == "gl") myRendererPopup->setSelected(1);
// Filter setting
s = instance()->settings().getString("gl_filter");
if(s == "linear") myFilterPopup->setSelectedTag(1);
else if(s == "nearest") myFilterPopup->setSelectedTag(2);
s = instance().settings().getString("gl_filter");
myFilterPopup->clearSelection();
if(s == "linear") myFilterPopup->setSelected(0);
else if(s == "nearest") myFilterPopup->setSelected(1);
// GL stretch setting
s = instance()->settings().getString("gl_fsmax");
if(s == "never") myFSStretchPopup->setSelectedTag(1);
else if(s == "ui") myFSStretchPopup->setSelectedTag(2);
else if(s == "tia") myFSStretchPopup->setSelectedTag(3);
else if(s == "always") myFSStretchPopup->setSelectedTag(4);
else myFSStretchPopup->setSelectedTag(1);
s = instance().settings().getString("gl_fsmax");
myFSStretchPopup->clearSelection();
if(s == "never") myFSStretchPopup->setSelected(0);
else if(s == "ui") myFSStretchPopup->setSelected(1);
else if(s == "tia") myFSStretchPopup->setSelected(2);
else if(s == "always") myFSStretchPopup->setSelected(3);
// Palette
s = instance()->settings().getString("palette");
if(s == "standard") myPalettePopup->setSelectedTag(1);
else if(s == "z26") myPalettePopup->setSelectedTag(2);
else if(s == "user") myPalettePopup->setSelectedTag(3);
s = instance().settings().getString("palette");
myPalettePopup->clearSelection();
if(s == "standard") myPalettePopup->setSelected(0);
else if(s == "z26") myPalettePopup->setSelected(1);
else if(s == "user") myPalettePopup->setSelected(2);
// Fullscreen resolution
s = instance()->settings().getString("fullres");
myFSResPopup->setSelectedName(s);
if(myFSResPopup->getSelectedTag() < 0)
s = instance().settings().getString("fullres");
myFSResPopup->clearSelection();
myFSResPopup->setSelected(s);
if(myFSResPopup->getSelected() < 0)
myFSResPopup->setSelectedMax();
// UI zoom level
s = instance()->settings().getString("zoom_ui");
i = instance()->settings().getInt("zoom_ui");
s = instance().settings().getString("zoom_ui");
i = instance().settings().getInt("zoom_ui");
myUIZoomSlider->setValue(i);
myUIZoomLabel->setLabel(s);
// TIA zoom level
s = instance()->settings().getString("zoom_tia");
i = instance()->settings().getInt("zoom_tia");
s = instance().settings().getString("zoom_tia");
i = instance().settings().getInt("zoom_tia");
myTIAZoomSlider->setValue(i);
myTIAZoomLabel->setLabel(s);
// GL aspect ratio setting
s = instance()->settings().getString("gl_aspect");
i = instance()->settings().getInt("gl_aspect");
s = instance().settings().getString("gl_aspect");
i = instance().settings().getInt("gl_aspect");
myAspectRatioSlider->setValue(i);
myAspectRatioLabel->setLabel(s);
// Framerate (0 or -1 means disabled)
s = instance()->settings().getString("framerate");
i = instance()->settings().getInt("framerate");
s = instance().settings().getString("framerate");
i = instance().settings().getInt("framerate");
myFrameRateSlider->setValue(i < 0 ? 0 : i);
myFrameRateLabel->setLabel(i < 0 ? "0" : s);
// Fullscreen
b = instance()->settings().getBool("fullscreen");
b = instance().settings().getBool("fullscreen");
myFullscreenCheckbox->setState(b);
handleFullscreenChange(b);
// PAL color-loss effect
b = instance()->settings().getBool("colorloss");
b = instance().settings().getBool("colorloss");
myColorLossCheckbox->setState(b);
// Use sync to vertical blank (GL mode only)
b = instance()->settings().getBool("gl_vsync");
b = instance().settings().getBool("gl_vsync");
myUseVSyncCheckbox->setState(b);
// Center window
b = instance()->settings().getBool("center");
b = instance().settings().getBool("center");
myCenterCheckbox->setState(b);
// Make sure that mutually-exclusive items are not enabled at the same time
i = myRendererPopup->getSelectedTag();
i = myRendererPopup->getSelected();
handleRendererChange(i);
}
@ -303,85 +314,85 @@ void VideoDialog::saveConfig()
bool b;
// Renderer setting
i = myRendererPopup->getSelectedTag();
if(i == 1) s = "soft";
else if(i == 2) s = "gl";
instance()->settings().setString("video", s);
i = myRendererPopup->getSelected();
if(i == 0) s = "soft";
else if(i == 1) s = "gl";
instance().settings().setString("video", s);
// Filter setting
i = myFilterPopup->getSelectedTag();
if(i == 1) s = "linear";
else if(i == 2) s = "nearest";
instance()->settings().setString("gl_filter", s);
i = myFilterPopup->getSelected();
if(i == 0) s = "linear";
else if(i == 1) s = "nearest";
instance().settings().setString("gl_filter", s);
// GL stretch setting
i = myFSStretchPopup->getSelectedTag();
if(i == 1) s = "never";
else if(i == 2) s = "ui";
else if(i == 3) s = "tia";
else if(i == 4) s = "always";
instance()->settings().setString("gl_fsmax", s);
i = myFSStretchPopup->getSelected();
if(i == 0) s = "never";
else if(i == 1) s = "ui";
else if(i == 2) s = "tia";
else if(i == 3) s = "always";
instance().settings().setString("gl_fsmax", s);
// Palette
i = myPalettePopup->getSelectedTag();
if(i == 1) s = "standard";
else if(i == 2) s = "z26";
else if(i == 3) s = "user";
instance()->settings().setString("palette", s);
i = myPalettePopup->getSelected();
if(i == 0) s = "standard";
else if(i == 1) s = "z26";
else if(i == 2) s = "user";
instance().settings().setString("palette", s);
// Fullscreen resolution
s = myFSResPopup->getSelectedString();
instance()->settings().setString("fullres", s);
instance().settings().setString("fullres", s);
// UI Scaler
s = myUIZoomLabel->getLabel();
instance()->settings().setString("zoom_ui", s);
instance().settings().setString("zoom_ui", s);
// TIA Scaler
s = myTIAZoomLabel->getLabel();
instance()->settings().setString("zoom_tia", s);
instance().settings().setString("zoom_tia", s);
// GL aspect ratio setting
s = myAspectRatioLabel->getLabel();
instance()->settings().setString("gl_aspect", s);
instance().settings().setString("gl_aspect", s);
// Framerate
i = myFrameRateSlider->getValue();
instance()->settings().setInt("framerate", i);
if(&instance()->console())
instance().settings().setInt("framerate", i);
if(&instance().console())
{
// Make sure auto-frame calculation is only enabled when necessary
instance()->console().mediaSource().enableAutoFrame(i <= 0);
instance()->console().setFramerate(i);
instance().console().mediaSource().enableAutoFrame(i <= 0);
instance().console().setFramerate(i);
}
// Fullscreen
b = myFullscreenCheckbox->getState();
instance()->settings().setBool("fullscreen", b);
instance().settings().setBool("fullscreen", b);
// PAL color-loss effect
b = myColorLossCheckbox->getState();
instance()->settings().setBool("colorloss", b);
instance().settings().setBool("colorloss", b);
// Use sync to vertical blank (GL mode only)
b = myUseVSyncCheckbox->getState();
instance()->settings().setBool("gl_vsync", b);
instance().settings().setBool("gl_vsync", b);
// Center window
b = myCenterCheckbox->getState();
instance()->settings().setBool("center", b);
instance().settings().setBool("center", b);
// Finally, issue a complete framebuffer re-initialization
instance()->createFrameBuffer(false);
instance().createFrameBuffer(false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::setDefaults()
{
myRendererPopup->setSelectedTag(1);
myFilterPopup->setSelectedTag(1);
myFSStretchPopup->setSelectedTag(1);
myPalettePopup->setSelectedTag(1);
myRendererPopup->setSelected(0);
myFilterPopup->setSelected(0);
myFSStretchPopup->setSelected(0);
myPalettePopup->setSelected(0);
myFSResPopup->setSelectedMax();
myUIZoomSlider->setValue(2);
myUIZoomLabel->setLabel("2");
@ -398,7 +409,7 @@ void VideoDialog::setDefaults()
myCenterCheckbox->setState(true);
// Make sure that mutually-exclusive items are not enabled at the same time
handleRendererChange(1); // 1 indicates software mode
handleRendererChange(0); // 0 indicates software mode
handleFullscreenChange(false); // indicates fullscreen deactivated
}
@ -407,7 +418,7 @@ void VideoDialog::handleRendererChange(int item)
{
#ifdef DISPLAY_OPENGL
// When we're in software mode, certain OpenGL-related options are disabled
bool gl = (item > 1) ? true : false;
bool gl = (item > 0) ? true : false;
myFilterPopup->setEnabled(gl);
myFSStretchPopup->setEnabled(gl);

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: Widget.cxx,v 1.57 2008-02-06 13:45:24 stephena Exp $
// $Id: Widget.cxx,v 1.58 2008-06-13 13:14:52 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -35,7 +35,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Widget::Widget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: GuiObject(boss->instance(), boss->parent(), x, y, w, h),
: GuiObject(boss->instance(), boss->parent(), boss->dialog(), x, y, w, h),
_type(0),
_boss(boss),
_font((GUI::Font*)&font),
@ -72,7 +72,7 @@ void Widget::draw()
_dirty = false;
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
if(!isVisible() || !_boss->isVisible())
return;
@ -92,12 +92,12 @@ void Widget::draw()
{
x++; y++; w-=2; h-=2;
}
fb.fillRect(x, y, w, h, (_flags & WIDGET_HILITED) ? _bgcolorhi : _bgcolor);
s.fillRect(x, y, w, h, (_flags & WIDGET_HILITED) ? _bgcolorhi : _bgcolor);
}
// Draw border
if(hasBorder) {
fb.box(_x, _y, _w, _h, kColor, kShadowColor);
s.box(_x, _y, _w, _h, kColor, kShadowColor);
_x += 4;
_y += 4;
_w -= 8;
@ -127,7 +127,7 @@ void Widget::draw()
}
// Tell the framebuffer this area is dirty
fb.addDirtyRect(getAbsX(), getAbsY(), oldW, oldH);
s.addDirtyRect(getAbsX(), getAbsY(), oldW, oldH);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -228,7 +228,7 @@ bool Widget::isWidgetInChain(WidgetArray& list, Widget* find)
Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
Widget* wid, int direction)
{
FrameBuffer& fb = boss->instance()->frameBuffer();
FBSurface& s = boss->dialog().surface();
int size = arr.size(), pos = -1;
Widget* tmp;
for(int i = 0; i < size; ++i)
@ -247,10 +247,10 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
if(tmp->_hasFocus)
{
tmp->lostFocus();
fb.frameRect(x, y, w, h, kDlgColor);
s.frameRect(x, y, w, h, kDlgColor);
tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h);
s.addDirtyRect(x, y, w, h);
}
}
@ -286,10 +286,10 @@ Widget* Widget::setFocusForChain(GuiObject* boss, WidgetArray& arr,
w = rect.width(), h = rect.height();
tmp->receivedFocus();
fb.frameRect(x, y, w, h, kWidFrameColor, kDashLine);
s.frameRect(x, y, w, h, kWidFrameColor, kDashLine);
tmp->setDirty(); tmp->draw();
fb.addDirtyRect(x, y, w, h);
s.addDirtyRect(x, y, w, h);
return tmp;
}
@ -341,9 +341,9 @@ void StaticTextWidget::setLabel(const string& label)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaticTextWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = _boss->instance()->frameBuffer();
fb.drawString(_font, _label, _x, _y, _w,
isEnabled() ? _textcolor : kColor, _align);
FBSurface& s = _boss->dialog().surface();
s.drawString(_font, _label, _x, _y, _w,
isEnabled() ? _textcolor : kColor, _align);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -408,9 +408,9 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = _boss->instance()->frameBuffer();
fb.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
!isEnabled() ? kColor : hilite ? _textcolorhi : _textcolor, _align);
FBSurface& s = _boss->dialog().surface();
s.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
!isEnabled() ? kColor : hilite ? _textcolorhi : _textcolor, _align);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -504,29 +504,29 @@ void CheckboxWidget::setState(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
// Draw the box
if(_drawBox)
fb.box(_x, _y + _boxY, 14, 14, kColor, kShadowColor);
s.box(_x, _y + _boxY, 14, 14, kColor, kShadowColor);
// Do we draw a square or cross?
fb.fillRect(_x + 2, _y + _boxY + 2, 10, 10, _bgcolor);
s.fillRect(_x + 2, _y + _boxY + 2, 10, 10, _bgcolor);
if(isEnabled())
{
if(_state)
{
unsigned int* img = _fillRect ? checked_img_o : checked_img_x;
int color = _fillRect ? kWidFrameColor : kCheckColor;
fb.drawBitmap(img, _x + 3, _y + _boxY + 3, color);
s.drawBitmap(img, _x + 3, _y + _boxY + 3, color);
}
}
else
fb.fillRect(_x + 2, _y + _boxY + 2, 10, 10, kColor);
s.fillRect(_x + 2, _y + _boxY + 2, 10, 10, kColor);
// Finally draw the label
fb.drawString(_font, _label, _x + 20, _y + _textY, _w,
isEnabled() ? kTextColor : kColor);
s.drawString(_font, _label, _x + 20, _y + _textY, _w,
isEnabled() ? kTextColor : kColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -650,24 +650,23 @@ bool SliderWidget::handleEvent(Event::Type e)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::drawWidget(bool hilite)
{
FrameBuffer& fb = _boss->instance()->frameBuffer();
FBSurface& s = _boss->dialog().surface();
// Draw the label, if any
if(_labelWidth > 0)
fb.drawString(_font, _label, _x, _y + 2, _labelWidth,
isEnabled() ? kTextColor : kColor, kTextAlignRight);
s.drawString(_font, _label, _x, _y + 2, _labelWidth,
isEnabled() ? kTextColor : kColor, kTextAlignRight);
// Draw the box
fb.box(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor, kShadowColor);
s.box(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor, kShadowColor);
// Fill the box
fb.fillRect(_x + _labelWidth + 2, _y + 2, _w - _labelWidth - 4, _h - 4,
!isEnabled() ? kColor : kWidColor);
s.fillRect(_x + _labelWidth + 2, _y + 2, _w - _labelWidth - 4, _h - 4,
!isEnabled() ? kColor : kWidColor);
// Draw the 'bar'
fb.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
!isEnabled() ? kColor :
hilite ? kSliderColorHi : kSliderColor);
s.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,17 +13,17 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.hxx,v 1.61 2008-05-11 21:18:35 stephena Exp $
// $Id: Widget.hxx,v 1.62 2008-06-13 13:14:52 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include "Dialog.hxx"
#ifndef WIDGET_HXX
#define WIDGET_HXX
class Dialog;
#include <assert.h>
#include "bspf.hxx"
@ -88,7 +88,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.61 2008-05-11 21:18:35 stephena Exp $
@version $Id: Widget.hxx,v 1.62 2008-06-13 13:14:52 stephena Exp $
*/
class Widget : public GuiObject
{

View File

@ -6,6 +6,7 @@ MODULE_OBJS := \
src/gui/BrowserDialog.o \
src/gui/CommandDialog.o \
src/gui/CommandMenu.o \
src/gui/ContextMenu.o \
src/gui/DialogContainer.o \
src/gui/Dialog.o \
src/gui/EditableWidget.o \