From f8b9e386bdb8e12a27e51b2cbdce192823a90dca Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 15 Dec 2016 14:06:57 +0100 Subject: [PATCH] Moved Menu and Quit assignments to Misc - Moved options for mapping a keyboard or joystick button for Config and Quit to the Misc page, since there was not enough room in the Input page. - Cleaned up the code to use variables for positioning those UI elements instead of hardcoded sizes. - Re-aligned the Scroll and Num Lock LED assignments to harmonize the look of the UI. --- .gitignore | 1 + src/od-pandora/gui/PanelInput.cpp | 115 ------------------ src/od-pandora/gui/PanelMisc.cpp | 193 +++++++++++++++++++++++------- 3 files changed, 154 insertions(+), 155 deletions(-) diff --git a/.gitignore b/.gitignore index 0a03505d..e5159b48 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ kickstarts/*.rom *.dat Amiberry/VisualGDB/Debug/Amiberry Amiberry/VisualGDB/Release/Amiberry +*.sqlite diff --git a/src/od-pandora/gui/PanelInput.cpp b/src/od-pandora/gui/PanelInput.cpp index 29955936..b84b0463 100644 --- a/src/od-pandora/gui/PanelInput.cpp +++ b/src/od-pandora/gui/PanelInput.cpp @@ -61,15 +61,6 @@ static gcn::Label *lblLeft; static gcn::UaeDropDown* cboLeft; static gcn::Label *lblRight; static gcn::UaeDropDown* cboRight; -static gcn::Label *lblKeyForMenu; -static gcn::UaeDropDown* KeyForMenu; -static gcn::Label *lblButtonForMenu; -static gcn::UaeDropDown* ButtonForMenu; -static gcn::Label *lblKeyForQuit; -static gcn::UaeDropDown* KeyForQuit; -static gcn::Label *lblButtonForQuit; -static gcn::UaeDropDown* ButtonForQuit; - class StringListModel : public gcn::ListModel { @@ -112,38 +103,6 @@ const char *tapDelayValues[] = { "Normal", "Short", "None" }; StringListModel tapDelayList(tapDelayValues, 3); #endif -static const int ControlKey_SDLKeyValues[] = { 0, SDLK_F11, SDLK_F12 }; - -const char *ControlKeyValues[] = { "------------------", "F11", "F12" }; -StringListModel ControlKeyList(ControlKeyValues, 3); - -static int GetControlKeyIndex(int key) -{ - int ControlKey_SDLKeyValues_Length = sizeof(ControlKey_SDLKeyValues) / sizeof(int); - for (int i = 0; i < (ControlKey_SDLKeyValues_Length + 1); ++i) - { - if (ControlKey_SDLKeyValues[i] == key) - return i; - } - return 0; // Default: no key -} - -static const int ControlButton_SDLButtonValues[] = { -1, 0, 1, 2, 3 }; - -const char *ControlButtonValues[] = { "------------------", "JoyButton0", "JoyButton1", "JoyButton2", "JoyButton3" }; -StringListModel ControlButtonList(ControlButtonValues, 5); - -static int GetControlButtonIndex(int button) -{ - int ControlButton_SDLButtonValues_Length = sizeof(ControlButton_SDLButtonValues) / sizeof(int); - for (int i = 0; i < (ControlButton_SDLButtonValues_Length + 1); ++i) - { - if (ControlButton_SDLButtonValues[i] == button) - return i; - } - return 0; // Default: no key -} - const char *mappingValues[] = { "CD32 rwd", "CD32 ffw", "CD32 play", "CD32 yellow", "CD32 green", @@ -332,19 +291,6 @@ public: else if (actionEvent.getSource() == cboRight) customControlMap[VK_RIGHT] = amigaKey[cboRight->getSelected()]; - - else if (actionEvent.getSource() == KeyForMenu) - changed_prefs.key_for_menu = ControlKey_SDLKeyValues[KeyForMenu->getSelected()]; - - else if (actionEvent.getSource() == KeyForQuit) - changed_prefs.key_for_quit = ControlKey_SDLKeyValues[KeyForQuit->getSelected()]; - - else if (actionEvent.getSource() == ButtonForMenu) - changed_prefs.button_for_menu = ControlButton_SDLButtonValues[ButtonForMenu->getSelected()]; - - else if (actionEvent.getSource() == ButtonForQuit) - changed_prefs.button_for_quit = ControlButton_SDLButtonValues[ButtonForQuit->getSelected()]; - } }; static InputActionListener* inputActionListener; @@ -510,42 +456,6 @@ void InitPanelInput(const struct _ConfigCategory& category) cboRight->setId("cboRight"); cboRight->addActionListener(inputActionListener); - lblKeyForMenu = new gcn::Label("Menu Key:"); - lblKeyForMenu->setSize(100, LABEL_HEIGHT); - lblKeyForMenu->setAlignment(gcn::Graphics::RIGHT); - KeyForMenu = new gcn::UaeDropDown(&ControlKeyList); - KeyForMenu->setSize(150, DROPDOWN_HEIGHT); - KeyForMenu->setBaseColor(gui_baseCol); - KeyForMenu->setId("KeyForMenu"); - KeyForMenu->addActionListener(inputActionListener); - - lblKeyForQuit = new gcn::Label("Quit Key:"); - lblKeyForQuit->setSize(100, LABEL_HEIGHT); - lblKeyForQuit->setAlignment(gcn::Graphics::RIGHT); - KeyForQuit = new gcn::UaeDropDown(&ControlKeyList); - KeyForQuit->setSize(150, DROPDOWN_HEIGHT); - KeyForQuit->setBaseColor(gui_baseCol); - KeyForQuit->setId("KeyForQuit"); - KeyForQuit->addActionListener(inputActionListener); - - lblButtonForMenu= new gcn::Label("Menu Button:"); - lblButtonForMenu->setSize(100, LABEL_HEIGHT); - lblButtonForMenu->setAlignment(gcn::Graphics::RIGHT); - ButtonForMenu = new gcn::UaeDropDown(&ControlButtonList); - ButtonForMenu->setSize(150, DROPDOWN_HEIGHT); - ButtonForMenu->setBaseColor(gui_baseCol); - ButtonForMenu->setId("ButtonForMenu"); - ButtonForMenu->addActionListener(inputActionListener); - - lblButtonForQuit = new gcn::Label("Quit Button:"); - lblButtonForQuit->setSize(100, LABEL_HEIGHT); - lblButtonForQuit->setAlignment(gcn::Graphics::RIGHT); - ButtonForQuit = new gcn::UaeDropDown(&ControlButtonList); - ButtonForQuit->setSize(150, DROPDOWN_HEIGHT); - ButtonForQuit->setBaseColor(gui_baseCol); - ButtonForQuit->setId("ButtonForQuit"); - ButtonForQuit->addActionListener(inputActionListener); - int posY = DISTANCE_BORDER; category.panel->add(lblPort0, DISTANCE_BORDER, posY); category.panel->add(cboPort0, DISTANCE_BORDER + lblPort0->getWidth() + 8, posY); @@ -596,17 +506,6 @@ void InitPanelInput(const struct _ConfigCategory& category) category.panel->add(cboRight, 300 + lblRight->getWidth() + 8, posY); posY += cboLeft->getHeight() + DISTANCE_NEXT_Y; - category.panel->add(lblKeyForMenu, DISTANCE_BORDER, posY); - category.panel->add(KeyForMenu, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY); - category.panel->add(lblKeyForQuit, 300, posY); - category.panel->add(KeyForQuit, 300 + lblKeyForQuit->getWidth() + 8, posY); - posY += KeyForMenu->getHeight() + 4; - - category.panel->add(lblButtonForMenu, DISTANCE_BORDER, posY); - category.panel->add(ButtonForMenu, DISTANCE_BORDER + lblButtonForMenu->getWidth() + 8, posY); - category.panel->add(lblButtonForQuit, 300, posY); - category.panel->add(ButtonForQuit, 300 + lblButtonForQuit->getWidth() + 8, posY); - RefreshPanelInput(); } @@ -650,15 +549,6 @@ void ExitPanelInput(void) delete lblRight; delete cboRight; - delete lblKeyForMenu; - delete KeyForMenu; - delete lblKeyForQuit; - delete KeyForQuit; - delete lblButtonForMenu; - delete ButtonForMenu; - delete lblButtonForQuit; - delete ButtonForQuit; - delete inputActionListener; } @@ -752,9 +642,4 @@ void RefreshPanelInput(void) cboDown->setSelected(GetAmigaKeyIndex(customControlMap[VK_DOWN])); cboLeft->setSelected(GetAmigaKeyIndex(customControlMap[VK_LEFT])); cboRight->setSelected(GetAmigaKeyIndex(customControlMap[VK_RIGHT])); - - KeyForMenu->setSelected(GetControlKeyIndex(changed_prefs.key_for_menu)); - KeyForQuit->setSelected(GetControlKeyIndex(changed_prefs.key_for_quit)); - ButtonForMenu->setSelected(GetControlButtonIndex(changed_prefs.button_for_menu)); - ButtonForQuit->setSelected(GetControlButtonIndex(changed_prefs.button_for_quit)); } diff --git a/src/od-pandora/gui/PanelMisc.cpp b/src/od-pandora/gui/PanelMisc.cpp index 8fabf8d0..79019f8b 100644 --- a/src/od-pandora/gui/PanelMisc.cpp +++ b/src/od-pandora/gui/PanelMisc.cpp @@ -28,6 +28,14 @@ static gcn::Label* lblPandoraSpeedInfo; static gcn::Slider* sldPandoraSpeed; #endif static gcn::UaeCheckBox* chkBSDSocket; +static gcn::Label *lblKeyForMenu; +static gcn::UaeDropDown* KeyForMenu; +static gcn::Label *lblButtonForMenu; +static gcn::UaeDropDown* ButtonForMenu; +static gcn::Label *lblKeyForQuit; +static gcn::UaeDropDown* KeyForQuit; +static gcn::Label *lblButtonForQuit; +static gcn::UaeDropDown* ButtonForQuit; #ifdef RASPBERRY class StringListModel : public gcn::ListModel @@ -66,6 +74,38 @@ const char *listValues[] = { "none", "POWER", "DF0", "DF1", "DF2", "DF3", "DF*", StringListModel KBDLedList(listValues, 9); #endif +static const int ControlKey_SDLKeyValues[] = { 0, SDLK_F11, SDLK_F12 }; + +const char *ControlKeyValues[] = { "------------------", "F11", "F12" }; +StringListModel ControlKeyList(ControlKeyValues, 3); + +static int GetControlKeyIndex(int key) +{ + int ControlKey_SDLKeyValues_Length = sizeof(ControlKey_SDLKeyValues) / sizeof(int); + for (int i = 0; i < (ControlKey_SDLKeyValues_Length + 1); ++i) + { + if (ControlKey_SDLKeyValues[i] == key) + return i; + } + return 0; // Default: no key +} + +static const int ControlButton_SDLButtonValues[] = { -1, 0, 1, 2, 3 }; + +const char *ControlButtonValues[] = { "------------------", "JoyButton0", "JoyButton1", "JoyButton2", "JoyButton3" }; +StringListModel ControlButtonList(ControlButtonValues, 5); + +static int GetControlButtonIndex(int button) +{ + int ControlButton_SDLButtonValues_Length = sizeof(ControlButton_SDLButtonValues) / sizeof(int); + for (int i = 0; i < (ControlButton_SDLButtonValues_Length + 1); ++i) + { + if (ControlButton_SDLButtonValues[i] == button) + return i; + } + return 0; // Default: no key +} + class MiscActionListener : public gcn::ActionListener { public: @@ -83,6 +123,17 @@ public: else if (actionEvent.getSource() == chkBSDSocket) changed_prefs.socket_emu = chkBSDSocket->isSelected(); + else if (actionEvent.getSource() == KeyForMenu) + changed_prefs.key_for_menu = ControlKey_SDLKeyValues[KeyForMenu->getSelected()]; + + else if (actionEvent.getSource() == KeyForQuit) + changed_prefs.key_for_quit = ControlKey_SDLKeyValues[KeyForQuit->getSelected()]; + + else if (actionEvent.getSource() == ButtonForMenu) + changed_prefs.button_for_menu = ControlButton_SDLButtonValues[ButtonForMenu->getSelected()]; + + else if (actionEvent.getSource() == ButtonForQuit) + changed_prefs.button_for_quit = ControlButton_SDLButtonValues[ButtonForQuit->getSelected()]; #ifdef PANDORA_SPECIFIC else if (actionEvent.getSource() == sldPandoraSpeed) @@ -143,62 +194,112 @@ void InitPanelMisc(const struct _ConfigCategory& category) chkBSDSocket->setId("BSDSocket"); chkBSDSocket->addActionListener(miscActionListener); - int posY = DISTANCE_BORDER; - category.panel->add(chkStatusLine, DISTANCE_BORDER, posY); - posY += chkStatusLine->getHeight() + DISTANCE_NEXT_Y; - category.panel->add(chkHideIdleLed, DISTANCE_BORDER, posY); - posY += chkHideIdleLed->getHeight() + DISTANCE_NEXT_Y; - category.panel->add(chkShowGUI, DISTANCE_BORDER, posY); - posY += chkShowGUI->getHeight() + DISTANCE_NEXT_Y; -#ifdef PANDORA_SPECIFIC - category.panel->add(lblPandoraSpeed, DISTANCE_BORDER, posY); - category.panel->add(sldPandoraSpeed, DISTANCE_BORDER + lblPandoraSpeed->getWidth() + 8, posY); - category.panel->add(lblPandoraSpeedInfo, sldPandoraSpeed->getX() + sldPandoraSpeed->getWidth() + 12, posY); - posY += sldPandoraSpeed->getHeight() + DISTANCE_NEXT_Y; -#endif - category.panel->add(chkBSDSocket, DISTANCE_BORDER, posY); - posY += chkBSDSocket->getHeight() + DISTANCE_NEXT_Y; - -#ifdef RASPBERRY - lblNumLock = new gcn::Label("NumLock LED"); - lblNumLock->setSize(150, LABEL_HEIGHT); - lblNumLock->setAlignment(gcn::Graphics::LEFT); + lblNumLock = new gcn::Label("NumLock LED:"); + lblNumLock->setSize(100, LABEL_HEIGHT); + lblNumLock->setAlignment(gcn::Graphics::RIGHT); cboKBDLed_num = new gcn::UaeDropDown(&KBDLedList); cboKBDLed_num->setSize(150, DROPDOWN_HEIGHT); cboKBDLed_num->setBaseColor(gui_baseCol); cboKBDLed_num->setId("numlock"); cboKBDLed_num->addActionListener(miscActionListener); +// +// lblCapLock = new gcn::Label("CapsLock LED:"); +// lblCapLock->setSize(100, LABEL_HEIGHT); +// lblCapLock->setAlignment(gcn::Graphics::RIGHT); +// cboKBDLed_cap = new gcn::UaeDropDown(&KBDLedList); +// cboKBDLed_cap->setSize(150, DROPDOWN_HEIGHT); +// cboKBDLed_cap->setBaseColor(gui_baseCol); +// cboKBDLed_cap->setId("capslock"); +// cboKBDLed_cap->addActionListener(miscActionListener); - lblCapLock = new gcn::Label("CapsLock LED"); - lblCapLock->setSize(150, LABEL_HEIGHT); - lblCapLock->setAlignment(gcn::Graphics::LEFT); - cboKBDLed_cap = new gcn::UaeDropDown(&KBDLedList); - cboKBDLed_cap->setSize(150, DROPDOWN_HEIGHT); - cboKBDLed_cap->setBaseColor(gui_baseCol); - cboKBDLed_cap->setId("capslock"); - cboKBDLed_cap->addActionListener(miscActionListener); - - lblScrLock = new gcn::Label("ScrollLock LED"); - lblScrLock->setSize(150, LABEL_HEIGHT); - lblScrLock->setAlignment(gcn::Graphics::LEFT); + lblScrLock = new gcn::Label("ScrollLock LED:"); + lblScrLock->setSize(100, LABEL_HEIGHT); + lblScrLock->setAlignment(gcn::Graphics::RIGHT); cboKBDLed_scr = new gcn::UaeDropDown(&KBDLedList); cboKBDLed_scr->setSize(150, DROPDOWN_HEIGHT); cboKBDLed_scr->setBaseColor(gui_baseCol); cboKBDLed_scr->setId("scrolllock"); cboKBDLed_scr->addActionListener(miscActionListener); - category.panel->add(lblNumLock, DISTANCE_BORDER, posY); -// category.panel->add(lblCapLock, lblNumLock->getX() + lblNumLock->getWidth() + DISTANCE_NEXT_X, posY); - category.panel->add(lblScrLock, lblCapLock->getX() + lblCapLock->getWidth() + DISTANCE_NEXT_X, posY); - posY += lblNumLock->getHeight() + 4; + lblKeyForMenu = new gcn::Label("Menu Key:"); + lblKeyForMenu->setSize(100, LABEL_HEIGHT); + lblKeyForMenu->setAlignment(gcn::Graphics::RIGHT); + KeyForMenu = new gcn::UaeDropDown(&ControlKeyList); + KeyForMenu->setSize(150, DROPDOWN_HEIGHT); + KeyForMenu->setBaseColor(gui_baseCol); + KeyForMenu->setId("KeyForMenu"); + KeyForMenu->addActionListener(miscActionListener); - category.panel->add(cboKBDLed_num, DISTANCE_BORDER, posY); -// category.panel->add(cboKBDLed_cap, cboKBDLed_num->getX() + cboKBDLed_num->getWidth() + DISTANCE_NEXT_X, posY); - category.panel->add(cboKBDLed_scr, cboKBDLed_cap->getX() + cboKBDLed_cap->getWidth() + DISTANCE_NEXT_X, posY); + lblKeyForQuit = new gcn::Label("Quit Key:"); + lblKeyForQuit->setSize(100, LABEL_HEIGHT); + lblKeyForQuit->setAlignment(gcn::Graphics::RIGHT); + KeyForQuit = new gcn::UaeDropDown(&ControlKeyList); + KeyForQuit->setSize(150, DROPDOWN_HEIGHT); + KeyForQuit->setBaseColor(gui_baseCol); + KeyForQuit->setId("KeyForQuit"); + KeyForQuit->addActionListener(miscActionListener); - posY += cboKBDLed_scr->getHeight() + DISTANCE_NEXT_Y; + lblButtonForMenu = new gcn::Label("Menu Button:"); + lblButtonForMenu->setSize(100, LABEL_HEIGHT); + lblButtonForMenu->setAlignment(gcn::Graphics::RIGHT); + ButtonForMenu = new gcn::UaeDropDown(&ControlButtonList); + ButtonForMenu->setSize(150, DROPDOWN_HEIGHT); + ButtonForMenu->setBaseColor(gui_baseCol); + ButtonForMenu->setId("ButtonForMenu"); + ButtonForMenu->addActionListener(miscActionListener); + + lblButtonForQuit = new gcn::Label("Quit Button:"); + lblButtonForQuit->setSize(100, LABEL_HEIGHT); + lblButtonForQuit->setAlignment(gcn::Graphics::RIGHT); + ButtonForQuit = new gcn::UaeDropDown(&ControlButtonList); + ButtonForQuit->setSize(150, DROPDOWN_HEIGHT); + ButtonForQuit->setBaseColor(gui_baseCol); + ButtonForQuit->setId("ButtonForQuit"); + ButtonForQuit->addActionListener(miscActionListener); + + int posY = DISTANCE_BORDER; + category.panel->add(chkStatusLine, DISTANCE_BORDER, posY); + posY += chkStatusLine->getHeight() + DISTANCE_NEXT_Y; + category.panel->add(chkHideIdleLed, DISTANCE_BORDER, posY); + posY += chkHideIdleLed->getHeight() + DISTANCE_NEXT_Y; + category.panel->add(chkShowGUI, DISTANCE_BORDER, posY); + posY += chkShowGUI->getHeight() + DISTANCE_NEXT_Y; + +#ifdef PANDORA_SPECIFIC + category.panel->add(lblPandoraSpeed, DISTANCE_BORDER, posY); + category.panel->add(sldPandoraSpeed, DISTANCE_BORDER + lblPandoraSpeed->getWidth() + 8, posY); + category.panel->add(lblPandoraSpeedInfo, sldPandoraSpeed->getX() + sldPandoraSpeed->getWidth() + 12, posY); + posY += sldPandoraSpeed->getHeight() + DISTANCE_NEXT_Y; #endif + + category.panel->add(chkBSDSocket, DISTANCE_BORDER, posY); + posY += chkBSDSocket->getHeight() + DISTANCE_NEXT_Y; + category.panel->add(lblNumLock, DISTANCE_BORDER, posY); + category.panel->add(cboKBDLed_num, DISTANCE_BORDER + lblNumLock->getWidth() + 8, posY); + +// category.panel->add(lblCapLock, lblNumLock->getX() + lblNumLock->getWidth() + DISTANCE_NEXT_X, posY); +// category.panel->add(cboKBDLed_cap, cboKBDLed_num->getX() + cboKBDLed_num->getWidth() + DISTANCE_NEXT_X, posY); + + category.panel->add(lblScrLock, cboKBDLed_num->getX() + cboKBDLed_num->getWidth() + DISTANCE_NEXT_X, posY); + category.panel->add(cboKBDLed_scr, lblScrLock->getX() + lblScrLock->getWidth() + 8, posY); + + posY += cboKBDLed_scr->getHeight() + DISTANCE_NEXT_Y; + + category.panel->add(lblKeyForMenu, DISTANCE_BORDER, posY); + category.panel->add(KeyForMenu, DISTANCE_BORDER + lblKeyForMenu->getWidth() + 8, posY); + + category.panel->add(lblKeyForQuit, KeyForMenu->getX() + KeyForMenu->getWidth() + DISTANCE_NEXT_X, posY); + category.panel->add(KeyForQuit, lblKeyForQuit->getX() + lblKeyForQuit->getWidth() + 8, posY); + + posY += KeyForMenu->getHeight() + DISTANCE_NEXT_Y; + + category.panel->add(lblButtonForMenu, DISTANCE_BORDER, posY); + category.panel->add(ButtonForMenu, DISTANCE_BORDER + lblButtonForMenu->getWidth() + 8, posY); + + category.panel->add(lblButtonForQuit, ButtonForMenu->getX() + ButtonForMenu->getWidth() + DISTANCE_NEXT_X, posY); + category.panel->add(ButtonForQuit, lblButtonForQuit->getX() + lblButtonForQuit->getWidth() + 8, posY); + RefreshPanelMisc(); } @@ -224,6 +325,14 @@ void ExitPanelMisc(void) delete cboKBDLed_scr; #endif delete miscActionListener; + delete lblKeyForMenu; + delete KeyForMenu; + delete lblKeyForQuit; + delete KeyForQuit; + delete lblButtonForMenu; + delete ButtonForMenu; + delete lblButtonForQuit; + delete ButtonForQuit; } @@ -245,4 +354,8 @@ void RefreshPanelMisc(void) cboKBDLed_num->setSelected(changed_prefs.kbd_led_num); cboKBDLed_scr->setSelected(changed_prefs.kbd_led_scr); #endif + KeyForMenu->setSelected(GetControlKeyIndex(changed_prefs.key_for_menu)); + KeyForQuit->setSelected(GetControlKeyIndex(changed_prefs.key_for_quit)); + ButtonForMenu->setSelected(GetControlButtonIndex(changed_prefs.button_for_menu)); + ButtonForQuit->setSelected(GetControlButtonIndex(changed_prefs.button_for_quit)); }