Skip to content

Commit

Permalink
[skip ci] change bg on button click
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryotechnic committed Aug 25, 2024
1 parent 02d9631 commit 2b3b850
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using CommunityToolkit.WinUI.Animations;
using H.NotifyIcon;
using Hi3Helper;
using Hi3Helper.Data;
using Hi3Helper.EncTool.WindowTool;
using Hi3Helper.Screen;
using Hi3Helper.Shared.ClassStruct;
Expand Down Expand Up @@ -1919,15 +1920,21 @@ public bool UseCustomBGRegion
get => ((IGameSettingsUniversal)CurrentGameProperty._GameSettings).SettingsCollapseMisc.UseCustomRegionBG;
set
{
if (UseCustomBGParamsSwitch.IsOn)
if (value)
{
ChangeGameBGButton.IsEnabled = true;
SetAndSaveConfigValue("UseCustomBG", new IniValue(true));
}
else
{
ChangeGameBGButton.IsEnabled = false;
SetAndSaveConfigValue("UseCustomBG", new IniValue(false));
}

string CustomBGParam = value ? "CustomBGPath" : "CurrentBackground";
((IGameSettingsUniversal)CurrentGameProperty._GameSettings).SettingsCollapseMisc.UseCustomRegionBG = value;
LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal = GetAppConfigValue(CustomBGParam).ToString();
BackgroundImgChanger.ChangeBackground(LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal, null, true, true);
}
}
#endregion
Expand Down Expand Up @@ -2156,8 +2163,9 @@ private async void ChangeGameBGButton_Click(object sender, RoutedEventArgs e)

LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal = file;
SetAndSaveConfigValue("CustomBGPath", file);
LogWriteLine("Wrote " + GetAppConfigValue("UseCustomBG").ToBool() + "to config", LogType.Debug, false);
BackgroundImgChanger.ChangeBackground(LauncherMetadataHelper.CurrentMetadataConfig.GameLauncherApi.GameBackgroundImgLocal, null, true, true);
// await SimpleDialogs.Dialog_QuickSettingsChangeBG(this);
}
}

Expand Down
1 change: 1 addition & 0 deletions CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ private bool IsBGCustom
{
bool isEnabled = GetAppConfigValue("UseCustomBG").ToBool();
string BGPath = GetAppConfigValue("CustomBGPath").ToString();
LogWriteLine("Read " + isEnabled + " BG Path: " + BGPath + " from config", LogType.Debug, false);
if (!string.IsNullOrEmpty(BGPath))
BGPathDisplay.Text = BGPath;
else
Expand Down

0 comments on commit 2b3b850

Please sign in to comment.