Skip to content

Commit

Permalink
ui progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelo420 committed Dec 8, 2023
1 parent dab871d commit f431e12
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 22 deletions.
2 changes: 2 additions & 0 deletions gamevault/Models/Progress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class Progress
public DateTime? LastPlayedAt { get; set; }
[JsonPropertyName("game")]
public Game? Game { get; set; }
[JsonPropertyName("user")]
public User? User { get; set; }

}

Expand Down
2 changes: 1 addition & 1 deletion gamevault/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum PERMISSION_ROLE
EDITOR,
ADMIN
}
internal class User
public class User
{
[JsonPropertyName("id")]
public int ID { get; set; }
Expand Down
19 changes: 13 additions & 6 deletions gamevault/UserControls/GameSettingsUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
xmlns:conv="clr-namespace:gamevault.Converter"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:helper="clr-namespace:gamevault.Helper"
xmlns:local="clr-namespace:gamevault.UserControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800" Focusable="True" Loaded="GameSettings_Loaded" FocusVisualStyle="{x:Null}">
<UserControl.Resources>
<Style x:Key="TabItemHeaderPath" TargetType="Path">
<Style.Triggers>
Expand All @@ -35,7 +36,13 @@
</Style>
<conv:GameSettingsTabVisibilityConverter x:Key="tabVisConv"/>
</UserControl.Resources>

<UserControl.InputBindings>
<KeyBinding Key="Esc">
<KeyBinding.Command>
<helper:CommandHelper Executed="KeyBindingEscape_OnExecuted"/>
</KeyBinding.Command>
</KeyBinding>
</UserControl.InputBindings>
<Border Padding="5" CornerRadius="5">
<Border.OpacityMask>
<VisualBrush>
Expand Down Expand Up @@ -295,8 +302,8 @@
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Game.ID}" FontSize="15" Width="70"/>
<TextBlock Text="{Binding Path=Game.FilePath}" FontSize="15" Margin="20,0,0,0" Width="280"/>
<TextBlock Text="{Binding Path=Game.ReleaseDate,StringFormat='{}{0:MM/dd/yyyy}'}" Width="100" FontSize="15" Margin="42,0,0,0"/>
<TextBlock Text="{Binding Path=Game.CreatedAt,StringFormat='{}{0:MM/dd/yyyy}'}" FontSize="15" Margin="98,0,0,0"/>
<TextBlock Text="{Binding Path=Game.ReleaseDate,StringFormat='{}{0:dd/MM/yyyy}'}" Width="100" FontSize="15" Margin="42,0,0,0"/>
<TextBlock Text="{Binding Path=Game.CreatedAt,StringFormat='{}{0:dd/MM/yyyy}'}" FontSize="15" Margin="98,0,0,0"/>
</StackPanel>
<TextBlock Text="Currently Mapped RAWG Game" FontSize="15" FontWeight="Bold" TextDecorations="Underline" Margin="0,20,0,0"/>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
Expand All @@ -308,8 +315,8 @@
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Game.RawgId}" FontSize="15" Width="70"/>
<TextBlock Text="{Binding Path=Game.RawgTitle}" FontSize="15" Margin="20,0,0,0" Width="280"/>
<TextBlock Text="{Binding Path=Game.RawgReleaseDate,StringFormat='{}{0:MM/dd/yyyy}'}" Width="100" FontSize="15" Margin="42,0,0,0"/>
<TextBlock Text="{Binding Path=Game.LastCached,StringFormat='{}{0:MM/dd/yyyy}'}" FontSize="15" Margin="102,0,0,0"/>
<TextBlock Text="{Binding Path=Game.RawgReleaseDate,StringFormat='{}{0:dd/MM/yyyy}'}" Width="100" FontSize="15" Margin="42,0,0,0"/>
<TextBlock Text="{Binding Path=Game.LastCached,StringFormat='{}{0:dd/MM/yyyy}'}" FontSize="15" Margin="102,0,0,0"/>
</StackPanel>
</StackPanel>
<TextBlock Text="Recache Game" FontSize="15" FontWeight="Bold" TextDecorations="Underline" Margin="0,20,0,0"/>
Expand Down
11 changes: 9 additions & 2 deletions gamevault/UserControls/GameSettingsUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ internal GameSettingsUserControl(Game game)
}
this.DataContext = ViewModel;
}
private void GameSettings_Loaded(object sender, RoutedEventArgs e)
{
this.Focus();
}
private void KeyBindingEscape_OnExecuted(object sender, object e)
{
MainWindowViewModel.Instance.ClosePopup();
}
private bool IsGameInstalled(Game game)
{
KeyValuePair<Game, string> result = NewInstallViewModel.Instance.InstalledGames.Where(g => g.Key.ID == game.ID).FirstOrDefault();
Expand Down Expand Up @@ -591,7 +599,6 @@ await Task.Run(() =>
this.IsEnabled = true;
}

#endregion

#endregion
}
}
101 changes: 88 additions & 13 deletions gamevault/UserControls/NewGameViewUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<ScaleTransform/>
</Border.RenderTransform>
</Border>
<TextBlock FontSize="50" FontWeight="Bold" Margin="60,-15,0,0" VerticalAlignment="Top">
<TextBlock FontSize="50" FontWeight="Bold" Margin="60,-15,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<TextBlock.ToolTip>
<TextBlock Text="{Binding Path=Game.RawgTitle,StringFormat='{}RAWG Title: {0}'}"/>
</TextBlock.ToolTip>
Expand All @@ -53,10 +53,10 @@
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<local:CacheImage Data="{Binding Game}" ImageCacheType="BoxArt" CornerRadius="5" VerticalAlignment="Top" HorizontalAlignment="Left" Height="600" Width="400" Margin="0,70,0,0"/>
<local:CacheImage Data="{Binding Game}" ImageCacheType="BoxArt" CornerRadius="5" VerticalAlignment="Top" HorizontalAlignment="Left" Height="550" Width="367" Margin="0,70,0,0"/>


<StackPanel Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="420,70,0,0" Orientation="Horizontal">
<!--ACTION BUTTONS-->
<StackPanel Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="390,70,0,0" Orientation="Horizontal">
<Grid Style="{DynamicResource HoverEffect}" VerticalAlignment="Top" HorizontalAlignment="Left" Visibility="{Binding ScrollToTopVisibility}" Background="Transparent" Cursor="Hand" Width="50" Height="50" Margin="00,0,0,0" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="GamePlay_Click">
<Path Data="{StaticResource IconInstalledGamesPlay}" Fill="White" RenderTransformOrigin="0.12,0.11">
<Path.RenderTransform>
Expand All @@ -67,12 +67,13 @@
<ScaleTransform/>
</Grid.RenderTransform>
</Grid>
<Grid Style="{DynamicResource HoverEffect}" VerticalAlignment="Top" HorizontalAlignment="Left" Visibility="{Binding ScrollToTopVisibility}" Background="Transparent" Cursor="Hand" Width="50" Height="50" Margin="20,0,0,0" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="GameDownload_Click">
<Grid Style="{DynamicResource HoverEffect}" VerticalAlignment="Top" HorizontalAlignment="Left" Visibility="{Binding ScrollToTopVisibility}" Background="Transparent" Cursor="Hand" Width="50" Height="60" Margin="20,0,0,0" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="GameDownload_Click">
<Path Data="{StaticResource IconDownload}" Fill="White" RenderTransformOrigin="0.06,0.04">
<Path.RenderTransform>
<ScaleTransform ScaleX="2.5" ScaleY="2.5"/>
</Path.RenderTransform>
</Path>
<TextBlock Text="{Binding Path=Game.Size,Converter={StaticResource sizeConv}}" Margin="0,0,0,0" FontSize="10" FontWeight="Bold" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
<Grid.RenderTransform>
<ScaleTransform/>
</Grid.RenderTransform>
Expand All @@ -88,8 +89,8 @@
</Grid.RenderTransform>
</Grid>
</StackPanel>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="430,150,0,10">
<!--TAGS_GENRES-->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="400,150,0,10">
<Border CornerRadius="5" Background="Gainsboro" Margin="0,10,10,10">
<Border.Style>
<Style TargetType="{x:Type Border}">
Expand Down Expand Up @@ -118,12 +119,41 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>

<ScrollViewer Background="Transparent" Margin="430,240,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="430" Width="1000" VerticalScrollBarVisibility="Auto">
<Border BorderThickness="2" CornerRadius="5" Background="{DynamicResource DarkBackground2}" Height="50" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1300,150,0,0" Cursor="Hand">
<Border.Style>
<Style TargetType="Border">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="DarkGray"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.ToolTip>
<ToolTip>
<ItemsControl ItemsSource="{Binding Path=Game.Tags}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border CornerRadius="5" Background="{DynamicResource MainColor}" Padding="0" Margin="10">
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" Margin="15,8,15,8" FontSize="15" FontWeight="Bold"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ToolTip>
</Border.ToolTip>
<TextBlock Text="View Tags" FontSize="15" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ScrollViewer Background="Transparent" Margin="400,240,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="381" Width="1000" VerticalScrollBarVisibility="Auto">
<TextBlock Text="{Binding Path=Game.Description}" TextWrapping="Wrap" FontSize="20" />
</ScrollViewer>

<StackPanel Background="Transparent" Margin="0,710,0,0" HorizontalAlignment="Left">
<!--DETAILS-->
<StackPanel Background="Transparent" Margin="0,660,0,0" HorizontalAlignment="Left">
<Grid>
<Path Fill="White" Data="{DynamicResource IconGameViewCalendar}" RenderTransformOrigin="0,0">
<Path.RenderTransform>
Expand Down Expand Up @@ -213,8 +243,7 @@
</ItemsControl>
</Grid>
</StackPanel>

<TextBlock Text="{Binding Path=Game.Size,Converter={StaticResource sizeConv}}" Margin="0,-15,0,0.8" VerticalAlignment="Top" HorizontalAlignment="Right" FontSize="50" FontWeight="Bold"/>
<!--PROGRESS-->
<StackPanel HorizontalAlignment="Right" Margin="0,135,0,0">
<TextBlock Text="State" FontSize="15" FontWeight="Bold"/>
<ComboBox ItemsSource="{Binding GameStates}" SelectedValue="{Binding Path=Progress.State}" FontSize="30" SelectionChanged="GameState_SelectionChanged">
Expand Down Expand Up @@ -272,6 +301,52 @@
</StackPanel>
</StackPanel>
</StackPanel>
<ItemsControl ItemsSource="{Binding UserProgress}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="320" Width="410" Margin="0,300,0,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border CornerRadius="5" Background="#33000000" Padding="0" Margin="0,0,0,10" Height="50">
<Grid Margin="5">
<local:CacheImage Data="{Binding User}" Stretch="Fill" ImageCacheType="UserIcon" CornerRadius="5" HorizontalAlignment="Left" VerticalAlignment="Center" Width="40"/>
<TextBlock Text="{Binding Path=User.Username}" FontSize="10" HorizontalAlignment="Left" Margin="50,0,0,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding MinutesPlayed,Converter={StaticResource timeConv}}" FontSize="10" HorizontalAlignment="Left" Margin="135,0,0,0" VerticalAlignment="Center"/>
<TextBlock FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,140,0">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Setters>
<Setter Property="Text">
<Setter.Value>
<MultiBinding StringFormat="{}{0}.{1}.{2}">
<Binding Path="LastPlayedAt.Day"/>
<Binding Path="LastPlayedAt.Month"/>
<Binding Path="LastPlayedAt.Year"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</TextBlock.Style>
<TextBlock.ToolTip>
<TextBlock HorizontalAlignment="Center">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}:{1} h">
<Binding Path="LastPlayedAt.Hour"/>
<Binding Path="LastPlayedAt.Minute"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</TextBlock.ToolTip>
</TextBlock>
<TextBlock Text="{Binding State}" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,0,0"/>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Viewbox>
</Grid>
Expand Down
6 changes: 6 additions & 0 deletions gamevault/UserControls/NewGameViewUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ private async void UserControl_Loaded(object sender, RoutedEventArgs e)
string result = WebHelper.GetRequest(@$"{SettingsViewModel.Instance.ServerUrl}/api/progresses/user/{LoginManager.Instance.GetCurrentUser().ID}/game/{gameID}");
return System.Text.Json.JsonSerializer.Deserialize<Progress>(result);
});

ViewModel.UserProgress = await Task<Progress[]>.Run(() =>
{
string result = WebHelper.GetRequest(@$"{SettingsViewModel.Instance.ServerUrl}/api/progresses/game/{gameID}");
return System.Text.Json.JsonSerializer.Deserialize<Progress[]>(result);
});
}
catch (Exception ex) { }
}
Expand Down
6 changes: 6 additions & 0 deletions gamevault/ViewModels/NewGameViewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class NewGameViewViewModel : ViewModelBase
#region PrivateMembers
private Game? game { get; set; }
private Progress? progress { get; set; }
private Progress[]? userProgress { get; set; }
private string[]? gameStates { get; set; }
#endregion
public Game? Game
Expand All @@ -24,6 +25,11 @@ public Progress? Progress
get { return progress; }
set { progress = value; OnPropertyChanged(); }
}
public Progress[]? UserProgress
{
get { return userProgress; }
set { userProgress = value; OnPropertyChanged(); }
}
public string[]? GameStates
{
get { if (gameStates == null) { gameStates = Enum.GetNames(typeof(State)); } return gameStates; }
Expand Down

0 comments on commit f431e12

Please sign in to comment.