From 3d59dece82cfbf8db515f221e8e7fb38eef2dfe7 Mon Sep 17 00:00:00 2001 From: CatsaCode Date: Thu, 1 May 2025 21:57:48 -0400 Subject: [PATCH 1/2] Add brightness and opacity settings Added a configuration option and UI sliders to adjust what color is applied to the image cover. The default color with 0.5 brightness and 0.8 opacity was a little too visible in my opinion. Some of the info could be hard to read, and having the play buttons disabled if a requirement was missing looked especially odd. Yes I could have just changed the color value to look better, but, I love customizability so I've added settings. Very much up to @vcmikuu if this change seems useful. --- assets/Settings.bsml | 8 ++++++++ include/UI/Settings.hpp | 2 ++ include/config.hpp | 2 ++ src/main.cpp | 7 ++++++- src/ui/Settings.cpp | 34 +++++++++++++++++++++++++++++++++- 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/assets/Settings.bsml b/assets/Settings.bsml index fca0948..f3b0ae6 100644 --- a/assets/Settings.bsml +++ b/assets/Settings.bsml @@ -8,6 +8,14 @@ + + + + + + + + diff --git a/include/UI/Settings.hpp b/include/UI/Settings.hpp index eeff575..47ff180 100644 --- a/include/UI/Settings.hpp +++ b/include/UI/Settings.hpp @@ -14,4 +14,6 @@ DECLARE_CLASS_CODEGEN(ImageCoverExpander::UI, Settings, HMUI::ViewController){ DECLARE_INSTANCE_FIELD(TMPro::TextMeshProUGUI*, versionText); DECLARE_BSML_PROPERTY(bool, enabledValue); + DECLARE_BSML_PROPERTY(float, brightnessValue); + DECLARE_BSML_PROPERTY(float, opacityValue); }; diff --git a/include/config.hpp b/include/config.hpp index 8d37ed6..c4012d1 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -4,4 +4,6 @@ DECLARE_CONFIG(ModConfig) { CONFIG_VALUE(Active, bool, "Enable the Mod", true); + CONFIG_VALUE(Brightness, float, "Brightness of the cover", 0.5); + CONFIG_VALUE(Opacity, float, "Opacity of the cover", 0.8); }; diff --git a/src/main.cpp b/src/main.cpp index 2545d41..6e8bde1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -135,7 +135,12 @@ MAKE_LATE_HOOK_MATCH( // Get the ImageView component of the image cover and set its properties auto* imageView = imageCoverTransform->GetComponent(); - imageView->set_color(Color(0.5, 0.5, 0.5, 1)); + imageView->set_color(Color( + getModConfig().Brightness.GetValue(), + getModConfig().Brightness.GetValue(), + getModConfig().Brightness.GetValue(), + getModConfig().Opacity.GetValue() + )); imageView->set_preserveAspect(false); imageView->_skew = 0.0f; diff --git a/src/ui/Settings.cpp b/src/ui/Settings.cpp index 04587e7..3dcc2ce 100644 --- a/src/ui/Settings.cpp +++ b/src/ui/Settings.cpp @@ -18,6 +18,8 @@ using namespace ImageCoverExpander; // Global variables to track settings updates and original enabled value bool updatedSettings = false; bool originalEnabledValue = false; +float originalBrightnessValue = 0.0; +float originalOpacityValue = 0.0; // Method called when the view is activated void ImageCoverExpander::UI::Settings::DidActivate(bool firstActivation, bool addedToHeirarchy, bool screenSystemDisabling) { @@ -31,6 +33,8 @@ void ImageCoverExpander::UI::Settings::DidActivate(bool firstActivation, bool ad // Initialize settings state updatedSettings = false; originalEnabledValue = get_enabledValue(); + originalBrightnessValue = get_brightnessValue(); + originalOpacityValue = get_opacityValue(); versionText->text = GIT_VERSION; // Uncomment the following lines for hot reload functionality @@ -44,9 +48,13 @@ void ImageCoverExpander::UI::Settings::DidActivate(bool firstActivation, bool ad void ImageCoverExpander::UI::Settings::DidDeactivate(bool removedFromHierarchy, bool screenSystemDisabling) { if (updatedSettings) { auto mfc = GetMainFlowCoordinator(); + if(!mfc) return; // Restart the game if the enabled value has changed - if (mfc && originalEnabledValue != get_enabledValue()) { + if (originalEnabledValue != get_enabledValue() || + originalBrightnessValue != get_brightnessValue() || + originalOpacityValue != get_opacityValue() + ) { mfc->_menuTransitionsHelper->RestartGame(nullptr); } } @@ -63,3 +71,27 @@ void ImageCoverExpander::UI::Settings::set_enabledValue(bool value) { updatedSettings = true; } + +// Get the current brightness value from the mod configuration +float ImageCoverExpander::UI::Settings::get_brightnessValue() { + return getModConfig().Brightness.GetValue(); +} + +// Set the brightness value in the mod configuration and mark settings as updated +void ImageCoverExpander::UI::Settings::set_brightnessValue(float value) { + getModConfig().Brightness.SetValue(value); + + updatedSettings = true; +} + +// Get the current opacity value from the mod configuration +float ImageCoverExpander::UI::Settings::get_opacityValue() { + return getModConfig().Opacity.GetValue(); +} + +// Set the opacity value in the mod configuration and mark settings as updated +void ImageCoverExpander::UI::Settings::set_opacityValue(float value) { + getModConfig().Opacity.SetValue(value); + + updatedSettings = true; +} From 244a04939ba0f114f89e8b91eeddeb041fd7d263 Mon Sep 17 00:00:00 2001 From: CatsaCode Date: Thu, 1 May 2025 22:05:37 -0400 Subject: [PATCH 2/2] Fix spacing in UI Removed the panel-bottom background element and added an anchor-pos-y offset to move everything back in place. The backgrounds, as far as I can tell, don't load properly and therefore serve no purpose other than to mess up alignment. This commit is out of the scope of the original PR, please comment if I've introduced a new bug that I can't see. --- assets/Settings.bsml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/assets/Settings.bsml b/assets/Settings.bsml index f3b0ae6..d84a45f 100644 --- a/assets/Settings.bsml +++ b/assets/Settings.bsml @@ -1,4 +1,4 @@ - + @@ -15,8 +15,4 @@ - - - -