Browse Source

Added basic score page

Kenneth van Ewijk 10 years ago
parent
commit
54a5277406

+ 5 - 1
YJMPD-UWP/MainPage.xaml.cs

@@ -140,7 +140,11 @@ namespace YJMPD_UWP
 
         private async void BackToGame_Click(object sender, RoutedEventArgs e)
         {
-            bool b = await Util.ShowConfirmDialog("Not implemented", "", Util.DialogType.OKCANCEL);
+            bool b = await Util.ShowConfirmDialog("View Scores", "Go to the scores page (test)?", Util.DialogType.OKCANCEL);
+            if(b)
+            {
+                App.Navigate(typeof(ScoreView));
+            }
         }
 
         private void Content_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)

+ 12 - 1
YJMPD-UWP/Themes/DefaultStyles.xaml

@@ -8,7 +8,13 @@
         <Setter Property="TextWrapping" Value="WrapWholeWords" />
     </Style>
 
-    <Style TargetType="StackPanel" x:Key="Base">
+    <Style TargetType="StackPanel" x:Key="BaseStackPanel">
+        <Setter Property="Margin" Value="10" />
+    </Style>
+    <Style TargetType="RelativePanel" x:Key="BaseRelativePanel">
+        <Setter Property="Margin" Value="10" />
+    </Style>
+    <Style TargetType="Grid" x:Key="BaseGrid">
         <Setter Property="Margin" Value="10" />
     </Style>
 
@@ -23,6 +29,11 @@
         <Setter Property="FontSize" Value="14" />
     </Style>
 
+    <Style TargetType="TextBlock" x:Key="Icon">
+        <Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
+        <Setter Property="FontSize" Value="14" />
+    </Style>
+
     <Style TargetType="Button" x:Key="Green">
         <Setter Property="Background" Value="DarkGreen" />
         <Setter Property="Foreground" Value="White" />

+ 46 - 0
YJMPD-UWP/ViewModels/ScoreVM.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using YJMPD_UWP.Model.Object;
+
+namespace YJMPD_UWP.ViewModels
+{
+    public class ScoreVM : TemplateVM
+    {
+        private List<Player> players;
+
+        public ScoreVM() : base("Scores")
+        {
+            this.players = App.Game.Players.OrderBy(p => p.Points).ToList();
+            App.Game.OnPlayersUpdate += Game_OnPlayersUpdate;
+        }
+
+        private void Game_OnPlayersUpdate(object sender, Helpers.EventArgs.GamePlayersUpdatedEventArgs e)
+        {
+            dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
+            {
+                this.players = App.Game.Players.OrderBy(p => p.Points).ToList();
+                NotifyPropertyChanged(nameof(Players));
+                NotifyPropertyChanged(nameof(PlayersCount));
+            });
+        }
+
+        public List<Player> Players
+        {
+            get
+            {
+                return new List<Player>(players);
+            }
+        }
+
+        public string PlayersCount
+        {
+            get
+            {
+                return "There are currently " + App.Game.Players.Count + " players in the match.";
+            }
+        }
+    }
+}

+ 1 - 1
YJMPD-UWP/Views/AboutView.xaml

@@ -8,7 +8,7 @@
     mc:Ignorable="d">
 
     <ScrollViewer>
-        <StackPanel Style="{StaticResource Base}" >
+        <StackPanel Style="{StaticResource BaseStackPanel}" >
             <StackPanel>
                 <TextBlock Style="{StaticResource Header}" Text="About this app" />
                 <TextBlock>

+ 1 - 1
YJMPD-UWP/Views/MatchView.xaml

@@ -13,7 +13,7 @@
     </Page.Resources>
     
     <ScrollViewer>
-        <StackPanel Style="{StaticResource Base}" >
+        <StackPanel Style="{StaticResource BaseStackPanel}" >
             <StackPanel>
                 <TextBlock Text="Start a match" Style="{StaticResource Header}" />
                 <Button Content="Start match" Style="{StaticResource Green}" Click="StartMatchButton_Click" IsEnabled="{Binding MatchAvailable}" Visibility="{Binding StartMatch, Converter={StaticResource BoolToVisConverter}}" />

+ 47 - 0
YJMPD-UWP/Views/ScoreView.xaml

@@ -0,0 +1,47 @@
+<Page
+    x:Class="YJMPD_UWP.Views.ScoreView"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:local="using:YJMPD_UWP.Views"
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+    mc:Ignorable="d">
+
+    <ScrollViewer>
+        <Grid Style="{StaticResource BaseGrid}" >
+            <Grid.RowDefinitions>
+                <RowDefinition Height="Auto" />
+                <RowDefinition Height="*" />
+                <RowDefinition Height="Auto" />
+            </Grid.RowDefinitions>
+
+            <StackPanel Margin="0,10,0,0" Grid.Row="0">
+                <TextBlock Text="Players" Style="{StaticResource Header}" />
+
+                <TextBlock Text="{Binding PlayersCount}" />
+            </StackPanel>
+
+            <ListView x:Name="PlayersList" ItemsSource="{Binding Players}" SelectionMode="None" Grid.Row="1" IsTapEnabled="False">
+                <ListView.ItemTemplate>
+                    <DataTemplate x:Name="ListViewDataTemplate">
+                        <StackPanel Orientation="Horizontal">
+                            <TextBlock Text="{Binding Username}" Margin="0,0,5,0" />
+                            <TextBlock Text="{Binding Points}"  Margin="0,0,5,0" />
+                            <TextBlock Text="{Binding PointsTotal}" />
+                        </StackPanel>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+
+            <StackPanel Grid.Row="2">
+                <Button Style="{StaticResource Green}" Name="ReadyButton" Click="ReadyButton_Click">
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Style="{StaticResource Icon}" Text="&#xE8FB;" Visibility="Collapsed" Name="ReadyCheck" Margin="0,0,10,0" />
+                        <TextBlock Text="Ready" />
+                    </StackPanel>
+                </Button>
+            </StackPanel>
+
+        </Grid>
+    </ScrollViewer>
+</Page>

+ 36 - 0
YJMPD-UWP/Views/ScoreView.xaml.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using YJMPD_UWP.ViewModels;
+
+namespace YJMPD_UWP.Views
+{
+    public sealed partial class ScoreView : Page
+    {
+        ScoreVM scorevm;
+
+        public ScoreView()
+        {
+            scorevm = new ScoreVM();
+            this.DataContext = scorevm;
+            this.InitializeComponent();
+        }
+
+        private void ReadyButton_Click(object sender, RoutedEventArgs e)
+        {
+            ReadyCheck.Visibility = Visibility.Visible;
+            ReadyButton.IsEnabled = false;
+        }
+    }
+}

+ 1 - 1
YJMPD-UWP/Views/SettingsView.xaml

@@ -8,7 +8,7 @@
     mc:Ignorable="d">
 
     <ScrollViewer>
-        <StackPanel Style="{StaticResource Base}" >
+        <StackPanel Style="{StaticResource BaseStackPanel}" >
             <StackPanel>
                 <TextBlock Text="Username" Style="{StaticResource Header}" />
                 <TextBox Text="{Binding Username, Mode=TwoWay}" />

+ 1 - 1
YJMPD-UWP/Views/StatisticsView.xaml

@@ -8,7 +8,7 @@
     mc:Ignorable="d">
 
     <ScrollViewer>
-        <StackPanel Style="{StaticResource Base}" >
+        <StackPanel Style="{StaticResource BaseStackPanel}" >
 
             <StackPanel Margin="0,10,0,0">
                 <TextBlock Text="{Binding Information}" Style="{StaticResource Subtext}" />

+ 8 - 0
YJMPD-UWP/YJMPD-UWP.csproj

@@ -119,6 +119,7 @@
     <Compile Include="ViewModels\AboutVM.cs" />
     <Compile Include="ViewModels\MainPageVM.cs" />
     <Compile Include="ViewModels\MatchVM.cs" />
+    <Compile Include="ViewModels\ScoreVM.cs" />
     <Compile Include="ViewModels\SettingsVM.cs" />
     <Compile Include="ViewModels\StatisticsVM.cs" />
     <Compile Include="ViewModels\TemplateVM.cs" />
@@ -128,6 +129,9 @@
     <Compile Include="Views\MatchView.xaml.cs">
       <DependentUpon>MatchView.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Views\ScoreView.xaml.cs">
+      <DependentUpon>ScoreView.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Views\SettingsView.xaml.cs">
       <DependentUpon>SettingsView.xaml</DependentUpon>
     </Compile>
@@ -183,6 +187,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Views\ScoreView.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Views\SettingsView.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>