Added config file to client
This commit is contained in:
23
src/FluckyGame.Client/FluckyGame.Client/ClientSettings.cs
Normal file
23
src/FluckyGame.Client/FluckyGame.Client/ClientSettings.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FluckyGame.Client
|
||||||
|
{
|
||||||
|
internal class ClientSettings
|
||||||
|
{
|
||||||
|
public Resolution resolution;
|
||||||
|
public Server server;
|
||||||
|
|
||||||
|
public struct Resolution
|
||||||
|
{
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
public bool fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct Server
|
||||||
|
{
|
||||||
|
public string hostname;
|
||||||
|
public int port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -64,6 +64,10 @@
|
|||||||
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||||
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
<Reference Include="Microsoft.Xna.Framework.GamerServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
@@ -73,6 +77,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Bone.cs" />
|
<Compile Include="Bone.cs" />
|
||||||
|
<Compile Include="ClientSettings.cs" />
|
||||||
<Compile Include="Entities\BouncingEntity.cs" />
|
<Compile Include="Entities\BouncingEntity.cs" />
|
||||||
<Compile Include="Entities\Entity.cs" />
|
<Compile Include="Entities\Entity.cs" />
|
||||||
<Compile Include="Entities\TerrainEntity.cs" />
|
<Compile Include="Entities\TerrainEntity.cs" />
|
||||||
@@ -119,6 +124,12 @@
|
|||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="client.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||||
<!--
|
<!--
|
||||||
|
@@ -14,7 +14,7 @@ using FluckyGame.Library;
|
|||||||
|
|
||||||
namespace FluckyGame.Client
|
namespace FluckyGame.Client
|
||||||
{
|
{
|
||||||
public class Game1 : Microsoft.Xna.Framework.Game
|
internal class Game1 : Microsoft.Xna.Framework.Game
|
||||||
{
|
{
|
||||||
public static Game1 currentInstance;
|
public static Game1 currentInstance;
|
||||||
public static Random random;
|
public static Random random;
|
||||||
@@ -47,7 +47,7 @@ namespace FluckyGame.Client
|
|||||||
random = new Random();
|
random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game1(TcpClient tcpClient)
|
public Game1(TcpClient tcpClient, ClientSettings clientSettings)
|
||||||
{
|
{
|
||||||
this.tcpClient = tcpClient;
|
this.tcpClient = tcpClient;
|
||||||
|
|
||||||
@@ -55,8 +55,9 @@ namespace FluckyGame.Client
|
|||||||
|
|
||||||
graphicsDeviceManager = new GraphicsDeviceManager(this)
|
graphicsDeviceManager = new GraphicsDeviceManager(this)
|
||||||
{
|
{
|
||||||
PreferredBackBufferWidth = 1920 / 2,
|
PreferredBackBufferWidth = clientSettings.resolution.width,
|
||||||
PreferredBackBufferHeight = 1080 / 2
|
PreferredBackBufferHeight = clientSettings.resolution.height,
|
||||||
|
IsFullScreen = clientSettings.resolution.fullscreen
|
||||||
};
|
};
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
|
|
||||||
|
@@ -1,18 +1,23 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace FluckyGame.Client
|
namespace FluckyGame.Client
|
||||||
{
|
{
|
||||||
static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
//TODO: error handling !!!
|
||||||
|
var settings = JsonConvert.DeserializeObject<ClientSettings>(File.ReadAllText("client.json"));
|
||||||
|
|
||||||
TcpClient tcpClient;
|
TcpClient tcpClient;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tcpClient = new TcpClient("home.brunner.ninja", 8001);
|
tcpClient = new TcpClient(settings.server.hostname, settings.server.port);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -20,7 +25,7 @@ namespace FluckyGame.Client
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (Game1 game = new Game1(tcpClient))
|
using (Game1 game = new Game1(tcpClient, settings))
|
||||||
game.Run();
|
game.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
src/FluckyGame.Client/FluckyGame.Client/client.json
Normal file
11
src/FluckyGame.Client/FluckyGame.Client/client.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"resolution": {
|
||||||
|
"width": 3840,
|
||||||
|
"height": 2160,
|
||||||
|
"fullscreen": true
|
||||||
|
},
|
||||||
|
"server": {
|
||||||
|
"hostname": "localhost",
|
||||||
|
"port": 8001
|
||||||
|
}
|
||||||
|
}
|
4
src/FluckyGame.Client/FluckyGame.Client/packages.config
Normal file
4
src/FluckyGame.Client/FluckyGame.Client/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
|
||||||
|
</packages>
|
Reference in New Issue
Block a user