diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 613a2546d..987984b5c 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -1859,6 +1859,30 @@ StringList EventHandler::getActionList(EventMode mode) const return l; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +StringMap EventHandler::getComboList(EventMode mode) const +{ + StringMap l; + ostringstream buf; + + switch(mode) + { + case kEmulationMode: + for(int i = 0; i < kEmulActionListSize; ++i) + if(EventHandler::ourEmulActionList[i].allow_combo) + { + buf << i; + l.push_back(EventHandler::ourEmulActionList[i].action, buf.str()); + buf.str(""); + } + break; + default: + break; + } + + return l; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Event::Type EventHandler::eventAtIndex(int idx, EventMode mode) const { @@ -2380,128 +2404,128 @@ void EventHandler::setSDLMappings() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::ActionList EventHandler::ourEmulActionList[kEmulActionListSize] = { - { Event::ConsoleSelect, "Select", 0 }, - { Event::ConsoleReset, "Reset", 0 }, - { Event::ConsoleColor, "Color TV", 0 }, - { Event::ConsoleBlackWhite, "Black & White TV", 0 }, - { Event::ConsoleLeftDifficultyA, "P0 Difficulty A", 0 }, - { Event::ConsoleLeftDifficultyB, "P0 Difficulty B", 0 }, - { Event::ConsoleRightDifficultyA, "P1 Difficulty A", 0 }, - { Event::ConsoleRightDifficultyB, "P1 Difficulty B", 0 }, - { Event::SaveState, "Save State", 0 }, - { Event::ChangeState, "Change State", 0 }, - { Event::LoadState, "Load State", 0 }, - { Event::TakeSnapshot, "Snapshot", 0 }, - { Event::Fry, "Fry cartridge", 0 }, - { Event::VolumeDecrease, "Decrease volume", 0 }, - { Event::VolumeIncrease, "Increase volume", 0 }, - { Event::PauseMode, "Pause", 0 }, - { Event::MenuMode, "Enter options menu mode", 0 }, - { Event::CmdMenuMode, "Toggle command menu mode", 0 }, - { Event::DebuggerMode, "Toggle debugger mode", 0 }, - { Event::LauncherMode, "Enter ROM launcher", 0 }, - { Event::Quit, "Quit", 0 }, + { Event::ConsoleSelect, "Select", 0, true }, + { Event::ConsoleReset, "Reset", 0, true }, + { Event::ConsoleColor, "Color TV", 0, true }, + { Event::ConsoleBlackWhite, "Black & White TV", 0, true }, + { Event::ConsoleLeftDifficultyA, "P0 Difficulty A", 0, true }, + { Event::ConsoleLeftDifficultyB, "P0 Difficulty B", 0, true }, + { Event::ConsoleRightDifficultyA, "P1 Difficulty A", 0, true }, + { Event::ConsoleRightDifficultyB, "P1 Difficulty B", 0, true }, + { Event::SaveState, "Save State", 0, false }, + { Event::ChangeState, "Change State", 0, false }, + { Event::LoadState, "Load State", 0, false }, + { Event::TakeSnapshot, "Snapshot", 0, false }, + { Event::Fry, "Fry cartridge", 0, false }, + { Event::VolumeDecrease, "Decrease volume", 0, false }, + { Event::VolumeIncrease, "Increase volume", 0, false }, + { Event::PauseMode, "Pause", 0, false }, + { Event::MenuMode, "Enter options menu mode", 0, false }, + { Event::CmdMenuMode, "Toggle command menu mode", 0, false }, + { Event::DebuggerMode, "Toggle debugger mode", 0, false }, + { Event::LauncherMode, "Enter ROM launcher", 0, false }, + { Event::Quit, "Quit", 0, false }, - { Event::JoystickZeroUp, "P0 Joystick Up", 0 }, - { Event::JoystickZeroDown, "P0 Joystick Down", 0 }, - { Event::JoystickZeroLeft, "P0 Joystick Left", 0 }, - { Event::JoystickZeroRight, "P0 Joystick Right", 0 }, - { Event::JoystickZeroFire1, "P0 Joystick Fire", 0 }, - { Event::JoystickZeroFire2, "P0 BoosterGrip Trigger", 0 }, - { Event::JoystickZeroFire3, "P0 BoosterGrip Booster", 0 }, + { Event::JoystickZeroUp, "P0 Joystick Up", 0, true }, + { Event::JoystickZeroDown, "P0 Joystick Down", 0, true }, + { Event::JoystickZeroLeft, "P0 Joystick Left", 0, true }, + { Event::JoystickZeroRight, "P0 Joystick Right", 0, true }, + { Event::JoystickZeroFire1, "P0 Joystick Fire", 0, true }, + { Event::JoystickZeroFire2, "P0 BoosterGrip Trigger", 0, true }, + { Event::JoystickZeroFire3, "P0 BoosterGrip Booster", 0, true }, - { Event::JoystickOneUp, "P1 Joystick Up", 0 }, - { Event::JoystickOneDown, "P1 Joystick Down", 0 }, - { Event::JoystickOneLeft, "P1 Joystick Left", 0 }, - { Event::JoystickOneRight, "P1 Joystick Right", 0 }, - { Event::JoystickOneFire1, "P1 Joystick Fire", 0 }, - { Event::JoystickOneFire2, "P1 BoosterGrip Trigger", 0 }, - { Event::JoystickOneFire3, "P1 BoosterGrip Booster", 0 }, + { Event::JoystickOneUp, "P1 Joystick Up", 0, true }, + { Event::JoystickOneDown, "P1 Joystick Down", 0, true }, + { Event::JoystickOneLeft, "P1 Joystick Left", 0, true }, + { Event::JoystickOneRight, "P1 Joystick Right", 0, true }, + { Event::JoystickOneFire1, "P1 Joystick Fire", 0, true }, + { Event::JoystickOneFire2, "P1 BoosterGrip Trigger", 0, true }, + { Event::JoystickOneFire3, "P1 BoosterGrip Booster", 0, true }, - { Event::PaddleZeroAnalog, "Paddle 0 Analog", 0 }, - { Event::PaddleZeroDecrease, "Paddle 0 Decrease", 0 }, - { Event::PaddleZeroIncrease, "Paddle 0 Increase", 0 }, - { Event::PaddleZeroFire, "Paddle 0 Fire", 0 }, + { Event::PaddleZeroAnalog, "Paddle 0 Analog", 0, true }, + { Event::PaddleZeroDecrease, "Paddle 0 Decrease", 0, true }, + { Event::PaddleZeroIncrease, "Paddle 0 Increase", 0, true }, + { Event::PaddleZeroFire, "Paddle 0 Fire", 0, true }, - { Event::PaddleOneAnalog, "Paddle 1 Analog", 0 }, - { Event::PaddleOneDecrease, "Paddle 1 Decrease", 0 }, - { Event::PaddleOneIncrease, "Paddle 1 Increase", 0 }, - { Event::PaddleOneFire, "Paddle 1 Fire", 0 }, + { Event::PaddleOneAnalog, "Paddle 1 Analog", 0, true }, + { Event::PaddleOneDecrease, "Paddle 1 Decrease", 0, true }, + { Event::PaddleOneIncrease, "Paddle 1 Increase", 0, true }, + { Event::PaddleOneFire, "Paddle 1 Fire", 0, true }, - { Event::PaddleTwoAnalog, "Paddle 2 Analog", 0 }, - { Event::PaddleTwoDecrease, "Paddle 2 Decrease", 0 }, - { Event::PaddleTwoIncrease, "Paddle 2 Increase", 0 }, - { Event::PaddleTwoFire, "Paddle 2 Fire", 0 }, + { Event::PaddleTwoAnalog, "Paddle 2 Analog", 0, true }, + { Event::PaddleTwoDecrease, "Paddle 2 Decrease", 0, true }, + { Event::PaddleTwoIncrease, "Paddle 2 Increase", 0, true }, + { Event::PaddleTwoFire, "Paddle 2 Fire", 0, true }, - { Event::PaddleThreeAnalog, "Paddle 3 Analog", 0 }, - { Event::PaddleThreeDecrease, "Paddle 3 Decrease", 0 }, - { Event::PaddleThreeIncrease, "Paddle 3 Increase", 0 }, - { Event::PaddleThreeFire, "Paddle 3 Fire", 0 }, + { Event::PaddleThreeAnalog, "Paddle 3 Analog", 0, true }, + { Event::PaddleThreeDecrease, "Paddle 3 Decrease", 0, true }, + { Event::PaddleThreeIncrease, "Paddle 3 Increase", 0, true }, + { Event::PaddleThreeFire, "Paddle 3 Fire", 0, true }, - { Event::KeyboardZero1, "P0 Keyboard 1", 0 }, - { Event::KeyboardZero2, "P0 Keyboard 2", 0 }, - { Event::KeyboardZero3, "P0 Keyboard 3", 0 }, - { Event::KeyboardZero4, "P0 Keyboard 4", 0 }, - { Event::KeyboardZero5, "P0 Keyboard 5", 0 }, - { Event::KeyboardZero6, "P0 Keyboard 6", 0 }, - { Event::KeyboardZero7, "P0 Keyboard 7", 0 }, - { Event::KeyboardZero8, "P0 Keyboard 8", 0 }, - { Event::KeyboardZero9, "P0 Keyboard 9", 0 }, - { Event::KeyboardZeroStar, "P0 Keyboard *", 0 }, - { Event::KeyboardZero0, "P0 Keyboard 0", 0 }, - { Event::KeyboardZeroPound, "P0 Keyboard #", 0 }, + { Event::KeyboardZero1, "P0 Keyboard 1", 0, true }, + { Event::KeyboardZero2, "P0 Keyboard 2", 0, true }, + { Event::KeyboardZero3, "P0 Keyboard 3", 0, true }, + { Event::KeyboardZero4, "P0 Keyboard 4", 0, true }, + { Event::KeyboardZero5, "P0 Keyboard 5", 0, true }, + { Event::KeyboardZero6, "P0 Keyboard 6", 0, true }, + { Event::KeyboardZero7, "P0 Keyboard 7", 0, true }, + { Event::KeyboardZero8, "P0 Keyboard 8", 0, true }, + { Event::KeyboardZero9, "P0 Keyboard 9", 0, true }, + { Event::KeyboardZeroStar, "P0 Keyboard *", 0, true }, + { Event::KeyboardZero0, "P0 Keyboard 0", 0, true }, + { Event::KeyboardZeroPound, "P0 Keyboard #", 0, true }, - { Event::KeyboardOne1, "P1 Keyboard 1", 0 }, - { Event::KeyboardOne2, "P1 Keyboard 2", 0 }, - { Event::KeyboardOne3, "P1 Keyboard 3", 0 }, - { Event::KeyboardOne4, "P1 Keyboard 4", 0 }, - { Event::KeyboardOne5, "P1 Keyboard 5", 0 }, - { Event::KeyboardOne6, "P1 Keyboard 6", 0 }, - { Event::KeyboardOne7, "P1 Keyboard 7", 0 }, - { Event::KeyboardOne8, "P1 Keyboard 8", 0 }, - { Event::KeyboardOne9, "P1 Keyboard 9", 0 }, - { Event::KeyboardOneStar, "P1 Keyboard *", 0 }, - { Event::KeyboardOne0, "P1 Keyboard 0", 0 }, - { Event::KeyboardOnePound, "P1 Keyboard #", 0 }, + { Event::KeyboardOne1, "P1 Keyboard 1", 0, true }, + { Event::KeyboardOne2, "P1 Keyboard 2", 0, true }, + { Event::KeyboardOne3, "P1 Keyboard 3", 0, true }, + { Event::KeyboardOne4, "P1 Keyboard 4", 0, true }, + { Event::KeyboardOne5, "P1 Keyboard 5", 0, true }, + { Event::KeyboardOne6, "P1 Keyboard 6", 0, true }, + { Event::KeyboardOne7, "P1 Keyboard 7", 0, true }, + { Event::KeyboardOne8, "P1 Keyboard 8", 0, true }, + { Event::KeyboardOne9, "P1 Keyboard 9", 0, true }, + { Event::KeyboardOneStar, "P1 Keyboard *", 0, true }, + { Event::KeyboardOne0, "P1 Keyboard 0", 0, true }, + { Event::KeyboardOnePound, "P1 Keyboard #", 0, true }, - { Event::Combo1, "Combo 1", 0 }, - { Event::Combo2, "Combo 2", 0 }, - { Event::Combo3, "Combo 3", 0 }, - { Event::Combo4, "Combo 4", 0 }, - { Event::Combo5, "Combo 5", 0 }, - { Event::Combo6, "Combo 6", 0 }, - { Event::Combo7, "Combo 7", 0 }, - { Event::Combo8, "Combo 8", 0 }, - { Event::Combo9, "Combo 9", 0 }, - { Event::Combo10, "Combo 10", 0 }, - { Event::Combo11, "Combo 11", 0 }, - { Event::Combo12, "Combo 12", 0 }, - { Event::Combo13, "Combo 13", 0 }, - { Event::Combo14, "Combo 14", 0 }, - { Event::Combo15, "Combo 15", 0 }, - { Event::Combo16, "Combo 16", 0 } + { Event::Combo1, "Combo 1", 0, false }, + { Event::Combo2, "Combo 2", 0, false }, + { Event::Combo3, "Combo 3", 0, false }, + { Event::Combo4, "Combo 4", 0, false }, + { Event::Combo5, "Combo 5", 0, false }, + { Event::Combo6, "Combo 6", 0, false }, + { Event::Combo7, "Combo 7", 0, false }, + { Event::Combo8, "Combo 8", 0, false }, + { Event::Combo9, "Combo 9", 0, false }, + { Event::Combo10, "Combo 10", 0, false }, + { Event::Combo11, "Combo 11", 0, false }, + { Event::Combo12, "Combo 12", 0, false }, + { Event::Combo13, "Combo 13", 0, false }, + { Event::Combo14, "Combo 14", 0, false }, + { Event::Combo15, "Combo 15", 0, false }, + { Event::Combo16, "Combo 16", 0, false } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::ActionList EventHandler::ourMenuActionList[kMenuActionListSize] = { - { Event::UIUp, "Move Up", 0 }, - { Event::UIDown, "Move Down", 0 }, - { Event::UILeft, "Move Left", 0 }, - { Event::UIRight, "Move Right", 0 }, + { Event::UIUp, "Move Up", 0, false }, + { Event::UIDown, "Move Down", 0, false }, + { Event::UILeft, "Move Left", 0, false }, + { Event::UIRight, "Move Right", 0, false }, - { Event::UIHome, "Home", 0 }, - { Event::UIEnd, "End", 0 }, - { Event::UIPgUp, "Page Up", 0 }, - { Event::UIPgDown, "Page Down", 0 }, + { Event::UIHome, "Home", 0, false }, + { Event::UIEnd, "End", 0, false }, + { Event::UIPgUp, "Page Up", 0, false }, + { Event::UIPgDown, "Page Down", 0, false }, - { Event::UIOK, "OK", 0 }, - { Event::UICancel, "Cancel", 0 }, - { Event::UISelect, "Select item", 0 }, + { Event::UIOK, "OK", 0, false }, + { Event::UICancel, "Cancel", 0, false }, + { Event::UISelect, "Select item", 0, false }, - { Event::UINavPrev, "Previous object", 0 }, - { Event::UINavNext, "Next object", 0 }, + { Event::UINavPrev, "Previous object", 0, false }, + { Event::UINavNext, "Next object", 0, false }, - { Event::UIPrevDir, "Parent directory", 0 } + { Event::UIPrevDir, "Parent directory", 0, false } }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 2ecf2e417..c307b070a 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -241,6 +241,7 @@ class EventHandler inline SDL_Joystick* getJoystick(int i) const { return ourJoysticks[i].stick; } StringList getActionList(EventMode mode) const; + StringMap getComboList(EventMode mode) const; inline Event::Type eventForKey(int key, EventMode mode) const { return myKeyTable[key][mode]; } @@ -401,6 +402,7 @@ class EventHandler Event::Type event; const char* action; char* key; + bool allow_combo; }; // Joystick related items diff --git a/src/gui/ComboDialog.cxx b/src/gui/ComboDialog.cxx new file mode 100644 index 000000000..8b587f51c --- /dev/null +++ b/src/gui/ComboDialog.cxx @@ -0,0 +1,234 @@ +//============================================================================ +// +// 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-2010 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id$ +//============================================================================ + +#include + +#include "bspf.hxx" + +#include "Control.hxx" +#include "Dialog.hxx" +#include "EventHandler.hxx" +#include "OSystem.hxx" +#include "EditTextWidget.hxx" +#include "PopUpWidget.hxx" +#include "StringList.hxx" +#include "Widget.hxx" + +#include "ComboDialog.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font, + const StringMap& combolist) + : Dialog(&boss->instance(), &boss->parent(), 0, 0, 0, 0) +{ + const int lineHeight = font.getLineHeight(), + fontWidth = font.getMaxCharWidth(), + fontHeight = font.getFontHeight(), + buttonWidth = font.getStringWidth("Defaults") + 20, + buttonHeight = font.getLineHeight() + 4; + int xpos, ypos; + int lwidth = font.getStringWidth("Fragment Size: "), + pwidth = font.getStringWidth("512 bytes"); + WidgetArray wid; + + // Set real dimensions + _w = 35 * fontWidth + 10; + _h = 8 * (lineHeight + 4) + 10; + +//for(uInt32 i = 0; i < combolist.size(); ++i) +//cerr << combolist[i].first << " -> " << combolist[i].second << endl; + +/* + // Volume + xpos = 3 * fontWidth; ypos = 10; + + myVolumeSlider = new SliderWidget(this, font, xpos, ypos, 6*fontWidth, lineHeight, + "Volume: ", lwidth, kVolumeChanged); + myVolumeSlider->setMinValue(1); myVolumeSlider->setMaxValue(100); + wid.push_back(myVolumeSlider); + myVolumeLabel = new StaticTextWidget(this, font, + xpos + myVolumeSlider->getWidth() + 4, + ypos + 1, + 3*fontWidth, fontHeight, "", kTextAlignLeft); + + myVolumeLabel->setFlags(WIDGET_CLEARBG); + ypos += lineHeight + 4; + + // Fragment size + items.clear(); + items.push_back("", "128"); + items.push_back("256 bytes", "256"); + items.push_back("512 bytes", "512"); + items.push_back("1 KB", "1024"); + items.push_back("2 KB", "2048"); + items.push_back("4 KB", "4096"); + myFragsizePopup = new PopUpWidget(this, font, xpos, ypos, + pwidth + myVolumeLabel->getWidth() - 4, lineHeight, + items, "Fragment size: ", lwidth); + wid.push_back(myFragsizePopup); + ypos += lineHeight + 4; + + // Output frequency + items.clear(); + items.push_back("11025 Hz", "11025"); + items.push_back("22050 Hz", "22050"); + items.push_back("31400 Hz", "31400"); + items.push_back("44100 Hz", "44100"); + items.push_back("48000 Hz", "48000"); + myFreqPopup = new PopUpWidget(this, font, xpos, ypos, + pwidth + myVolumeLabel->getWidth() - 4, lineHeight, + items, "Output freq: ", lwidth); + wid.push_back(myFreqPopup); + ypos += lineHeight + 4; + + // TIA frequency + // ... use same items as above + myTiaFreqPopup = new PopUpWidget(this, font, xpos, ypos, + pwidth + myVolumeLabel->getWidth() - 4, lineHeight, + items, "TIA freq: ", lwidth); + wid.push_back(myTiaFreqPopup); + ypos += lineHeight + 4; + + // Clip volume + myClipVolumeCheckbox = new CheckboxWidget(this, font, xpos+50, ypos, + "Clip volume", 0); + wid.push_back(myClipVolumeCheckbox); + ypos += lineHeight + 4; + + // Enable sound + mySoundEnableCheckbox = new CheckboxWidget(this, font, xpos+50, ypos, + "Enable sound", kSoundEnableChanged); + wid.push_back(mySoundEnableCheckbox); + ypos += lineHeight + 12; + + // Add Defaults, OK and Cancel buttons + ButtonWidget* b; + b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10, + buttonWidth, buttonHeight, "Defaults", kDefaultsCmd); + wid.push_back(b); + addOKCancelBGroup(wid, font); + + addToFocusList(wid); +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ComboDialog::~ComboDialog() +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ComboDialog::loadConfig() +{ +/* + // Volume + myVolumeSlider->setValue(instance().settings().getInt("volume")); + myVolumeLabel->setLabel(instance().settings().getString("volume")); + + // Fragsize + myFragsizePopup->setSelected(instance().settings().getString("fragsize"), "512"); + + // Output frequency + myFreqPopup->setSelected(instance().settings().getString("freq"), "31400"); + + // TIA frequency + myTiaFreqPopup->setSelected(instance().settings().getString("tiafreq"), "31400"); + + // Clip volume + myClipVolumeCheckbox->setState(instance().settings().getBool("clipvol")); + + // Enable sound + bool b = instance().settings().getBool("sound"); + mySoundEnableCheckbox->setState(b); +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ComboDialog::saveConfig() +{ +/* + Settings& settings = instance().settings(); + + // Volume + settings.setInt("volume", myVolumeSlider->getValue()); + instance().sound().setVolume(myVolumeSlider->getValue()); + + // Fragsize + settings.setString("fragsize", myFragsizePopup->getSelectedTag()); + + // Output frequency + settings.setString("freq", myFreqPopup->getSelectedTag()); + + // TIA frequency + settings.setString("tiafreq", myTiaFreqPopup->getSelectedTag()); + + // Enable/disable volume clipping (requires a restart to take effect) + settings.setBool("clipvol", myClipVolumeCheckbox->getState()); + + // Enable/disable sound (requires a restart to take effect) + instance().sound().setEnabled(mySoundEnableCheckbox->getState()); + + // Only force a re-initialization when necessary, since it can + // be a time-consuming operation + if(&instance().console()) + instance().console().initializeAudio(); +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ComboDialog::setDefaults() +{ +/* + myVolumeSlider->setValue(100); + myVolumeLabel->setLabel("100"); + + myFragsizePopup->setSelected("512", ""); + myFreqPopup->setSelected("31400", ""); + myTiaFreqPopup->setSelected("31400", ""); + + myClipVolumeCheckbox->setState(true); + mySoundEnableCheckbox->setState(true); + + // Make sure that mutually-exclusive items are not enabled at the same time + handleSoundEnableChange(true); + + _dirty = true; +*/ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void ComboDialog::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/src/gui/ComboDialog.hxx b/src/gui/ComboDialog.hxx new file mode 100644 index 000000000..f8658ede2 --- /dev/null +++ b/src/gui/ComboDialog.hxx @@ -0,0 +1,54 @@ +//============================================================================ +// +// 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-2010 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id$ +//============================================================================ + +#ifndef COMBO_DIALOG_HXX +#define COMBO_DIALOG_HXX + +class PopUpWidget; +class EditTextWidget; +class StaticTextWidget; + +#include "Dialog.hxx" +#include "DialogContainer.hxx" +#include "OSystem.hxx" +#include "bspf.hxx" + +class ComboDialog : public Dialog +{ + public: + ComboDialog(GuiObject* boss, const GUI::Font& font, const StringMap& combolist); + ~ComboDialog(); + + /** Place the dialog onscreen and center it */ + void show() { parent().addDialog(this); } + + private: + void loadConfig(); + void saveConfig(); + void setDefaults(); + + virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); + + private: + StaticTextWidget* myComboName; + EditTextWidget* myComboMapping; + PopUpWidget* myEvents[8]; +}; + +#endif diff --git a/src/gui/EventMappingWidget.cxx b/src/gui/EventMappingWidget.cxx index 04d36f977..90ee66865 100644 --- a/src/gui/EventMappingWidget.cxx +++ b/src/gui/EventMappingWidget.cxx @@ -30,6 +30,7 @@ #include "EditTextWidget.hxx" #include "StringListWidget.hxx" #include "Widget.hxx" +#include "ComboDialog.hxx" #include "EventMappingWidget.hxx" @@ -96,7 +97,12 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font, "Combo", kComboCmd); myComboButton->setTarget(this); addFocusWidget(myComboButton); + + myComboDialog = new ComboDialog(boss, font, + instance().eventHandler().getComboList(mode)); } + else + myComboButton = NULL; // Show message for currently selected event xpos = 10; ypos = 5 + myActionsList->getHeight() + 5; @@ -156,11 +162,12 @@ void EventMappingWidget::startRemapping() myLastStick = myLastAxis = myLastHat = myLastValue = -1; // Disable all other widgets while in remap mode, except enable 'Cancel' - myActionsList->setEnabled(false); - myMapButton->setEnabled(false); - myEraseButton->setEnabled(false); - myCancelMapButton->setEnabled(true); - myResetButton->setEnabled(false); + myActionsList->setEnabled(!myRemapStatus); + myMapButton->setEnabled(!myRemapStatus); + myCancelMapButton->setEnabled(myRemapStatus); + myEraseButton->setEnabled(!myRemapStatus); + myResetButton->setEnabled(!myRemapStatus); + if(myComboButton) myComboButton->setEnabled(!myRemapStatus); // And show a message indicating which key is being remapped ostringstream buf; @@ -211,19 +218,15 @@ void EventMappingWidget::stopRemapping() myLastStick = myLastAxis = myLastHat = myLastValue = -1; // And re-enable all the widgets - myActionsList->setEnabled(true); - myMapButton->setEnabled(false); - myEraseButton->setEnabled(false); - myCancelMapButton->setEnabled(false); - myResetButton->setEnabled(true); + myActionsList->setEnabled(!myRemapStatus); + myMapButton->setEnabled(!myRemapStatus); + myCancelMapButton->setEnabled(myRemapStatus); + myEraseButton->setEnabled(!myRemapStatus); + myResetButton->setEnabled(!myRemapStatus); + if(myComboButton) myComboButton->setEnabled(!myRemapStatus); // Make sure the list widget is in a known state - if(myActionSelected >= 0) - { - drawKeyMapping(); - myMapButton->setEnabled(true); - myEraseButton->setEnabled(true); - } + drawKeyMapping(); // Widget is now free to process events normally myActionsList->clearFlags(WIDGET_WANTS_RAWDATA); @@ -234,10 +237,8 @@ void EventMappingWidget::drawKeyMapping() { if(myActionSelected >= 0) { - ostringstream buf; - buf << instance().eventHandler().keyAtIndex(myActionSelected, myEventMode); myKeyMapping->setTextColor(kTextColor); - myKeyMapping->setEditString(buf.str()); + myKeyMapping->setEditString(instance().eventHandler().keyAtIndex(myActionSelected, myEventMode)); } } @@ -382,7 +383,8 @@ void EventMappingWidget::handleCommand(CommandSender* sender, int cmd, break; case kComboCmd: -cerr << "combo\n"; + if(myComboDialog) + myComboDialog->show(); break; } } diff --git a/src/gui/EventMappingWidget.hxx b/src/gui/EventMappingWidget.hxx index 1a1783590..d2a8d2ec5 100644 --- a/src/gui/EventMappingWidget.hxx +++ b/src/gui/EventMappingWidget.hxx @@ -31,6 +31,7 @@ class StaticTextWidget; class StringListWidget; class PopUpWidget; class GuiObject; +class ComboDialog; class InputDialog; #include "Widget.hxx" @@ -86,6 +87,8 @@ class EventMappingWidget : public Widget, public CommandSender StringListWidget* myActionsList; EditTextWidget* myKeyMapping; + ComboDialog* myComboDialog; + // Since this widget can be used for different collections of events, // we need to specify exactly which group of events we are remapping EventMode myEventMode; diff --git a/src/gui/module.mk b/src/gui/module.mk index 9f3461150..af5aab5e1 100644 --- a/src/gui/module.mk +++ b/src/gui/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS := \ src/gui/AboutDialog.o \ src/gui/AudioDialog.o \ src/gui/BrowserDialog.o \ + src/gui/ComboDialog.o \ src/gui/CommandDialog.o \ src/gui/CommandMenu.o \ src/gui/ContextMenu.o \