From e5c3eb0327bde0c167f302f64c10084ff64a7da2 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 31 Dec 2006 23:20:13 +0000 Subject: [PATCH] Added 'launchersize' commandline argument, which specifies the size of the ROM launcher window, and takes a value of 1 (320x240), 2 (400x300) and 3 (512x384). Stella must be restarted for this to take effect. Added 'uipalette' commandline argument, which selects between the palettes to use for the UI (1 - classic, 2 - GP2X). We'll probably add more of these in the future. Added UIDialog, accessible from the Options dialog, and populated with the above items. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1258 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/OSystem.cxx | 6 +- stella/src/emucore/Settings.cxx | 7 +- stella/src/gp2x/SettingsGP2X.cxx | 4 +- stella/src/gui/Launcher.cxx | 28 +++++- stella/src/gui/Launcher.hxx | 17 ++-- stella/src/gui/OptionsDialog.cxx | 14 +-- stella/src/gui/UIDialog.cxx | 164 +++++++++++++++++++++++++++++++ stella/src/gui/UIDialog.hxx | 52 ++++++++++ stella/src/gui/module.mk | 1 + 9 files changed, 266 insertions(+), 27 deletions(-) create mode 100644 stella/src/gui/UIDialog.cxx create mode 100644 stella/src/gui/UIDialog.hxx diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 7d9440551..9afdb1bc1 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.cxx @@ -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: OSystem.cxx,v 1.88 2006-12-31 17:21:17 stephena Exp $ +// $Id: OSystem.cxx,v 1.89 2006-12-31 23:20:13 stephena Exp $ //============================================================================ #include @@ -266,8 +266,8 @@ bool OSystem::createFrameBuffer(bool showmessage) // For now, we just use the standard palette // Once an interface is created for this, it will be changable // within the emulation - int palette = 0; // 1 indicates GP2X, but it should be called something else - // Perhaps tweaked and called high-contrast or something?? + int palette = mySettings->getInt("uipalette") - 1; + if(palette < 0 || palette >= kNumUIPalettes) palette = 0; myFrameBuffer->setUIPalette(&ourGUIColors[palette][0]); if(showmessage) diff --git a/stella/src/emucore/Settings.cxx b/stella/src/emucore/Settings.cxx index 0484ec411..6b92d079f 100644 --- a/stella/src/emucore/Settings.cxx +++ b/stella/src/emucore/Settings.cxx @@ -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.110 2006-12-30 22:26:28 stephena Exp $ +// $Id: Settings.cxx,v 1.111 2006-12-31 23:20:13 stephena Exp $ //============================================================================ #include @@ -80,7 +80,8 @@ Settings::Settings(OSystem* osystem) setInternal("lastrom", ""); setInternal("modtime", ""); setInternal("debugheight", "0"); - + setInternal("launchersize", "2"); + setInternal("uipalette", "0"); setInternal("autoslot", "false"); setInternal("fastscbios", "true"); } @@ -345,6 +346,8 @@ void Settings::usage() << endl << " -listrominfo Display contents of stella.pro, one line per ROM entry\n" << " -rominfo Display detailed information for the given ROM\n" + << " -launchersize <1|2|3> Set the size of the ROM launcher\n" + << " -uipalette <1|2> Used the specified palette for UI elements\n" << " -help Show the text you're now reading\n" #ifdef DEBUGGER_SUPPORT << endl diff --git a/stella/src/gp2x/SettingsGP2X.cxx b/stella/src/gp2x/SettingsGP2X.cxx index ffd9190b0..1da603a94 100644 --- a/stella/src/gp2x/SettingsGP2X.cxx +++ b/stella/src/gp2x/SettingsGP2X.cxx @@ -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: SettingsGP2X.cxx,v 1.23 2006-12-30 20:23:51 azaballa Exp $ +// $Id: SettingsGP2X.cxx,v 1.24 2006-12-31 23:20:13 stephena Exp $ // Modified on 2006/02/05 by Alex Zaballa for use on GP2X //============================================================================ @@ -42,6 +42,8 @@ SettingsGP2X::SettingsGP2X(OSystem* osystem) setInternal("p1speed", "15"); setInternal("p2speed", "15"); setInternal("p3speed", "15"); + setInternal("launchersize", "1"); + setInternal("uipalette", "1"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/Launcher.cxx b/stella/src/gui/Launcher.cxx index f72bf4ec3..dc78562ae 100644 --- a/stella/src/gui/Launcher.cxx +++ b/stella/src/gui/Launcher.cxx @@ -13,11 +13,12 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Launcher.cxx,v 1.9 2006-12-31 17:21:17 stephena Exp $ +// $Id: Launcher.cxx,v 1.10 2006-12-31 23:20:13 stephena Exp $ //============================================================================ #include "Version.hxx" #include "OSystem.hxx" +#include "Settings.hxx" #include "FrameBuffer.hxx" #include "LauncherDialog.hxx" #include "bspf.hxx" @@ -25,10 +26,27 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Launcher::Launcher(OSystem* osystem) - : DialogContainer(osystem) + : DialogContainer(osystem), + myWidth(320), + myHeight(240) { - myBaseDialog = new LauncherDialog(myOSystem, this, - 0, 0, kLauncherWidth, kLauncherHeight); + int size = myOSystem->settings().getInt("launchersize"); + switch(size) + { + case 1: + myWidth = 320; + myHeight = 240; + break; + case 2: + myWidth = 400; + myHeight = 300; + break; + case 3: + myWidth = 512; + myHeight = 384; + break; + } + myBaseDialog = new LauncherDialog(myOSystem, this, 0, 0, myWidth, myHeight); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -40,5 +58,5 @@ Launcher::~Launcher() void Launcher::initializeVideo() { string title = string("Stella ") + STELLA_VERSION; - myOSystem->frameBuffer().initialize(title, kLauncherWidth, kLauncherHeight, false); + myOSystem->frameBuffer().initialize(title, myWidth, myHeight, false); } diff --git a/stella/src/gui/Launcher.hxx b/stella/src/gui/Launcher.hxx index 777bcb6de..04bdfdf2e 100644 --- a/stella/src/gui/Launcher.hxx +++ b/stella/src/gui/Launcher.hxx @@ -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: Launcher.hxx,v 1.7 2006-12-31 17:21:17 stephena Exp $ +// $Id: Launcher.hxx,v 1.8 2006-12-31 23:20:13 stephena Exp $ //============================================================================ #ifndef LAUNCHER_HXX @@ -23,18 +23,11 @@ class OSystem; #include "DialogContainer.hxx" -enum { - kLauncherWidth = 320, - kLauncherHeight = 240 -// kLauncherWidth = 639, -// kLauncherHeight = 479 -}; - /** The base dialog for the ROM launcher in Stella. @author Stephen Anthony - @version $Id: Launcher.hxx,v 1.7 2006-12-31 17:21:17 stephena Exp $ + @version $Id: Launcher.hxx,v 1.8 2006-12-31 23:20:13 stephena Exp $ */ class Launcher : public DialogContainer { @@ -53,6 +46,12 @@ class Launcher : public DialogContainer Initialize the video subsystem wrt this class. */ void initializeVideo(); + + private: + // The width and height of this dialog + // These can only be changed by exiting and restarting Stella + int myWidth; + int myHeight; }; #endif diff --git a/stella/src/gui/OptionsDialog.cxx b/stella/src/gui/OptionsDialog.cxx index cd3980538..004365a2b 100644 --- a/stella/src/gui/OptionsDialog.cxx +++ b/stella/src/gui/OptionsDialog.cxx @@ -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.46 2006-12-30 22:26:29 stephena Exp $ +// $Id: OptionsDialog.cxx,v 1.47 2006-12-31 23:20:13 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,7 +27,7 @@ #include "VideoDialog.hxx" #include "AudioDialog.hxx" #include "InputDialog.hxx" -//#include "UIDialog.hxx" +#include "UIDialog.hxx" #include "FileSnapDialog.hxx" #include "GameInfoDialog.hxx" #include "HelpDialog.hxx" @@ -119,12 +119,13 @@ OptionsDialog::OptionsDialog(OSystem* osystem, DialogContainer* parent, w = 230; h = 185; myInputDialog = new InputDialog(myOSystem, parent, font, x, y, w, h); + w = 200; h = 90; + myUIDialog = new UIDialog(myOSystem, parent, font, x, y, w, h); + w = 280; h = 120; myFileSnapDialog = new FileSnapDialog(myOSystem, parent, font, boss, x, y, w, h); - - w = 255; h = 190; myGameInfoDialog = new GameInfoDialog(myOSystem, parent, font, this, x, y, w, h); @@ -155,7 +156,7 @@ OptionsDialog::~OptionsDialog() delete myVideoDialog; delete myAudioDialog; delete myInputDialog; -// delete myUIDialog; + delete myUIDialog; delete myFileSnapDialog; delete myGameInfoDialog; delete myCheatCodeDialog; @@ -182,8 +183,7 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd, break; case kUsrIfaceCmd: -// parent()->addDialog(myGameInfoDialog); -cerr << "UI dialog\n"; + parent()->addDialog(myUIDialog); break; case kFileSnapCmd: diff --git a/stella/src/gui/UIDialog.cxx b/stella/src/gui/UIDialog.cxx new file mode 100644 index 000000000..765af60c1 --- /dev/null +++ b/stella/src/gui/UIDialog.cxx @@ -0,0 +1,164 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2006 by Bradford W. Mott and the Stella team +// +// 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.1 2006-12-31 23:20:13 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#include + +#include "OSystem.hxx" +#include "Settings.hxx" +#include "Widget.hxx" +#include "PopUpWidget.hxx" +#include "Dialog.hxx" +#include "UIDialog.hxx" +#include "GuiUtils.hxx" + +#include "bspf.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent, + const GUI::Font& font, int x, int y, int w, int h) + : Dialog(osystem, parent, x, y, w, h) +{ + const int lineHeight = font.getLineHeight(), + fontHeight = font.getFontHeight(); + int xpos, ypos; + int lwidth = font.getStringWidth("Rom launcher size: "), + pwidth = font.getStringWidth("xxxxxxx"); + WidgetArray wid; + + xpos = 10; ypos = 10; + + // Launcher size + myLauncherPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, + "Rom launcher size: ", lwidth); + myLauncherPopup->appendEntry("320x240", 1); + myLauncherPopup->appendEntry("400x300", 2); + myLauncherPopup->appendEntry("512x384", 3); + wid.push_back(myLauncherPopup); + ypos += lineHeight + 4; + + // UI Palette + myPalettePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, + "Interface Palette: ", lwidth); + myPalettePopup->appendEntry("Classic", 1); + myPalettePopup->appendEntry("GP2X", 2); + wid.push_back(myPalettePopup); + ypos += lineHeight + 4; + + // Add message concerning usage + lwidth = font.getStringWidth("(*) Changes require application restart"); + new StaticTextWidget(this, font, 10, _h - 38, lwidth, fontHeight, + "(*) Changes require application restart", + kTextAlignLeft); + + // Add Defaults, OK and Cancel buttons + ButtonWidget* b; + b = addButton(font, 10, _h - 24, "Defaults", kDefaultsCmd); + wid.push_back(b); +#ifndef MAC_OSX + b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd); + wid.push_back(b); + addOKWidget(b); + b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd); + wid.push_back(b); + addCancelWidget(b); +#else + b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "Cancel", kCloseCmd); + wid.push_back(b); + addCancelWidget(b); + b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd); + wid.push_back(b); + addOKWidget(b); +#endif + + addToFocusList(wid); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +UIDialog::~UIDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void UIDialog::loadConfig() +{ + int i; + + // Launcher size + i = instance()->settings().getInt("launchersize"); + if(i < 1 || i > 3) + i = 1; + myLauncherPopup->setSelectedTag(i); + + // UI palette + i = instance()->settings().getInt("uipalette"); + if(i < 1 || i > 2) + i = 1; + myPalettePopup->setSelectedTag(i); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void UIDialog::saveConfig() +{ + Settings& settings = instance()->settings(); + int i; + + // Launcher size + i = myLauncherPopup->getSelectedTag(); + settings.setInt("launchersize", i); + + // UI palette + i = myPalettePopup->getSelectedTag(); + settings.setInt("uipalette", i); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void UIDialog::setDefaults() +{ +#if !defined (GP2X) + myLauncherPopup->setSelectedTag(2); + myPalettePopup->setSelectedTag(1); +#else + myLauncherPopup->setSelectedTag(1); + myPalettePopup->setSelectedTag(2); +#endif + + _dirty = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void UIDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) +{ + switch(cmd) + { + case kOKCmd: + saveConfig(); + close(); + break; + + case kDefaultsCmd: + setDefaults(); + break; + + default: + Dialog::handleCommand(sender, cmd, data, 0); + break; + } +} diff --git a/stella/src/gui/UIDialog.hxx b/stella/src/gui/UIDialog.hxx new file mode 100644 index 000000000..3287c929c --- /dev/null +++ b/stella/src/gui/UIDialog.hxx @@ -0,0 +1,52 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2006 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: UIDialog.hxx,v 1.1 2006-12-31 23:20:13 stephena Exp $ +// +// Based on code from ScummVM - Scumm Interpreter +// Copyright (C) 2002-2004 The ScummVM project +//============================================================================ + +#ifndef UI_DIALOG_HXX +#define UI_DIALOG_HXX + +class CommandSender; +class Dialog; +class DialogContainer; +class PopUpWidget; + +#include "OSystem.hxx" +#include "bspf.hxx" + +class UIDialog : public Dialog +{ + public: + UIDialog(OSystem* osystem, DialogContainer* parent, + const GUI::Font& font, int x, int y, int w, int h); + ~UIDialog(); + + protected: + PopUpWidget* myLauncherPopup; + PopUpWidget* myPalettePopup; + + private: + void loadConfig(); + void saveConfig(); + void setDefaults(); + + virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); +}; + +#endif diff --git a/stella/src/gui/module.mk b/stella/src/gui/module.mk index 2a6f57268..9e8b7c8e8 100644 --- a/stella/src/gui/module.mk +++ b/stella/src/gui/module.mk @@ -29,6 +29,7 @@ MODULE_OBJS := \ src/gui/CheckListWidget.o \ src/gui/StringListWidget.o \ src/gui/TabWidget.o \ + src/gui/UIDialog.o \ src/gui/VideoDialog.o \ src/gui/Widget.o