feat: client configuration file added
This commit is contained in:
parent
5df09f64e2
commit
bc6aaa865a
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@ -33,17 +33,6 @@
|
|||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"console": "internalConsole"
|
"console": "internalConsole"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": ".NET Launch (Host)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "build",
|
|
||||||
"program": "${workspaceFolder}/Platforms/Desktop/bin/Debug/net9.0/Desktop.exe",
|
|
||||||
"args": ["--server"],
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"console": "internalConsole"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"compounds": [
|
"compounds": [
|
||||||
|
2
Engine
2
Engine
@ -1 +1 @@
|
|||||||
Subproject commit c3be8f60b7e78984bb73501dc4d273a05b1331d2
|
Subproject commit 767fc28488fbbea9d1125f91934f4b882275890c
|
11
Platforms/Desktop/ClientConfiguration.cs
Normal file
11
Platforms/Desktop/ClientConfiguration.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
public class ClientConfiguration
|
||||||
|
{
|
||||||
|
public bool Host = false;
|
||||||
|
public int HostPort = 8888;
|
||||||
|
|
||||||
|
public string ServerAddress = "localhost";
|
||||||
|
public int ServerPort = 8888;
|
||||||
|
|
||||||
|
public int windowWidth = 1024;
|
||||||
|
public int windowHeight = 576;
|
||||||
|
}
|
@ -39,6 +39,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../../Shared/Shared.csproj" />
|
<ProjectReference Include="../../Shared/Shared.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Engine\Engine.Serializers\Engine.Serializers.Yaml\Engine.Serializers.Yaml.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
|
||||||
<Message Text="Restoring dotnet tools" Importance="High" />
|
<Message Text="Restoring dotnet tools" Importance="High" />
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
using Pong;
|
|
||||||
|
|
||||||
using Syntriax.Engine.Core;
|
using Syntriax.Engine.Core;
|
||||||
using Syntriax.Engine.Core.Debug;
|
using Syntriax.Engine.Core.Debug;
|
||||||
using Syntriax.Engine.Core.Serialization;
|
using Syntriax.Engine.Core.Serialization;
|
||||||
@ -24,21 +21,34 @@ logger = new LoggerWrapper(logger, new ConsoleLogger());
|
|||||||
|
|
||||||
universe.InstantiateUniverseObject().SetUniverseObject("Logger").BehaviourController.AddBehaviour<LoggerContainer>().Logger = logger;
|
universe.InstantiateUniverseObject().SetUniverseObject("Logger").BehaviourController.AddBehaviour<LoggerContainer>().Logger = logger;
|
||||||
|
|
||||||
bool isServerEnabled = Environment.GetCommandLineArgs().FirstOrDefault(x => x.CompareTo("--server") == 0) is not null;
|
string settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.yaml");
|
||||||
|
ClientConfiguration clientConfiguration;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clientConfiguration = serializer.Deserialize<ClientConfiguration>(File.ReadAllText(settingsPath));
|
||||||
|
logger.Log(clientConfiguration, $"{settingsPath} read");
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
clientConfiguration = new();
|
||||||
|
logger.LogError(serializer, $"Error loading {settingsPath}. Creating new settings file");
|
||||||
|
logger.LogException(serializer, exception);
|
||||||
|
File.WriteAllText(settingsPath, serializer.Serialize(clientConfiguration));
|
||||||
|
}
|
||||||
|
|
||||||
if (isServerEnabled)
|
if (clientConfiguration.Host)
|
||||||
PongUniverse.ApplyPongServer(universe, 8888);
|
Pong.PongUniverse.ApplyPongServer(universe, clientConfiguration.HostPort);
|
||||||
|
|
||||||
PongUniverse.ApplyPongClient(universe, "localhost", 8888);
|
Pong.PongUniverse.ApplyPongClient(universe, clientConfiguration.ServerAddress, clientConfiguration.ServerPort);
|
||||||
PongUniverse.ApplyPongUniverse(universe);
|
Pong.PongUniverse.ApplyPongUniverse(universe);
|
||||||
|
|
||||||
universe.InstantiateUniverseObject().SetUniverseObject("Desktop HO")
|
universe.InstantiateUniverseObject().SetUniverseObject("Desktop HO")
|
||||||
.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||||
|
|
||||||
using MonoGameWindow monoGameWindow = new(universe);
|
using MonoGameWindow monoGameWindow = new(universe);
|
||||||
|
|
||||||
monoGameWindow.Graphics.PreferredBackBufferWidth = 1024;
|
monoGameWindow.Graphics.PreferredBackBufferWidth = clientConfiguration.windowWidth;
|
||||||
monoGameWindow.Graphics.PreferredBackBufferHeight = 576;
|
monoGameWindow.Graphics.PreferredBackBufferHeight = clientConfiguration.windowHeight;
|
||||||
monoGameWindow.Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
monoGameWindow.Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
||||||
|
|
||||||
monoGameWindow.Run();
|
monoGameWindow.Run();
|
||||||
|
18
Pong.sln
18
Pong.sln
@ -25,6 +25,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Integration.MonoGame
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Platforms\Server\Server.csproj", "{A15263DB-DF65-4A07-8CA1-33A2919501A0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Platforms\Server\Server.csproj", "{A15263DB-DF65-4A07-8CA1-33A2919501A0}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine.Serializers", "Engine.Serializers", "{F1257AE1-A8BC-DE44-CB86-406F1335A1D0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Serializers.Yaml", "Engine\Engine.Serializers\Engine.Serializers.Yaml\Engine.Serializers.Yaml.csproj", "{79F870AB-249E-4CA0-9DF0-F265514581DF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -131,6 +135,18 @@ Global
|
|||||||
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x64.Build.0 = Release|Any CPU
|
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.ActiveCfg = Release|Any CPU
|
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.Build.0 = Release|Any CPU
|
{A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -144,5 +160,7 @@ Global
|
|||||||
{9059393F-4073-9273-0EEC-2B1BA61B620B} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
|
{9059393F-4073-9273-0EEC-2B1BA61B620B} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
|
||||||
{7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283} = {9059393F-4073-9273-0EEC-2B1BA61B620B}
|
{7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283} = {9059393F-4073-9273-0EEC-2B1BA61B620B}
|
||||||
{A15263DB-DF65-4A07-8CA1-33A2919501A0} = {FECFFD54-338F-4060-9161-1E5770D1DC33}
|
{A15263DB-DF65-4A07-8CA1-33A2919501A0} = {FECFFD54-338F-4060-9161-1E5770D1DC33}
|
||||||
|
{F1257AE1-A8BC-DE44-CB86-406F1335A1D0} = {F7F62670-237A-4C93-A30E-CE661C6FC401}
|
||||||
|
{79F870AB-249E-4CA0-9DF0-F265514581DF} = {F1257AE1-A8BC-DE44-CB86-406F1335A1D0}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
Loading…
x
Reference in New Issue
Block a user