Skip to content

Commit

Permalink
feat: ✨ finish UI and basic front-end logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Grange007 committed Oct 28, 2023
1 parent a967881 commit ca52a79
Show file tree
Hide file tree
Showing 46 changed files with 2,379 additions and 70 deletions.
23 changes: 23 additions & 0 deletions logic/Client/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Client"
x:Class="Client.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>

<Style x:Key="littleAttributes"
TargetType="Label">
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="FontSize" Value="Micro" />
</Style>
</ResourceDictionary>


</Application.Resources>
</Application>
12 changes: 12 additions & 0 deletions logic/Client/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Client
{
public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
}
14 changes: 14 additions & 0 deletions logic/Client/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Client.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Client"
Shell.FlyoutBehavior="Disabled">

<ShellContent
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage"
/>

</Shell>
10 changes: 10 additions & 0 deletions logic/Client/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Client
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}
130 changes: 97 additions & 33 deletions logic/Client/Client.csproj
Original file line number Diff line number Diff line change
@@ -1,33 +1,97 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>eesast_software_trans_enlarged.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="Logo.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="FrameRateTask" Version="1.2.0" />
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Core" Version="2.46.6" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
<ProjectReference Include="..\..\playback\Playback\Playback.csproj" />
<ProjectReference Include="..\Preparation\Preparation.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="Logo.png" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Client</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>Client</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.client</ApplicationId>
<ApplicationIdGuid>872eca96-e290-4365-952b-f5e5b16e7217</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<MauiImage Include="Resources\Images\eesast_logo_32x32.png" />
<MauiImage Include="Resources\Images\eesast_software_trans_enlarged_256x256.png" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.24.4" />
<PackageReference Include="Grpc" Version="2.46.6" />
<PackageReference Include="Grpc.Tools" Version="2.54.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>


<ItemGroup>
<Compile Update="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Update="Map.xaml.cs">
<DependentUpon>Map.xaml</DependentUpon>
</Compile>
<Compile Update="GameStatusBar.xaml.cs">
<DependentUpon>GameStatusBar.xaml</DependentUpon>
</Compile>
<Compile Update="PlayerStatusBar.xaml.cs">
<DependentUpon>PlayerStatusBar.xaml</DependentUpon>
</Compile>
</ItemGroup>


<ItemGroup>
<MauiXaml Update="Map.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="GameStatusBar.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="PlayerStatusBar.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
</ItemGroup>

</Project>
70 changes: 33 additions & 37 deletions logic/Client/Client.sln
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client.csproj", "{5AD8481D-90EF-410C-BD48-355DB97EEAB3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Playback", "..\..\playback\Playback\Playback.csproj", "{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\..\dependency\proto\Protos.csproj", "{A0F72D3B-9A82-48EB-90AF-B3770151AD83}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD8481D-90EF-410C-BD48-355DB97EEAB3}.Release|Any CPU.Build.0 = Release|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Debug|Any CPU.Build.0 = Debug|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.ActiveCfg = Release|Any CPU
{662FDB27-FBF3-4D2D-BDA4-B4BF4D35B866}.Release|Any CPU.Build.0 = Release|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A0F72D3B-9A82-48EB-90AF-B3770151AD83}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89A74B1B-445C-49EB-9C93-506DC243C227}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client.csproj", "{F75BC602-8C64-4645-9C9A-2DF71085C52C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\..\dependency\proto\Protos.csproj", "{DAE45955-E55C-4E11-80B4-E7EC77E11C89}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.Build.0 = Release|Any CPU
{F75BC602-8C64-4645-9C9A-2DF71085C52C}.Release|Any CPU.Deploy.0 = Release|Any CPU
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAE45955-E55C-4E11-80B4-E7EC77E11C89}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C1CF739-9F04-4B0F-B148-BCC1629AACE7}
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions logic/Client/GameStatusBar.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Client.GameStatusBar">
<Grid x:Name="GameStatusGrid" Grid.Row="0" Grid.Column="4" Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition Height="10*"/>
<RowDefinition Height="10*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="20*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="20*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="50*" />
</Grid.RowDefinitions>

<Label x:Name="GameTime" Text="时间:00:00" Grid.Row="1" HorizontalOptions="Start" VerticalOptions="Start"/>
<Label x:Name="WormHole1HP" Text="虫洞1生命值" Grid.Row="2" HorizontalOptions="Start" VerticalOptions="End"/>
<BoxView x:Name="WormHole1HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="3" HorizontalOptions="Start" VerticalOptions="End"/>
<Label x:Name="WormHole2Hp" Text="虫洞2生命值" Grid.Row="4" HorizontalOptions="Start" VerticalOptions="End"/>
<BoxView x:Name="WormHole2HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="5" HorizontalOptions="Start" VerticalOptions="End"/>
<Label x:Name="WormHole3Hp" Text="虫洞3生命值" Grid.Row="6" HorizontalOptions="Start" VerticalOptions="End"/>
<BoxView x:Name="WormHole3HpSlide" Color="Green" HeightRequest="3" WidthRequest="80" Grid.Row="7" HorizontalOptions="Start" VerticalOptions="End"/>
</Grid>
</ContentView>
59 changes: 59 additions & 0 deletions logic/Client/GameStatusBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Protobuf;

namespace Client;

public partial class GameStatusBar : ContentView
{
private readonly int lengthOfHp1Slide;
private readonly int lengthOfHp2Slide;
private readonly int lengthOfHp3Slide;

Check warning on line 9 in logic/Client/GameStatusBar.xaml.cs

View workflow job for this annotation

GitHub Actions / dotnet-build

Field 'GameStatusBar.lengthOfHp3Slide' is never assigned to, and will always have its default value 0
private readonly int WormHoleFullHp = 18000;
public GameStatusBar(Grid parent, int Row, int Column)
{
InitializeComponent();
parent.Children.Add(this);
parent.SetColumn(this, Column);
parent.SetRow(this, Row);
parent.SetRowSpan(this, 2);
}

public void SetWormHoleValue(MessageOfBuilding wormholeMsg)
{
if (wormholeMsg.BuildingType != BuildingType.Wormhole)
{
return;
}
switch (wormholeMsg.BuildingId)
{
case 0:
WormHole1HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp1Slide;
break;
case 1:
WormHole2HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp2Slide;
break;
case 2:
WormHole3HpSlide.WidthRequest = wormholeMsg.Hp / WormHoleFullHp * lengthOfHp3Slide;
break;
}
}

public void SetGameTimeValue(MessageOfAll obj)
{
int min, sec;
sec = obj.GameTime / 1000;
min = sec / 60;
sec = sec % 60;
GameTime.Text = "时间:";
if (min / 10 == 0)
{
GameTime.Text += "0";
}
GameTime.Text += min.ToString() + ":";
if (sec / 10 == 0)
{
GameTime.Text += "0";
}
GameTime.Text += sec.ToString();
}

}
Binary file removed logic/Client/Logo.png
Binary file not shown.
Loading

0 comments on commit ca52a79

Please sign in to comment.