/// <summary> /// The windows process event messages. /// </summary> /// <param name="args"> /// The event args. /// </param> private static void OnWndProc(WndEventComposition args) { if (!isVisible) { return; } LuminositySlider.OnWndProc(args); AlphaSlider.OnWndProc(args); var pos = Utils.GetCursorPos(); if (args.Msg == WindowsMessages.WM_LBUTTONDOWN) { isMoving = Utils.IsUnderRectangle(pos, X, Y, BackgroundSprite.Width, 25); // Apply Button if (Utils.IsUnderRectangle(pos, X + 290, Y + 297, 74, 12)) { Close(); return; } // Cancel Button if (Utils.IsUnderRectangle(pos, X + 370, Y + 296, 73, 14)) { FireEvent(initialColor); Close(); return; } if (Utils.IsUnderRectangle(pos, ColorPickerX, ColorPickerY, ColorPickerW, ColorPickerH)) { isSelecting = true; UpdateColor(); } } else if (args.Msg == WindowsMessages.WM_LBUTTONUP) { isMoving = isSelecting = false; } else if (args.Msg == WindowsMessages.WM_MOUSEMOVE) { if (isSelecting) { if (Utils.IsUnderRectangle(pos, ColorPickerX, ColorPickerY, ColorPickerW, ColorPickerH)) { UpdateColor(); } } if (isMoving) { X += (int)(pos.X - previousPos.X); Y += (int)(pos.Y - previousPos.Y); } previousPos = pos; } }
/// <summary> /// The windows event process message event. /// </summary> /// <param name="args"> /// The arguments. /// </param> public void OnWndProc(WndEventComposition args) { switch (args.Msg) { case WindowsMessages.WM_LBUTTONDOWN: if (Utils.IsUnderRectangle( Utils.GetCursorPos(), this.X, this.Y, this.Width, this.Height + Resources.CPActiveSlider.Height)) { this.ActiveSprite.Visible = this.Moving = true; this.InactiveSprite.Visible = false; this.UpdatePercent(); } break; case WindowsMessages.WM_MOUSEMOVE: if (this.Moving) { this.UpdatePercent(); } break; case WindowsMessages.WM_LBUTTONUP: this.ActiveSprite.Visible = this.Moving = false; this.InactiveSprite.Visible = true; break; } }
/// <summary> /// Sends the message. /// </summary> /// <param name="key"> /// The key. /// </param> /// <param name="message"> /// The message. /// </param> public static void SendMessage(uint key, WindowsMessages message, WndEventComposition args) { foreach (var menu in RootMenus) { menu.Value.OnReceiveMessage(message, Utils.GetCursorPos(), key, args); } }
/// <summary> /// The windows process messages event. /// </summary> /// <param name="args"> /// The arguments. /// </param> private static void OnWndProc(WndEventComposition args) { if (args.Msg == WindowsMessages.WM_MOUSEMOVE) { unchecked { posX = (short)args.LParam; posY = (short)((long)args.LParam >> 16); } } }
private static void OnWndProc(WndEventComposition args) { if ((args.Msg == WindowsMessages.WM_KEYUP || args.Msg == WindowsMessages.WM_KEYDOWN) && args.WParam == Config.ShowMenuPressKey) { DrawMenu = args.Msg == WindowsMessages.WM_KEYDOWN; } if (args.Msg == WindowsMessages.WM_KEYUP && args.WParam == Config.ShowMenuToggleKey) { DrawMenu = !DrawMenu; } }
/// <summary> /// Called when the game receives a window message. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="cursorPos"> /// The cursor position. /// </param> /// <param name="key"> /// The key. /// </param> /// <param name="wndArgs"> /// The windows arguments. /// </param> internal void OnReceiveMessage( WindowsMessages message, Vector2 cursorPos, uint key, WndEventComposition wndArgs) { if (message == WindowsMessages.WM_MOUSEMOVE) { if (this.Visible && this.IsInside(cursorPos)) { if (cursorPos.X > this.Position.X + this.Width - 67 && cursorPos.X < this.Position.X + this.Width - 67 + this.Height + 8) { this.ShowTooltip(); } } else { this.ShowTooltip(true); } } switch (this.ValueType) { case MenuValueType.Boolean: if (message != WindowsMessages.WM_LBUTTONDOWN) { return; } if (!this.Visible) { return; } if (!this.IsInside(cursorPos)) { return; } if (cursorPos.X > this.Position.X + this.Width) { break; } if (cursorPos.X > this.Position.X + this.Width - this.Height) { this.SetValue(!this.GetValue <bool>()); } break; case MenuValueType.Slider: if (!this.Visible) { this.Interacting = false; return; } if (message == WindowsMessages.WM_MOUSEMOVE && this.Interacting || message == WindowsMessages.WM_LBUTTONDOWN && !this.Interacting && this.IsInside(cursorPos)) { var val = this.GetValue <Slider>(); var t = val.MinValue + ((cursorPos.X - this.Position.X) * (val.MaxValue - val.MinValue)) / this.Width; val.Value = (int)t; this.SetValue(val); } if (message != WindowsMessages.WM_LBUTTONDOWN && message != WindowsMessages.WM_LBUTTONUP) { return; } if (!this.IsInside(cursorPos) && message == WindowsMessages.WM_LBUTTONDOWN) { return; } this.Interacting = message == WindowsMessages.WM_LBUTTONDOWN; break; case MenuValueType.Color: if (message != WindowsMessages.WM_LBUTTONDOWN) { return; } if (!this.Visible) { return; } if (!this.IsInside(cursorPos)) { return; } if (cursorPos.X > this.Position.X + this.Width) { break; } if (cursorPos.X > this.Position.X + this.Width - this.Height) { var c = this.GetValue <System.Drawing.Color>(); ColorPicker.Load(delegate(System.Drawing.Color args) { this.SetValue(args); }, c); } break; case MenuValueType.Circle: if (message != WindowsMessages.WM_LBUTTONDOWN) { return; } if (!this.Visible) { return; } if (!this.IsInside(cursorPos)) { return; } if (cursorPos.X > this.Position.X + this.Width) { break; } if (cursorPos.X - this.Position.X > this.Width - this.Height) { var val = this.GetValue <Circle>(); val.Active = !val.Active; this.SetValue(val); } else if (cursorPos.X - this.Position.X > this.Width - 2 * this.Height) { var c = this.GetValue <Circle>(); ColorPicker.Load( delegate(System.Drawing.Color args) { var val = this.GetValue <Circle>(); val.Color = args; this.SetValue(val); }, c.Color); } break; case MenuValueType.KeyBind: if (!MenuGUI.IsChatOpen && !Shop.IsOpen) { switch (message) { case WindowsMessages.WM_KEYDOWN: var val = this.GetValue <KeyBind>(); if (key == val.Key || key == val.SecondaryKey) { if (val.Type == KeyBindType.Press) { if (!val.Active) { val.Active = true; this.SetValue(val); } } } break; case WindowsMessages.WM_KEYUP: var val2 = this.GetValue <KeyBind>(); if (key == val2.Key || key == val2.SecondaryKey) { if (val2.Type == KeyBindType.Press) { val2.Active = false; this.SetValue(val2); } else { val2.Active = !val2.Active; this.SetValue(val2); } } break; } } if (key == 8 && message == WindowsMessages.WM_KEYUP && this.Interacting) { var val = this.GetValue <KeyBind>(); val.Key = 0; val.SecondaryKey = 0; this.SetValue(val); this.Interacting = false; this.KeybindSettingStage = KeybindSetStage.NotSetting; } if (message == WindowsMessages.WM_KEYUP && this.Interacting && this.KeybindSettingStage != KeybindSetStage.NotSetting) { if (this.KeybindSettingStage == KeybindSetStage.Keybind1) { var val = this.GetValue <KeyBind>(); val.Key = key; this.SetValue(val); this.KeybindSettingStage = KeybindSetStage.Keybind2; } else if (this.KeybindSettingStage == KeybindSetStage.Keybind2) { var val = this.GetValue <KeyBind>(); val.SecondaryKey = key; this.SetValue(val); this.Interacting = false; this.KeybindSettingStage = KeybindSetStage.NotSetting; } } if (message == WindowsMessages.WM_KEYUP && this.Interacting && this.KeybindSettingStage == KeybindSetStage.NotSetting) { var val = this.GetValue <KeyBind>(); val.Key = key; val.SecondaryKey = 0; this.SetValue(val); this.Interacting = false; } if (!this.Visible) { return; } if (message != WindowsMessages.WM_LBUTTONDOWN && wndArgs.Msg != WindowsMessages.WM_RBUTTONDOWN) { return; } if (!this.IsInside(cursorPos)) { return; } if (cursorPos.X > this.Position.X + this.Width) { break; } if (cursorPos.X > this.Position.X + this.Width - this.Height) { var val = this.GetValue <KeyBind>(); val.Active = !val.Active; this.SetValue(val); } else { if (wndArgs.Msg == WindowsMessages.WM_RBUTTONDOWN) { this.KeybindSettingStage = KeybindSetStage.Keybind1; } //this.Stage = KeybindSetStage.NotSetting; this.Interacting = !this.Interacting; } break; case MenuValueType.StringList: if (!this.Visible) { return; } if (message != WindowsMessages.WM_LBUTTONDOWN) { return; } if (!this.IsInside(cursorPos)) { return; } if (cursorPos.X > this.Position.X + this.Width) { break; } var slVal = this.GetValue <StringList>(); if (cursorPos.X > this.Position.X + this.Width - this.Height) { slVal.SelectedIndex = slVal.SelectedIndex == slVal.SList.Length - 1 ? 0 : (slVal.SelectedIndex + 1); this.SetValue(slVal); } else if (cursorPos.X > this.Position.X + this.Width - 2 * this.Height) { slVal.SelectedIndex = slVal.SelectedIndex == 0 ? slVal.SList.Length - 1 : (slVal.SelectedIndex - 1); this.SetValue(slVal); } break; } }
/// <summary> /// Fired when the game receives a window event. /// </summary> /// <param name="args"> /// The windows event process message args. /// </param> internal void OnWndProc(WndEventComposition args) { this.OnReceiveMessage(args.Msg, Utils.GetCursorPos(), args.WParam, args); }
/// <summary> /// Called when the game receives a window message. /// </summary> /// <param name="message"> /// The message. /// </param> /// <param name="cursorPos"> /// The cursor position. /// </param> /// <param name="key"> /// The key. /// </param> internal void OnReceiveMessage(WindowsMessages message, Vector2 cursorPos, uint key, WndEventComposition args) { //Spread the message to the menu's children recursively foreach (var child in this.Children.ToArray()) { child.OnReceiveMessage(message, cursorPos, key, args); } foreach (var item in this.Items.ToArray()) { item.OnReceiveMessage(message, cursorPos, key, args); } //Handle the left clicks on the menus to hide or show the submenus. if (message != WindowsMessages.WM_LBUTTONDOWN) { return; } if (this.IsRootMenu && this.Visible) { if (cursorPos.X - MenuSettings.BasePosition.X < MenuSettings.MenuItemWidth) { var n = (int)(cursorPos.Y - MenuSettings.BasePosition.Y) / MenuSettings.MenuItemHeight; if (this.MenuCount != n) { foreach (var schild in this.Children.ToArray()) { schild.Visible = false; } foreach (var sitem in this.Items.ToArray()) { sitem.Visible = false; } } } } if (!this.Visible) { return; } if (!this.IsInside(cursorPos)) { return; } if (!this.IsRootMenu && this.Parent != null) { //Close all the submenus in the level foreach (var child in this.Parent.Children.ToArray().Where(child => child.Name != this.Name)) { foreach (var schild in child.Children.ToArray()) { schild.Visible = false; } foreach (var sitem in child.Items.ToArray()) { sitem.Visible = false; } } } //Hide or Show the submenus. foreach (var child in this.Children.ToArray()) { child.Visible = !child.Visible; } //Hide or Show the items. foreach (var item in this.Items.ToArray()) { item.Visible = !item.Visible; } }