Skip to content

Commit

Permalink
Merge pull request #30 from markuskonojacki/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
markuskonojacki authored Sep 14, 2022
2 parents 20204a6 + 1e66a63 commit 2678005
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Logic/Logic.Ui/Chatroom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static void ClientOnObjectReceived(SimpleSocketClient simpleSocketClient
{
Application.Current.Dispatcher.Invoke(delegate
{
ManageCharacterRequestPacket();
new Task<Task>(async () => await ManageCharacterRequestPacket()).Start();
});
}
else if (obj.GetType() == typeof(CharacterDataPacket))
Expand Down
2 changes: 1 addition & 1 deletion Logic/Logic.Ui/Logic.Ui.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<AssemblyName>PhexensWuerfelraum.Logic.Ui</AssemblyName>
<RootNamespace>PhexensWuerfelraum.Logic.Ui</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
19 changes: 11 additions & 8 deletions Logic/Logic.Ui/ViewModels/NavigationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ public class NavigationViewModel : BaseViewModel

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

OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Cogs }, IsEnabled = true, Text = "Einstellungen", NavigationDestination = new Uri("Views/SettingsPage.xaml", UriKind.RelativeOrAbsolute) });
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Information }, IsEnabled = true, Text = "Über", NavigationDestination = new Uri("Views/AboutPage.xaml", UriKind.RelativeOrAbsolute) });
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Cogs }, IsEnabled = true, Text = "Einstellungen", NavigationDestination = new Uri("Views/SettingsPage.xaml", UriKind.RelativeOrAbsolute) });
OptionsMenu.Add(new MenuItem() { Icon = new PackIconMaterial() { Kind = PackIconMaterialKind.Information }, IsEnabled = true, Text = "Über", NavigationDestination = new Uri("Views/AboutPage.xaml", UriKind.RelativeOrAbsolute) });
}
}

public ObservableCollection<MenuItem> Menu => AppMenu;
Expand Down
44 changes: 35 additions & 9 deletions Server/Server.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using SimpleSockets;
using SimpleSockets.Messaging.Metadata;
using SimpleSockets.Server;
using Newtonsoft.Json.Linq;

namespace PhexensWuerfelraum.Server.Console
{
Expand All @@ -21,7 +22,9 @@ internal class Program
private static SimpleSocketListener _listener;

private static readonly List<HeartbeatPacket> heartbeats = new();
private static Dictionary<int, int> d20statistic = new();
private static Dictionary<int, int> d20statistic;
private static JObject d20statisticJson;
private static string d20statisticPath;

#region version

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

// make sure the config folder exists
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config"));
string configFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config");
Directory.CreateDirectory(configFolder);

var privKeyFileName = "PrivateKey.pfx";
var privateKeyPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", privKeyFileName));
var privateKeyPath = Path.Combine(Path.Combine(configFolder, privKeyFileName));
var publicKeyFileName = "PublicKey.pem";
var publicKeyPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", publicKeyFileName));
var publicKeyPath = Path.Combine(Path.Combine(configFolder, publicKeyFileName));

d20statisticPath = Path.Combine(configFolder, "d20statistic.json");

if (File.Exists(d20statisticPath))
{
d20statisticJson = JObject.Parse(File.ReadAllText(d20statisticPath));
d20statistic = d20statisticJson.ToObject<Dictionary<int, int>>();
}
else
{
d20statistic = new();

for (int i = 1; i <= 20; i++)
{
d20statistic[i] = 0;
}

WriteStatisticToDisk();
}

if (File.Exists(privateKeyPath))
{
Expand Down Expand Up @@ -78,17 +101,18 @@ private static void Main(string[] args)
BindEvents();
_listener.StartListening(Port);

for (int i = 1; i <= 20; i++)
{
d20statistic[i] = 0;
}

while (true)
{
System.Console.Read();
}
}

private static void WriteStatisticToDisk()
{
d20statisticJson = JObject.FromObject(d20statistic);
File.WriteAllText(d20statisticPath, d20statisticJson.ToString());
}

private static int ShowClients()
{
var ids = new List<int>();
Expand Down Expand Up @@ -206,6 +230,8 @@ private static void ListenerOnObjectReceived(IClientInfo client, object obj, Typ
WriteLine($"{i}: {d20statistic[i]} ({Math.Round((double)d20statistic[i] / (double)sumRolls * 100, 2)} %)");
}
WriteLine($"sum: {sumRolls} d20 rolls");

WriteStatisticToDisk();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Ui/Ui.Desktop/Ui.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetName>PhexensWuerfelraum</TargetName>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
Expand Down

0 comments on commit 2678005

Please sign in to comment.