/// <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> /// Called per Windows Message. /// </summary> /// <param name="args">WndEventArgs</param> public void OnWndProc(WndEventArgs args) { if (Utils.IsUnderRectangle(Utils.GetCursorPos(), this.position.X, this.position.Y, this.line.Width, 25f)) { #region Mouse var message = (WindowsMessages)args.Msg; if (message == WindowsMessages.WM_LBUTTONDOWN) { if (Utils.TickCount - this.clickTick < 0x5DC) { this.clickTick = Utils.TickCount; Notifications.RemoveNotification(this); this.Draw = this.Update = false; if (this.autoDispose) { this.Dispose(); } return; } this.clickTick = Utils.TickCount; } #endregion } }
/// <summary> /// Called per Windows Message. /// </summary> /// <param name="args">WndEventArgs</param> public void OnWndProc(WndEventArgs args) { if (Utils.IsUnderRectangle(Drawing.WorldToScreen(Game.CursorPos), position.X, position.Y, line.Width, 25f)) { #region Mouse var message = (WindowsMessages)args.Msg; if (message == WindowsMessages.WM_LBUTTONDOWN) { if (Utils.TickCount - clickTick < 0x5DC) { clickTick = Utils.TickCount; Notifications.Free(handler); Draw = Update = false; if (autoDispose) { Dispose(); } return; } clickTick = Utils.TickCount; } #endregion } }
/// <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.SliderActive.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> /// Indicates whether the position is inside the menu item. /// </summary> /// <param name="position"> /// The position. /// </param> /// <returns> /// The <see cref="bool" />. /// </returns> internal bool IsInside(Vector2 position) { return(Utils.IsUnderRectangle( position, this.Position.X, this.Position.Y, !string.IsNullOrEmpty(this.Tooltip) ? this.Width + this.Height : this.Width, this.Height)); }
/// <summary> /// Determines whether the specified position is inside the menu. /// </summary> /// <param name="position"> /// The position. /// </param> /// <returns> /// The <see cref="bool" />. /// </returns> internal bool IsInside(Vector2 position) { return(Utils.IsUnderRectangle(position, this.Position.X, this.Position.Y, this.Width, this.Height)); }
private void OnGameWndProc(WndEventArgs args) { try { if (!Menu.Item(Name + "Clickable").GetValue <bool>()) { return; } var index = 0; var hudWidth = (float)Math.Ceiling(HudWidth * _scale); var hudHeight = (float)Math.Ceiling(HudHeight * _scale); var spacing = (float) Math.Ceiling((10f + Menu.Item(Menu.Name + "DrawingSpacing").GetValue <Slider>().Value) * _scale) + hudHeight; var offsetTop = Menu.Item(Menu.Name + "DrawingOffsetTop").GetValue <Slider>().Value + hudHeight / 2; var offsetRight = Drawing.Width - Menu.Item(Menu.Name + "DrawingOffsetRight").GetValue <Slider>().Value - (hudWidth + (float)Math.Ceiling(4 * _scale)) / 2f; if (args.Msg == (uint)WindowsMessages.WM_RBUTTONUP || args.Msg == (uint)WindowsMessages.WM_LBUTTONDBLCLK) { var pos = Utils.GetCursorPos(); foreach (var enemy in _enemyObjects) { var offset = spacing * index; if (args.Msg == (uint)WindowsMessages.WM_LBUTTONDBLCLK) { var spellData = _spellDatas[enemy.Unit.NetworkId]; for (var i = 0; spellData.Count > i; i++) { var spell = spellData[i]; if (spell != null) { if (Utils.IsUnderRectangle( pos, offsetRight + hudWidth * 0.359f - SummonerWidth / 2f, offsetTop - hudHeight * 0.28f + offset + (float)Math.Ceiling(26 * _scale) * i - SummonerHeight / 2f, SummonerWidth, SummonerHeight)) { var teleportCd = 0f; if (spell.Name.Contains("Teleport", StringComparison.OrdinalIgnoreCase) && _teleports.ContainsKey(enemy.Unit.NetworkId)) { _teleports.TryGetValue(enemy.Unit.NetworkId, out teleportCd); } var time = (teleportCd > 0.1f ? teleportCd : spell.CooldownExpires) - Game.Time; if (time > 0 && Environment.TickCount > _lastChatSend + 1500) { _lastChatSend = Environment.TickCount; var sName = ReadableSummonerName(spell.Name); Game.Say( string.Format( "{0} {1} {2}", enemy.Unit.ChampionName, sName, ((float)(Math.Round(time * 2f, MidpointRounding.AwayFromZero) / 2f)) .FormatTime())); } } } } } else { if (enemy.Unit.IsVisible && !enemy.Unit.IsDead && Utils.IsUnderRectangle( pos, offsetRight - hudWidth / 2f + hudWidth * 0.1f, offsetTop + offset - hudHeight / 2f, hudWidth, hudHeight)) { ObjectManager.Player.IssueOrder(GameObjectOrder.MoveTo, enemy.Unit); } } index++; } } } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } }
/// <summary> /// Called per game tick for update /// </summary> public void OnUpdate() { if (!this.Update) { return; } switch (this.state) { case NotificationState.Idle: { #region Duration End Handler if (!this.flashing && this.duration > 0x0 && this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 && this.BorderColor.A == 0x0) { this.Update = this.Draw = false; if (this.autoDispose) { this.Dispose(); } Notifications.RemoveNotification(this); return; } #endregion #region Decreasement Tick var t = Math.Max(0, this.startT + this.duration - Utils.GameTimeTickCount + 500); if (!this.flashing && this.duration > 0x0 && t < 500) { var alpha = (byte)(255 * ((float)t / 500)); this.TextColor.A = alpha; this.BoxColor.A = alpha; this.BorderColor.A = alpha; } #endregion #region Flashing if (this.flashing) { if (Utils.TickCount - this.flashTick > 0x0) { if (this.TextColor.A > 0x0 && this.BoxColor.A > 0x0 && this.BorderColor.A > 0x0) { if (this.duration > 0x0) { if (this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 && this.BorderColor.A == 0x0) { this.Update = this.Draw = false; if (this.autoDispose) { this.Dispose(); } Notifications.RemoveNotification(this); return; } } this.flashingBytes[0x0] = --this.TextColor.A; this.flashingBytes[0x1] = --this.BoxColor.A; this.flashingBytes[0x2] = --this.BorderColor.A; this.TextColor.A = 0x0; this.BoxColor.A = 0x0; this.BorderColor.A = 0x0; } else { this.TextColor.A = this.flashingBytes[0x0]; this.BoxColor.A = this.flashingBytes[0x1]; this.BorderColor.A = this.flashingBytes[0x2]; if (this.TextColor.A > 0x0) { this.TextColor.A--; } if (this.BoxColor.A > 0x0) { this.BoxColor.A--; } if (this.BorderColor.A > 0x0) { this.BorderColor.A--; } if (this.duration > 0x0) { if (this.TextColor.A == 0x0 && this.BoxColor.A == 0x0 && this.BorderColor.A == 0x0) { this.Update = this.Draw = false; if (this.autoDispose) { this.Dispose(); } Notifications.RemoveNotification(this); return; } } } this.flashTick = Utils.TickCount + this.flashInterval; } } #endregion #region Mouse var mouseLocation = Drawing.WorldToScreen(Game.CursorPos); if (Utils.IsUnderRectangle( mouseLocation, this.position.X, this.position.Y, this.line.Width, 25f)) { this.TextColor.A = 0xFF; this.BoxColor.A = 0xFF; this.BorderColor.A = 0xFF; var textDimension = this.Font.MeasureText(this.sprite, this.Text); if (textDimension.Width + 0x10 > this.line.Width) { var extra = textDimension.Width - 0xB4; if (this.updatePosition == Vector2.Zero) { this.textFix = new Vector2(this.position.X, this.position.Y); this.updatePosition = new Vector2(this.position.X - extra, this.position.Y); } if (this.updatePosition != Vector2.Zero && this.position.X > this.updatePosition.X) { this.position.X -= 1f; this.line.Width += 1f; } } } else if (this.updatePosition != Vector2.Zero) { if (this.position.X < this.textFix.X) { this.position.X += 1f; this.line.Width -= 1f; } else { this.textFix = Vector2.Zero; this.updatePosition = Vector2.Zero; } } #endregion #region Movement var location = Notifications.GetLocation(); if (location != -0x1 && this.position.Y > location) { if (this.updatePosition != Vector2.Zero && this.textFix != Vector2.Zero) { this.position.X = this.textFix.X; this.textFix = Vector2.Zero; this.line.Width = 190f; } this.updatePosition = new Vector2(this.position.X, Notifications.GetLocation(this)); this.state = NotificationState.AnimationMove; this.moveStartT = Utils.GameTimeTickCount; this.moveStartPosition = this.position; } #endregion break; } case NotificationState.AnimationMove: { #region Movement if (Math.Abs(this.position.Y - this.updatePosition.Y) > float.Epsilon) { var percentT = Math.Min(1, ((float)Utils.GameTimeTickCount - this.moveStartT) / 500); this.position.Y = this.moveStartPosition.Y + (this.updatePosition.Y - this.moveStartPosition.Y) * percentT; } else { this.updatePosition = Vector2.Zero; this.state = NotificationState.Idle; } #endregion break; } case NotificationState.AnimationShowShrink: { #region Shrink if (Math.Abs(this.line.Width - 0xB9) < float.Epsilon) { this.state = NotificationState.AnimationShowMove; this.updatePosition = new Vector2(this.position.X, Notifications.GetLocation(this)); return; } this.line.Width--; this.position.X++; #endregion break; } case NotificationState.AnimationShowMove: { #region Movement if (Math.Abs(Notifications.GetLocation() + 0x1E - this.updatePosition.Y) < float.Epsilon) { this.updatePosition.Y = Notifications.GetLocation(); } if (Math.Abs(this.position.Y - this.updatePosition.Y) > float.Epsilon) { var value = (this.updatePosition.Distance(new Vector2(this.position.X, this.position.Y - 0.5f)) < this.updatePosition.Distance(new Vector2(this.position.X, this.position.Y + 0.5f))) ? -0.5f : 0.5f; this.position.Y += value; } else { this.updatePosition = Vector2.Zero; this.state = NotificationState.AnimationShowGrow; } #endregion break; } case NotificationState.AnimationShowGrow: { #region Growth if (Math.Abs(this.line.Width - 0xBE) < float.Epsilon) { this.state = NotificationState.Idle; return; } this.line.Width++; this.position.X--; #endregion break; } } }
/// <summary> /// Called per game tick for update /// </summary> public void OnUpdate() { if (!Update) { return; } switch (state) { case NotificationState.Idle: { #region Duration End Handler if (!flashing && duration > 0x0 && TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.Free(handler); return; } #endregion #region Decreasement Tick if (!flashing && duration > 0x0 && Utils.TickCount - decreasementTick > 0x0) { if (TextColor.A > 0x0) { TextColor.A--; } if (BoxColor.A > 0x0) { BoxColor.A--; } if (BorderColor.A > 0x0) { BorderColor.A--; } decreasementTick = GetNextDecreasementTick(); } #endregion #region Flashing if (flashing) { if (Utils.TickCount - flashTick > 0x0) { if (TextColor.A > 0x0 && BoxColor.A > 0x0 && BorderColor.A > 0x0) { if (duration > 0x0) { if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.Free(handler); return; } } flashingBytes[0x0] = --TextColor.A; flashingBytes[0x1] = --BoxColor.A; flashingBytes[0x2] = --BorderColor.A; TextColor.A = 0x0; BoxColor.A = 0x0; BorderColor.A = 0x0; } else { TextColor.A = flashingBytes[0x0]; BoxColor.A = flashingBytes[0x1]; BorderColor.A = flashingBytes[0x2]; if (TextColor.A > 0x0) { TextColor.A--; } if (BoxColor.A > 0x0) { BoxColor.A--; } if (BorderColor.A > 0x0) { BorderColor.A--; } if (duration > 0x0) { if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.Free(handler); return; } } } flashTick = Utils.TickCount + flashInterval; } } #endregion #region Mouse var mouseLocation = Drawing.WorldToScreen(Game.CursorPos); if (Utils.IsUnderRectangle(mouseLocation, position.X, position.Y, line.Width, 25f)) { TextColor.A = 0xFF; BoxColor.A = 0xFF; BorderColor.A = 0xFF; var textDimension = Font.MeasureText(sprite, Text); if (textDimension.Width + 0x10 > line.Width) { var extra = textDimension.Width - 0xB4; if (updatePosition == Vector2.Zero) { textFix = new Vector2(position.X, position.Y); updatePosition = new Vector2(position.X - extra, position.Y); } if (updatePosition != Vector2.Zero && position.X > updatePosition.X) { position.X -= 1f; line.Width += 1f; } } } else if (updatePosition != Vector2.Zero) { if (position.X < textFix.X) { position.X += 1f; line.Width -= 1f; } else { textFix = Vector2.Zero; updatePosition = Vector2.Zero; } } #endregion #region Movement var location = Notifications.GetLocation(); if (location != -0x1 && position.Y > location) { if (Notifications.IsFirst((int)position.Y)) { handler = Notifications.Reserve(GetId(), handler); if (handler != null) { if (updatePosition != Vector2.Zero && textFix != Vector2.Zero) { position.X = textFix.X; textFix = Vector2.Zero; line.Width = 190f; } updatePosition = new Vector2(position.X, Notifications.GetLocation(handler)); state = NotificationState.AnimationMove; } } } #endregion break; } case NotificationState.AnimationMove: { #region Movement if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon) { var value = (updatePosition.Distance(new Vector2(position.X, position.Y - 0x1)) < updatePosition.Distance(new Vector2(position.X, position.Y + 0x1))) ? -0x1 : 0x1; position.Y += value; } else { updatePosition = Vector2.Zero; state = NotificationState.Idle; } #endregion break; } case NotificationState.AnimationShowShrink: { #region Shrink if (Math.Abs(line.Width - 0xB9) < float.Epsilon) { handler = Notifications.Reserve(GetId(), handler); if (handler != null) { state = NotificationState.AnimationShowMove; updatePosition = new Vector2(position.X, Notifications.GetLocation(handler)); } return; } line.Width--; position.X++; #endregion break; } case NotificationState.AnimationShowMove: { #region Movement if (Math.Abs(Notifications.GetLocation() + 0x1E - updatePosition.Y) < float.Epsilon) { updatePosition.Y = Notifications.GetLocation(); } if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon) { var value = (updatePosition.Distance(new Vector2(position.X, position.Y - 0.5f)) < updatePosition.Distance(new Vector2(position.X, position.Y + 0.5f))) ? -0.5f : 0.5f; position.Y += value; } else { updatePosition = Vector2.Zero; state = NotificationState.AnimationShowGrow; } #endregion break; } case NotificationState.AnimationShowGrow: { #region Growth if (Math.Abs(line.Width - 0xBE) < float.Epsilon) { state = NotificationState.Idle; return; } line.Width++; position.X--; #endregion break; } } }
/// <summary> /// Called per game tick for update /// </summary> public void OnUpdate() { if (!Update) { return; } switch (state) { case NotificationState.Idle: { #region Duration End Handler if (!flashing && duration > 0x0 && TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.RemoveNotification(this); return; } #endregion #region Decreasement Tick var t = Math.Max(0, startT + duration - Utils.GameTimeTickCount + 500); if (!flashing && duration > 0x0 && t < 500) { var alpha = (byte)(255 * ((float)t / 500)); TextColor.A = alpha; BoxColor.A = alpha; BorderColor.A = alpha; } #endregion #region Flashing if (flashing) { if (Utils.TickCount - flashTick > 0x0) { if (TextColor.A > 0x0 && BoxColor.A > 0x0 && BorderColor.A > 0x0) { if (duration > 0x0) { if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.RemoveNotification(this); return; } } flashingBytes[0x0] = --TextColor.A; flashingBytes[0x1] = --BoxColor.A; flashingBytes[0x2] = --BorderColor.A; TextColor.A = 0x0; BoxColor.A = 0x0; BorderColor.A = 0x0; } else { TextColor.A = flashingBytes[0x0]; BoxColor.A = flashingBytes[0x1]; BorderColor.A = flashingBytes[0x2]; if (TextColor.A > 0x0) { TextColor.A--; } if (BoxColor.A > 0x0) { BoxColor.A--; } if (BorderColor.A > 0x0) { BorderColor.A--; } if (duration > 0x0) { if (TextColor.A == 0x0 && BoxColor.A == 0x0 && BorderColor.A == 0x0) { Update = Draw = false; if (autoDispose) { Dispose(); } Notifications.RemoveNotification(this); return; } } } flashTick = Utils.TickCount + flashInterval; } } #endregion #region Mouse var mouseLocation = Drawing.WorldToScreen(Game.CursorPos); if (Utils.IsUnderRectangle(mouseLocation, position.X, position.Y, line.Width, 25f)) { TextColor.A = 0xFF; BoxColor.A = 0xFF; BorderColor.A = 0xFF; var textDimension = Font.MeasureText(sprite, Text); if (textDimension.Width + 0x10 > line.Width) { var extra = textDimension.Width - 0xB4; if (updatePosition == Vector2.Zero) { textFix = new Vector2(position.X, position.Y); updatePosition = new Vector2(position.X - extra, position.Y); } if (updatePosition != Vector2.Zero && position.X > updatePosition.X) { position.X -= 1f; line.Width += 1f; } } } else if (updatePosition != Vector2.Zero) { if (position.X < textFix.X) { position.X += 1f; line.Width -= 1f; } else { textFix = Vector2.Zero; updatePosition = Vector2.Zero; } } #endregion #region Movement var location = Notifications.GetLocation(); if (location != -0x1 && position.Y > location) { if (updatePosition != Vector2.Zero && textFix != Vector2.Zero) { position.X = textFix.X; textFix = Vector2.Zero; line.Width = 190f; } updatePosition = new Vector2(position.X, Notifications.GetLocation(this)); state = NotificationState.AnimationMove; moveStartT = Utils.GameTimeTickCount; moveStartPosition = position; } #endregion break; } case NotificationState.AnimationMove: { #region Movement if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon) { var percentT = Math.Min(1, ((float)Utils.GameTimeTickCount - moveStartT) / 500); position.Y = moveStartPosition.Y + (updatePosition.Y - moveStartPosition.Y) * percentT; } else { updatePosition = Vector2.Zero; state = NotificationState.Idle; } #endregion break; } case NotificationState.AnimationShowShrink: { #region Shrink if (Math.Abs(line.Width - 0xB9) < float.Epsilon) { state = NotificationState.AnimationShowMove; updatePosition = new Vector2(position.X, Notifications.GetLocation(this)); return; } line.Width--; position.X++; #endregion break; } case NotificationState.AnimationShowMove: { #region Movement if (Math.Abs(Notifications.GetLocation() + 0x1E - updatePosition.Y) < float.Epsilon) { updatePosition.Y = Notifications.GetLocation(); } if (Math.Abs(position.Y - updatePosition.Y) > float.Epsilon) { var value = (updatePosition.Distance(new Vector2(position.X, position.Y - 0.5f)) < updatePosition.Distance(new Vector2(position.X, position.Y + 0.5f))) ? -0.5f : 0.5f; position.Y += value; } else { updatePosition = Vector2.Zero; state = NotificationState.AnimationShowGrow; } #endregion break; } case NotificationState.AnimationShowGrow: { #region Growth if (Math.Abs(line.Width - 0xBE) < float.Epsilon) { state = NotificationState.Idle; return; } line.Width++; position.X--; #endregion break; } } }