diff --git a/stella/src/debugger/gui/RiotWidget.cxx b/stella/src/debugger/gui/RiotWidget.cxx index 85af15d57..84732f466 100644 --- a/stella/src/debugger/gui/RiotWidget.cxx +++ b/stella/src/debugger/gui/RiotWidget.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: RiotWidget.cxx,v 1.6 2008-06-13 13:14:50 stephena Exp $ +// $Id: RiotWidget.cxx,v 1.7 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -91,7 +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; + StringMap 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 @@ -159,8 +159,8 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font, lwidth = font.getStringWidth("P0 Diff: "); xpos = col; ypos += 3 * lineHeight; items.clear(); - items.push_back("B/easy"); - items.push_back("A/hard"); + items.push_back("B/easy", "b"); + items.push_back("A/hard", "a"); myP0Diff = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight, items, "P0 Diff: ", lwidth, kP0DiffChanged); myP0Diff->setTarget(this); @@ -174,8 +174,8 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& font, // TV Type ypos += myP1Diff->getHeight() + 5; items.clear(); - items.push_back("B&W"); - items.push_back("Color"); + items.push_back("B&W", "bw"); + items.push_back("Color", "color"); myTVType = new PopUpWidget(boss, font, xpos, ypos, pwidth, lineHeight, items, "TV Type: ", lwidth, kTVTypeChanged); myTVType->setTarget(this); @@ -345,11 +345,11 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) break; case kP0DiffChanged: - riot.diffP0((bool)myP0Diff->getSelected()); + riot.diffP0(myP0Diff->getSelectedTag() != "b"); break; case kP1DiffChanged: - riot.diffP1((bool)myP1Diff->getSelected()); + riot.diffP1(myP1Diff->getSelectedTag() != "b"); break; case kTVTypeChanged: diff --git a/stella/src/debugger/gui/RomListWidget.cxx b/stella/src/debugger/gui/RomListWidget.cxx index 0208f3af9..04c91554c 100644 --- a/stella/src/debugger/gui/RomListWidget.cxx +++ b/stella/src/debugger/gui/RomListWidget.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: RomListWidget.cxx,v 1.14 2008-06-19 12:01:30 stephena Exp $ +// $Id: RomListWidget.cxx,v 1.15 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -32,10 +32,10 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& font, { _type = kRomListWidget; - StringList l; + StringMap l; // l.push_back("Add bookmark"); - l.push_back("Save ROM"); - l.push_back("Set PC"); + l.push_back("Save ROM", "saverom"); + l.push_back("Set PC", "setpc"); myMenu = new ContextMenu(this, font, l); // Take advantage of a wide debugger window when possible diff --git a/stella/src/debugger/gui/RomWidget.cxx b/stella/src/debugger/gui/RomWidget.cxx index c0cf75ddc..54da33dc6 100644 --- a/stella/src/debugger/gui/RomWidget.cxx +++ b/stella/src/debugger/gui/RomWidget.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: RomWidget.cxx,v 1.26 2008-06-19 19:15:44 stephena Exp $ +// $Id: RomWidget.cxx,v 1.27 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -126,15 +126,15 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case kCMenuItemSelectedCmd: { - const string& rmb = myRomList->myMenu->getSelectedString(); + const string& rmb = myRomList->myMenu->getSelectedTag(); - if(rmb == "Save ROM") + if(rmb == "saverom") { mySaveRom->show(_x + 50, _y + 80); mySaveRom->setTitle(""); mySaveRom->setEmitSignal(kRomNameEntered); } - else if(rmb == "Set PC") + else if(rmb == "setpc") setPC(myRomList->getSelected()); break; diff --git a/stella/src/debugger/gui/TiaOutputWidget.cxx b/stella/src/debugger/gui/TiaOutputWidget.cxx index cd9223cff..ec31a7546 100644 --- a/stella/src/debugger/gui/TiaOutputWidget.cxx +++ b/stella/src/debugger/gui/TiaOutputWidget.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: TiaOutputWidget.cxx,v 1.17 2008-06-19 12:01:30 stephena Exp $ +// $Id: TiaOutputWidget.cxx,v 1.18 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -44,10 +44,10 @@ TiaOutputWidget::TiaOutputWidget(GuiObject* boss, const GUI::Font& font, _type = kTiaOutputWidget; // Create context menu for commands - StringList l; - l.push_back("Fill to scanline"); - l.push_back("Set breakpoint"); - l.push_back("Set zoom position"); + StringMap l; + l.push_back("Fill to scanline", "scanline"); + l.push_back("Set breakpoint", "bp"); + l.push_back("Set zoom position", "zoom"); myMenu = new ContextMenu(this, font, l); } @@ -109,36 +109,34 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in switch(cmd) { case kCMenuItemSelectedCmd: - switch(myMenu->getSelected()) + { + const string& rmb = myMenu->getSelectedTag(); + + if(rmb == "scanline") { - case 0: + ostringstream command; + int lines = myClickY + ystart - + instance().debugger().tiaDebug().scanlines(); + if(lines > 0) { - ostringstream command; - int lines = myClickY + ystart - - instance().debugger().tiaDebug().scanlines(); - if(lines > 0) - { - command << "scanline #" << lines; - instance().debugger().parser().run(command.str()); - } - break; - } - - case 1: - { - ostringstream command; - int scanline = myClickY + ystart; - command << "breakif _scan==#" << scanline; + command << "scanline #" << lines; instance().debugger().parser().run(command.str()); - break; } - - case 2: - if(myZoom) - myZoom->setPos(myClickX, myClickY); - break; + } + else if(rmb == "bp") + { + ostringstream command; + int scanline = myClickY + ystart; + command << "breakif _scan==#" << scanline; + instance().debugger().parser().run(command.str()); + } + else if(rmb == "zoom") + { + if(myZoom) + myZoom->setPos(myClickX, myClickY); } break; + } } } diff --git a/stella/src/debugger/gui/TiaZoomWidget.cxx b/stella/src/debugger/gui/TiaZoomWidget.cxx index 523898099..d0d8c06a5 100644 --- a/stella/src/debugger/gui/TiaZoomWidget.cxx +++ b/stella/src/debugger/gui/TiaZoomWidget.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: TiaZoomWidget.cxx,v 1.17 2008-06-19 12:01:30 stephena Exp $ +// $Id: TiaZoomWidget.cxx,v 1.18 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -56,10 +56,10 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, myYCenter = myNumRows >> 1; // Create context menu for zoom levels - StringList l; - l.push_back("2x zoom"); - l.push_back("4x zoom"); - l.push_back("8x zoom"); + StringMap l; + l.push_back("2x zoom", "2"); + l.push_back("4x zoom", "4"); + l.push_back("8x zoom", "8"); myMenu = new ContextMenu(this, font, l); } @@ -204,14 +204,7 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int { case kCMenuItemSelectedCmd: { - int item = myMenu->getSelected(), level = 0; - if(item == 0) - level = 2; - else if(item == 1) - level = 4; - else if(item == 2) - level = 8; - + int level = (int) atoi(myMenu->getSelectedTag().c_str()); if(level > 0) zoom(level); break; diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 8538c7bdf..c1b9a6b07 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.cxx,v 1.136 2008-07-22 14:54:39 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.137 2008-07-25 12:41:41 stephena Exp $ //============================================================================ #include @@ -625,21 +625,25 @@ uInt8 FrameBuffer::getPhosphor(uInt8 c1, uInt8 c2) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const StringList& FrameBuffer::supportedTIAFilters(const string& type) +const StringMap& FrameBuffer::supportedTIAFilters(const string& type) { - myTIAFilters.clear(); - + uInt32 max_zoom = maxWindowSizeForScreen(320, 210, + myOSystem->desktopWidth(), myOSystem->desktopHeight()); #ifdef SMALL_SCREEN uInt32 firstmode = 0; #else uInt32 firstmode = 1; #endif + myTIAFilters.clear(); for(uInt32 i = firstmode; i < GFX_NumModes; ++i) { // For now, just include all filters // This will change once OpenGL-only filters are added - myTIAFilters.push_back(ourGraphicsModes[i].description); - cerr << ourGraphicsModes[i].description << endl; + if(ourGraphicsModes[i].zoom <= max_zoom) + { + myTIAFilters.push_back(ourGraphicsModes[i].description, + ourGraphicsModes[i].name); + } } return myTIAFilters; } @@ -1073,14 +1077,14 @@ void FBSurface::drawString(const GUI::Font* font, const string& s, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBuffer::GraphicsMode FrameBuffer::ourGraphicsModes[GFX_NumModes] = { - { GFX_Zoom1x, "zoom1x", "Zoom 1x", 1 }, - { GFX_Zoom2x, "zoom2x", "Zoom 2x", 2 }, - { GFX_Zoom3x, "zoom3x", "Zoom 3x", 3 }, - { GFX_Zoom4x, "zoom4x", "Zoom 4x", 4 }, - { GFX_Zoom5x, "zoom5x", "Zoom 5x", 5 }, - { GFX_Zoom6x, "zoom6x", "Zoom 6x", 6 }, - { GFX_Zoom7x, "zoom7x", "Zoom 7x", 7 }, - { GFX_Zoom8x, "zoom8x", "Zoom 8x", 8 }, - { GFX_Zoom9x, "zoom9x", "Zoom 9x", 9 }, - { GFX_Zoom10x, "zoom10x", "Zoom 10x", 10 } + { GFX_Zoom1x, "zoom1x", "Zoom 1x", 1, 0x3 }, + { GFX_Zoom2x, "zoom2x", "Zoom 2x", 2, 0x3 }, + { GFX_Zoom3x, "zoom3x", "Zoom 3x", 3, 0x3 }, + { GFX_Zoom4x, "zoom4x", "Zoom 4x", 4, 0x3 }, + { GFX_Zoom5x, "zoom5x", "Zoom 5x", 5, 0x3 }, + { GFX_Zoom6x, "zoom6x", "Zoom 6x", 6, 0x3 }, + { GFX_Zoom7x, "zoom7x", "Zoom 7x", 7, 0x3 }, + { GFX_Zoom8x, "zoom8x", "Zoom 8x", 8, 0x3 }, + { GFX_Zoom9x, "zoom9x", "Zoom 9x", 9, 0x3 }, + { GFX_Zoom10x, "zoom10x", "Zoom 10x", 10, 0x3 } }; diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index 638b8ba2c..2c5115cae 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.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: FrameBuffer.hxx,v 1.101 2008-07-22 14:54:39 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.102 2008-07-25 12:41:41 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -90,7 +90,7 @@ enum { turn drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.101 2008-07-22 14:54:39 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.102 2008-07-25 12:41:41 stephena Exp $ */ class FrameBuffer { @@ -223,7 +223,7 @@ class FrameBuffer /** Get the supported TIA filters for the given framebuffer type. */ - const StringList& supportedTIAFilters(const string& type); + const StringMap& supportedTIAFilters(const string& type); /** Set up the TIA/emulation palette for a screen of any depth > 8. @@ -307,6 +307,7 @@ class FrameBuffer const char* name; const char* description; uInt32 zoom; + uInt8 avail; // 0x1 bit -> software, 0x2 bit -> opengl }; // Contains all relevant info for the dimensions of an SDL screen @@ -382,7 +383,7 @@ class FrameBuffer Uint32 myAvgPalette[256][256]; // Names of the TIA filters that can be used for this framebuffer - StringList myTIAFilters; + StringMap myTIAFilters; private: /** @@ -510,7 +511,7 @@ class FrameBuffer FrameBuffer type. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.101 2008-07-22 14:54:39 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.102 2008-07-25 12:41:41 stephena Exp $ */ // Text alignment modes for drawString() enum TextAlignment { diff --git a/stella/src/gui/AudioDialog.cxx b/stella/src/gui/AudioDialog.cxx index bf22bd2ab..368402938 100644 --- a/stella/src/gui/AudioDialog.cxx +++ b/stella/src/gui/AudioDialog.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: AudioDialog.cxx,v 1.28 2008-06-13 13:14:51 stephena Exp $ +// $Id: AudioDialog.cxx,v 1.29 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -50,7 +50,7 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent, int lwidth = font.getStringWidth("Fragment Size: "), pwidth = font.getStringWidth("4096"); WidgetArray wid; - StringList items; + StringMap items; // Set real dimensions // _w = 35 * fontWidth + 10; @@ -73,12 +73,12 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent, // 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"); + items.push_back("128", "128"); + items.push_back("256", "256"); + items.push_back("512", "512"); + items.push_back("1024", "1024"); + items.push_back("2048", "2048"); + items.push_back("4096", "4096"); myFragsizePopup = new PopUpWidget(this, font, xpos, ypos, pwidth + myVolumeLabel->getWidth() - 4, lineHeight, items, "Fragment size: ", lwidth); @@ -87,11 +87,11 @@ AudioDialog::AudioDialog(OSystem* osystem, DialogContainer* parent, // Output frequency items.clear(); - items.push_back("11025"); - items.push_back("22050"); - items.push_back("31400"); - items.push_back("44100"); - items.push_back("48000"); + items.push_back("11025", "11025"); + items.push_back("22050", "22050"); + items.push_back("31400", "31400"); + items.push_back("44100", "44100"); + items.push_back("48000", "48000"); myFreqPopup = new PopUpWidget(this, font, xpos, ypos, pwidth + myVolumeLabel->getWidth() - 4, lineHeight, items, "Output freq: ", lwidth); @@ -136,50 +136,24 @@ AudioDialog::~AudioDialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void AudioDialog::loadConfig() { - bool b; - int i; - // Volume myVolumeSlider->setValue(instance().settings().getInt("volume")); myVolumeLabel->setLabel(instance().settings().getString("volume")); // Fragsize - 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); + myFragsizePopup->setSelected(instance().settings().getString("fragsize"), "512"); // Output frequency - 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); + myFreqPopup->setSelected(instance().settings().getString("freq"), "31400"); // TIA frequency - 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); + myTiaFreqPopup->setSelected(instance().settings().getString("tiafreq"), "31400"); // Clip volume - b = instance().settings().getBool("clipvol"); - myClipVolumeCheckbox->setState(b); + myClipVolumeCheckbox->setState(instance().settings().getBool("clipvol")); // Enable sound - b = instance().settings().getBool("sound"); + bool b = instance().settings().getBool("sound"); mySoundEnableCheckbox->setState(b); // Make sure that mutually-exclusive items are not enabled at the same time @@ -190,33 +164,24 @@ void AudioDialog::loadConfig() void AudioDialog::saveConfig() { Settings& settings = instance().settings(); - string s; - bool b; - int i; // Volume - i = myVolumeSlider->getValue(); - instance().sound().setVolume(i); + instance().sound().setVolume(myVolumeSlider->getValue()); // Fragsize - s = myFragsizePopup->getSelectedString(); - settings.setString("fragsize", s); + settings.setString("fragsize", myFragsizePopup->getSelectedTag()); // Output frequency - s = myFreqPopup->getSelectedString(); - settings.setString("freq", s); + settings.setString("freq", myFreqPopup->getSelectedTag()); // TIA frequency - s = myTiaFreqPopup->getSelectedString(); - settings.setString("tiafreq", s); + settings.setString("tiafreq", myTiaFreqPopup->getSelectedTag()); // Enable/disable volume clipping (requires a restart to take effect) - b = myClipVolumeCheckbox->getState(); - settings.setBool("clipvol", b); + settings.setBool("clipvol", myClipVolumeCheckbox->getState()); // Enable/disable sound (requires a restart to take effect) - b = mySoundEnableCheckbox->getState(); - instance().sound().setEnabled(b); + instance().sound().setEnabled(mySoundEnableCheckbox->getState()); // Only force a re-initialization when necessary, since it can // be a time-consuming operation @@ -230,9 +195,9 @@ void AudioDialog::setDefaults() myVolumeSlider->setValue(100); myVolumeLabel->setLabel("100"); - myFragsizePopup->setSelected(2); // 512 bytes - myFreqPopup->setSelected(2); // 31400 Hz - myTiaFreqPopup->setSelected(2); // 31400 Hz + myFragsizePopup->setSelected("512", ""); + myFreqPopup->setSelected("31400", ""); + myTiaFreqPopup->setSelected("31400", ""); myClipVolumeCheckbox->setState(true); mySoundEnableCheckbox->setState(true); diff --git a/stella/src/gui/ContextMenu.cxx b/stella/src/gui/ContextMenu.cxx index dbeaa27a2..47a49e03d 100644 --- a/stella/src/gui/ContextMenu.cxx +++ b/stella/src/gui/ContextMenu.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: ContextMenu.cxx,v 1.4 2008-06-19 19:15:44 stephena Exp $ +// $Id: ContextMenu.cxx,v 1.5 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -27,10 +27,9 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font, - const StringList& items, int cmd) + const StringMap& items, int cmd) : Dialog(&boss->instance(), &boss->parent(), 0, 0, 16, 16), CommandSender(boss), - _entries(items), _currentItem(-1), _selectedItem(-1), _rowHeight(font.getLineHeight()), @@ -40,6 +39,21 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font, _xorig(0), _yorig(0) { + addItems(items); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ContextMenu::~ContextMenu() +{ + _entries.clear(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ContextMenu::addItems(const StringMap& items) +{ + _entries.clear(); + _entries = items; + // Create two columns of entries if there are more than 10 items if(_entries.size() > 10) { @@ -59,7 +73,7 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font, int maxwidth = 0; for(unsigned int i = 0; i < _entries.size(); ++i) { - int length = _font->getStringWidth(_entries[i]); + int length = _font->getStringWidth(_entries[i].first); if(length > maxwidth) maxwidth = length; } @@ -69,12 +83,6 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font, _h = _entriesPerColumn * _rowHeight + 4; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ContextMenu::~ContextMenu() -{ - _entries.clear(); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void ContextMenu::show(uInt32 x, uInt32 y, int item) { @@ -124,11 +132,21 @@ void ContextMenu::setSelected(int item) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ContextMenu::setSelected(const string& name) +void ContextMenu::setSelected(const string& tag, const string& defaultTag) { for(unsigned int item = 0; item < _entries.size(); ++item) { - if(_entries[item] == name) + if(BSPF_strcasecmp(_entries[item].second.c_str(), tag.c_str()) == 0) + { + setSelected(item); + return; + } + } + + // If we get this far, the value wasn't found; use the default value + for(unsigned int item = 0; item < _entries.size(); ++item) + { + if(BSPF_strcasecmp(_entries[item].second.c_str(), defaultTag.c_str()) == 0) { setSelected(item); return; @@ -155,9 +173,15 @@ int ContextMenu::getSelected() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const string& ContextMenu::getSelectedString() const +const string& ContextMenu::getSelectedName() const { - return (_selectedItem >= 0) ? _entries[_selectedItem] : EmptyString; + return (_selectedItem >= 0) ? _entries[_selectedItem].first : EmptyString; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const string& ContextMenu::getSelectedTag() const +{ + return (_selectedItem >= 0) ? _entries[_selectedItem].second : EmptyString; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -324,8 +348,6 @@ void ContextMenu::drawDialog() if(_dirty) { - FBSurface& s = surface(); - // Draw menu border and background s.fillRect(_x+1, _y+1, _w-2, _h-2, kWidColor); s.box(_x, _y, _w, _h, kColor, kShadowColor); @@ -363,7 +385,7 @@ void ContextMenu::drawDialog() w = _w - 4; } if(hilite) s.fillRect(x, y, w, _rowHeight, kTextColorHi); - s.drawString(_font, _entries[i], x + 1, y + 2, w - 2, + s.drawString(_font, _entries[i].first, x + 1, y + 2, w - 2, hilite ? kWidColor : kTextColor); } s.addDirtyRect(_x, _y, _w, _h); diff --git a/stella/src/gui/ContextMenu.hxx b/stella/src/gui/ContextMenu.hxx index 470d59b07..74c0b458d 100644 --- a/stella/src/gui/ContextMenu.hxx +++ b/stella/src/gui/ContextMenu.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: ContextMenu.hxx,v 1.4 2008-06-19 19:15:44 stephena Exp $ +// $Id: ContextMenu.hxx,v 1.5 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -43,17 +43,20 @@ class ContextMenu : public Dialog, public CommandSender { public: ContextMenu(GuiObject* boss, const GUI::Font& font, - const StringList& items, int cmd = 0); + const StringMap& items, int cmd = 0); virtual ~ContextMenu(); + /** Add the given items to the widget. */ + void addItems(const StringMap& items); + /** Show context menu onscreen at the specified coordinates */ void show(uInt32 x, uInt32 y, int item = -1); /** 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 first entry matching the given tag. */ + void setSelected(const string& tag, const string& defaultTag); /** Select the highest/last entry in the internal list. */ void setSelectedMax(); @@ -63,7 +66,8 @@ class ContextMenu : public Dialog, public CommandSender /** Accessor methods for the currently selected item. */ int getSelected() const; - const string& getSelectedString() const; + const string& getSelectedName() const; + const string& getSelectedTag() const; /** This dialog uses its own positioning, so we override Dialog::center() */ void center(); @@ -92,7 +96,7 @@ class ContextMenu : public Dialog, public CommandSender void sendSelection(); private: - StringList _entries; + StringMap _entries; int _currentItem; int _selectedItem; diff --git a/stella/src/gui/GameInfoDialog.cxx b/stella/src/gui/GameInfoDialog.cxx index 73300cc84..8a2e9de5d 100644 --- a/stella/src/gui/GameInfoDialog.cxx +++ b/stella/src/gui/GameInfoDialog.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: GameInfoDialog.cxx,v 1.57 2008-06-13 13:14:51 stephena Exp $ +// $Id: GameInfoDialog.cxx,v 1.58 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -48,9 +48,8 @@ GameInfoDialog::GameInfoDialog( buttonHeight = font.getLineHeight() + 4; const int vBorder = 4; int xpos, ypos, lwidth, fwidth, pwidth, tabID; - unsigned int i; WidgetArray wid; - StringList items; + StringMap items, ports, ctrls; // The tab widget xpos = 2; ypos = vBorder; @@ -111,8 +110,8 @@ GameInfoDialog::GameInfoDialog( "Sound:", kTextAlignLeft); pwidth = font.getStringWidth("Stereo"); items.clear(); - items.push_back("Mono"); - items.push_back("Stereo"); + items.push_back("Mono", "MONO"); + items.push_back("Stereo", "STEREO"); mySound = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(mySound); @@ -122,8 +121,31 @@ GameInfoDialog::GameInfoDialog( "Type:", kTextAlignLeft); pwidth = font.getStringWidth("SB (128-256k SUPERbanking)"); items.clear(); - for(i = 0; i < kNumCartTypes; ++i) - items.push_back(ourCartridgeList[i][0]); + items.push_back("Auto-detect", "AUTO-DETECT"); + items.push_back("0840 (8K ECONObanking)", "0840" ); + items.push_back("2K (2K Atari)", "2K" ); + items.push_back("3E (32K Tigervision)", "3E" ); + items.push_back("3F (512K Tigervision)", "3F" ); + items.push_back("4A50 (64K 4A50 + ram)", "4A50" ); + items.push_back("4K (4K Atari)", "4K" ); + items.push_back("AR (Supercharger)", "AR" ); + items.push_back("CV (Commavid extra ram)", "CV" ); + items.push_back("DPC (Pitfall II)", "DPC" ); + items.push_back("E0 (8K Parker Bros)", "E0" ); + items.push_back("E7 (16K M-network)", "E7" ); + items.push_back("F4 (32K Atari)", "F4" ); + items.push_back("F4SC (32K Atari + ram)", "F4SC" ); + items.push_back("F6 (16K Atari)", "F6" ); + items.push_back("F6SC (16K Atari + ram)", "F6SC" ); + items.push_back("F8 (8K Atari)", "F8" ); + items.push_back("F8SC (8K Atari + ram)", "F8SC" ); + items.push_back("FASC (CBS RAM Plus)", "FASC" ); + items.push_back("FE (8K Decathlon)", "FE" ); + items.push_back("MB (Dynacom Megaboy)", "MB" ); + items.push_back("MC (C. Wilkson Megacart)", "MC" ); + items.push_back("SB (128-256k SUPERbanking)", "SB" ); + items.push_back("UA (8K UA Ltd.)", "UA" ); + items.push_back("X07 (64K AtariAge)", "X07" ); myType = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(myType); @@ -142,8 +164,8 @@ GameInfoDialog::GameInfoDialog( new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "Left Difficulty:", kTextAlignLeft); items.clear(); - items.push_back("B"); - items.push_back("A"); + items.push_back("B", "B"); + items.push_back("A", "A"); myLeftDiff = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(myLeftDiff); @@ -160,8 +182,8 @@ GameInfoDialog::GameInfoDialog( new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "TV Type:", kTextAlignLeft); items.clear(); - items.push_back("Color"); - items.push_back("B & W"); + items.push_back("Color", "COLOR"); + items.push_back("B & W", "BLACKANDWHITE"); myTVType = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(myTVType); @@ -179,43 +201,45 @@ GameInfoDialog::GameInfoDialog( pwidth = font.getStringWidth("CX-22 Trakball"); new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "P0 Controller:", kTextAlignLeft); - items.clear(); - for(i = 0; i < kNumControllerTypes; ++i) - items.push_back(ourControllerList[i][0]); + ctrls.clear(); + ctrls.push_back("Joystick", "JOYSTICK" ); + ctrls.push_back("Paddles", "PADDLES" ); + ctrls.push_back("BoosterGrip", "BOOSTERGRIP" ); + ctrls.push_back("Driving", "DRIVING" ); + ctrls.push_back("Keyboard", "KEYBOARD" ); + ctrls.push_back("CX-22 Trakball", "TRACKBALL22" ); + ctrls.push_back("CX-80 Mouse", "TRACKBALL80" ); + ctrls.push_back("AmigaMouse", "AMIGAMOUSE" ); + ctrls.push_back("AtariVox", "ATARIVOX" ); + ctrls.push_back("SaveKey", "SAVEKEY" ); myP0Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos, - pwidth, lineHeight, items, "", 0, 0); + pwidth, lineHeight, ctrls, "", 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"); + ports.clear(); + ports.push_back("left port", "L"); + ports.push_back("right port", "R"); myLeftPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, - items, "", 0, kLeftCChanged); + ports, "", 0, kLeftCChanged); wid.push_back(myLeftPort); xpos = 10; ypos += lineHeight + 5; new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "P1 Controller:", kTextAlignLeft); - items.clear(); - for(i = 0; i < kNumControllerTypes; ++i) - items.push_back(ourControllerList[i][0]); myP1Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos, - pwidth, lineHeight, items, "", 0, 0); + pwidth, lineHeight, ctrls, "", 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, - items, "", 0, kRightCChanged); + ports, "", 0, kRightCChanged); wid.push_back(myRightPort); xpos = 10; ypos += lineHeight + 5; @@ -223,8 +247,8 @@ GameInfoDialog::GameInfoDialog( new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "Swap Paddles:", kTextAlignLeft); items.clear(); - items.push_back("Yes"); - items.push_back("No"); + items.push_back("Yes", "YES"); + items.push_back("No", "NO"); mySwapPaddles = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(mySwapPaddles); @@ -244,13 +268,13 @@ GameInfoDialog::GameInfoDialog( 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"); + items.push_back("Auto-detect", "AUTO-DETECT"); + items.push_back("NTSC", "NTSC"); + items.push_back("PAL", "PAL"); + items.push_back("SECAM", "SECAM"); + items.push_back("NTSC50", "NTSC50"); + items.push_back("PAL60", "PAL60"); + items.push_back("SECAM60", "SECAM60"); myFormat = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(myFormat); @@ -274,8 +298,8 @@ GameInfoDialog::GameInfoDialog( new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "Use Phosphor:", kTextAlignLeft); items.clear(); - items.push_back("Yes"); - items.push_back("No"); + items.push_back("Yes", "YES"); + items.push_back("No", "NO"); myPhosphor = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, kPhosphorChanged); wid.push_back(myPhosphor); @@ -297,8 +321,8 @@ GameInfoDialog::GameInfoDialog( new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight, "Use HMBlanks:", kTextAlignLeft); items.clear(); - items.push_back("Yes"); - items.push_back("No"); + items.push_back("Yes", "YES"); + items.push_back("No", "NO"); myHmoveBlanks = new PopUpWidget(myTab, font, xpos+lwidth, ypos, pwidth, lineHeight, items, "", 0, 0); wid.push_back(myHmoveBlanks); @@ -362,126 +386,45 @@ void GameInfoDialog::loadView() if(!myPropertiesLoaded) return; - string s; - int i; - // Cartridge properties - s = myGameProperties.get(Cartridge_Name); - myName->setEditString(s); - - s = myGameProperties.get(Cartridge_MD5); - myMD5->setLabel(s); - - s = myGameProperties.get(Cartridge_Manufacturer); - myManufacturer->setEditString(s); - - s = myGameProperties.get(Cartridge_ModelNo); - myModelNo->setEditString(s); - - s = myGameProperties.get(Cartridge_Rarity); - myRarity->setEditString(s); - - s = myGameProperties.get(Cartridge_Note); - myNote->setEditString(s); - - s = myGameProperties.get(Cartridge_Sound); - 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; - } - myType->setSelected(i); + myName->setEditString(myGameProperties.get(Cartridge_Name)); + myMD5->setLabel(myGameProperties.get(Cartridge_MD5)); + myManufacturer->setEditString(myGameProperties.get(Cartridge_Manufacturer)); + myModelNo->setEditString(myGameProperties.get(Cartridge_ModelNo)); + myRarity->setEditString(myGameProperties.get(Cartridge_Rarity)); + myNote->setEditString(myGameProperties.get(Cartridge_Note)); + mySound->setSelected(myGameProperties.get(Cartridge_Sound), "MONO"); + myType->setSelected(myGameProperties.get(Cartridge_Type), "AUTO-DETECT"); // Console properties - s = myGameProperties.get(Console_LeftDifficulty); - myLeftDiff->clearSelection(); - if(s == "B") myLeftDiff->setSelected(0); - else if(s == "A") myLeftDiff->setSelected(1); + myLeftDiff->setSelected(myGameProperties.get(Console_LeftDifficulty), "B"); + myRightDiff->setSelected(myGameProperties.get(Console_RightDifficulty), "B"); + myTVType->setSelected(myGameProperties.get(Console_TelevisionType), "COLOR"); - s = myGameProperties.get(Console_RightDifficulty); - myRightDiff->clearSelection(); - if(s == "B") myRightDiff->setSelected(0); - else if(s == "A") myRightDiff->setSelected(1); - - s = myGameProperties.get(Console_TelevisionType); - myTVType->clearSelection(); - if(s == "COLOR") myTVType->setSelected(0); - else if(s == "BLACKANDWHITE") myTVType->setSelected(1); - - s = myGameProperties.get(Console_SwapPorts); - myLeftPort->clearSelection(); - myRightPort->clearSelection(); - myLeftPort->setSelected(s == "NO" ? 0 : 1); - myRightPort->setSelected(s == "NO" ? 1 : 0); + const string& swap = myGameProperties.get(Console_SwapPorts); + myLeftPort->setSelected((swap == "NO" ? "L" : "R"), "L"); + myRightPort->setSelected((swap == "NO" ? "R" : "L"), "R"); // Controller properties - s = myGameProperties.get(Controller_Left); - myP0Controller->clearSelection(); - for(i = 0; i < kNumControllerTypes; ++i) - { - if(s == ourControllerList[i][1]) - break; - } - myP0Controller->setSelected(i); - - s = myGameProperties.get(Controller_Right); - myP1Controller->clearSelection(); - for(i = 0; i < kNumControllerTypes; ++i) - { - if(s == ourControllerList[i][1]) - break; - } - myP1Controller->setSelected(i); - - s = myGameProperties.get(Controller_SwapPaddles); - mySwapPaddles->clearSelection(); - if(s == "YES") mySwapPaddles->setSelected(0); - else if(s == "NO") mySwapPaddles->setSelected(1); + myP0Controller->setSelected(myGameProperties.get(Controller_Left), "JOYSTICK"); + myP1Controller->setSelected(myGameProperties.get(Controller_Right), "JOYSTICK"); + mySwapPaddles->setSelected(myGameProperties.get(Controller_SwapPaddles), "NO"); // Display properties - s = myGameProperties.get(Display_Format); - 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); + myFormat->setSelected(myGameProperties.get(Display_Format), "AUTO-DETECT"); + myYStart->setEditString(myGameProperties.get(Display_YStart)); + myHeight->setEditString(myGameProperties.get(Display_Height)); - s = myGameProperties.get(Display_YStart); - myYStart->setEditString(s); + const string& phos = myGameProperties.get(Display_Phosphor); + myPhosphor->setSelected(phos, "NO"); + myPPBlend->setEnabled(phos != "NO"); + myPPBlendLabel->setEnabled(phos != "NO"); - s = myGameProperties.get(Display_Height); - myHeight->setEditString(s); + const string& blend = myGameProperties.get(Display_PPBlend); + myPPBlend->setValue(atoi(blend.c_str())); + myPPBlendLabel->setLabel(blend); - s = myGameProperties.get(Display_Phosphor); - myPhosphor->clearSelection(); - myPPBlend->setEnabled(false); - myPPBlendLabel->setEnabled(false); - if(s == "YES") - { - myPhosphor->setSelected(0); - myPPBlend->setEnabled(true); - myPPBlendLabel->setEnabled(true); - } - else if(s == "NO") - myPhosphor->setSelected(1); - - s = myGameProperties.get(Display_PPBlend); - myPPBlend->setValue(atoi(s.c_str())); - myPPBlendLabel->setLabel(s); - - s = myGameProperties.get(Emulation_HmoveBlanks); - myHmoveBlanks->clearSelection(); - if(s == "YES") myHmoveBlanks->setSelected(0); - else if(s == "NO") myHmoveBlanks->setSelected(1); + myHmoveBlanks->setSelected(myGameProperties.get(Emulation_HmoveBlanks), "YES"); myTab->loadConfig(); } @@ -492,101 +435,33 @@ void GameInfoDialog::saveConfig() if(!myPropertiesLoaded) return; - string s; - int i, tag; - // Cartridge properties - s = myName->getEditString(); - myGameProperties.set(Cartridge_Name, s); - - s = myManufacturer->getEditString(); - myGameProperties.set(Cartridge_Manufacturer, s); - - s = myModelNo->getEditString(); - myGameProperties.set(Cartridge_ModelNo, s); - - s = myRarity->getEditString(); - myGameProperties.set(Cartridge_Rarity, s); - - s = myNote->getEditString(); - myGameProperties.set(Cartridge_Note, s); - - tag = mySound->getSelected(); - s = (tag == 0) ? "Mono" : "Stereo"; - myGameProperties.set(Cartridge_Sound, s); - - tag = myType->getSelected(); - for(i = 0; i < kNumCartTypes; ++i) - { - if(i == tag) - { - myGameProperties.set(Cartridge_Type, ourCartridgeList[i][1]); - break; - } - } + myGameProperties.set(Cartridge_Name, myName->getEditString()); + myGameProperties.set(Cartridge_Manufacturer, myManufacturer->getEditString()); + myGameProperties.set(Cartridge_ModelNo, myModelNo->getEditString()); + myGameProperties.set(Cartridge_Rarity, myRarity->getEditString()); + myGameProperties.set(Cartridge_Note, myNote->getEditString()); + myGameProperties.set(Cartridge_Sound, mySound->getSelectedTag()); + myGameProperties.set(Cartridge_Type, myType->getSelectedTag()); // Console properties - tag = myLeftDiff->getSelected(); - s = (tag == 0) ? "B" : "A"; - myGameProperties.set(Console_LeftDifficulty, s); - - tag = myRightDiff->getSelected(); - s = (tag == 0) ? "B" : "A"; - myGameProperties.set(Console_RightDifficulty, s); - - tag = myTVType->getSelected(); - s = (tag == 0) ? "Color" : "BlackAndWhite"; - myGameProperties.set(Console_TelevisionType, s); + myGameProperties.set(Console_LeftDifficulty, myLeftDiff->getSelectedTag()); + myGameProperties.set(Console_RightDifficulty, myRightDiff->getSelectedTag()); + myGameProperties.set(Console_TelevisionType, myTVType->getSelectedTag()); // Controller properties - tag = myP0Controller->getSelected(); - for(i = 0; i < kNumControllerTypes; ++i) - { - if(i == tag) - { - myGameProperties.set(Controller_Left, ourControllerList[i][1]); - break; - } - } - - tag = myP1Controller->getSelected(); - for(i = 0; i < kNumControllerTypes; ++i) - { - if(i == tag) - { - myGameProperties.set(Controller_Right, ourControllerList[i][1]); - break; - } - } - - tag = myLeftPort->getSelected(); - s = (tag == 0) ? "No" : "Yes"; - myGameProperties.set(Console_SwapPorts, s); - - tag = mySwapPaddles->getSelected(); - s = (tag == 0) ? "Yes" : "No"; - myGameProperties.set(Controller_SwapPaddles, s); + myGameProperties.set(Controller_Left, myP0Controller->getSelectedTag()); + myGameProperties.set(Controller_Right, myP1Controller->getSelectedTag()); + myGameProperties.set(Console_SwapPorts, myLeftPort->getSelectedTag()); + myGameProperties.set(Controller_SwapPaddles, mySwapPaddles->getSelectedTag()); // Display properties - s = myFormat->getSelectedString(); // use string directly - myGameProperties.set(Display_Format, s); - - s = myYStart->getEditString(); - myGameProperties.set(Display_YStart, s); - - s = myHeight->getEditString(); - myGameProperties.set(Display_Height, s); - - tag = myPhosphor->getSelected(); - s = (tag == 0) ? "Yes" : "No"; - myGameProperties.set(Display_Phosphor, s); - - s = myPPBlendLabel->getLabel(); - myGameProperties.set(Display_PPBlend, s); - - tag = myHmoveBlanks->getSelected(); - s = (tag == 0) ? "Yes" : "No"; - myGameProperties.set(Emulation_HmoveBlanks, s); + myGameProperties.set(Display_Format, myFormat->getSelectedTag()); + myGameProperties.set(Display_YStart, myYStart->getEditString()); + myGameProperties.set(Display_Height, myHeight->getEditString()); + myGameProperties.set(Display_Phosphor, myPhosphor->getSelectedTag()); + myGameProperties.set(Display_PPBlend, myPPBlendLabel->getLabel()); + myGameProperties.set(Emulation_HmoveBlanks, myHmoveBlanks->getSelectedTag()); // Determine whether to add or remove an entry from the properties set if(myDefaultsSelected) @@ -639,7 +514,7 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, case kPhosphorChanged: { - bool status = myPhosphor->getSelected() == 0 ? true : false; + bool status = myPhosphor->getSelectedTag() == "YES"; myPPBlend->setEnabled(status); myPPBlendLabel->setEnabled(status); break; @@ -654,46 +529,3 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, break; } } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* GameInfoDialog::ourControllerList[kNumControllerTypes][2] = { - { "Joystick", "JOYSTICK" }, - { "Paddles", "PADDLES" }, - { "BoosterGrip", "BOOSTERGRIP" }, - { "Driving", "DRIVING" }, - { "Keyboard", "KEYBOARD" }, - { "CX-22 Trakball", "TRACKBALL22" }, - { "CX-80 Mouse", "TRACKBALL80" }, - { "AmigaMouse", "AMIGAMOUSE" }, - { "AtariVox", "ATARIVOX" }, - { "SaveKey", "SAVEKEY" } -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const char* GameInfoDialog::ourCartridgeList[kNumCartTypes][2] = { - { "Auto-detect", "AUTO-DETECT" }, - { "0840 (8K ECONObanking)", "0840" }, - { "2K (2K Atari)", "2K" }, - { "3E (32K Tigervision)", "3E" }, - { "3F (512K Tigervision)", "3F" }, - { "4A50 (64K 4A50 + ram)", "4A50" }, - { "4K (4K Atari)", "4K" }, - { "AR (Supercharger)", "AR" }, - { "CV (Commavid extra ram)", "CV" }, - { "DPC (Pitfall II)", "DPC" }, - { "E0 (8K Parker Bros)", "E0" }, - { "E7 (16K M-network)", "E7" }, - { "F4 (32K Atari)", "F4" }, - { "F4SC (32K Atari + ram)", "F4SC" }, - { "F6 (16K Atari)", "F6" }, - { "F6SC (16K Atari + ram)", "F6SC" }, - { "F8 (8K Atari)", "F8" }, - { "F8SC (8K Atari + ram)", "F8SC" }, - { "FASC (CBS RAM Plus)", "FASC" }, - { "FE (8K Decathlon)", "FE" }, - { "MB (Dynacom Megaboy)", "MB" }, - { "MC (C. Wilkson Megacart)", "MC" }, - { "SB (128-256k SUPERbanking)", "SB" }, - { "UA (8K UA Ltd.)", "UA" }, - { "X07 (64K AtariAge)", "X07" } -}; diff --git a/stella/src/gui/GameInfoDialog.hxx b/stella/src/gui/GameInfoDialog.hxx index a6a7d4564..5dc6326d8 100644 --- a/stella/src/gui/GameInfoDialog.hxx +++ b/stella/src/gui/GameInfoDialog.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: GameInfoDialog.hxx,v 1.33 2008-05-12 22:40:26 stephena Exp $ +// $Id: GameInfoDialog.hxx,v 1.34 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -87,19 +87,11 @@ class GameInfoDialog : public Dialog, public CommandSender StaticTextWidget* myPPBlendLabel; PopUpWidget* myHmoveBlanks; - // Structure used for cartridge and controller types - struct PropType { - const char* name; - const char* comparitor; - }; - enum { kLeftCChanged = 'LCch', kRightCChanged = 'RCch', kPhosphorChanged = 'PPch', - kPPBlendChanged = 'PBch', - kNumCartTypes = 25, - kNumControllerTypes = 10 + kPPBlendChanged = 'PBch' }; /** Game properties for currently loaded ROM */ @@ -110,12 +102,6 @@ class GameInfoDialog : public Dialog, public CommandSender /** Indicates that the default properties have been loaded */ bool myDefaultsSelected; - - /** Holds static strings for Cartridge type */ - static const char* ourCartridgeList[kNumCartTypes][2]; - - /** Holds static strings for Controller type */ - static const char* ourControllerList[kNumControllerTypes][2]; }; #endif diff --git a/stella/src/gui/InputDialog.cxx b/stella/src/gui/InputDialog.cxx index 27551d5d5..0d816e192 100644 --- a/stella/src/gui/InputDialog.cxx +++ b/stella/src/gui/InputDialog.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: InputDialog.cxx,v 1.33 2008-06-13 13:14:51 stephena Exp $ +// $Id: InputDialog.cxx,v 1.34 2008-07-25 12:41:41 stephena Exp $ //============================================================================ #include "bspf.hxx" @@ -99,7 +99,7 @@ void InputDialog::addVDeviceTab(const GUI::Font& font) fontHeight = font.getFontHeight(); int xpos, ypos, lwidth, pwidth, tabID; WidgetArray wid; - StringList items; + StringMap items; // Virtual device/ports tabID = myTab->addTab("Virtual Devs"); @@ -110,8 +110,8 @@ void InputDialog::addVDeviceTab(const GUI::Font& font) pwidth = font.getStringWidth("right virtual port"); items.clear(); - items.push_back("left virtual port"); - items.push_back("right virtual port"); + items.push_back("left virtual port", "left"); + items.push_back("right virtual port", "right"); myLeftPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, "Stelladaptor 1 is: ", lwidth, kLeftChanged); wid.push_back(myLeftPort); @@ -205,8 +205,8 @@ void InputDialog::loadConfig() void InputDialog::saveConfig() { // Left & right ports - const string& sa1 = myLeftPort->getSelected() == 1 ? "right" : "left"; - const string& sa2 = myRightPort->getSelected() == 1 ? "right" : "left"; + const string& sa1 = myLeftPort->getSelectedTag(); + const string& sa2 = myRightPort->getSelectedTag(); instance().eventHandler().mapStelladaptors(sa1, sa2); // Joystick deadzone diff --git a/stella/src/gui/PopUpWidget.cxx b/stella/src/gui/PopUpWidget.cxx index 8ae0c4784..67ffb2547 100644 --- a/stella/src/gui/PopUpWidget.cxx +++ b/stella/src/gui/PopUpWidget.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: PopUpWidget.cxx,v 1.41 2008-06-19 12:01:31 stephena Exp $ +// $Id: PopUpWidget.cxx,v 1.42 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -43,7 +43,7 @@ static unsigned int up_down_arrows[8] = { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int w, int h, const StringList& list, + int x, int y, int w, int h, const StringMap& list, const string& label, int labelWidth, int cmd) : Widget(boss, font, x, y - 1, w, h + 2), CommandSender(boss), @@ -133,7 +133,7 @@ void PopUpWidget::drawWidget(bool hilite) !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor); // Draw the selected entry, if any - const string& name = myMenu->getSelectedString(); + const string& name = myMenu->getSelectedName(); TextAlignment align = (_font->getStringWidth(name) > w-6) ? kTextAlignRight : kTextAlignLeft; s.drawString(_font, name, x+2, _y+myTextY, w-6, diff --git a/stella/src/gui/PopUpWidget.hxx b/stella/src/gui/PopUpWidget.hxx index c0d8bc283..86aa6bed2 100644 --- a/stella/src/gui/PopUpWidget.hxx +++ b/stella/src/gui/PopUpWidget.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: PopUpWidget.hxx,v 1.21 2008-06-13 13:14:51 stephena Exp $ +// $Id: PopUpWidget.hxx,v 1.22 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -44,19 +44,24 @@ class PopUpWidget : public Widget, public CommandSender { public: PopUpWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, int w, int h, const StringList& items, + int x, int y, int w, int h, const StringMap& items, const string& label, int labelWidth = 0, int cmd = 0); ~PopUpWidget(); + /** Add the given items to the widget. */ + /** 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(); } + void addItems(const StringMap& items) { myMenu->addItems(items); } + void setSelected(int item) { myMenu->setSelected(item); } + void setSelected(const string& tag, + const string& def) { myMenu->setSelected(tag, def); } + void setSelectedMax() { myMenu->setSelectedMax(); } + void clearSelection() { myMenu->clearSelection(); } - int getSelected() const { return myMenu->getSelected(); } - const string& getSelectedString() const { return myMenu->getSelectedString(); } + int getSelected() const { return myMenu->getSelected(); } + const string& getSelectedName() const { return myMenu->getSelectedName(); } + const string& getSelectedTag() const { return myMenu->getSelectedTag(); } bool wantsFocus() { return true; } diff --git a/stella/src/gui/StringList.hxx b/stella/src/gui/StringList.hxx index a894baa2e..c91f0200f 100644 --- a/stella/src/gui/StringList.hxx +++ b/stella/src/gui/StringList.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: StringList.hxx,v 1.8 2008-02-06 13:45:24 stephena Exp $ +// $Id: StringList.hxx,v 1.9 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -62,4 +62,14 @@ class StringList : public Common::Array } }; +class StringMap : public Common::Array< pair > +{ + public: + void push_back(const string& name, const string& tag) + { + ensureCapacity(_size + 1); + _data[_size++] = make_pair(name, tag); + } +}; + #endif diff --git a/stella/src/gui/UIDialog.cxx b/stella/src/gui/UIDialog.cxx index 778992bb8..be22a96e4 100644 --- a/stella/src/gui/UIDialog.cxx +++ b/stella/src/gui/UIDialog.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: UIDialog.cxx,v 1.14 2008-06-13 13:14:52 stephena Exp $ +// $Id: UIDialog.cxx,v 1.15 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -48,7 +48,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent, int xpos, ypos, tabID; int lwidth, pwidth = font.getStringWidth("Standard"); WidgetArray wid; - StringList items; + StringMap items; // Set real dimensions // _w = 36 * fontWidth + 10; @@ -97,8 +97,8 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent, // Launcher font items.clear(); - items.push_back("Small"); - items.push_back("Large"); + items.push_back("Small", "small"); + items.push_back("Large", "large"); myLauncherFontPopup = new PopUpWidget(myTab, font, xpos, ypos+1, pwidth, lineHeight, items, "Launcher Font: ", lwidth); @@ -176,8 +176,8 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent, // UI Palette ypos += 1; items.clear(); - items.push_back("Standard"); - items.push_back("Classic"); + items.push_back("Standard", "1"); + items.push_back("Classic", "2"); myPalettePopup = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, "Interface Palette: ", lwidth); wid.push_back(myPalettePopup); @@ -249,11 +249,10 @@ void UIDialog::loadConfig() // Launcher font const string& s = instance().settings().getString("launcherfont"); - myLauncherFontPopup->setSelected(s == "large" ? 1 : 0); + myLauncherFontPopup->setSelected(s, "small"); // ROM launcher info viewer - bool b = instance().settings().getBool("romviewer"); - myRomViewerCheckbox->setState(b); + myRomViewerCheckbox->setState(instance().settings().getBool("romviewer")); // Debugger size instance().settings().getSize("debuggerres", w, h); @@ -268,9 +267,8 @@ void UIDialog::loadConfig() myDebuggerHeightLabel->setValue(h); // UI palette - int i = instance().settings().getInt("uipalette"); - if(i < 1 || i > 2) i = 1; - myPalettePopup->setSelected(i-1); + const string& pal = instance().settings().getString("uipalette"); + myPalettePopup->setSelected(pal, "1"); // Mouse wheel lines int mw = instance().settings().getInt("mwheel"); @@ -290,7 +288,7 @@ void UIDialog::saveConfig() // Launcher font instance().settings().setString("launcherfont", - myLauncherFontPopup->getSelected() == 1 ? "large" : "small"); + myLauncherFontPopup->getSelectedTag()); // ROM launcher info viewer instance().settings().setBool("romviewer", myRomViewerCheckbox->getState()); @@ -300,8 +298,8 @@ void UIDialog::saveConfig() myDebuggerWidthSlider->getValue(), myDebuggerHeightSlider->getValue()); // UI palette - instance().settings().setInt("uipalette", - myPalettePopup->getSelected() + 1); + instance().settings().setString("uipalette", + myPalettePopup->getSelectedTag()); // Mouse wheel lines int mw = myWheelLinesSlider->getValue(); @@ -334,7 +332,7 @@ void UIDialog::setDefaults() break; case 2: // Misc. options - myPalettePopup->setSelected(0); + myPalettePopup->setSelected("1", "1"); myWheelLinesSlider->setValue(4); myWheelLinesLabel->setValue(4); break; diff --git a/stella/src/gui/VideoDialog.cxx b/stella/src/gui/VideoDialog.cxx index 9eeaafacc..3adabcd99 100644 --- a/stella/src/gui/VideoDialog.cxx +++ b/stella/src/gui/VideoDialog.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: VideoDialog.cxx,v 1.53 2008-07-22 14:54:39 stephena Exp $ +// $Id: VideoDialog.cxx,v 1.54 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -49,7 +49,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, int lwidth = font.getStringWidth("Dirty Rects: "), pwidth = font.getStringWidth("1920x1200"); WidgetArray wid; - StringList items; + StringMap items; // Set real dimensions // _w = 46 * fontWidth + 10; @@ -59,9 +59,9 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, // Video renderer items.clear(); - items.push_back("Software"); + items.push_back("Software", "soft"); #ifdef DISPLAY_OPENGL - items.push_back("OpenGL"); + items.push_back("OpenGL", "gl"); #endif myRendererPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "Renderer: ", lwidth, @@ -69,79 +69,52 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, wid.push_back(myRendererPopup); ypos += lineHeight + 4; - // Video filter + // TIA filters (will be dynamically filled later) 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); + myTIAFilterPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, + lineHeight, items, "TIA Filter: ", lwidth); + wid.push_back(myTIAFilterPopup); ypos += lineHeight + 4; - // GL FS stretch + // TIA Palette 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, items, "Palette: ", lwidth); - wid.push_back(myPalettePopup); + items.push_back("Standard", "standard"); + items.push_back("Z26", "z26"); + items.push_back("User", "user"); + myTIAPalettePopup = new PopUpWidget(this, font, xpos, ypos, pwidth, + lineHeight, items, "TIA Palette: ", lwidth); + wid.push_back(myTIAPalettePopup); ypos += lineHeight + 4; // Fullscreen resolution items.clear(); - items.push_back("Auto"); + items.push_back("Auto", "auto"); for(uInt32 i = 0; i < instance().supportedResolutions().size(); ++i) - items.push_back(instance().supportedResolutions()[i].name); + items.push_back(instance().supportedResolutions()[i].name, + instance().supportedResolutions()[i].name); myFSResPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "FS Res: ", lwidth); wid.push_back(myFSResPopup); ypos += lineHeight + 4; -#if 0 - // Available TIA filters + // GL Video filter items.clear(); - for(uInt32 i = 0; i < instance().frameBuffer().supportedTIAFilters().size(); ++i) - items.push_back(instance().supportedResolutions()[i].name); - myFSResPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, - lineHeight, items, "FS Res: ", lwidth); - wid.push_back(myFSResPopup); + items.push_back("Linear", "linear"); + items.push_back("Nearest", "nearest"); + myGLFilterPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, + items, "GL Filter: ", lwidth); + wid.push_back(myGLFilterPopup); ypos += lineHeight + 4; -#endif -#if 0 - // Available UI zoom levels - myUIZoomSlider = new SliderWidget(this, font, xpos, ypos, pwidth, lineHeight, - "UI Zoom: ", lwidth, kUIZoomChanged); - myUIZoomSlider->setMinValue(1); myUIZoomSlider->setMaxValue(10); - wid.push_back(myUIZoomSlider); - myUIZoomLabel = - new StaticTextWidget(this, font, xpos + myUIZoomSlider->getWidth() + 4, - ypos + 1, fontWidth * 2, fontHeight, "", kTextAlignLeft); - myUIZoomLabel->setFlags(WIDGET_CLEARBG); - ypos += lineHeight + 4; -#endif - - // Available TIA zoom levels - myTIAZoomSlider = new SliderWidget(this, font, xpos, ypos, pwidth, lineHeight, - "TIA Zoom: ", lwidth, kTIAZoomChanged); - myTIAZoomSlider->setMinValue(1); myTIAZoomSlider->setMaxValue(10); - wid.push_back(myTIAZoomSlider); - myTIAZoomLabel = - new StaticTextWidget(this, font, xpos + myTIAZoomSlider->getWidth() + 4, - ypos + 1, fontWidth * 2, fontHeight, "", kTextAlignLeft); - myTIAZoomLabel->setFlags(WIDGET_CLEARBG); + // GL FS stretch + items.clear(); + items.push_back("Never", "never"); + items.push_back("UI mode", "ui"); + items.push_back("TIA mode", "tia"); + items.push_back("Always", "always"); + myGLStretchPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, + items, "GL Stretch: ", lwidth); + wid.push_back(myGLStretchPopup); ypos += lineHeight + 4; // GL aspect ratio @@ -212,15 +185,13 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, // Disable certain functions when we know they aren't present #ifndef DISPLAY_GL - myFilterPopup->clearFlags(WIDGET_ENABLED); + myGLFilterPopup->clearFlags(WIDGET_ENABLED); + myGLStretchPopup->clearFlags(WIDGET_ENABLED); myAspectRatioSlider->clearFlags(WIDGET_ENABLED); myAspectRatioLabel->clearFlags(WIDGET_ENABLED); - myFSStretchPopup->clearFlags(WIDGET_ENABLED); myUseVSyncCheckbox->clearFlags(WIDGET_ENABLED); #endif #ifndef WINDOWED_SUPPORT - myTIAZoomSlider->clearFlags(WIDGET_ENABLED); - myTIAZoomLabel->clearFlags(WIDGET_ENABLED); myFullscreenCheckbox->clearFlags(WIDGET_ENABLED); myCenterCheckbox->clearFlags(WIDGET_ENABLED); #endif @@ -234,135 +205,84 @@ VideoDialog::~VideoDialog() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::loadConfig() { - string s; - bool b; - int i; - // Renderer setting - s = BSPF_tolower(instance().settings().getString("video")); - myRendererPopup->clearSelection(); - if(s == "soft") myRendererPopup->setSelected(0); - else if(s == "gl") myRendererPopup->setSelected(1); + myRendererPopup->setSelected( + instance().settings().getString("video"), "soft"); - // Filter setting - s = BSPF_tolower(instance().settings().getString("gl_filter")); - myFilterPopup->clearSelection(); - if(s == "linear") myFilterPopup->setSelected(0); - else if(s == "nearest") myFilterPopup->setSelected(1); + // TIA Filter + // taken care of in ::handleRendererChange() - // GL stretch setting - s = BSPF_tolower(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 = BSPF_tolower(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); + // TIA Palette + myTIAPalettePopup->setSelected( + instance().settings().getString("palette"), "standard"); // Fullscreen resolution - s = BSPF_tolower(instance().settings().getString("fullres")); - myFSResPopup->clearSelection(); - if(s == "auto") myFSResPopup->setSelected(0); - else myFSResPopup->setSelected(s); - if(myFSResPopup->getSelected() < 0) - myFSResPopup->setSelectedMax(); + myFSResPopup->setSelected( + instance().settings().getString("fullres"), "auto"); -/* - // TIA zoom level - s = instance().settings().getString("zoom_tia"); - i = instance().settings().getInt("zoom_tia"); - myTIAZoomSlider->setValue(i); - myTIAZoomLabel->setLabel(s); -*/ + // GL Filter setting + myGLFilterPopup->setSelected( + instance().settings().getString("gl_filter"), "linear"); + + // GL stretch setting + myGLStretchPopup->setSelected( + instance().settings().getString("gl_fsmax"), "never"); // GL aspect ratio setting - s = instance().settings().getString("gl_aspect"); - i = instance().settings().getInt("gl_aspect"); - myAspectRatioSlider->setValue(i); - myAspectRatioLabel->setLabel(s); + myAspectRatioSlider->setValue(instance().settings().getInt("gl_aspect")); + myAspectRatioLabel->setLabel(instance().settings().getString("gl_aspect")); // Framerate (0 or -1 means disabled) - s = instance().settings().getString("framerate"); - i = instance().settings().getInt("framerate"); - myFrameRateSlider->setValue(i < 0 ? 0 : i); - myFrameRateLabel->setLabel(i < 0 ? "0" : s); + int rate = instance().settings().getInt("framerate"); + myFrameRateSlider->setValue(rate < 0 ? 0 : rate); + myFrameRateLabel->setLabel(rate < 0 ? "0" : + instance().settings().getString("framerate")); // Fullscreen - b = instance().settings().getBool("fullscreen"); + bool b = instance().settings().getBool("fullscreen"); myFullscreenCheckbox->setState(b); handleFullscreenChange(b); // PAL color-loss effect - b = instance().settings().getBool("colorloss"); - myColorLossCheckbox->setState(b); + myColorLossCheckbox->setState(instance().settings().getBool("colorloss")); // Use sync to vertical blank (GL mode only) - b = instance().settings().getBool("gl_vsync"); - myUseVSyncCheckbox->setState(b); + myUseVSyncCheckbox->setState(instance().settings().getBool("gl_vsync")); // Center window - b = instance().settings().getBool("center"); - myCenterCheckbox->setState(b); + myCenterCheckbox->setState(instance().settings().getBool("center")); // Make sure that mutually-exclusive items are not enabled at the same time - i = myRendererPopup->getSelected(); - handleRendererChange(i); + // Also, this sets the TIA filters, so it cannot be removed from here + handleRendererChange(myRendererPopup->getSelectedTag()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::saveConfig() { - string s; - int i; - bool b; - // Renderer setting - i = myRendererPopup->getSelected(); - if(i == 0) s = "soft"; - else if(i == 1) s = "gl"; - instance().settings().setString("video", s); + instance().settings().setString("video", myRendererPopup->getSelectedTag()); - // Filter setting - i = myFilterPopup->getSelected(); - if(i == 0) s = "linear"; - else if(i == 1) s = "nearest"; - instance().settings().setString("gl_filter", s); + // TIA Filter + instance().settings().setString("tia_filter", myTIAFilterPopup->getSelectedTag()); - // GL stretch setting - 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->getSelected(); - if(i == 0) s = "standard"; - else if(i == 1) s = "z26"; - else if(i == 2) s = "user"; - instance().settings().setString("palette", s); + // TIA Palette + instance().settings().setString("palette", myTIAPalettePopup->getSelectedTag()); // Fullscreen resolution - s = myFSResPopup->getSelectedString(); - instance().settings().setString("fullres", s); + instance().settings().setString("fullres", myFSResPopup->getSelectedTag()); - // TIA Scaler - s = myTIAZoomLabel->getLabel(); - instance().settings().setString("zoom_tia", s); + // GL Filter setting + instance().settings().setString("gl_filter", myGLFilterPopup->getSelectedTag()); + + // GL stretch setting + instance().settings().setString("gl_fsmax", myGLStretchPopup->getSelectedTag()); // GL aspect ratio setting - s = myAspectRatioLabel->getLabel(); - instance().settings().setString("gl_aspect", s); + instance().settings().setString("gl_aspect", myAspectRatioLabel->getLabel()); // Framerate - i = myFrameRateSlider->getValue(); + int i = myFrameRateSlider->getValue(); instance().settings().setInt("framerate", i); if(&instance().console()) { @@ -372,20 +292,16 @@ void VideoDialog::saveConfig() } // Fullscreen - b = myFullscreenCheckbox->getState(); - instance().settings().setBool("fullscreen", b); + instance().settings().setBool("fullscreen", myFullscreenCheckbox->getState()); // PAL color-loss effect - b = myColorLossCheckbox->getState(); - instance().settings().setBool("colorloss", b); + instance().settings().setBool("colorloss", myColorLossCheckbox->getState()); // Use sync to vertical blank (GL mode only) - b = myUseVSyncCheckbox->getState(); - instance().settings().setBool("gl_vsync", b); + instance().settings().setBool("gl_vsync", myUseVSyncCheckbox->getState()); // Center window - b = myCenterCheckbox->getState(); - instance().settings().setBool("center", b); + instance().settings().setBool("center", myCenterCheckbox->getState()); // Finally, issue a complete framebuffer re-initialization instance().createFrameBuffer(false); @@ -394,13 +310,17 @@ void VideoDialog::saveConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::setDefaults() { - myRendererPopup->setSelected(0); - myFilterPopup->setSelected(0); - myFSStretchPopup->setSelected(0); - myPalettePopup->setSelected(0); - myFSResPopup->setSelectedMax(); - myTIAZoomSlider->setValue(2); - myTIAZoomLabel->setLabel("2"); + myRendererPopup->setSelected("soft", ""); + myTIAFilterPopup->setSelected( +#ifdef SMALL_SCREEN + "zoom1x", ""); +#else + "zoom2x", ""); +#endif + myTIAPalettePopup->setSelected("standard", ""); + myFSResPopup->setSelected("auto", ""); + myGLFilterPopup->setSelected("linear", ""); + myGLStretchPopup->setSelected("never", ""); myAspectRatioSlider->setValue(100); myAspectRatioLabel->setLabel("100"); myFrameRateSlider->setValue(0); @@ -412,25 +332,36 @@ void VideoDialog::setDefaults() myCenterCheckbox->setState(true); // Make sure that mutually-exclusive items are not enabled at the same time - handleRendererChange(0); // 0 indicates software mode - handleFullscreenChange(false); // indicates fullscreen deactivated + handleRendererChange("soft"); + handleFullscreenChange(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void VideoDialog::handleRendererChange(int item) +void VideoDialog::handleRendererChange(const string& mode) { + // TIA filters are dynamically loaded, since they depend on the size of + // the desktop and which renderer we're using + const StringMap& items = instance().frameBuffer().supportedTIAFilters(mode); + myTIAFilterPopup->addItems(items); + myTIAFilterPopup->setSelected(instance().settings().getString("tia_filter"), +#ifdef SMALL_SCREEN + "zoom1x"); +#else + "zoom2x"); +#endif + #ifdef DISPLAY_OPENGL // When we're in software mode, certain OpenGL-related options are disabled - bool gl = (item > 0) ? true : false; + bool gl = (mode == "gl"); - myFilterPopup->setEnabled(gl); - myFSStretchPopup->setEnabled(gl); + myGLFilterPopup->setEnabled(gl); + myGLStretchPopup->setEnabled(gl); myAspectRatioSlider->setEnabled(gl); myAspectRatioLabel->setEnabled(gl); myUseVSyncCheckbox->setEnabled(gl); +#endif _dirty = true; -#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -439,9 +370,6 @@ void VideoDialog::handleFullscreenChange(bool enable) #ifdef WINDOWED_SUPPORT myFSResPopup->setEnabled(enable); - myTIAZoomSlider->setEnabled(!enable); - myTIAZoomLabel->setEnabled(!enable); - _dirty = true; #endif } @@ -462,11 +390,7 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd, break; case kRendererChanged: - handleRendererChange(data); - break; - - case kTIAZoomChanged: - myTIAZoomLabel->setValue(myTIAZoomSlider->getValue()); + handleRendererChange(myRendererPopup->getSelectedTag()); break; case kAspectRatioChanged: diff --git a/stella/src/gui/VideoDialog.hxx b/stella/src/gui/VideoDialog.hxx index 08d47d56e..10117946a 100644 --- a/stella/src/gui/VideoDialog.hxx +++ b/stella/src/gui/VideoDialog.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: VideoDialog.hxx,v 1.23 2008-02-06 13:45:24 stephena Exp $ +// $Id: VideoDialog.hxx,v 1.24 2008-07-25 12:41:41 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -45,22 +45,19 @@ class VideoDialog : public Dialog void saveConfig(); void setDefaults(); - void handleRendererChange(int item); + void handleRendererChange(const string& mode); void handleFullscreenChange(bool enable); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); private: PopUpWidget* myRendererPopup; - PopUpWidget* myFilterPopup; - PopUpWidget* myFSStretchPopup; + PopUpWidget* myTIAFilterPopup; + PopUpWidget* myTIAPalettePopup; + PopUpWidget* myFSResPopup; + PopUpWidget* myGLFilterPopup; + PopUpWidget* myGLStretchPopup; SliderWidget* myAspectRatioSlider; StaticTextWidget* myAspectRatioLabel; - PopUpWidget* myPalettePopup; - PopUpWidget* myFSResPopup; - SliderWidget* myUIZoomSlider; - StaticTextWidget* myUIZoomLabel; - SliderWidget* myTIAZoomSlider; - StaticTextWidget* myTIAZoomLabel; SliderWidget* myFrameRateSlider; StaticTextWidget* myFrameRateLabel; @@ -72,8 +69,6 @@ class VideoDialog : public Dialog enum { kRendererChanged = 'VDrd', kAspectRatioChanged = 'VDar', - kUIZoomChanged = 'VDui', - kTIAZoomChanged = 'VDti', kFrameRateChanged = 'VDfr', kFullScrChanged = 'VDfs' };