Skip to content

Commit

Permalink
Added the possibility to set the process name when adding a game (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jul 7, 2023
1 parent 2f4c8aa commit 7138c53
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 53 deletions.
38 changes: 19 additions & 19 deletions Gavilya/Pages/AddEditPage2.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,34 @@
</Grid>
</Grid>
</Border>
<TextBlock Text="{x:Static lang:Resources.GameTags}" FontWeight="ExtraBold" FontSize="13" Margin="2,5,2,2" VerticalAlignment="Center" />
<Border x:Name="TagsBorder" Visibility="Visible" CornerRadius="5" Margin="0 10" Background="{DynamicResource Background2}" Padding="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Static lang:Resources.GameTags}" FontWeight="ExtraBold" FontSize="13" Margin="2,5,2,2" VerticalAlignment="Center" />
<Border x:Name="TagsBorder" Visibility="Visible" CornerRadius="5" Margin="0 10" Background="{DynamicResource Background2}" Padding="10">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<StackPanel Orientation="Horizontal" Grid.Column="0">
<Button FontSize="13" x:Name="AddTagsBtn" Click="AddTagsBtn_Click" Cursor="Hand" Style="{DynamicResource RegularButton}" Background="{DynamicResource Background2}" Margin="0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.AssociateTags}" FontWeight="ExtraBold" VerticalAlignment="Center">
<Button.ToolTip>
<ToolTip Content="{x:Static lang:Resources.ConvertToSteam}" Background="{DynamicResource Background}" Foreground="{DynamicResource Foreground}" />
</Button.ToolTip>
</Button>
</StackPanel>
</Grid>
</Border>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="0">
<Button FontSize="13" x:Name="AddTagsBtn" Click="AddTagsBtn_Click" Cursor="Hand" Style="{DynamicResource RegularButton}" Background="{DynamicResource Background2}" Margin="0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.AssociateTags}" FontWeight="ExtraBold" VerticalAlignment="Center">
<Button.ToolTip>
<ToolTip Content="{x:Static lang:Resources.ConvertToSteam}" Background="{DynamicResource Background}" Foreground="{DynamicResource Foreground}" />
</Button.ToolTip>
</Button>
</StackPanel>
</Grid>
</Border>
</StackPanel>

<StackPanel HorizontalAlignment="Center" Grid.Row="1" Margin="0 0 0 20" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button FontSize="13" x:Name="BackBtn" Click="BackBtn_Click" Cursor="Hand" Style="{DynamicResource RegularButton}" Background="{DynamicResource Background2}" Margin="0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.Back}" FontWeight="ExtraBold">
<Button.ToolTip>
<ToolTip Content="{x:Static lang:Resources.Back}" Background="{DynamicResource Background}" Foreground="{DynamicResource Foreground}" />
</Button.ToolTip>
</Button>
<Button FontSize="13" Cursor="Hand" x:Name="NextBtn" Click="NextBtn_Click" Style="{DynamicResource PlayButton}" Margin="10,0,10,0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.Finish}" FontWeight="ExtraBold">
<Button FontSize="13" Cursor="Hand" x:Name="NextBtn" Click="NextBtn_Click" Style="{DynamicResource PlayButton}" Margin="10,0,10,0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.Next}" FontWeight="ExtraBold">
<Button.ToolTip>
<ToolTip Content="{x:Static lang:Resources.Finish}" Background="{DynamicResource Background}" Foreground="{DynamicResource Foreground}" />
<ToolTip Content="{x:Static lang:Resources.Next}" Background="{DynamicResource Background}" Foreground="{DynamicResource Foreground}" />
</Button.ToolTip>
</Button>
<Button FontSize="13" x:Name="CancelBtn" Click="CancelBtn_Click" Cursor="Hand" Style="{DynamicResource RegularButton}" Background="{DynamicResource Background2}" Margin="0,0,0,0" Foreground="{DynamicResource Foreground}" Padding="7" Content="{x:Static lang:Resources.Cancel}" FontWeight="ExtraBold">
Expand Down
16 changes: 3 additions & 13 deletions Gavilya/Pages/AddEditPage2.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void InitUI()
}
}

private void NextBtn_Click(object sender, RoutedEventArgs e)
internal void NextBtn_Click(object sender, RoutedEventArgs e)
{
try
{
Expand All @@ -111,12 +111,7 @@ private void NextBtn_Click(object sender, RoutedEventArgs e)
AddGame.GameInfo.Stores = Stores;
AddGame.GameInfo.AssociatedTags = Tags;
AddGame.GameInfo.Description = DescriptionTextBox.Text;
Global.Games.Add(AddGame.GameInfo);

GameSaver.Save(Global.Games); // Save
Global.ReloadAllPages(); // Refresh UI

AddGame.Close();
AddGame.ChangePage(2); // Change page
}
else
{
Expand All @@ -131,12 +126,7 @@ private void NextBtn_Click(object sender, RoutedEventArgs e)
ConvertSteamBtn_Click(this, null);
}

Global.Games[Global.Games.IndexOf(old)] = GameCard.GameInfo; // Update
GameSaver.Save(Global.Games); // Save

Global.ReloadAllPages(); // Refresh UI

EditGame.Close();
EditGame.ChangePage(2);
}
}
catch (Exception ex)
Expand Down
30 changes: 26 additions & 4 deletions Gavilya/Windows/AddGame.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,45 @@
</Border>
<TextBlock Text="{x:Static lang:Resources.Infos}" FontWeight="Bold"/>
</StackPanel>
<Border Grid.Column="1" Background="{DynamicResource Accent}" Width="75" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
<Border Grid.Column="1" Background="{DynamicResource Accent}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
</Grid>
</Button>
<Button Foreground="{DynamicResource LightForeground}" Click="Page2Btn_Click" Background="Transparent" x:Name="Page2Btn" Padding="0" Style="{DynamicResource RegularButton}">
<Grid Margin="0 10 10 10">
<Grid Margin="0 10 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border x:Name="LineBorder" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="75" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
<Border x:Name="LineBorder" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

<StackPanel Grid.Column="1">
<Border x:Name="NumberBorder" CornerRadius="10" Width="20" Height="20" Background="{DynamicResource LightForeground}">
<TextBlock Text="2" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<Grid>
<TextBlock x:Name="_2Txt" Text="2" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<TextBlock x:Name="CheckTxt2" Text="&#xF299;" FontFamily="..\Fonts\#FluentSystemIcons-Filled" Visibility="Collapsed" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
</Grid>
</Border>
<TextBlock Text="{x:Static lang:Resources.Integrations}" FontWeight="Bold"/>
</StackPanel>
<Border x:Name="LineBorder2" Grid.Column="2" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

</Grid>
</Button>
<Button Foreground="{DynamicResource LightForeground}" Click="Page3Btn_Click" Background="Transparent" x:Name="Page3Btn" Padding="0" Style="{DynamicResource RegularButton}">
<Grid Margin="0 10 10 10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border x:Name="LineBorder3" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

<StackPanel Grid.Column="1">
<Border x:Name="NumberBorder3" CornerRadius="10" Width="20" Height="20" Background="{DynamicResource LightForeground}">
<TextBlock Text="3" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
</Border>
<TextBlock Text="{x:Static lang:Resources.Advanced}" FontWeight="Bold"/>
</StackPanel>
</Grid>
</Button>
</StackPanel>
Expand Down
54 changes: 48 additions & 6 deletions Gavilya/Windows/AddGame.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public partial class AddGame : Window

readonly AddEditPage AddEditPage;
readonly AddEditPage2 AddEditPage2;
readonly AddEditPage3 AddEditPage3;
public AddGame(bool isUWP, bool isSteam)
{
InitializeComponent();
Expand Down Expand Up @@ -67,6 +68,7 @@ public AddGame(bool isUWP, bool isSteam)

AddEditPage2 = new(this);
AddEditPage = new(this, AddEditPage2);
AddEditPage3 = new(this);

ChangePage(0);
}
Expand All @@ -77,26 +79,62 @@ internal void ChangePage(int id)
{
0 => AddEditPage,
1 => AddEditPage2,
2 => AddEditPage3,
_ => AddEditPage
}; // Set

if (id == 1)
if (id == 0)
{
LineBorder.Background = Global.GetSolidColor("LightForeground");
NumberBorder.Background = Global.GetSolidColor("LightForeground");
Page2Btn.Foreground = Global.GetSolidColor("LightForeground");

LineBorder2.Background = Global.GetSolidColor("LightForeground");
LineBorder3.Background = Global.GetSolidColor("LightForeground");
NumberBorder3.Background = Global.GetSolidColor("LightForeground");
Page3Btn.Foreground = Global.GetSolidColor("LightForeground");


_1Txt.Visibility = Visibility.Visible;
CheckTxt.Visibility = Visibility.Collapsed;

_2Txt.Visibility = Visibility.Visible;
CheckTxt2.Visibility = Visibility.Collapsed;

}
else if (id == 1)
{
LineBorder2.Background = Global.GetSolidColor("LightForeground");
LineBorder3.Background = Global.GetSolidColor("LightForeground");
NumberBorder3.Background = Global.GetSolidColor("LightForeground");
Page3Btn.Foreground = Global.GetSolidColor("LightForeground");

LineBorder.Background = Global.GetSolidColor("Accent");
NumberBorder.Background = Global.GetSolidColor("Accent");
Page2Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Collapsed;
CheckTxt.Visibility = Visibility.Visible;

_2Txt.Visibility = Visibility.Visible;
CheckTxt2.Visibility = Visibility.Collapsed;
}
else
{
LineBorder.Background = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
NumberBorder.Background = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
Page2Btn.Foreground = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
LineBorder.Background = Global.GetSolidColor("Accent");
NumberBorder.Background = Global.GetSolidColor("Accent");
Page2Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Visible;
CheckTxt.Visibility = Visibility.Collapsed;
LineBorder2.Background = Global.GetSolidColor("Accent");
LineBorder3.Background = Global.GetSolidColor("Accent");
NumberBorder3.Background = Global.GetSolidColor("Accent");
Page3Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Collapsed;
CheckTxt.Visibility = Visibility.Visible;

_2Txt.Visibility = Visibility.Collapsed;
CheckTxt2.Visibility = Visibility.Visible;
}
}

Expand Down Expand Up @@ -132,4 +170,8 @@ private void Page1Btn_Click(object sender, RoutedEventArgs e)
{
ChangePage(0);
}
private void Page3Btn_Click(object sender, RoutedEventArgs e)
{
AddEditPage2.NextBtn_Click(this, e);
}
}
32 changes: 27 additions & 5 deletions Gavilya/Windows/EditGame.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,29 +116,51 @@
<StackPanel>
<Border CornerRadius="10" Width="20" Height="20" Background="{DynamicResource Accent}">
<Grid>
<TextBlock x:Name="_1Txt" Text="1" FontWeight="Bold" Foreground="{DynamicResource HoverForeground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<TextBlock x:Name="_1Txt" Text="1" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<TextBlock x:Name="CheckTxt" Text="&#xF299;" FontFamily="..\Fonts\#FluentSystemIcons-Filled" Visibility="Collapsed" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
</Grid>
</Border>
<TextBlock Text="{x:Static lang:Resources.Infos}" FontWeight="Bold"/>
</StackPanel>
<Border Grid.Column="1" Background="{DynamicResource Accent}" Width="75" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
<Border Grid.Column="1" Background="{DynamicResource Accent}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
</Grid>
</Button>
<Button Foreground="{DynamicResource LightForeground}" Click="Page2Btn_Click" Background="Transparent" x:Name="Page2Btn" Padding="0" Style="{DynamicResource RegularButton}">
<Grid Margin="0 10 10 10">
<Grid Margin="0 10 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border x:Name="LineBorder" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="75" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>
<Border x:Name="LineBorder" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

<StackPanel Grid.Column="1">
<Border x:Name="NumberBorder" CornerRadius="10" Width="20" Height="20" Background="{DynamicResource LightForeground}">
<TextBlock Text="2" FontWeight="Bold" Foreground="{DynamicResource HoverForeground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<Grid>
<TextBlock x:Name="_2Txt" Text="2" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
<TextBlock x:Name="CheckTxt2" Text="&#xF299;" FontFamily="..\Fonts\#FluentSystemIcons-Filled" Visibility="Collapsed" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
</Grid>
</Border>
<TextBlock Text="{x:Static lang:Resources.Integrations}" FontWeight="Bold"/>
</StackPanel>
<Border x:Name="LineBorder2" Grid.Column="2" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

</Grid>
</Button>
<Button Foreground="{DynamicResource LightForeground}" Click="Page3Btn_Click" Background="Transparent" x:Name="Page3Btn" Padding="0" Style="{DynamicResource RegularButton}">
<Grid Margin="0 10 10 10">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border x:Name="LineBorder3" Grid.Column="0" Background="{DynamicResource LightForeground}" Width="50" VerticalAlignment="Center" Height="2" CornerRadius="1 0 0 1"/>

<StackPanel Grid.Column="1">
<Border x:Name="NumberBorder3" CornerRadius="10" Width="20" Height="20" Background="{DynamicResource LightForeground}">
<TextBlock Text="3" FontWeight="Bold" Foreground="{DynamicResource Foreground}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14" />
</Border>
<TextBlock Text="{x:Static lang:Resources.Advanced}" FontWeight="Bold"/>
</StackPanel>
</Grid>
</Button>
</StackPanel>
Expand Down
55 changes: 49 additions & 6 deletions Gavilya/Windows/EditGame.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public partial class EditGame : Window

readonly AddEditPage AddEditPage;
readonly AddEditPage2 AddEditPage2;
readonly AddEditPage3 AddEditPage3;

/// <summary>
/// Window where the user can edit a game
Expand All @@ -59,6 +60,7 @@ public EditGame(GameCard gameCard)
GameCard = gameCard; // Pass the arg

AddEditPage2 = new(this, GameCard);
AddEditPage3 = new(this, GameCard);
AddEditPage = new(this, GameCard, AddEditPage2);

ChangePage(0);
Expand All @@ -70,26 +72,62 @@ internal void ChangePage(int id)
{
0 => AddEditPage,
1 => AddEditPage2,
2 => AddEditPage3,
_ => AddEditPage
}; // Set

if (id == 1)
if (id == 0)
{
LineBorder.Background = Global.GetSolidColor("LightForeground");
NumberBorder.Background = Global.GetSolidColor("LightForeground");
Page2Btn.Foreground = Global.GetSolidColor("LightForeground");

LineBorder2.Background = Global.GetSolidColor("LightForeground");
LineBorder3.Background = Global.GetSolidColor("LightForeground");
NumberBorder3.Background = Global.GetSolidColor("LightForeground");
Page3Btn.Foreground = Global.GetSolidColor("LightForeground");


_1Txt.Visibility = Visibility.Visible;
CheckTxt.Visibility = Visibility.Collapsed;

_2Txt.Visibility = Visibility.Visible;
CheckTxt2.Visibility = Visibility.Collapsed;

}
else if (id == 1)
{
LineBorder2.Background = Global.GetSolidColor("LightForeground");
LineBorder3.Background = Global.GetSolidColor("LightForeground");
NumberBorder3.Background = Global.GetSolidColor("LightForeground");
Page3Btn.Foreground = Global.GetSolidColor("LightForeground");

LineBorder.Background = Global.GetSolidColor("Accent");
NumberBorder.Background = Global.GetSolidColor("Accent");
Page2Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Collapsed;
CheckTxt.Visibility = Visibility.Visible;

_2Txt.Visibility = Visibility.Visible;
CheckTxt2.Visibility = Visibility.Collapsed;
}
else
{
LineBorder.Background = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
NumberBorder.Background = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
Page2Btn.Foreground = new SolidColorBrush { Color = Color.FromRgb(50, 50, 70) };
LineBorder.Background = Global.GetSolidColor("Accent");
NumberBorder.Background = Global.GetSolidColor("Accent");
Page2Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Visible;
CheckTxt.Visibility = Visibility.Collapsed;
LineBorder2.Background = Global.GetSolidColor("Accent");
LineBorder3.Background = Global.GetSolidColor("Accent");
NumberBorder3.Background = Global.GetSolidColor("Accent");
Page3Btn.Foreground = Global.GetSolidColor("Accent");

_1Txt.Visibility = Visibility.Collapsed;
CheckTxt.Visibility = Visibility.Visible;

_2Txt.Visibility = Visibility.Collapsed;
CheckTxt2.Visibility = Visibility.Visible;
}
}

Expand All @@ -112,4 +150,9 @@ private void Page1Btn_Click(object sender, RoutedEventArgs e)
{
ChangePage(0);
}

private void Page3Btn_Click(object sender, RoutedEventArgs e)
{
AddEditPage2.NextBtn_Click(this, e);
}
}

0 comments on commit 7138c53

Please sign in to comment.