Skip to content

Commit 2678005

Browse files
Merge pull request #30 from markuskonojacki/dev
Dev
2 parents 20204a6 + 1e66a63 commit 2678005

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

Logic/Logic.Ui/Chatroom.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private static void ClientOnObjectReceived(SimpleSocketClient simpleSocketClient
273273
{
274274
Application.Current.Dispatcher.Invoke(delegate
275275
{
276-
ManageCharacterRequestPacket();
276+
new Task<Task>(async () => await ManageCharacterRequestPacket()).Start();
277277
});
278278
}
279279
else if (obj.GetType() == typeof(CharacterDataPacket))

Logic/Logic.Ui/Logic.Ui.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0-windows</TargetFramework>
4+
<TargetFramework>net6.0-windows7.0</TargetFramework>
55
<AssemblyName>PhexensWuerfelraum.Logic.Ui</AssemblyName>
66
<RootNamespace>PhexensWuerfelraum.Logic.Ui</RootNamespace>
77
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

Logic/Logic.Ui/ViewModels/NavigationViewModel.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ public class NavigationViewModel : BaseViewModel
1212

1313
public NavigationViewModel()
1414
{
15-
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.CommentTextMultiple }, IsEnabled = true, Text = "Chat'n'Roll", NavigationDestination = new Uri("Views/ChatnRollPage.xaml", UriKind.RelativeOrAbsolute) });
16-
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Brush }, IsEnabled = true, Text = "Whiteboard", NavigationDestination = new Uri("Views/WhiteboardPage.xaml", UriKind.RelativeOrAbsolute) });
17-
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.SwordCross }, IsEnabled = false, Text = "BattleMap", NavigationDestination = new Uri("Views/BattleMapPage.xaml", UriKind.RelativeOrAbsolute) });
18-
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.AccountEdit }, IsEnabled = true, Text = "Charakter", NavigationDestination = new Uri("Views/CharacterPage.xaml", UriKind.RelativeOrAbsolute) });
19-
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.HeartBroken }, IsEnabled = true, Text = "Patzertabelle", NavigationDestination = new Uri("Views/PatzerTabellePage.xaml", UriKind.RelativeOrAbsolute) });
20-
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Wikipedia }, IsEnabled = true, Text = "Wiki", NavigationDestination = new Uri("Views/WikiPage.xaml", UriKind.RelativeOrAbsolute) });
15+
if (OperatingSystem.IsWindowsVersionAtLeast(7))
16+
{
17+
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.CommentTextMultiple }, IsEnabled = true, Text = "Chat'n'Roll", NavigationDestination = new Uri("Views/ChatnRollPage.xaml", UriKind.RelativeOrAbsolute) });
18+
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Brush }, IsEnabled = true, Text = "Whiteboard", NavigationDestination = new Uri("Views/WhiteboardPage.xaml", UriKind.RelativeOrAbsolute) });
19+
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.SwordCross }, IsEnabled = false, Text = "BattleMap", NavigationDestination = new Uri("Views/BattleMapPage.xaml", UriKind.RelativeOrAbsolute) });
20+
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.AccountEdit }, IsEnabled = true, Text = "Charakter", NavigationDestination = new Uri("Views/CharacterPage.xaml", UriKind.RelativeOrAbsolute) });
21+
Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.HeartBroken }, IsEnabled = true, Text = "Patzertabelle", NavigationDestination = new Uri("Views/PatzerTabellePage.xaml", UriKind.RelativeOrAbsolute) });
22+
//Menu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Wikipedia }, IsEnabled = true, Text = "Wiki", NavigationDestination = new Uri("Views/WikiPage.xaml", UriKind.RelativeOrAbsolute) });
2123

22-
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Cogs }, IsEnabled = true, Text = "Einstellungen", NavigationDestination = new Uri("Views/SettingsPage.xaml", UriKind.RelativeOrAbsolute) });
23-
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Information }, IsEnabled = true, Text = "Über", NavigationDestination = new Uri("Views/AboutPage.xaml", UriKind.RelativeOrAbsolute) });
24+
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Cogs }, IsEnabled = true, Text = "Einstellungen", NavigationDestination = new Uri("Views/SettingsPage.xaml", UriKind.RelativeOrAbsolute) });
25+
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Information }, IsEnabled = true, Text = "Über", NavigationDestination = new Uri("Views/AboutPage.xaml", UriKind.RelativeOrAbsolute) });
26+
}
2427
}
2528

2629
public ObservableCollection<MenuItem> Menu => AppMenu;

Server/Server.Console/Program.cs

+35-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using SimpleSockets;
1111
using SimpleSockets.Messaging.Metadata;
1212
using SimpleSockets.Server;
13+
using Newtonsoft.Json.Linq;
1314

1415
namespace PhexensWuerfelraum.Server.Console
1516
{
@@ -21,7 +22,9 @@ internal class Program
2122
private static SimpleSocketListener _listener;
2223

2324
private static readonly List<HeartbeatPacket> heartbeats = new();
24-
private static Dictionary<int, int> d20statistic = new();
25+
private static Dictionary<int, int> d20statistic;
26+
private static JObject d20statisticJson;
27+
private static string d20statisticPath;
2528

2629
#region version
2730

@@ -39,12 +42,32 @@ private static void Main(string[] args)
3942
WriteLine($"Starting the server {Version}");
4043

4144
// make sure the config folder exists
42-
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config"));
45+
string configFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config");
46+
Directory.CreateDirectory(configFolder);
4347

4448
var privKeyFileName = "PrivateKey.pfx";
45-
var privateKeyPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", privKeyFileName));
49+
var privateKeyPath = Path.Combine(Path.Combine(configFolder, privKeyFileName));
4650
var publicKeyFileName = "PublicKey.pem";
47-
var publicKeyPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", publicKeyFileName));
51+
var publicKeyPath = Path.Combine(Path.Combine(configFolder, publicKeyFileName));
52+
53+
d20statisticPath = Path.Combine(configFolder, "d20statistic.json");
54+
55+
if (File.Exists(d20statisticPath))
56+
{
57+
d20statisticJson = JObject.Parse(File.ReadAllText(d20statisticPath));
58+
d20statistic = d20statisticJson.ToObject<Dictionary<int, int>>();
59+
}
60+
else
61+
{
62+
d20statistic = new();
63+
64+
for (int i = 1; i <= 20; i++)
65+
{
66+
d20statistic[i] = 0;
67+
}
68+
69+
WriteStatisticToDisk();
70+
}
4871

4972
if (File.Exists(privateKeyPath))
5073
{
@@ -78,17 +101,18 @@ private static void Main(string[] args)
78101
BindEvents();
79102
_listener.StartListening(Port);
80103

81-
for (int i = 1; i <= 20; i++)
82-
{
83-
d20statistic[i] = 0;
84-
}
85-
86104
while (true)
87105
{
88106
System.Console.Read();
89107
}
90108
}
91109

110+
private static void WriteStatisticToDisk()
111+
{
112+
d20statisticJson = JObject.FromObject(d20statistic);
113+
File.WriteAllText(d20statisticPath, d20statisticJson.ToString());
114+
}
115+
92116
private static int ShowClients()
93117
{
94118
var ids = new List<int>();
@@ -206,6 +230,8 @@ private static void ListenerOnObjectReceived(IClientInfo client, object obj, Typ
206230
WriteLine($"{i}: {d20statistic[i]} ({Math.Round((double)d20statistic[i] / (double)sumRolls * 100, 2)} %)");
207231
}
208232
WriteLine($"sum: {sumRolls} d20 rolls");
233+
234+
WriteStatisticToDisk();
209235
}
210236
}
211237

Ui/Ui.Desktop/Ui.Desktop.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
55
<TargetName>PhexensWuerfelraum</TargetName>
6-
<TargetFramework>net6.0-windows</TargetFramework>
6+
<TargetFramework>net6.0-windows7.0</TargetFramework>
77
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
88
<UseWPF>true</UseWPF>
99
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>

0 commit comments

Comments
 (0)