From 1c7e0e43a55cf8ecddd57e935f58d9070eef0c3b Mon Sep 17 00:00:00 2001 From: InfiniteBlueGX <105176909+InfiniteBlueGX@users.noreply.github.com> Date: Wed, 19 Oct 2022 18:33:16 -0500 Subject: [PATCH] Add more button triggers for returning from menus (#1030) --- source/gui/gui.h | 2 +- source/gui/gui_button.cpp | 4 +- source/gui/gui_element.cpp | 6 +++ source/menu.cpp | 95 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 101 insertions(+), 6 deletions(-) diff --git a/source/gui/gui.h b/source/gui/gui.h index 23a61c3..a5b538c 100644 --- a/source/gui/gui.h +++ b/source/gui/gui.h @@ -435,7 +435,7 @@ class GuiElement //!Called constantly to redraw the element's tooltip virtual void DrawTooltip(); protected: - GuiTrigger * trigger[3]; //!< GuiTriggers (input actions) that this element responds to + GuiTrigger * trigger[5]; //!< GuiTriggers (input actions) that this element responds to UpdateCallback updateCB; //!< Callback function to call when this element is updated GuiElement * parentElement; //!< Parent element int focus; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused) diff --git a/source/gui/gui_button.cpp b/source/gui/gui_button.cpp index 7a0b9f2..9f8df08 100644 --- a/source/gui/gui_button.cpp +++ b/source/gui/gui_button.cpp @@ -255,7 +255,7 @@ void GuiButton::Update(GuiTrigger * t) if(this->IsClickable()) { s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig, wiidrc_btns, wiidrc_btns_trig; - for(int i=0; i<3; i++) + for(int i=0; i<5; i++) { if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) { @@ -310,7 +310,7 @@ void GuiButton::Update(GuiTrigger * t) bool held = false; s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig, wiidrc_btns, wiidrc_btns_h, wiidrc_btns_trig; - for(int i=0; i<3; i++) + for(int i=0; i<5; i++) { if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) { diff --git a/source/gui/gui_element.cpp b/source/gui/gui_element.cpp index 9efb1c1..82a4a5d 100644 --- a/source/gui/gui_element.cpp +++ b/source/gui/gui_element.cpp @@ -31,6 +31,8 @@ GuiElement::GuiElement() trigger[0] = NULL; trigger[1] = NULL; trigger[2] = NULL; + trigger[3] = NULL; + trigger[4] = NULL; parentElement = NULL; rumble = true; selectable = false; @@ -362,6 +364,10 @@ void GuiElement::SetTrigger(GuiTrigger * t) trigger[1] = t; else if(!trigger[2]) trigger[2] = t; + else if(!trigger[3]) + trigger[3] = t; + else if(!trigger[4]) + trigger[4] = t; else // all were assigned, so we'll just overwrite the first one trigger[0] = t; } diff --git a/source/menu.cpp b/source/menu.cpp index 7a3c616..cfa4d42 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -1382,7 +1382,11 @@ static int MenuGame() GuiImageData batteryBar(battery_bar_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); GuiText saveBtnTxt("Save", 22, (GXColor){0, 0, 0, 255}); GuiImage saveBtnImg(&btnLargeOutline); @@ -1502,6 +1506,8 @@ static int MenuGame() closeBtn.SetTrigger(trigA); closeBtn.SetTrigger(trig2); closeBtn.SetTrigger(&trigHome); + closeBtn.SetTrigger(&trigB); + closeBtn.SetTrigger(&trig1); closeBtn.SetEffectGrow(); #ifdef HW_RVL @@ -1822,7 +1828,11 @@ static int MenuGameSaves(int action) GuiImageData btnCloseOutlineOver(button_small_over_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); @@ -1837,6 +1847,8 @@ static int MenuGameSaves(int action) backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiText closeBtnTxt("Close", 20, (GXColor){0, 0, 0, 255}); @@ -2094,7 +2106,11 @@ static int MenuGameSettings() GuiImageData btnCloseOutlineOver(button_small_over_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); GuiText mappingBtnTxt("Button Mappings", 22, (GXColor){0, 0, 0, 255}); mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); @@ -2230,6 +2246,8 @@ static int MenuGameSettings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -2344,6 +2362,11 @@ static int MenuGameCheats() GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -2357,6 +2380,8 @@ static int MenuGameCheats() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -2418,6 +2443,11 @@ static int MenuSettingsMappings() GuiImageData iconJustifier(icon_settings_justifier_png); GuiImageData iconMouse(icon_settings_mouse_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText snesBtnTxt("SNES Controller", 22, (GXColor){0, 0, 0, 255}); snesBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-40); GuiImage snesBtnImg(&btnLargeOutline); @@ -2517,6 +2547,8 @@ static int MenuSettingsMappings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -2600,6 +2632,11 @@ static int MenuSettingsMappingsController() GuiImageData iconNunchuk(icon_settings_nunchuk_png); GuiImageData iconWiiupro(icon_settings_wiiupro_png); GuiImageData iconDrc(icon_settings_drc_png); + + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255}); gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); @@ -2726,6 +2763,8 @@ static int MenuSettingsMappingsController() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -3424,6 +3463,11 @@ static int MenuSettingsOtherMappings() GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3437,6 +3481,8 @@ static int MenuSettingsOtherMappings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -3587,6 +3633,11 @@ static int MenuSettingsVideo() GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3600,6 +3651,8 @@ static int MenuSettingsVideo() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -3796,6 +3849,12 @@ static int MenuSettingsAudio() GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM); GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3809,6 +3868,8 @@ static int MenuSettingsAudio() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); optionBrowser.SetPosition(0, 108); @@ -3898,6 +3959,11 @@ static int MenuSettings() GuiImageData iconMenu(icon_settings_menu_png); GuiImageData iconNetwork(icon_settings_network_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText savingBtnTxt1("Saving", 22, (GXColor){0, 0, 0, 255}); GuiText savingBtnTxt2("&", 18, (GXColor){0, 0, 0, 255}); GuiText savingBtnTxt3("Loading", 22, (GXColor){0, 0, 0, 255}); @@ -3987,6 +4053,8 @@ static int MenuSettings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiText resetBtnTxt("Reset Settings", 22, (GXColor){0, 0, 0, 255}); @@ -4099,6 +4167,11 @@ static int MenuSettingsFile() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -4112,6 +4185,8 @@ static int MenuSettingsFile() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -4317,6 +4392,11 @@ static int MenuSettingsMenu() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -4330,6 +4410,8 @@ static int MenuSettingsMenu() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -4521,6 +4603,11 @@ static int MenuSettingsNetwork() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -4534,6 +4621,8 @@ static int MenuSettingsNetwork() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options);