diff --git a/rabi_splitter_WPF/MainWindow.xaml b/rabi_splitter_WPF/MainWindow.xaml
index 733aaab..db24e6e 100644
--- a/rabi_splitter_WPF/MainWindow.xaml
+++ b/rabi_splitter_WPF/MainWindow.xaml
@@ -26,10 +26,13 @@
-
-
-
-
+
+
+
+
+
+
+
diff --git a/rabi_splitter_WPF/MainWindow.xaml.cs b/rabi_splitter_WPF/MainWindow.xaml.cs
index 68f2ea5..7f590bd 100644
--- a/rabi_splitter_WPF/MainWindow.xaml.cs
+++ b/rabi_splitter_WPF/MainWindow.xaml.cs
@@ -1,20 +1,12 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
using System.Windows.Threading;
namespace rabi_splitter_WPF
@@ -181,5 +173,73 @@ namespace rabi_splitter_WPF
s.ScrollToEnd();
}
}
+
+ private void CommandButton_Click(object sender, RoutedEventArgs e)
+ {
+ var userInput = SpawnMessageBox("Input Command");
+ if (userInput == null) return;
+ debugContext.Log($">>> {userInput}");
+
+ var args = userInput.Split();
+ if (args.Length < 1) return;
+
+ string errorMessage = null;
+ switch (args[0])
+ {
+ case "set":
+ if (args.Length < 3)
+ {
+ errorMessage = "Invalid Format. Expected 'set '";
+ break;
+ }
+ errorMessage = rabiRibiDisplay.TrySetProperty(args[1], args[2]);
+ break;
+ default:
+ errorMessage = "Invalid Command";
+ break;
+ }
+ if (errorMessage != null) {
+ debugContext.Log(errorMessage);
+ }
+ }
+
+ private string SpawnMessageBox(string label)
+ {
+ var dialog = new System.Windows.Forms.Form()
+ {
+ Height = 105,
+ Width = 340,
+ StartPosition = System.Windows.Forms.FormStartPosition.CenterParent,
+ FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog,
+ MaximizeBox = false,
+ MinimizeBox = false,
+ };
+
+ var textLabel = new System.Windows.Forms.Label() { Left = 0, Top = 0, Width = 320, Text = label, TextAlign = System.Drawing.ContentAlignment.MiddleCenter };
+ var textBox = new System.Windows.Forms.TextBox() { Left = 10, Top = 20, Width = 300 };
+ var cancelButton = new System.Windows.Forms.Button() { Text = "Cancel", Left = 70, Width = 80, Top = 40, DialogResult = System.Windows.Forms.DialogResult.Cancel };
+ var confirmButton = new System.Windows.Forms.Button() { Text = "Ok", Left = 170, Width = 80, Top = 40, DialogResult = System.Windows.Forms.DialogResult.OK };
+ cancelButton.Click += (s, e) => { dialog.Close(); };
+ confirmButton.Click += (s, e) => { dialog.Close(); };
+ dialog.Controls.Add(textBox);
+ dialog.Controls.Add(textLabel);
+ dialog.Controls.Add(cancelButton);
+ dialog.Controls.Add(confirmButton);
+ dialog.CancelButton = cancelButton;
+ dialog.AcceptButton = confirmButton;
+
+ string userInput;
+ if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ userInput = textBox.Text;
+ }
+ else
+ {
+ userInput = null;
+ }
+ dialog.Dispose();
+
+ return userInput;
+ }
}
}
diff --git a/rabi_splitter_WPF/RabiRibiDisplay.cs b/rabi_splitter_WPF/RabiRibiDisplay.cs
index b305d92..fe66564 100644
--- a/rabi_splitter_WPF/RabiRibiDisplay.cs
+++ b/rabi_splitter_WPF/RabiRibiDisplay.cs
@@ -395,5 +395,43 @@ namespace rabi_splitter_WPF
mainWindow.SendMessage($"setgametime {time}\r\n");
}
+
+ public string TrySetProperty(string varName, string value)
+ {
+ try
+ {
+ switch (varName)
+ {
+ case "deaths":
+ {
+ var intValue = int.Parse(value);
+ inGameState.nDeaths = intValue;
+ inGameState.nDeathsAlt = intValue;
+ break;
+ }
+ case "resets":
+ {
+ var intValue = int.Parse(value);
+ inGameState.nRestarts = intValue;
+ break;
+ }
+
+ default:
+ {
+ return $"Unknown Property: {varName}";
+ }
+ }
+ }
+ catch (FormatException)
+ {
+ return $"Invalid Format: {value}";
+ }
+ catch (OverflowException)
+ {
+ return $"Overflow: {value}";
+ }
+
+ return null;
+ }
}
}