Skip to content

Commit

Permalink
Dev Commit | Bug fixes
Browse files Browse the repository at this point in the history
[ Fixes ]
- Fixed where an Invalid game selected like
Genshin Impact Location was set on a Honkai Star Rail Location.
Even it throws an error, when switching to HSR game it will show the Genshin.

- Fixed where the Settings Window is not Draggable.

[ Changes ]
- Settings "Others" tab changes.
- Genshin and HSR default background size reduced.
  • Loading branch information
IchimakiKasura committed Jun 17, 2023
1 parent 948291d commit 77d306d
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 46 deletions.
4 changes: 3 additions & 1 deletion src/HoyoLauncher.Core/Config/ConfigRead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public sealed class ConfigRead
public string GameInstallPath { get; private set; }
public string GameBackgroundName { get; private set; }
public string GameStartName { get; private set; }
public string GameName { get ; private set; }
public ImageBrush GameBackground { get; private set; }

public static ConfigRead GetConfig(string FilePath)
Expand Down Expand Up @@ -62,7 +63,8 @@ public static ConfigRead GetConfig(string FilePath)
GameInstallPath = gamepath,
GameBackgroundName = Path.Combine(FilePath, "bg", gamebg),
GameStartName = Path.Combine(gamepath, gamename),
GameBackground = GameBG_TEMP
GameBackground = GameBG_TEMP,
GameName = gamename
};
}
}
5 changes: 3 additions & 2 deletions src/HoyoLauncher.Core/HoyoMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ public static void GameChange(short uid)
values.LaunchButton = false;
values.LaunchButtonContent = AppResources.Resources.GAME_SOON_TEXT;
}
else if(!GameConfig.ConfigExist)
else if(!GameConfig.ConfigExist || GameConfig.GameName != CurrentGameSelected.GAME_EXECUTABLE)
{
values.LaunchButton = false;
values.Background = CurrentGameSelected.GAME_DEFAULT_BG;
values.LaunchButtonContent = AppResources.Resources.GAME_NOTFOUND;
}

if(IsGameRunning)
if (IsGameRunning)
{
values.LaunchButton = false;
values.LaunchButtonContent = AppResources.Resources.GAME_LAUNCHED_TEXT;
Expand Down
56 changes: 40 additions & 16 deletions src/HoyoLauncherSettings/HoyoSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,70 @@
</Grid>
</Border>

<Grid>
<Border Name="Button_Location" Background="#f6f5f3" Margin="40,101,660,390" CornerRadius="10,10,0,0">
<TextBlock Text="Locations" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
<Grid Mouse.MouseDown="ChangePageClick">
<Border Name="Button_Locations" Background="#f6f5f3" Margin="40,101,660,390" CornerRadius="10,10,0,0">
<TextBlock Foreground="#997f5f" IsHitTestVisible="False" Text="Locations" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
</Border>
<Border Name="Button_Others" Background="#e3e1de" Margin="161,101,539,390" CornerRadius="10,10,0,0">
<TextBlock Text="Others" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
<TextBlock IsHitTestVisible="False" Text="Others" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
</Border>
<Border Name="Button_About" Background="#e3e1de" Margin="282,101,418,390" CornerRadius="10,10,0,0">
<TextBlock Text="About" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
<TextBlock IsHitTestVisible="False" Text="About" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontFamily="Segoe ui"/>
</Border>
</Grid>

<Border Background="#f6f5f3" Margin="30,130,30,80" CornerRadius="10">
<Grid>
<Canvas Name="Locations" Visibility="Visible">
<TextBlock Text="Genshin Impact Location: " FontSize="20" FontWeight="SemiBold" Margin="10,11,10,299"/>
<Canvas Name="Locations" Visibility="Visible" ButtonBase.Click="LocationButtonClick">
<TextBlock Text="Genshin Impact Location: " FontSize="20" FontWeight="SemiBold" Canvas.Left="18" Canvas.Top="14" HorizontalAlignment="Center" VerticalAlignment="Top"/>
<TextBox Name="GI_DIR_TXT" Style="{StaticResource TextBoxStyle}" IsReadOnly="True" Canvas.Left="29" Canvas.Top="46" Width="564"/>
<Button Name="GI_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" Click="GenshinClick" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="46" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>
<Button Name="GI_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="46" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>

<TextBlock Text="Honkai Star Rail Location: " FontSize="20" FontWeight="SemiBold" Margin="10,81,10,229"/>
<TextBlock Text="Honkai Star Rail Location: " FontSize="20" FontWeight="SemiBold" HorizontalAlignment="Center" Canvas.Left="18" Canvas.Top="84" VerticalAlignment="Top"/>
<TextBox Name="HSR_DIR_TXT" Style="{StaticResource TextBoxStyle}" IsReadOnly="True" Canvas.Left="29" Canvas.Top="116" Width="564"/>
<Button Name="HSR_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" Click="HSRClick" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="116" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>
<Button Name="HSR_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="116" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>

<TextBlock Text="Honkai Impact 3rd Location: " FontSize="20" FontWeight="SemiBold" Margin="10,151,10,159"/>
<TextBlock Text="Honkai Impact 3rd Location: " FontSize="20" FontWeight="SemiBold" HorizontalAlignment="Center" Canvas.Left="18" Canvas.Top="154" VerticalAlignment="Top"/>
<TextBox Name="HI3_DIR_TXT" Style="{StaticResource TextBoxStyle}" IsReadOnly="True" Canvas.Left="29" Canvas.Top="186" Width="564"/>
<Button Name="HI3_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" Click="HI3Click" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="186" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>
<Button Name="HI3_LOCATE" Content="Open Folder" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Black" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="186" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>

<TextBlock Text="Zenless Zone Zero Location: " FontSize="20" FontWeight="SemiBold" Margin="10,221,10,89"/>
<TextBlock Text="Zenless Zone Zero Location: " FontSize="20" FontWeight="SemiBold" HorizontalAlignment="Center" Canvas.Left="18" Canvas.Top="224" VerticalAlignment="Top"/>
<TextBox x:Name="ZZZ_DIR_TXT" Text="Unavailable" Style="{StaticResource TextBoxStyle}" HorizontalContentAlignment="Center" IsReadOnly="True" Canvas.Left="29" Canvas.Top="256" Width="564"/>
<Button Name="ZZZ_LOCATE" Content="Open Folder" IsEnabled="False" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="Gray" FontSize="14" BorderThickness="2" Height="29" Canvas.Left="611" Canvas.Top="256" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132"/>
</Canvas>

<Canvas Name="Others" Visibility="Hidden" Margin="20">
<Border Name="RadioButtonTray_Click" Cursor="Hand" Background="Transparent" Height="26" Width="164">
<RadioButton Name="RadioButtonTray" IsHitTestVisible="False" Content="Minimize to Tray" Margin="0,0,55,9">

<Border Background="#e3e1de" HorizontalAlignment="Left" Height="270" VerticalAlignment="Center" Width="360" Canvas.Left="360" CornerRadius="10" Padding="15">
<TextBlock Name="Tooltip_Text" Text="[TOOL TIP TEXT MESSAGES | INFO ]" FontSize="20" TextWrapping="Wrap"/>
</Border>

<Border Name="RadioButtonTray_Click" Cursor="Hand" Background="Transparent" Height="26" Width="164" HorizontalAlignment="Center" Canvas.Top="24" VerticalAlignment="Top" Canvas.Left="31">
<RadioButton Name="RadioButtonTray" IsHitTestVisible="False" Content="Minimize to Tray" Margin="-20,0,75,9">
<RadioButton.RenderTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
</RadioButton.RenderTransform>
</RadioButton>
</Border>

<Border Name="RadioButtonBackground_Click" Cursor="Hand" Background="Transparent" Height="26" Width="233" HorizontalAlignment="Left" Canvas.Top="65" VerticalAlignment="Center" Canvas.Left="11">
<RadioButton Name="RadioButtonBackground" IsHitTestVisible="False" Content="Enable Background Video" Margin="0,0,55,9">
<RadioButton.RenderTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
</RadioButton.RenderTransform>
</RadioButton>
</Border>

<Border Name="RadioButtonSelectiveStartup_Click" Cursor="Hand" Background="Transparent" Height="26" Width="301" HorizontalAlignment="Left" Canvas.Top="106" VerticalAlignment="Center" Canvas.Left="11">
<RadioButton Name="RadioButtonSelectiveStartup" IsHitTestVisible="False" Content="Enable Last Game Played on Start" Margin="0,0,55,9">
<RadioButton.RenderTransform>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
</RadioButton.RenderTransform>
</RadioButton>
</Border>

<Button Content="Clear Locations" Style="{StaticResource MainButton}" BorderBrush="Gray" Foreground="#997f5f" FontSize="14" BorderThickness="2" Height="29" Canvas.Top="241" HorizontalAlignment="Left" VerticalAlignment="Center" Width="132" Canvas.Left="11"/>

</Canvas>

<Canvas Name="About" Visibility="Hidden">
Expand All @@ -87,7 +111,7 @@
<LineBreak/>
<Hyperlink Click="GithubPR">Contribute on the Project</Hyperlink>
</TextBlock>
<Image Source="/Resources/HoyoVerseIcon.png" Stretch="Fill" Cursor="Hand" Height="130" Width="130" Canvas.Top="-2" HorizontalAlignment="Center" VerticalAlignment="Top"/>
<Image Source="/Resources/HoyoVerseIcon.png" Stretch="Fill" Height="130" Width="130" Canvas.Top="-2" HorizontalAlignment="Center" VerticalAlignment="Top"/>
<Image Source="/Resources/github.png" MouseDown="GithubIconButton" Stretch="Fill" Cursor="Hand" Height="40" Canvas.Left="508" Width="40" Canvas.Top="252" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Canvas>
</Grid>
Expand Down
68 changes: 42 additions & 26 deletions src/HoyoLauncherSettings/HoyoSettings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public partial class HoyoSettings : Window
{

// Hear me out, I'm kinda lazy when making the Button_Location etc.. so fuck the mess
readonly Brush SelectedPageColor = new BrushConverter().ConvertFromString("#f6f5f3") as Brush;
readonly Brush UnSelectedPageColor = new BrushConverter().ConvertFromString("#e3e1de") as Brush;

Expand All @@ -16,7 +15,7 @@ public HoyoSettings()

HoyoWindow.BLACK_THING.Opacity = 0.5;

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

Expand All @@ -27,10 +26,6 @@ public HoyoSettings()
if (e.ChangedButton is MouseButton.Left)
AppSettings.Settings.Default.MinimizedTray = (bool)(RadioButtonTray.IsChecked = !RadioButtonTray.IsChecked);
};

Button_Location.MouseDown += (s, e) => ChangePage(e, location: 0);
Button_Others.MouseDown += (s, e) => ChangePage(e, others: 0);
Button_About.MouseDown += (s, e) => ChangePage(e, about: 0);
}

private void OnLoaded(object sender, RoutedEventArgs e)
Expand All @@ -46,23 +41,31 @@ protected override void OnClosed(EventArgs e)
base.OnClosed(e);
}

static void GetFolderDirectory(TextBox txt)
void LocationButtonClick(object s, RoutedEventArgs e)
{
using var Folder = new Forms.FolderBrowserDialog();
TextBox textBox = null;

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;
}
e.Handled = true;

if(Folder.ShowDialog() is Forms.DialogResult.Cancel)
if (Folder.ShowDialog() is Forms.DialogResult.Cancel)
return;

txt.Text = Folder.SelectedPath;
textBox.Text = Folder.SelectedPath;
}

void GenshinClick(object s, RoutedEventArgs e) =>
GetFolderDirectory(GI_DIR_TXT);
void HSRClick(object s, RoutedEventArgs e) =>
GetFolderDirectory(HSR_DIR_TXT);
void HI3Click(object s, RoutedEventArgs e) =>
GetFolderDirectory(HI3_DIR_TXT);

void ConfirmClick(object s, RoutedEventArgs e)
{
bool ErrorOccured = false;
Expand Down Expand Up @@ -97,20 +100,33 @@ void ConfirmClick(object s, RoutedEventArgs e)
Close();
}

void ChangePage(MouseButtonEventArgs e,
Visibility location = Visibility.Hidden,
Visibility others = Visibility.Hidden,
Visibility about = Visibility.Hidden)
// 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 };

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

Locations.Visibility = location;
Others.Visibility = others;
About.Visibility = about;
foreach (var page in pages)
page.Visibility = Visibility.Hidden;

Button_Location.Background = location is Visibility.Visible ? SelectedPageColor : UnSelectedPageColor;
Button_Others.Background = others is Visibility.Visible ? SelectedPageColor : UnSelectedPageColor;
Button_About.Background = about is Visibility.Visible ? SelectedPageColor : UnSelectedPageColor;
foreach (var button in buttons)
{
((TextBlock)button.Child).Foreground = Brushes.Black;
button.Background = UnSelectedPageColor;
}

sButton.Background = SelectedPageColor;
((TextBlock)sButton.Child).Foreground = (Brush)new BrushConverter().ConvertFromString("#997f5f");

switch (sButton.Name)
{
case "Button_Locations": Locations.Visibility = Visibility.Visible; break;
case "Button_Others": Others.Visibility = Visibility.Visible; break;
case "Button_About": About.Visibility = Visibility.Visible; break;
}
}

static void RefreshCurrentSelectedGame()
Expand Down
2 changes: 1 addition & 1 deletion src/HoyoLauncherSettings/SettingsDictionary.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="5">
<ScrollViewer Margin="5,0,5,0" x:Name="PART_ContentHost" />
<ScrollViewer Margin="5,-1,5,2" x:Name="PART_ContentHost" />
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
Expand Down
Binary file modified src/Resources/DEFAULT_GENSHIN_BG.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/DEFAULT_HSR_BG.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/HoyoVerseIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 77d306d

Please sign in to comment.