From ab2d21a45cc1a14614f606d56046e80a3df487d6 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 17 Oct 2024 00:21:36 +0200 Subject: [PATCH 01/34] Added all sprites to cclcc optionsmenu profile --- profiles/cclcc/hud/optionsmenu.lua | 207 ++++++++++++++++++++++++++++- 1 file changed, 200 insertions(+), 7 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 6e7d87a3..4c8a8269 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -1,15 +1,208 @@ root.OptionsMenu = { Type = OptionsMenuType.CCLCC, DrawType = DrawComponentType.SystemMenu, - BackgroundSprite = "OptionsBackground", + FadeInDuration = 0.2, FadeOutDuration = 0.2, - SliderTrackSprite = "OptionsBackground", - SliderFillSprite = "OptionsBackground", - SliderThumbSprite = "OptionsBackground" + + BackgroundSprite = "OptionsBackground", + + PointerSprite = "OptionsPointer", + + HeaderSprite = "OptionsHeader", + PageHeaderSprites = {}, + + PagePanelSprite = "OptionsPagePanel", + PagePanelSprites = {}, + PoleAnimation = "OptionsPoleAnimation", + + SliderTrackSprite = "OptionsSliderTrack", + VoiceSliderTrackSprite = "OptionsVoiceSliderTrack", + BinaryBoxSprite = "OptionsBinaryBox", + + SkipReadSprite = "OptionsSkipRead", + SkipAllSprite = "OptionsSkipAll", + OnSprite = "OptionsOn", + OffSprite = "OptionsOff", + YesSprite = "OptionsYes", + NoSprite = "OptionsNo", + + GuideSprite = "OptionsGuide", + VoiceGuideSprite = "OptionsVoiceGuide", + + LabelSprites = {}, + NametagSprites = {}, + PortraitSprites = {} }; root.Sprites["OptionsBackground"] = { - Sheet = "Title", - Bounds = { X = 0, Y = 0, Width = 1920, Height = 1080 } -}; \ No newline at end of file + Sheet = "Config", + Bounds = { X = 0, Y = 0, Width = 1571, Height = 1089 } +}; + +root.Sprites["OptionsSliderTrack"] = { + Sheet = "Config", + Bounds = { X = 684, Y = 1291, Width = 446, Height = 50 } +}; + +root.Sprites["OptionsVoiceSliderTrack"] = { + Sheet = "Config", + Bounds = { X = 951, Y = 1239, Width = 250, Height = 35 } +}; + +root.Sprites["OptionsBinaryBox"] = { + Sheet = "Config", + Bounds = { X = 684, Y = 1343, Width = 298, Height = 50 } +}; + +root.Sprites["OptionsPointer"] = { + Sheet = "Config", + Bounds = { X = 697, Y = 1241, Width = 71, Height = 43 } +}; + +root.Sprites["OptionsHeader"] = { + Sheet = "Config", + Bounds = { X = 5, Y = 1243, Width = 663, Height = 267 } +}; + +root.Sprites["OptionsPagePanel"] = { + Sheet = "Config", + Bounds = { X = 1571, Y = 0, Width = 477, Height = 1080 } +}; + +root.Sprites["OptionsSkipRead"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1394, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsSkipAll"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1448, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsOn"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1499, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsOff"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1551, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsYes"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1603, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsNo"] = { + Sheet = "Config", + Bounds = { X = 952, Y = 1655, Width = 148, Height = 50 } +}; + +root.Sprites["OptionsGuide"] = { + Sheet = "Config", + Bounds = { X = 0, Y = 2416, Width = 1926, Height = 57 } +}; + +root.Sprites["OptionsVoiceGuide"] = { + Sheet = "Config", + Bounds = { X = 0, Y = 2476, Width = 1926, Height = 57 } +}; + +for i = 1, 4 do + height = 80; + + root.Sprites["OptionsPageHeader" .. i] = { + Sheet = "Config", + Bounds = { + X = 0, + Y = 1510 + height * i, + Width = 942, + Height = height + } + }; + + root.OptionsMenu.PageHeaderSprites[#root.OptionsMenu.PageHeaderSprites + 1] = "OptionsPageHeader" .. i; +end + +for i = 1, 16 do + offset = ((i > 12) and {104} or {0})[1]; + height = 52; + + root.Sprites["OptionsLabel" .. i] = { + Sheet = "Config", + Bounds = { + X = 1239, + Y = 1237 + height * i + offset, + Width = 809, + Height = height + } + }; + root.OptionsMenu.LabelSprites[#root.OptionsMenu.LabelSprites + 1] = "OptionsLabel" .. i; +end + +for i = 1, 13 do + width = 218; + height = 53; + + root.Sprites["OptionsNametag" .. i] = { + Sheet = "Config", + Bounds = { + X = width * ((i - 1) % 6), + Y = height * ((i - 1) // 6), + Width = width, + Height = height + } + }; + root.OptionsMenu.NametagSprites[#root.OptionsMenu.NametagSprites + 1] = "OptionsNametag" .. i; +end + +for i = 1, 8 do + -- Interweave highlighted and non-highlighted variants + width = 224; + offset = ((i % 2 == 0) and {width * 4} or {0})[1]; + + root.Sprites["OptionsPagePanel" .. i] = { + Sheet = "Config", + Bounds = { + X = offset + width * ((i - 1) // 2), + Y = 2205, + Width = width, + Height = 195 + } + }; + root.OptionsMenu.PagePanelSprites[#root.OptionsMenu.PagePanelSprites + 1] = "OptionsPagePanel" .. i; +end + +for i = 1, 26 do + -- Interweave on and muted variants + width = 100; + + root.Sprites["OptionsPortrait" .. i] = { + Sheet = "ConfigEx", + Bounds = { + X = 768 + (width + 1) * (i - 1), + Y = ((i % 2 == 1) and {2256} or {2357})[1], + Width = width, + Height = width + } + }; + root.OptionsMenu.PortraitSprites[#root.OptionsMenu.PortraitSprites + 1] = "OptionsPortrait" .. i; +end + +MakeAnimation({ + Name = "OptionsPoleAnimation", + Sheet = "ConfigEx", + FirstFrameX = 0, + FirstFrameY = 0, + FrameWidth = 539, + ColWidth = 539, + FrameHeight = 1080, + RowHeight = 1096, + Frames = 15, + Duration = 1, + Rows = 3, + Columns = 7, + PrimaryDirection = AnimationDirections.Right +}); \ No newline at end of file From 87508b0397d759e4083cb0c315c4330093846b0d Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 17 Oct 2024 20:19:41 +0200 Subject: [PATCH 02/34] Moved config slider profile settings to derived classes --- src/profile/games/mo6tw/optionsmenu.cpp | 4 ++++ src/profile/games/mo6tw/optionsmenu.h | 4 ++++ src/profile/games/mo8/optionsmenu.cpp | 4 ++++ src/profile/games/mo8/optionsmenu.h | 4 ++++ src/profile/ui/optionsmenu.cpp | 3 --- src/profile/ui/optionsmenu.h | 3 --- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/profile/games/mo6tw/optionsmenu.cpp b/src/profile/games/mo6tw/optionsmenu.cpp index b0a5e616..0ce96435 100644 --- a/src/profile/games/mo6tw/optionsmenu.cpp +++ b/src/profile/games/mo6tw/optionsmenu.cpp @@ -27,6 +27,10 @@ void Configure() { GetMemberSpriteArray(SectionHeaderSprites, SectionHeaderSpriteCount, "SectionHeaderSprites"); + SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); + SliderFillSprite = EnsureGetMemberSprite("SliderFillSprite"); + SliderThumbSprite = EnsureGetMemberSprite("SliderThumbSprite"); + CheckboxBoxSprite = EnsureGetMemberSprite("CheckboxBoxSprite"); CheckboxTickSprite = EnsureGetMemberSprite("CheckboxTickSprite"); GetMemberSpriteArray(CheckboxLabelSprites, CheckboxLabelCount, diff --git a/src/profile/games/mo6tw/optionsmenu.h b/src/profile/games/mo6tw/optionsmenu.h index ce6c8a52..7e9b7abc 100644 --- a/src/profile/games/mo6tw/optionsmenu.h +++ b/src/profile/games/mo6tw/optionsmenu.h @@ -22,6 +22,10 @@ inline int VoiceTogglePerLine; inline Sprite SectionHeaderSprites[SectionHeaderSpriteCount]; +inline Sprite SliderTrackSprite; +inline Sprite SliderFillSprite; +inline Sprite SliderThumbSprite; + inline Sprite CheckboxBoxSprite; inline Sprite CheckboxTickSprite; inline Sprite CheckboxLabelSprites[CheckboxLabelCount]; diff --git a/src/profile/games/mo8/optionsmenu.cpp b/src/profile/games/mo8/optionsmenu.cpp index 80677921..5589f1dc 100644 --- a/src/profile/games/mo8/optionsmenu.cpp +++ b/src/profile/games/mo8/optionsmenu.cpp @@ -26,6 +26,10 @@ void Configure() { EnsureGetMemberSprite("BackButtonHighlightedSprite"); BackButtonPosition = EnsureGetMemberVec2("BackButtonPosition"); + SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); + SliderFillSprite = EnsureGetMemberSprite("SliderFillSprite"); + SliderThumbSprite = EnsureGetMemberSprite("SliderThumbSprite"); + ButtonHighlight = EnsureGetMemberSprite("ButtonHighlight"); PageLabelPosition = EnsureGetMemberVec2("PageLabelPosition"); ListStartingPosition = EnsureGetMemberVec2("ListStartingPosition"); diff --git a/src/profile/games/mo8/optionsmenu.h b/src/profile/games/mo8/optionsmenu.h index 53a75833..e13b17e3 100644 --- a/src/profile/games/mo8/optionsmenu.h +++ b/src/profile/games/mo8/optionsmenu.h @@ -14,6 +14,10 @@ inline Sprite BackButtonSprite; inline Sprite BackButtonHighlightedSprite; inline glm::vec2 BackButtonPosition; +inline Sprite SliderTrackSprite; +inline Sprite SliderFillSprite; +inline Sprite SliderThumbSprite; + inline Sprite ButtonHighlight; inline glm::vec2 PageLabelPosition; inline glm::vec2 ListStartingPosition; diff --git a/src/profile/ui/optionsmenu.cpp b/src/profile/ui/optionsmenu.cpp index 389a782f..9d215c5e 100644 --- a/src/profile/ui/optionsmenu.cpp +++ b/src/profile/ui/optionsmenu.cpp @@ -25,9 +25,6 @@ void Configure() { FadeOutDuration = EnsureGetMemberFloat("FadeOutDuration"); BackgroundSprite = EnsureGetMemberSprite("BackgroundSprite"); - SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); - SliderFillSprite = EnsureGetMemberSprite("SliderFillSprite"); - SliderThumbSprite = EnsureGetMemberSprite("SliderThumbSprite"); }; if (Type == +OptionsMenuType::MO6TW) { diff --git a/src/profile/ui/optionsmenu.h b/src/profile/ui/optionsmenu.h index 728a9387..f89564d2 100644 --- a/src/profile/ui/optionsmenu.h +++ b/src/profile/ui/optionsmenu.h @@ -10,9 +10,6 @@ namespace OptionsMenu { inline Impacto::UI::OptionsMenuType Type = Impacto::UI::OptionsMenuType::None; inline Sprite BackgroundSprite; -inline Sprite SliderTrackSprite; -inline Sprite SliderFillSprite; -inline Sprite SliderThumbSprite; inline float FadeInDuration; inline float FadeOutDuration; From 5cff4c120b35c3c39864fa98d865457073052061 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 17 Oct 2024 20:44:04 +0200 Subject: [PATCH 03/34] Added cclcc config sprites to cpp profile --- src/profile/games/cclcc/optionsmenu.cpp | 23 ++++++++++++++++++ src/profile/games/cclcc/optionsmenu.h | 31 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 7db28272..a55637d9 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -13,6 +13,29 @@ namespace CCLCC { namespace OptionsMenu { void Configure() { + HeaderSprite = EnsureGetMemberSprite("HeaderSprite"); + GetMemberSpriteArray(PageHeaderSprites, PageHeaderSpriteCount, + "PageHeaderSprites"); + PoleAnimation = EnsureGetMemberAnimation("PoleAnimation"); + + SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); + VoiceSliderTrackSprite = EnsureGetMemberSprite("VoiceSliderTrackSprite"); + BinaryBoxSprite = EnsureGetMemberSprite("BinaryBoxSprite"); + + SkipReadSprite = EnsureGetMemberSprite("SkipReadSprite"); + SkipAllSprite = EnsureGetMemberSprite("SkipAllSprite"); + OnSprite = EnsureGetMemberSprite("OnSprite"); + OffSprite = EnsureGetMemberSprite("OffSprite"); + YesSprite = EnsureGetMemberSprite("YesSprite"); + NoSprite = EnsureGetMemberSprite("NoSprite"); + + GuideSprite = EnsureGetMemberSprite("GuideSprite"); + VoiceGuideSprite = EnsureGetMemberSprite("VoiceGuideSprite"); + + GetMemberSpriteArray(LabelSprites, LabelSpriteCount, "LabelSprites"); + GetMemberSpriteArray(NametagSprites, NametagSpriteCount, "NametagSprites"); + GetMemberSpriteArray(PortraitSprites, PortraitSpriteCount, "PortraitSprites"); + auto drawType = Game::DrawComponentType::_from_integral_unchecked( EnsureGetMemberInt("DrawType")); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 1c1ad53d..907f151a 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -1,12 +1,43 @@ #pragma once #include "../../../spritesheet.h" +#include "../../../spriteanimation.h" namespace Impacto { namespace Profile { namespace CCLCC { namespace OptionsMenu { +int constexpr PageHeaderSpriteCount = 4; +int constexpr PagePanelSpriteCount = 8; +int constexpr LabelSpriteCount = 16; +int constexpr NametagSpriteCount = 13; +int constexpr PortraitSpriteCount = 26; + +inline Sprite PointerSprite; + +inline Sprite HeaderSprite; +inline Sprite PageHeaderSprites[PageHeaderSpriteCount]; +inline SpriteAnimationDef PoleAnimation; + +inline Sprite SliderTrackSprite; +inline Sprite VoiceSliderTrackSprite; +inline Sprite BinaryBoxSprite; + +inline Sprite SkipReadSprite; +inline Sprite SkipAllSprite; +inline Sprite OnSprite; +inline Sprite OffSprite; +inline Sprite YesSprite; +inline Sprite NoSprite; + +inline Sprite GuideSprite; +inline Sprite VoiceGuideSprite; + +inline Sprite LabelSprites[LabelSpriteCount]; +inline Sprite NametagSprites[NametagSpriteCount]; +inline Sprite PortraitSprites[PortraitSpriteCount]; + void Configure(); } // namespace OptionsMenu From d7204db559c485496927a031ff8f919e96109689 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 17 Oct 2024 21:37:11 +0200 Subject: [PATCH 04/34] Added positioning info to cclcc options profile --- profiles/cclcc/hud/optionsmenu.lua | 29 ++++++++++++++++++++----- src/profile/games/cclcc/optionsmenu.cpp | 24 ++++++++++++++++++++ src/profile/games/cclcc/optionsmenu.h | 21 ++++++++++++++++++ 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 4c8a8269..febea387 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -6,19 +6,27 @@ root.OptionsMenu = { FadeOutDuration = 0.2, BackgroundSprite = "OptionsBackground", + BackgroundPosition = { X = 179, Y = 0 }, PointerSprite = "OptionsPointer", + PointerOffset = { X = 89, Y = 5 }, HeaderSprite = "OptionsHeader", + HeaderPosition = { X = 10, Y = 10 }, PageHeaderSprites = {}, + PageHeaderPosition = { X = 696, Y = 182 }, PagePanelSprite = "OptionsPagePanel", + PagePanelPosition = { X = 0, Y = -8 }, PagePanelSprites = {}, PoleAnimation = "OptionsPoleAnimation", SliderTrackSprite = "OptionsSliderTrack", + SliderTrackOffset = { X = 664, Y = 2 }, VoiceSliderTrackSprite = "OptionsVoiceSliderTrack", + VoiceSliderOffset = { X = 111, Y = 56 }, BinaryBoxSprite = "OptionsBinaryBox", + BinaryBoxOffset = { X = 812, Y = 2 }, SkipReadSprite = "OptionsSkipRead", SkipAllSprite = "OptionsSkipAll", @@ -29,10 +37,19 @@ root.OptionsMenu = { GuideSprite = "OptionsGuide", VoiceGuideSprite = "OptionsVoiceGuide", + GuidePosition = { X = 0, Y = 986 }, + + EntriesStartPosition = { X = 521, Y = 311 }, + EntriesVerticalOffset = 126, + SoundEntriesStartPosition = { X = 521, Y = 331 }, + SoundEntriesVerticalOffset = 70, + VoiceEntriesOffset = { X = 408, Y = 160 }, LabelSprites = {}, NametagSprites = {}, - PortraitSprites = {} + NametagOffset = { X = 112, Y = 2 }, + PortraitSprites = {}, + VoicePosition = { X = 458, Y = 312 }, }; root.Sprites["OptionsBackground"] = { @@ -102,12 +119,12 @@ root.Sprites["OptionsNo"] = { root.Sprites["OptionsGuide"] = { Sheet = "Config", - Bounds = { X = 0, Y = 2416, Width = 1926, Height = 57 } + Bounds = { X = 0, Y = 2476, Width = 1926, Height = 57 } }; root.Sprites["OptionsVoiceGuide"] = { Sheet = "Config", - Bounds = { X = 0, Y = 2476, Width = 1926, Height = 57 } + Bounds = { X = 0, Y = 2416, Width = 1926, Height = 57 } }; for i = 1, 4 do @@ -117,7 +134,7 @@ for i = 1, 4 do Sheet = "Config", Bounds = { X = 0, - Y = 1510 + height * i, + Y = 1510 + height * (i - 1), Width = 942, Height = height } @@ -134,7 +151,7 @@ for i = 1, 16 do Sheet = "Config", Bounds = { X = 1239, - Y = 1237 + height * i + offset, + Y = 1237 + height * (i - 1) + offset, Width = 809, Height = height } @@ -150,7 +167,7 @@ for i = 1, 13 do Sheet = "Config", Bounds = { X = width * ((i - 1) % 6), - Y = height * ((i - 1) // 6), + Y = 1863 + height * ((i - 1) // 6), Width = width, Height = height } diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index a55637d9..c157912e 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -13,14 +13,29 @@ namespace CCLCC { namespace OptionsMenu { void Configure() { + BackgroundPosition = EnsureGetMemberVec2("BackgroundPosition"); + + PointerSprite = EnsureGetMemberSprite("PointerSprite"); + PointerOffset = EnsureGetMemberVec2("PointerOffset"); + HeaderSprite = EnsureGetMemberSprite("HeaderSprite"); + HeaderPosition = EnsureGetMemberVec2("HeaderPosition"); GetMemberSpriteArray(PageHeaderSprites, PageHeaderSpriteCount, "PageHeaderSprites"); + PageHeaderPosition = EnsureGetMemberVec2("PageHeaderPosition"); + + PagePanelSprite = EnsureGetMemberSprite("PagePanelSprite"); + PagePanelPosition = EnsureGetMemberVec2("PagePanelPosition"); + GetMemberSpriteArray(PagePanelSprites, PagePanelSpriteCount, + "PagePanelSprites"); PoleAnimation = EnsureGetMemberAnimation("PoleAnimation"); SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); + SliderTrackOffset = EnsureGetMemberVec2("SliderTrackOffset"); VoiceSliderTrackSprite = EnsureGetMemberSprite("VoiceSliderTrackSprite"); + VoiceSliderOffset = EnsureGetMemberVec2("VoiceSliderOffset"); BinaryBoxSprite = EnsureGetMemberSprite("BinaryBoxSprite"); + BinaryBoxOffset = EnsureGetMemberVec2("BinaryBoxOffset"); SkipReadSprite = EnsureGetMemberSprite("SkipReadSprite"); SkipAllSprite = EnsureGetMemberSprite("SkipAllSprite"); @@ -31,10 +46,19 @@ void Configure() { GuideSprite = EnsureGetMemberSprite("GuideSprite"); VoiceGuideSprite = EnsureGetMemberSprite("VoiceGuideSprite"); + GuidePosition = EnsureGetMemberVec2("GuidePosition"); + + EntriesStartPosition = EnsureGetMemberVec2("EntriesStartPosition"); + EntriesVerticalOffset = EnsureGetMemberInt("EntriesVerticalOffset"); + SoundEntriesStartPosition = EnsureGetMemberVec2("SoundEntriesStartPosition"); + SoundEntriesVerticalOffset = EnsureGetMemberInt("SoundEntriesVerticalOffset"); + VoiceEntriesOffset = EnsureGetMemberVec2("VoiceEntriesOffset"); GetMemberSpriteArray(LabelSprites, LabelSpriteCount, "LabelSprites"); GetMemberSpriteArray(NametagSprites, NametagSpriteCount, "NametagSprites"); + NametagOffset = EnsureGetMemberVec2("NametagOffset"); GetMemberSpriteArray(PortraitSprites, PortraitSpriteCount, "PortraitSprites"); + VoicePosition = EnsureGetMemberVec2("VoicePosition"); auto drawType = Game::DrawComponentType::_from_integral_unchecked( EnsureGetMemberInt("DrawType")); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 907f151a..266a3300 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -14,15 +14,27 @@ int constexpr LabelSpriteCount = 16; int constexpr NametagSpriteCount = 13; int constexpr PortraitSpriteCount = 26; +inline glm::vec2 BackgroundPosition; + inline Sprite PointerSprite; +inline glm::vec2 PointerOffset; inline Sprite HeaderSprite; +inline glm::vec2 HeaderPosition; inline Sprite PageHeaderSprites[PageHeaderSpriteCount]; +inline glm::vec2 PageHeaderPosition; + +inline Sprite PagePanelSprite; +inline glm::vec2 PagePanelPosition; +inline Sprite PagePanelSprites[PagePanelSpriteCount]; inline SpriteAnimationDef PoleAnimation; inline Sprite SliderTrackSprite; +inline glm::vec2 SliderTrackOffset; inline Sprite VoiceSliderTrackSprite; +inline glm::vec2 VoiceSliderOffset; inline Sprite BinaryBoxSprite; +inline glm::vec2 BinaryBoxOffset; inline Sprite SkipReadSprite; inline Sprite SkipAllSprite; @@ -33,10 +45,19 @@ inline Sprite NoSprite; inline Sprite GuideSprite; inline Sprite VoiceGuideSprite; +inline glm::vec2 GuidePosition; + +inline glm::vec2 EntriesStartPosition; +inline int EntriesVerticalOffset; +inline glm::vec2 SoundEntriesStartPosition; +inline int SoundEntriesVerticalOffset; +inline glm::vec2 VoiceEntriesOffset; inline Sprite LabelSprites[LabelSpriteCount]; inline Sprite NametagSprites[NametagSpriteCount]; +inline glm::vec2 NametagOffset; inline Sprite PortraitSprites[PortraitSpriteCount]; +inline glm::vec2 VoicePosition; void Configure(); From 6de0a3c6dc59de7bf8205d639c97187c651406e8 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 17 Oct 2024 22:56:15 +0200 Subject: [PATCH 05/34] Implemented static cclcc config ui mockup --- profiles/cclcc/hud/optionsmenu.lua | 46 ++++++++++++++++++------------ src/games/cclcc/optionsmenu.cpp | 35 +++++++++++++++++++++-- src/games/cclcc/optionsmenu.h | 2 ++ 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index febea387..734e3c79 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -17,7 +17,7 @@ root.OptionsMenu = { PageHeaderPosition = { X = 696, Y = 182 }, PagePanelSprite = "OptionsPagePanel", - PagePanelPosition = { X = 0, Y = -8 }, + PagePanelPosition = { X = -114, Y = 0 }, PagePanelSprites = {}, PoleAnimation = "OptionsPoleAnimation", @@ -127,14 +127,14 @@ root.Sprites["OptionsVoiceGuide"] = { Bounds = { X = 0, Y = 2416, Width = 1926, Height = 57 } }; -for i = 1, 4 do +for i = 0, 3 do height = 80; root.Sprites["OptionsPageHeader" .. i] = { Sheet = "Config", Bounds = { X = 0, - Y = 1510 + height * (i - 1), + Y = 1510 + height * i, Width = 942, Height = height } @@ -143,31 +143,36 @@ for i = 1, 4 do root.OptionsMenu.PageHeaderSprites[#root.OptionsMenu.PageHeaderSprites + 1] = "OptionsPageHeader" .. i; end -for i = 1, 16 do - offset = ((i > 12) and {104} or {0})[1]; - height = 52; +-- Rearange the labels in the array so they're in order of appearance +labelIndices = {5, 6, 7, 1, + 2, 3, 8, + 9, 10, 11, 12, 13, 4, 15, 14, + 16}; +height = 52; +for i = 0, 15 do + offset = ((i > 11) and {104} or {0})[1]; root.Sprites["OptionsLabel" .. i] = { Sheet = "Config", Bounds = { X = 1239, - Y = 1237 + height * (i - 1) + offset, + Y = 1237 + height * i + offset, Width = 809, Height = height } }; - root.OptionsMenu.LabelSprites[#root.OptionsMenu.LabelSprites + 1] = "OptionsLabel" .. i; + root.OptionsMenu.LabelSprites[labelIndices[i + 1]] = "OptionsLabel" .. i; end -for i = 1, 13 do +for i = 0, 12 do width = 218; height = 53; root.Sprites["OptionsNametag" .. i] = { Sheet = "Config", Bounds = { - X = width * ((i - 1) % 6), - Y = 1863 + height * ((i - 1) // 6), + X = width * (i % 6), + Y = 1863 + height * (i // 6), Width = width, Height = height } @@ -175,15 +180,15 @@ for i = 1, 13 do root.OptionsMenu.NametagSprites[#root.OptionsMenu.NametagSprites + 1] = "OptionsNametag" .. i; end -for i = 1, 8 do +for i = 0, 7 do -- Interweave highlighted and non-highlighted variants width = 224; - offset = ((i % 2 == 0) and {width * 4} or {0})[1]; + offset = ((i % 2 == 1) and {width * 4} or {0})[1]; root.Sprites["OptionsPagePanel" .. i] = { Sheet = "Config", Bounds = { - X = offset + width * ((i - 1) // 2), + X = offset + width * (i // 2), Y = 2205, Width = width, Height = 195 @@ -192,15 +197,15 @@ for i = 1, 8 do root.OptionsMenu.PagePanelSprites[#root.OptionsMenu.PagePanelSprites + 1] = "OptionsPagePanel" .. i; end -for i = 1, 26 do +for i = 0, 25 do -- Interweave on and muted variants width = 100; root.Sprites["OptionsPortrait" .. i] = { Sheet = "ConfigEx", Bounds = { - X = 768 + (width + 1) * (i - 1), - Y = ((i % 2 == 1) and {2256} or {2357})[1], + X = 768 + (width + 1) * i, + Y = ((i % 2 == 0) and {2256} or {2357})[1], Width = width, Height = width } @@ -211,15 +216,20 @@ end MakeAnimation({ Name = "OptionsPoleAnimation", Sheet = "ConfigEx", + FirstFrameX = 0, FirstFrameY = 0, + FrameWidth = 539, ColWidth = 539, FrameHeight = 1080, RowHeight = 1096, + Frames = 15, Duration = 1, Rows = 3, Columns = 7, - PrimaryDirection = AnimationDirections.Right + + PrimaryDirection = AnimationDirections.Right, + SecondaryDirection = AnimationDirections.Down }); \ No newline at end of file diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 67184740..6d5b6e9f 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -25,12 +25,15 @@ OptionsMenu::OptionsMenu() { FadeAnimation.LoopMode = AnimationLoopMode::Stop; FadeAnimation.DurationIn = FadeInDuration; FadeAnimation.DurationOut = FadeOutDuration; + + PoleAnimation = Profile::CCLCC::OptionsMenu::PoleAnimation.Instantiate(); } void OptionsMenu::Show() { if (State != Shown) { State = Showing; FadeAnimation.StartIn(); + PoleAnimation.StartIn(); // FirstPage->Show(); if (UI::FocusedMenu != 0) { LastFocusedMenu = UI::FocusedMenu; @@ -44,6 +47,7 @@ void OptionsMenu::Hide() { if (State != Hidden) { State = Hiding; FadeAnimation.StartOut(); + PoleAnimation.StartOut(); if (LastFocusedMenu != 0) { UI::FocusedMenu = LastFocusedMenu; LastFocusedMenu->IsFocused = true; @@ -58,6 +62,7 @@ void OptionsMenu::Update(float dt) { UpdateInput(); FadeAnimation.Update(dt); + PoleAnimation.Update(dt); if (ScrWork[SW_SYSSUBMENUCT] < 32 && State == Shown && ScrWork[SW_SYSSUBMENUNO] == 5) { Hide(); @@ -70,8 +75,34 @@ void OptionsMenu::Update(float dt) { void OptionsMenu::Render() { if (State != Hidden && ScrWork[SW_SYSSUBMENUCT] >= 32 && ScrWork[SW_SYSSUBMENUNO] == 5) { - // glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress); - Renderer->DrawSprite(BackgroundSprite, glm::vec2(0.0f)); + glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress); + + Renderer->DrawSprite(BackgroundSprite, BackgroundPosition, col); + Renderer->DrawSprite(HeaderSprite, HeaderPosition, col); + + Renderer->DrawSprite(PageHeaderSprites[2], PageHeaderPosition, col); + for (int i = 7; i < 15; i++) { + glm::vec2 pos = SoundEntriesStartPosition; + pos.y += SoundEntriesVerticalOffset * (i - 7); + + Renderer->DrawSprite(LabelSprites[i], pos, col); + + if (11 <= i && i <= 13) { + glm::vec2 boxPos = pos + BinaryBoxOffset; + + Renderer->DrawSprite(BinaryBoxSprite, boxPos, col); + Renderer->DrawSprite(YesSprite, boxPos, col); + Renderer->DrawSprite( + NoSprite, boxPos + glm::vec2(BinaryBoxSprite.ScaledWidth() / 2, 0), + col); + } else { + Renderer->DrawSprite(SliderTrackSprite, pos + SliderTrackOffset, col); + } + } + + Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); + + Renderer->DrawSprite(GuideSprite, GuidePosition, col); } } diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index ce951260..f7b888ba 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -1,6 +1,7 @@ #pragma once #include "../../ui/menu.h" +#include "../../spriteanimation.h" namespace Impacto { namespace UI { @@ -17,6 +18,7 @@ class OptionsMenu : public Menu { private: Animation FadeAnimation; + SpriteAnimation PoleAnimation; }; } // namespace CCLCC From b62f748317e931bd3e2fe27530f0646e98d8d2ab Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sun, 20 Oct 2024 22:44:57 +0200 Subject: [PATCH 06/34] Implemented pages and binary buttons --- CMakeLists.txt | 2 + src/games/cclcc/optionsmenu.cpp | 105 ++++++++++++++++--- src/games/cclcc/optionsmenu.h | 11 ++ src/spritesheet.h | 4 +- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 69 ++++++++++++ src/ui/widgets/cclcc/optionsbinarybutton.h | 37 +++++++ src/util.h | 3 + 7 files changed, 215 insertions(+), 16 deletions(-) create mode 100644 src/ui/widgets/cclcc/optionsbinarybutton.cpp create mode 100644 src/ui/widgets/cclcc/optionsbinarybutton.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8273d850..4560cdaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,7 @@ set(Impacto_Src src/ui/widgets/cc/backlogentry.cpp src/ui/widgets/cc/titlebutton.cpp src/ui/widgets/cclcc/titlebutton.cpp + src/ui/widgets/cclcc/optionsbinarybutton.cpp src/ui/widgets/cclcc/saveentrybutton.cpp src/ui/widgets/cclcc/sysmenubutton.cpp src/ui/widgets/cclcc/tipsentrybutton.cpp @@ -556,6 +557,7 @@ set(Impacto_Header src/ui/widgets/cc/backlogentry.h src/ui/widgets/cc/titlebutton.h src/ui/widgets/cclcc/titlebutton.h + src/ui/widgets/cclcc/optionsbinarybutton.h src/renderer/3d/camera.h src/renderer/3d/model.h diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 6d5b6e9f..722ba04b 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -2,14 +2,9 @@ #include "../../profile/ui/optionsmenu.h" #include "../../profile/games/cclcc/optionsmenu.h" -#include "../../renderer/renderer.h" -#include "../../mem.h" -#include "../../profile/scriptvars.h" -#include "../../inputsystem.h" +#include "../../profile/scriptinput.h" #include "../../vm/interface/input.h" -#include "../../ui/widgets/button.h" -#include "../../vm/vm.h" -#include "../../audio/audiochannel.h" +#include "../../ui/widgets/cclcc/optionsbinarybutton.h" namespace Impacto { namespace UI { @@ -18,6 +13,8 @@ namespace CCLCC { using namespace Impacto::Profile::OptionsMenu; using namespace Impacto::Profile::CCLCC::OptionsMenu; using namespace Impacto::Profile::ScriptVars; +using namespace Impacto::UI::Widgets; +using namespace Impacto::UI::Widgets::CCLCC; using namespace Impacto::Vm::Interface; OptionsMenu::OptionsMenu() { @@ -27,6 +24,56 @@ OptionsMenu::OptionsMenu() { FadeAnimation.DurationOut = FadeOutDuration; PoleAnimation = Profile::CCLCC::OptionsMenu::PoleAnimation.Instantiate(); + + Pages.reserve(4); + + BasicPage = new Group(this); + BasicPage->FocusLock = false; + for (int i = 0; i < 4; i++) { + glm::vec2 pos = EntriesStartPosition; + pos.y += EntriesVerticalOffset * i; + + BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, + LabelSprites[i], pos), + FDIR_DOWN); + } + Pages.push_back(BasicPage); + + TextPage = new Group(this); + TextPage->FocusLock = false; + for (int i = 4; i < 7; i++) { + glm::vec2 pos = EntriesStartPosition; + pos.y += EntriesVerticalOffset * (i - 4); + + TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[i], pos), + FDIR_DOWN); + } + Pages.push_back(TextPage); + + SoundPage = new Group(this); + SoundPage->FocusLock = false; + for (int i = 7; i < 15; i++) { + glm::vec2 pos = SoundEntriesStartPosition; + pos.y += SoundEntriesVerticalOffset * (i - 7); + + SoundPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[i], pos), + FDIR_DOWN); + } + Pages.push_back(SoundPage); + + VoicePage = new Group(this); + VoicePage->FocusLock = false; + for (int i = 0; i < 12; i++) { + glm::vec2 pos = VoicePosition; + pos += VoiceEntriesOffset * glm::vec2(i % 3, i / 3); + + VoicePage->Add(new Label(NametagSprites[i], pos), FDIR_RIGHT); + } + Pages.push_back(VoicePage); + + CurrentPage = 0; } void OptionsMenu::Show() { @@ -34,25 +81,32 @@ void OptionsMenu::Show() { State = Showing; FadeAnimation.StartIn(); PoleAnimation.StartIn(); - // FirstPage->Show(); - if (UI::FocusedMenu != 0) { + + Pages.at(CurrentPage)->Show(); + + if (UI::FocusedMenu != nullptr) { LastFocusedMenu = UI::FocusedMenu; LastFocusedMenu->IsFocused = false; } IsFocused = true; UI::FocusedMenu = this; + + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; } } + void OptionsMenu::Hide() { if (State != Hidden) { State = Hiding; FadeAnimation.StartOut(); PoleAnimation.StartOut(); - if (LastFocusedMenu != 0) { + + if (LastFocusedMenu != nullptr) { UI::FocusedMenu = LastFocusedMenu; LastFocusedMenu->IsFocused = true; } else { - UI::FocusedMenu = 0; + UI::FocusedMenu = nullptr; } IsFocused = false; } @@ -70,6 +124,10 @@ void OptionsMenu::Update(float dt) { ScrWork[SW_SYSSUBMENUNO] == 5) { Show(); } + + int newPageOffset = -(int)(bool)(PADinputButtonWentDown & PAD1L1) + + (int)(bool)(PADinputButtonWentDown & PAD1R1); + GoToPage((CurrentPage + newPageOffset) % Pages.size()); } void OptionsMenu::Render() { @@ -80,7 +138,10 @@ void OptionsMenu::Render() { Renderer->DrawSprite(BackgroundSprite, BackgroundPosition, col); Renderer->DrawSprite(HeaderSprite, HeaderPosition, col); - Renderer->DrawSprite(PageHeaderSprites[2], PageHeaderPosition, col); + Renderer->DrawSprite(PageHeaderSprites[+CurrentPage], PageHeaderPosition, + col); + Pages.at(CurrentPage)->Render(); + /* for (int i = 7; i < 15; i++) { glm::vec2 pos = SoundEntriesStartPosition; pos.y += SoundEntriesVerticalOffset * (i - 7); @@ -93,12 +154,13 @@ void OptionsMenu::Render() { Renderer->DrawSprite(BinaryBoxSprite, boxPos, col); Renderer->DrawSprite(YesSprite, boxPos, col); Renderer->DrawSprite( - NoSprite, boxPos + glm::vec2(BinaryBoxSprite.ScaledWidth() / 2, 0), - col); + NoSprite, boxPos + glm::vec2(BinaryBoxSprite.ScaledWidth() / 2, 0), + col); } else { Renderer->DrawSprite(SliderTrackSprite, pos + SliderTrackOffset, col); } } + */ Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); @@ -106,6 +168,21 @@ void OptionsMenu::Render() { } } +void OptionsMenu::GoToPage(int pageNumber) { + if (CurrentPage == pageNumber) return; + + Pages.at(CurrentPage)->HasFocus = false; + + CurrentPage = pageNumber; + Group& page = *Pages.at(CurrentPage); + + page.HasFocus = true; + page.Show(); + + CurrentlyFocusedElement = page.GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; +} + } // namespace CCLCC } // namespace UI } // namespace Impacto \ No newline at end of file diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index f7b888ba..5cfb59f4 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -2,6 +2,7 @@ #include "../../ui/menu.h" #include "../../spriteanimation.h" +#include "../../ui/widgets/group.h" namespace Impacto { namespace UI { @@ -17,8 +18,18 @@ class OptionsMenu : public Menu { void Render(); private: + void GoToPage(int pageNumber); + Animation FadeAnimation; SpriteAnimation PoleAnimation; + + Widgets::Group* BasicPage; + Widgets::Group* TextPage; + Widgets::Group* SoundPage; + Widgets::Group* VoicePage; + + int CurrentPage; + std::vector Pages; }; } // namespace CCLCC diff --git a/src/spritesheet.h b/src/spritesheet.h index b60c2b2a..5f727a1b 100644 --- a/src/spritesheet.h +++ b/src/spritesheet.h @@ -27,8 +27,8 @@ struct Sprite { RectF Bounds{0.0f, 0.0f, 0.0f, 0.0f}; glm::vec2 BaseScale; - float ScaledWidth() { return Bounds.Width * BaseScale.x; } - float ScaledHeight() { return Bounds.Height * BaseScale.y; } + float ScaledWidth() const { return Bounds.Width * BaseScale.x; } + float ScaledHeight() const { return Bounds.Height * BaseScale.y; } void SetScaledWidth(float scaledWidth) { Bounds.Width = scaledWidth / BaseScale.x; } diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp new file mode 100644 index 00000000..7ef5beae --- /dev/null +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -0,0 +1,69 @@ +#include "optionsbinarybutton.h" + +#include "../../../profile/games/cclcc/optionsmenu.h" +#include "../../../renderer/renderer.h" + +using namespace Impacto::Profile::CCLCC::OptionsMenu; + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +OptionsBinaryButton::OptionsBinaryButton(const Sprite& box, + const Sprite& trueLabel, + const Sprite& falseLabel, + const Sprite& label, glm::vec2 pos) + : BoxSprite(box), + TrueSprite(trueLabel), + FalseSprite(falseLabel), + LabelSprite(label) { + Bounds = RectF(pos.x, pos.y, BinaryBoxOffset.x + BoxSprite.ScaledWidth(), + LabelSprite.ScaledHeight()); +} + +inline glm::vec2 OptionsBinaryButton::GetTruePos() const { + return Bounds.GetPos() + BinaryBoxOffset; +} + +inline glm::vec2 OptionsBinaryButton::GetFalsePos() const { + return Bounds.GetPos() + BinaryBoxOffset + + glm::vec2(BoxSprite.ScaledWidth() / 2, 0.0f); +} + +void OptionsBinaryButton::Render() { + HighlightTint.a = Tint.a; + glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); + + glm::vec4 trueTint; + glm::vec4 falseTint; + glm::vec2 highlightPos; + RectF highlightBounds(0.0f, 0.0f, BoxSprite.ScaledWidth() / 2, + BoxSprite.ScaledHeight()); + if (State) { + trueTint = Tint; + falseTint = black; + highlightPos = GetTruePos(); + } else { + trueTint = black; + falseTint = Tint; + highlightPos = GetFalsePos(); + } + highlightBounds.X = highlightPos.x; + highlightBounds.Y = highlightPos.y; + + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); + + Renderer->DrawRect(highlightBounds, HighlightTint); + Renderer->DrawSprite(BoxSprite, GetTruePos(), Tint); + + Renderer->DrawSprite(TrueSprite, GetTruePos(), trueTint); + Renderer->DrawSprite(FalseSprite, GetFalsePos(), falseTint); +} + +void OptionsBinaryButton::UpdateInput() {} + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h new file mode 100644 index 00000000..03f0c5dd --- /dev/null +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -0,0 +1,37 @@ +#pragma once + +#include "../../widget.h" +#include "../../../spritesheet.h" + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +class OptionsBinaryButton : public Widget { + public: + OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, + const Sprite& falseLabel, const Sprite& label, + glm::vec2 pos); + + void Render() override; + void UpdateInput() override; + + private: + inline glm::vec2 GetTruePos() const; + inline glm::vec2 GetFalsePos() const; + + const Sprite& BoxSprite; + const Sprite& TrueSprite; + const Sprite& FalseSprite; + const Sprite& LabelSprite; + + glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); + + bool State = true; +}; + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/util.h b/src/util.h index 96ecbeeb..4bc53701 100644 --- a/src/util.h +++ b/src/util.h @@ -80,6 +80,9 @@ struct RectF { return !(*this == other); } + constexpr glm::vec2 GetPos() const { return glm::vec2(X, Y); } + constexpr glm::vec2 GetSize() const { return glm::vec2(Width, Height); } + static RectF Coalesce(const RectF& first, const RectF& second); }; From bb06bf20ea9a2b4b91889c65df541faa997fcdeb Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sun, 20 Oct 2024 23:11:29 +0200 Subject: [PATCH 07/34] Added options slider --- CMakeLists.txt | 2 ++ src/games/cclcc/optionsmenu.cpp | 36 ++++++++++++++---------- src/ui/widgets/cclcc/optionsslider.cpp | 39 ++++++++++++++++++++++++++ src/ui/widgets/cclcc/optionsslider.h | 30 ++++++++++++++++++++ 4 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 src/ui/widgets/cclcc/optionsslider.cpp create mode 100644 src/ui/widgets/cclcc/optionsslider.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4560cdaf..a0fa78cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,6 +245,7 @@ set(Impacto_Src src/ui/widgets/cc/titlebutton.cpp src/ui/widgets/cclcc/titlebutton.cpp src/ui/widgets/cclcc/optionsbinarybutton.cpp + src/ui/widgets/cclcc/optionsslider.cpp src/ui/widgets/cclcc/saveentrybutton.cpp src/ui/widgets/cclcc/sysmenubutton.cpp src/ui/widgets/cclcc/tipsentrybutton.cpp @@ -558,6 +559,7 @@ set(Impacto_Header src/ui/widgets/cc/titlebutton.h src/ui/widgets/cclcc/titlebutton.h src/ui/widgets/cclcc/optionsbinarybutton.h + src/ui/widgets/cclcc/optionsslider.h src/renderer/3d/camera.h src/renderer/3d/model.h diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 722ba04b..c23107b5 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -5,6 +5,7 @@ #include "../../profile/scriptinput.h" #include "../../vm/interface/input.h" #include "../../ui/widgets/cclcc/optionsbinarybutton.h" +#include "../../ui/widgets/cclcc/optionsslider.h" namespace Impacto { namespace UI { @@ -26,40 +27,45 @@ OptionsMenu::OptionsMenu() { PoleAnimation = Profile::CCLCC::OptionsMenu::PoleAnimation.Instantiate(); Pages.reserve(4); + glm::vec2 pos = EntriesStartPosition; BasicPage = new Group(this); BasicPage->FocusLock = false; for (int i = 0; i < 4; i++) { - glm::vec2 pos = EntriesStartPosition; - pos.y += EntriesVerticalOffset * i; - BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, LabelSprites[i], pos), FDIR_DOWN); + + pos.y += EntriesVerticalOffset; } Pages.push_back(BasicPage); + pos = EntriesStartPosition; TextPage = new Group(this); TextPage->FocusLock = false; - for (int i = 4; i < 7; i++) { - glm::vec2 pos = EntriesStartPosition; - pos.y += EntriesVerticalOffset * (i - 4); - - TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[i], pos), + for (int i = 4; i < 6; i++) { + TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos), FDIR_DOWN); + + pos.y += EntriesVerticalOffset; } + TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[6], pos), + FDIR_DOWN); Pages.push_back(TextPage); + pos = SoundEntriesStartPosition; SoundPage = new Group(this); SoundPage->FocusLock = false; for (int i = 7; i < 15; i++) { - glm::vec2 pos = SoundEntriesStartPosition; - pos.y += SoundEntriesVerticalOffset * (i - 7); - - SoundPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[i], pos), - FDIR_DOWN); + Widget* widget = + (i < 11 || i == 14) + ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos) + : widget = new OptionsBinaryButton(BinaryBoxSprite, YesSprite, + NoSprite, LabelSprites[i], pos); + SoundPage->Add(widget, FDIR_DOWN); + + pos.y += SoundEntriesVerticalOffset; } Pages.push_back(SoundPage); diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp new file mode 100644 index 00000000..7dabe416 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -0,0 +1,39 @@ +#include "optionsslider.h" + +#include "../../../profile/games/cclcc/optionsmenu.h" +#include "../../../renderer/renderer.h" + +using namespace Impacto::Profile::CCLCC::OptionsMenu; + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, + glm::vec2 pos) + : BoxSprite(box), LabelSprite(label) { + Bounds = RectF(pos.x, pos.y, SliderTrackOffset.x + box.ScaledWidth(), + LabelSprite.ScaledHeight()); +} + +void OptionsSlider::Render() { + HighlightTint.a = Tint.a; + glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); + + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); + + RectF highlightBounds( + Bounds.X + SliderTrackOffset.x, Bounds.Y + SliderTrackOffset.y, + Progress * BoxSprite.ScaledWidth(), BoxSprite.ScaledHeight()); + Renderer->DrawRect(highlightBounds, HighlightTint); + + Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); +} + +void OptionsSlider::UpdateInput() {} + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h new file mode 100644 index 00000000..a00ee00d --- /dev/null +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -0,0 +1,30 @@ +#pragma once + +#include "../../widget.h" +#include "../../../spritesheet.h" + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +class OptionsSlider : public Widget { + public: + OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos); + + void Render() override; + void UpdateInput() override; + + private: + const Sprite& BoxSprite; + const Sprite& LabelSprite; + + glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); + + float Progress = 0.0f; +}; + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file From 52a63df9bad464e74111e336475802ac363ba3ae Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sun, 20 Oct 2024 23:23:28 +0200 Subject: [PATCH 08/34] Added highlight color to profile --- profiles/cclcc/hud/optionsmenu.lua | 2 ++ src/games/cclcc/optionsmenu.cpp | 19 +++++++------ src/profile/games/cclcc/optionsmenu.cpp | 2 ++ src/profile/games/cclcc/optionsmenu.h | 2 ++ src/ui/widgets/cclcc/optionsbinarybutton.cpp | 29 ++++++++------------ src/ui/widgets/cclcc/optionsbinarybutton.h | 4 +-- src/ui/widgets/cclcc/optionsslider.cpp | 8 +++--- src/ui/widgets/cclcc/optionsslider.h | 5 ++-- 8 files changed, 37 insertions(+), 34 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 734e3c79..33a81aad 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -5,6 +5,8 @@ root.OptionsMenu = { FadeInDuration = 0.2, FadeOutDuration = 0.2, + HighlightColor = { X = 0.94, Y = 0.49, Z = 0.59 }, + BackgroundSprite = "OptionsBackground", BackgroundPosition = { X = 179, Y = 0 }, diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index c23107b5..27397765 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -28,12 +28,13 @@ OptionsMenu::OptionsMenu() { Pages.reserve(4); glm::vec2 pos = EntriesStartPosition; + glm::vec4 highlightTint(HighlightColor, 1.0f); BasicPage = new Group(this); BasicPage->FocusLock = false; for (int i = 0; i < 4; i++) { BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, - LabelSprites[i], pos), + LabelSprites[i], pos, highlightTint), FDIR_DOWN); pos.y += EntriesVerticalOffset; @@ -44,13 +45,14 @@ OptionsMenu::OptionsMenu() { TextPage = new Group(this); TextPage->FocusLock = false; for (int i = 4; i < 6; i++) { - TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos), + TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos, + highlightTint), FDIR_DOWN); pos.y += EntriesVerticalOffset; } TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[6], pos), + LabelSprites[6], pos, highlightTint), FDIR_DOWN); Pages.push_back(TextPage); @@ -58,11 +60,12 @@ OptionsMenu::OptionsMenu() { SoundPage = new Group(this); SoundPage->FocusLock = false; for (int i = 7; i < 15; i++) { - Widget* widget = - (i < 11 || i == 14) - ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos) - : widget = new OptionsBinaryButton(BinaryBoxSprite, YesSprite, - NoSprite, LabelSprites[i], pos); + Widget* widget = (i < 11 || i == 14) + ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], + pos, highlightTint) + : widget = new OptionsBinaryButton( + BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[i], pos, highlightTint); SoundPage->Add(widget, FDIR_DOWN); pos.y += SoundEntriesVerticalOffset; diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index c157912e..216d5e03 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -15,6 +15,8 @@ namespace OptionsMenu { void Configure() { BackgroundPosition = EnsureGetMemberVec2("BackgroundPosition"); + HighlightColor = EnsureGetMemberVec3("HighlightColor"); + PointerSprite = EnsureGetMemberSprite("PointerSprite"); PointerOffset = EnsureGetMemberVec2("PointerOffset"); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 266a3300..78f174ad 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -16,6 +16,8 @@ int constexpr PortraitSpriteCount = 26; inline glm::vec2 BackgroundPosition; +inline glm::vec3 HighlightColor; + inline Sprite PointerSprite; inline glm::vec2 PointerOffset; diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index 7ef5beae..790055a9 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -13,11 +13,13 @@ namespace CCLCC { OptionsBinaryButton::OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, const Sprite& falseLabel, - const Sprite& label, glm::vec2 pos) + const Sprite& label, glm::vec2 pos, + glm::vec4 highlightTint) : BoxSprite(box), TrueSprite(trueLabel), FalseSprite(falseLabel), - LabelSprite(label) { + LabelSprite(label), + HighlightTint(highlightTint) { Bounds = RectF(pos.x, pos.y, BinaryBoxOffset.x + BoxSprite.ScaledWidth(), LabelSprite.ScaledHeight()); } @@ -33,32 +35,23 @@ inline glm::vec2 OptionsBinaryButton::GetFalsePos() const { void OptionsBinaryButton::Render() { HighlightTint.a = Tint.a; - glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); - glm::vec4 trueTint; - glm::vec4 falseTint; - glm::vec2 highlightPos; RectF highlightBounds(0.0f, 0.0f, BoxSprite.ScaledWidth() / 2, BoxSprite.ScaledHeight()); - if (State) { - trueTint = Tint; - falseTint = black; - highlightPos = GetTruePos(); - } else { - trueTint = black; - falseTint = Tint; - highlightPos = GetFalsePos(); - } + glm::vec2 highlightPos = (State) ? GetTruePos() : GetFalsePos(); highlightBounds.X = highlightPos.x; highlightBounds.Y = highlightPos.y; - Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), + {0.0f, 0.0f, 0.0f, Tint.a}); Renderer->DrawRect(highlightBounds, HighlightTint); Renderer->DrawSprite(BoxSprite, GetTruePos(), Tint); - Renderer->DrawSprite(TrueSprite, GetTruePos(), trueTint); - Renderer->DrawSprite(FalseSprite, GetFalsePos(), falseTint); + Renderer->DrawSprite(TrueSprite, GetTruePos(), Tint, glm::vec2(1.0f), 0.0f, + !State); + Renderer->DrawSprite(FalseSprite, GetFalsePos(), Tint, glm::vec2(1.0f), 0.0f, + State); } void OptionsBinaryButton::UpdateInput() {} diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h index 03f0c5dd..365c9de1 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.h +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -12,7 +12,7 @@ class OptionsBinaryButton : public Widget { public: OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, const Sprite& falseLabel, const Sprite& label, - glm::vec2 pos); + glm::vec2 pos, glm::vec4 highlightTint); void Render() override; void UpdateInput() override; @@ -26,7 +26,7 @@ class OptionsBinaryButton : public Widget { const Sprite& FalseSprite; const Sprite& LabelSprite; - glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); + glm::vec4 HighlightTint; bool State = true; }; diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index 7dabe416..ea5a8d87 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -11,17 +11,17 @@ namespace Widgets { namespace CCLCC { OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, - glm::vec2 pos) - : BoxSprite(box), LabelSprite(label) { + glm::vec2 pos, glm::vec4 highlightTint) + : BoxSprite(box), LabelSprite(label), HighlightTint(highlightTint) { Bounds = RectF(pos.x, pos.y, SliderTrackOffset.x + box.ScaledWidth(), LabelSprite.ScaledHeight()); } void OptionsSlider::Render() { HighlightTint.a = Tint.a; - glm::vec4 black = glm::vec4(0.0f, 0.0f, 0.0f, Tint.a); - Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), black); + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), + {0.0f, 0.0f, 0.0f, Tint.a}); RectF highlightBounds( Bounds.X + SliderTrackOffset.x, Bounds.Y + SliderTrackOffset.y, diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index a00ee00d..243411ef 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -10,7 +10,8 @@ namespace CCLCC { class OptionsSlider : public Widget { public: - OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos); + OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, + glm::vec4 highlightTint); void Render() override; void UpdateInput() override; @@ -19,7 +20,7 @@ class OptionsSlider : public Widget { const Sprite& BoxSprite; const Sprite& LabelSprite; - glm::vec4 HighlightTint = glm::vec4(0.94f, 0.49f, 0.59f, 1.0f); + glm::vec4 HighlightTint; float Progress = 0.0f; }; From c5b4da3a736236f942c9be8d3d24c765cb313834 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 12 Nov 2024 22:11:51 +0100 Subject: [PATCH 09/34] Implemented base of config movement --- CMakeLists.txt | 2 + profiles/cclcc/hud/optionsmenu.lua | 2 +- src/games/cclcc/optionsmenu.cpp | 43 ++++++++---------- src/games/cclcc/optionsmenu.h | 9 ++-- src/games/chlcc/optionsmenu.cpp | 4 ++ src/games/mo6tw/optionsmenu.cpp | 4 ++ src/ui/widgets/cclcc/optionsbinarybutton.cpp | 25 ++++++----- src/ui/widgets/cclcc/optionsbinarybutton.h | 7 +-- src/ui/widgets/cclcc/optionsentry.cpp | 46 ++++++++++++++++++++ src/ui/widgets/cclcc/optionsentry.h | 29 ++++++++++++ src/ui/widgets/cclcc/optionsslider.cpp | 12 ++--- src/ui/widgets/cclcc/optionsslider.h | 7 +-- src/vm/inst_misc.cpp | 8 ---- 13 files changed, 130 insertions(+), 68 deletions(-) create mode 100644 src/ui/widgets/cclcc/optionsentry.cpp create mode 100644 src/ui/widgets/cclcc/optionsentry.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a0fa78cf..d01f8392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,7 @@ set(Impacto_Src src/ui/widgets/cc/backlogentry.cpp src/ui/widgets/cc/titlebutton.cpp src/ui/widgets/cclcc/titlebutton.cpp + src/ui/widgets/cclcc/optionsentry.cpp src/ui/widgets/cclcc/optionsbinarybutton.cpp src/ui/widgets/cclcc/optionsslider.cpp src/ui/widgets/cclcc/saveentrybutton.cpp @@ -558,6 +559,7 @@ set(Impacto_Header src/ui/widgets/cc/backlogentry.h src/ui/widgets/cc/titlebutton.h src/ui/widgets/cclcc/titlebutton.h + src/ui/widgets/cclcc/optionsentry.h src/ui/widgets/cclcc/optionsbinarybutton.h src/ui/widgets/cclcc/optionsslider.h diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 33a81aad..b8c22331 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -11,7 +11,7 @@ root.OptionsMenu = { BackgroundPosition = { X = 179, Y = 0 }, PointerSprite = "OptionsPointer", - PointerOffset = { X = 89, Y = 5 }, + PointerOffset = { X = -89, Y = 5 }, HeaderSprite = "OptionsHeader", HeaderPosition = { X = 10, Y = 10 }, diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 27397765..6c2f31c5 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -31,7 +31,6 @@ OptionsMenu::OptionsMenu() { glm::vec4 highlightTint(HighlightColor, 1.0f); BasicPage = new Group(this); - BasicPage->FocusLock = false; for (int i = 0; i < 4; i++) { BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, LabelSprites[i], pos, highlightTint), @@ -43,7 +42,6 @@ OptionsMenu::OptionsMenu() { pos = EntriesStartPosition; TextPage = new Group(this); - TextPage->FocusLock = false; for (int i = 4; i < 6; i++) { TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos, highlightTint), @@ -58,7 +56,6 @@ OptionsMenu::OptionsMenu() { pos = SoundEntriesStartPosition; SoundPage = new Group(this); - SoundPage->FocusLock = false; for (int i = 7; i < 15; i++) { Widget* widget = (i < 11 || i == 14) ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], @@ -73,7 +70,6 @@ OptionsMenu::OptionsMenu() { Pages.push_back(SoundPage); VoicePage = new Group(this); - VoicePage->FocusLock = false; for (int i = 0; i < 12; i++) { glm::vec2 pos = VoicePosition; pos += VoiceEntriesOffset * glm::vec2(i % 3, i / 3); @@ -123,6 +119,7 @@ void OptionsMenu::Hide() { void OptionsMenu::Update(float dt) { UpdateInput(); + Pages.at(CurrentPage)->Update(dt); FadeAnimation.Update(dt); PoleAnimation.Update(dt); @@ -139,6 +136,19 @@ void OptionsMenu::Update(float dt) { GoToPage((CurrentPage + newPageOffset) % Pages.size()); } +void OptionsMenu::UpdateInput() { + bool nothingSelected = + CurrentlyFocusedElement == nullptr || + !static_cast(CurrentlyFocusedElement)->Selected; + if (nothingSelected && GetControlState(CT_Back)) { + SetFlag(SF_SUBMENUEXIT, true); + return; + } + + // Only able to move up and down if nothing is selected + if (nothingSelected) Menu::UpdateInput(); +} + void OptionsMenu::Render() { if (State != Hidden && ScrWork[SW_SYSSUBMENUCT] >= 32 && ScrWork[SW_SYSSUBMENUNO] == 5) { @@ -147,29 +157,9 @@ void OptionsMenu::Render() { Renderer->DrawSprite(BackgroundSprite, BackgroundPosition, col); Renderer->DrawSprite(HeaderSprite, HeaderPosition, col); - Renderer->DrawSprite(PageHeaderSprites[+CurrentPage], PageHeaderPosition, + Renderer->DrawSprite(PageHeaderSprites[CurrentPage], PageHeaderPosition, col); Pages.at(CurrentPage)->Render(); - /* - for (int i = 7; i < 15; i++) { - glm::vec2 pos = SoundEntriesStartPosition; - pos.y += SoundEntriesVerticalOffset * (i - 7); - - Renderer->DrawSprite(LabelSprites[i], pos, col); - - if (11 <= i && i <= 13) { - glm::vec2 boxPos = pos + BinaryBoxOffset; - - Renderer->DrawSprite(BinaryBoxSprite, boxPos, col); - Renderer->DrawSprite(YesSprite, boxPos, col); - Renderer->DrawSprite( - NoSprite, boxPos + glm::vec2(BinaryBoxSprite.ScaledWidth() / 2, 0), - col); - } else { - Renderer->DrawSprite(SliderTrackSprite, pos + SliderTrackOffset, col); - } - } - */ Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); @@ -180,7 +170,7 @@ void OptionsMenu::Render() { void OptionsMenu::GoToPage(int pageNumber) { if (CurrentPage == pageNumber) return; - Pages.at(CurrentPage)->HasFocus = false; + Pages.at(CurrentPage)->Hide(); CurrentPage = pageNumber; Group& page = *Pages.at(CurrentPage); @@ -188,6 +178,7 @@ void OptionsMenu::GoToPage(int pageNumber) { page.HasFocus = true; page.Show(); + if (CurrentlyFocusedElement) CurrentlyFocusedElement->Hide(); CurrentlyFocusedElement = page.GetFirstFocusableChild(); CurrentlyFocusedElement->HasFocus = true; } diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index 5cfb59f4..3022992a 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -12,10 +12,11 @@ class OptionsMenu : public Menu { public: OptionsMenu(); - void Show(); - void Hide(); - void Update(float dt); - void Render(); + void Show() override; + void Hide() override; + void Update(float dt) override; + void UpdateInput() override; + void Render() override; private: void GoToPage(int pageNumber); diff --git a/src/games/chlcc/optionsmenu.cpp b/src/games/chlcc/optionsmenu.cpp index f5fe40a8..5025ad19 100644 --- a/src/games/chlcc/optionsmenu.cpp +++ b/src/games/chlcc/optionsmenu.cpp @@ -131,6 +131,10 @@ void OptionsMenu::Update(float dt) { TitleFade.Update(dt); UpdateTitles(); } + + if (GetControlState(CT_Back)) { + SetFlag(SF_SUBMENUEXIT, true); + } } inline void OptionsMenu::DrawCircles() { diff --git a/src/games/mo6tw/optionsmenu.cpp b/src/games/mo6tw/optionsmenu.cpp index 2b854b10..d4490b13 100644 --- a/src/games/mo6tw/optionsmenu.cpp +++ b/src/games/mo6tw/optionsmenu.cpp @@ -377,6 +377,10 @@ void OptionsMenu::Update(float dt) { } } } + + if (GetControlState(CT_Back)) { + SetFlag(SF_SUBMENUEXIT, true); + } } void OptionsMenu::Render() { diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index 790055a9..9ca1a991 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -2,8 +2,10 @@ #include "../../../profile/games/cclcc/optionsmenu.h" #include "../../../renderer/renderer.h" +#include "../../../vm/interface/input.h" using namespace Impacto::Profile::CCLCC::OptionsMenu; +using namespace Impacto::Vm::Interface; namespace Impacto { namespace UI { @@ -15,13 +17,11 @@ OptionsBinaryButton::OptionsBinaryButton(const Sprite& box, const Sprite& falseLabel, const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint) - : BoxSprite(box), + : OptionsEntry(label, pos, highlightTint), + BoxSprite(box), TrueSprite(trueLabel), - FalseSprite(falseLabel), - LabelSprite(label), - HighlightTint(highlightTint) { - Bounds = RectF(pos.x, pos.y, BinaryBoxOffset.x + BoxSprite.ScaledWidth(), - LabelSprite.ScaledHeight()); + FalseSprite(falseLabel) { + Bounds.Width = BinaryBoxOffset.x + BoxSprite.ScaledWidth(); } inline glm::vec2 OptionsBinaryButton::GetTruePos() const { @@ -34,7 +34,7 @@ inline glm::vec2 OptionsBinaryButton::GetFalsePos() const { } void OptionsBinaryButton::Render() { - HighlightTint.a = Tint.a; + OptionsEntry::Render(); RectF highlightBounds(0.0f, 0.0f, BoxSprite.ScaledWidth() / 2, BoxSprite.ScaledHeight()); @@ -42,9 +42,6 @@ void OptionsBinaryButton::Render() { highlightBounds.X = highlightPos.x; highlightBounds.Y = highlightPos.y; - Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), - {0.0f, 0.0f, 0.0f, Tint.a}); - Renderer->DrawRect(highlightBounds, HighlightTint); Renderer->DrawSprite(BoxSprite, GetTruePos(), Tint); @@ -54,7 +51,13 @@ void OptionsBinaryButton::Render() { State); } -void OptionsBinaryButton::UpdateInput() {} +void OptionsBinaryButton::UpdateInput() { + OptionsEntry::UpdateInput(); + if (!Selected) return; + + if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) + State = PADinputButtonWentDown & PAD1LEFT; +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h index 365c9de1..1460acd2 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.h +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -1,6 +1,6 @@ #pragma once -#include "../../widget.h" +#include "./optionsentry.h" #include "../../../spritesheet.h" namespace Impacto { @@ -8,7 +8,7 @@ namespace UI { namespace Widgets { namespace CCLCC { -class OptionsBinaryButton : public Widget { +class OptionsBinaryButton : public OptionsEntry { public: OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, const Sprite& falseLabel, const Sprite& label, @@ -24,9 +24,6 @@ class OptionsBinaryButton : public Widget { const Sprite& BoxSprite; const Sprite& TrueSprite; const Sprite& FalseSprite; - const Sprite& LabelSprite; - - glm::vec4 HighlightTint; bool State = true; }; diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp new file mode 100644 index 00000000..6af02213 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -0,0 +1,46 @@ +#include "optionsentry.h" + +#include "../../../profile/games/cclcc/optionsmenu.h" +#include "../../../renderer/renderer.h" +#include "../../../vm/interface/input.h" + +using namespace Impacto::Profile::CCLCC::OptionsMenu; +using namespace Impacto::Vm::Interface; + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +OptionsEntry::OptionsEntry(const Sprite& label, glm::vec2 pos, + glm::vec4 highlightTint) + : LabelSprite(label), HighlightTint(highlightTint) { + Bounds = RectF(pos.x, pos.y, LabelSprite.ScaledWidth(), + LabelSprite.ScaledHeight()); +} + +void OptionsEntry::Render() { + HighlightTint.a = Tint.a; + + Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), + Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); + if (HasFocus) + Renderer->DrawSprite(PointerSprite, Bounds.GetPos() + PointerOffset, Tint); +} + +void OptionsEntry::UpdateInput() { + if (!HasFocus) return; + + if (PADinputButtonWentDown & PAD1A) { + Selected = true; + } else if (PADinputButtonWentDown & PAD1B) { + Selected = false; + } +} + +void OptionsEntry::Hide() { Selected = false; } + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsentry.h b/src/ui/widgets/cclcc/optionsentry.h new file mode 100644 index 00000000..018c1610 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsentry.h @@ -0,0 +1,29 @@ +#pragma once + +#include "../../widget.h" +#include "../../../spritesheet.h" + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +class OptionsEntry : public Widget { + public: + OptionsEntry(const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint); + + void Render() override; + void UpdateInput() override; + void Hide() override; + + bool Selected = false; + + protected: + const Sprite& LabelSprite; + glm::vec4 HighlightTint; +}; + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index ea5a8d87..ffd0bde8 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -12,16 +12,12 @@ namespace CCLCC { OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint) - : BoxSprite(box), LabelSprite(label), HighlightTint(highlightTint) { - Bounds = RectF(pos.x, pos.y, SliderTrackOffset.x + box.ScaledWidth(), - LabelSprite.ScaledHeight()); + : OptionsEntry(label, pos, highlightTint), BoxSprite(box) { + Bounds.Width = SliderTrackOffset.x + BoxSprite.ScaledWidth(); } void OptionsSlider::Render() { - HighlightTint.a = Tint.a; - - Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), - {0.0f, 0.0f, 0.0f, Tint.a}); + OptionsEntry::Render(); RectF highlightBounds( Bounds.X + SliderTrackOffset.x, Bounds.Y + SliderTrackOffset.y, @@ -31,7 +27,7 @@ void OptionsSlider::Render() { Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); } -void OptionsSlider::UpdateInput() {} +void OptionsSlider::UpdateInput() { OptionsEntry::UpdateInput(); } } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 243411ef..9dc1f3d3 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -1,6 +1,6 @@ #pragma once -#include "../../widget.h" +#include "./optionsentry.h" #include "../../../spritesheet.h" namespace Impacto { @@ -8,7 +8,7 @@ namespace UI { namespace Widgets { namespace CCLCC { -class OptionsSlider : public Widget { +class OptionsSlider : public OptionsEntry { public: OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint); @@ -18,9 +18,6 @@ class OptionsSlider : public Widget { private: const Sprite& BoxSprite; - const Sprite& LabelSprite; - - glm::vec4 HighlightTint; float Progress = 0.0f; }; diff --git a/src/vm/inst_misc.cpp b/src/vm/inst_misc.cpp index 07649c85..5b602927 100644 --- a/src/vm/inst_misc.cpp +++ b/src/vm/inst_misc.cpp @@ -219,14 +219,6 @@ VmInstruction(InstOption) { "STUB instruction Option(type: Init)\n"); break; case 1: - if (!((Interface::PADinputButtonWentDown & Interface::PAD1B) || - (Interface::PADinputMouseWentDown & Interface::PAD1B))) { - ResetInstruction; - BlockThread; - } else { - SetFlag(SF_SUBMENUEXIT, true); - Interface::PADinputButtonWentDown |= Interface::PAD1A; - } ImpLogSlow(LL_Warning, LC_VMStub, "STUB instruction Option(type: Main)\n"); break; From a50a36307da107e6e7478c748b212cdc796c32ed Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 12 Nov 2024 22:54:04 +0100 Subject: [PATCH 10/34] Implemented config slider movement --- profiles/cclcc/hud/optionsmenu.lua | 1 + src/games/cclcc/optionsmenu.cpp | 4 ++-- src/profile/games/cclcc/optionsmenu.cpp | 1 + src/profile/games/cclcc/optionsmenu.h | 1 + src/ui/widgets/cclcc/optionsslider.cpp | 19 ++++++++++++++++--- src/ui/widgets/cclcc/optionsslider.h | 5 +++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index b8c22331..884e949c 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -29,6 +29,7 @@ root.OptionsMenu = { VoiceSliderOffset = { X = 111, Y = 56 }, BinaryBoxSprite = "OptionsBinaryBox", BinaryBoxOffset = { X = 812, Y = 2 }, + SliderSpeed = 1.0, SkipReadSprite = "OptionsSkipRead", SkipAllSprite = "OptionsSkipAll", diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 6c2f31c5..823f55ae 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -44,7 +44,7 @@ OptionsMenu::OptionsMenu() { TextPage = new Group(this); for (int i = 4; i < 6; i++) { TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos, - highlightTint), + highlightTint, SliderSpeed), FDIR_DOWN); pos.y += EntriesVerticalOffset; @@ -59,7 +59,7 @@ OptionsMenu::OptionsMenu() { for (int i = 7; i < 15; i++) { Widget* widget = (i < 11 || i == 14) ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], - pos, highlightTint) + pos, highlightTint, SliderSpeed) : widget = new OptionsBinaryButton( BinaryBoxSprite, YesSprite, NoSprite, LabelSprites[i], pos, highlightTint); diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 216d5e03..93b2f671 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -38,6 +38,7 @@ void Configure() { VoiceSliderOffset = EnsureGetMemberVec2("VoiceSliderOffset"); BinaryBoxSprite = EnsureGetMemberSprite("BinaryBoxSprite"); BinaryBoxOffset = EnsureGetMemberVec2("BinaryBoxOffset"); + SliderSpeed = EnsureGetMemberFloat("SliderSpeed"); SkipReadSprite = EnsureGetMemberSprite("SkipReadSprite"); SkipAllSprite = EnsureGetMemberSprite("SkipAllSprite"); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 78f174ad..0b0d72fa 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -37,6 +37,7 @@ inline Sprite VoiceSliderTrackSprite; inline glm::vec2 VoiceSliderOffset; inline Sprite BinaryBoxSprite; inline glm::vec2 BinaryBoxOffset; +inline float SliderSpeed; inline Sprite SkipReadSprite; inline Sprite SkipAllSprite; diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index ffd0bde8..1c15b546 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -2,8 +2,10 @@ #include "../../../profile/games/cclcc/optionsmenu.h" #include "../../../renderer/renderer.h" +#include "../../../vm/interface/input.h" using namespace Impacto::Profile::CCLCC::OptionsMenu; +using namespace Impacto::Vm::Interface; namespace Impacto { namespace UI { @@ -11,8 +13,11 @@ namespace Widgets { namespace CCLCC { OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, - glm::vec2 pos, glm::vec4 highlightTint) - : OptionsEntry(label, pos, highlightTint), BoxSprite(box) { + glm::vec2 pos, glm::vec4 highlightTint, + float sliderSpeed) + : OptionsEntry(label, pos, highlightTint), + BoxSprite(box), + SliderSpeed(sliderSpeed) { Bounds.Width = SliderTrackOffset.x + BoxSprite.ScaledWidth(); } @@ -27,7 +32,15 @@ void OptionsSlider::Render() { Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); } -void OptionsSlider::UpdateInput() { OptionsEntry::UpdateInput(); } +void OptionsSlider::Update(float dt) { + OptionsEntry::Update(dt); + if (!Selected) return; + + int slideDirection = (bool)(PADinputButtonIsDown & PAD1RIGHT) - + (bool)(PADinputButtonIsDown & PAD1LEFT); + Progress = + std::clamp(Progress + slideDirection * SliderSpeed * dt, 0.0f, 1.0f); +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 9dc1f3d3..9333d216 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -11,15 +11,16 @@ namespace CCLCC { class OptionsSlider : public OptionsEntry { public: OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, - glm::vec4 highlightTint); + glm::vec4 highlightTint, float sliderSpeed); void Render() override; - void UpdateInput() override; + void Update(float dt) override; private: const Sprite& BoxSprite; float Progress = 0.0f; + float SliderSpeed = 1.0f; }; } // namespace CCLCC From 7540247ad9e51f5d7a7abdaacb59fd52fef28125 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Wed, 13 Nov 2024 01:01:09 +0100 Subject: [PATCH 11/34] Added character voice page --- CMakeLists.txt | 2 + profiles/cclcc/hud/optionsmenu.lua | 4 +- src/games/cclcc/optionsmenu.cpp | 46 ++++++++++++++++++-- src/ui/widgets/cclcc/optionsslider.h | 2 +- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 48 +++++++++++++++++++++ src/ui/widgets/cclcc/optionsvoiceslider.h | 29 +++++++++++++ 6 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 src/ui/widgets/cclcc/optionsvoiceslider.cpp create mode 100644 src/ui/widgets/cclcc/optionsvoiceslider.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d01f8392..61bb515d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,6 +247,7 @@ set(Impacto_Src src/ui/widgets/cclcc/optionsentry.cpp src/ui/widgets/cclcc/optionsbinarybutton.cpp src/ui/widgets/cclcc/optionsslider.cpp + src/ui/widgets/cclcc/optionsvoiceslider.cpp src/ui/widgets/cclcc/saveentrybutton.cpp src/ui/widgets/cclcc/sysmenubutton.cpp src/ui/widgets/cclcc/tipsentrybutton.cpp @@ -562,6 +563,7 @@ set(Impacto_Header src/ui/widgets/cclcc/optionsentry.h src/ui/widgets/cclcc/optionsbinarybutton.h src/ui/widgets/cclcc/optionsslider.h + src/ui/widgets/cclcc/optionsvoiceslider.h src/renderer/3d/camera.h src/renderer/3d/model.h diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 884e949c..0987145b 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -26,7 +26,7 @@ root.OptionsMenu = { SliderTrackSprite = "OptionsSliderTrack", SliderTrackOffset = { X = 664, Y = 2 }, VoiceSliderTrackSprite = "OptionsVoiceSliderTrack", - VoiceSliderOffset = { X = 111, Y = 56 }, + VoiceSliderOffset = { X = 110, Y = 55 }, BinaryBoxSprite = "OptionsBinaryBox", BinaryBoxOffset = { X = 812, Y = 2 }, SliderSpeed = 1.0, @@ -207,7 +207,7 @@ for i = 0, 25 do root.Sprites["OptionsPortrait" .. i] = { Sheet = "ConfigEx", Bounds = { - X = 768 + (width + 1) * i, + X = 768 + (width + 1) * (i // 2), Y = ((i % 2 == 0) and {2256} or {2357})[1], Width = width, Height = width diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 823f55ae..3fde5d48 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -6,6 +6,7 @@ #include "../../vm/interface/input.h" #include "../../ui/widgets/cclcc/optionsbinarybutton.h" #include "../../ui/widgets/cclcc/optionsslider.h" +#include "../../ui/widgets/cclcc/optionsvoiceslider.h" namespace Impacto { namespace UI { @@ -70,12 +71,47 @@ OptionsMenu::OptionsMenu() { Pages.push_back(SoundPage); VoicePage = new Group(this); - for (int i = 0; i < 12; i++) { + constexpr int columns = 3; + constexpr int entries = 12; + for (int i = 0; i < entries; i++) { glm::vec2 pos = VoicePosition; - pos += VoiceEntriesOffset * glm::vec2(i % 3, i / 3); + pos += VoiceEntriesOffset * glm::vec2(i % columns, i / columns); - VoicePage->Add(new Label(NametagSprites[i], pos), FDIR_RIGHT); + Widget* widget = new OptionsVoiceSlider( + VoiceSliderTrackSprite, NametagSprites[i], PortraitSprites[2 * i], + PortraitSprites[2 * i + 1], pos, highlightTint, SliderSpeed); + VoicePage->Add(widget, FDIR_RIGHT); } + + // Loop separately to overwrite the direction set at initial adding + // First entry won't set anything; skip + for (int i = 1; i < entries; i++) { + Widget* const widget = VoicePage->Children.at(i); + + if (i % columns != 0) { // Not on first column + Widget* const leftWidget = VoicePage->Children.at(i - 1); + widget->SetFocus(leftWidget, FDIR_LEFT); + leftWidget->SetFocus(widget, FDIR_RIGHT); + + if (i % columns == columns - 1) { // On last column + Widget* const rowStart = VoicePage->Children.at(i - columns + 1); + widget->SetFocus(rowStart, FDIR_RIGHT); + rowStart->SetFocus(widget, FDIR_LEFT); + } + } + if (i >= columns) { // Not on first row + Widget* const upWidget = VoicePage->Children.at(i - columns); + widget->SetFocus(upWidget, FDIR_UP); + upWidget->SetFocus(widget, FDIR_DOWN); + + if (i >= entries - columns) { // On last layer + Widget* const columnStart = VoicePage->Children.at(i % columns); + widget->SetFocus(columnStart, FDIR_DOWN); + columnStart->SetFocus(widget, FDIR_UP); + } + } + } + Pages.push_back(VoicePage); CurrentPage = 0; @@ -163,7 +199,9 @@ void OptionsMenu::Render() { Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); - Renderer->DrawSprite(GuideSprite, GuidePosition, col); + const Sprite& guideSprite = + CurrentPage == 3 ? VoiceGuideSprite : GuideSprite; + Renderer->DrawSprite(guideSprite, GuidePosition, col); } } diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 9333d216..627734fb 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -16,7 +16,7 @@ class OptionsSlider : public OptionsEntry { void Render() override; void Update(float dt) override; - private: + protected: const Sprite& BoxSprite; float Progress = 0.0f; diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp new file mode 100644 index 00000000..a7c75f18 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -0,0 +1,48 @@ +#include "optionsvoiceslider.h" + +#include "../../../profile/games/cclcc/optionsmenu.h" +#include "../../../renderer/renderer.h" +#include "../../../vm/interface/input.h" + +using namespace Impacto::Profile::CCLCC::OptionsMenu; +using namespace Impacto::Vm::Interface; + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +OptionsVoiceSlider::OptionsVoiceSlider(const Sprite& box, const Sprite& label, + const Sprite& portrait, + const Sprite& mutedPortrait, + glm::vec2 pos, glm::vec4 highlightTint, + float sliderSpeed) + : OptionsSlider(box, label, pos, highlightTint, sliderSpeed), + Portrait(portrait), + MutedPortrait(mutedPortrait) {} + +void OptionsVoiceSlider::Render() { + HighlightTint.a = Tint.a; + + Renderer->DrawSprite(Muted ? MutedPortrait : Portrait, Bounds.GetPos(), Tint); + Renderer->DrawSprite(LabelSprite, Bounds.GetPos() + NametagOffset, + Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); + + RectF highlightBounds( + Bounds.X + VoiceSliderOffset.x, Bounds.Y + VoiceSliderOffset.y, + Progress * BoxSprite.ScaledWidth(), BoxSprite.ScaledHeight()); + Renderer->DrawRect(highlightBounds, HighlightTint); + Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + VoiceSliderOffset, Tint); +} + +void OptionsVoiceSlider::UpdateInput() { + OptionsEntry::UpdateInput(); + if (!Selected) return; + + Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); +} + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.h b/src/ui/widgets/cclcc/optionsvoiceslider.h new file mode 100644 index 00000000..a49543c4 --- /dev/null +++ b/src/ui/widgets/cclcc/optionsvoiceslider.h @@ -0,0 +1,29 @@ +#pragma once + +#include "./optionsslider.h" +#include "../../../spritesheet.h" + +namespace Impacto { +namespace UI { +namespace Widgets { +namespace CCLCC { + +class OptionsVoiceSlider : public OptionsSlider { + public: + OptionsVoiceSlider(const Sprite& box, const Sprite& label, + const Sprite& portrait, const Sprite& mutedPortrait, + glm::vec2 pos, glm::vec4 highlightTint, float sliderSpeed); + void Render() override; + void UpdateInput() override; + + private: + const Sprite& Portrait; + const Sprite& MutedPortrait; + + bool Muted = false; +}; + +} // namespace CCLCC +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file From 8a506db8bc9fa5a987d28c49dbb939fe85ba8a16 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Wed, 13 Nov 2024 23:38:50 +0100 Subject: [PATCH 12/34] Added highlight boxes --- profiles/cclcc/hud/optionsmenu.lua | 22 +++++++++++-------- src/profile/games/cclcc/optionsmenu.cpp | 4 ++++ src/profile/games/cclcc/optionsmenu.h | 4 ++++ src/ui/widgets/cclcc/optionsentry.cpp | 21 +++++++++++------- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 11 +++++++++- src/util.h | 24 +++++++++++++++++++++ 6 files changed, 68 insertions(+), 18 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 0987145b..edd28275 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -11,7 +11,7 @@ root.OptionsMenu = { BackgroundPosition = { X = 179, Y = 0 }, PointerSprite = "OptionsPointer", - PointerOffset = { X = -89, Y = 5 }, + PointerOffset = { X = 13, Y = 2 }, HeaderSprite = "OptionsHeader", HeaderPosition = { X = 10, Y = 10 }, @@ -24,11 +24,11 @@ root.OptionsMenu = { PoleAnimation = "OptionsPoleAnimation", SliderTrackSprite = "OptionsSliderTrack", - SliderTrackOffset = { X = 664, Y = 2 }, + SliderTrackOffset = { X = 766, Y = 0 }, VoiceSliderTrackSprite = "OptionsVoiceSliderTrack", - VoiceSliderOffset = { X = 110, Y = 55 }, + VoiceSliderOffset = { X = 114, Y = 57 }, BinaryBoxSprite = "OptionsBinaryBox", - BinaryBoxOffset = { X = 812, Y = 2 }, + BinaryBoxOffset = { X = 914, Y = 0 }, SliderSpeed = 1.0, SkipReadSprite = "OptionsSkipRead", @@ -42,17 +42,21 @@ root.OptionsMenu = { VoiceGuideSprite = "OptionsVoiceGuide", GuidePosition = { X = 0, Y = 986 }, - EntriesStartPosition = { X = 521, Y = 311 }, + EntriesStartPosition = { X = 419, Y = 313 }, EntriesVerticalOffset = 126, - SoundEntriesStartPosition = { X = 521, Y = 331 }, + SoundEntriesStartPosition = { X = 419, Y = 333 }, SoundEntriesVerticalOffset = 70, VoiceEntriesOffset = { X = 408, Y = 160 }, + EntryDimensions = { X = 1212, Y = 50 }, + VoiceEntryDimensions = { X = 374, Y = 104 }, LabelSprites = {}, + LabelOffset = { X = 102, Y = -2 }, NametagSprites = {}, - NametagOffset = { X = 112, Y = 2 }, + NametagOffset = { X = 116, Y = 4 }, PortraitSprites = {}, - VoicePosition = { X = 458, Y = 312 }, + PortraitOffset = { X = 3, Y = 2 }, + VoicePosition = { X = 454, Y = 310 }, }; root.Sprites["OptionsBackground"] = { @@ -77,7 +81,7 @@ root.Sprites["OptionsBinaryBox"] = { root.Sprites["OptionsPointer"] = { Sheet = "Config", - Bounds = { X = 697, Y = 1241, Width = 71, Height = 43 } + Bounds = { X = 697, Y = 1241, Width = 71, Height = 45 } }; root.Sprites["OptionsHeader"] = { diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 93b2f671..e5897fa6 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -56,11 +56,15 @@ void Configure() { SoundEntriesStartPosition = EnsureGetMemberVec2("SoundEntriesStartPosition"); SoundEntriesVerticalOffset = EnsureGetMemberInt("SoundEntriesVerticalOffset"); VoiceEntriesOffset = EnsureGetMemberVec2("VoiceEntriesOffset"); + EntryDimensions = EnsureGetMemberVec2("EntryDimensions"); + VoiceEntryDimensions = EnsureGetMemberVec2("VoiceEntryDimensions"); GetMemberSpriteArray(LabelSprites, LabelSpriteCount, "LabelSprites"); + LabelOffset = EnsureGetMemberVec2("LabelOffset"); GetMemberSpriteArray(NametagSprites, NametagSpriteCount, "NametagSprites"); NametagOffset = EnsureGetMemberVec2("NametagOffset"); GetMemberSpriteArray(PortraitSprites, PortraitSpriteCount, "PortraitSprites"); + PortraitOffset = EnsureGetMemberVec2("PortraitOffset"); VoicePosition = EnsureGetMemberVec2("VoicePosition"); auto drawType = Game::DrawComponentType::_from_integral_unchecked( diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 0b0d72fa..526c67b6 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -55,11 +55,15 @@ inline int EntriesVerticalOffset; inline glm::vec2 SoundEntriesStartPosition; inline int SoundEntriesVerticalOffset; inline glm::vec2 VoiceEntriesOffset; +inline glm::vec2 EntryDimensions; +inline glm::vec2 VoiceEntryDimensions; inline Sprite LabelSprites[LabelSpriteCount]; +inline glm::vec2 LabelOffset; inline Sprite NametagSprites[NametagSpriteCount]; inline glm::vec2 NametagOffset; inline Sprite PortraitSprites[PortraitSpriteCount]; +inline glm::vec2 PortraitOffset; inline glm::vec2 VoicePosition; void Configure(); diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 6af02213..338f271e 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -22,20 +22,25 @@ OptionsEntry::OptionsEntry(const Sprite& label, glm::vec2 pos, void OptionsEntry::Render() { HighlightTint.a = Tint.a; - Renderer->DrawSprite(LabelSprite, Bounds.GetPos(), - Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); - if (HasFocus) + if (HasFocus) { + RectF highlightBoundBox(Bounds.X, Bounds.Y, EntryDimensions.x, + EntryDimensions.y); + Renderer->DrawRect(highlightBoundBox, HighlightTint); + Renderer->DrawRect(highlightBoundBox + RectF(2.0f, 2.0f, -4.0f, -4.0f), + glm::vec4(1.0f, 1.0f, 1.0f, Tint.a)); + Renderer->DrawSprite(PointerSprite, Bounds.GetPos() + PointerOffset, Tint); + } + + Renderer->DrawSprite(LabelSprite, Bounds.GetPos() + LabelOffset, + Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); } void OptionsEntry::UpdateInput() { if (!HasFocus) return; - if (PADinputButtonWentDown & PAD1A) { - Selected = true; - } else if (PADinputButtonWentDown & PAD1B) { - Selected = false; - } + Selected ^= (bool)(PADinputButtonWentDown & PAD1A); + if (PADinputButtonWentDown & PAD1B) Selected = false; } void OptionsEntry::Hide() { Selected = false; } diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index a7c75f18..efd3cbf5 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -24,7 +24,16 @@ OptionsVoiceSlider::OptionsVoiceSlider(const Sprite& box, const Sprite& label, void OptionsVoiceSlider::Render() { HighlightTint.a = Tint.a; - Renderer->DrawSprite(Muted ? MutedPortrait : Portrait, Bounds.GetPos(), Tint); + if (HasFocus) { + RectF highlightBoundBox(Bounds.X, Bounds.Y, VoiceEntryDimensions.x, + VoiceEntryDimensions.y); + Renderer->DrawRect(highlightBoundBox, HighlightTint); + Renderer->DrawRect(highlightBoundBox + RectF(2.0f, 2.0f, -4.0f, -4.0f), + glm::vec4(1.0f, 1.0f, 1.0f, Tint.a)); + } + + Renderer->DrawSprite(Muted ? MutedPortrait : Portrait, + Bounds.GetPos() + PortraitOffset, Tint); Renderer->DrawSprite(LabelSprite, Bounds.GetPos() + NametagOffset, Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); diff --git a/src/util.h b/src/util.h index 4bc53701..0d1f4c5f 100644 --- a/src/util.h +++ b/src/util.h @@ -72,6 +72,30 @@ struct RectF { rect.Y + rect.Height <= Y + Height); } + constexpr RectF operator+(RectF const& other) const { + return RectF(X + other.X, Y + other.Y, Width + other.Width, + Height + other.Height); + } + + constexpr RectF operator-(RectF const& other) const { + return RectF(X - other.X, Y - other.Y, Width - other.Width, + Height - other.Height); + } + + constexpr void operator+=(RectF const& other) { + X += other.X; + Y += other.Y; + Width += other.Width; + Height += other.Height; + } + + constexpr void operator-=(RectF const& other) { + X -= other.X; + Y -= other.Y; + Width -= other.Width; + Height -= other.Height; + } + constexpr bool operator==(RectF const& other) const { return X == other.X && Y == other.Y && Width == other.Width && Height == other.Height; From 76813ac3a52b1bc69375fe2c9bc04d0f4e3dd251 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 16 Nov 2024 23:03:52 +0100 Subject: [PATCH 13/34] Allow for muting characters on hover --- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index efd3cbf5..f8d2ea67 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -46,9 +46,8 @@ void OptionsVoiceSlider::Render() { void OptionsVoiceSlider::UpdateInput() { OptionsEntry::UpdateInput(); - if (!Selected) return; - Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); + if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); } } // namespace CCLCC From 7c204a29bfd66ba00ab641950313b18337d63c36 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 16 Nov 2024 23:33:53 +0100 Subject: [PATCH 14/34] Added page indicator lights --- profiles/cclcc/hud/optionsmenu.lua | 5 +++++ src/games/cclcc/optionsmenu.cpp | 5 +++++ src/profile/games/cclcc/optionsmenu.cpp | 6 ++++++ src/profile/games/cclcc/optionsmenu.h | 1 + 4 files changed, 17 insertions(+) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index edd28275..6b7a7df2 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -22,6 +22,11 @@ root.OptionsMenu = { PagePanelPosition = { X = -114, Y = 0 }, PagePanelSprites = {}, PoleAnimation = "OptionsPoleAnimation", + -- TODO: Replace this once array fetching is implemented + PagePanelIconOffsets0 = { X = 259, Y = 73 }, + PagePanelIconOffsets1 = { X = 235, Y = 333 }, + PagePanelIconOffsets2 = { X = 261, Y = 585 }, + PagePanelIconOffsets3 = { X = 238, Y = 831 }, SliderTrackSprite = "OptionsSliderTrack", SliderTrackOffset = { X = 766, Y = 0 }, diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 3fde5d48..28b82620 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -198,6 +198,11 @@ void OptionsMenu::Render() { Pages.at(CurrentPage)->Render(); Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); + if (PoleAnimation.IsIn()) { + Renderer->DrawSprite( + PagePanelSprites[2 * CurrentPage + !(bool)CurrentlyFocusedElement], + PagePanelPosition + PagePanelIconOffsets[CurrentPage], col); + } const Sprite& guideSprite = CurrentPage == 3 ? VoiceGuideSprite : GuideSprite; diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index e5897fa6..1eb55419 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -32,6 +32,12 @@ void Configure() { "PagePanelSprites"); PoleAnimation = EnsureGetMemberAnimation("PoleAnimation"); + // TODO: Replace this once array fetching is implemented + for (int i = 0; i < PagePanelSpriteCount / 2; i++) { + PagePanelIconOffsets[i] = EnsureGetMemberVec2( + ("PagePanelIconOffsets" + std::to_string(i)).c_str()); + } + SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); SliderTrackOffset = EnsureGetMemberVec2("SliderTrackOffset"); VoiceSliderTrackSprite = EnsureGetMemberSprite("VoiceSliderTrackSprite"); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 526c67b6..6a9b692b 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -29,6 +29,7 @@ inline glm::vec2 PageHeaderPosition; inline Sprite PagePanelSprite; inline glm::vec2 PagePanelPosition; inline Sprite PagePanelSprites[PagePanelSpriteCount]; +inline glm::vec2 PagePanelIconOffsets[PagePanelSpriteCount]; inline SpriteAnimationDef PoleAnimation; inline Sprite SliderTrackSprite; From c77d66d61321471ec8167f9634ad68fc074be8d0 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 17 Dec 2024 20:21:32 +0100 Subject: [PATCH 15/34] Fixed options entry highlighting and selecting behaviour --- src/games/cclcc/optionsmenu.cpp | 46 ++++++++++++++++----------- src/games/cclcc/optionsmenu.h | 3 ++ src/ui/widgets/cclcc/optionsentry.cpp | 5 ++- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 28b82620..a6058ab6 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -131,9 +131,6 @@ void OptionsMenu::Show() { } IsFocused = true; UI::FocusedMenu = this; - - CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); - CurrentlyFocusedElement->HasFocus = true; } } @@ -166,23 +163,40 @@ void OptionsMenu::Update(float dt) { ScrWork[SW_SYSSUBMENUNO] == 5) { Show(); } - - int newPageOffset = -(int)(bool)(PADinputButtonWentDown & PAD1L1) + - (int)(bool)(PADinputButtonWentDown & PAD1R1); - GoToPage((CurrentPage + newPageOffset) % Pages.size()); } void OptionsMenu::UpdateInput() { - bool nothingSelected = - CurrentlyFocusedElement == nullptr || - !static_cast(CurrentlyFocusedElement)->Selected; - if (nothingSelected && GetControlState(CT_Back)) { - SetFlag(SF_SUBMENUEXIT, true); + if (CurrentlyFocusedElement == nullptr) { + if (GetControlState(CT_Back)) { + SetFlag(SF_SUBMENUEXIT, true); + return; + } + + const int direction = (bool)(PADinputButtonWentDown & PAD1DOWN) - + (bool)(PADinputButtonWentDown & PAD1UP); + if (direction) GoToPage((CurrentPage + direction) % Pages.size()); + + if (PADinputButtonWentDown & PAD1A) { + // Don't have anything else consume the confirmation + PADinputButtonWentDown &= ~PAD1A; + + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; + } + + return; + } + + // If something is selected, the option entry takes full control + if (static_cast(CurrentlyFocusedElement)->Selected) return; + + if (GetControlState(CT_Back)) { + static_cast(CurrentlyFocusedElement)->Hide(); + CurrentlyFocusedElement = nullptr; return; } - // Only able to move up and down if nothing is selected - if (nothingSelected) Menu::UpdateInput(); + Menu::UpdateInput(); } void OptionsMenu::Render() { @@ -220,10 +234,6 @@ void OptionsMenu::GoToPage(int pageNumber) { page.HasFocus = true; page.Show(); - - if (CurrentlyFocusedElement) CurrentlyFocusedElement->Hide(); - CurrentlyFocusedElement = page.GetFirstFocusableChild(); - CurrentlyFocusedElement->HasFocus = true; } } // namespace CCLCC diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index 3022992a..58e2c06b 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -3,6 +3,9 @@ #include "../../ui/menu.h" #include "../../spriteanimation.h" #include "../../ui/widgets/group.h" +#include "../../ui/widgets/cclcc/optionsentry.h" + +using namespace Impacto::UI::Widgets::CCLCC; namespace Impacto { namespace UI { diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 338f271e..a4f79bbb 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -43,7 +43,10 @@ void OptionsEntry::UpdateInput() { if (PADinputButtonWentDown & PAD1B) Selected = false; } -void OptionsEntry::Hide() { Selected = false; } +void OptionsEntry::Hide() { + Widget::Hide(); + Selected = false; +} } // namespace CCLCC } // namespace Widgets From 47be24619594b75ca02a12d783f84226219be747 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Wed, 18 Dec 2024 02:28:53 +0100 Subject: [PATCH 16/34] Implemented mouse input for OptionsEntry --- CMakeLists.txt | 2 + src/games/cclcc/optionsmenu.cpp | 44 +++++++++++----- src/games/cclcc/optionsmenu.h | 1 + src/ui/widget.h | 2 +- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 54 ++++++++++++-------- src/ui/widgets/cclcc/optionsbinarybutton.h | 14 +++-- src/ui/widgets/cclcc/optionsentry.cpp | 17 ++++-- src/ui/widgets/cclcc/optionsentry.h | 10 +++- src/ui/widgets/cclcc/optionsslider.cpp | 6 ++- src/ui/widgets/cclcc/optionsslider.h | 3 +- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 17 +++--- src/ui/widgets/cclcc/optionsvoiceslider.h | 3 +- src/ui/widgets/clickbutton.cpp | 34 ++++++++++++ src/ui/widgets/clickbutton.h | 26 ++++++++++ 14 files changed, 178 insertions(+), 55 deletions(-) create mode 100644 src/ui/widgets/clickbutton.cpp create mode 100644 src/ui/widgets/clickbutton.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 61bb515d..d88a6e52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,6 +226,7 @@ set(Impacto_Src src/ui/widgets/group.cpp src/ui/widgets/carousel.cpp src/ui/widgets/cgviewer.cpp + src/ui/widgets/clickbutton.cpp src/ui/widgets/mo6tw/titlebutton.cpp src/ui/widgets/mo6tw/saveentrybutton.cpp src/ui/widgets/mo6tw/tipsentrybutton.cpp @@ -542,6 +543,7 @@ set(Impacto_Header src/ui/widgets/group.h src/ui/widgets/carousel.h src/ui/widgets/cgviewer.h + src/ui/widgets/clickbutton.h src/ui/widgets/mo6tw/titlebutton.h src/ui/widgets/mo6tw/saveentrybutton.h src/ui/widgets/mo6tw/tipsentrybutton.h diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index a6058ab6..87503188 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -30,12 +30,15 @@ OptionsMenu::OptionsMenu() { Pages.reserve(4); glm::vec2 pos = EntriesStartPosition; glm::vec4 highlightTint(HighlightColor, 1.0f); + std::function select = + std::bind(&OptionsMenu::Select, this, std::placeholders::_1); BasicPage = new Group(this); for (int i = 0; i < 4; i++) { - BasicPage->Add(new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, - LabelSprites[i], pos, highlightTint), - FDIR_DOWN); + BasicPage->Add( + new OptionsBinaryButton(BinaryBoxSprite, OnSprite, OffSprite, + LabelSprites[i], pos, highlightTint, select), + FDIR_DOWN); pos.y += EntriesVerticalOffset; } @@ -45,25 +48,27 @@ OptionsMenu::OptionsMenu() { TextPage = new Group(this); for (int i = 4; i < 6; i++) { TextPage->Add(new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos, - highlightTint, SliderSpeed), + highlightTint, SliderSpeed, select), FDIR_DOWN); pos.y += EntriesVerticalOffset; } - TextPage->Add(new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[6], pos, highlightTint), - FDIR_DOWN); + TextPage->Add( + new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + LabelSprites[6], pos, highlightTint, select), + FDIR_DOWN); Pages.push_back(TextPage); pos = SoundEntriesStartPosition; SoundPage = new Group(this); for (int i = 7; i < 15; i++) { - Widget* widget = (i < 11 || i == 14) - ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], - pos, highlightTint, SliderSpeed) - : widget = new OptionsBinaryButton( - BinaryBoxSprite, YesSprite, NoSprite, - LabelSprites[i], pos, highlightTint); + Widget* widget = + (i < 11 || i == 14) + ? new OptionsSlider(SliderTrackSprite, LabelSprites[i], pos, + highlightTint, SliderSpeed, select) + : widget = new OptionsBinaryButton(BinaryBoxSprite, YesSprite, + NoSprite, LabelSprites[i], pos, + highlightTint, select); SoundPage->Add(widget, FDIR_DOWN); pos.y += SoundEntriesVerticalOffset; @@ -79,7 +84,7 @@ OptionsMenu::OptionsMenu() { Widget* widget = new OptionsVoiceSlider( VoiceSliderTrackSprite, NametagSprites[i], PortraitSprites[2 * i], - PortraitSprites[2 * i + 1], pos, highlightTint, SliderSpeed); + PortraitSprites[2 * i + 1], pos, highlightTint, SliderSpeed, select); VoicePage->Add(widget, FDIR_RIGHT); } @@ -236,6 +241,17 @@ void OptionsMenu::GoToPage(int pageNumber) { page.Show(); } +void OptionsMenu::Select(OptionsEntry* toSelect) { + for (Widget* entry : Pages.at(CurrentPage)->Children) { + const bool select = entry == toSelect; + + static_cast(entry)->Selected = select; + entry->HasFocus = select; + } + + CurrentlyFocusedElement = toSelect; +} + } // namespace CCLCC } // namespace UI } // namespace Impacto \ No newline at end of file diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index 58e2c06b..df51a299 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -23,6 +23,7 @@ class OptionsMenu : public Menu { private: void GoToPage(int pageNumber); + void Select(OptionsEntry* entry); Animation FadeAnimation; SpriteAnimation PoleAnimation; diff --git a/src/ui/widget.h b/src/ui/widget.h index f08f4f25..e18ac8c0 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -24,7 +24,7 @@ class Widget { virtual void Update(float dt); virtual void UpdateInput() = 0; - virtual void Render() = 0; + virtual void Render() {} virtual void Show(); virtual void Hide(); diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index 9ca1a991..b7255136 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -3,6 +3,7 @@ #include "../../../profile/games/cclcc/optionsmenu.h" #include "../../../renderer/renderer.h" #include "../../../vm/interface/input.h" +#include "../../../inputsystem.h" using namespace Impacto::Profile::CCLCC::OptionsMenu; using namespace Impacto::Vm::Interface; @@ -12,25 +13,28 @@ namespace UI { namespace Widgets { namespace CCLCC { -OptionsBinaryButton::OptionsBinaryButton(const Sprite& box, - const Sprite& trueLabel, - const Sprite& falseLabel, - const Sprite& label, glm::vec2 pos, - glm::vec4 highlightTint) - : OptionsEntry(label, pos, highlightTint), +OptionsBinaryButton::OptionsBinaryButton( + const Sprite& box, const Sprite& trueLabel, const Sprite& falseLabel, + const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint, + std::function select) + : OptionsEntry(label, pos, highlightTint, select), BoxSprite(box), TrueSprite(trueLabel), FalseSprite(falseLabel) { Bounds.Width = BinaryBoxOffset.x + BoxSprite.ScaledWidth(); -} - -inline glm::vec2 OptionsBinaryButton::GetTruePos() const { - return Bounds.GetPos() + BinaryBoxOffset; -} + EntryButton.Bounds.Width = Bounds.Width; -inline glm::vec2 OptionsBinaryButton::GetFalsePos() const { - return Bounds.GetPos() + BinaryBoxOffset + - glm::vec2(BoxSprite.ScaledWidth() / 2, 0.0f); + glm::vec2 truePosition = pos + BinaryBoxOffset; + TrueButton = + ClickButton(0, + RectF(truePosition.x, truePosition.y, + TrueSprite.ScaledWidth(), TrueSprite.ScaledHeight()), + std::bind(&OptionsBinaryButton::TrueOnClick, this, + std::placeholders::_1)); + FalseButton = ClickButton( + 0, TrueButton.Bounds + RectF(box.ScaledWidth() / 2.0f, 0.0f, 0.0f, 0.0f), + std::bind(&OptionsBinaryButton::FalseOnClick, this, + std::placeholders::_1)); } void OptionsBinaryButton::Render() { @@ -38,27 +42,37 @@ void OptionsBinaryButton::Render() { RectF highlightBounds(0.0f, 0.0f, BoxSprite.ScaledWidth() / 2, BoxSprite.ScaledHeight()); - glm::vec2 highlightPos = (State) ? GetTruePos() : GetFalsePos(); + glm::vec2 highlightPos = ((State) ? TrueButton : FalseButton).Bounds.GetPos(); highlightBounds.X = highlightPos.x; highlightBounds.Y = highlightPos.y; Renderer->DrawRect(highlightBounds, HighlightTint); - Renderer->DrawSprite(BoxSprite, GetTruePos(), Tint); + Renderer->DrawSprite(BoxSprite, TrueButton.Bounds.GetPos(), Tint); - Renderer->DrawSprite(TrueSprite, GetTruePos(), Tint, glm::vec2(1.0f), 0.0f, - !State); - Renderer->DrawSprite(FalseSprite, GetFalsePos(), Tint, glm::vec2(1.0f), 0.0f, - State); + Renderer->DrawSprite(TrueSprite, TrueButton.Bounds.GetPos(), Tint, + glm::vec2(1.0f), 0.0f, !State); + Renderer->DrawSprite(FalseSprite, FalseButton.Bounds.GetPos(), Tint, + glm::vec2(1.0f), 0.0f, State); } void OptionsBinaryButton::UpdateInput() { OptionsEntry::UpdateInput(); + + // Handle mouse/touch input + TrueButton.UpdateInput(); + FalseButton.UpdateInput(); + if (!Selected) return; + // Handle keyboard/controller input if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) State = PADinputButtonWentDown & PAD1LEFT; } +void OptionsBinaryButton::TrueOnClick(ClickButton* target) { State = true; } + +void OptionsBinaryButton::FalseOnClick(ClickButton* target) { State = false; } + } // namespace CCLCC } // namespace Widgets } // namespace UI diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h index 1460acd2..4751e637 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.h +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -1,6 +1,7 @@ #pragma once #include "./optionsentry.h" +#include "../clickbutton.h" #include "../../../spritesheet.h" namespace Impacto { @@ -12,19 +13,24 @@ class OptionsBinaryButton : public OptionsEntry { public: OptionsBinaryButton(const Sprite& box, const Sprite& trueLabel, const Sprite& falseLabel, const Sprite& label, - glm::vec2 pos, glm::vec4 highlightTint); + glm::vec2 pos, glm::vec4 highlightTint, + std::function select); void Render() override; void UpdateInput() override; private: - inline glm::vec2 GetTruePos() const; - inline glm::vec2 GetFalsePos() const; + ClickButton TrueButton; + ClickButton FalseButton; - const Sprite& BoxSprite; const Sprite& TrueSprite; const Sprite& FalseSprite; + void TrueOnClick(ClickButton* target); + void FalseOnClick(ClickButton* target); + + const Sprite& BoxSprite; + bool State = true; }; diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index a4f79bbb..3db76e52 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -13,10 +13,15 @@ namespace Widgets { namespace CCLCC { OptionsEntry::OptionsEntry(const Sprite& label, glm::vec2 pos, - glm::vec4 highlightTint) - : LabelSprite(label), HighlightTint(highlightTint) { - Bounds = RectF(pos.x, pos.y, LabelSprite.ScaledWidth(), - LabelSprite.ScaledHeight()); + glm::vec4 highlightTint, + std::function select) + : LabelSprite(label), HighlightTint(highlightTint), Select(select) { + Bounds = RectF(pos.x, pos.y, LabelOffset.x + LabelSprite.ScaledWidth(), + LabelOffset.y + LabelSprite.ScaledHeight()); + + std::function onClick = + std::bind(&OptionsEntry::EntryButtonOnClick, this, std::placeholders::_1); + EntryButton = ClickButton(0, Bounds, onClick); } void OptionsEntry::Render() { @@ -37,6 +42,8 @@ void OptionsEntry::Render() { } void OptionsEntry::UpdateInput() { + EntryButton.UpdateInput(); + if (!HasFocus) return; Selected ^= (bool)(PADinputButtonWentDown & PAD1A); @@ -48,6 +55,8 @@ void OptionsEntry::Hide() { Selected = false; } +void OptionsEntry::EntryButtonOnClick(ClickButton* target) { Select(this); } + } // namespace CCLCC } // namespace Widgets } // namespace UI diff --git a/src/ui/widgets/cclcc/optionsentry.h b/src/ui/widgets/cclcc/optionsentry.h index 018c1610..8221b5a2 100644 --- a/src/ui/widgets/cclcc/optionsentry.h +++ b/src/ui/widgets/cclcc/optionsentry.h @@ -1,5 +1,8 @@ #pragma once +#include + +#include "../clickbutton.h" #include "../../widget.h" #include "../../../spritesheet.h" @@ -10,7 +13,8 @@ namespace CCLCC { class OptionsEntry : public Widget { public: - OptionsEntry(const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint); + OptionsEntry(const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint, + std::function select); void Render() override; void UpdateInput() override; @@ -19,6 +23,10 @@ class OptionsEntry : public Widget { bool Selected = false; protected: + ClickButton EntryButton; + std::function Select; + void EntryButtonOnClick(ClickButton* target); + const Sprite& LabelSprite; glm::vec4 HighlightTint; }; diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index 1c15b546..5cf58e22 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -14,11 +14,13 @@ namespace CCLCC { OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint, - float sliderSpeed) - : OptionsEntry(label, pos, highlightTint), + float sliderSpeed, + std::function select) + : OptionsEntry(label, pos, highlightTint, select), BoxSprite(box), SliderSpeed(sliderSpeed) { Bounds.Width = SliderTrackOffset.x + BoxSprite.ScaledWidth(); + EntryButton.Bounds.Width = Bounds.Width; } void OptionsSlider::Render() { diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 627734fb..676aac48 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -11,7 +11,8 @@ namespace CCLCC { class OptionsSlider : public OptionsEntry { public: OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, - glm::vec4 highlightTint, float sliderSpeed); + glm::vec4 highlightTint, float sliderSpeed, + std::function select); void Render() override; void Update(float dt) override; diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index f8d2ea67..a9e34968 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -12,14 +12,17 @@ namespace UI { namespace Widgets { namespace CCLCC { -OptionsVoiceSlider::OptionsVoiceSlider(const Sprite& box, const Sprite& label, - const Sprite& portrait, - const Sprite& mutedPortrait, - glm::vec2 pos, glm::vec4 highlightTint, - float sliderSpeed) - : OptionsSlider(box, label, pos, highlightTint, sliderSpeed), +OptionsVoiceSlider::OptionsVoiceSlider( + const Sprite& box, const Sprite& label, const Sprite& portrait, + const Sprite& mutedPortrait, glm::vec2 pos, glm::vec4 highlightTint, + float sliderSpeed, std::function select) + : OptionsSlider(box, label, pos, highlightTint, sliderSpeed, select), Portrait(portrait), - MutedPortrait(mutedPortrait) {} + MutedPortrait(mutedPortrait) { + Bounds = + RectF(Bounds.X, Bounds.Y, VoiceEntryDimensions.x, VoiceEntryDimensions.y); + EntryButton.Bounds = Bounds; +} void OptionsVoiceSlider::Render() { HighlightTint.a = Tint.a; diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.h b/src/ui/widgets/cclcc/optionsvoiceslider.h index a49543c4..123e718c 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.h +++ b/src/ui/widgets/cclcc/optionsvoiceslider.h @@ -12,7 +12,8 @@ class OptionsVoiceSlider : public OptionsSlider { public: OptionsVoiceSlider(const Sprite& box, const Sprite& label, const Sprite& portrait, const Sprite& mutedPortrait, - glm::vec2 pos, glm::vec4 highlightTint, float sliderSpeed); + glm::vec2 pos, glm::vec4 highlightTint, float sliderSpeed, + std::function select); void Render() override; void UpdateInput() override; diff --git a/src/ui/widgets/clickbutton.cpp b/src/ui/widgets/clickbutton.cpp new file mode 100644 index 00000000..31759d1d --- /dev/null +++ b/src/ui/widgets/clickbutton.cpp @@ -0,0 +1,34 @@ +#include "clickbutton.h" + +#include "../../inputsystem.h" +#include "../../vm/interface/input.h" + +namespace Impacto { +namespace UI { +namespace Widgets { + +ClickButton::ClickButton(int id, RectF bounds, + std::function onClickHandler) + : Id(id), OnClickHandler(onClickHandler) { + Bounds = bounds; +} + +void ClickButton::UpdateInput() { + if (!Enabled) return; + + if (Input::CurrentInputDevice == Input::Device::Mouse && + Input::PrevMousePos != Input::CurMousePos) { + Hovered = Bounds.ContainsPoint(Input::CurMousePos); + } else if (Input::CurrentInputDevice == Input::Device::Touch && + Input::TouchIsDown[0] && + Input::PrevTouchPos != Input::CurTouchPos) { + Hovered = Bounds.ContainsPoint(Input::CurTouchPos); + } + + if (Hovered && Vm::Interface::PADinputMouseWentDown & Vm::Interface::PAD1A) + OnClickHandler(this); +} + +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/clickbutton.h b/src/ui/widgets/clickbutton.h new file mode 100644 index 00000000..0d6a27c6 --- /dev/null +++ b/src/ui/widgets/clickbutton.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include "../widget.h" + +namespace Impacto { +namespace UI { +namespace Widgets { + +class ClickButton : public Widget { + public: + ClickButton() {} + ClickButton(int id, RectF bounds, + std::function onClickHandler); + + virtual void UpdateInput() override; + + int Id; + + std::function OnClickHandler; +}; + +} // namespace Widgets +} // namespace UI +} // namespace Impacto \ No newline at end of file From 28287056c9f328d81c14f9e53d3b1ac714e3743b Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 19 Dec 2024 00:29:59 +0100 Subject: [PATCH 17/34] Implemented mouse input for OptionsSlider --- src/ui/widgets/cclcc/optionsslider.cpp | 25 ++++++++++++++------- src/ui/widgets/cclcc/optionsslider.h | 9 ++++++-- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 8 +++++-- src/ui/widgets/scrollbar.cpp | 17 ++++++++++++++ src/ui/widgets/scrollbar.h | 2 ++ 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index 5cf58e22..02a4c8a1 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -18,11 +18,22 @@ OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, std::function select) : OptionsEntry(label, pos, highlightTint, select), BoxSprite(box), - SliderSpeed(sliderSpeed) { + Slider(0, pos + SliderTrackOffset, 0.0f, 1.0f, &Progress, + SBDIR_HORIZONTAL, + glm::vec2(BoxSprite.ScaledWidth(), BoxSprite.ScaledHeight())) { Bounds.Width = SliderTrackOffset.x + BoxSprite.ScaledWidth(); EntryButton.Bounds.Width = Bounds.Width; } +OptionsSlider::OptionsSlider(const Sprite& box, const Sprite& label, + glm::vec2 pos, glm::vec4 highlightTint, + RectF sliderBounds, float sliderSpeed, + std::function select) + : OptionsEntry(label, pos, highlightTint, select), + BoxSprite(box), + Slider(0, sliderBounds.GetPos(), 0.0f, 1.0f, &Progress, SBDIR_HORIZONTAL, + sliderBounds.GetSize()) {} + void OptionsSlider::Render() { OptionsEntry::Render(); @@ -34,14 +45,12 @@ void OptionsSlider::Render() { Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); } -void OptionsSlider::Update(float dt) { - OptionsEntry::Update(dt); - if (!Selected) return; +void OptionsSlider::UpdateInput() { + OptionsEntry::UpdateInput(); - int slideDirection = (bool)(PADinputButtonIsDown & PAD1RIGHT) - - (bool)(PADinputButtonIsDown & PAD1LEFT); - Progress = - std::clamp(Progress + slideDirection * SliderSpeed * dt, 0.0f, 1.0f); + Slider.HasFocus = Selected; + Slider.UpdateInput(); + Slider.ClampValue(); } } // namespace CCLCC diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 676aac48..66335c0c 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -1,6 +1,7 @@ #pragma once #include "./optionsentry.h" +#include "../scrollbar.h" #include "../../../spritesheet.h" namespace Impacto { @@ -15,13 +16,17 @@ class OptionsSlider : public OptionsEntry { std::function select); void Render() override; - void Update(float dt) override; + void UpdateInput() override; protected: + OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, + glm::vec4 highlightTint, RectF sliderBounds, float sliderSpeed, + std::function select); + const Sprite& BoxSprite; + Scrollbar Slider; float Progress = 0.0f; - float SliderSpeed = 1.0f; }; } // namespace CCLCC diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index a9e34968..5ded91e7 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -16,7 +16,11 @@ OptionsVoiceSlider::OptionsVoiceSlider( const Sprite& box, const Sprite& label, const Sprite& portrait, const Sprite& mutedPortrait, glm::vec2 pos, glm::vec4 highlightTint, float sliderSpeed, std::function select) - : OptionsSlider(box, label, pos, highlightTint, sliderSpeed, select), + : OptionsSlider( + box, label, pos, highlightTint, + RectF(pos.x + VoiceSliderOffset.x, pos.y + VoiceSliderOffset.y, + box.ScaledWidth(), box.ScaledHeight()), + sliderSpeed, select), Portrait(portrait), MutedPortrait(mutedPortrait) { Bounds = @@ -48,7 +52,7 @@ void OptionsVoiceSlider::Render() { } void OptionsVoiceSlider::UpdateInput() { - OptionsEntry::UpdateInput(); + OptionsSlider::UpdateInput(); if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); } diff --git a/src/ui/widgets/scrollbar.cpp b/src/ui/widgets/scrollbar.cpp index 87fa0963..0be7c835 100644 --- a/src/ui/widgets/scrollbar.cpp +++ b/src/ui/widgets/scrollbar.cpp @@ -10,6 +10,23 @@ namespace Widgets { using namespace Impacto::Profile::ScriptVars; using namespace Impacto::Vm::Interface; +Scrollbar::Scrollbar(int id, glm::vec2 pos, float start, float end, + float* value, ScrollbarDirection dir, + glm::vec2 trackBounds) + : Id(id), + StartValue(start), + EndValue(end), + Value(value), + Direction(dir), + TrackBounds(pos.x, pos.y, trackBounds.x, trackBounds.y), + Step((end - start) * 0.01f), + Length(dir == SBDIR_VERTICAL ? trackBounds.y : trackBounds.x), + ThumbBounds(0.0f, 0.0f, 0.0f, 0.0f), + ThumbLength(0.0f), + HasTrack(false) { + UpdatePosition(); +} + Scrollbar::Scrollbar(int id, glm::vec2 pos, float start, float end, float* value, ScrollbarDirection dir, Sprite const& thumb, glm::vec2 trackBounds, float thumbLength) diff --git a/src/ui/widgets/scrollbar.h b/src/ui/widgets/scrollbar.h index 70317bec..9a9919c9 100644 --- a/src/ui/widgets/scrollbar.h +++ b/src/ui/widgets/scrollbar.h @@ -11,6 +11,8 @@ enum ScrollbarDirection { SBDIR_VERTICAL, SBDIR_HORIZONTAL }; class Scrollbar : public Widget { public: + Scrollbar(int id, glm::vec2 pos, float start, float end, float* value, + ScrollbarDirection dir, glm::vec2 trackBounds); Scrollbar(int id, glm::vec2 pos, float start, float end, float* value, ScrollbarDirection dir, Sprite const& thumb, glm::vec2 trackBounds, float thumbLength); From a00e1643b95b59743e6f28aab20139319da2afa4 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 19 Dec 2024 00:34:53 +0100 Subject: [PATCH 18/34] Fixed scrollbar so it no longer scrolls when hovering after clicking --- src/ui/widgets/scrollbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/widgets/scrollbar.cpp b/src/ui/widgets/scrollbar.cpp index 0be7c835..5bbdd03b 100644 --- a/src/ui/widgets/scrollbar.cpp +++ b/src/ui/widgets/scrollbar.cpp @@ -114,7 +114,7 @@ void Scrollbar::UpdateInput() { Hovered = TrackBounds.ContainsPoint(Input::CurMousePos) || ThumbBounds.ContainsPoint(Input::CurMousePos); } - if (Hovered && Input::MouseButtonIsDown[SDL_BUTTON_LEFT]) { + if (Hovered && Input::MouseButtonWentDown[SDL_BUTTON_LEFT]) { Scrolling = true; } if (Input::MouseButtonIsDown[SDL_BUTTON_LEFT] && Scrolling) { From 3febf796308e86ae5067905799b1948cb5e216ac Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Thu, 19 Dec 2024 00:40:23 +0100 Subject: [PATCH 19/34] Implemented backing out with right-mouse --- src/games/cclcc/optionsmenu.cpp | 2 +- src/ui/widgets/cclcc/optionsentry.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 87503188..1182a2ae 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -195,7 +195,7 @@ void OptionsMenu::UpdateInput() { // If something is selected, the option entry takes full control if (static_cast(CurrentlyFocusedElement)->Selected) return; - if (GetControlState(CT_Back)) { + if (GetControlState(CT_Back) || PADinputMouseWentDown & PAD1B) { static_cast(CurrentlyFocusedElement)->Hide(); CurrentlyFocusedElement = nullptr; return; diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 3db76e52..c8a5ee98 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -47,7 +47,8 @@ void OptionsEntry::UpdateInput() { if (!HasFocus) return; Selected ^= (bool)(PADinputButtonWentDown & PAD1A); - if (PADinputButtonWentDown & PAD1B) Selected = false; + if (PADinputButtonWentDown & PAD1B || PADinputMouseWentDown & PAD1B) + Selected = false; } void OptionsEntry::Hide() { From 18f4a29092984fd0415c028da3e7bae86529baee Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Tue, 24 Dec 2024 00:28:29 +0100 Subject: [PATCH 20/34] Implemented mouse input for options tabs --- profiles/cclcc/hud/optionsmenu.lua | 4 ++++ src/games/cclcc/optionsmenu.cpp | 30 +++++++++++++++++++++---- src/games/cclcc/optionsmenu.h | 5 ++++- src/profile/games/cclcc/optionsmenu.cpp | 13 ++++++----- src/profile/games/cclcc/optionsmenu.h | 19 ++++++++-------- 5 files changed, 51 insertions(+), 20 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 6b7a7df2..715c19b9 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -27,6 +27,10 @@ root.OptionsMenu = { PagePanelIconOffsets1 = { X = 235, Y = 333 }, PagePanelIconOffsets2 = { X = 261, Y = 585 }, PagePanelIconOffsets3 = { X = 238, Y = 831 }, + PagePanelHoverBounds0 = { X = 168, Y = 79, Width = 150, Height = 183 }, + PagePanelHoverBounds1 = { X = 147, Y = 343, Width = 154, Height = 177 }, + PagePanelHoverBounds2 = { X = 169, Y = 591, Width = 146, Height = 181 }, + PagePanelHoverBounds3 = { X = 149, Y = 837, Width = 150, Height = 179 }, SliderTrackSprite = "OptionsSliderTrack", SliderTrackOffset = { X = 766, Y = 0 }, diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 1182a2ae..fc2c997e 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -27,12 +27,20 @@ OptionsMenu::OptionsMenu() { PoleAnimation = Profile::CCLCC::OptionsMenu::PoleAnimation.Instantiate(); - Pages.reserve(4); + Pages.reserve(PageCount); glm::vec2 pos = EntriesStartPosition; glm::vec4 highlightTint(HighlightColor, 1.0f); std::function select = std::bind(&OptionsMenu::Select, this, std::placeholders::_1); + PageButtons.reserve(PageCount); + std::function pageButtonOnClick = + std::bind(&OptionsMenu::PageButtonOnClick, this, std::placeholders::_1); + for (int i = 0; i < PageCount; i++) { + PageButtons.push_back( + ClickButton(i, PagePanelHoverBounds[i], pageButtonOnClick)); + } + BasicPage = new Group(this); for (int i = 0; i < 4; i++) { BasicPage->Add( @@ -171,6 +179,8 @@ void OptionsMenu::Update(float dt) { } void OptionsMenu::UpdateInput() { + for (ClickButton& button : PageButtons) button.UpdateInput(); + if (CurrentlyFocusedElement == nullptr) { if (GetControlState(CT_Back)) { SetFlag(SF_SUBMENUEXIT, true); @@ -218,9 +228,15 @@ void OptionsMenu::Render() { Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); if (PoleAnimation.IsIn()) { - Renderer->DrawSprite( - PagePanelSprites[2 * CurrentPage + !(bool)CurrentlyFocusedElement], - PagePanelPosition + PagePanelIconOffsets[CurrentPage], col); + for (ClickButton& panel : PageButtons) { + if (panel.Id == CurrentPage || panel.Hovered) { + const bool highlighted = + panel.Id == CurrentPage && (bool)CurrentlyFocusedElement; + Renderer->DrawSprite( + PagePanelSprites[2 * panel.Id + !highlighted], + PagePanelPosition + PagePanelIconOffsets[panel.Id], col); + } + } } const Sprite& guideSprite = @@ -252,6 +268,12 @@ void OptionsMenu::Select(OptionsEntry* toSelect) { CurrentlyFocusedElement = toSelect; } +void OptionsMenu::PageButtonOnClick(ClickButton* target) { + GoToPage(target->Id); + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; +} + } // namespace CCLCC } // namespace UI } // namespace Impacto \ No newline at end of file diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index df51a299..830b3839 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -3,6 +3,7 @@ #include "../../ui/menu.h" #include "../../spriteanimation.h" #include "../../ui/widgets/group.h" +#include "../../ui/widgets/clickbutton.h" #include "../../ui/widgets/cclcc/optionsentry.h" using namespace Impacto::UI::Widgets::CCLCC; @@ -24,6 +25,7 @@ class OptionsMenu : public Menu { private: void GoToPage(int pageNumber); void Select(OptionsEntry* entry); + void PageButtonOnClick(Widgets::ClickButton* target); Animation FadeAnimation; SpriteAnimation PoleAnimation; @@ -34,7 +36,8 @@ class OptionsMenu : public Menu { Widgets::Group* VoicePage; int CurrentPage; - std::vector Pages; + std::vector Pages; + std::vector PageButtons; }; } // namespace CCLCC diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 1eb55419..0ef274fd 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -22,8 +22,7 @@ void Configure() { HeaderSprite = EnsureGetMemberSprite("HeaderSprite"); HeaderPosition = EnsureGetMemberVec2("HeaderPosition"); - GetMemberSpriteArray(PageHeaderSprites, PageHeaderSpriteCount, - "PageHeaderSprites"); + GetMemberSpriteArray(PageHeaderSprites, PageCount, "PageHeaderSprites"); PageHeaderPosition = EnsureGetMemberVec2("PageHeaderPosition"); PagePanelSprite = EnsureGetMemberSprite("PagePanelSprite"); @@ -33,9 +32,11 @@ void Configure() { PoleAnimation = EnsureGetMemberAnimation("PoleAnimation"); // TODO: Replace this once array fetching is implemented - for (int i = 0; i < PagePanelSpriteCount / 2; i++) { + for (int i = 0; i < PageCount; i++) { PagePanelIconOffsets[i] = EnsureGetMemberVec2( ("PagePanelIconOffsets" + std::to_string(i)).c_str()); + PagePanelHoverBounds[i] = EnsureGetMemberRectF( + ("PagePanelHoverBounds" + std::to_string(i)).c_str()); } SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); @@ -65,11 +66,11 @@ void Configure() { EntryDimensions = EnsureGetMemberVec2("EntryDimensions"); VoiceEntryDimensions = EnsureGetMemberVec2("VoiceEntryDimensions"); - GetMemberSpriteArray(LabelSprites, LabelSpriteCount, "LabelSprites"); + GetMemberSpriteArray(LabelSprites, LabelCount, "LabelSprites"); LabelOffset = EnsureGetMemberVec2("LabelOffset"); - GetMemberSpriteArray(NametagSprites, NametagSpriteCount, "NametagSprites"); + GetMemberSpriteArray(NametagSprites, NametagCount, "NametagSprites"); NametagOffset = EnsureGetMemberVec2("NametagOffset"); - GetMemberSpriteArray(PortraitSprites, PortraitSpriteCount, "PortraitSprites"); + GetMemberSpriteArray(PortraitSprites, PortraitCount, "PortraitSprites"); PortraitOffset = EnsureGetMemberVec2("PortraitOffset"); VoicePosition = EnsureGetMemberVec2("VoicePosition"); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 6a9b692b..f5e9ab88 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -8,11 +8,11 @@ namespace Profile { namespace CCLCC { namespace OptionsMenu { -int constexpr PageHeaderSpriteCount = 4; -int constexpr PagePanelSpriteCount = 8; -int constexpr LabelSpriteCount = 16; -int constexpr NametagSpriteCount = 13; -int constexpr PortraitSpriteCount = 26; +int constexpr PageCount = 4; +int constexpr PagePanelSpriteCount = PageCount * 2; +int constexpr LabelCount = 16; +int constexpr NametagCount = 13; +int constexpr PortraitCount = NametagCount * 2; inline glm::vec2 BackgroundPosition; @@ -23,7 +23,7 @@ inline glm::vec2 PointerOffset; inline Sprite HeaderSprite; inline glm::vec2 HeaderPosition; -inline Sprite PageHeaderSprites[PageHeaderSpriteCount]; +inline Sprite PageHeaderSprites[PageCount]; inline glm::vec2 PageHeaderPosition; inline Sprite PagePanelSprite; @@ -31,6 +31,7 @@ inline glm::vec2 PagePanelPosition; inline Sprite PagePanelSprites[PagePanelSpriteCount]; inline glm::vec2 PagePanelIconOffsets[PagePanelSpriteCount]; inline SpriteAnimationDef PoleAnimation; +inline RectF PagePanelHoverBounds[PageCount]; inline Sprite SliderTrackSprite; inline glm::vec2 SliderTrackOffset; @@ -59,11 +60,11 @@ inline glm::vec2 VoiceEntriesOffset; inline glm::vec2 EntryDimensions; inline glm::vec2 VoiceEntryDimensions; -inline Sprite LabelSprites[LabelSpriteCount]; +inline Sprite LabelSprites[LabelCount]; inline glm::vec2 LabelOffset; -inline Sprite NametagSprites[NametagSpriteCount]; +inline Sprite NametagSprites[NametagCount]; inline glm::vec2 NametagOffset; -inline Sprite PortraitSprites[PortraitSpriteCount]; +inline Sprite PortraitSprites[PortraitCount]; inline glm::vec2 PortraitOffset; inline glm::vec2 VoicePosition; From 90eef0fd75c61770da59e42f28814a447d7b3663 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 21:21:54 +0100 Subject: [PATCH 21/34] Implemented bumper tab switching for options menu --- src/games/cclcc/optionsmenu.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index fc2c997e..21b9ba43 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -181,6 +181,19 @@ void OptionsMenu::Update(float dt) { void OptionsMenu::UpdateInput() { for (ClickButton& button : PageButtons) button.UpdateInput(); + // Tab cycling + if (PADinputButtonWentDown & (PAD1L1 | PAD1R1)) { + const bool focusedElement = CurrentlyFocusedElement; + const int direction = (bool)(PADinputButtonWentDown & PAD1R1) - + (bool)(PADinputButtonWentDown & PAD1L1); + GoToPage((CurrentPage + direction) % Pages.size()); + + if (focusedElement) { + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; + } + } + if (CurrentlyFocusedElement == nullptr) { if (GetControlState(CT_Back)) { SetFlag(SF_SUBMENUEXIT, true); From 24b7aead20c791451973947bc0990a3926d33560 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 21:29:16 +0100 Subject: [PATCH 22/34] Added mouse highlights to option entries --- src/ui/widgets/cclcc/optionsentry.cpp | 2 +- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index c8a5ee98..c6326f4e 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -27,7 +27,7 @@ OptionsEntry::OptionsEntry(const Sprite& label, glm::vec2 pos, void OptionsEntry::Render() { HighlightTint.a = Tint.a; - if (HasFocus) { + if (HasFocus || EntryButton.Hovered) { RectF highlightBoundBox(Bounds.X, Bounds.Y, EntryDimensions.x, EntryDimensions.y); Renderer->DrawRect(highlightBoundBox, HighlightTint); diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index 5ded91e7..757887f9 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -31,7 +31,7 @@ OptionsVoiceSlider::OptionsVoiceSlider( void OptionsVoiceSlider::Render() { HighlightTint.a = Tint.a; - if (HasFocus) { + if (HasFocus || EntryButton.Hovered) { RectF highlightBoundBox(Bounds.X, Bounds.Y, VoiceEntryDimensions.x, VoiceEntryDimensions.y); Renderer->DrawRect(highlightBoundBox, HighlightTint); From 905653aa1293cef1160fbc7b86e77c46c15c6d4b Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 21:49:10 +0100 Subject: [PATCH 23/34] Improved click button reliability --- src/ui/widgets/cclcc/optionsentry.cpp | 3 +++ src/ui/widgets/cclcc/optionsentry.h | 2 ++ src/ui/widgets/clickbutton.cpp | 21 ++++++++++++++++++++- src/ui/widgets/clickbutton.h | 3 +++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index c6326f4e..098ebadd 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -51,8 +51,11 @@ void OptionsEntry::UpdateInput() { Selected = false; } +void OptionsEntry::Show() { EntryButton.Show(); } + void OptionsEntry::Hide() { Widget::Hide(); + EntryButton.Hide(); Selected = false; } diff --git a/src/ui/widgets/cclcc/optionsentry.h b/src/ui/widgets/cclcc/optionsentry.h index 8221b5a2..f9b802e9 100644 --- a/src/ui/widgets/cclcc/optionsentry.h +++ b/src/ui/widgets/cclcc/optionsentry.h @@ -18,6 +18,8 @@ class OptionsEntry : public Widget { void Render() override; void UpdateInput() override; + + void Show() override; void Hide() override; bool Selected = false; diff --git a/src/ui/widgets/clickbutton.cpp b/src/ui/widgets/clickbutton.cpp index 31759d1d..c0756a68 100644 --- a/src/ui/widgets/clickbutton.cpp +++ b/src/ui/widgets/clickbutton.cpp @@ -17,7 +17,8 @@ void ClickButton::UpdateInput() { if (!Enabled) return; if (Input::CurrentInputDevice == Input::Device::Mouse && - Input::PrevMousePos != Input::CurMousePos) { + (Input::PrevMousePos != Input::CurMousePos || + Vm::Interface::PADinputMouseWentDown)) { Hovered = Bounds.ContainsPoint(Input::CurMousePos); } else if (Input::CurrentInputDevice == Input::Device::Touch && Input::TouchIsDown[0] && @@ -29,6 +30,24 @@ void ClickButton::UpdateInput() { OnClickHandler(this); } +void ClickButton::Show() { + Enabled = true; + + switch (Input::CurrentInputDevice) { + case Input::Device::Mouse: + Hovered = Bounds.ContainsPoint(Input::CurMousePos); + break; + case Input::Device::Touch: + Hovered = Bounds.ContainsPoint(Input::CurTouchPos); + break; + } +} + +void ClickButton::Hide() { + Enabled = false; + Hovered = false; +} + } // namespace Widgets } // namespace UI } // namespace Impacto \ No newline at end of file diff --git a/src/ui/widgets/clickbutton.h b/src/ui/widgets/clickbutton.h index 0d6a27c6..d844a04c 100644 --- a/src/ui/widgets/clickbutton.h +++ b/src/ui/widgets/clickbutton.h @@ -16,6 +16,9 @@ class ClickButton : public Widget { virtual void UpdateInput() override; + virtual void Show(); + virtual void Hide(); + int Id; std::function OnClickHandler; From ab4dcf71e6fb872279e771f682283e5cf3fb76de Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 22:02:23 +0100 Subject: [PATCH 24/34] Improved page panel spritesheet location --- profiles/cclcc/hud/optionsmenu.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 715c19b9..1c355557 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -201,6 +201,11 @@ for i = 0, 7 do width = 224; offset = ((i % 2 == 1) and {width * 4} or {0})[1]; + -- Non-highlighted Text and Sound panels are poorly placed in the spritesheet, for some reason + if (i == 3 or i == 5) then + offset = offset - 1; + end + root.Sprites["OptionsPagePanel" .. i] = { Sheet = "Config", Bounds = { From bbeb94d16ec8423160499f46658b0899a12672e6 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 22:13:51 +0100 Subject: [PATCH 25/34] Converted two profile settings to use vec2-arrays and RectF-arrays instead --- profiles/cclcc/hud/optionsmenu.lua | 21 ++++++++++++--------- src/profile/games/cclcc/optionsmenu.cpp | 10 ++-------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 1c355557..69914089 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -21,16 +21,19 @@ root.OptionsMenu = { PagePanelSprite = "OptionsPagePanel", PagePanelPosition = { X = -114, Y = 0 }, PagePanelSprites = {}, + PagePanelIconOffsets = { + { X = 259, Y = 73 }, + { X = 235, Y = 333 }, + { X = 261, Y = 585 }, + { X = 238, Y = 831 } + }, + PagePanelHoverBounds = { + { X = 168, Y = 79, Width = 150, Height = 183 }, + { X = 147, Y = 343, Width = 154, Height = 177 }, + { X = 169, Y = 591, Width = 146, Height = 181 }, + { X = 149, Y = 837, Width = 150, Height = 179 }, + }, PoleAnimation = "OptionsPoleAnimation", - -- TODO: Replace this once array fetching is implemented - PagePanelIconOffsets0 = { X = 259, Y = 73 }, - PagePanelIconOffsets1 = { X = 235, Y = 333 }, - PagePanelIconOffsets2 = { X = 261, Y = 585 }, - PagePanelIconOffsets3 = { X = 238, Y = 831 }, - PagePanelHoverBounds0 = { X = 168, Y = 79, Width = 150, Height = 183 }, - PagePanelHoverBounds1 = { X = 147, Y = 343, Width = 154, Height = 177 }, - PagePanelHoverBounds2 = { X = 169, Y = 591, Width = 146, Height = 181 }, - PagePanelHoverBounds3 = { X = 149, Y = 837, Width = 150, Height = 179 }, SliderTrackSprite = "OptionsSliderTrack", SliderTrackOffset = { X = 766, Y = 0 }, diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 0ef274fd..0c45eba4 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -29,16 +29,10 @@ void Configure() { PagePanelPosition = EnsureGetMemberVec2("PagePanelPosition"); GetMemberSpriteArray(PagePanelSprites, PagePanelSpriteCount, "PagePanelSprites"); + GetMemberVec2Array(PagePanelIconOffsets, PageCount, "PagePanelIconOffsets"); + GetMemberRectFArray(PagePanelHoverBounds, PageCount, "PagePanelHoverBounds"); PoleAnimation = EnsureGetMemberAnimation("PoleAnimation"); - // TODO: Replace this once array fetching is implemented - for (int i = 0; i < PageCount; i++) { - PagePanelIconOffsets[i] = EnsureGetMemberVec2( - ("PagePanelIconOffsets" + std::to_string(i)).c_str()); - PagePanelHoverBounds[i] = EnsureGetMemberRectF( - ("PagePanelHoverBounds" + std::to_string(i)).c_str()); - } - SliderTrackSprite = EnsureGetMemberSprite("SliderTrackSprite"); SliderTrackOffset = EnsureGetMemberVec2("SliderTrackOffset"); VoiceSliderTrackSprite = EnsureGetMemberSprite("VoiceSliderTrackSprite"); From 641bdc30591e00628918ef59aa2b91be323419eb Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 23:17:34 +0100 Subject: [PATCH 26/34] Fixed options menu exiting --- src/games/cclcc/optionsmenu.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 21b9ba43..6266223b 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -164,8 +164,7 @@ void OptionsMenu::Hide() { } void OptionsMenu::Update(float dt) { - UpdateInput(); - Pages.at(CurrentPage)->Update(dt); + const bool wasOut = FadeAnimation.IsOut(); FadeAnimation.Update(dt); PoleAnimation.Update(dt); @@ -176,6 +175,21 @@ void OptionsMenu::Update(float dt) { ScrWork[SW_SYSSUBMENUNO] == 5) { Show(); } + + if (State != Hidden) { + UpdateInput(); + Pages.at(CurrentPage)->Update(dt); + } + + if (FadeAnimation.IsIn()) + State = Shown; + else if (!wasOut && FadeAnimation.IsOut()) { + State = Hidden; + + Pages.at(CurrentPage)->Hide(); + CurrentPage = 0; + CurrentlyFocusedElement = nullptr; + } } void OptionsMenu::UpdateInput() { From 95ab928d78cb5b7d54f33df4cabcd46105d6e514 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Fri, 27 Dec 2024 23:32:09 +0100 Subject: [PATCH 27/34] Implemented muting voice with mouse --- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 22 +++++++++++++++++++++ src/ui/widgets/cclcc/optionsvoiceslider.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index 757887f9..f2fbab02 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -26,6 +26,13 @@ OptionsVoiceSlider::OptionsVoiceSlider( Bounds = RectF(Bounds.X, Bounds.Y, VoiceEntryDimensions.x, VoiceEntryDimensions.y); EntryButton.Bounds = Bounds; + + std::function onClick = std::bind( + &OptionsVoiceSlider::MuteButtonOnClick, this, std::placeholders::_1); + const RectF muteButtonBounds(Bounds.GetPos().x + PortraitOffset.x, + Bounds.GetPos().y + PortraitOffset.y, + portrait.ScaledWidth(), portrait.ScaledHeight()); + MuteButton = ClickButton(0, muteButtonBounds, onClick); } void OptionsVoiceSlider::Render() { @@ -53,10 +60,25 @@ void OptionsVoiceSlider::Render() { void OptionsVoiceSlider::UpdateInput() { OptionsSlider::UpdateInput(); + MuteButton.UpdateInput(); if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); } +void OptionsVoiceSlider::Show() { + OptionsSlider::Show(); + MuteButton.Show(); +} + +void OptionsVoiceSlider::Hide() { + OptionsSlider::Hide(); + MuteButton.Hide(); +} + +void OptionsVoiceSlider::MuteButtonOnClick(ClickButton* target) { + Muted = !Muted; +} + } // namespace CCLCC } // namespace Widgets } // namespace UI diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.h b/src/ui/widgets/cclcc/optionsvoiceslider.h index 123e718c..932ba011 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.h +++ b/src/ui/widgets/cclcc/optionsvoiceslider.h @@ -17,11 +17,16 @@ class OptionsVoiceSlider : public OptionsSlider { void Render() override; void UpdateInput() override; + void Show() override; + void Hide() override; + private: const Sprite& Portrait; const Sprite& MutedPortrait; bool Muted = false; + ClickButton MuteButton; + void MuteButtonOnClick(ClickButton* target); }; } // namespace CCLCC From 0dc85ea130b96515eb208babb78277e03f676f46 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 00:24:24 +0100 Subject: [PATCH 28/34] Added sysse to options menu --- src/games/cclcc/optionsmenu.cpp | 28 ++++++++++++++++++-- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 28 +++++++++++++++----- src/ui/widgets/cclcc/optionsentry.cpp | 20 +++++++++++--- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 14 +++++++++- 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 6266223b..d82497e3 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -193,10 +193,17 @@ void OptionsMenu::Update(float dt) { } void OptionsMenu::UpdateInput() { - for (ClickButton& button : PageButtons) button.UpdateInput(); + for (ClickButton& button : PageButtons) { + const bool wasHovered = button.Hovered; + button.UpdateInput(); + if (!wasHovered && button.Hovered) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + } // Tab cycling if (PADinputButtonWentDown & (PAD1L1 | PAD1R1)) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + const bool focusedElement = CurrentlyFocusedElement; const int direction = (bool)(PADinputButtonWentDown & PAD1R1) - (bool)(PADinputButtonWentDown & PAD1L1); @@ -210,18 +217,26 @@ void OptionsMenu::UpdateInput() { if (CurrentlyFocusedElement == nullptr) { if (GetControlState(CT_Back)) { + if (!GetFlag(SF_SUBMENUEXIT)) + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + SetFlag(SF_SUBMENUEXIT, true); return; } const int direction = (bool)(PADinputButtonWentDown & PAD1DOWN) - (bool)(PADinputButtonWentDown & PAD1UP); - if (direction) GoToPage((CurrentPage + direction) % Pages.size()); + if (direction) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + GoToPage((CurrentPage + direction) % Pages.size()); + } if (PADinputButtonWentDown & PAD1A) { // Don't have anything else consume the confirmation PADinputButtonWentDown &= ~PAD1A; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); CurrentlyFocusedElement->HasFocus = true; } @@ -233,12 +248,16 @@ void OptionsMenu::UpdateInput() { if (static_cast(CurrentlyFocusedElement)->Selected) return; if (GetControlState(CT_Back) || PADinputMouseWentDown & PAD1B) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + static_cast(CurrentlyFocusedElement)->Hide(); CurrentlyFocusedElement = nullptr; return; } Menu::UpdateInput(); + if (PADinputButtonWentDown & (PAD1DOWN | PAD1UP)) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); } void OptionsMenu::Render() { @@ -296,6 +315,11 @@ void OptionsMenu::Select(OptionsEntry* toSelect) { } void OptionsMenu::PageButtonOnClick(ClickButton* target) { + if (target->Id != CurrentPage || !CurrentlyFocusedElement) + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + + if (target->Id == CurrentPage && CurrentlyFocusedElement) return; + GoToPage(target->Id); CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); CurrentlyFocusedElement->HasFocus = true; diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index b7255136..7cd606e2 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -56,22 +56,38 @@ void OptionsBinaryButton::Render() { } void OptionsBinaryButton::UpdateInput() { - OptionsEntry::UpdateInput(); - // Handle mouse/touch input TrueButton.UpdateInput(); FalseButton.UpdateInput(); + OptionsEntry::UpdateInput(); + if (!Selected) return; // Handle keyboard/controller input - if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) - State = PADinputButtonWentDown & PAD1LEFT; + if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) { + const bool newState = PADinputButtonWentDown & PAD1LEFT; + + if (State != newState) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = newState; + } } -void OptionsBinaryButton::TrueOnClick(ClickButton* target) { State = true; } +void OptionsBinaryButton::TrueOnClick(ClickButton* target) { + if (Selected && State != true) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = true; +} -void OptionsBinaryButton::FalseOnClick(ClickButton* target) { State = false; } +void OptionsBinaryButton::FalseOnClick(ClickButton* target) { + if (Selected && State != false) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = false; +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 098ebadd..596f55b5 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -42,13 +42,22 @@ void OptionsEntry::Render() { } void OptionsEntry::UpdateInput() { + const bool wasHovered = EntryButton.Hovered; EntryButton.UpdateInput(); + if (!wasHovered && EntryButton.Hovered) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); if (!HasFocus) return; - Selected ^= (bool)(PADinputButtonWentDown & PAD1A); - if (PADinputButtonWentDown & PAD1B || PADinputMouseWentDown & PAD1B) + if (PADinputButtonWentDown & PAD1A) { + Selected = !Selected; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + } + + if (PADinputButtonWentDown & PAD1B || PADinputMouseWentDown & PAD1B) { Selected = false; + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + } } void OptionsEntry::Show() { EntryButton.Show(); } @@ -59,7 +68,12 @@ void OptionsEntry::Hide() { Selected = false; } -void OptionsEntry::EntryButtonOnClick(ClickButton* target) { Select(this); } +void OptionsEntry::EntryButtonOnClick(ClickButton* target) { + if (Selected) return; + + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + Select(this); +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index f2fbab02..00b54e7f 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -62,7 +62,17 @@ void OptionsVoiceSlider::UpdateInput() { OptionsSlider::UpdateInput(); MuteButton.UpdateInput(); - if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); + if (!HasFocus) return; + + if (PADinputButtonWentDown & PAD1Y) { + Muted = !Muted; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + } + + if ((bool)(PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) && + !(bool)(PADinputButtonWentDown & (PAD1UP | PAD1DOWN))) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + } } void OptionsVoiceSlider::Show() { @@ -76,6 +86,8 @@ void OptionsVoiceSlider::Hide() { } void OptionsVoiceSlider::MuteButtonOnClick(ClickButton* target) { + if (HasFocus) Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + Muted = !Muted; } From 64c6d2aef65651f0463fd8857cdb3b29b785cc64 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 17:32:31 +0100 Subject: [PATCH 29/34] Gave skip mode option 'read' and 'all' sprites --- src/games/cclcc/optionsmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index d82497e3..fd64214c 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -62,7 +62,7 @@ OptionsMenu::OptionsMenu() { pos.y += EntriesVerticalOffset; } TextPage->Add( - new OptionsBinaryButton(BinaryBoxSprite, YesSprite, NoSprite, + new OptionsBinaryButton(BinaryBoxSprite, SkipReadSprite, SkipAllSprite, LabelSprites[6], pos, highlightTint, select), FDIR_DOWN); Pages.push_back(TextPage); From c8ba1f9b5bcee90341cb77c57824686076340709 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 17:42:30 +0100 Subject: [PATCH 30/34] Properly enabled and disabled OptionsBinaryButton true/false buttons --- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 14 ++++++++++++++ src/ui/widgets/cclcc/optionsbinarybutton.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index 7cd606e2..8f6288b2 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -75,6 +75,20 @@ void OptionsBinaryButton::UpdateInput() { } } +void OptionsBinaryButton::Show() { + OptionsEntry::Show(); + + TrueButton.Show(); + FalseButton.Show(); +} + +void OptionsBinaryButton::Hide() { + OptionsEntry::Hide(); + + TrueButton.Hide(); + FalseButton.Hide(); +} + void OptionsBinaryButton::TrueOnClick(ClickButton* target) { if (Selected && State != true) Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h index 4751e637..0069934c 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.h +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -19,6 +19,9 @@ class OptionsBinaryButton : public OptionsEntry { void Render() override; void UpdateInput() override; + void Show() override; + void Hide() override; + private: ClickButton TrueButton; ClickButton FalseButton; From 97190eb50f7b753ce0eb7685df745e9a265586ad Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 20:05:13 +0100 Subject: [PATCH 31/34] Implemented options menu fade animation --- profiles/cclcc/hud/optionsmenu.lua | 9 ++-- src/games/cclcc/optionsmenu.cpp | 46 +++++++++++++++----- src/profile/games/cclcc/optionsmenu.cpp | 5 +++ src/profile/games/cclcc/optionsmenu.h | 3 ++ src/ui/widget.cpp | 4 +- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 20 +++++++++ src/ui/widgets/cclcc/optionsbinarybutton.h | 4 ++ src/ui/widgets/cclcc/optionsentry.cpp | 17 ++++++++ src/ui/widgets/cclcc/optionsentry.h | 4 ++ src/ui/widgets/cclcc/optionsslider.cpp | 17 ++++++++ src/ui/widgets/cclcc/optionsslider.h | 4 ++ src/ui/widgets/cclcc/optionsvoiceslider.cpp | 17 ++++++++ src/ui/widgets/cclcc/optionsvoiceslider.h | 4 ++ 13 files changed, 138 insertions(+), 16 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 69914089..72eff68b 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -2,13 +2,14 @@ root.OptionsMenu = { Type = OptionsMenuType.CCLCC, DrawType = DrawComponentType.SystemMenu, - FadeInDuration = 0.2, - FadeOutDuration = 0.2, + FadeInDuration = 0.5, + FadeOutDuration = 0.5, HighlightColor = { X = 0.94, Y = 0.49, Z = 0.59 }, BackgroundSprite = "OptionsBackground", BackgroundPosition = { X = 179, Y = 0 }, + BackgroundFadeStartPosition = { X = 179, Y = -375 }, PointerSprite = "OptionsPointer", PointerOffset = { X = 13, Y = 2 }, @@ -20,6 +21,7 @@ root.OptionsMenu = { PagePanelSprite = "OptionsPagePanel", PagePanelPosition = { X = -114, Y = 0 }, + PagePanelFadeStartPosition = { X = -464, Y = 0 }, PagePanelSprites = {}, PagePanelIconOffsets = { { X = 259, Y = 73 }, @@ -53,6 +55,7 @@ root.OptionsMenu = { GuideSprite = "OptionsGuide", VoiceGuideSprite = "OptionsVoiceGuide", GuidePosition = { X = 0, Y = 986 }, + GuideFadeStartPosition = { X = 0, Y = 1375 }, EntriesStartPosition = { X = 419, Y = 313 }, EntriesVerticalOffset = 126, @@ -250,7 +253,7 @@ MakeAnimation({ RowHeight = 1096, Frames = 15, - Duration = 1, + Duration = 0.5, Rows = 3, Columns = 7, diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index fd64214c..9ec48f18 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -164,7 +164,7 @@ void OptionsMenu::Hide() { } void OptionsMenu::Update(float dt) { - const bool wasOut = FadeAnimation.IsOut(); + const bool wasAnimating = !FadeAnimation.IsOut() && !FadeAnimation.IsIn(); FadeAnimation.Update(dt); PoleAnimation.Update(dt); @@ -181,14 +181,24 @@ void OptionsMenu::Update(float dt) { Pages.at(CurrentPage)->Update(dt); } - if (FadeAnimation.IsIn()) + if (!FadeAnimation.IsIn() && !FadeAnimation.IsOut()) { + const glm::vec2 backgroundPosition = + glm::vec2(0.0f, glm::mix(BackgroundFadeStartPosition.y, + BackgroundPosition.y, FadeAnimation.Progress)); + Pages.at(CurrentPage)->MoveTo(backgroundPosition); + } + + if (FadeAnimation.IsIn()) { State = Shown; - else if (!wasOut && FadeAnimation.IsOut()) { + Pages.at(CurrentPage)->MoveTo(glm::vec2(0.0f, BackgroundPosition.y)); + } else if (wasAnimating && FadeAnimation.IsOut()) { State = Hidden; Pages.at(CurrentPage)->Hide(); CurrentPage = 0; CurrentlyFocusedElement = nullptr; + + SetFlag(SF_SUBMENUEXIT, true); } } @@ -220,7 +230,7 @@ void OptionsMenu::UpdateInput() { if (!GetFlag(SF_SUBMENUEXIT)) Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); - SetFlag(SF_SUBMENUEXIT, true); + Hide(); return; } @@ -265,14 +275,28 @@ void OptionsMenu::Render() { ScrWork[SW_SYSSUBMENUNO] == 5) { glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress); - Renderer->DrawSprite(BackgroundSprite, BackgroundPosition, col); - Renderer->DrawSprite(HeaderSprite, HeaderPosition, col); - - Renderer->DrawSprite(PageHeaderSprites[CurrentPage], PageHeaderPosition, - col); + const glm::vec2 backgroundAnimationOffset = + glm::vec2(0.0f, FadeAnimation.Progress * BackgroundPosition.y + + (1.0f - FadeAnimation.Progress) * + BackgroundFadeStartPosition.y); + const glm::vec2 pagePanelPosition = + PagePanelPosition * FadeAnimation.Progress + + (1.0f - FadeAnimation.Progress) * PagePanelFadeStartPosition; + const glm::vec2 guidePosition = + GuidePosition * FadeAnimation.Progress + + (1.0f - FadeAnimation.Progress) * GuideFadeStartPosition; + + Renderer->DrawSprite(BackgroundSprite, + BackgroundPosition + backgroundAnimationOffset, col); + Renderer->DrawSprite(HeaderSprite, + HeaderPosition + backgroundAnimationOffset, col); + + Renderer->DrawSprite(PageHeaderSprites[CurrentPage], + PageHeaderPosition + backgroundAnimationOffset, col); + Pages.at(CurrentPage)->Tint = col; Pages.at(CurrentPage)->Render(); - Renderer->DrawSprite(PoleAnimation.CurrentSprite(), PagePanelPosition, col); + Renderer->DrawSprite(PoleAnimation.CurrentSprite(), pagePanelPosition, col); if (PoleAnimation.IsIn()) { for (ClickButton& panel : PageButtons) { if (panel.Id == CurrentPage || panel.Hovered) { @@ -287,7 +311,7 @@ void OptionsMenu::Render() { const Sprite& guideSprite = CurrentPage == 3 ? VoiceGuideSprite : GuideSprite; - Renderer->DrawSprite(guideSprite, GuidePosition, col); + Renderer->DrawSprite(guideSprite, guidePosition, col); } } diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 0c45eba4..73c26f20 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -14,6 +14,8 @@ namespace OptionsMenu { void Configure() { BackgroundPosition = EnsureGetMemberVec2("BackgroundPosition"); + BackgroundFadeStartPosition = + EnsureGetMemberVec2("BackgroundFadeStartPosition"); HighlightColor = EnsureGetMemberVec3("HighlightColor"); @@ -27,6 +29,8 @@ void Configure() { PagePanelSprite = EnsureGetMemberSprite("PagePanelSprite"); PagePanelPosition = EnsureGetMemberVec2("PagePanelPosition"); + PagePanelFadeStartPosition = + EnsureGetMemberVec2("PagePanelFadeStartPosition"); GetMemberSpriteArray(PagePanelSprites, PagePanelSpriteCount, "PagePanelSprites"); GetMemberVec2Array(PagePanelIconOffsets, PageCount, "PagePanelIconOffsets"); @@ -51,6 +55,7 @@ void Configure() { GuideSprite = EnsureGetMemberSprite("GuideSprite"); VoiceGuideSprite = EnsureGetMemberSprite("VoiceGuideSprite"); GuidePosition = EnsureGetMemberVec2("GuidePosition"); + GuideFadeStartPosition = EnsureGetMemberVec2("GuideFadeStartPosition"); EntriesStartPosition = EnsureGetMemberVec2("EntriesStartPosition"); EntriesVerticalOffset = EnsureGetMemberInt("EntriesVerticalOffset"); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index f5e9ab88..66cfaafc 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -15,6 +15,7 @@ int constexpr NametagCount = 13; int constexpr PortraitCount = NametagCount * 2; inline glm::vec2 BackgroundPosition; +inline glm::vec2 BackgroundFadeStartPosition; inline glm::vec3 HighlightColor; @@ -28,6 +29,7 @@ inline glm::vec2 PageHeaderPosition; inline Sprite PagePanelSprite; inline glm::vec2 PagePanelPosition; +inline glm::vec2 PagePanelFadeStartPosition; inline Sprite PagePanelSprites[PagePanelSpriteCount]; inline glm::vec2 PagePanelIconOffsets[PagePanelSpriteCount]; inline SpriteAnimationDef PoleAnimation; @@ -51,6 +53,7 @@ inline Sprite NoSprite; inline Sprite GuideSprite; inline Sprite VoiceGuideSprite; inline glm::vec2 GuidePosition; +inline glm::vec2 GuideFadeStartPosition; inline glm::vec2 EntriesStartPosition; inline int EntriesVerticalOffset; diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index 1f400fbd..4c07a711 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -22,7 +22,7 @@ void Widget::Hide() { WidgetType Widget::GetType() { return WT_NORMAL; } void Widget::Move(glm::vec2 relativePosition, float duration) { - MoveOrigin = glm::vec2(Bounds.X, Bounds.Y); + MoveOrigin = Bounds.GetPos(); MoveTarget = MoveOrigin + relativePosition; MoveAnimation.Progress = 0.0f; MoveAnimation.Direction = AnimationDirection::In; @@ -36,7 +36,7 @@ void Widget::Move(glm::vec2 relativePosition) { } void Widget::MoveTo(glm::vec2 pos, float duration) { - MoveOrigin = glm::vec2(Bounds.X, Bounds.Y); + MoveOrigin = Bounds.GetPos(); MoveTarget = pos; MoveAnimation.Progress = 0.0f; MoveAnimation.Direction = AnimationDirection::In; diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index 8f6288b2..f4278a62 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -55,6 +55,13 @@ void OptionsBinaryButton::Render() { glm::vec2(1.0f), 0.0f, State); } +void OptionsBinaryButton::Update(float dt) { + OptionsEntry::Update(dt); + + TrueButton.Update(dt); + FalseButton.Update(dt); +} + void OptionsBinaryButton::UpdateInput() { // Handle mouse/touch input TrueButton.UpdateInput(); @@ -89,6 +96,19 @@ void OptionsBinaryButton::Hide() { FalseButton.Hide(); } +void OptionsBinaryButton::Move(glm::vec2 relativePos) { + OptionsEntry::Move(relativePos); + TrueButton.Move(relativePos); + FalseButton.Move(relativePos); +} + +void OptionsBinaryButton::MoveTo(glm::vec2 pos) { + const glm::vec2 relativePosition = pos - Bounds.GetPos(); + OptionsEntry::MoveTo(pos); + TrueButton.Move(relativePosition); + FalseButton.Move(relativePosition); +} + void OptionsBinaryButton::TrueOnClick(ClickButton* target) { if (Selected && State != true) Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.h b/src/ui/widgets/cclcc/optionsbinarybutton.h index 0069934c..74cdb6da 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.h +++ b/src/ui/widgets/cclcc/optionsbinarybutton.h @@ -17,11 +17,15 @@ class OptionsBinaryButton : public OptionsEntry { std::function select); void Render() override; + void Update(float dt) override; void UpdateInput() override; void Show() override; void Hide() override; + void Move(glm::vec2 relativePos) override; + void MoveTo(glm::vec2 pos) override; + private: ClickButton TrueButton; ClickButton FalseButton; diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 596f55b5..892992a7 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -41,6 +41,12 @@ void OptionsEntry::Render() { Selected ? Tint : glm::vec4(0.0f, 0.0f, 0.0f, Tint.a)); } +void OptionsEntry::Update(float dt) { + Widget::Update(dt); + + EntryButton.Update(dt); +} + void OptionsEntry::UpdateInput() { const bool wasHovered = EntryButton.Hovered; EntryButton.UpdateInput(); @@ -68,6 +74,17 @@ void OptionsEntry::Hide() { Selected = false; } +void OptionsEntry::Move(glm::vec2 relativePos) { + Widget::Move(relativePos); + EntryButton.Move(relativePos); +} + +void OptionsEntry::MoveTo(glm::vec2 pos) { + const glm::vec2 relativePosition = pos - Bounds.GetPos(); + Widget::MoveTo(pos); + EntryButton.Move(relativePosition); +} + void OptionsEntry::EntryButtonOnClick(ClickButton* target) { if (Selected) return; diff --git a/src/ui/widgets/cclcc/optionsentry.h b/src/ui/widgets/cclcc/optionsentry.h index f9b802e9..00751b76 100644 --- a/src/ui/widgets/cclcc/optionsentry.h +++ b/src/ui/widgets/cclcc/optionsentry.h @@ -17,11 +17,15 @@ class OptionsEntry : public Widget { std::function select); void Render() override; + void Update(float dt) override; void UpdateInput() override; void Show() override; void Hide() override; + void Move(glm::vec2 relativePos) override; + void MoveTo(glm::vec2 pos) override; + bool Selected = false; protected: diff --git a/src/ui/widgets/cclcc/optionsslider.cpp b/src/ui/widgets/cclcc/optionsslider.cpp index 02a4c8a1..cfec4b33 100644 --- a/src/ui/widgets/cclcc/optionsslider.cpp +++ b/src/ui/widgets/cclcc/optionsslider.cpp @@ -45,6 +45,12 @@ void OptionsSlider::Render() { Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + SliderTrackOffset, Tint); } +void OptionsSlider::Update(float dt) { + OptionsEntry::Update(dt); + + Slider.Update(dt); +} + void OptionsSlider::UpdateInput() { OptionsEntry::UpdateInput(); @@ -53,6 +59,17 @@ void OptionsSlider::UpdateInput() { Slider.ClampValue(); } +void OptionsSlider::Move(glm::vec2 relativePos) { + OptionsEntry::Move(relativePos); + Slider.Move(relativePos); +} + +void OptionsSlider::MoveTo(glm::vec2 pos) { + const glm::vec2 relativePosition = pos - Bounds.GetPos(); + OptionsEntry::MoveTo(pos); + Slider.Move(relativePosition); +} + } // namespace CCLCC } // namespace Widgets } // namespace UI diff --git a/src/ui/widgets/cclcc/optionsslider.h b/src/ui/widgets/cclcc/optionsslider.h index 66335c0c..b71bd576 100644 --- a/src/ui/widgets/cclcc/optionsslider.h +++ b/src/ui/widgets/cclcc/optionsslider.h @@ -16,8 +16,12 @@ class OptionsSlider : public OptionsEntry { std::function select); void Render() override; + void Update(float dt) override; void UpdateInput() override; + void Move(glm::vec2 relativePos) override; + void MoveTo(glm::vec2 pos) override; + protected: OptionsSlider(const Sprite& box, const Sprite& label, glm::vec2 pos, glm::vec4 highlightTint, RectF sliderBounds, float sliderSpeed, diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index 00b54e7f..42cd96aa 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -58,6 +58,12 @@ void OptionsVoiceSlider::Render() { Renderer->DrawSprite(BoxSprite, Bounds.GetPos() + VoiceSliderOffset, Tint); } +void OptionsVoiceSlider::Update(float dt) { + OptionsSlider::Update(dt); + + MuteButton.Update(dt); +} + void OptionsVoiceSlider::UpdateInput() { OptionsSlider::UpdateInput(); MuteButton.UpdateInput(); @@ -85,6 +91,17 @@ void OptionsVoiceSlider::Hide() { MuteButton.Hide(); } +void OptionsVoiceSlider::Move(glm::vec2 relativePos) { + OptionsSlider::Move(relativePos); + MuteButton.Move(relativePos); +} + +void OptionsVoiceSlider::MoveTo(glm::vec2 pos) { + const glm::vec2 relativePosition = pos - Bounds.GetPos(); + OptionsSlider::MoveTo(pos); + MuteButton.Move(relativePosition); +} + void OptionsVoiceSlider::MuteButtonOnClick(ClickButton* target) { if (HasFocus) Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.h b/src/ui/widgets/cclcc/optionsvoiceslider.h index 932ba011..ecac36d4 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.h +++ b/src/ui/widgets/cclcc/optionsvoiceslider.h @@ -15,11 +15,15 @@ class OptionsVoiceSlider : public OptionsSlider { glm::vec2 pos, glm::vec4 highlightTint, float sliderSpeed, std::function select); void Render() override; + void Update(float dt) override; void UpdateInput() override; void Show() override; void Hide() override; + void Move(glm::vec2 relativePos) override; + void MoveTo(glm::vec2 pos) override; + private: const Sprite& Portrait; const Sprite& MutedPortrait; From b37507e28567bf07aaaf27052372780659ea49a6 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 21:00:04 +0100 Subject: [PATCH 32/34] Implemented button holding logic for options menu --- profiles/cclcc/hud/optionsmenu.lua | 3 + src/games/cclcc/optionsmenu.cpp | 115 ++++++++++++++++---- src/games/cclcc/optionsmenu.h | 11 +- src/profile/games/cclcc/optionsmenu.cpp | 3 + src/profile/games/cclcc/optionsmenu.h | 3 + src/ui/backlogmenu.cpp | 2 +- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 5 - 7 files changed, 112 insertions(+), 30 deletions(-) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index 72eff68b..e1113c3f 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -72,6 +72,9 @@ root.OptionsMenu = { PortraitSprites = {}, PortraitOffset = { X = 3, Y = 2 }, VoicePosition = { X = 454, Y = 310 }, + + MinButtonHoldTime = 0.5, + ButtonHoldTimeInterval = 0.05, }; root.Sprites["OptionsBackground"] = { diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 9ec48f18..a73bccff 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -177,7 +177,7 @@ void OptionsMenu::Update(float dt) { } if (State != Hidden) { - UpdateInput(); + UpdateInput(dt); Pages.at(CurrentPage)->Update(dt); } @@ -202,7 +202,8 @@ void OptionsMenu::Update(float dt) { } } -void OptionsMenu::UpdateInput() { +void OptionsMenu::UpdatePageInput(float dt) { + // Mouse input for (ClickButton& button : PageButtons) { const bool wasHovered = button.Hovered; button.UpdateInput(); @@ -210,20 +211,97 @@ void OptionsMenu::UpdateInput() { Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); } - // Tab cycling - if (PADinputButtonWentDown & (PAD1L1 | PAD1R1)) { - Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + const bool pagePanelHighlighted = CurrentlyFocusedElement == nullptr; - const bool focusedElement = CurrentlyFocusedElement; - const int direction = (bool)(PADinputButtonWentDown & PAD1R1) - - (bool)(PADinputButtonWentDown & PAD1L1); - GoToPage((CurrentPage + direction) % Pages.size()); + // Button input - if (focusedElement) { - CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); - CurrentlyFocusedElement->HasFocus = true; - } + int direction = + (bool)(PADinputButtonIsDown & + (PAD1R1 | (PAD1DOWN * pagePanelHighlighted))) - + (bool)(PADinputButtonIsDown & (PAD1L1 | (PAD1UP * pagePanelHighlighted))); + + if (direction == 0) { + PageDirectionButtonHeldTime = 0.0f; + PageDirectionButtonWaitTime = 0.0f; + return; + } + + if (0.0f < PageDirectionButtonHeldTime && + PageDirectionButtonHeldTime < MinButtonHoldTime) { + PageDirectionButtonHeldTime += dt; + PageDirectionButtonWaitTime = 0.0f; + return; + } + + if (PageDirectionButtonWaitTime > 0.0f) { + PageDirectionButtonWaitTime -= dt; + return; + } + + // Page advancement fired + + PageDirectionButtonHeldTime += dt; + PageDirectionButtonWaitTime = ButtonHoldTimeInterval; + + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + const bool focusedElement = CurrentlyFocusedElement; + GoToPage((CurrentPage + direction) % Pages.size()); + + if (focusedElement) { + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); + CurrentlyFocusedElement->HasFocus = true; + } +} + +void OptionsMenu::UpdateEntryMovementInput(float dt) { + const int verticalMovement = (bool)(PADinputButtonIsDown & PAD1DOWN) - + (bool)(PADinputButtonIsDown & PAD1UP); + const int horizontalMovement = (bool)(PADinputButtonIsDown & PAD1RIGHT) - + (bool)(PADinputButtonIsDown & PAD1LEFT); + const bool moving = + verticalMovement || (CurrentPage == 3 && horizontalMovement); + + if (!moving) { + DirectionButtonHeldTime = 0.0f; + DirectionButtonWaitTime = 0.0f; + return; + } + + if (0.0f < DirectionButtonHeldTime && + DirectionButtonHeldTime < MinButtonHoldTime) { + DirectionButtonHeldTime += dt; + DirectionButtonWaitTime = 0.0f; + return; + } + + if (DirectionButtonWaitTime > 0.0f) { + DirectionButtonWaitTime -= dt; + return; + } + + // Advance entry + + DirectionButtonHeldTime += dt; + DirectionButtonWaitTime = ButtonHoldTimeInterval; + + const Widget* const lastHighlight = CurrentlyFocusedElement; + if (horizontalMovement != 0) { + const FocusDirection horizontalDirection = + horizontalMovement == -1 ? FDIR_LEFT : FDIR_RIGHT; + AdvanceFocus(horizontalDirection); + } + if (verticalMovement != 0) { + const FocusDirection verticalDirection = + verticalMovement == -1 ? FDIR_UP : FDIR_DOWN; + AdvanceFocus(verticalDirection); } + if (CurrentlyFocusedElement != lastHighlight) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); +} + +void OptionsMenu::UpdateInput(float dt) { + UpdatePageInput(dt); if (CurrentlyFocusedElement == nullptr) { if (GetControlState(CT_Back)) { @@ -234,13 +312,6 @@ void OptionsMenu::UpdateInput() { return; } - const int direction = (bool)(PADinputButtonWentDown & PAD1DOWN) - - (bool)(PADinputButtonWentDown & PAD1UP); - if (direction) { - Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); - GoToPage((CurrentPage + direction) % Pages.size()); - } - if (PADinputButtonWentDown & PAD1A) { // Don't have anything else consume the confirmation PADinputButtonWentDown &= ~PAD1A; @@ -265,9 +336,7 @@ void OptionsMenu::UpdateInput() { return; } - Menu::UpdateInput(); - if (PADinputButtonWentDown & (PAD1DOWN | PAD1UP)) - Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + UpdateEntryMovementInput(dt); } void OptionsMenu::Render() { diff --git a/src/games/cclcc/optionsmenu.h b/src/games/cclcc/optionsmenu.h index 830b3839..96b84543 100644 --- a/src/games/cclcc/optionsmenu.h +++ b/src/games/cclcc/optionsmenu.h @@ -19,7 +19,7 @@ class OptionsMenu : public Menu { void Show() override; void Hide() override; void Update(float dt) override; - void UpdateInput() override; + void UpdateInput(float dt); void Render() override; private: @@ -27,6 +27,9 @@ class OptionsMenu : public Menu { void Select(OptionsEntry* entry); void PageButtonOnClick(Widgets::ClickButton* target); + void UpdatePageInput(float dt); + void UpdateEntryMovementInput(float dt); + Animation FadeAnimation; SpriteAnimation PoleAnimation; @@ -38,6 +41,12 @@ class OptionsMenu : public Menu { int CurrentPage; std::vector Pages; std::vector PageButtons; + + float DirectionButtonHeldTime = 0.0f; + float DirectionButtonWaitTime = 0.0f; + + float PageDirectionButtonHeldTime = 0.0f; + float PageDirectionButtonWaitTime = 0.0f; }; } // namespace CCLCC diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 73c26f20..005178c3 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -73,6 +73,9 @@ void Configure() { PortraitOffset = EnsureGetMemberVec2("PortraitOffset"); VoicePosition = EnsureGetMemberVec2("VoicePosition"); + MinButtonHoldTime = EnsureGetMemberFloat("MinButtonHoldTime"); + ButtonHoldTimeInterval = EnsureGetMemberFloat("ButtonHoldTimeInterval"); + auto drawType = Game::DrawComponentType::_from_integral_unchecked( EnsureGetMemberInt("DrawType")); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 66cfaafc..76192d33 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -71,6 +71,9 @@ inline Sprite PortraitSprites[PortraitCount]; inline glm::vec2 PortraitOffset; inline glm::vec2 VoicePosition; +inline float MinButtonHoldTime; +inline float ButtonHoldTimeInterval; + void Configure(); } // namespace OptionsMenu diff --git a/src/ui/backlogmenu.cpp b/src/ui/backlogmenu.cpp index 3e73ea56..035a1abb 100644 --- a/src/ui/backlogmenu.cpp +++ b/src/ui/backlogmenu.cpp @@ -172,7 +172,7 @@ void BacklogMenu::UpdateScrollingInput(float dt) { if (!padScrolling) { DirectionalButtonHeldTime = 0.0f; return; - }; + } FocusDirection dir = (PADinputButtonIsDown & PAD1DOWN) ? FDIR_DOWN : FDIR_UP; diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index 42cd96aa..9c47d02b 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -74,11 +74,6 @@ void OptionsVoiceSlider::UpdateInput() { Muted = !Muted; Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); } - - if ((bool)(PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) && - !(bool)(PADinputButtonWentDown & (PAD1UP | PAD1DOWN))) { - Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); - } } void OptionsVoiceSlider::Show() { From 1168b347b42d08aa727e59d44e1c1136b889405f Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 21:11:35 +0100 Subject: [PATCH 33/34] Added menu mask overlay to config menu --- profiles/cclcc/hud/optionsmenu.lua | 7 +++++++ src/games/cclcc/optionsmenu.cpp | 9 +++++++++ src/profile/games/cclcc/optionsmenu.cpp | 2 ++ src/profile/games/cclcc/optionsmenu.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/profiles/cclcc/hud/optionsmenu.lua b/profiles/cclcc/hud/optionsmenu.lua index e1113c3f..ad6c0800 100644 --- a/profiles/cclcc/hud/optionsmenu.lua +++ b/profiles/cclcc/hud/optionsmenu.lua @@ -75,6 +75,8 @@ root.OptionsMenu = { MinButtonHoldTime = 0.5, ButtonHoldTimeInterval = 0.05, + + MenuMask = "MenuMask", }; root.Sprites["OptionsBackground"] = { @@ -152,6 +154,11 @@ root.Sprites["OptionsVoiceGuide"] = { Bounds = { X = 0, Y = 2416, Width = 1926, Height = 57 } }; +root.Sprites["MenuMask"] = { + Sheet = "MenuChip", + Bounds = { X = 154, Y = 140, Width = 1900, Height = 1061 }, +}; + for i = 0, 3 do height = 80; diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index a73bccff..03333cce 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -1,5 +1,6 @@ #include "optionsmenu.h" +#include "../../profile/game.h" #include "../../profile/ui/optionsmenu.h" #include "../../profile/games/cclcc/optionsmenu.h" #include "../../profile/scriptinput.h" @@ -344,6 +345,9 @@ void OptionsMenu::Render() { ScrWork[SW_SYSSUBMENUNO] == 5) { glm::vec4 col(1.0f, 1.0f, 1.0f, FadeAnimation.Progress); + glm::vec4 maskTint = col; + maskTint.a *= (float)0xa0 / 0x100; + const glm::vec2 backgroundAnimationOffset = glm::vec2(0.0f, FadeAnimation.Progress * BackgroundPosition.y + (1.0f - FadeAnimation.Progress) * @@ -378,6 +382,11 @@ void OptionsMenu::Render() { } } + Renderer->DrawSprite( + MenuMaskSprite, + RectF(0.0f, 0.0f, Profile::DesignWidth, Profile::DesignHeight), + maskTint); + const Sprite& guideSprite = CurrentPage == 3 ? VoiceGuideSprite : GuideSprite; Renderer->DrawSprite(guideSprite, guidePosition, col); diff --git a/src/profile/games/cclcc/optionsmenu.cpp b/src/profile/games/cclcc/optionsmenu.cpp index 005178c3..bc9805aa 100644 --- a/src/profile/games/cclcc/optionsmenu.cpp +++ b/src/profile/games/cclcc/optionsmenu.cpp @@ -76,6 +76,8 @@ void Configure() { MinButtonHoldTime = EnsureGetMemberFloat("MinButtonHoldTime"); ButtonHoldTimeInterval = EnsureGetMemberFloat("ButtonHoldTimeInterval"); + MenuMaskSprite = EnsureGetMemberSprite("MenuMask"); + auto drawType = Game::DrawComponentType::_from_integral_unchecked( EnsureGetMemberInt("DrawType")); diff --git a/src/profile/games/cclcc/optionsmenu.h b/src/profile/games/cclcc/optionsmenu.h index 76192d33..7db6b6f3 100644 --- a/src/profile/games/cclcc/optionsmenu.h +++ b/src/profile/games/cclcc/optionsmenu.h @@ -74,6 +74,8 @@ inline glm::vec2 VoicePosition; inline float MinButtonHoldTime; inline float ButtonHoldTimeInterval; +inline Sprite MenuMaskSprite; + void Configure(); } // namespace OptionsMenu From 4e40f8bf4a67cf7cd9818c3e8c382c3d3ff6da33 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 21:24:41 +0100 Subject: [PATCH 34/34] Fixed options menu sometimes getting stuck upon quick reentry --- src/games/cclcc/optionsmenu.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 03333cce..f36e8892 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -165,8 +165,6 @@ void OptionsMenu::Hide() { } void OptionsMenu::Update(float dt) { - const bool wasAnimating = !FadeAnimation.IsOut() && !FadeAnimation.IsIn(); - FadeAnimation.Update(dt); PoleAnimation.Update(dt); if (ScrWork[SW_SYSSUBMENUCT] < 32 && State == Shown && @@ -192,14 +190,16 @@ void OptionsMenu::Update(float dt) { if (FadeAnimation.IsIn()) { State = Shown; Pages.at(CurrentPage)->MoveTo(glm::vec2(0.0f, BackgroundPosition.y)); - } else if (wasAnimating && FadeAnimation.IsOut()) { - State = Hidden; - - Pages.at(CurrentPage)->Hide(); - CurrentPage = 0; - CurrentlyFocusedElement = nullptr; + } else if (State == Hiding && FadeAnimation.IsOut()) { + if (ScrWork[SW_SYSSUBMENUCT] == 0) { + State = Hidden; - SetFlag(SF_SUBMENUEXIT, true); + Pages.at(CurrentPage)->Hide(); + CurrentPage = 0; + CurrentlyFocusedElement = nullptr; + } else { + SetFlag(SF_SUBMENUEXIT, true); + } } }