Skip to content

Commit 71d8193

Browse files
authored
Merge pull request #15 from Grange007/dev
feat: ✨ finish UI and basic front-end logic
2 parents a967881 + b027287 commit 71d8193

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2579
-229
lines changed

logic/Client/App.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:Client"
5+
x:Class="Client.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
13+
<Style x:Key="littleAttributes"
14+
TargetType="Label">
15+
<Setter Property="VerticalOptions" Value="Center" />
16+
<Setter Property="HorizontalOptions" Value="Start" />
17+
<Setter Property="FontSize" Value="Micro" />
18+
</Style>
19+
</ResourceDictionary>
20+
21+
22+
</Application.Resources>
23+
</Application>

logic/Client/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace Client
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
MainPage = new AppShell();
9+
}
10+
}
11+
}

logic/Client/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="Client.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:Client"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
ContentTemplate="{DataTemplate local:MainPage}"
11+
Route="MainPage"
12+
/>
13+
14+
</Shell>

logic/Client/AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Client
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

logic/Client/Client.csproj

Lines changed: 97 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,97 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net6.0-windows</TargetFramework>
6-
<Nullable>enable</Nullable>
7-
<UseWPF>true</UseWPF>
8-
<ApplicationIcon>eesast_software_trans_enlarged.ico</ApplicationIcon>
9-
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<None Remove="Logo.png" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<PackageReference Include="CommandLineParser" Version="2.9.1" />
17-
<PackageReference Include="FrameRateTask" Version="1.2.0" />
18-
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
19-
<PackageReference Include="Grpc" Version="2.46.6" />
20-
<PackageReference Include="Grpc.Core" Version="2.46.6" />
21-
</ItemGroup>
22-
23-
<ItemGroup>
24-
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
25-
<ProjectReference Include="..\..\playback\Playback\Playback.csproj" />
26-
<ProjectReference Include="..\Preparation\Preparation.csproj" />
27-
</ItemGroup>
28-
29-
<ItemGroup>
30-
<Resource Include="Logo.png" />
31-
</ItemGroup>
32-
33-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
6+
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
7+
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>Client</RootNamespace>
10+
<UseMaui>true</UseMaui>
11+
<SingleProject>true</SingleProject>
12+
<ImplicitUsings>enable</ImplicitUsings>
13+
14+
<!-- Display name -->
15+
<ApplicationTitle>Client</ApplicationTitle>
16+
17+
<!-- App Identifier -->
18+
<ApplicationId>com.companyname.client</ApplicationId>
19+
<ApplicationIdGuid>872eca96-e290-4365-952b-f5e5b16e7217</ApplicationIdGuid>
20+
21+
<!-- Versions -->
22+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
23+
<ApplicationVersion>1</ApplicationVersion>
24+
25+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
26+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
27+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
28+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
29+
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
30+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<!-- App Icon -->
35+
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
36+
37+
<!-- Splash Screen -->
38+
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
39+
40+
<!-- Images -->
41+
<MauiImage Include="Resources\Images\*" />
42+
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
43+
<MauiImage Include="Resources\Images\eesast_logo_32x32.png" />
44+
<MauiImage Include="Resources\Images\eesast_software_trans_enlarged_256x256.png" />
45+
46+
<!-- Custom Fonts -->
47+
<MauiFont Include="Resources\Fonts\*" />
48+
49+
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
50+
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
51+
</ItemGroup>
52+
53+
54+
<ItemGroup>
55+
<PackageReference Include="Google.Protobuf" Version="3.24.4" />
56+
<PackageReference Include="Grpc" Version="2.46.6" />
57+
<PackageReference Include="Grpc.Tools" Version="2.54.0">
58+
<PrivateAssets>all</PrivateAssets>
59+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
60+
</PackageReference>
61+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
62+
</ItemGroup>
63+
64+
65+
<ItemGroup>
66+
<Compile Update="MainPage.xaml.cs">
67+
<DependentUpon>MainPage.xaml</DependentUpon>
68+
</Compile>
69+
<Compile Update="Map.xaml.cs">
70+
<DependentUpon>Map.xaml</DependentUpon>
71+
</Compile>
72+
<Compile Update="GameStatusBar.xaml.cs">
73+
<DependentUpon>GameStatusBar.xaml</DependentUpon>
74+
</Compile>
75+
<Compile Update="PlayerStatusBar.xaml.cs">
76+
<DependentUpon>PlayerStatusBar.xaml</DependentUpon>
77+
</Compile>
78+
</ItemGroup>
79+
80+
81+
<ItemGroup>
82+
<MauiXaml Update="Map.xaml">
83+
<Generator>MSBuild:Compile</Generator>
84+
</MauiXaml>
85+
<MauiXaml Update="GameStatusBar.xaml">
86+
<Generator>MSBuild:Compile</Generator>
87+
</MauiXaml>
88+
<MauiXaml Update="PlayerStatusBar.xaml">
89+
<Generator>MSBuild:Compile</Generator>
90+
</MauiXaml>
91+
</ItemGroup>
92+
93+
<ItemGroup>
94+
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
95+
</ItemGroup>
96+
97+
</Project>

logic/Client/Client.sln

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.1.32328.378
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client.csproj", "{5AD8481D-90EF-410C-BD48-355DB97EEAB3}"
7-
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playback", "..\..\playback\Playback\Playback.csproj", "{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}"
9-
EndProject
10-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\..\dependency\proto\Protos.csproj", "{A0F72D3B-9A82-48EB-90AF-B3770151AD83}"
11-
EndProject
12-
Global
13-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14-
Debug|Any CPU = Debug|Any CPU
15-
Release|Any CPU = Release|Any CPU
16-
EndGlobalSection
17-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19-
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
20-
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
21-
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.Build.0 = Release|Any CPU
22-
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23-
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.Build.0 = Debug|Any CPU
24-
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.ActiveCfg = Release|Any CPU
25-
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.Build.0 = Release|Any CPU
26-
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27-
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.Build.0 = Debug|Any CPU
28-
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.ActiveCfg = Release|Any CPU
29-
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.Build.0 = Release|Any CPU
30-
EndGlobalSection
31-
GlobalSection(SolutionProperties) = preSolution
32-
HideSolutionNode = FALSE
33-
EndGlobalSection
34-
GlobalSection(ExtensibilityGlobals) = postSolution
35-
SolutionGuid = {89A74B1B-445C-49EB-9C93-506DC243C227}
36-
EndGlobalSection
37-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.34202.233
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client.csproj", "{F75BC602-8C64-4645-9C9A-2DF71085C52C}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\..\dependency\proto\Protos.csproj", "{DAE45955-E55C-4E11-80B4-E7EC77E11C89}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
19+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.Deploy.0 = Release|Any CPU
22+
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Release|Any CPU.Build.0 = Release|Any CPU
26+
EndGlobalSection
27+
GlobalSection(SolutionProperties) = preSolution
28+
HideSolutionNode = FALSE
29+
EndGlobalSection
30+
GlobalSection(ExtensibilityGlobals) = postSolution
31+
SolutionGuid = {4C1CF739-9F04-4B0F-B148-BCC1629AACE7}
32+
EndGlobalSection
33+
EndGlobal

logic/Client/GameStatusBar.xaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Client.GameStatusBar">
5+
<Grid x:Name="GameStatusGrid" Grid.Row="0" Grid.Column="4" Grid.RowSpan="2">
6+
<Grid.RowDefinitions>
7+
<RowDefinition Height="5*" />
8+
<RowDefinition Height="10*"/>
9+
<RowDefinition Height="10*"/>
10+
<RowDefinition Height="1*"/>
11+
<RowDefinition Height="20*"/>
12+
<RowDefinition Height="1*"/>
13+
<RowDefinition Height="20*"/>
14+
<RowDefinition Height="1*"/>
15+
<RowDefinition Height="50*" />
16+
</Grid.RowDefinitions>
17+
18+
<Label x:Name="GameTime" Text="时间:00:00" Grid.Row="1" HorizontalOptions="Start" VerticalOptions="Start"/>
19+
<Label x:Name="WormHole1HP" Text="虫洞1生命值" Grid.Row="2" HorizontalOptions="Start" VerticalOptions="End"/>
20+
<BoxView x:Name="WormHole1HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="3" HorizontalOptions="Start" VerticalOptions="End"/>
21+
<Label x:Name="WormHole2Hp" Text="虫洞2生命值" Grid.Row="4" HorizontalOptions="Start" VerticalOptions="End"/>
22+
<BoxView x:Name="WormHole2HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="5" HorizontalOptions="Start" VerticalOptions="End"/>
23+
<Label x:Name="WormHole3Hp" Text="虫洞3生命值" Grid.Row="6" HorizontalOptions="Start" VerticalOptions="End"/>
24+
<BoxView x:Name="WormHole3HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="7" HorizontalOptions="Start" VerticalOptions="End"/>
25+
</Grid>
26+
</ContentView>

logic/Client/GameStatusBar.xaml.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Protobuf;
2+
3+
namespace Client;
4+
5+
public partial class GameStatusBar : ContentView
6+
{
7+
private readonly int lengthOfHp1Slide;
8+
private readonly int lengthOfHp2Slide;
9+
private readonly int lengthOfHp3Slide;
10+
private readonly int WormHoleFullHp = 18000;
11+
public GameStatusBar(Grid parent, int Row, int Column)
12+
{
13+
InitializeComponent();
14+
parent.Children.Add(this);
15+
parent.SetColumn(this, Column);
16+
parent.SetRow(this, Row);
17+
parent.SetRowSpan(this, 2);
18+
}
19+
public void SetWormHoleValue(MessageOfBuilding wormholeMsg)
20+
{
21+
if (wormholeMsg.BuildingType != BuildingType.Wormhole)
22+
{
23+
return;
24+
}
25+
switch (wormholeMsg.BuildingId)
26+
{
27+
case 0:
28+
WormHole1HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp1Slide;
29+
break;
30+
case 1:
31+
WormHole2HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp2Slide;
32+
break;
33+
case 2:
34+
WormHole3HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp3Slide;
35+
break;
36+
}
37+
}
38+
39+
public void SetGameTimeValue(MessageOfAll obj)
40+
{
41+
int min, sec;
42+
sec = obj.GameTime / 1000;
43+
min = sec / 60;
44+
sec = sec % 60;
45+
GameTime.Text = "时间:";
46+
if (min / 10 == 0)
47+
{
48+
GameTime.Text += "0";
49+
}
50+
GameTime.Text += min.ToString() + ":";
51+
if (sec / 10 == 0)
52+
{
53+
GameTime.Text += "0";
54+
}
55+
GameTime.Text += sec.ToString();
56+
}
57+
58+
}

logic/Client/Logo.png

-55 KB
Binary file not shown.

0 commit comments

Comments
 (0)