diff --git a/Core/UI/IMenu/MenuManager.cs b/Core/UI/IMenu/MenuManager.cs index db2c9a3..20b0377 100644 --- a/Core/UI/IMenu/MenuManager.cs +++ b/Core/UI/IMenu/MenuManager.cs @@ -19,6 +19,7 @@ // Menu Interface class, used to control the menu. // // -------------------------------------------------------------------------------------------------------------------- + namespace LeagueSharp.SDK.Core.UI.IMenu { using System; @@ -46,8 +47,8 @@ public class MenuManager public static readonly DirectoryInfo ConfigFolder = Directory.CreateDirectory( Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), - "LS" + Environment.UserName.GetHashCode().ToString("X"), + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "LS" + Environment.UserName.GetHashCode().ToString("X"), "MenuConfigSDK")); /// @@ -268,6 +269,17 @@ protected virtual void FireOnOpen() } } + /// + /// OnUpdate event. + /// + /// + /// The event data + /// + private static void Game_OnUpdate(EventArgs args) + { + // Do nothing. + } + /// /// On Draw event. /// @@ -326,10 +338,10 @@ private void Game_OnWndProc(WndEventArgs args) var keys = new WindowsKeys(args); if (!this.ForcedOpen) { - if (keys.SingleKey == Keys.ShiftKey) + if (keys.SingleKey == Keys.ShiftKey || keys.Key == (Keys.Return | Keys.Shift)) { var keyDown = keys.Msg == WindowsMessages.KEYDOWN; - var keyUp = keys.Msg == WindowsMessages.KEYUP; + var keyUp = keys.Msg == WindowsMessages.KEYUP || keys.Msg == WindowsMessages.CHAR; if (keyDown) { @@ -386,17 +398,6 @@ private void SaveSettings() } } - /// - /// OnUpdate event. - /// - /// - /// The event data - /// - private static void Game_OnUpdate(EventArgs args) - { - // Do nothing. - } - #endregion } } \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs b/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs index edabd46..f306fda 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs @@ -19,6 +19,7 @@ // A default implementation of // // -------------------------------------------------------------------------------------------------------------------- + namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default { using System.Windows.Forms; @@ -71,9 +72,9 @@ public DefaultKeyBind(MenuKeyBind component) public Rectangle ButtonBoundaries(MenuKeyBind component) { return new Rectangle( - (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), - (int)component.Position.Y, - MenuSettings.ContainerHeight, + (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), + (int)component.Position.Y, + MenuSettings.ContainerHeight, MenuSettings.ContainerHeight); } @@ -96,22 +97,22 @@ public override void Draw() .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), - centerY, + MenuManager.Instance.Sprite, + this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + centerY, MenuSettings.TextColor); if (!this.Component.Interacting) { var keyString = "[" + this.Component.Key + "]"; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - keyString, + MenuManager.Instance.Sprite, + keyString, (int) (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - - DefaultUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset), - centerY, + - DefaultUtilities.CalcWidthText(keyString) - MenuSettings.ContainerTextOffset), + centerY, MenuSettings.TextColor); } @@ -122,32 +123,32 @@ public override void Draw() { new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f, - this.Component.Position.Y + 1), + + MenuSettings.ContainerHeight / 2f, + this.Component.Position.Y + 1), new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f, + + MenuSettings.ContainerHeight / 2f, this.Component.Position.Y + MenuSettings.ContainerHeight) - }, + }, this.Component.Active ? new ColorBGRA(0, 100, 0, 255) : new ColorBGRA(255, 0, 0, 255)); Line.End(); var centerX = (int) new Rectangle( - (int)(this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight), - (int)this.Component.Position.Y, - MenuSettings.ContainerHeight, + (int)(this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight), + (int)this.Component.Position.Y, + MenuSettings.ContainerHeight, MenuSettings.ContainerHeight).GetCenteredText( - null, - MenuSettings.Font, - this.Component.Active ? "ON" : "OFF", + null, + MenuSettings.Font, + this.Component.Active ? "ON" : "OFF", CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Active ? "ON" : "OFF", - centerX, - centerY, + MenuManager.Instance.Sprite, + this.Component.Active ? "ON" : "OFF", + centerX, + centerY, MenuSettings.TextColor); } @@ -238,9 +239,9 @@ public override void OnWndProc(WindowsKeys args) var content = this.KeyBindBoundaries(this.Component); if (args.Cursor.IsUnderRectangle( - container.X, - container.Y, - container.Width, + container.X, + container.Y, + container.Width, container.Height)) { this.Component.Active = !this.Component.Active; @@ -302,6 +303,11 @@ private static void ChangeKey(MenuKeyBind component, Keys newKey) /// private static void HandleDown(MenuKeyBind component, Keys expectedKey) { + if (component.Key == Keys.ControlKey && expectedKey == (Keys.Control | Keys.ControlKey)) + { + expectedKey = Keys.ControlKey; + } + if (!component.Interacting && expectedKey == component.Key && component.Type == KeyBindType.Press) { component.Active = true; @@ -317,17 +323,21 @@ private static void HandleDown(MenuKeyBind component, Keys expectedKey) /// private static void HandleUp(MenuKeyBind component, Keys expectedKey) { - if (expectedKey == component.Key) + switch (component.Type) { - switch (component.Type) - { - case KeyBindType.Press: + case KeyBindType.Press: + if ((expectedKey.HasFlag(Keys.Shift) && expectedKey.HasFlag(component.Key)) + || (expectedKey == component.Key)) + { component.Active = false; - break; - case KeyBindType.Toggle: + } + break; + case KeyBindType.Toggle: + if (expectedKey == component.Key) + { component.Active = !component.Active; - break; - } + } + break; } }