diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..1452ed3 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,13 @@ + + + + latest + true + 1591 + MIT + https://git.pilzinsel64.de/sm64-rom-manager/sm64-rom-manager + Pilzinsel64 + enable + + + \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config index b9b6491..5deed28 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Project64Savestater/App.config b/Project64Savestater/App.config index 565b94b..baaedee 100644 --- a/Project64Savestater/App.config +++ b/Project64Savestater/App.config @@ -2,6 +2,6 @@ - + diff --git a/Project64Savestater/AppGlobals.cs b/Project64Savestater/AppGlobals.cs new file mode 100644 index 0000000..37d8067 --- /dev/null +++ b/Project64Savestater/AppGlobals.cs @@ -0,0 +1,23 @@ +using Pilz.UI.Telerik.Symbols; +using System.Reflection; +using System.Runtime.CompilerServices; + +namespace PJ64Savestater; + +public static class AppGlobals +{ + public static IRadSymbolFactory Symbols { get; } = new AppSymbolFactory(); + + private class AppSymbolFactory : RadSymbolFactory + { + public override Assembly GetImageResourceAssembly() + { + return Assembly.GetExecutingAssembly(); + } + + public override string GetImageRessourcePath(AppSymbols svgImage) + { + return $"{typeof(AppGlobals).Namespace}.Symbols.{svgImage}.svg"; + } + } +} diff --git a/Project64Savestater/AppSymbols.cs b/Project64Savestater/AppSymbols.cs new file mode 100644 index 0000000..133ed16 --- /dev/null +++ b/Project64Savestater/AppSymbols.cs @@ -0,0 +1,11 @@ +namespace PJ64Savestater; + +public enum AppSymbols +{ + browse_folder, + circled_play, + game_controller, + refresh, + save, + stop_cicled, +} diff --git a/Project64Savestater/ControllerTypes.cs b/Project64Savestater/ControllerTypes.cs index 868d466..73272b1 100644 --- a/Project64Savestater/ControllerTypes.cs +++ b/Project64Savestater/ControllerTypes.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PJ64Savestater; -namespace PJ64Savestater +public enum ControllerTypes : byte { - public enum ControllerTypes : byte - { - Keyboard, - DirectInput - } + Keyboard, + DirectInput } diff --git a/Project64Savestater/Globals.cs b/Project64Savestater/Globals.cs index 3824b87..c7dcb6c 100644 --- a/Project64Savestater/Globals.cs +++ b/Project64Savestater/Globals.cs @@ -1,24 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PJ64Savestater; -namespace PJ64Savestater +internal static class Globals { - internal static class Globals + public static bool CompareTwoByteArrays(byte[] arr1, byte[] arr2) { - public static bool CompareTwoByteArrays(byte[] arr1, byte[] arr2) - { - if (arr2.Count() != arr1.Count()) - return false; - for (int i = 0, loopTo = arr1.Count() - 1; i <= loopTo; i++) - { - if (arr1[i] != arr2[i]) - return false; - } + if (arr2.Length != arr1.Length) + return false; - return true; + for (int i = 0, loopTo = arr1.Length - 1; i <= loopTo; i++) + { + if (arr1[i] != arr2[i]) + return false; } + + return true; } } diff --git a/Project64Savestater/InputControl.cs b/Project64Savestater/InputControl.cs index 8e88c33..63591c7 100644 --- a/Project64Savestater/InputControl.cs +++ b/Project64Savestater/InputControl.cs @@ -1,43 +1,38 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PJ64Savestater; -namespace PJ64Savestater +public class InputControl { - public class InputControl + public InputKeys? InputKey { get; set; } = null; + public int? KeyIndex { get; set; } = null; + public object? Value { get; set; } = null; + + public static bool operator ==(InputControl left, InputControl right) { - public InputKeys? InputKey { get; set; } = null; - public int? KeyIndex { get; set; } = null; - public object Value { get; set; } = null; + return left.InputKey == right.InputKey && left.KeyIndex == right.KeyIndex && (left.Value == null && right.Value == null || left.Value != null && right.Value != null && left.Value.Equals(right.Value)); + } - public static bool operator ==(InputControl left, InputControl right) - { - return left.InputKey == right.InputKey && left.KeyIndex == right.KeyIndex && ((left.Value == null && right.Value == null) || (left.Value != null && right.Value != null && left.Value.Equals(right.Value))); - } + public static bool operator !=(InputControl left, InputControl right) + { + return !(left == right); + } - public static bool operator !=(InputControl left, InputControl right) - { - return !(left == right); - } + public override bool Equals(object? obj) + { + return obj is InputControl control + && EqualityComparer.Default.Equals(InputKey, control.InputKey) + && EqualityComparer.Default.Equals(KeyIndex, control.KeyIndex) + && EqualityComparer.Default.Equals(Value, control.Value); + } - public override bool Equals(object obj) - { - var control = obj as InputControl; - return control != null && - EqualityComparer.Default.Equals(InputKey, control.InputKey) && - EqualityComparer.Default.Equals(KeyIndex, control.KeyIndex) && - EqualityComparer.Default.Equals(Value, control.Value); - } - - public override int GetHashCode() - { - var hashCode = 2070896532; + public override int GetHashCode() + { + var hashCode = 2070896532; + if (InputKey != null) hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(InputKey); + if (KeyIndex != null) hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(KeyIndex); + if (Value != null) hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Value); - return hashCode; - } + return hashCode; } } diff --git a/Project64Savestater/InputKeys.cs b/Project64Savestater/InputKeys.cs index 446ad25..87dbb6e 100644 --- a/Project64Savestater/InputKeys.cs +++ b/Project64Savestater/InputKeys.cs @@ -1,44 +1,37 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace PJ64Savestater; -namespace PJ64Savestater +public enum InputKeys : byte { - public enum InputKeys : byte - { - // Uses Index + // Uses Index - Buttons, // Button index 'Default: False - AccelerationSliders, // ASlider index 'Default: 0 - ForceSliders, // FSlider index 'Default: 0 - PointOfViewControllers, // Point index 'Default: -1 - Sliders, // Slider index 'Default: 0 - VelocitySliders, // VSlider index 'Default: 0 + Buttons, // Button index 'Default: False + AccelerationSliders, // ASlider index 'Default: 0 + ForceSliders, // FSlider index 'Default: 0 + PointOfViewControllers, // Point index 'Default: -1 + Sliders, // Slider index 'Default: 0 + VelocitySliders, // VSlider index 'Default: 0 - // Don't uses Index + // Don't uses Index - AccelerationX, // AX 'Default: 0 - AccelerationY, // AY 'Default: 0 - AccelerationZ, // AZ 'Default: 0 - AngularAccelerationX, // AAX 'Default: 0 - AngularAccelerationY, // AAY 'Default: 0 - AngularAccelerationZ, // AAZ 'Default: 0 - ForceX, // FX 'Default: 0 - ForceY, // FY 'Default: 0 - ForceZ, // FZ 'Default: 0 - RotationX, // RX 'Default: 0 - RotationY, // RY 'Default: 0 - RotationZ, // RZ 'Default: 0 - TorqueX, // TX 'Default: 0 - TorqueY, // TY 'Default: 0 - TorqueZ, // TZ 'Default: 0 - VelocityX, // VX 'Default: 0 - VelocityY, // VY 'Default: 0 - VelocityZ, // VZ 'Default: 0 - X, // X 'Default: 0 - Y, // Y 'Default: 0 - Z // Z 'Default: 0 - } + AccelerationX, // AX 'Default: 0 + AccelerationY, // AY 'Default: 0 + AccelerationZ, // AZ 'Default: 0 + AngularAccelerationX, // AAX 'Default: 0 + AngularAccelerationY, // AAY 'Default: 0 + AngularAccelerationZ, // AAZ 'Default: 0 + ForceX, // FX 'Default: 0 + ForceY, // FY 'Default: 0 + ForceZ, // FZ 'Default: 0 + RotationX, // RX 'Default: 0 + RotationY, // RY 'Default: 0 + RotationZ, // RZ 'Default: 0 + TorqueX, // TX 'Default: 0 + TorqueY, // TY 'Default: 0 + TorqueZ, // TZ 'Default: 0 + VelocityX, // VX 'Default: 0 + VelocityY, // VY 'Default: 0 + VelocityZ, // VZ 'Default: 0 + X, // X 'Default: 0 + Y, // Y 'Default: 0 + Z // Z 'Default: 0 } diff --git a/Project64Savestater/InputProfile.cs b/Project64Savestater/InputProfile.cs index 9ac52e4..1da03c2 100644 --- a/Project64Savestater/InputProfile.cs +++ b/Project64Savestater/InputProfile.cs @@ -1,82 +1,76 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace PJ64Savestater +namespace PJ64Savestater; + +public class InputProfile { - public class InputProfile + public string? ProfileCode { get; set; } + public Dictionary Controls { get; } = []; + + private byte[] _ControllerInstanceGuid = Array.Empty(); + + [JsonConstructor] + public InputProfile() { - public string ProfileCode { get; set; } - public Dictionary Controls { get; } = new Dictionary(); + } - private byte[] _ControllerInstanceGuid = Array.Empty(); + public InputProfile(string profileCode) + { + ProfileCode = profileCode; + } - [JsonConstructor] - public InputProfile() + public Guid ControllerInstanceGuid + { + get { + if (_ControllerInstanceGuid.Length == 0) + return default; + return new Guid(_ControllerInstanceGuid); } - - public InputProfile(string profileCode) + set { - ProfileCode = profileCode; - } - - public Guid ControllerInstanceGuid - { - get - { - if (_ControllerInstanceGuid.Count() == 0) - return default; - return new Guid(_ControllerInstanceGuid); - } - set - { - _ControllerInstanceGuid = value.ToByteArray(); - } - } - - public InputControl this[string name] - { - get - { - if (!Controls.ContainsKey(name)) - Controls.Add(name, new InputControl()); - return Controls[name]; - } - set - { - if (!Controls.ContainsKey(name)) - Controls.Add(name, value); - else - Controls[name] = value; - } - } - - public void ClearProfile() - { - Controls.Clear(); - } - - public void Save(string fileName) - { - File.WriteAllText(fileName, JObject.FromObject(this, GetJsonSerializer()).ToString()); - } - - public static InputProfile Load(string fileName) - { - return (InputProfile)JObject.Parse(File.ReadAllText(fileName)).ToObject(typeof(InputProfile), GetJsonSerializer()); - } - - private static JsonSerializer GetJsonSerializer() - { - var serializer = JsonSerializer.CreateDefault(); - serializer.TypeNameHandling = TypeNameHandling.Auto; - return serializer; + _ControllerInstanceGuid = value.ToByteArray(); } } + + public InputControl this[string name] + { + get + { + if (!Controls.ContainsKey(name)) + Controls.Add(name, new InputControl()); + return Controls[name]; + } + set + { + if (!Controls.ContainsKey(name)) + Controls.Add(name, value); + else + Controls[name] = value; + } + } + + public void ClearProfile() + { + Controls.Clear(); + } + + public void Save(string fileName) + { + File.WriteAllText(fileName, JsonConvert.SerializeObject(this, GetJsonSerializer())); + } + + public static InputProfile? Load(string fileName) + { + return JsonConvert.DeserializeObject(File.ReadAllText(fileName), GetJsonSerializer()); + } + + private static JsonSerializerSettings GetJsonSerializer() + { + return new() + { + TypeNameHandling = TypeNameHandling.Auto + }; + } } diff --git a/Project64Savestater/LangRes.Designer.cs b/Project64Savestater/LangRes.Designer.cs index 1c196d8..1b3d662 100644 --- a/Project64Savestater/LangRes.Designer.cs +++ b/Project64Savestater/LangRes.Designer.cs @@ -61,7 +61,7 @@ namespace PJ64Savestater { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Start Listening ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Start ähnelt. /// internal static string Button_StartListening { get { @@ -70,7 +70,7 @@ namespace PJ64Savestater { } /// - /// Sucht eine lokalisierte Zeichenfolge, die Stop Listening ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die Stop ähnelt. /// internal static string Button_StopListening { get { diff --git a/Project64Savestater/LangRes.de.resx b/Project64Savestater/LangRes.de.resx index 95bce5b..2870b25 100644 --- a/Project64Savestater/LangRes.de.resx +++ b/Project64Savestater/LangRes.de.resx @@ -117,11 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Zuhören beginnen - - Zuhören beenden + Stopp Dieses Profil ist für ein anderes Program bzw. für einen anderen Verwendungszweck. Es kann demnach nicht geladen und verwendet werden. diff --git a/Project64Savestater/LangRes.resx b/Project64Savestater/LangRes.resx index b3e1080..d5ed329 100644 --- a/Project64Savestater/LangRes.resx +++ b/Project64Savestater/LangRes.resx @@ -118,10 +118,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Start Listening + Start - Stop Listening + Stop This input profile is for a different program. It can't be loaded. diff --git a/Project64Savestater/MainForm.Designer.cs b/Project64Savestater/MainForm.Designer.cs index a1f7b07..663f270 100644 --- a/Project64Savestater/MainForm.Designer.cs +++ b/Project64Savestater/MainForm.Designer.cs @@ -28,143 +28,144 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); - this.radLabel1 = new Telerik.WinControls.UI.RadLabel(); - this.radDropDownList_Pads = new Telerik.WinControls.UI.RadDropDownList(); - this.radButton_LoadPads = new Telerik.WinControls.UI.RadButton(); - this.panel1 = new System.Windows.Forms.Panel(); - this.radTextBox_LoadSavestate = new Telerik.WinControls.UI.RadTextBox(); - this.radTextBox_CreateSavestate = new Telerik.WinControls.UI.RadTextBox(); - this.radButton_LoadProfile = new Telerik.WinControls.UI.RadButton(); - this.radButton_SaveProfile = new Telerik.WinControls.UI.RadButton(); - this.radButton_StartStopListening = new Telerik.WinControls.UI.RadButton(); - this.radLabel3 = new Telerik.WinControls.UI.RadLabel(); - this.radLabel2 = new Telerik.WinControls.UI.RadLabel(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radDropDownList_Pads)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_LoadPads)).BeginInit(); - this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.radTextBox_LoadSavestate)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radTextBox_CreateSavestate)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_LoadProfile)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_SaveProfile)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_StartStopListening)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel3)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); - this.SuspendLayout(); + var resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + radLabel1 = new Telerik.WinControls.UI.RadLabel(); + radDropDownList_Pads = new Telerik.WinControls.UI.RadDropDownList(); + radButton_LoadPads = new Telerik.WinControls.UI.RadButton(); + radTextBox_LoadSavestate = new Telerik.WinControls.UI.RadTextBox(); + radTextBox_CreateSavestate = new Telerik.WinControls.UI.RadTextBox(); + radButton_LoadProfile = new Telerik.WinControls.UI.RadButton(); + radButton_SaveProfile = new Telerik.WinControls.UI.RadButton(); + radButton_StartStopListening = new Telerik.WinControls.UI.RadButton(); + radLabel3 = new Telerik.WinControls.UI.RadLabel(); + radLabel2 = new Telerik.WinControls.UI.RadLabel(); + tableLayoutPanel1 = new TableLayoutPanel(); + ((System.ComponentModel.ISupportInitialize)radLabel1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radDropDownList_Pads).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radButton_LoadPads).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radTextBox_LoadSavestate).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radTextBox_CreateSavestate).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radButton_LoadProfile).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radButton_SaveProfile).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radButton_StartStopListening).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radLabel3).BeginInit(); + ((System.ComponentModel.ISupportInitialize)radLabel2).BeginInit(); + tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)this).BeginInit(); + SuspendLayout(); // // radLabel1 // - this.radLabel1.Image = global::PJ64Savestater.Properties.Resources.icons8_game_controller_16px; - resources.ApplyResources(this.radLabel1, "radLabel1"); - this.radLabel1.Name = "radLabel1"; + resources.ApplyResources(radLabel1, "radLabel1"); + radLabel1.Name = "radLabel1"; + // + // + // + radLabel1.RootElement.MinSize = new Size(0, 24); // // radDropDownList_Pads // - this.radDropDownList_Pads.DropDownAnimationEnabled = true; - this.radDropDownList_Pads.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; - resources.ApplyResources(this.radDropDownList_Pads, "radDropDownList_Pads"); - this.radDropDownList_Pads.Name = "radDropDownList_Pads"; - this.radDropDownList_Pads.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(this.radDropDownList1_SelectedIndexChanged); + resources.ApplyResources(radDropDownList_Pads, "radDropDownList_Pads"); + tableLayoutPanel1.SetColumnSpan(radDropDownList_Pads, 2); + radDropDownList_Pads.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; + radDropDownList_Pads.Name = "radDropDownList_Pads"; + radDropDownList_Pads.SelectedIndexChanged += RadDropDownList1_SelectedIndexChanged; // // radButton_LoadPads // - this.radButton_LoadPads.Image = global::PJ64Savestater.Properties.Resources.icons8_refresh_16px; - resources.ApplyResources(this.radButton_LoadPads, "radButton_LoadPads"); - this.radButton_LoadPads.Name = "radButton_LoadPads"; - this.radButton_LoadPads.Click += new System.EventHandler(this.radButton1_Click); - // - // panel1 - // - this.panel1.BackColor = System.Drawing.Color.Transparent; - this.panel1.Controls.Add(this.radTextBox_LoadSavestate); - this.panel1.Controls.Add(this.radTextBox_CreateSavestate); - this.panel1.Controls.Add(this.radButton_LoadProfile); - this.panel1.Controls.Add(this.radButton_SaveProfile); - this.panel1.Controls.Add(this.radButton_StartStopListening); - this.panel1.Controls.Add(this.radLabel3); - this.panel1.Controls.Add(this.radLabel2); - this.panel1.Controls.Add(this.radLabel1); - this.panel1.Controls.Add(this.radButton_LoadPads); - this.panel1.Controls.Add(this.radDropDownList_Pads); - resources.ApplyResources(this.panel1, "panel1"); - this.panel1.Name = "panel1"; + resources.ApplyResources(radButton_LoadPads, "radButton_LoadPads"); + radButton_LoadPads.Name = "radButton_LoadPads"; + radButton_LoadPads.Click += RadButton1_Click; // // radTextBox_LoadSavestate // - resources.ApplyResources(this.radTextBox_LoadSavestate, "radTextBox_LoadSavestate"); - this.radTextBox_LoadSavestate.Name = "radTextBox_LoadSavestate"; - this.radTextBox_LoadSavestate.TextChanged += new System.EventHandler(this.radTextBox2_TextChanged); - this.radTextBox_LoadSavestate.Click += new System.EventHandler(this.RadTextBox_Savestate_Clicked); - this.radTextBox_LoadSavestate.LostFocus += new System.EventHandler(this.RadTextBox_Savestate_LostFocus); + resources.ApplyResources(radTextBox_LoadSavestate, "radTextBox_LoadSavestate"); + radTextBox_LoadSavestate.Name = "radTextBox_LoadSavestate"; + radTextBox_LoadSavestate.TextChanged += RadTextBox2_TextChanged; + radTextBox_LoadSavestate.Click += RadTextBox_Savestate_Clicked; + radTextBox_LoadSavestate.LostFocus += RadTextBox_Savestate_LostFocus; // // radTextBox_CreateSavestate // - resources.ApplyResources(this.radTextBox_CreateSavestate, "radTextBox_CreateSavestate"); - this.radTextBox_CreateSavestate.Name = "radTextBox_CreateSavestate"; - this.radTextBox_CreateSavestate.TextChanged += new System.EventHandler(this.radTextBox1_TextChanged); - this.radTextBox_CreateSavestate.Click += new System.EventHandler(this.RadTextBox_Savestate_Clicked); - this.radTextBox_CreateSavestate.LostFocus += new System.EventHandler(this.RadTextBox_Savestate_LostFocus); + resources.ApplyResources(radTextBox_CreateSavestate, "radTextBox_CreateSavestate"); + radTextBox_CreateSavestate.Name = "radTextBox_CreateSavestate"; + radTextBox_CreateSavestate.TextChanged += RadTextBox1_TextChanged; + radTextBox_CreateSavestate.Click += RadTextBox_Savestate_Clicked; + radTextBox_CreateSavestate.LostFocus += RadTextBox_Savestate_LostFocus; // // radButton_LoadProfile // - this.radButton_LoadProfile.Image = global::PJ64Savestater.Properties.Resources.icons8_opened_folder_16px; - resources.ApplyResources(this.radButton_LoadProfile, "radButton_LoadProfile"); - this.radButton_LoadProfile.Name = "radButton_LoadProfile"; - this.radButton_LoadProfile.Click += new System.EventHandler(this.radButton4_Click); + resources.ApplyResources(radButton_LoadProfile, "radButton_LoadProfile"); + radButton_LoadProfile.Name = "radButton_LoadProfile"; + radButton_LoadProfile.Click += RadButton4_Click; // // radButton_SaveProfile // - this.radButton_SaveProfile.Image = global::PJ64Savestater.Properties.Resources.icons8_save_16px; - resources.ApplyResources(this.radButton_SaveProfile, "radButton_SaveProfile"); - this.radButton_SaveProfile.Name = "radButton_SaveProfile"; - this.radButton_SaveProfile.Click += new System.EventHandler(this.radButton3_Click); + resources.ApplyResources(radButton_SaveProfile, "radButton_SaveProfile"); + radButton_SaveProfile.Name = "radButton_SaveProfile"; + radButton_SaveProfile.Click += RadButton3_Click; // // radButton_StartStopListening // - this.radButton_StartStopListening.Image = global::PJ64Savestater.Properties.Resources.icons8_play_button_circled_16px; - resources.ApplyResources(this.radButton_StartStopListening, "radButton_StartStopListening"); - this.radButton_StartStopListening.Name = "radButton_StartStopListening"; - this.radButton_StartStopListening.Click += new System.EventHandler(this.radButton_StartStopListening_Click); + resources.ApplyResources(radButton_StartStopListening, "radButton_StartStopListening"); + radButton_StartStopListening.Name = "radButton_StartStopListening"; + radButton_StartStopListening.Click += RadButton_StartStopListening_Click; // // radLabel3 // - resources.ApplyResources(this.radLabel3, "radLabel3"); - this.radLabel3.Name = "radLabel3"; + resources.ApplyResources(radLabel3, "radLabel3"); + radLabel3.Name = "radLabel3"; + // + // + // + radLabel3.RootElement.MinSize = new Size(0, 24); // // radLabel2 // - resources.ApplyResources(this.radLabel2, "radLabel2"); - this.radLabel2.Name = "radLabel2"; + resources.ApplyResources(radLabel2, "radLabel2"); + radLabel2.Name = "radLabel2"; + // + // + // + radLabel2.RootElement.MinSize = new Size(0, 24); + // + // tableLayoutPanel1 + // + resources.ApplyResources(tableLayoutPanel1, "tableLayoutPanel1"); + tableLayoutPanel1.Controls.Add(radButton_LoadPads, 3, 0); + tableLayoutPanel1.Controls.Add(radButton_StartStopListening, 4, 0); + tableLayoutPanel1.Controls.Add(radButton_SaveProfile, 4, 1); + tableLayoutPanel1.Controls.Add(radButton_LoadProfile, 4, 2); + tableLayoutPanel1.Controls.Add(radTextBox_LoadSavestate, 1, 2); + tableLayoutPanel1.Controls.Add(radLabel1, 0, 0); + tableLayoutPanel1.Controls.Add(radTextBox_CreateSavestate, 1, 1); + tableLayoutPanel1.Controls.Add(radLabel2, 0, 1); + tableLayoutPanel1.Controls.Add(radDropDownList_Pads, 1, 0); + tableLayoutPanel1.Controls.Add(radLabel3, 0, 2); + tableLayoutPanel1.Name = "tableLayoutPanel1"; // // MainForm // resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.panel1); - this.Name = "MainForm"; - // - // - // - this.RootElement.ApplyShapeToControl = true; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); - this.Shown += new System.EventHandler(this.MainForm_Shown); - ((System.ComponentModel.ISupportInitialize)(this.radLabel1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radDropDownList_Pads)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_LoadPads)).EndInit(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.radTextBox_LoadSavestate)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radTextBox_CreateSavestate)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_LoadProfile)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_SaveProfile)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radButton_StartStopListening)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel3)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.radLabel2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); - this.ResumeLayout(false); - + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(tableLayoutPanel1); + Name = "MainForm"; + FormClosing += MainForm_FormClosing; + Shown += MainForm_Shown; + ((System.ComponentModel.ISupportInitialize)radLabel1).EndInit(); + ((System.ComponentModel.ISupportInitialize)radDropDownList_Pads).EndInit(); + ((System.ComponentModel.ISupportInitialize)radButton_LoadPads).EndInit(); + ((System.ComponentModel.ISupportInitialize)radTextBox_LoadSavestate).EndInit(); + ((System.ComponentModel.ISupportInitialize)radTextBox_CreateSavestate).EndInit(); + ((System.ComponentModel.ISupportInitialize)radButton_LoadProfile).EndInit(); + ((System.ComponentModel.ISupportInitialize)radButton_SaveProfile).EndInit(); + ((System.ComponentModel.ISupportInitialize)radButton_StartStopListening).EndInit(); + ((System.ComponentModel.ISupportInitialize)radLabel3).EndInit(); + ((System.ComponentModel.ISupportInitialize)radLabel2).EndInit(); + tableLayoutPanel1.ResumeLayout(false); + tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)this).EndInit(); + ResumeLayout(false); } #endregion @@ -172,7 +173,6 @@ private Telerik.WinControls.UI.RadLabel radLabel1; private Telerik.WinControls.UI.RadDropDownList radDropDownList_Pads; private Telerik.WinControls.UI.RadButton radButton_LoadPads; - private Panel panel1; private Telerik.WinControls.UI.RadButton radButton_StartStopListening; private Telerik.WinControls.UI.RadLabel radLabel3; private Telerik.WinControls.UI.RadLabel radLabel2; @@ -180,5 +180,6 @@ private Telerik.WinControls.UI.RadButton radButton_SaveProfile; private Telerik.WinControls.UI.RadTextBox radTextBox_LoadSavestate; private Telerik.WinControls.UI.RadTextBox radTextBox_CreateSavestate; + private TableLayoutPanel tableLayoutPanel1; } } diff --git a/Project64Savestater/MainForm.cs b/Project64Savestater/MainForm.cs index 6a9cce6..5172479 100644 --- a/Project64Savestater/MainForm.cs +++ b/Project64Savestater/MainForm.cs @@ -1,668 +1,675 @@ -using SharpDX.DirectInput; -using System; -using System.Collections.Generic; -using System.ComponentModel; +using Pilz.UI.Symbols; +using SharpDX.DirectInput; using System.Configuration; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; using Telerik.WinControls; using Telerik.WinControls.UI; using Timer = System.Timers.Timer; -namespace PJ64Savestater +namespace PJ64Savestater; + +public partial class MainForm : RadForm { - public partial class MainForm : Telerik.WinControls.UI.RadForm + private const string FILTER_INPUTPROFILE = "Json files (*.json)|*.json"; + private const string PROFILE_CODE = "Project64 Savestater"; + private const string DEFAULT_PROFILE_FILENAME = "Profile.json"; + + private readonly int toleranceOffset = 1000; + private readonly Timer myTimer; + private readonly DirectInput dInput = new(); + private DeviceInstance[] allDevices = []; + private Joystick? curPad = null; + private RadTextBox? focuesTextBox = null; + private InputProfile? curProfile = null; + private bool enableActionExecution = false; + + public MainForm() { - private const string FILTER_INPUTPROFILE = "Json files (*.json)|*.json"; - private const string PROFILE_CODE = "Project64 Savestater"; - private const string DEFAULT_PROFILE_FILENAME = "Profile.json"; + // Read configs + var reader = new AppSettingsReader(); + toleranceOffset = (int)reader.GetValue("toleranceOffset", typeof(int)); - private Timer myTimer; - private DirectInput DInput = new DirectInput(); - private DeviceInstance[] allDevices = Array.Empty(); - private Joystick curPad = null; - private RadTextBox focuesTextBox = null; - private InputProfile curProfile = null; - private bool enableActionExecution = false; - private int toleranceOffset = 1000; + // Init components + InitializeComponent(); - public MainForm() + // Symbols + //radLabel1.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.game_controller, SymbolSize.Small); + radButton_LoadPads.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.refresh, SymbolSize.Small); + radButton_LoadProfile.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.browse_folder, SymbolSize.Small); + radButton_StartStopListening.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.circled_play, SymbolSize.Small); + radButton_SaveProfile.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.save, SymbolSize.Small); + + // Init Timer + myTimer = new Timer(1) { - // Read configs - var reader = new AppSettingsReader(); - toleranceOffset = (int)reader.GetValue("toleranceOffset", typeof(int)); + SynchronizingObject = this, + AutoReset = true, + Enabled = true + }; + myTimer.Elapsed += MyTimer_Elapsed; + } - // Init components - InitializeComponent(); + private void LoadPads() + { + allDevices = [.. dInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly)]; + radDropDownList_Pads.Items.Clear(); + foreach (DeviceInstance d in allDevices) + radDropDownList_Pads.Items.Add(d.InstanceName); + } - // Init Timer - myTimer = new Timer(1) - { - SynchronizingObject = this, - AutoReset = true, - Enabled = true - }; - myTimer.Elapsed += MyTimer_Elapsed; + private void SetCurrentPad(Guid guid) + { + curPad = new Joystick(dInput, guid); + foreach (DeviceObjectInstance doi in curPad.GetObjects(DeviceObjectTypeFlags.Axis)) + curPad.GetObjectPropertiesById(doi.ObjectId).Range = new InputRange(-5000, 5000); + curPad.Properties.AxisMode = DeviceAxisMode.Absolute; + curPad.SetCooperativeLevel(Handle, CooperativeLevel.NonExclusive | CooperativeLevel.Background); + curPad.Acquire(); + if (curProfile is not null) + curProfile.ControllerInstanceGuid = guid; + } + + private static string GetDefaultProfileFilePath() + { + var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); + Directory.CreateDirectory(dir); + return Path.Combine(dir, DEFAULT_PROFILE_FILENAME); + } + + private void CheckForInput() + { + if (curPad is null) + return; + + var inputCodes = new List(); + var state = new JoystickState(); + bool success; + + try + { + curPad.Poll(); + curPad.GetCurrentState(ref state); + success = true; + } + catch (SharpDX.SharpDXException) + { + success = false; } - private void LoadPads() + if (!success) + return; + + for (int i = 0, loopTo = state.Buttons.Length - 1; i <= loopTo; i++) { - allDevices = DInput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly).ToArray(); - radDropDownList_Pads.Items.Clear(); - foreach (DeviceInstance d in allDevices) - radDropDownList_Pads.Items.Add(d.InstanceName); + if (state.Buttons[i]) + inputCodes.Add("Button " + i); } - private void SetCurrentPad(Guid guid) + for (int i = 0, loopTo1 = state.PointOfViewControllers.Length - 1; i <= loopTo1; i++) { - curPad = new Joystick(DInput, guid); - foreach (DeviceObjectInstance doi in curPad.GetObjects(DeviceObjectTypeFlags.Axis)) - curPad.GetObjectPropertiesById(doi.ObjectId).Range = new InputRange(-5000, 5000); - curPad.Properties.AxisMode = DeviceAxisMode.Absolute; - curPad.SetCooperativeLevel(Handle, CooperativeLevel.NonExclusive | CooperativeLevel.Background); - curPad.Acquire(); - if (curProfile is object) - curProfile.ControllerInstanceGuid = guid; + int val = state.PointOfViewControllers[i]; + if (val > -1) + inputCodes.Add("Point " + i + " " + val); } - private static string GetDefaultProfileFilePath() + for (int i = 0, loopTo2 = state.Sliders.Length - 1; i <= loopTo2; i++) { - var dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); - Directory.CreateDirectory(dir); - return Path.Combine(dir, DEFAULT_PROFILE_FILENAME); + int val = state.Sliders[i]; + if (val > toleranceOffset) + inputCodes.Add("Slider " + i + " +"); + if (val < -toleranceOffset) + inputCodes.Add("Slider " + i + " -"); } - private void CheckForInput() + for (int i = 0, loopTo3 = state.AccelerationSliders.Length - 1; i <= loopTo3; i++) { - if (curPad is object) - { - var inputCodes = new List(); - var state = new JoystickState(); - bool success; - - try - { - curPad.Poll(); - curPad.GetCurrentState(ref state); - success = true; - } - catch (SharpDX.SharpDXException) - { - success = false; - } - - if (success) - { - - for (int i = 0, loopTo = state.Buttons.Length - 1; i <= loopTo; i++) - { - if (state.Buttons[i]) - inputCodes.Add("Button " + i); - } - - for (int i = 0, loopTo1 = state.PointOfViewControllers.Length - 1; i <= loopTo1; i++) - { - int val = state.PointOfViewControllers[i]; - if (val > -1) - inputCodes.Add("Point " + i + " " + val); - } - - for (int i = 0, loopTo2 = state.Sliders.Length - 1; i <= loopTo2; i++) - { - int val = state.Sliders[i]; - if (val > toleranceOffset) - inputCodes.Add("Slider " + i + " +"); - if (val < -toleranceOffset) - inputCodes.Add("Slider " + i + " -"); - } - - for (int i = 0, loopTo3 = state.AccelerationSliders.Length - 1; i <= loopTo3; i++) - { - int val = state.AccelerationSliders[i]; - if (val > toleranceOffset) - inputCodes.Add("ASlider " + i + " +"); - if (val < -toleranceOffset) - inputCodes.Add("ASlider " + i + " -"); - } - - for (int i = 0, loopTo4 = state.ForceSliders.Length - 1; i <= loopTo4; i++) - { - int val = state.ForceSliders[i]; - if (val > toleranceOffset) - inputCodes.Add("FSlider " + i + " +"); - if (val < -toleranceOffset) - inputCodes.Add("FSlider " + i + " -"); - } - - for (int i = 0, loopTo5 = state.VelocitySliders.Length - 1; i <= loopTo5; i++) - { - int val = state.VelocitySliders[i]; - if (val > toleranceOffset) - inputCodes.Add("VSlider " + i + " +"); - if (val < -toleranceOffset) - inputCodes.Add("VSlider " + i + " -"); - } - - if (state.X > toleranceOffset) - inputCodes.Add("X +"); - if (state.X < -toleranceOffset) - inputCodes.Add("X -"); - - if (state.Y > toleranceOffset) - inputCodes.Add("Y +"); - if (state.Y < -toleranceOffset) - inputCodes.Add("Y -"); - - if (state.Z > toleranceOffset) - inputCodes.Add("Z +"); - if (state.Z < -toleranceOffset) - inputCodes.Add("Z -"); - - if (state.AccelerationX > toleranceOffset) - inputCodes.Add("AX +"); - if (state.AccelerationX < -toleranceOffset) - inputCodes.Add("AX -"); - - if (state.AccelerationY > toleranceOffset) - inputCodes.Add("AY +"); - if (state.AccelerationY < -toleranceOffset) - inputCodes.Add("AY -"); - - if (state.AccelerationZ > toleranceOffset) - inputCodes.Add("AZ +"); - if (state.AccelerationZ < -toleranceOffset) - inputCodes.Add("AZ -"); - - if (state.AngularAccelerationX > toleranceOffset) - inputCodes.Add("AAX +"); - if (state.AngularAccelerationX < -toleranceOffset) - inputCodes.Add("AAX -"); - - if (state.AngularAccelerationY > toleranceOffset) - inputCodes.Add("AAY +"); - if (state.AngularAccelerationY < -toleranceOffset) - inputCodes.Add("AAY -"); - - if (state.AngularAccelerationZ > toleranceOffset) - inputCodes.Add("AAZ +"); - if (state.AngularAccelerationZ < -toleranceOffset) - inputCodes.Add("AAZ -"); - - if (state.ForceX > toleranceOffset) - inputCodes.Add("FX +"); - if (state.ForceX < -toleranceOffset) - inputCodes.Add("FX -"); - - if (state.ForceY > toleranceOffset) - inputCodes.Add("FY +"); - if (state.ForceY < -toleranceOffset) - inputCodes.Add("FY -"); - - if (state.ForceZ > toleranceOffset) - inputCodes.Add("FZ +"); - if (state.ForceZ < -toleranceOffset) - inputCodes.Add("FZ -"); - - if (state.RotationX > toleranceOffset) - inputCodes.Add("RX +"); - if (state.RotationX < -toleranceOffset) - inputCodes.Add("RX -"); - - if (state.RotationY > toleranceOffset) - inputCodes.Add("RY +"); - if (state.RotationY < -toleranceOffset) - inputCodes.Add("RY -"); - - if (state.RotationZ > toleranceOffset) - inputCodes.Add("RZ +"); - if (state.RotationZ < -toleranceOffset) - inputCodes.Add("RZ -"); - - if (state.TorqueX > toleranceOffset) - inputCodes.Add("TX +"); - if (state.TorqueX < -toleranceOffset) - inputCodes.Add("TX -"); - - if (state.TorqueY > toleranceOffset) - inputCodes.Add("TY +"); - if (state.TorqueY < -toleranceOffset) - inputCodes.Add("TY -"); - - if (state.TorqueZ > toleranceOffset) - inputCodes.Add("TZ +"); - if (state.TorqueZ < -toleranceOffset) - inputCodes.Add("TZ -"); - - if (state.VelocityX > toleranceOffset) - inputCodes.Add("VX +"); - if (state.VelocityX < -toleranceOffset) - inputCodes.Add("VX -"); - - if (state.VelocityY > toleranceOffset) - inputCodes.Add("VY +"); - if (state.VelocityY < -toleranceOffset) - inputCodes.Add("VY -"); - - if (state.VelocityZ > toleranceOffset) - inputCodes.Add("VZ +"); - if (state.VelocityZ < -toleranceOffset) - inputCodes.Add("VZ -"); - - if (inputCodes.Any()) - { - if (focuesTextBox is object) - focuesTextBox.Text = inputCodes.Last(); - else if (enableActionExecution) - CheckForActions(inputCodes.ToArray()); - } - } - } + int val = state.AccelerationSliders[i]; + if (val > toleranceOffset) + inputCodes.Add("ASlider " + i + " +"); + if (val < -toleranceOffset) + inputCodes.Add("ASlider " + i + " -"); } - private void CheckForActions(string[] inputCodes) + for (int i = 0, loopTo4 = state.ForceSliders.Length - 1; i <= loopTo4; i++) { - foreach (var inputCode in inputCodes) - { - var inputControl = GetInputControlFromString(inputCode); - foreach (var ctrl in curProfile.Controls) - { - if (ctrl.Value == inputControl) - ExecuteAction(ctrl.Key); - } - } + int val = state.ForceSliders[i]; + if (val > toleranceOffset) + inputCodes.Add("FSlider " + i + " +"); + if (val < -toleranceOffset) + inputCodes.Add("FSlider " + i + " -"); } - private static void ExecuteAction(string actionCode) + for (int i = 0, loopTo5 = state.VelocitySliders.Length - 1; i <= loopTo5; i++) { - if (actionCode == ActionCodes.CreateSavestate) - SendKeys.Send("{F5}"); - else if (actionCode == ActionCodes.LoadSavestate) - SendKeys.Send("{F7}"); + int val = state.VelocitySliders[i]; + if (val > toleranceOffset) + inputCodes.Add("VSlider " + i + " +"); + if (val < -toleranceOffset) + inputCodes.Add("VSlider " + i + " -"); } - private void SetAction(string actionCode, string inputCode) + if (state.X > toleranceOffset) + inputCodes.Add("X +"); + if (state.X < -toleranceOffset) + inputCodes.Add("X -"); + + if (state.Y > toleranceOffset) + inputCodes.Add("Y +"); + if (state.Y < -toleranceOffset) + inputCodes.Add("Y -"); + + if (state.Z > toleranceOffset) + inputCodes.Add("Z +"); + if (state.Z < -toleranceOffset) + inputCodes.Add("Z -"); + + if (state.AccelerationX > toleranceOffset) + inputCodes.Add("AX +"); + if (state.AccelerationX < -toleranceOffset) + inputCodes.Add("AX -"); + + if (state.AccelerationY > toleranceOffset) + inputCodes.Add("AY +"); + if (state.AccelerationY < -toleranceOffset) + inputCodes.Add("AY -"); + + if (state.AccelerationZ > toleranceOffset) + inputCodes.Add("AZ +"); + if (state.AccelerationZ < -toleranceOffset) + inputCodes.Add("AZ -"); + + if (state.AngularAccelerationX > toleranceOffset) + inputCodes.Add("AAX +"); + if (state.AngularAccelerationX < -toleranceOffset) + inputCodes.Add("AAX -"); + + if (state.AngularAccelerationY > toleranceOffset) + inputCodes.Add("AAY +"); + if (state.AngularAccelerationY < -toleranceOffset) + inputCodes.Add("AAY -"); + + if (state.AngularAccelerationZ > toleranceOffset) + inputCodes.Add("AAZ +"); + if (state.AngularAccelerationZ < -toleranceOffset) + inputCodes.Add("AAZ -"); + + if (state.ForceX > toleranceOffset) + inputCodes.Add("FX +"); + if (state.ForceX < -toleranceOffset) + inputCodes.Add("FX -"); + + if (state.ForceY > toleranceOffset) + inputCodes.Add("FY +"); + if (state.ForceY < -toleranceOffset) + inputCodes.Add("FY -"); + + if (state.ForceZ > toleranceOffset) + inputCodes.Add("FZ +"); + if (state.ForceZ < -toleranceOffset) + inputCodes.Add("FZ -"); + + if (state.RotationX > toleranceOffset) + inputCodes.Add("RX +"); + if (state.RotationX < -toleranceOffset) + inputCodes.Add("RX -"); + + if (state.RotationY > toleranceOffset) + inputCodes.Add("RY +"); + if (state.RotationY < -toleranceOffset) + inputCodes.Add("RY -"); + + if (state.RotationZ > toleranceOffset) + inputCodes.Add("RZ +"); + if (state.RotationZ < -toleranceOffset) + inputCodes.Add("RZ -"); + + if (state.TorqueX > toleranceOffset) + inputCodes.Add("TX +"); + if (state.TorqueX < -toleranceOffset) + inputCodes.Add("TX -"); + + if (state.TorqueY > toleranceOffset) + inputCodes.Add("TY +"); + if (state.TorqueY < -toleranceOffset) + inputCodes.Add("TY -"); + + if (state.TorqueZ > toleranceOffset) + inputCodes.Add("TZ +"); + if (state.TorqueZ < -toleranceOffset) + inputCodes.Add("TZ -"); + + if (state.VelocityX > toleranceOffset) + inputCodes.Add("VX +"); + if (state.VelocityX < -toleranceOffset) + inputCodes.Add("VX -"); + + if (state.VelocityY > toleranceOffset) + inputCodes.Add("VY +"); + if (state.VelocityY < -toleranceOffset) + inputCodes.Add("VY -"); + + if (state.VelocityZ > toleranceOffset) + inputCodes.Add("VZ +"); + if (state.VelocityZ < -toleranceOffset) + inputCodes.Add("VZ -"); + + if (inputCodes.Any()) { - if (curProfile is object) - curProfile[actionCode] = GetInputControlFromString(inputCode); - } - - public static InputControl GetInputControlFromString(string str) - { - var input = new InputControl(); - var p = str.Split(' '); - var switchExpr = p[0]; - switch (switchExpr) - { - case "Button": - input.InputKey = InputKeys.Buttons; - input.KeyIndex = Convert.ToInt32(p[1]); - break; - case "Point": - input.InputKey = InputKeys.PointOfViewControllers; - input.KeyIndex = Convert.ToInt32(p[1]); - input.Value = p[2]; - break; - case "Slider": - input.InputKey = InputKeys.Sliders; - input.KeyIndex = Convert.ToInt32(p[1]); - break; - case "ASlider": - input.InputKey = InputKeys.AccelerationSliders; - input.KeyIndex = Convert.ToInt32(p[1]); - break; - case "FSlider": - input.InputKey = InputKeys.ForceSliders; - input.KeyIndex = Convert.ToInt32(p[1]); - break; - case "VSlider": - input.InputKey = InputKeys.VelocitySliders; - input.KeyIndex = Convert.ToInt32(p[1]); - break; - case "X": - input.InputKey = InputKeys.X; - input.Value = p[1]; - break; - case "Y": - input.InputKey = InputKeys.Y; - input.Value = p[1]; - break; - case "Z": - input.InputKey = InputKeys.Z; - input.Value = p[1]; - break; - case "AX": - input.InputKey = InputKeys.AccelerationX; - input.Value = p[1]; - break; - case "AY": - input.InputKey = InputKeys.AccelerationY; - input.Value = p[1]; - break; - case "AZ": - input.InputKey = InputKeys.AccelerationZ; - input.Value = p[1]; - break; - case "AAX": - input.InputKey = InputKeys.AngularAccelerationX; - input.Value = p[1]; - break; - case "AAY": - input.InputKey = InputKeys.AngularAccelerationY; - input.Value = p[1]; - break; - case "AAZ": - input.InputKey = InputKeys.AngularAccelerationZ; - input.Value = p[1]; - break; - case "FX": - input.InputKey = InputKeys.ForceX; - input.Value = p[1]; - break; - case "FY": - input.InputKey = InputKeys.ForceY; - input.Value = p[1]; - break; - case "FZ": - input.InputKey = InputKeys.ForceZ; - input.Value = p[1]; - break; - case "RX": - input.InputKey = InputKeys.RotationX; - input.Value = p[1]; - break; - case "RY": - input.InputKey = InputKeys.RotationY; - input.Value = p[1]; - break; - case "RZ": - input.InputKey = InputKeys.RotationZ; - input.Value = p[1]; - break; - case "TX": - input.InputKey = InputKeys.TorqueX; - input.Value = p[1]; - break; - case "TY": - input.InputKey = InputKeys.TorqueY; - input.Value = p[1]; - break; - case "TZ": - input.InputKey = InputKeys.TorqueZ; - input.Value = p[1]; - break; - case "VX": - input.InputKey = InputKeys.VelocityX; - input.Value = p[1]; - break; - case "VY": - input.InputKey = InputKeys.VelocityY; - input.Value = p[1]; - break; - case "VZ": - input.InputKey = InputKeys.VelocityZ; - input.Value = p[1]; - break; - } - - return input; - } - - public static string GetStringFromInputControl(InputControl input) - { - string str = string.Empty; - if (input.InputKey is null && input.KeyIndex is null && input.Value is null) return string.Empty; - - switch (input.InputKey) - { - case var @case when @case == InputKeys.Buttons: - { - return $"Button {input.KeyIndex}"; - } - - case var case1 when case1 == InputKeys.PointOfViewControllers: - { - return $"Point {input.KeyIndex} {input.Value}"; - } - - case var case2 when case2 == InputKeys.Sliders: - { - return $"Slider {input.KeyIndex}"; - } - - case var case3 when case3 == InputKeys.AccelerationSliders: - { - return $"ASlider {input.KeyIndex}"; - } - - case var case4 when case4 == InputKeys.ForceSliders: - { - return $"FSlider {input.KeyIndex}"; - } - - case var case5 when case5 == InputKeys.VelocitySliders: - { - return $"VSlider {input.KeyIndex}"; - } - - case var case6 when case6 == InputKeys.X: - { - return $"X {input.Value}"; - } - - case var case7 when case7 == InputKeys.Y: - { - return $"Y {input.Value}"; - } - - case var case8 when case8 == InputKeys.Z: - { - return $"Z {input.Value}"; - } - - case var case9 when case9 == InputKeys.AccelerationX: - { - return $"AX {input.Value}"; - } - - case var case10 when case10 == InputKeys.AccelerationY: - { - return $"AY {input.Value}"; - } - - case var case11 when case11 == InputKeys.AccelerationZ: - { - return $"AZ {input.Value}"; - } - - case var case12 when case12 == InputKeys.AngularAccelerationX: - { - return $"AAX {input.Value}"; - } - - case var case13 when case13 == InputKeys.AngularAccelerationY: - { - return $"AAY {input.Value}"; - } - - case var case14 when case14 == InputKeys.AngularAccelerationZ: - { - return $"AAZ {input.Value}"; - } - - case var case15 when case15 == InputKeys.ForceX: - { - return $"FX {input.Value}"; - } - - case var case16 when case16 == InputKeys.ForceY: - { - return $"FY {input.Value}"; - } - - case var case17 when case17 == InputKeys.ForceZ: - { - return $"FZ {input.Value}"; - } - - case var case18 when case18 == InputKeys.RotationX: - { - return $"RX {input.Value}"; - } - - case var case19 when case19 == InputKeys.RotationY: - { - return $"RY {input.Value}"; - } - - case var case20 when case20 == InputKeys.RotationZ: - { - return $"RZ {input.Value}"; - } - - case var case21 when case21 == InputKeys.TorqueX: - { - return $"TX {input.Value}"; - } - - case var case22 when case22 == InputKeys.TorqueY: - { - return $"TY {input.Value}"; - } - - case var case23 when case23 == InputKeys.TorqueZ: - { - return $"TZ {input.Value}"; - } - - case var case24 when case24 == InputKeys.VelocityX: - { - return $"VX {input.Value}"; - } - - case var case25 when case25 == InputKeys.VelocityY: - { - return $"VY {input.Value}"; - } - - case var case26 when case26 == InputKeys.VelocityZ: - { - return $"VZ {input.Value}"; - } - } - - return str; - } - - private void LoadProfile(string filePath) - { - var p = !string.IsNullOrEmpty(filePath) && System.IO.File.Exists(filePath) ? InputProfile.Load(filePath) : new InputProfile(PROFILE_CODE); - - if (p.ProfileCode == PROFILE_CODE) - { - radTextBox_CreateSavestate.Text = GetStringFromInputControl(p[ActionCodes.CreateSavestate]); - radTextBox_LoadSavestate.Text = GetStringFromInputControl(p[ActionCodes.LoadSavestate]); - - try - { - var tguid = allDevices.FirstOrDefault(n => Globals.CompareTwoByteArrays(n.InstanceGuid.ToByteArray(), p.ControllerInstanceGuid.ToByteArray())); - if (tguid is object) - radDropDownList_Pads.SelectedIndex = Array.IndexOf(allDevices, tguid); - } - catch (Exception) - { - } - - curProfile = p; - } - else - RadMessageBox.Show(this, LangRes.MsgBox_WrongProfileCode, LangRes.MsgBox_WrongProfileCode_Title, MessageBoxButtons.OK, RadMessageIcon.Exclamation); - } - - private void MyTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) - { - CheckForInput(); - } - - private void MainForm_Shown(object sender, EventArgs e) - { - LoadPads(); - LoadProfile(GetDefaultProfileFilePath()); - } - - private void radButton_StartStopListening_Click(object sender, EventArgs e) - { - if (enableActionExecution) - { - radButton_StartStopListening.Image = Properties.Resources.icons8_play_button_circled_16px; - radButton_StartStopListening.Text = LangRes.Button_StartListening; - enableActionExecution = false; - } - else - { - radButton_StartStopListening.Image = Properties.Resources.icons8_stop_squared_16px; - radButton_StartStopListening.Text = LangRes.Button_StopListening; - enableActionExecution = true; - } - } - - private void radButton3_Click(object sender, EventArgs e) - { - var sfd_SaveInputProfile = new RadSaveFileDialog - { - Filter = FILTER_INPUTPROFILE - }; - if (sfd_SaveInputProfile.ShowDialog(this) == DialogResult.OK) - curProfile.Save(sfd_SaveInputProfile.FileName); - } - - private void radButton4_Click(object sender, EventArgs e) - { - var ofd_SaveInputProfile = new RadOpenFileDialog - { - Filter = FILTER_INPUTPROFILE - }; - if (ofd_SaveInputProfile.ShowDialog(this) == DialogResult.OK) - LoadProfile(ofd_SaveInputProfile.FileName); - } - - private void radTextBox1_TextChanged(object sender, EventArgs e) - { - SetAction(ActionCodes.CreateSavestate, ((RadTextBox)sender).Text); - } - - private void radTextBox2_TextChanged(object sender, EventArgs e) - { - SetAction(ActionCodes.LoadSavestate, ((RadTextBox)sender).Text); - } - - private void radButton1_Click(object sender, EventArgs e) - { - LoadPads(); - } - - private void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e) - { - int index = radDropDownList_Pads.SelectedIndex; - if (index >= 0) - SetCurrentPad(allDevices[index].InstanceGuid); - } - - private void MainForm_FormClosing(object sender, FormClosingEventArgs e) - { - curProfile.Save(GetDefaultProfileFilePath()); - } - - private void RadTextBox_Savestate_Clicked(object sender, EventArgs e) - { - if (curPad is object && curProfile is object) - focuesTextBox = (RadTextBox)sender; - } - - private void RadTextBox_Savestate_LostFocus(object sender, EventArgs e) - { - focuesTextBox = null; + if (focuesTextBox is not null) + focuesTextBox.Text = inputCodes.Last(); + else if (enableActionExecution) + CheckForActions([.. inputCodes]); } } + + private void CheckForActions(string[] inputCodes) + { + if (curProfile is null) + return; + + foreach (var inputCode in inputCodes) + { + var inputControl = GetInputControlFromString(inputCode); + foreach (var ctrl in curProfile.Controls) + { + if (ctrl.Value == inputControl) + ExecuteAction(ctrl.Key); + } + } + } + + private static void ExecuteAction(string actionCode) + { + if (actionCode == ActionCodes.CreateSavestate) + SendKeys.Send("{F5}"); + else if (actionCode == ActionCodes.LoadSavestate) + SendKeys.Send("{F7}"); + } + + private void SetAction(string actionCode, string inputCode) + { + if (curProfile is not null) + curProfile[actionCode] = GetInputControlFromString(inputCode); + } + + public static InputControl GetInputControlFromString(string str) + { + var input = new InputControl(); + var p = str.Split(' '); + var switchExpr = p[0]; + switch (switchExpr) + { + case "Button": + input.InputKey = InputKeys.Buttons; + input.KeyIndex = Convert.ToInt32(p[1]); + break; + case "Point": + input.InputKey = InputKeys.PointOfViewControllers; + input.KeyIndex = Convert.ToInt32(p[1]); + input.Value = p[2]; + break; + case "Slider": + input.InputKey = InputKeys.Sliders; + input.KeyIndex = Convert.ToInt32(p[1]); + break; + case "ASlider": + input.InputKey = InputKeys.AccelerationSliders; + input.KeyIndex = Convert.ToInt32(p[1]); + break; + case "FSlider": + input.InputKey = InputKeys.ForceSliders; + input.KeyIndex = Convert.ToInt32(p[1]); + break; + case "VSlider": + input.InputKey = InputKeys.VelocitySliders; + input.KeyIndex = Convert.ToInt32(p[1]); + break; + case "X": + input.InputKey = InputKeys.X; + input.Value = p[1]; + break; + case "Y": + input.InputKey = InputKeys.Y; + input.Value = p[1]; + break; + case "Z": + input.InputKey = InputKeys.Z; + input.Value = p[1]; + break; + case "AX": + input.InputKey = InputKeys.AccelerationX; + input.Value = p[1]; + break; + case "AY": + input.InputKey = InputKeys.AccelerationY; + input.Value = p[1]; + break; + case "AZ": + input.InputKey = InputKeys.AccelerationZ; + input.Value = p[1]; + break; + case "AAX": + input.InputKey = InputKeys.AngularAccelerationX; + input.Value = p[1]; + break; + case "AAY": + input.InputKey = InputKeys.AngularAccelerationY; + input.Value = p[1]; + break; + case "AAZ": + input.InputKey = InputKeys.AngularAccelerationZ; + input.Value = p[1]; + break; + case "FX": + input.InputKey = InputKeys.ForceX; + input.Value = p[1]; + break; + case "FY": + input.InputKey = InputKeys.ForceY; + input.Value = p[1]; + break; + case "FZ": + input.InputKey = InputKeys.ForceZ; + input.Value = p[1]; + break; + case "RX": + input.InputKey = InputKeys.RotationX; + input.Value = p[1]; + break; + case "RY": + input.InputKey = InputKeys.RotationY; + input.Value = p[1]; + break; + case "RZ": + input.InputKey = InputKeys.RotationZ; + input.Value = p[1]; + break; + case "TX": + input.InputKey = InputKeys.TorqueX; + input.Value = p[1]; + break; + case "TY": + input.InputKey = InputKeys.TorqueY; + input.Value = p[1]; + break; + case "TZ": + input.InputKey = InputKeys.TorqueZ; + input.Value = p[1]; + break; + case "VX": + input.InputKey = InputKeys.VelocityX; + input.Value = p[1]; + break; + case "VY": + input.InputKey = InputKeys.VelocityY; + input.Value = p[1]; + break; + case "VZ": + input.InputKey = InputKeys.VelocityZ; + input.Value = p[1]; + break; + } + + return input; + } + + public static string GetStringFromInputControl(InputControl input) + { + string str = string.Empty; + if (input.InputKey is null && input.KeyIndex is null && input.Value is null) return string.Empty; + + switch (input.InputKey) + { + case var @case when @case == InputKeys.Buttons: + { + return $"Button {input.KeyIndex}"; + } + + case var case1 when case1 == InputKeys.PointOfViewControllers: + { + return $"Point {input.KeyIndex} {input.Value}"; + } + + case var case2 when case2 == InputKeys.Sliders: + { + return $"Slider {input.KeyIndex}"; + } + + case var case3 when case3 == InputKeys.AccelerationSliders: + { + return $"ASlider {input.KeyIndex}"; + } + + case var case4 when case4 == InputKeys.ForceSliders: + { + return $"FSlider {input.KeyIndex}"; + } + + case var case5 when case5 == InputKeys.VelocitySliders: + { + return $"VSlider {input.KeyIndex}"; + } + + case var case6 when case6 == InputKeys.X: + { + return $"X {input.Value}"; + } + + case var case7 when case7 == InputKeys.Y: + { + return $"Y {input.Value}"; + } + + case var case8 when case8 == InputKeys.Z: + { + return $"Z {input.Value}"; + } + + case var case9 when case9 == InputKeys.AccelerationX: + { + return $"AX {input.Value}"; + } + + case var case10 when case10 == InputKeys.AccelerationY: + { + return $"AY {input.Value}"; + } + + case var case11 when case11 == InputKeys.AccelerationZ: + { + return $"AZ {input.Value}"; + } + + case var case12 when case12 == InputKeys.AngularAccelerationX: + { + return $"AAX {input.Value}"; + } + + case var case13 when case13 == InputKeys.AngularAccelerationY: + { + return $"AAY {input.Value}"; + } + + case var case14 when case14 == InputKeys.AngularAccelerationZ: + { + return $"AAZ {input.Value}"; + } + + case var case15 when case15 == InputKeys.ForceX: + { + return $"FX {input.Value}"; + } + + case var case16 when case16 == InputKeys.ForceY: + { + return $"FY {input.Value}"; + } + + case var case17 when case17 == InputKeys.ForceZ: + { + return $"FZ {input.Value}"; + } + + case var case18 when case18 == InputKeys.RotationX: + { + return $"RX {input.Value}"; + } + + case var case19 when case19 == InputKeys.RotationY: + { + return $"RY {input.Value}"; + } + + case var case20 when case20 == InputKeys.RotationZ: + { + return $"RZ {input.Value}"; + } + + case var case21 when case21 == InputKeys.TorqueX: + { + return $"TX {input.Value}"; + } + + case var case22 when case22 == InputKeys.TorqueY: + { + return $"TY {input.Value}"; + } + + case var case23 when case23 == InputKeys.TorqueZ: + { + return $"TZ {input.Value}"; + } + + case var case24 when case24 == InputKeys.VelocityX: + { + return $"VX {input.Value}"; + } + + case var case25 when case25 == InputKeys.VelocityY: + { + return $"VY {input.Value}"; + } + + case var case26 when case26 == InputKeys.VelocityZ: + { + return $"VZ {input.Value}"; + } + } + + return str; + } + + private void LoadProfile(string filePath) + { + var p = !string.IsNullOrEmpty(filePath) && File.Exists(filePath) ? InputProfile.Load(filePath) : new InputProfile(PROFILE_CODE); + + if (p is null || p.ProfileCode != PROFILE_CODE) + { + RadMessageBox.Show(this, LangRes.MsgBox_WrongProfileCode, LangRes.MsgBox_WrongProfileCode_Title, MessageBoxButtons.OK, RadMessageIcon.Exclamation); + return; + } + + radTextBox_CreateSavestate.Text = GetStringFromInputControl(p[ActionCodes.CreateSavestate]); + radTextBox_LoadSavestate.Text = GetStringFromInputControl(p[ActionCodes.LoadSavestate]); + + try + { + var tguid = allDevices.FirstOrDefault(n => Globals.CompareTwoByteArrays(n.InstanceGuid.ToByteArray(), p.ControllerInstanceGuid.ToByteArray())); + if (tguid is not null) + radDropDownList_Pads.SelectedIndex = Array.IndexOf(allDevices, tguid); + } + catch (Exception) + { + } + + curProfile = p; + } + + private void MyTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) + { + CheckForInput(); + } + + private void MainForm_Shown(object sender, EventArgs e) + { + LoadPads(); + LoadProfile(GetDefaultProfileFilePath()); + } + + private void RadButton_StartStopListening_Click(object sender, EventArgs e) + { + if (enableActionExecution) + { + radButton_StartStopListening.SvgImage = radButton_StartStopListening.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.circled_play, SymbolSize.Small); ; + radButton_StartStopListening.Text = LangRes.Button_StartListening; + enableActionExecution = false; + } + else + { + radButton_StartStopListening.SvgImage = radButton_StartStopListening.SvgImage = AppGlobals.Symbols.GetSvgImage(AppSymbols.stop_cicled, SymbolSize.Small); ; + radButton_StartStopListening.Text = LangRes.Button_StopListening; + enableActionExecution = true; + } + } + + private void RadButton3_Click(object sender, EventArgs e) + { + if (curProfile is null) + return; + + var sfd_SaveInputProfile = new RadSaveFileDialog + { + Filter = FILTER_INPUTPROFILE + }; + + if (sfd_SaveInputProfile.ShowDialog(this) == DialogResult.OK) + curProfile.Save(sfd_SaveInputProfile.FileName); + } + + private void RadButton4_Click(object sender, EventArgs e) + { + var ofd_SaveInputProfile = new RadOpenFileDialog + { + Filter = FILTER_INPUTPROFILE + }; + if (ofd_SaveInputProfile.ShowDialog(this) == DialogResult.OK) + LoadProfile(ofd_SaveInputProfile.FileName); + } + + private void RadTextBox1_TextChanged(object sender, EventArgs e) + { + SetAction(ActionCodes.CreateSavestate, ((RadTextBox)sender).Text); + } + + private void RadTextBox2_TextChanged(object sender, EventArgs e) + { + SetAction(ActionCodes.LoadSavestate, ((RadTextBox)sender).Text); + } + + private void RadButton1_Click(object sender, EventArgs e) + { + LoadPads(); + } + + private void RadDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e) + { + int index = radDropDownList_Pads.SelectedIndex; + if (index >= 0) + SetCurrentPad(allDevices[index].InstanceGuid); + } + + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + curProfile?.Save(GetDefaultProfileFilePath()); + } + + private void RadTextBox_Savestate_Clicked(object sender, EventArgs e) + { + if (curPad is not null && curProfile is not null && sender is RadTextBox rtb) + focuesTextBox = rtb; + } + + private void RadTextBox_Savestate_LostFocus(object sender, EventArgs e) + { + focuesTextBox = null; + } } diff --git a/Project64Savestater/MainForm.de.resx b/Project64Savestater/MainForm.de.resx index 717fa49..18b00e2 100644 --- a/Project64Savestater/MainForm.de.resx +++ b/Project64Savestater/MainForm.de.resx @@ -1,4 +1,64 @@ - + + + @@ -57,30 +117,24 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Kontroller: - Profil laden Profil speichern - - Zuhöreren beginnen - 111, 18 - Speicherpunkt laden: + Speicherpunkt laden 126, 18 - Speicherpunkt erstellen: + Speicherpunkt erstellen diff --git a/Project64Savestater/MainForm.resx b/Project64Savestater/MainForm.resx index c0557b6..2add773 100644 --- a/Project64Savestater/MainForm.resx +++ b/Project64Savestater/MainForm.resx @@ -1,4 +1,64 @@ + + @@ -52,67 +112,43 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 3, 4 + 3, 3 + + + 0, 24 - 74, 18 + 74, 24 0 - Controller: + Controller - + ImageBeforeText - - radLabel1 + + Top, Left, Right - - Telerik.WinControls.UI.RadLabel, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 7 - - - 83, 3 - - - 290, 24 - - - 1 - - - radDropDownList_Pads - - - Telerik.WinControls.UI.RadDropDownList, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 9 + + 5 MiddleCenter - 379, 3 + 352, 3 24, 24 @@ -120,225 +156,162 @@ 2 - - radButton_LoadPads - - - Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 8 - - - 149, 63 - - - 85, 24 - - - 10 - - - radTextBox_LoadSavestate - - - Telerik.WinControls.UI.RadTextBox, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 0 - - - 149, 33 - - - 85, 24 - - - 9 - - - radTextBox_CreateSavestate - - - Telerik.WinControls.UI.RadTextBox, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 1 - - - MiddleCenter - - - 409, 63 - - - 137, 24 - - - 8 - - - Load Profile - - - ImageBeforeText - - - radButton_LoadProfile - - - Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 2 - - - MiddleCenter - - - 409, 33 - - - 137, 24 - - - 8 - - - Save Profile - - - ImageBeforeText - - - radButton_SaveProfile - - - Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - - - panel1 - - - 3 + + Top, Left, Right - MiddleCenter + MiddleRight - 409, 3 + 382, 3 - 137, 24 + 164, 24 7 - Start listening + Start + + + MiddleLeft ImageBeforeText - - radButton_StartStopListening + + Top, Left, Right - - Telerik.WinControls.UI.RadButton, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e + + MiddleRight - - panel1 + + 382, 33 - - 4 + + 164, 24 - - 3, 66 + + 8 - - 83, 18 + + Save profile - - 6 + + MiddleLeft - - Load Savestate: + + ImageBeforeText - - radLabel3 + + Top, Left, Right - - Telerik.WinControls.UI.RadLabel, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e + + MiddleRight - - panel1 + + 382, 63 - - 5 + + 164, 24 + + + 8 + + + Load profile + + + MiddleLeft + + + ImageBeforeText + + + Top, Left, Right + + + 100, 63 + + + 120, 20 + + + 10 + + + Top, Left, Right + + + 100, 33 + + + 120, 20 + + + 9 - 3, 36 + 3, 33 + + + 0, 24 - 91, 18 + 91, 24 4 - Create Savestate: + Create savestate - - radLabel2 + + 3, 63 - - Telerik.WinControls.UI.RadLabel, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e + + 0, 24 - - panel1 + + 83, 24 - + 6 - + + Load savestate + + Fill - + 0, 0 - - 549, 91 - - + 3 - - panel1 + + 549, 90 - - System.Windows.Forms.Panel, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 4 - - $this + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="radButton_LoadPads" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="radButton_StartStopListening" Row="0" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="radButton_SaveProfile" Row="1" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="radButton_LoadProfile" Row="2" RowSpan="1" Column="4" ColumnSpan="1" /><Control Name="radTextBox_LoadSavestate" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="radLabel1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="radTextBox_CreateSavestate" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="radLabel2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="radDropDownList_Pads" Row="0" RowSpan="1" Column="1" ColumnSpan="2" /><Control Name="radLabel3" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,30,Percent,30,AutoSize,0,Percent,40" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0" /></TableLayoutSettings> - - 0 + + 100, 3 - + + 246, 20 + + + 1 + + True - + 7, 15 @@ -346,7 +319,7 @@ 7, 15 - 549, 91 + 549, 90 @@ -2120,10 +2093,4 @@ Project64 Savestater - - MainForm - - - Telerik.WinControls.UI.RadForm, Telerik.WinControls.UI, Culture=neutral, PublicKeyToken=5bb2a467cbec794e - \ No newline at end of file diff --git a/Project64Savestater/PJ64Savestater.csproj b/Project64Savestater/PJ64Savestater.csproj index 5259e72..2d7d399 100644 --- a/Project64Savestater/PJ64Savestater.csproj +++ b/Project64Savestater/PJ64Savestater.csproj @@ -1,36 +1,35 @@  + WinExe - net6.0-windows - true - true + net8.0-windows enable true enable - PJ64Savestater.Program icons8_data_backup.ico Project64 Savestater - 1.2.1.0 - Pilzinsel64 https://pilzinsel64.de - https://gitlab.com/Pilzinsel64/project64-savestater - - - embedded - - - embedded + https://git.pilzinsel64.com/Pilzinsel64/project64-savestater + + - - - - + + + + + + + + + + + True @@ -43,6 +42,7 @@ LangRes.resx + ResXFileCodeGenerator @@ -53,7 +53,9 @@ LangRes.Designer.cs + - + + \ No newline at end of file diff --git a/Project64Savestater/Program.cs b/Project64Savestater/Program.cs index 18a7599..51b7515 100644 --- a/Project64Savestater/Program.cs +++ b/Project64Savestater/Program.cs @@ -1,24 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; +using Pilz; +using Pilz.UI.Telerik.Theming; +using Telerik.WinControls.Themes; -namespace PJ64Savestater +[assembly: AssemblyAppVersion("1.3.0.0")] + +namespace PJ64Savestater; + +static class Program { - static class Program + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() { - /// - /// Der Haupteinstiegspunkt für die Anwendung. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - VisualThemeHelper.SetVisualTheme(); - //Application.SetDefaultFont(new Font(Control.DefaultFont.FontFamily, 8.25f)); // Kein Effekt? - Application.Run(new MainForm()); - } + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + ThemeHelper.ApplyApplicationTheme(ApplicationTheme.Auto, () => new Windows11CompactTheme(), () => new Windows11CompactDarkTheme()); + Application.Run(new MainForm()); } } diff --git a/Project64Savestater/Properties/Resources.Designer.cs b/Project64Savestater/Properties/Resources.Designer.cs deleted file mode 100644 index 6dab0c6..0000000 --- a/Project64Savestater/Properties/Resources.Designer.cs +++ /dev/null @@ -1,123 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 -// -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. -// -//------------------------------------------------------------------------------ - -namespace PJ64Savestater.Properties { - using System; - - - /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. - /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PJ64Savestater.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_game_controller_16px { - get { - object obj = ResourceManager.GetObject("icons8_game_controller_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_opened_folder_16px { - get { - object obj = ResourceManager.GetObject("icons8_opened_folder_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_play_button_circled_16px { - get { - object obj = ResourceManager.GetObject("icons8_play_button_circled_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_refresh_16px { - get { - object obj = ResourceManager.GetObject("icons8_refresh_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_save_16px { - get { - object obj = ResourceManager.GetObject("icons8_save_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icons8_stop_squared_16px { - get { - object obj = ResourceManager.GetObject("icons8_stop_squared_16px", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/Project64Savestater/Properties/Resources.resx b/Project64Savestater/Properties/Resources.resx deleted file mode 100644 index 8cda3a0..0000000 --- a/Project64Savestater/Properties/Resources.resx +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\icons8_game_controller_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8_opened_folder_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8_play_button_circled_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8_refresh_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8_save_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8_stop_squared_16px.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/Project64Savestater/Properties/Settings.Designer.cs b/Project64Savestater/Properties/Settings.Designer.cs deleted file mode 100644 index f948f67..0000000 --- a/Project64Savestater/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.42000 -// -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. -// -//------------------------------------------------------------------------------ - -namespace PJ64Savestater.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/Project64Savestater/Properties/Settings.settings b/Project64Savestater/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/Project64Savestater/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Project64Savestater/Resources/icons8_game_controller_16px.png b/Project64Savestater/Resources/icons8_game_controller_16px.png deleted file mode 100644 index ba25be2..0000000 Binary files a/Project64Savestater/Resources/icons8_game_controller_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_opened_folder_16px.png b/Project64Savestater/Resources/icons8_opened_folder_16px.png deleted file mode 100644 index 94708b7..0000000 Binary files a/Project64Savestater/Resources/icons8_opened_folder_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_play_16px.png b/Project64Savestater/Resources/icons8_play_16px.png deleted file mode 100644 index 1f3d4af..0000000 Binary files a/Project64Savestater/Resources/icons8_play_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_play_button_circled_16px.png b/Project64Savestater/Resources/icons8_play_button_circled_16px.png deleted file mode 100644 index c71f0cf..0000000 Binary files a/Project64Savestater/Resources/icons8_play_button_circled_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_refresh_16px.png b/Project64Savestater/Resources/icons8_refresh_16px.png deleted file mode 100644 index e462dd9..0000000 Binary files a/Project64Savestater/Resources/icons8_refresh_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_save_16px.png b/Project64Savestater/Resources/icons8_save_16px.png deleted file mode 100644 index 0e51657..0000000 Binary files a/Project64Savestater/Resources/icons8_save_16px.png and /dev/null differ diff --git a/Project64Savestater/Resources/icons8_stop_squared_16px.png b/Project64Savestater/Resources/icons8_stop_squared_16px.png deleted file mode 100644 index 039a985..0000000 Binary files a/Project64Savestater/Resources/icons8_stop_squared_16px.png and /dev/null differ diff --git a/Project64Savestater/Symbols/browse_folder.svg b/Project64Savestater/Symbols/browse_folder.svg new file mode 100644 index 0000000..f662d50 --- /dev/null +++ b/Project64Savestater/Symbols/browse_folder.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/Symbols/circled_play.svg b/Project64Savestater/Symbols/circled_play.svg new file mode 100644 index 0000000..b5327df --- /dev/null +++ b/Project64Savestater/Symbols/circled_play.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/Symbols/game_controller.svg b/Project64Savestater/Symbols/game_controller.svg new file mode 100644 index 0000000..6c140ef --- /dev/null +++ b/Project64Savestater/Symbols/game_controller.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/Symbols/refresh.svg b/Project64Savestater/Symbols/refresh.svg new file mode 100644 index 0000000..dc201fb --- /dev/null +++ b/Project64Savestater/Symbols/refresh.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/Symbols/save.svg b/Project64Savestater/Symbols/save.svg new file mode 100644 index 0000000..a7b9247 --- /dev/null +++ b/Project64Savestater/Symbols/save.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/Symbols/stop_circled.svg b/Project64Savestater/Symbols/stop_circled.svg new file mode 100644 index 0000000..8ae089d --- /dev/null +++ b/Project64Savestater/Symbols/stop_circled.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Project64Savestater/VisualThemeHelper.cs b/Project64Savestater/VisualThemeHelper.cs deleted file mode 100644 index 24f8649..0000000 --- a/Project64Savestater/VisualThemeHelper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.Win32; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Telerik.WinControls; - -namespace PJ64Savestater -{ - internal static class VisualThemeHelper - { - public static void SetVisualTheme() - { - RadThemeComponentBase? setTheme = null; - - if (!WindowsSettings.AppsUseLightTheme) - setTheme = new Telerik.WinControls.Themes.FluentDarkTheme(); - setTheme ??= new Telerik.WinControls.Themes.FluentTheme(); - - // Set theme - ThemeResolutionService.ApplicationThemeName = setTheme.ThemeName; - } - } -}