diff --git a/assets/Settings.bsml b/assets/Settings.bsml index fca0948..d84a45f 100644 --- a/assets/Settings.bsml +++ b/assets/Settings.bsml @@ -1,4 +1,4 @@ - + @@ -8,7 +8,11 @@ - - + + + + + + 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; +}