From 768600c73e50d6837723db199448dde8fec4ec73 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 3 Apr 2019 22:30:48 +0300 Subject: [PATCH] This needs rework --- SekiroSpeedrunUtil/hotkeys.json | 24 ++- SekiroSpeedrunUtil/ui/FormMain.Designer.cs | 227 ++++++++++++++++----- SekiroSpeedrunUtil/ui/FormMain.cs | 1 - SekiroSpeedrunUtil/ui/FormMainHotkeys.cs | 69 ++++++- 4 files changed, 261 insertions(+), 60 deletions(-) diff --git a/SekiroSpeedrunUtil/hotkeys.json b/SekiroSpeedrunUtil/hotkeys.json index c46b606..56f4bdb 100644 --- a/SekiroSpeedrunUtil/hotkeys.json +++ b/SekiroSpeedrunUtil/hotkeys.json @@ -12,21 +12,27 @@ "Modifiers": 4 }, { - "HotkeyString": "F8", + "HotkeyString": "Shift+F3", "Name": "BackupSave", - "Key": 119, - "Modifiers": 0 + "Key": 114, + "Modifiers": 4 }, { - "HotkeyString": "F9", + "HotkeyString": "Shift+F4", "Name": "LoadSave", - "Key": 120, - "Modifiers": 0 + "Key": 115, + "Modifiers": 4 }, { - "HotkeyString": "F10", + "HotkeyString": "Shift+F5", "Name": "LoadLastQuickSave", - "Key": 121, - "Modifiers": 0 + "Key": 116, + "Modifiers": 4 + }, + { + "HotkeyString": "Shift+F6", + "Name": "ForceQuit", + "Key": 117, + "Modifiers": 4 } ] \ No newline at end of file diff --git a/SekiroSpeedrunUtil/ui/FormMain.Designer.cs b/SekiroSpeedrunUtil/ui/FormMain.Designer.cs index 509744e..801471c 100644 --- a/SekiroSpeedrunUtil/ui/FormMain.Designer.cs +++ b/SekiroSpeedrunUtil/ui/FormMain.Designer.cs @@ -83,6 +83,13 @@ private void InitializeComponent() { this.tabPage1 = new MetroFramework.Controls.MetroTabPage(); this.pageHotkeys = new MetroFramework.Controls.MetroTabPage(); this.metroPanel4 = new MetroFramework.Controls.MetroPanel(); + this.btnRemoveFlagToggle = new MetroFramework.Controls.MetroButton(); + this.btnAddFlagToggle = new MetroFramework.Controls.MetroButton(); + this.flagToggleList = new MetroFramework.Controls.MetroListView(); + this.metroLabel19 = new MetroFramework.Controls.MetroLabel(); + this.flagToggle = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel18 = new MetroFramework.Controls.MetroLabel(); + this.hotkeyQuit = new MetroFramework.Controls.MetroTextBox(); this.metroLabel16 = new MetroFramework.Controls.MetroLabel(); this.hotkeyLoadQuick = new MetroFramework.Controls.MetroTextBox(); this.metroLabel13 = new MetroFramework.Controls.MetroLabel(); @@ -131,8 +138,7 @@ private void InitializeComponent() { this.toastMsg = new MetroFramework.Controls.MetroLabel(); this.btnInfo = new MetroFramework.Controls.MetroLink(); this.lblTinyTitle = new MetroFramework.Controls.MetroLabel(); - this.metroLabel18 = new MetroFramework.Controls.MetroLabel(); - this.hotkeyQuit = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel20 = new MetroFramework.Controls.MetroLabel(); this.groupBox4.SuspendLayout(); this.metroPanel1.SuspendLayout(); this.metroPanel3.SuspendLayout(); @@ -928,6 +934,12 @@ private void InitializeComponent() { // // metroPanel4 // + this.metroPanel4.Controls.Add(this.metroLabel20); + this.metroPanel4.Controls.Add(this.btnRemoveFlagToggle); + this.metroPanel4.Controls.Add(this.btnAddFlagToggle); + this.metroPanel4.Controls.Add(this.flagToggleList); + this.metroPanel4.Controls.Add(this.metroLabel19); + this.metroPanel4.Controls.Add(this.flagToggle); this.metroPanel4.Controls.Add(this.metroLabel18); this.metroPanel4.Controls.Add(this.hotkeyQuit); this.metroPanel4.Controls.Add(this.metroLabel16); @@ -954,6 +966,153 @@ private void InitializeComponent() { this.metroPanel4.VerticalScrollbarHighlightOnWheel = false; this.metroPanel4.VerticalScrollbarSize = 10; // + // btnRemoveFlagToggle + // + this.btnRemoveFlagToggle.Enabled = false; + this.btnRemoveFlagToggle.Location = new System.Drawing.Point(532, 282); + this.btnRemoveFlagToggle.Name = "btnRemoveFlagToggle"; + this.btnRemoveFlagToggle.Size = new System.Drawing.Size(75, 23); + this.btnRemoveFlagToggle.Style = MetroFramework.MetroColorStyle.Teal; + this.btnRemoveFlagToggle.TabIndex = 33; + this.btnRemoveFlagToggle.Text = "-"; + this.btnRemoveFlagToggle.Theme = MetroFramework.MetroThemeStyle.Dark; + this.btnRemoveFlagToggle.UseSelectable = true; + this.btnRemoveFlagToggle.Visible = false; + this.btnRemoveFlagToggle.Click += new System.EventHandler(this.BtnRemoveFlagToggle_Click); + // + // btnAddFlagToggle + // + this.btnAddFlagToggle.Enabled = false; + this.btnAddFlagToggle.Location = new System.Drawing.Point(613, 282); + this.btnAddFlagToggle.Name = "btnAddFlagToggle"; + this.btnAddFlagToggle.Size = new System.Drawing.Size(75, 23); + this.btnAddFlagToggle.Style = MetroFramework.MetroColorStyle.Teal; + this.btnAddFlagToggle.TabIndex = 32; + this.btnAddFlagToggle.Text = "+"; + this.btnAddFlagToggle.Theme = MetroFramework.MetroThemeStyle.Dark; + this.btnAddFlagToggle.UseSelectable = true; + this.btnAddFlagToggle.Visible = false; + this.btnAddFlagToggle.Click += new System.EventHandler(this.BtnAddFlagToggle_Click); + // + // flagToggleList + // + this.flagToggleList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(18)))), ((int)(((byte)(18))))); + this.flagToggleList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.flagToggleList.Enabled = false; + this.flagToggleList.Font = new System.Drawing.Font("Segoe UI", 12F); + this.flagToggleList.ForeColor = System.Drawing.Color.DarkGray; + this.flagToggleList.FullRowSelect = true; + this.flagToggleList.LabelEdit = true; + this.flagToggleList.Location = new System.Drawing.Point(383, 70); + this.flagToggleList.Name = "flagToggleList"; + this.flagToggleList.OwnerDraw = true; + this.flagToggleList.Size = new System.Drawing.Size(305, 206); + this.flagToggleList.TabIndex = 26; + this.flagToggleList.Theme = MetroFramework.MetroThemeStyle.Dark; + this.flagToggleList.UseCompatibleStateImageBehavior = false; + this.flagToggleList.UseCustomBackColor = true; + this.flagToggleList.UseCustomForeColor = true; + this.flagToggleList.UseSelectable = true; + this.flagToggleList.Visible = false; + // + // metroLabel19 + // + this.metroLabel19.AutoSize = true; + this.metroLabel19.Enabled = false; + this.metroLabel19.Location = new System.Drawing.Point(13, 228); + this.metroLabel19.Name = "metroLabel19"; + this.metroLabel19.Size = new System.Drawing.Size(77, 19); + this.metroLabel19.Style = MetroFramework.MetroColorStyle.Teal; + this.metroLabel19.TabIndex = 25; + this.metroLabel19.Text = "Flag Toggle"; + this.metroLabel19.Theme = MetroFramework.MetroThemeStyle.Dark; + this.metroLabel19.Visible = false; + // + // flagToggle + // + // + // + // + this.flagToggle.CustomButton.Image = null; + this.flagToggle.CustomButton.Location = new System.Drawing.Point(128, 2); + this.flagToggle.CustomButton.Name = ""; + this.flagToggle.CustomButton.Size = new System.Drawing.Size(15, 15); + this.flagToggle.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.flagToggle.CustomButton.TabIndex = 1; + this.flagToggle.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.flagToggle.CustomButton.UseSelectable = true; + this.flagToggle.CustomButton.Visible = false; + this.flagToggle.Enabled = false; + this.flagToggle.Lines = new string[] { + "F9"}; + this.flagToggle.Location = new System.Drawing.Point(172, 228); + this.flagToggle.MaxLength = 32767; + this.flagToggle.Name = "flagToggle"; + this.flagToggle.PasswordChar = '\0'; + this.flagToggle.ReadOnly = true; + this.flagToggle.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.flagToggle.SelectedText = ""; + this.flagToggle.SelectionLength = 0; + this.flagToggle.SelectionStart = 0; + this.flagToggle.ShortcutsEnabled = true; + this.flagToggle.ShowClearButton = true; + this.flagToggle.Size = new System.Drawing.Size(146, 20); + this.flagToggle.Style = MetroFramework.MetroColorStyle.Teal; + this.flagToggle.TabIndex = 24; + this.flagToggle.Text = "F9"; + this.flagToggle.Theme = MetroFramework.MetroThemeStyle.Dark; + this.flagToggle.UseSelectable = true; + this.flagToggle.Visible = false; + this.flagToggle.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.flagToggle.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // metroLabel18 + // + this.metroLabel18.AutoSize = true; + this.metroLabel18.Location = new System.Drawing.Point(13, 202); + this.metroLabel18.Name = "metroLabel18"; + this.metroLabel18.Size = new System.Drawing.Size(87, 19); + this.metroLabel18.Style = MetroFramework.MetroColorStyle.Teal; + this.metroLabel18.TabIndex = 23; + this.metroLabel18.Text = "Quit to menu"; + this.metroLabel18.Theme = MetroFramework.MetroThemeStyle.Dark; + // + // hotkeyQuit + // + // + // + // + this.hotkeyQuit.CustomButton.Image = null; + this.hotkeyQuit.CustomButton.Location = new System.Drawing.Point(128, 2); + this.hotkeyQuit.CustomButton.Name = ""; + this.hotkeyQuit.CustomButton.Size = new System.Drawing.Size(15, 15); + this.hotkeyQuit.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.hotkeyQuit.CustomButton.TabIndex = 1; + this.hotkeyQuit.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.hotkeyQuit.CustomButton.UseSelectable = true; + this.hotkeyQuit.CustomButton.Visible = false; + this.hotkeyQuit.Lines = new string[] { + "F9"}; + this.hotkeyQuit.Location = new System.Drawing.Point(172, 202); + this.hotkeyQuit.MaxLength = 32767; + this.hotkeyQuit.Name = "hotkeyQuit"; + this.hotkeyQuit.PasswordChar = '\0'; + this.hotkeyQuit.ReadOnly = true; + this.hotkeyQuit.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.hotkeyQuit.SelectedText = ""; + this.hotkeyQuit.SelectionLength = 0; + this.hotkeyQuit.SelectionStart = 0; + this.hotkeyQuit.ShortcutsEnabled = true; + this.hotkeyQuit.ShowClearButton = true; + this.hotkeyQuit.Size = new System.Drawing.Size(146, 20); + this.hotkeyQuit.Style = MetroFramework.MetroColorStyle.Teal; + this.hotkeyQuit.TabIndex = 22; + this.hotkeyQuit.Text = "F9"; + this.hotkeyQuit.Theme = MetroFramework.MetroThemeStyle.Dark; + this.hotkeyQuit.UseSelectable = true; + this.hotkeyQuit.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.hotkeyQuit.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // // metroLabel16 // this.metroLabel16.AutoSize = true; @@ -1824,58 +1983,24 @@ private void InitializeComponent() { this.lblTinyTitle.Theme = MetroFramework.MetroThemeStyle.Dark; this.lblTinyTitle.Visible = false; // - // metroLabel18 + // metroLabel20 // - this.metroLabel18.AutoSize = true; - this.metroLabel18.Location = new System.Drawing.Point(13, 202); - this.metroLabel18.Name = "metroLabel18"; - this.metroLabel18.Size = new System.Drawing.Size(87, 19); - this.metroLabel18.Style = MetroFramework.MetroColorStyle.Teal; - this.metroLabel18.TabIndex = 23; - this.metroLabel18.Text = "Quit to menu"; - this.metroLabel18.Theme = MetroFramework.MetroThemeStyle.Dark; - // - // hotkeyQuit - // - // - // - // - this.hotkeyQuit.CustomButton.Image = null; - this.hotkeyQuit.CustomButton.Location = new System.Drawing.Point(128, 2); - this.hotkeyQuit.CustomButton.Name = ""; - this.hotkeyQuit.CustomButton.Size = new System.Drawing.Size(15, 15); - this.hotkeyQuit.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.hotkeyQuit.CustomButton.TabIndex = 1; - this.hotkeyQuit.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; - this.hotkeyQuit.CustomButton.UseSelectable = true; - this.hotkeyQuit.CustomButton.Visible = false; - this.hotkeyQuit.Lines = new string[] { - "F9"}; - this.hotkeyQuit.Location = new System.Drawing.Point(172, 202); - this.hotkeyQuit.MaxLength = 32767; - this.hotkeyQuit.Name = "hotkeyQuit"; - this.hotkeyQuit.PasswordChar = '\0'; - this.hotkeyQuit.ReadOnly = true; - this.hotkeyQuit.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.hotkeyQuit.SelectedText = ""; - this.hotkeyQuit.SelectionLength = 0; - this.hotkeyQuit.SelectionStart = 0; - this.hotkeyQuit.ShortcutsEnabled = true; - this.hotkeyQuit.ShowClearButton = true; - this.hotkeyQuit.Size = new System.Drawing.Size(146, 20); - this.hotkeyQuit.Style = MetroFramework.MetroColorStyle.Teal; - this.hotkeyQuit.TabIndex = 22; - this.hotkeyQuit.Text = "F9"; - this.hotkeyQuit.Theme = MetroFramework.MetroThemeStyle.Dark; - this.hotkeyQuit.UseSelectable = true; - this.hotkeyQuit.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); - this.hotkeyQuit.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.metroLabel20.AutoSize = true; + this.metroLabel20.Enabled = false; + this.metroLabel20.Location = new System.Drawing.Point(383, 48); + this.metroLabel20.Name = "metroLabel20"; + this.metroLabel20.Size = new System.Drawing.Size(97, 19); + this.metroLabel20.Style = MetroFramework.MetroColorStyle.Teal; + this.metroLabel20.TabIndex = 34; + this.metroLabel20.Text = "Flags to toggle"; + this.metroLabel20.Theme = MetroFramework.MetroThemeStyle.Dark; + this.metroLabel20.Visible = false; // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(962, 515); + this.ClientSize = new System.Drawing.Size(851, 515); this.Controls.Add(this.lblTinyTitle); this.Controls.Add(this.btnInfo); this.Controls.Add(this.toast); @@ -2025,5 +2150,11 @@ private void InitializeComponent() { private MetroFramework.Controls.MetroButton injectItems; private MetroFramework.Controls.MetroLabel metroLabel18; private MetroFramework.Controls.MetroTextBox hotkeyQuit; + private MetroFramework.Controls.MetroLabel metroLabel19; + private MetroFramework.Controls.MetroTextBox flagToggle; + private MetroFramework.Controls.MetroButton btnRemoveFlagToggle; + private MetroFramework.Controls.MetroButton btnAddFlagToggle; + private MetroFramework.Controls.MetroListView flagToggleList; + private MetroFramework.Controls.MetroLabel metroLabel20; } } \ No newline at end of file diff --git a/SekiroSpeedrunUtil/ui/FormMain.cs b/SekiroSpeedrunUtil/ui/FormMain.cs index 19c3a49..3807596 100644 --- a/SekiroSpeedrunUtil/ui/FormMain.cs +++ b/SekiroSpeedrunUtil/ui/FormMain.cs @@ -201,6 +201,5 @@ private void DetectorMouseMove(object sender, Point p) { Opacity = 0.2d; } - } } diff --git a/SekiroSpeedrunUtil/ui/FormMainHotkeys.cs b/SekiroSpeedrunUtil/ui/FormMainHotkeys.cs index 6658e97..499f751 100644 --- a/SekiroSpeedrunUtil/ui/FormMainHotkeys.cs +++ b/SekiroSpeedrunUtil/ui/FormMainHotkeys.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.Collections.Generic; +using System.IO; using System.Windows.Forms; using Newtonsoft.Json; @@ -11,6 +13,7 @@ public partial class FormMain { private HotkeyStruct _loadSave; private HotkeyStruct _loadQuick; private HotkeyStruct _forceQuit; + private HotkeyStruct _flagToggle; public void InitHotkeys() { @@ -62,6 +65,13 @@ public void InitHotkeys() { hotkeyQuit.Text = hotkeyStruct.HotkeyString; }); break; + /*case "FlagToggle": + _flagToggle = hotkeyStruct; + _flagToggle.Id = HotKeyManager.RegisterHotKey(hotkeyStruct.Key, hotkeyStruct.Modifiers); + flagToggle.InvokeIfRequired(() => { + flagToggle.Text = hotkeyStruct.HotkeyString; + }); + break;*/ } } @@ -71,6 +81,7 @@ public void InitHotkeys() { hotkeyLoadSave.KeyDown += HotkeyLoadSaveOnKeyDown; hotkeyLoadQuick.KeyDown += HotkeyLoadQuickOnKeyDown; hotkeyQuit.KeyDown += HotkeyQuitOnKeyDown; + //flagToggle.KeyDown += FlagToggleOnKeyDown; HotKeyManager.HotKeyPressed += (sender, e) => { mainTabControl.InvokeIfRequired(() => { @@ -84,6 +95,34 @@ public void InitHotkeys() { HotKeyManager.UnregisterHotKey(_saveCurrentCoordinates.Id); } }; + + flagToggleList.DoubleClick += (sender, args) => { + if (flagToggleList.SelectedItems.Count > 0) { + flagToggleList.SelectedItems[0].BeginEdit(); + } + }; + } + + private void FlagToggleOnKeyDown(object sender, KeyEventArgs e) { + var hotkey = ResolveHotkey(e); + if (hotkey.Invalid) return; + if (hotkey.Clear) { + flagToggle.Text = ""; + metroLabel9.Focus(); + return; + } + + flagToggle.Text = hotkey.HotkeyString; + + if (_flagToggle.Id > 0) { + HotKeyManager.UnregisterHotKey(_flagToggle.Id); + } + + _flagToggle = hotkey; + _flagToggle.Name = "FlagToggle"; + _flagToggle.Id = HotKeyManager.RegisterHotKey(hotkey.Key, hotkey.Modifiers); + metroLabel9.Focus(); + SaveHotkeys(); } private void HotkeyQuitOnKeyDown(object sender, KeyEventArgs e) { @@ -181,7 +220,8 @@ private void SaveHotkeys() { _backupSave, _loadSave, _loadQuick, - _forceQuit + _forceQuit, + _flagToggle })); } @@ -215,8 +255,21 @@ private void HotkeyPressed(object sender, HotKeyEventArgs e) { ForceQuit(); return; } + + if (e.Key == _flagToggle.Key && e.Modifiers == _flagToggle.Modifiers) { + FlagToggle(); + return; + } + } + + private void FlagToggle() { + foreach (var item in flagToggleList.Items) { + Diag.WriteLine(item.ToString()); + } } + // flagToggle _flagToggle FlagToggle + private void ForceQuit() { var rp = RemoteProc.Instance(); if (rp == null) return; @@ -316,6 +369,18 @@ private static HotkeyStruct ResolveHotkey(KeyEventArgs e) { return hotkey; } + private void BtnAddFlagToggle_Click(object sender, EventArgs e) { + flagToggleList.Items.Add("Flag Name"); + } + + private void BtnRemoveFlagToggle_Click(object sender, EventArgs e) { + if (flagToggleList.SelectedItems.Count > 0) { + foreach (var selectedItem in flagToggleList.SelectedItems) { + flagToggleList.Items.Remove((ListViewItem)selectedItem); + } + } + } + public struct HotkeyStruct { public string HotkeyString; public string Name;