Almost completely finished the Video Dialog interface. Only six more

to go :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@384 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-03-26 04:19:56 +00:00
parent a4376c52cf
commit 7e3c3de3ce
9 changed files with 256 additions and 97 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: mainSDL.cxx,v 1.28 2005-03-14 04:08:13 stephena Exp $
// $Id: mainSDL.cxx,v 1.29 2005-03-26 04:19:53 stephena Exp $
//============================================================================
#include <fstream>
@ -845,6 +845,10 @@ int main(int argc, char* argv[])
return 0;
}
// Finally, make sure the settings are valid
// We do it once here, so the rest of the program can assume valid settings
//FIXME theSettings->validate();
// Create the event handler for the system
theEventHandler = new EventHandler(theOSystem);

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: Settings.cxx,v 1.33 2005-02-22 18:41:12 stephena Exp $
// $Id: Settings.cxx,v 1.34 2005-03-26 04:19:56 stephena Exp $
//============================================================================
#include <cassert>
@ -40,11 +40,9 @@ Settings::Settings(OSystem* osystem)
// Now fill it with options that are common to all versions of Stella
set("video", "soft");
set("video_driver", "");
#ifdef DISPLAY_OPENGL
set("gl_filter", "nearest");
set("gl_aspect", "2");
set("gl_aspect", "2.0");
set("gl_fsmax", "false");
#endif
set("sound", "true");
set("fragsize", "512");
set("fullscreen", "false");
@ -60,11 +58,9 @@ Settings::Settings(OSystem* osystem)
set("mergeprops", "false");
set("paddle", "0");
set("palette", "standard");
#ifdef SNAPSHOT_SUPPORT
set("ssdir", ".");
set("ssname", "romname");
set("sssingle", "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: Dialog.cxx,v 1.7 2005-03-15 22:28:05 stephena Exp $
// $Id: Dialog.cxx,v 1.8 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -75,7 +75,6 @@ void Dialog::open()
// Load the config only on the first open (ie, since close was last called)
if(_openCount++ == 0)
loadConfig();
cerr << "_openCount = " << _openCount << endl;
Widget* w = _firstWidget;

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: GuiUtils.hxx,v 1.2 2005-03-14 04:08:15 stephena Exp $
// $Id: GuiUtils.hxx,v 1.3 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -29,7 +29,7 @@
Probably not very neat, but at least it works ...
@author Stephen Anthony
@version $Id: GuiUtils.hxx,v 1.2 2005-03-14 04:08:15 stephena Exp $
@version $Id: GuiUtils.hxx,v 1.3 2005-03-26 04:19:56 stephena Exp $
*/
// Colors indices to use for the various GUI elements
@ -41,10 +41,16 @@ enum OverlayColor {
kTextColorHi
};
// Standard entries for OK/Cancel buttons
// The commands generated by various widgets
enum {
kOKCmd = 'ok ',
kCloseCmd = 'clos'
kCloseCmd = 'clos',
kDefaultsCmd,
kRendererChanged,
kVolumeChanged,
kAspectRatioChanged,
kFrameRateChanged,
kZoomChanged
};
static const string EmptyString("");

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.1 2005-03-14 04:08:15 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.2 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -100,6 +100,9 @@ void PopUpDialog::handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCou
_clickY = -1;
_openTime = (uInt32)-1;
if(_popUpBoss->_cmd)
_popUpBoss->sendCommand(_popUpBoss->_cmd, _selection);
// We remove the dialog and delete the dialog when the user has selected an item
_popUpBoss->instance()->menu().removeDialog();
delete this;
@ -263,11 +266,12 @@ void PopUpDialog::drawMenuEntry(Int32 entry, bool hilite)
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpWidget::PopUpWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uInt32 labelWidth)
const string& label, uInt32 labelWidth, Int32 cmd)
: Widget(boss, x, y - 1, w, h + 2),
CommandSender(boss),
_label(label),
_labelWidth(labelWidth)
_labelWidth(labelWidth),
_cmd(cmd)
{
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
_type = kPopUpWidget;

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.1 2005-03-14 04:08:15 stephena Exp $
// $Id: PopUpWidget.hxx,v 1.2 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -64,7 +64,7 @@ class PopUpWidget : public Widget, public CommandSender
public:
PopUpWidget(GuiObject* boss, Int32 x, Int32 y, Int32 w, Int32 h,
const string& label, uInt32 labelWidth = 0);
const string& label, uInt32 labelWidth = 0, Int32 cmd = 0);
void handleMouseDown(Int32 x, Int32 y, Int32 button, Int32 clickCount);
@ -84,6 +84,9 @@ class PopUpWidget : public Widget, public CommandSender
protected:
void drawWidget(bool hilite);
protected:
uInt32 _cmd;
private:
PopUpDialog* myPopUpDialog;
};

View File

@ -13,12 +13,14 @@
// 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.2 2005-03-15 22:28:05 stephena Exp $
// $Id: VideoDialog.cxx,v 1.3 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
//============================================================================
#include <sstream>
#include "OSystem.hxx"
#include "Settings.hxx"
#include "Menu.hxx"
@ -39,73 +41,80 @@ enum {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16 h)
: Dialog(osystem, x, y, w, h),
myDriver(NULL)
: Dialog(osystem, x, y, w, h)
{
int yoff = 10;
const int xoff = 2;
const int woff = _w - 120;
const int labelWidth = 65;
int yoff = 10,
xoff = 2,
woff = _w - 130,
labelWidth = 65;
// Video driver (query FrameBuffer for what's supported)
myDriver = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "(*)Driver: ", labelWidth);
myDriver->appendEntry("<default>", 0);
myDriver->appendEntry("");
myDriver->appendEntry("First one", 1);
myDriver->appendEntry("Another one", 2);
// Video driver (query OSystem for what's supported)
myDriverPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
"(*)Driver: ", labelWidth);
myDriverPopup->appendEntry("First one", 1);
myDriverPopup->appendEntry("Another one", 2);
yoff += kVideoRowHeight + 4;
// Video renderer
myRenderer = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "(*)Renderer: ", labelWidth);
myRenderer->appendEntry("<default>", 0);
myRenderer->appendEntry("");
myRenderer->appendEntry("Software", 1);
myRenderer->appendEntry("OpenGL", 2);
myRendererPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
"(*)Renderer: ", labelWidth, kRendererChanged);
myRendererPopup->appendEntry("Software", 1);
myRendererPopup->appendEntry("OpenGL", 2);
yoff += kVideoRowHeight + 4;
// Video filter
myFilter = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "Filter: ", labelWidth);
myFilter->appendEntry("<default>", 0);
myFilter->appendEntry("");
myFilter->appendEntry("Linear", 1);
myFilter->appendEntry("Nearest", 2);
myFilterPopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight,
"GL Filter: ", labelWidth);
myFilterPopup->appendEntry("Linear", 1);
myFilterPopup->appendEntry("Nearest", 2);
yoff += kVideoRowHeight + 4;
// Aspect ratio FIXME - maybe this should be a slider ??
myAspectRatio = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "(*)Aspect: ", labelWidth);
myAspectRatio->appendEntry("<default>", 0);
myAspectRatio->appendEntry("");
myAspectRatio->appendEntry("1.0", 1);
myAspectRatio->appendEntry("1.1", 2);
myAspectRatio->appendEntry("1.2", 3);
myAspectRatio->appendEntry("1.3", 4);
myAspectRatio->appendEntry("1.4", 5);
/*
myAspectRatio->appendEntry("1.5", 6);
myAspectRatio->appendEntry("1.6", 7);
myAspectRatio->appendEntry("1.7", 8);
myAspectRatio->appendEntry("1.8", 9);
myAspectRatio->appendEntry("1.9", 10);
myAspectRatio->appendEntry("2.0", 11);
*/
// Aspect ratio
myAspectRatioSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight,
"(*)GL Aspect: ", labelWidth, kAspectRatioChanged);
myAspectRatioSlider->setMinValue(1); myAspectRatioSlider->setMaxValue(100);
myAspectRatioLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 24, kLineHeight,
"", kTextAlignLeft);
myAspectRatioLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 4;
// Palette
myPalette = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "Palette: ", labelWidth);
myPalette->appendEntry("<default>", 0);
myPalette->appendEntry("");
myPalette->appendEntry("Standard", 1);
myPalette->appendEntry("Original", 2);
myPalette->appendEntry("Z26", 3);
myPalettePopup = new PopUpWidget(this, xoff, yoff, woff, kLineHeight, "Palette: ", labelWidth);
myPalettePopup->appendEntry("Standard", 1);
myPalettePopup->appendEntry("Original", 2);
myPalettePopup->appendEntry("Z26", 3);
yoff += kVideoRowHeight + 4;
// Add OK & Cancel buttons
// Move over to the next column
yoff = 10;
xoff = xoff + 115;
// Framerate
myFrameRateSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight,
"Framerate: ", labelWidth, kFrameRateChanged);
myFrameRateSlider->setMinValue(1); myFrameRateSlider->setMaxValue(300);
myFrameRateLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 20, kLineHeight,
"", kTextAlignLeft);
myFrameRateLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 4;
// Zoom level
myZoomSlider = new SliderWidget(this, xoff, yoff, woff - 14, kLineHeight,
"Zoom: ", labelWidth, kZoomChanged);
myZoomSlider->setMinValue(0); myZoomSlider->setMaxValue(50);
myZoomLabel = new StaticTextWidget(this, xoff + woff - 11, yoff, 20, kLineHeight,
"", kTextAlignLeft);
myZoomLabel->setFlags(WIDGET_CLEARBG);
yoff += kVideoRowHeight + 4;
// Add Defaults, OK and Cancel buttons
addButton( 10, _h - 24, "Defaults", kDefaultsCmd, 0);
#ifndef MAC_OSX
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
#else
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
#endif
// FIXME - get list of video drivers from OSystem
@ -113,6 +122,8 @@ VideoDialog::VideoDialog(OSystem* osystem, uInt16 x, uInt16 y, uInt16 w, uInt16
// for (; l->code; ++l) {
// _langPopUp->appendEntry(l->description, l->id);
// }
setDefaults();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -123,59 +134,156 @@ VideoDialog::~VideoDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::loadConfig()
{
cerr << "VideoDialog::loadConfig()\n";
string s;
bool b;
uInt32 i;
float f;
// Driver setting
myDriver->setSelectedTag(0); // FIXME
myDriverPopup->setSelectedTag(0); // FIXME
// Renderer setting
s = instance()->settings().getString("video");
if(s == "soft")
myRenderer->setSelectedTag(1);
myRendererPopup->setSelectedTag(1);
else if(s == "gl")
myRenderer->setSelectedTag(2);
else
myRenderer->setSelectedTag(0);
myRendererPopup->setSelectedTag(2);
// Filter setting
s = instance()->settings().getString("gl_filter");
if(s == "linear")
myFilter->setSelectedTag(1);
myFilterPopup->setSelectedTag(1);
else if(s == "nearest")
myFilter->setSelectedTag(2);
else
myFilter->setSelectedTag(0);
myFilterPopup->setSelectedTag(2);
// Aspect ratio
// Aspect ratio - another huge hack
s = instance()->settings().getString("gl_aspect");
// TODO
f = instance()->settings().getFloat("gl_aspect");
if(f == -1.0)
{
f = 1.1;
s = "1.1";
}
else if(f < 1.1)
{
f = 1.1;
s = "1.1";
}
else if(f > 2.0)
{
f = 2.0;
s = "2.0";
}
i = (uInt32)((f * 10) - 10) * 10;
myAspectRatioSlider->setValue(i);
myAspectRatioLabel->setLabel(s);
// Palette
// Filter setting
s = instance()->settings().getString("palette");
if(s == "standard")
myPalette->setSelectedTag(1);
myPalettePopup->setSelectedTag(1);
else if(s == "original")
myPalette->setSelectedTag(2);
myPalettePopup->setSelectedTag(2);
else if(s == "z26")
myPalette->setSelectedTag(3);
else
myPalette->setSelectedTag(0);
myPalettePopup->setSelectedTag(3);
// Framerate
myFrameRateSlider->setValue(instance()->settings().getInt("framerate"));
myFrameRateLabel->setLabel(instance()->settings().getString("framerate"));
// Zoom
i = (instance()->settings().getInt("zoom") - 1) * 10;
myZoomSlider->setValue(i);
myZoomLabel->setLabel(instance()->settings().getString("zoom"));
// Make sure that mutually-exclusive items are not enabled at the same time
i = myRendererPopup->getSelectedTag() - 1;
handleRendererChange(i);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::saveConfig()
{
cerr << "VideoDialog::saveConfig()\n";
string s;
uInt32 i;
// Driver setting
instance()->settings().setString("video_driver", ""); // FIXME
// Renderer setting
i = myRendererPopup->getSelectedTag();
if(i == 1)
instance()->settings().setString("video", "soft");
else if(i == 2)
instance()->settings().setString("video", "gl");
// Filter setting
i = myFilterPopup->getSelectedTag();
if(i == 1)
instance()->settings().setString("gl_filter", "linear");
else if(i == 2)
instance()->settings().setString("gl_filter", "nearest");
// FIXME - immediately change the filtering
// Aspect ratio
s = myAspectRatioLabel->getLabel();
instance()->settings().setString("gl_aspect", s);
// Palette
s = myPalette->getSelectedString();
instance()->settings().setString("palette", s);
i = myPalettePopup->getSelectedTag();
if(i == 1)
instance()->settings().setString("palette", "standard");
else if(i == 2)
instance()->settings().setString("palette", "original");
else if(i == 3)
instance()->settings().setString("palette", "z26");
s = myPalettePopup->getSelectedString();
instance()->settings().setString("palette", s); // FIXME - make this more efficient
instance()->console().togglePalette(s);
// Framerate
i = myFrameRateSlider->getValue();
instance()->settings().setInt("framerate", i);
// FIXME - immediately change the framerate
// Zoom
i = (myZoomSlider->getValue() / 10) + 1;
instance()->settings().setInt("zoom", i);
// FIXME - immediately change the zoom
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::setDefaults()
{
myDriverPopup->setSelectedTag(0);
myRendererPopup->setSelectedTag(1);
myFilterPopup->setSelectedTag(1);
myPalettePopup->setSelectedTag(1);
myFrameRateSlider->setValue(60);
myFrameRateLabel->setLabel("60");
// For some unknown reason (ie, a bug), slider widgets can only
// take certain ranges of numbers. So we have to fudge things ...
myZoomSlider->setValue(10);
myZoomLabel->setLabel("2");
myAspectRatioSlider->setValue(100);
myAspectRatioLabel->setLabel("2.0");
// Make sure that mutually-exclusive items are not enabled at the same time
handleRendererChange(0); // 0 indicates software mode
instance()->frameBuffer().refresh();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VideoDialog::handleRendererChange(uInt32 item)
{
// When we're in software mode, certain OpenGL-related options are disabled
bool active = item == 0 ? false : true;
myFilterPopup->setEnabled(active);
myAspectRatioSlider->setEnabled(active);
myAspectRatioLabel->setEnabled(active);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -188,6 +296,35 @@ void VideoDialog::handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data)
close();
break;
case kDefaultsCmd:
setDefaults();
break;
case kRendererChanged:
handleRendererChange(data);
break;
case kAspectRatioChanged:
{
// This is terribly dirty, but what can we do?
float ratio = (((myAspectRatioSlider->getValue() + 9) / 10) / 10.0) + 1.0;
ostringstream r;
if(ratio == 2.0)
r << ratio << ".0";
else
r << ratio;
myAspectRatioLabel->setLabel(r.str());
break;
}
case kFrameRateChanged:
myFrameRateLabel->setValue(myFrameRateSlider->getValue());
break;
case kZoomChanged:
myZoomLabel->setValue((myZoomSlider->getValue() + 10) / 10);
break;
default:
Dialog::handleCommand(sender, cmd, data);
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: VideoDialog.hxx,v 1.1 2005-03-14 04:08:15 stephena Exp $
// $Id: VideoDialog.hxx,v 1.2 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -25,6 +25,8 @@
class CommandSender;
class Dialog;
class PopUpWidget;
class SliderWidget;
class StaticTextWidget;
#include "OSystem.hxx"
#include "bspf.hxx"
@ -38,15 +40,23 @@ class VideoDialog : public Dialog
virtual void handleCommand(CommandSender* sender, uInt32 cmd, uInt32 data);
protected:
PopUpWidget* myDriver;
PopUpWidget* myRenderer;
PopUpWidget* myFilter;
PopUpWidget* myAspectRatio;
PopUpWidget* myPalette;
PopUpWidget* myDriverPopup;
PopUpWidget* myRendererPopup;
PopUpWidget* myFilterPopup;
SliderWidget* myAspectRatioSlider;
StaticTextWidget* myAspectRatioLabel;
PopUpWidget* myPalettePopup;
SliderWidget* myFrameRateSlider;
StaticTextWidget* myFrameRateLabel;
SliderWidget* myZoomSlider;
StaticTextWidget* myZoomLabel;
private:
void loadConfig();
void saveConfig();
void setDefaults();
void handleRendererChange(uInt32 item);
};
#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: Widget.hxx,v 1.6 2005-03-15 22:28:05 stephena Exp $
// $Id: Widget.hxx,v 1.7 2005-03-26 04:19:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -56,7 +56,7 @@ enum {
};
enum {
kButtonWidth = 72,
kButtonWidth = 50,
kButtonHeight = 16
};
@ -64,7 +64,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.6 2005-03-15 22:28:05 stephena Exp $
@version $Id: Widget.hxx,v 1.7 2005-03-26 04:19:56 stephena Exp $
*/
class Widget : public GuiObject
{