Skip to content

Commit

Permalink
Dev Commit
Browse files Browse the repository at this point in the history
Setting's "Other" tab are now functional.
  • Loading branch information
IchimakiKasura committed Jun 18, 2023
1 parent 77d306d commit 856657b
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void AppMinimizeToTray()
{
HoyoWindow.WindowState = WindowState.Minimized;

if(AppSettings.Settings.Default.MinimizedTray is false) return;
if(AppSettings.Settings.Default.CHECKBOX_MINIMIZE_TRAY is false) return;

HoyoWindow.ShowInTaskbar = false;
HoyoWindow.Hide();
Expand Down
6 changes: 5 additions & 1 deletion src/HoyoLauncher.Core/HoyoMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public static void Initialize()
ValidateSettings(AppSettings.Settings.Default.HONKAI_STAR_RAIL_DIR, HoyoGames.HonkaiStarRail, HoyoWindow.HONKAI_STAR_RAIL_LAUNCHER, out bool _);
ValidateSettings(AppSettings.Settings.Default.HONKAI_IMPACT_THIRD_DIR, HoyoGames.HonkaiImpactThird, HoyoWindow.HONKAI_IMPACT_THIRD_LAUNCHER, out bool _);

LastGame();
if (!AppSettings.Settings.Default.CHECKBOX_BACKGROUND)
HoyoWindow.MediaElementBG.Source = null;

if(AppSettings.Settings.Default.CHECKBOX_LASTGAME)
LastGame();
}

public static void GameChange(string uid) =>
Expand Down
244 changes: 237 additions & 7 deletions src/HoyoLauncherSettings/HoyoSettings.xaml

Large diffs are not rendered by default.

61 changes: 41 additions & 20 deletions src/HoyoLauncherSettings/HoyoSettings.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
namespace HoyoLauncher.HoyoLauncherSettings;
using HoyoLauncher.HoyoLauncherSettings.Settings.OthersTab;

namespace HoyoLauncher.HoyoLauncherSettings;

public partial class HoyoSettings : Window
{
public static HoyoSettings _hoyosettings;

readonly Brush SelectedPageColor = new BrushConverter().ConvertFromString("#f6f5f3") as Brush;
readonly Brush UnSelectedPageColor = new BrushConverter().ConvertFromString("#e3e1de") as Brush;

public HoyoSettings()
{
InitializeComponent();
_hoyosettings = this;

VERSION.Text = App.Version;
BUILDHASH.Text = $"({App.UniqueHashBUILD})";
Tooltip_Text.Text = "";

HoyoWindow.BLACK_THING.Opacity = 0.5;

WindowDrag.MouseDown += (s, e) => { if (e.ChangedButton is MouseButton.Left) DragMove(); };
ExitButton.Click += (s, e) => Close();
CancelButton.Click += (s, e) => Close();

RadioButtonTray.IsChecked = AppSettings.Settings.Default.MinimizedTray;
HoyoTooltips.SetToolTips();
HoyoRadioButtons.SetRadioButtons();

RadioButtonTray_Click.MouseDown += (s, e) =>
foreach (var btn in new List<Border>{ Button_Locations, Button_Others, Button_About })
{
if (e.ChangedButton is MouseButton.Left)
AppSettings.Settings.Default.MinimizedTray = (bool)(RadioButtonTray.IsChecked = !RadioButtonTray.IsChecked);
};
btn.MouseEnter += (s,e) => ((TextBlock)btn.Child).Foreground = (Brush)new BrushConverter().ConvertFromString("#f4cb99");
btn.MouseLeave += (s,e) =>
{
if(btn.Background.ToString() == "#FFF6F5F3")
((TextBlock)btn.Child).Foreground = (Brush)new BrushConverter().ConvertFromString("#997f5f");
else ((TextBlock)btn.Child).Foreground = Brushes.Black;
};
}
}

private void OnLoaded(object sender, RoutedEventArgs e)
Expand All @@ -48,15 +59,9 @@ void LocationButtonClick(object s, RoutedEventArgs e)

switch(((Button)e.Source).Name)
{
case "GI_LOCATE":
textBox = GI_DIR_TXT;
break;
case "HSR_LOCATE":
textBox = HSR_DIR_TXT;
break;
case "HI3_LOCATE":
textBox = HI3_DIR_TXT;
break;
case "GI_LOCATE": textBox = GI_DIR_TXT; break;
case "HSR_LOCATE": textBox = HSR_DIR_TXT; break;
case "HI3_LOCATE": textBox = HI3_DIR_TXT; break;
}
e.Handled = true;

Expand Down Expand Up @@ -103,16 +108,14 @@ void ConfirmClick(object s, RoutedEventArgs e)
// lmao "List" was unnecessary but i like chaos
void ChangePageClick(object s, MouseButtonEventArgs e)
{
var sButton = ((Border)e.Source);
List<Canvas> pages = new() { Locations, Others, About };
List<Border> buttons = new() { Button_Locations, Button_Others, Button_About };
var sButton = (Border)e.Source;

if (e.ChangedButton is not MouseButton.Left) return;

foreach (var page in pages)
foreach (var page in new List<Canvas>{ Locations, Others, About })
page.Visibility = Visibility.Hidden;

foreach (var button in buttons)
foreach (var button in new List<Border>{ Button_Locations, Button_Others, Button_About })
{
((TextBlock)button.Child).Foreground = Brushes.Black;
button.Background = UnSelectedPageColor;
Expand All @@ -129,6 +132,24 @@ void ChangePageClick(object s, MouseButtonEventArgs e)
}
}

void ResetLocationButtonClick(object s, RoutedEventArgs e)
{
GI_DIR_TXT.Text = "";
HSR_DIR_TXT.Text = "";
HI3_DIR_TXT.Text = "";
}

void ResetSettingsButtonClick(object s, RoutedEventArgs e)
{
AppSettings.Settings.Default.Reset();
GI_DIR_TXT.Text = AppSettings.Settings.Default.GENSHIN_IMPACT_DIR;
HSR_DIR_TXT.Text = AppSettings.Settings.Default.HONKAI_STAR_RAIL_DIR;
HI3_DIR_TXT.Text = AppSettings.Settings.Default.HONKAI_IMPACT_THIRD_DIR;
RadioButtonTray.IsChecked = AppSettings.Settings.Default.CHECKBOX_MINIMIZE_TRAY;
RadioButtonBackground.IsChecked = AppSettings.Settings.Default.CHECKBOX_BACKGROUND;
RadioButtonSelectiveStartup.IsChecked = AppSettings.Settings.Default.CHECKBOX_LASTGAME;
}

static void RefreshCurrentSelectedGame()
{
if(HoyoMain.CurrentGameSelected != HoyoGames.DEFAULT)
Expand Down
35 changes: 35 additions & 0 deletions src/HoyoLauncherSettings/Settings.OthersTab/RadioButtons.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using static HoyoLauncher.HoyoLauncherSettings.HoyoSettings;

namespace HoyoLauncher.HoyoLauncherSettings.Settings.OthersTab;
sealed class HoyoRadioButtons
{
// kinda messed up but it'll work, just need some better coding; ref wont work on the AppSettings.Settings.Default
public static void SetRadioButtons()
{
_hoyosettings.RadioButtonTray.IsChecked = AppSettings.Settings.Default.CHECKBOX_MINIMIZE_TRAY;
_hoyosettings.RadioButtonBackground.IsChecked = AppSettings.Settings.Default.CHECKBOX_BACKGROUND;
_hoyosettings.RadioButtonSelectiveStartup.IsChecked = AppSettings.Settings.Default.CHECKBOX_LASTGAME;

_hoyosettings.RadioButtonTray_Click.MouseDown += (s, e) =>
SetSettingsValue(e, () =>
{
AppSettings.Settings.Default.CHECKBOX_MINIMIZE_TRAY = (bool)(_hoyosettings.RadioButtonTray.IsChecked = !_hoyosettings.RadioButtonTray.IsChecked);
});
_hoyosettings.RadioButtonBackground_Click.MouseDown += (s, e) =>
SetSettingsValue(e, () =>
{
AppSettings.Settings.Default.CHECKBOX_BACKGROUND = (bool)(_hoyosettings.RadioButtonBackground.IsChecked = !_hoyosettings.RadioButtonBackground.IsChecked);
});
_hoyosettings.RadioButtonSelectiveStartup_Click.MouseDown += (s, e) =>
SetSettingsValue(e, () =>
{
AppSettings.Settings.Default.CHECKBOX_LASTGAME = (bool)(_hoyosettings.RadioButtonSelectiveStartup.IsChecked = !_hoyosettings.RadioButtonSelectiveStartup.IsChecked);
});
}

static void SetSettingsValue(MouseButtonEventArgs e, Action action)
{
if (e.ChangedButton is MouseButton.Left)
action();
}
}
34 changes: 34 additions & 0 deletions src/HoyoLauncherSettings/Settings.OthersTab/Tooltips.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using static HoyoLauncher.HoyoLauncherSettings.HoyoSettings;

namespace HoyoLauncher.HoyoLauncherSettings.Settings.OthersTab;
sealed class HoyoTooltips
{
public static void SetToolTips()
{
_hoyosettings.RadioButtonTray_Click.MouseEnter += ShowTooltip;
_hoyosettings.RadioButtonBackground_Click.MouseEnter += ShowTooltip;
_hoyosettings.RadioButtonSelectiveStartup_Click.MouseEnter += ShowTooltip;

_hoyosettings.Button_ClearLocationTexts.MouseEnter += ShowTooltip;
_hoyosettings.Button_ResetSettings.MouseEnter += ShowTooltip;

_hoyosettings.Funni.MouseEnter += ShowTooltip;


_hoyosettings.RadioButtonTray_Click.MouseLeave += RemoveTooltip;
_hoyosettings.RadioButtonBackground_Click.MouseLeave += RemoveTooltip;
_hoyosettings.RadioButtonSelectiveStartup_Click.MouseLeave += RemoveTooltip;

_hoyosettings.Button_ClearLocationTexts.MouseLeave += RemoveTooltip;
_hoyosettings.Button_ResetSettings.MouseLeave += RemoveTooltip;

_hoyosettings.Funni.MouseLeave += RemoveTooltip;
}

static void ShowTooltip(object s, MouseEventArgs e) =>
_hoyosettings.Tooltip_Text.Text = ((UIElement)s).Uid;

static void RemoveTooltip(object s, MouseEventArgs e) =>
_hoyosettings.Tooltip_Text.Text = "";

}
30 changes: 27 additions & 3 deletions src/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
<Setting Name="LAST_GAME" Type="System.Int16" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="MinimizedTray" Type="System.Boolean" Scope="User">
<Setting Name="CHECKBOX_MINIMIZE_TRAY" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="FIRSTRUN" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CHECKBOX_BACKGROUND" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="CHECKBOX_LASTGAME" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 856657b

Please sign in to comment.