diff --git a/Core/Bootstrap.cs b/Core/Bootstrap.cs index 3806293..b7c0558 100644 --- a/Core/Bootstrap.cs +++ b/Core/Bootstrap.cs @@ -21,10 +21,10 @@ namespace LeagueSharp.SDK using System.Security.Permissions; using System.Threading; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// Bootstrap is an initialization pointer for the AppDomainManager to initialize the library correctly once loaded in @@ -92,14 +92,22 @@ public static void Init(string[] args) Notifications.Initialize(Variables.LeagueSharpMenu); Logging.Write()(LogLevel.Info, "[SDK Bootstrap] Notifications Initialized."); + // Load the ThemeManager + ThemeManager.Initialize(Variables.LeagueSharpMenu); + Logging.Write()(LogLevel.Info, "[SDK Bootstrap] ThemeManager Initialized."); + // Load Damages. - Damage.Initialize(Variables.GameVersion); + Damage.Initialize(); Logging.Write()(LogLevel.Info, "[SDK Bootstrap] Damage Library Initialized."); + // Load Language + MultiLanguage.LoadTranslation(); + Logging.Write()(LogLevel.Info, "[SDK Bootstrap] MultiLanguage Initialized"); + // Final notification. Logging.Write()(LogLevel.Info, "[-- SDK Bootstrap Loading --]"); } #endregion } -} +} \ No newline at end of file diff --git a/Core/Enumerations/CastStates.cs b/Core/Enumerations/CastStates.cs index e7d3d89..d3829a3 100644 --- a/Core/Enumerations/CastStates.cs +++ b/Core/Enumerations/CastStates.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Cast States @@ -71,6 +71,5 @@ public enum CastStates /// Failed Condition /// FailedCondition - } } \ No newline at end of file diff --git a/Core/Enumerations/CastTypes.cs b/Core/Enumerations/CastTypes.cs deleted file mode 100644 index be49891..0000000 --- a/Core/Enumerations/CastTypes.cs +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// Indicates how a spell can be casted - /// - public enum CastType - { - /// - /// The spell can be casted on an enemy champion - /// - EnemyChampions, - - /// - /// The spell can be casted on an enemy minion - /// - EnemyMinions, - - /// - /// The spell can be casted on an enemy tower - /// - EnemyTurrets, - - /// - /// The spell can be casted on an ally champion - /// - AllyChampions, - - /// - /// The spell can be casted on an ally minion - /// - AllyMinions, - - /// - /// The spell can be casted on an ally turret - /// - AllyTurrets, - - /// - /// The spell can be casted only on pets. - /// - HeroPets, - - /// - /// The spell can be casted on a position - /// - Position, - - /// - /// The spell can be casted in a direction - /// - Direction, - - /// - /// The spell can be casted on self - /// - Self, - - /// - /// The spell is a charging spell - /// - Charging, - - /// - /// The spell is a toggleable spell - /// - Toggle, - - /// - /// The spell is a channel - /// - Channel, - - /// - /// The spell is activable - /// - Activate, - - /// - /// The spell can't be casted - /// - ImpossibleToCast - } -} diff --git a/Core/Enumerations/CenteredFlags.cs b/Core/Enumerations/CenteredFlags.cs index 4f4c480..96f3501 100644 --- a/Core/Enumerations/CenteredFlags.cs +++ b/Core/Enumerations/CenteredFlags.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { using System; @@ -28,32 +28,32 @@ public enum CenteredFlags /// /// None Flag /// - None = 0, + None = 0, /// /// Center Horizontally Left. /// - HorizontalLeft = 1 << 0, + HorizontalLeft = 1 << 0, /// /// Center Horizontally. /// - HorizontalCenter = 1 << 1, + HorizontalCenter = 1 << 1, /// /// Center Horizontally Right. /// - HorizontalRight = 1 << 2, + HorizontalRight = 1 << 2, /// /// Center Vertically Up. /// - VerticalUp = 1 << 3, + VerticalUp = 1 << 3, /// /// Center Vertically. /// - VerticalCenter = 1 << 4, + VerticalCenter = 1 << 4, /// /// Center Vertically Down. diff --git a/Core/Enumerations/CollisionableObjects.cs b/Core/Enumerations/CollisionableObjects.cs deleted file mode 100644 index ee64efe..0000000 --- a/Core/Enumerations/CollisionableObjects.cs +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - using System; - - /// - /// Collision-able Objects Flags - /// - [Flags] - public enum CollisionableObjects - { - /// - /// Minion Collision-able Flag - /// - Minions = 1 << 0, - - /// - /// Hero Collision-able Flag - /// - Heroes = 1 << 1, - - /// - /// Yasuo's Wall Collision-able Flag - /// - YasuoWall = 1 << 2, - - /// - /// Braum's Shield Collision-able Flag - /// - BraumShield = 1 << 3, - - /// - /// Wall Collision-able Flag - /// - Walls = 1 << 4 - } -} \ No newline at end of file diff --git a/Core/Enumerations/DangerLevel.cs b/Core/Enumerations/DangerLevel.cs deleted file mode 100644 index d5dea05..0000000 --- a/Core/Enumerations/DangerLevel.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// The danger level of the spell. - /// - public enum DangerLevel - { - /// - /// Low danger level - /// - Low, - - /// - /// Medium danger level, should be interrupted - /// - Medium, - - /// - /// High danger level, definitely should be interrupted - /// - High - } -} \ No newline at end of file diff --git a/Core/Enumerations/DrawType.cs b/Core/Enumerations/DrawType.cs index 93d98f4..f0344f5 100644 --- a/Core/Enumerations/DrawType.cs +++ b/Core/Enumerations/DrawType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { using System; @@ -28,12 +28,12 @@ public enum DrawType /// /// The OnBeginScene drawing type. /// - OnBeginScene, + OnBeginScene, /// /// The OnDraw drawing type. /// - OnDraw, + OnDraw, /// /// The OnEndScene drawing type. diff --git a/Core/Enumerations/GapcloserType.cs b/Core/Enumerations/GapcloserType.cs deleted file mode 100644 index 46aee8c..0000000 --- a/Core/Enumerations/GapcloserType.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// Gapcloser Spell Type - /// - public enum GapcloserType - { - /// - /// Skillshot Spell - /// - Skillshot, - - /// - /// Targeted Spell - /// - Targeted - } -} \ No newline at end of file diff --git a/Core/Enumerations/HealthPredictionType.cs b/Core/Enumerations/HealthPredictionType.cs index 54f2d5f..279cc7d 100644 --- a/Core/Enumerations/HealthPredictionType.cs +++ b/Core/Enumerations/HealthPredictionType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Name enumerations of health prediction types @@ -25,7 +25,7 @@ public enum HealthPredictionType /// /// Default Prediction /// - Default, + Default, /// /// Simulated Prediction diff --git a/Core/Enumerations/HitChance.cs b/Core/Enumerations/HitChance.cs index 1101bd8..daad63b 100644 --- a/Core/Enumerations/HitChance.cs +++ b/Core/Enumerations/HitChance.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Skillshot HitChance @@ -25,47 +25,47 @@ public enum HitChance /// /// Target is immobile, skillshot will hit. /// - Immobile = 8, + Immobile = 8, /// /// Target is dashing to a known location, skillshot will hit. /// - Dashing = 7, + Dashing = 7, /// /// Very High Prediction output, skillshot will probably hit. /// - VeryHigh = 6, + VeryHigh = 6, /// /// High Prediction output, skillshot will probably hit. /// - High = 5, + High = 5, /// /// Medium Prediction output, accuracy considered low. /// - Medium = 4, + Medium = 4, /// /// Low Prediction output, accuracy considered low. /// - Low = 3, + Low = 3, /// /// Impossible Hit. /// - Impossible = 2, + Impossible = 2, /// /// skillshot is out of range. /// - OutOfRange = 1, + OutOfRange = 1, /// /// Collision before hit onto target. /// - Collision = 0, + Collision = 0, /// /// No HitChance. diff --git a/Core/Enumerations/JungleType.cs b/Core/Enumerations/JungleType.cs index 1f5382b..27222c7 100644 --- a/Core/Enumerations/JungleType.cs +++ b/Core/Enumerations/JungleType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The jungle mob types. @@ -25,17 +25,17 @@ public enum JungleType /// /// The unknown type. /// - Unknown, + Unknown, /// /// The small type. /// - Small, + Small, /// /// The large type. /// - Large, + Large, /// /// The legendary type. diff --git a/Core/Enumerations/KeyBindType.cs b/Core/Enumerations/KeyBindType.cs index b960971..aac0fa4 100644 --- a/Core/Enumerations/KeyBindType.cs +++ b/Core/Enumerations/KeyBindType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Key Bind Type for Menu. @@ -25,7 +25,7 @@ public enum KeyBindType /// /// Toggle Key Bind. /// - Toggle, + Toggle, /// /// Press Key Bind diff --git a/Core/Enumerations/LogLevel.cs b/Core/Enumerations/LogLevel.cs index 6b63fef..76acaf4 100644 --- a/Core/Enumerations/LogLevel.cs +++ b/Core/Enumerations/LogLevel.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The level of the information being logged @@ -25,27 +25,27 @@ public enum LogLevel /// /// Debug Information /// - Debug = 2, + Debug = 2, /// /// An error occurred somewhere in the code (exception) /// - Error = 5, + Error = 5, /// /// An error occurred and the program is unable to proceed /// - Fatal = 6, + Fatal = 6, /// /// General information /// - Info = 1, + Info = 1, /// /// Current location of the program /// - Trace = 3, + Trace = 3, /// /// Warning level diff --git a/Core/Enumerations/MinionTypes.cs b/Core/Enumerations/MinionTypes.cs index 88b2b7a..515344c 100644 --- a/Core/Enumerations/MinionTypes.cs +++ b/Core/Enumerations/MinionTypes.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { using System; diff --git a/Core/Enumerations/NotificationIconType.cs b/Core/Enumerations/NotificationIconType.cs index dd0ad93..f6004a2 100644 --- a/Core/Enumerations/NotificationIconType.cs +++ b/Core/Enumerations/NotificationIconType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The notification icon type. @@ -25,22 +25,22 @@ public enum NotificationIconType /// /// No Icon. /// - None = 0, + None = 0, /// /// Error Icon. /// - Error = 1, + Error = 1, /// /// Warning Icon. /// - Warning = 2, + Warning = 2, /// /// Check Icon. /// - Check = 3, + Check = 3, /// /// Select Icon. diff --git a/Core/Enumerations/OrbwalkingMode.cs b/Core/Enumerations/OrbwalkingMode.cs index 707fd35..f404b4c 100644 --- a/Core/Enumerations/OrbwalkingMode.cs +++ b/Core/Enumerations/OrbwalkingMode.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Orbwalker Modes diff --git a/Core/Enumerations/OrbwalkingType.cs b/Core/Enumerations/OrbwalkingType.cs index 6360935..ec6b3dd 100644 --- a/Core/Enumerations/OrbwalkingType.cs +++ b/Core/Enumerations/OrbwalkingType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Orbwalker Process Type diff --git a/Core/Enumerations/PerformanceType.cs b/Core/Enumerations/PerformanceType.cs index 76143c9..dd33c7d 100644 --- a/Core/Enumerations/PerformanceType.cs +++ b/Core/Enumerations/PerformanceType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Performance Type to log. @@ -25,12 +25,12 @@ public enum PerformanceType /// /// Logs the Tick Count(CPU Ticks). /// - TickCount, + TickCount, /// /// Logs the number of milliseconds. /// - Milliseconds, + Milliseconds, /// /// Logs the time spanned in TimeSpam format. diff --git a/Core/Enumerations/SkillshotDetectionType.cs b/Core/Enumerations/SkillshotDetectionType.cs index f2d58c7..4c316ee 100644 --- a/Core/Enumerations/SkillshotDetectionType.cs +++ b/Core/Enumerations/SkillshotDetectionType.cs @@ -1,4 +1,4 @@ -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { public enum SkillshotDetectionType { diff --git a/Core/Enumerations/SkillshotType.cs b/Core/Enumerations/SkillshotType.cs index d5c3cb2..87f0128 100644 --- a/Core/Enumerations/SkillshotType.cs +++ b/Core/Enumerations/SkillshotType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// Skillshot Type Enumeration @@ -25,12 +25,12 @@ public enum SkillshotType /// /// Determines that the skillshot is a linear skillshot. /// - SkillshotLine, + SkillshotLine, /// /// Determines that the skillshot is a circle skillshot. /// - SkillshotCircle, + SkillshotCircle, /// /// Determines that the skillshot is a cone skillshot. diff --git a/Core/Enumerations/SpellTags.cs b/Core/Enumerations/SpellTags.cs deleted file mode 100644 index 2f0dbfd..0000000 --- a/Core/Enumerations/SpellTags.cs +++ /dev/null @@ -1,135 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// Properties that a spell can have - /// - public enum SpellTags - { - /// - /// The spell deals damage - /// - Damage, - - /// - /// The spell's effects are AoE - /// - AoE, - - /// - /// The spell applies on-hit effects. - /// - AppliesOnHitEffects, - - /// - /// The spell applies CC - /// - CrowdControl, - - /// - /// The spell applies a shield on the target - /// - Shield, - - /// - /// The spell can heal - /// - Heal, - - /// - /// The spell makes the target enter a stasis state (invulnerable) - /// - Stasis, - - /// - /// The spell leaves a mark than can subsequently be proc'd to deal additional damage - /// - LeavesMark, - - /// - /// The spell can detonate a previously left mark. - /// - CanDetonateMark, - - /// - /// The spell modifies the champion's other spells (nida/jayce/elise ult) - /// - Transformation, - - /// - /// The spell is a dash - /// - Dash, - - /// - /// The spell is a blink - /// - Blink, - - /// - /// The spell teleports the champion - /// - Teleport, - - /// - /// The spell amplifies the damage dealt by attacks or spells - /// - DamageAmplifier, - - /// - /// The spell increases health/armor/mr - /// - DefensiveBuff, - - /// - /// The spell increases the target's movement speed - /// - MovementSpeedAmplifier, - - /// - /// The spell increases the target's Attack Speed - /// - AttackSpeedAmplifier, - - /// - /// The spell increases the target's Attack Range - /// - AttackRangeModifier, - - /// - /// The spell applies a spellshield - /// - SpellShield, - - /// - /// The spell removes all CC from target - /// - RemoveCrowdControl, - - /// - /// The spell grants vision of the target area. - /// - GrantsVision, - - /// - /// The spell can be interrupted - /// - Interruptable - } -} \ No newline at end of file diff --git a/Core/Enumerations/SpellType.cs b/Core/Enumerations/SpellType.cs deleted file mode 100644 index 612616c..0000000 --- a/Core/Enumerations/SpellType.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// SpellType enumeration - /// - public enum SpellType - { - /// - /// The spell is a Circle Skillshot - /// - SkillshotCircle, - - /// - /// The spell is a Circle Skillshot that leaves a Missile - /// - SkillshotMissileCircle, - - /// - /// The spell is a Line Skillshot - /// - SkillshotLine, - - /// - /// The spell is a Line Skillshot that creates a Missile - /// - SkillshotMissileLine, - - /// - /// The spell is a Cone Skillshot - /// - SkillshotCone, - - /// - /// The spell is a Cone Skillshot that leaves a Missile - /// - SkillshotMissileCone, - - /// - /// The spell is an Arc Skillshot (Diana Q) - /// - SkillshotMissileArc, - - /// - /// The spell is a Ring Skillshot (Veigar E) - /// - SkillshotRing, - - /// - /// The spell is an Arc Skillshot - /// - SkillshotArc, - - /// - /// The spell is Targeted - /// - Targeted, - - /// - /// The spell is Targeted and has a missile. - /// - TargetedMissile, - - /// - /// The spell can be toggled on/off - /// - Toggled, - - /// - /// The spell can be activated, after which it lasts for a while (Vayne R, Olaf R) - /// - Activated, - - /// - /// The spell does nothing else but contain a passive (Vayne W, Mini Gnar W) - /// - Passive, - - /// - /// The spell is casted to a position like a skillshot but does undodgeable / random damage. Ezreal E, Ahri R... - /// - Position, - - /// - /// The spell must specify a start point and an end point (Viktor E, Rumble R) - /// - Vector - } -} \ No newline at end of file diff --git a/Core/Enumerations/TeleportStatus.cs b/Core/Enumerations/TeleportStatus.cs index 039cb44..a63def2 100644 --- a/Core/Enumerations/TeleportStatus.cs +++ b/Core/Enumerations/TeleportStatus.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The teleport status. @@ -25,17 +25,17 @@ public enum TeleportStatus /// /// The start status. /// - Start, + Start, /// /// The abort status. /// - Abort, + Abort, /// /// The finish status. /// - Finish, + Finish, /// /// The unknown status. diff --git a/Core/Enumerations/TeleportType.cs b/Core/Enumerations/TeleportType.cs index 4fc0d4d..95fd442 100644 --- a/Core/Enumerations/TeleportType.cs +++ b/Core/Enumerations/TeleportType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The teleport type. @@ -25,22 +25,22 @@ public enum TeleportType /// /// The recall type. /// - Recall, + Recall, /// /// The teleport type. /// - Teleport, + Teleport, /// /// The twisted fate type. /// - TwistedFate, + TwistedFate, /// /// The shen type. /// - Shen, + Shen, /// /// The unknown type. diff --git a/Core/Enumerations/TurretType.cs b/Core/Enumerations/TurretType.cs index e275c92..83c6ac4 100644 --- a/Core/Enumerations/TurretType.cs +++ b/Core/Enumerations/TurretType.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { /// /// The turret type. @@ -25,22 +25,22 @@ public enum TurretType /// /// The unknown tier. /// - Unknown, + Unknown, /// /// The tier one. /// - TierOne, + TierOne, /// /// The tier two. /// - TierTwo, + TierTwo, /// /// The tier three. /// - TierThree, + TierThree, /// /// The tier four. diff --git a/Core/Enumerations/WindowsMessages.cs b/Core/Enumerations/WindowsMessages.cs index a13e81e..0664f65 100644 --- a/Core/Enumerations/WindowsMessages.cs +++ b/Core/Enumerations/WindowsMessages.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Enumerations { using System; using System.Diagnostics.CodeAnalysis; @@ -25,7 +25,8 @@ namespace LeagueSharp.SDK /// Defined in from Windows SDK v6.1 /// Documentation pulled from MSDN. /// - [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Official names from the winuser.h of the Windows SDK v6.1")] + [SuppressMessage("ReSharper", "InconsistentNaming", + Justification = "Official names from the winuser.h of the Windows SDK v6.1")] public enum WindowsMessages : uint { /// diff --git a/Core/Events/Dash.cs b/Core/Events/Dash.cs index 5160a07..e773d72 100644 --- a/Core/Events/Dash.cs +++ b/Core/Events/Dash.cs @@ -76,12 +76,7 @@ public static DashArgs GetDashInfo(this Obj_AI_Base unit) public static bool IsDashing(this Obj_AI_Base unit) { DashArgs value; - if (DetectedDashes.TryGetValue(unit.NetworkId, out value) && unit.Path.Length != 0) - { - return value.EndTick != 0; - } - - return false; + return DetectedDashes.TryGetValue(unit.NetworkId, out value) && unit.Path.Length != 0 && value.EndTick != 0; } #endregion @@ -96,39 +91,42 @@ public static bool IsDashing(this Obj_AI_Base unit) private static void EventDash(Obj_AI_Base sender, GameObjectNewPathEventArgs args) { var hero = sender as Obj_AI_Hero; - if (hero != null && hero.IsValid) + + if (hero == null || !hero.IsValid) + { + return; + } + + if (!DetectedDashes.ContainsKey(hero.NetworkId)) + { + DetectedDashes.Add(hero.NetworkId, new DashArgs()); + } + + if (args.IsDash) + { + var path = new List { hero.ServerPosition.ToVector2() }; + path.AddRange(args.Path.ToList().ToVector2()); + + DetectedDashes[hero.NetworkId].Unit = sender; + DetectedDashes[hero.NetworkId].Path = path; + DetectedDashes[hero.NetworkId].Speed = args.Speed; + DetectedDashes[hero.NetworkId].StartPos = hero.ServerPosition.ToVector2(); + DetectedDashes[hero.NetworkId].StartTick = Variables.TickCount - (Game.Ping / 2); + DetectedDashes[hero.NetworkId].EndPos = path.Last(); + DetectedDashes[hero.NetworkId].EndTick = DetectedDashes[hero.NetworkId].StartTick + + (int) + (1000 + * (DetectedDashes[hero.NetworkId].EndPos.Distance( + DetectedDashes[hero.NetworkId].StartPos) + / DetectedDashes[hero.NetworkId].Speed)); + DetectedDashes[hero.NetworkId].Duration = DetectedDashes[hero.NetworkId].EndTick + - DetectedDashes[hero.NetworkId].StartTick; + + OnDash?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, DetectedDashes[hero.NetworkId]); + } + else { - if (!DetectedDashes.ContainsKey(hero.NetworkId)) - { - DetectedDashes.Add(hero.NetworkId, new DashArgs()); - } - - if (args.IsDash) - { - var path = new List { hero.ServerPosition.ToVector2() }; - path.AddRange(args.Path.ToList().ToVector2()); - - DetectedDashes[hero.NetworkId].Unit = sender; - DetectedDashes[hero.NetworkId].Path = path; - DetectedDashes[hero.NetworkId].Speed = args.Speed; - DetectedDashes[hero.NetworkId].StartPos = hero.ServerPosition.ToVector2(); - DetectedDashes[hero.NetworkId].StartTick = Variables.TickCount - (Game.Ping / 2); - DetectedDashes[hero.NetworkId].EndPos = path.Last(); - DetectedDashes[hero.NetworkId].EndTick = DetectedDashes[hero.NetworkId].StartTick - + (int) - (1000 - * (DetectedDashes[hero.NetworkId].EndPos.Distance( - DetectedDashes[hero.NetworkId].StartPos) - / DetectedDashes[hero.NetworkId].Speed)); - DetectedDashes[hero.NetworkId].Duration = DetectedDashes[hero.NetworkId].EndTick - - DetectedDashes[hero.NetworkId].StartTick; - - OnDash?.Invoke(MethodBase.GetCurrentMethod().DeclaringType, DetectedDashes[hero.NetworkId]); - } - else - { - DetectedDashes[hero.NetworkId].EndTick = 0; - } + DetectedDashes[hero.NetworkId].EndTick = 0; } } diff --git a/Core/Events/Events.cs b/Core/Events/Events.cs index 1782561..c89cfb8 100644 --- a/Core/Events/Events.cs +++ b/Core/Events/Events.cs @@ -19,12 +19,9 @@ namespace LeagueSharp.SDK { using System; - using LeagueSharp.SDK.Core.Utils; - /// /// The provided events by the kit. /// - [ResourceImport] public static partial class Events { #region Constructors and Destructors diff --git a/Core/Events/Gapcloser.cs b/Core/Events/Gapcloser.cs index 48d1be2..dfd9569 100644 --- a/Core/Events/Gapcloser.cs +++ b/Core/Events/Gapcloser.cs @@ -22,7 +22,9 @@ namespace LeagueSharp.SDK using System.Linq; using System.Reflection; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.Data.Enumerations; using SharpDX; @@ -39,10 +41,10 @@ public static partial class Events private static readonly List ActiveSpellsList = new List(); /// - /// Gets or sets the spells. + /// Gets the spells. /// - [ResourceImport("Data.Gapclosers.json")] - private static readonly Dictionary SpellsList = new Dictionary(); + private static readonly IReadOnlyDictionary SpellsList = + Data.Get().SpellsList; #endregion @@ -65,7 +67,7 @@ public static partial class Events /// /// Gets the spells. /// - public static IEnumerable GapCloserSpells => SpellsList.Values; + public static IEnumerable GapCloserSpells => SpellsList.Values; #endregion @@ -78,30 +80,34 @@ public static partial class Events /// Process Spell Cast Data private static void EventGapcloser(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { - if (SpellsList.All(spell => spell.Value.SpellName != args.SData.Name.ToLower())) + if (SpellsList.Values.All(spell => spell.SpellName != args.SData.Name.ToLower())) { return; } var hero = sender as Obj_AI_Hero; - var player = GameObjects.Player; - if (hero != null) + + if (hero == null || hero.IsAlly) { - ActiveSpellsList.Add( - new GapCloserEventArgs - { - Start = args.Start, End = args.End, Sender = hero, TickCount = Variables.TickCount, - SkillType = - (args.Target != null && args.Target.IsValid) - ? GapcloserType.Targeted - : GapcloserType.Skillshot, - Slot = args.Slot, - IsDirectedToPlayer = - (args.Target != null && args.Target.IsValid && args.Target.IsMe) - || player.Distance(args.End) < player.Distance(args.Start) || sender.IsFacing(player), - SpellName = args.SData.Name - }); + return; } + + ActiveSpellsList.Add( + new GapCloserEventArgs + { + Start = args.Start, End = args.End, Target = args.Target, + Sender = hero, TickCount = Variables.TickCount, + SkillType = + (args.Target != null && args.Target.IsValid) + ? GapcloserType.Targeted + : GapcloserType.Skillshot, + Slot = args.Slot, + IsDirectedToPlayer = (hero.Distance(ObjectManager.Player) < 1500 || args.End.Distance(ObjectManager.Player.Position) < 800) && + ((args.Target != null && args.Target.IsValid && args.Target.IsMe) + || args.End.DistanceToPlayer() < args.Start.DistanceToPlayer() + || hero.IsFacing(GameObjects.Player)), + SpellName = args.SData.Name + }); } /// @@ -110,6 +116,7 @@ private static void EventGapcloser(Obj_AI_Base sender, GameObjectProcessSpellCas private static void EventGapcloser() { ActiveSpellsList.RemoveAll(entry => Variables.TickCount > entry.TickCount + 900); + if (OnGapCloser == null) { return; @@ -129,31 +136,6 @@ private static void EventGapcloser() #endregion - /// - /// GapCloser Data Container - /// - public struct GapCloser - { - #region Fields - - /// - /// Spell Type - /// - public GapcloserType SkillType { get; set; } - - /// - /// Spell Slot - /// - public SpellSlot Slot { get; set; } - - /// - /// Spell Name - /// - public string SpellName { get; set; } - - #endregion - } - /// /// GapCloser Data Container /// @@ -162,9 +144,13 @@ public class GapCloserEventArgs : EventArgs #region Public Properties /// - /// Gets or sets the end. + /// Gets or sets the position at which the enemy will be upon spell completion. /// public Vector3 End { get; set; } + + /// + /// Gets or sets the target of the gapcloser spell. It can be null! + public GameObject Target { get; set; } /// /// Gets or sets a value indicating whether is directed to player. @@ -204,4 +190,4 @@ public class GapCloserEventArgs : EventArgs #endregion } } -} \ No newline at end of file +} diff --git a/Core/Events/InterruptableSpell.cs b/Core/Events/InterruptableSpell.cs index 621a72f..b64fd18 100644 --- a/Core/Events/InterruptableSpell.cs +++ b/Core/Events/InterruptableSpell.cs @@ -22,64 +22,53 @@ namespace LeagueSharp.SDK using System.Linq; using System.Reflection; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.Data.Enumerations; /// /// Provides events for interrupting spells. /// public static partial class Events { - #region Public Events + #region Static Fields /// - /// Gets fired when an enemy is casting a spellData that should be interrupted. - /// - public static event EventHandler OnInterruptableTarget; - - #endregion - - #region Public Properties - - /// - /// Gets the casting interruptible spell dictionary. + /// Gets the global interruptable spells. /// - public static IReadOnlyDictionary CastingInterruptableSpell - => CastingInterruptableSpellDictionary; + public static readonly IReadOnlyList GlobalInterruptableSpells = + Data.Get().GlobalInterruptableSpells; /// - /// Gets the interruptible spells dictionary. + /// Gets the interruptable spells. /// - public static IReadOnlyList GlobalInterruptableSpells => GlobalInterruptableSpellsList; + public static readonly IReadOnlyDictionary> InterruptableSpells = + Data.Get().InterruptableSpells; /// - /// Gets the interruptible spells dictionary. + /// Gets the casting interruptable spells. /// - public static IReadOnlyDictionary> InterruptableSpells - => InterruptableSpellsDictionary; + private static readonly Dictionary CastingInterruptableSpellDictionary = + new Dictionary(); #endregion - #region Properties + #region Public Events /// - /// Gets or sets the casting interrupt-able spell. + /// Gets fired when an enemy is casting a spellData that should be interrupted. /// - private static Dictionary CastingInterruptableSpellDictionary { get; set; } = - new Dictionary(); + public static event EventHandler OnInterruptableTarget; - /// - /// Gets or sets the interrupt-able spells. - /// - [ResourceImport("Data.InterruptableSpells.json")] - private static Dictionary> InterruptableSpellsDictionary { get; set; } = - new Dictionary>(); + #endregion + + #region Public Properties /// - /// Gets the global interruptable spells list. + /// Gets the casting interruptible spell dictionary. /// - [ResourceImport("Data.GlobalInterruptableSpellsList.json")] - private static List GlobalInterruptableSpellsList { get; set; } = - new List(); + public static IReadOnlyDictionary CastingInterruptableSpell + => CastingInterruptableSpellDictionary; #endregion @@ -101,17 +90,14 @@ public static InterruptableTargetEventArgs GetInterruptableTargetData(Obj_AI_Her return null; } - InterruptableSpellData value; - if (CastingInterruptableSpellDictionary.TryGetValue(target.NetworkId, out value)) - { - return new InterruptableTargetEventArgs( - target, - value.DangerLevel, - target.Spellbook.CastEndTime, - value.MovementInterrupts); - } - - return null; + InterruptableSpellDataEntry value; + return CastingInterruptableSpellDictionary.TryGetValue(target.NetworkId, out value) + ? new InterruptableTargetEventArgs( + target, + value.DangerLevel, + target.Spellbook.CastEndTime, + value.MovementInterrupts) + : null; } /// @@ -174,24 +160,26 @@ private static void EventInterruptableSpell() private static void EventInterruptableSpell(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) { var target = sender as Obj_AI_Hero; + if (target == null || CastingInterruptableSpellDictionary.ContainsKey(target.NetworkId)) { return; } var globalInterruptSpell = GlobalInterruptableSpells.FirstOrDefault(s => s.Name.Equals(args.SData.Name)); + if (globalInterruptSpell != null) { CastingInterruptableSpellDictionary.Add(target.NetworkId, globalInterruptSpell); return; } - if (!InterruptableSpellsDictionary.ContainsKey(target.ChampionName)) + if (!InterruptableSpells.ContainsKey(target.ChampionName)) { return; } - var spell = InterruptableSpellsDictionary[target.ChampionName].Find( + var spell = InterruptableSpells[target.ChampionName].Find( s => { var firstOrDefault = target.Spellbook.Spells.FirstOrDefault( @@ -228,93 +216,6 @@ private static void EventInterruptableSpell(Spellbook sender) #endregion - /// - /// Interrupt-able Spell Data - /// - public class InterruptableSpellData - { - #region Constructors and Destructors - - /// - /// Initializes a new instance of the class. - /// - public InterruptableSpellData() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Spell Slot - /// - /// - /// Danger Level - /// - /// - /// Does movement interrupt the spell - /// - public InterruptableSpellData(SpellSlot slot, DangerLevel dangerLevel, bool movementInterrupts = true) - { - this.Slot = slot; - this.DangerLevel = dangerLevel; - this.MovementInterrupts = movementInterrupts; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// Spell Name - /// - /// - /// Danger Level - /// - /// - /// The slot. - /// - /// - /// Does movement interrupt the spell - /// - public InterruptableSpellData( - string name, - DangerLevel dangerLevel, - SpellSlot slot = SpellSlot.Unknown, - bool movementInterrupts = true) - { - this.Name = name; - this.DangerLevel = dangerLevel; - this.Slot = slot; - this.MovementInterrupts = movementInterrupts; - } - - #endregion - - #region Public Properties - - /// - /// Gets the danger level. - /// - public DangerLevel DangerLevel { get; set; } - - /// - /// Gets a value indicating whether movement interrupts. - /// - public bool MovementInterrupts { get; set; } - - /// - /// Gets the name. - /// - public string Name { get; set; } - - /// - /// Gets the slot. - /// - public SpellSlot Slot { get; set; } - - #endregion - } - /// /// Class that represents the event arguments for /// diff --git a/Core/Events/Load.cs b/Core/Events/Load.cs index 6c5cb6f..e9735ee 100644 --- a/Core/Events/Load.cs +++ b/Core/Events/Load.cs @@ -21,7 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; using System.Reflection; - using LeagueSharp.SDK.Core.Utils; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Provides an event for when the game starts. diff --git a/Core/Events/Teleport.cs b/Core/Events/Teleport.cs index f72e501..897383f 100644 --- a/Core/Events/Teleport.cs +++ b/Core/Events/Teleport.cs @@ -21,6 +21,8 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Reflection; + using LeagueSharp.SDK.Enumerations; + /// /// Teleport class, contains Teleport even which is triggered on recalls, teleports and shen or twisted fate /// ultimates. diff --git a/Core/Extensions/Enumerable.cs b/Core/Extensions/Enumerable.cs index e50db03..a26ca8e 100644 --- a/Core/Extensions/Enumerable.cs +++ b/Core/Extensions/Enumerable.cs @@ -21,7 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.ComponentModel; using System.Linq; - using LeagueSharp.SDK.Core.Utils; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; diff --git a/Core/Extensions/SharpDX/Generic.cs b/Core/Extensions/SharpDX/Generic.cs index 1f2de90..522c352 100644 --- a/Core/Extensions/SharpDX/Generic.cs +++ b/Core/Extensions/SharpDX/Generic.cs @@ -17,7 +17,7 @@ namespace LeagueSharp.SDK { - using global::SharpDX; + using SharpDX; /// /// The generic SharpDX extensions. diff --git a/Core/Extensions/SharpDX/Vector2Extensions.cs b/Core/Extensions/SharpDX/Vector2Extensions.cs index d826138..26a43c6 100644 --- a/Core/Extensions/SharpDX/Vector2Extensions.cs +++ b/Core/Extensions/SharpDX/Vector2Extensions.cs @@ -39,6 +39,7 @@ public static partial class Extensions public static float AngleBetween(this Vector2 vector2, Vector2 toVector2) { var theta = vector2.Polar() - toVector2.Polar(); + if (theta < 0) { theta = theta + 360; @@ -107,6 +108,7 @@ public static Vector2 Closest(this Vector2 vector2, IEnumerable array) foreach (var vector in array) { var temporaryDistance = vector2.Distance(vector); + if (distance < temporaryDistance) { distance = temporaryDistance; @@ -131,6 +133,7 @@ public static Vector3 Closest(this Vector2 vector2, IEnumerable array) foreach (var vector in array) { var temporaryDistance = vector2.Distance(vector); + if (distance < temporaryDistance) { distance = temporaryDistance; @@ -361,12 +364,14 @@ public static IntersectionResult Intersection( } var r = numerator / denominator; + if (r < 0 || r > 1) { return default(IntersectionResult); } var s = ((deltaACy * deltaBAx) - (deltaACx * deltaBAy)) / denominator; + if (s < 0 || s > 1) { return default(IntersectionResult); @@ -476,7 +481,7 @@ public static bool IsValid(this Vector2 vector2) /// Is Vector2 position a wall position public static bool IsWall(this Vector2 vector2) { - return vector2.ToVector3().IsWall(); + return NavMesh.GetCollisionFlags(vector2.X, vector2.Y).HasFlag(CollisionFlags.Wall); } /// @@ -512,6 +517,7 @@ public static Vector2 Normalized(this Vector2 vector2) public static float PathLength(this List path) { var distance = 0f; + for (var i = 0; i < path.Count - 1; i++) { distance += path[i].Distance(path[i + 1]); @@ -544,6 +550,7 @@ public static float Polar(this Vector2 vector2) } var theta = (float)(Math.Atan(vector2.Y / vector2.X) * (180 / Math.PI)); + if (vector2.X < 0) { theta += 180; @@ -576,6 +583,7 @@ public static ProjectionInfo ProjectOn(this Vector2 point, Vector2 segmentStart, / ((float)Math.Pow(bx - ax, 2) + (float)Math.Pow(by - ay, 2)); var pointLine = new Vector2(ax + (rL * (bx - ax)), ay + (rL * (by - ay))); float rS; + if (rL < 0) { rS = 0; @@ -635,32 +643,6 @@ public static List ToVector3(this List path) return path.Select(point => point.ToVector3()).ToList(); } - /// - /// Transforms an extended Vector2 into a Vector4. - /// - /// SharpDX Vector2 - /// Float Z-axis (default = 0f) - /// Float W-axis (default = 0f) - /// The - public static Vector4 ToVector4(this Vector2 vector2, float z = 0f, float w = 1f) - { - return new Vector4(vector2, z, w); - } - - /// - /// Transforms an extended Vector2 List into a Vector4 List. - /// - /// - /// The path. - /// - /// - /// Vector4 List - /// - public static List ToVector4(this List path) - { - return path.Select(point => point.ToVector4()).ToList(); - } - /// /// Calculates movement collision between two vectors points. /// @@ -778,6 +760,7 @@ public static MovementCollisionInfo VectorMovementCollision( else { var sqr = (b * b) - (a * c); + if (sqr >= 0) { var nom = (float)Math.Sqrt(sqr); @@ -808,7 +791,7 @@ public static MovementCollisionInfo VectorMovementCollision( return new MovementCollisionInfo( t1, - (!float.IsNaN(t1)) ? new Vector2(sP1X + (s * t1), sP1Y + (k * t1)) : default(Vector2)); + !float.IsNaN(t1) ? new Vector2(sP1X + (s * t1), sP1Y + (k * t1)) : default(Vector2)); } #endregion diff --git a/Core/Extensions/SharpDX/Vector3Extensions.cs b/Core/Extensions/SharpDX/Vector3Extensions.cs index 50afa6c..1bed35c 100644 --- a/Core/Extensions/SharpDX/Vector3Extensions.cs +++ b/Core/Extensions/SharpDX/Vector3Extensions.cs @@ -254,7 +254,7 @@ public static bool IsUnderEnemyTurret(this Vector3 position) /// public static bool IsValid(this Vector3 vector3) { - return vector3 != Vector3.Zero; + return vector3.ToVector2().IsValid(); } /// @@ -264,7 +264,7 @@ public static bool IsValid(this Vector3 vector3) /// Is Vector3 position a wall position public static bool IsWall(this Vector3 vector3) { - return NavMesh.GetCollisionFlags(vector3).HasFlag(CollisionFlags.Wall); + return vector3.ToVector2().IsWall(); } /// @@ -300,6 +300,7 @@ public static Vector3 Normalized(this Vector3 vector3) public static float PathLength(this List path) { var distance = 0f; + for (var i = 0; i < path.Count - 1; i++) { distance += path[i].Distance(path[i + 1]); @@ -368,14 +369,7 @@ public static Vector3 Rotated(this Vector3 vector3, float angle) /// Modified Vector3. public static Vector3 SetZ(this Vector3 v, float? value = null) { - if (value == null) - { - v.Z = Game.CursorPos.Z; - } - else - { - v.Z = (float)value; - } + v.Z = value ?? Game.CursorPos.Z; return v; } @@ -404,31 +398,6 @@ public static List ToVector2(this List path) return path.Select(point => point.ToVector2()).ToList(); } - /// - /// Transforms an extended Vector3 into a Vector4. - /// - /// SharpDX Vector3 - /// Float W-axis (default = 0f) - /// The - public static Vector4 ToVector4(this Vector3 vector3, float w = 1f) - { - return new Vector4(vector3, w); - } - - /// - /// Transforms an extended Vector3 List into a Vector4 List. - /// - /// - /// The path. - /// - /// - /// Vector4 List - /// - public static List ToVector4(this List path) - { - return path.Select(point => point.ToVector4()).ToList(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Extensions/Unit.cs b/Core/Extensions/Unit.cs index c9cb402..0c61e49 100644 --- a/Core/Extensions/Unit.cs +++ b/Core/Extensions/Unit.cs @@ -20,6 +20,8 @@ namespace LeagueSharp.SDK using System; using System.Linq; + using LeagueSharp.SDK.Enumerations; + using SharpDX; /// @@ -317,23 +319,23 @@ public static SpellSlot GetSpellSlot(this Obj_AI_Hero unit, string name) public static TurretType GetTurretType(this Obj_AI_Turret turret) { var name = turret.CharData.BaseSkinName; + if (TurretsTierOne.Contains(name)) { return TurretType.TierOne; } + if (TurretsTierTwo.Contains(name)) { - return TurretType.TierOne; + return TurretType.TierTwo; } + if (TurretsTierThree.Contains(name)) { - return TurretType.TierOne; - } - if (TurretsTierFour.Contains(name)) - { - return TurretType.TierOne; + return TurretType.TierThree; } - return TurretType.Unknown; + + return TurretsTierFour.Contains(name) ? TurretType.TierFour : TurretType.Unknown; } /// @@ -344,6 +346,7 @@ public static TurretType GetTurretType(this Obj_AI_Turret turret) public static bool InFountain(this Obj_AI_Hero hero) { float fountainRange = 562500; // 750 * 750 + if (Game.MapId == GameMapId.SummonersRift) { fountainRange = 1102500; // 1050 * 1050 @@ -382,7 +385,7 @@ public static bool IsBothFacing(this Obj_AI_Base source, Obj_AI_Base target) /// Returns if the source is facing the target (boolean) public static bool IsFacing(this Obj_AI_Base source, Obj_AI_Base target) { - return (source.IsValid() && target.IsValid()) + return source.IsValid() && target.IsValid() && source.Direction.AngleBetween(target.Position - source.Position) < 90; } @@ -464,7 +467,7 @@ public static bool IsValidTarget( bool checkTeam = true, Vector3 from = default(Vector3)) { - if (unit == null || !unit.IsValid || unit.IsDead || !unit.IsVisible || !unit.IsTargetable + if (unit == null || !unit.IsValid || !unit.IsVisible || unit.IsDead || !unit.IsTargetable || unit.IsInvulnerable) { return false; @@ -482,11 +485,9 @@ public static bool IsValidTarget( return false; } - var unitPosition = @base?.ServerPosition ?? unit.Position; - - return @from.IsValid() - ? @from.DistanceSquared(unitPosition) < range * range - : GameObjects.Player.DistanceSquared(unitPosition) < range * range; + return + (@from.IsValid() ? @from : GameObjects.Player.ServerPosition).DistanceSquared( + @base?.ServerPosition ?? unit.Position) < range * range; } #endregion diff --git a/Core/GameObjects.cs b/Core/GameObjects.cs index f939fa4..2e8ec29 100644 --- a/Core/GameObjects.cs +++ b/Core/GameObjects.cs @@ -21,7 +21,8 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// A static (stack) class which contains a sort-of cached versions of the important game objects. @@ -565,6 +566,7 @@ private static void OnCreate(GameObject sender, EventArgs args) } else if (minion.Name != "WardCorpse") { + JungleList.Add(minion); switch (minion.GetJungleType()) { case JungleType.Small: @@ -577,8 +579,6 @@ private static void OnCreate(GameObject sender, EventArgs args) JungleLegendaryList.Add(minion); break; } - - JungleList.Add(minion); } return; @@ -588,6 +588,7 @@ private static void OnCreate(GameObject sender, EventArgs args) if (particle != null) { ParticleEmittersList.Add(particle); + return; } @@ -609,36 +610,6 @@ private static void OnCreate(GameObject sender, EventArgs args) return; } - var shop = sender as Obj_Shop; - if (shop != null) - { - ShopsList.Add(shop); - if (shop.IsAlly) - { - AllyShopsList.Add(shop); - } - else - { - EnemyShopsList.Add(shop); - } - - return; - } - - var spawnPoint = sender as Obj_SpawnPoint; - if (spawnPoint != null) - { - SpawnPointsList.Add(spawnPoint); - if (spawnPoint.IsAlly) - { - AllySpawnPointsList.Add(spawnPoint); - } - else - { - EnemySpawnPointsList.Add(spawnPoint); - } - } - var inhibitor = sender as Obj_BarracksDampener; if (inhibitor != null) { @@ -652,20 +623,6 @@ private static void OnCreate(GameObject sender, EventArgs args) EnemyInhibitorsList.Add(inhibitor); } } - - var nexus = sender as Obj_HQ; - if (nexus != null) - { - NexusList.Add(nexus); - if (nexus.IsAlly) - { - AllyNexus = nexus; - } - else - { - EnemyNexus = nexus; - } - } } /// @@ -684,9 +641,13 @@ private static void OnDelete(GameObject sender, EventArgs args) GameObjectsList.Remove(gameObject); } - foreach (var attackableUnitObject in AttackableUnitsList.Where(a => a.Compare(sender)).ToList()) + var attackableUnit = sender as AttackableUnit; + if (attackableUnit != null) { - AttackableUnitsList.Remove(attackableUnitObject); + foreach (var attackableUnitObject in AttackableUnitsList.Where(a => a.Compare(attackableUnit)).ToList()) + { + AttackableUnitsList.Remove(attackableUnitObject); + } } var hero = sender as Obj_AI_Hero; @@ -717,16 +678,16 @@ private static void OnDelete(GameObject sender, EventArgs args) { if (minion.GetMinionType().HasFlag(MinionTypes.Ward)) { - foreach (var ward in WardsList.Where(w => w.Compare(minion)).ToList()) + foreach (var wardObject in WardsList.Where(w => w.Compare(minion)).ToList()) { - WardsList.Remove(ward); + WardsList.Remove(wardObject); if (minion.IsEnemy) { - EnemyWardsList.Remove(ward); + EnemyWardsList.Remove(wardObject); } else { - AllyWardsList.Remove(ward); + AllyWardsList.Remove(wardObject); } } } @@ -752,6 +713,7 @@ private static void OnDelete(GameObject sender, EventArgs args) { foreach (var jungleObject in JungleList.Where(j => j.Compare(minion)).ToList()) { + JungleList.Remove(jungleObject); switch (jungleObject.GetJungleType()) { case JungleType.Small: @@ -764,8 +726,6 @@ private static void OnDelete(GameObject sender, EventArgs args) JungleLegendaryList.Remove(jungleObject); break; } - - JungleList.Remove(jungleObject); } } @@ -775,7 +735,11 @@ private static void OnDelete(GameObject sender, EventArgs args) var particle = sender as Obj_GeneralParticleEmitter; if (particle != null) { - ParticleEmittersList.Remove(particle); + foreach (var particleObject in ParticleEmittersList.Where(a => a.Compare(particle)).ToList()) + { + ParticleEmittersList.Remove(particleObject); + } + return; } @@ -800,42 +764,6 @@ private static void OnDelete(GameObject sender, EventArgs args) return; } - var shop = sender as Obj_Shop; - if (shop != null) - { - foreach (var shopObject in ShopsList.Where(s => s.Compare(shop)).ToList()) - { - ShopsList.Remove(shopObject); - if (shop.IsAlly) - { - AllyShopsList.Remove(shopObject); - } - else - { - EnemyShopsList.Remove(shopObject); - } - } - - return; - } - - var spawnPoint = sender as Obj_SpawnPoint; - if (spawnPoint != null) - { - foreach (var spawnPointObject in SpawnPointsList.Where(s => s.Compare(spawnPoint)).ToList()) - { - SpawnPointsList.Remove(spawnPointObject); - if (spawnPoint.IsAlly) - { - AllySpawnPointsList.Remove(spawnPointObject); - } - else - { - EnemySpawnPointsList.Remove(spawnPointObject); - } - } - } - var inhibitor = sender as Obj_BarracksDampener; if (inhibitor != null) { @@ -852,23 +780,6 @@ private static void OnDelete(GameObject sender, EventArgs args) } } } - - var nexus = sender as Obj_HQ; - if (nexus != null) - { - foreach (var nexusObject in NexusList.Where(n => n.Compare(nexus)).ToList()) - { - NexusList.Remove(nexusObject); - if (nexusObject.IsAlly) - { - AllyNexus = null; - } - else - { - EnemyNexus = null; - } - } - } } #endregion diff --git a/Core/Math/Collision.cs b/Core/Math/Collision.cs index 8982df6..7a0c8de 100644 --- a/Core/Math/Collision.cs +++ b/Core/Math/Collision.cs @@ -20,7 +20,10 @@ namespace LeagueSharp.SDK using System; using System.Collections.Generic; using System.Linq; - using System.Text.RegularExpressions; + + using LeagueSharp.Data.Enumerations; + using LeagueSharp.SDK.Polygons; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -31,15 +34,9 @@ public static class Collision { #region Static Fields - /// - /// Wall Cast Tick (for Yasuo) - /// - private static int wallCastT; + private static MissileClient yasuoWallLeft, yasuoWallRight; - /// - /// Yasuo's wall position in Vector2 format. - /// - private static Vector2 yasuoWallCastedPos; + private static RectanglePoly yasuoWallPoly; #endregion @@ -51,7 +48,45 @@ public static class Collision /// static Collision() { - Obj_AI_Base.OnProcessSpellCast += Obj_AI_Hero_OnProcessSpellCast; + GameObject.OnCreate += (sender, args) => + { + var missile = sender as MissileClient; + var spellCaster = missile?.SpellCaster as Obj_AI_Hero; + + if (spellCaster == null || spellCaster.ChampionName != "Yasuo" + || spellCaster.Team == GameObjects.Player.Team) + { + return; + } + + switch (missile.SData.Name) + { + case "YasuoWMovingWallMisL": + yasuoWallLeft = missile; + break; + case "YasuoWMovingWallMisR": + yasuoWallRight = missile; + break; + } + }; + GameObject.OnDelete += (sender, args) => + { + var missile = sender as MissileClient; + + if (missile == null) + { + return; + } + + if (missile.Compare(yasuoWallLeft)) + { + yasuoWallLeft = null; + } + else if (missile.Compare(yasuoWallRight)) + { + yasuoWallRight = null; + } + }; } #endregion @@ -78,44 +113,26 @@ public static List GetCollision(List positions, Prediction { if (input.CollisionObjects.HasFlag(CollisionableObjects.Minions)) { - foreach (var minion in - GameObjects.EnemyMinions.Where( - minion => - minion.IsValidTarget( - Math.Min(input.Range + input.Radius + 100, 2000), - true, - input.RangeCheckFrom))) - { - input.Unit = minion; - var minionPrediction = Movement.GetPrediction(input, false, false); - if (minionPrediction.UnitPosition.ToVector2() - .DistanceSquared(input.From.ToVector2(), position.ToVector2(), true) - <= Math.Pow(input.Radius + 15 + minion.BoundingRadius, 2)) - { - result.Add(minion); - } - } + result.AddRange( + GameObjects.EnemyMinions.Where(i => i.IsMinion() || i.IsPet()) + .Concat(GameObjects.Jungle) + .Where( + minion => + minion.IsValidTarget( + Math.Min(input.Range + input.Radius + 100, 2000), + true, + input.RangeCheckFrom) && IsHitCollision(minion, input, position, 15))); } if (input.CollisionObjects.HasFlag(CollisionableObjects.Heroes)) { - foreach (var hero in + result.AddRange( GameObjects.EnemyHeroes.Where( hero => hero.IsValidTarget( Math.Min(input.Range + input.Radius + 100, 2000), true, - input.RangeCheckFrom))) - { - input.Unit = hero; - var prediction = Movement.GetPrediction(input, false, false); - if (prediction.UnitPosition.ToVector2() - .DistanceSquared(input.From.ToVector2(), position.ToVector2(), true) - <= Math.Pow(input.Radius + 50 + hero.BoundingRadius, 2)) - { - result.Add(hero); - } - } + input.RangeCheckFrom) && IsHitCollision(hero, input, position, 50))); } if (input.CollisionObjects.HasFlag(CollisionableObjects.Walls)) @@ -123,8 +140,7 @@ public static List GetCollision(List positions, Prediction var step = position.Distance(input.From) / 20; for (var i = 0; i < 20; i++) { - var p = input.From.ToVector2().Extend(position.ToVector2(), step * i); - if (NavMesh.GetCollisionFlags(p.X, p.Y).HasFlag(CollisionFlags.Wall)) + if (input.From.ToVector2().Extend(position, step * i).IsWall()) { result.Add(GameObjects.Player); } @@ -133,43 +149,32 @@ public static List GetCollision(List positions, Prediction if (input.CollisionObjects.HasFlag(CollisionableObjects.YasuoWall)) { - if (Variables.TickCount - wallCastT > 4000) + if (yasuoWallLeft == null || yasuoWallRight == null) { continue; } - GameObject wall = null; - foreach (var gameObject in - GameObjects.AllGameObjects.Where( - gameObject => - gameObject.IsValid - && Regex.IsMatch(gameObject.Name, "_w_windwall_enemy_0.\\.troy", RegexOptions.IgnoreCase))) - { - wall = gameObject; - } + yasuoWallPoly = new RectanglePoly(yasuoWallLeft.Position, yasuoWallRight.Position, 75); - if (wall == null) + var intersections = new List(); + for (var i = 0; i < yasuoWallPoly.Points.Count; i++) { - break; - } + var inter = + yasuoWallPoly.Points[i].Intersection( + yasuoWallPoly.Points[i != yasuoWallPoly.Points.Count - 1 ? i + 1 : 0], + input.From.ToVector2(), + position.ToVector2()); - var level = wall.Name.Substring(wall.Name.Length - 6, 1); - var wallWidth = 300 + (50 * Convert.ToInt32(level)); - - var wallDirection = (wall.Position.ToVector2() - yasuoWallCastedPos).Normalized().Perpendicular(); - var wallStart = wall.Position.ToVector2() + (wallWidth / 2f * wallDirection); - var wallEnd = wallStart - (wallWidth * wallDirection); - - if (wallStart.Intersection(wallEnd, position.ToVector2(), input.From.ToVector2()).Intersects) - { - var t = Variables.TickCount - + (((wallStart.Intersection(wallEnd, position.ToVector2(), input.From.ToVector2()) - .Point.Distance(input.From) / input.Speed) + input.Delay) * 1000); - if (t < wallCastT + 4000) + if (inter.Intersects) { - result.Add(GameObjects.Player); + intersections.Add(inter.Point); } } + + if (intersections.Count > 0) + { + result.Add(GameObjects.Player); + } } } @@ -180,18 +185,22 @@ public static List GetCollision(List positions, Prediction #region Methods - /// - /// Processed Casted Spell subscribed event function - /// - /// sender. - /// Processed Spell Cast Data - private static void Obj_AI_Hero_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) + private static bool IsHitCollision(Obj_AI_Base collision, ICloneable input, Vector3 pos, float extraRadius) { - if (sender.IsValid && sender.Team != GameObjects.Player.Team && args.SData.Name == "YasuoWMovingWall") + var inputSub = input.Clone() as PredictionInput; + + if (inputSub == null) { - wallCastT = Variables.TickCount; - yasuoWallCastedPos = sender.ServerPosition.ToVector2(); + return false; } + + inputSub.Unit = collision; + var unitRadius = inputSub.Unit.BoundingRadius; + var predPos = Movement.GetPrediction(inputSub, false, false).UnitPosition.ToVector2(); + return predPos.Distance(inputSub.From) < inputSub.Radius + unitRadius / 2 + || predPos.Distance(pos) < inputSub.Radius + unitRadius / 2 + || predPos.DistanceSquared(inputSub.From.ToVector2(), pos.ToVector2(), true) + <= Math.Pow(inputSub.Radius + unitRadius + extraRadius, 2); } #endregion diff --git a/Core/Math/ConvexHull.cs b/Core/Math/ConvexHull.cs index 9ad91a9..23d30da 100644 --- a/Core/Math/ConvexHull.cs +++ b/Core/Math/ConvexHull.cs @@ -188,7 +188,7 @@ public static List MakeConvexHull(List points) // Start wrapping up the other points. float sweepAngle = 0; - for (; ;) + for (;;) { // If all of the points are on the hull, we're done. if (points.Count == 0) @@ -298,11 +298,11 @@ private static float AngleValue(float x1, float y1, float x2, float y2) /// Skip certain point 3 /// The private static bool CircleEnclosesPoints( - Vector2 center, - float radius2, - IEnumerable points, - int skip1, - int skip2, + Vector2 center, + float radius2, + IEnumerable points, + int skip1, + int skip2, int skip3) { return (from point in points.Where((t, i) => (i != skip1) && (i != skip2) && (i != skip3)) @@ -334,7 +334,8 @@ private static void FindCircle(Vector2 a, Vector2 b, Vector2 c, out Vector2 cent var dx2 = -(c.Y - b.Y); // See where the lines intersect. - var cx = ((y1 * dx1 * dx2) + (x2 * dx1 * dy2) - (x1 * dy1 * dx2) - (y2 * dx1 * dx2)) / ((dx1 * dy2) - (dy1 * dx2)); + var cx = ((y1 * dx1 * dx2) + (x2 * dx1 * dy2) - (x1 * dy1 * dx2) - (y2 * dx1 * dx2)) + / ((dx1 * dy2) - (dy1 * dx2)); var cy = ((cx - x1) * dy1 / dx1) + y1; center = new Vector2(cx, cy); @@ -414,10 +415,10 @@ private static RectangleF GetMinMaxBox(IEnumerable points) /// The list. /// private static MinMaxCornersInfo GetMinMaxCorners( - IEnumerable points, - Vector2 upperLeft, - Vector2 upperRight, - Vector2 lowerLeft, + IEnumerable points, + Vector2 upperLeft, + Vector2 upperRight, + Vector2 lowerLeft, Vector2 lowerRight) { // Search the other points. diff --git a/Core/Math/Geometry.cs b/Core/Math/Geometry.cs index 6f21cc8..e1a861c 100644 --- a/Core/Math/Geometry.cs +++ b/Core/Math/Geometry.cs @@ -17,6 +17,8 @@ namespace LeagueSharp.SDK { + using LeagueSharp.SDK.Enumerations; + using SharpDX; using SharpDX.Direct3D9; @@ -36,9 +38,9 @@ public static class Geometry /// Centered Flags /// Vector2 center position of the rendering object on the rectangle. public static Vector2 GetCenter( - this SharpDX.Rectangle rectangle, + this Rectangle rectangle, Sprite sprite, - SharpDX.Rectangle dimensions, + Rectangle dimensions, CenteredFlags flags) { var x = 0; @@ -81,11 +83,7 @@ public static Vector2 GetCenter( /// The Text /// Centered Flags /// Returns the center position of the text on the rectangle. - public static Vector2 GetCenteredText( - this SharpDX.Rectangle rectangle, - Sprite sprite, - string text, - CenteredFlags flags) + public static Vector2 GetCenteredText(this Rectangle rectangle, Sprite sprite, string text, CenteredFlags flags) { return rectangle.GetCenter(sprite, Constants.LeagueSharpFont.MeasureText(sprite, text, 0), flags); } @@ -100,7 +98,7 @@ public static Vector2 GetCenteredText( /// Centered Flags /// Returns the center position of the text on the rectangle. public static Vector2 GetCenteredText( - this SharpDX.Rectangle rectangle, + this Rectangle rectangle, Sprite sprite, Font font, string text, diff --git a/Core/Math/Polygons/ArcPoly.cs b/Core/Math/Polygons/ArcPoly.cs index 16eab31..befbcd8 100644 --- a/Core/Math/Polygons/ArcPoly.cs +++ b/Core/Math/Polygons/ArcPoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using System; diff --git a/Core/Math/Polygons/CirclePoly.cs b/Core/Math/Polygons/CirclePoly.cs index bffc1f4..069250a 100644 --- a/Core/Math/Polygons/CirclePoly.cs +++ b/Core/Math/Polygons/CirclePoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using System; diff --git a/Core/Math/Polygons/LinePoly.cs b/Core/Math/Polygons/LinePoly.cs index 19e1e1f..2bbaefd 100644 --- a/Core/Math/Polygons/LinePoly.cs +++ b/Core/Math/Polygons/LinePoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using SharpDX; diff --git a/Core/Math/Polygons/Polygon.cs b/Core/Math/Polygons/Polygon.cs index a44ac1a..d8bb42d 100644 --- a/Core/Math/Polygons/Polygon.cs +++ b/Core/Math/Polygons/Polygon.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using System.Collections.Generic; using System.Linq; @@ -128,7 +128,7 @@ public bool IsInside(GameObject gameObject) public bool IsOutside(Vector2 point) { var p = new IntPoint(point.X, point.Y); - return Clipper.Clipper.PointInPolygon(p, this.ToClipperPath()) != 1; + return Clipper.PointInPolygon(p, this.ToClipperPath()) != 1; } /// diff --git a/Core/Math/Polygons/RectanglePoly.cs b/Core/Math/Polygons/RectanglePoly.cs index 182bf94..a64f8dd 100644 --- a/Core/Math/Polygons/RectanglePoly.cs +++ b/Core/Math/Polygons/RectanglePoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using SharpDX; diff --git a/Core/Math/Polygons/RingPoly.cs b/Core/Math/Polygons/RingPoly.cs index ffa6ce2..cce2a65 100644 --- a/Core/Math/Polygons/RingPoly.cs +++ b/Core/Math/Polygons/RingPoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using System; @@ -92,14 +92,14 @@ public RingPoly(Vector2 center, float width, float outerRadius, int quality = 20 public Vector2 Center { get; set; } /// - /// Gets or sets the ring width + /// Gets or sets the outer radius. /// - public float Width { get; set; } + public float OuterRadius { get; set; } /// - /// Gets or sets the outer radius. + /// Gets or sets the ring width /// - public float OuterRadius { get; set; } + public float Width { get; set; } #endregion diff --git a/Core/Math/Polygons/SectorPoly.cs b/Core/Math/Polygons/SectorPoly.cs index 49a4835..7b678b2 100644 --- a/Core/Math/Polygons/SectorPoly.cs +++ b/Core/Math/Polygons/SectorPoly.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK +namespace LeagueSharp.SDK.Polygons { using System; diff --git a/Core/Math/Prediction/Cluster.cs b/Core/Math/Prediction/Cluster.cs index 50bc402..e030fca 100644 --- a/Core/Math/Prediction/Cluster.cs +++ b/Core/Math/Prediction/Cluster.cs @@ -20,6 +20,8 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; + using LeagueSharp.SDK.Enumerations; + using SharpDX; /// @@ -67,15 +69,23 @@ public static PredictionOutput GetAoEPrediction(PredictionInput input) internal static List GetPossibleTargets(PredictionInput input) { var result = new List(); - var originalUnit = input.Unit; + foreach (var enemy in GameObjects.EnemyHeroes.Where( h => - h.NetworkId != originalUnit.NetworkId + !h.Compare(input.Unit) && h.IsValidTarget(input.Range + 200 + input.RealRadius, true, input.RangeCheckFrom))) { - input.Unit = enemy; - var prediction = Movement.GetPrediction(input, false, false); + var inputs = input.Clone() as PredictionInput; + + if (inputs == null) + { + continue; + } + + inputs.Unit = enemy; + var prediction = Movement.GetPrediction(inputs, false, true); + if (prediction.Hitchance >= HitChance.High) { result.Add(new PossibleTarget { Position = prediction.UnitPosition.ToVector2(), Unit = enemy }); @@ -143,6 +153,7 @@ public static PredictionOutput GetCirclePrediction(PredictionInput input) for (var i = 1; i < posibleTargets.Count; i++) { var distance = posibleTargets[i].Position.DistanceSquared(posibleTargets[0].Position); + if (distance > maxdist || maxdist.CompareTo(-1) == 0) { maxdistindex = i; @@ -209,6 +220,7 @@ public static PredictionOutput GetConePrediction(PredictionInput input) if (i != j) { var p = (posibleTargets[i].Position + posibleTargets[j].Position) * 0.5f; + if (!candidates.Contains(p)) { candidates.Add(p); @@ -224,6 +236,7 @@ public static PredictionOutput GetConePrediction(PredictionInput input) foreach (var candidate in candidates) { var hits = GetHits(candidate, input.Range, input.Radius, positionsList); + if (hits > bestCandidateHits) { bestCandidate = candidate; @@ -298,6 +311,7 @@ public static PredictionOutput GetLinePrediction(PredictionInput input) Unit = input.Unit } }; + if (mainTargetPrediction.Hitchance >= HitChance.Medium) { // Add the posible targets in range: @@ -331,6 +345,7 @@ public static PredictionOutput GetLinePrediction(PredictionInput input) { var hits = GetHits(input.From.ToVector2(), candidate, input.Radius, positionsList).ToList(); var hitsCount = hits.Count; + if (hitsCount >= bestCandidateHits) { bestCandidateHits = hitsCount; @@ -356,6 +371,7 @@ public static PredictionOutput GetLinePrediction(PredictionInput input) var proj2 = positionsList[j].ProjectOn(startP, endP); var dist = bestCandidateHitPoints[i].DistanceSquared(proj1.LinePoint) + bestCandidateHitPoints[j].DistanceSquared(proj2.LinePoint); + if (dist >= maxDistance && (proj1.LinePoint - positionsList[i]).AngleBetween( proj2.LinePoint - positionsList[j]) > 90) diff --git a/Core/Math/Prediction/Health.cs b/Core/Math/Prediction/Health.cs index 71151de..983cd36 100644 --- a/Core/Math/Prediction/Health.cs +++ b/Core/Math/Prediction/Health.cs @@ -21,8 +21,8 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Health Prediction class for prediction of health of units. @@ -160,17 +160,20 @@ public static int TurretAggroStartTick(Obj_AI_Minion minion) private static float GetPredictionDefault(Obj_AI_Base unit, int time, int delay = 70) { var predictedDamage = 0f; + foreach (var attack in ActiveAttacks.Values.Where(i => i.Target.Compare(unit) && !i.Processed)) { var attackDamage = 0f; + if (attack.Source.IsValidTarget(float.MaxValue, false) && attack.Target.IsValidTarget()) { var landTime = attack.StartTick + attack.Delay + 1000 * (attack.Source.IsMelee ? 0 - : Math.Max(0, unit.Distance(attack.Source) - attack.Source.BoundingRadius) + : Math.Max(unit.Distance(attack.Source) - attack.Source.BoundingRadius, 0) / attack.ProjectileSpeed) + delay; + if (landTime < Variables.TickCount + time) { attackDamage = attack.Damage; @@ -198,21 +201,24 @@ private static float GetPredictionDefault(Obj_AI_Base unit, int time, int delay private static float GetPredictionSimulated(Obj_AI_Base unit, int time) { var predictedDamage = 0f; + foreach (var attack in ActiveAttacks.Values.Where(i => i.Target.Compare(unit))) { var n = 0; + if (Variables.TickCount - 100 <= attack.StartTick + attack.AnimationTime && attack.Source.IsValidTarget(float.MaxValue, false) && attack.Target.IsValidTarget()) { var fromT = attack.StartTick; var toT = Variables.TickCount + time; + while (fromT < toT) { if (fromT >= Variables.TickCount && fromT + attack.Delay / 1000 + (attack.Source.IsMelee ? 0 - : Math.Max(0, unit.Distance(attack.Source) - attack.Source.BoundingRadius) + : Math.Max(unit.Distance(attack.Source) - attack.Source.BoundingRadius, 0) / attack.ProjectileSpeed) < toT) { n++; @@ -245,14 +251,17 @@ private static void OnGameObjectDelete(GameObject sender, EventArgs args) } var aiBase = sender as Obj_AI_Base; + if (aiBase != null) { var objNetworkId = aiBase.NetworkId; + if (ActiveAttacks.ContainsKey(objNetworkId)) { ActiveAttacks.Remove(objNetworkId); return; } + foreach (var activeAttack in ActiveAttacks.Values.Where(i => i.Target.Compare(aiBase))) { ActiveAttacks.Remove(activeAttack.Source.NetworkId); @@ -261,9 +270,11 @@ private static void OnGameObjectDelete(GameObject sender, EventArgs args) } var missile = sender as MissileClient; + if (missile?.SpellCaster != null) { var casterNetworkId = missile.SpellCaster.NetworkId; + if (ActiveAttacks.ContainsKey(casterNetworkId)) { ActiveAttacks[casterNetworkId].Processed = true; @@ -306,6 +317,7 @@ private static void OnObjAiBaseDoCast(Obj_AI_Base sender, GameObjectProcessSpell if (sender.IsValid && sender.IsMelee) { var casterNetworkId = sender.NetworkId; + if (ActiveAttacks.ContainsKey(casterNetworkId)) { ActiveAttacks[casterNetworkId].Processed = true; @@ -362,6 +374,7 @@ private static void OnSpellbookStopCast(Spellbook sender, SpellbookStopCastEvent if (sender.Owner.IsValid && args.StopAnimation && args.DestroyMissile) { var casterNetworkId = sender.Owner.NetworkId; + if (ActiveAttacks.ContainsKey(casterNetworkId)) { ActiveAttacks.Remove(casterNetworkId); diff --git a/Core/Math/Prediction/Movement.cs b/Core/Math/Prediction/Movement.cs index de41f75..1cea7c1 100644 --- a/Core/Math/Prediction/Movement.cs +++ b/Core/Math/Prediction/Movement.cs @@ -21,7 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data.Enumerations; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -93,33 +95,6 @@ public static PredictionOutput GetPrediction(PredictionInput input) #region Methods - /// - /// Calculates the position to cast a spell according to unit movement. - /// - /// PredictionInput type - /// Additional Speed (Multiplicative) - /// The - internal static PredictionOutput GetAdvancedPrediction(PredictionInput input, float additionalSpeed = 0) - { - var speed = Math.Abs(additionalSpeed) < float.Epsilon ? input.Speed : input.Speed * additionalSpeed; - - if (Math.Abs(speed - int.MaxValue) < float.Epsilon) - { - speed = 90000; - } - - var unit = input.Unit; - var position = PositionAfter(unit, 1, unit.MoveSpeed - 100); - var prediction = position + (speed * (input.Delay / 1000)); - - return new PredictionOutput() - { - UnitPosition = new Vector3(position.X, position.Y, unit.ServerPosition.Z), - CastPosition = new Vector3(prediction.X, prediction.Y, unit.ServerPosition.Z), - Hitchance = HitChance.High - }; - } - /// /// Returns Dashing Prediction /// @@ -131,17 +106,21 @@ internal static PredictionOutput GetDashingPrediction(PredictionInput input) { var dashData = input.Unit.GetDashInfo(); var result = new PredictionOutput { Input = input }; - input.Delay += 0.1f; // Normal dashes. if (!dashData.IsBlink) { + var endP = dashData.EndPos.ToVector3(); + // Mid air: var dashPred = GetPositionOnPath( input, - new List { input.Unit.ServerPosition.ToVector2(), dashData.Path.Last() }, + new List { input.Unit.ServerPosition.ToVector2(), endP.ToVector2() }, dashData.Speed); - if (dashPred.Hitchance >= HitChance.High) + + if (dashPred.Hitchance >= HitChance.High + && dashPred.UnitPosition.ToVector2() + .Distance(input.Unit.Position.ToVector2(), endP.ToVector2(), true) < 200) { dashPred.CastPosition = dashPred.UnitPosition; dashPred.Hitchance = HitChance.Dashing; @@ -151,20 +130,23 @@ internal static PredictionOutput GetDashingPrediction(PredictionInput input) // At the end of the dash: if (dashData.Path.PathLength() > 200) { - var endP = dashData.Path.Last(); - var timeToPoint = input.Delay + (input.From.Distance(endP) / input.Speed); + var timeToPoint = input.Delay / 2f + + (Math.Abs(input.Speed - float.MaxValue) > float.Epsilon + ? input.From.Distance(endP) / input.Speed + : 0) - 0.25f; + if (timeToPoint - <= (input.Unit.Distance(endP) / dashData.Speed) + (input.RealRadius / input.Unit.MoveSpeed)) + <= input.Unit.Distance(endP) / dashData.Speed + input.RealRadius / input.Unit.MoveSpeed) { return new PredictionOutput { - CastPosition = endP.ToVector3(), UnitPosition = endP.ToVector3(), + Input = input, CastPosition = endP, UnitPosition = endP, Hitchance = HitChance.Dashing }; } } - result.CastPosition = dashData.Path.Last().ToVector3(); + result.CastPosition = endP; result.UnitPosition = result.CastPosition; // Figure out where the unit is going. @@ -183,22 +165,23 @@ internal static PredictionOutput GetDashingPrediction(PredictionInput input) /// output internal static PredictionOutput GetImmobilePrediction(PredictionInput input, double remainingImmobileT) { - var timeToReachTargetPosition = input.Delay + (input.Unit.Distance(input.From) / input.Speed); - - if (timeToReachTargetPosition <= remainingImmobileT + (input.RealRadius / input.Unit.MoveSpeed)) + var result = new PredictionOutput + { + Input = input, CastPosition = input.Unit.ServerPosition, + UnitPosition = input.Unit.ServerPosition, Hitchance = HitChance.High + }; + var timeToReachTargetPosition = input.Delay + + (Math.Abs(input.Speed - float.MaxValue) > float.Epsilon + ? input.Unit.Distance(input.From) / input.Speed + : 0); + + if (timeToReachTargetPosition <= remainingImmobileT + input.RealRadius / input.Unit.MoveSpeed) { - return new PredictionOutput - { - CastPosition = input.Unit.ServerPosition, UnitPosition = input.Unit.Position, - Hitchance = HitChance.Immobile - }; + result.UnitPosition = input.Unit.Position; + result.Hitchance = HitChance.Immobile; } - return new PredictionOutput - { - Input = input, CastPosition = input.Unit.ServerPosition, - UnitPosition = input.Unit.ServerPosition, Hitchance = HitChance.High - }; + return result; } /// @@ -212,24 +195,24 @@ internal static PredictionOutput GetImmobilePrediction(PredictionInput input, do /// output internal static PredictionOutput GetPositionOnPath(PredictionInput input, List path, float speed = -1) { - speed = (Math.Abs(speed - (-1)) < float.Epsilon) ? input.Unit.MoveSpeed : speed; + speed = Math.Abs(speed - -1) < float.Epsilon ? input.Unit.MoveSpeed : speed; - if (path.Count <= 1) + if (path.Count <= 1 || input.Unit.IsWindingUp) { return new PredictionOutput { Input = input, UnitPosition = input.Unit.ServerPosition, - CastPosition = input.Unit.ServerPosition, Hitchance = HitChance.VeryHigh + CastPosition = input.Unit.ServerPosition, Hitchance = HitChance.High }; } var pLength = path.PathLength(); + var dist = input.Delay * speed - input.RealRadius; // Skillshots with only a delay - if (pLength >= (input.Delay * speed) - input.RealRadius - && Math.Abs(input.Speed - float.MaxValue) < float.Epsilon) + if (pLength >= dist && Math.Abs(input.Speed - float.MaxValue) < float.Epsilon) { - var tDistance = (input.Delay * speed) - input.RealRadius; + var tDistance = dist; for (var i = 0; i < path.Count - 1; i++) { @@ -240,21 +223,17 @@ internal static PredictionOutput GetPositionOnPath(PredictionInput input, List= tDistance) { var direction = (b - a).Normalized(); - - var cp = a + (direction * tDistance); + var cp = a + direction * tDistance; var p = a - + (direction - * ((i == path.Count - 2) - ? Math.Min(tDistance + input.RealRadius, d) - : (tDistance + input.RealRadius))); + + direction + * (i == path.Count - 2 + ? Math.Min(tDistance + input.RealRadius, d) + : tDistance + input.RealRadius); return new PredictionOutput { Input = input, CastPosition = cp.ToVector3(), UnitPosition = p.ToVector3(), - Hitchance = - GamePath.PathTracker.GetCurrentPath(input.Unit).Time < 0.1d - ? HitChance.VeryHigh - : HitChance.High + Hitchance = HitChance.High }; } @@ -263,29 +242,43 @@ internal static PredictionOutput GetPositionOnPath(PredictionInput input, List= (input.Delay * speed) - input.RealRadius - && Math.Abs(input.Speed - float.MaxValue) > float.Epsilon) + if (pLength >= dist && Math.Abs(input.Speed - float.MaxValue) > float.Epsilon) { - path = path.CutPath(Math.Max(0, (input.Delay * speed) - input.RealRadius)); + var tDistance = dist; + + if ((input.Type == SkillshotType.SkillshotLine || input.Type == SkillshotType.SkillshotCone) + && input.Unit.DistanceSquared(input.From) < 200 * 200) + { + tDistance = dist - input.RealRadius; + } + + path = path.CutPath(tDistance); var tT = 0f; + for (var i = 0; i < path.Count - 1; i++) { var a = path[i]; var b = path[i + 1]; var tB = a.Distance(b) / speed; var direction = (b - a).Normalized(); - a = a - (speed * tT * direction); + a = a - speed * tT * direction; var sol = a.VectorMovementCollision(b, speed, input.From.ToVector2(), input.Speed, tT); var t = (float)sol[0]; var pos = (Vector2)sol[1]; if (pos.IsValid() && t >= tT && t <= tT + tB) { - var p = pos + (input.RealRadius * direction); + if (pos.DistanceSquared(b) < 20) + { + break; + } + + var p = pos + input.RealRadius * direction; if (input.Type == SkillshotType.SkillshotLine) { var alpha = (input.From.ToVector2() - p).AngleBetween(a - b); + if (alpha > 30 && alpha < 180 - 30) { var beta = (float)Math.Asin(input.RealRadius / p.Distance(input.From)); @@ -299,10 +292,7 @@ internal static PredictionOutput GetPositionOnPath(PredictionInput input, List @@ -331,8 +318,6 @@ internal static PredictionOutput GetPositionOnPath(PredictionInput input, List internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, bool checkCollision) { - PredictionOutput result = null; - if (!input.Unit.IsValidTarget(float.MaxValue, false)) { return new PredictionOutput(); @@ -341,7 +326,7 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b if (ft) { // Increase the delay due to the latency and server tick: - input.Delay += (Game.Ping / 2000f) + 0.06f; + input.Delay += Game.Ping / 2000f + 0.06f; if (input.AoE) { @@ -356,6 +341,8 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b return new PredictionOutput { Input = input }; } + PredictionOutput result = null; + // Unit is dashing. if (input.Unit.IsDashing()) { @@ -365,6 +352,7 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b { // Unit is immobile. var remainingImmobileT = UnitIsImmobileUntil(input.Unit); + if (remainingImmobileT >= 0d) { result = GetImmobilePrediction(input, remainingImmobileT); @@ -374,7 +362,7 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b // Normal prediction if (result == null) { - result = GetAdvancedPrediction(input); + result = GetStandardPrediction(input); } // Check if the unit position is in range @@ -382,7 +370,7 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b { if (result.Hitchance >= HitChance.High && input.RangeCheckFrom.DistanceSquared(input.Unit.Position) - > Math.Pow(input.Range + (input.RealRadius * 3 / 4), 2)) + > Math.Pow(input.Range + input.RealRadius * 3 / 4, 2)) { result.Hitchance = HitChance.Medium; } @@ -393,29 +381,34 @@ internal static PredictionOutput GetPrediction(PredictionInput input, bool ft, b result.Hitchance = HitChance.OutOfRange; } - if (input.RangeCheckFrom.DistanceSquared(result.CastPosition) > Math.Pow(input.Range, 2)) + if (input.RangeCheckFrom.DistanceSquared(result.CastPosition) > Math.Pow(input.Range, 2) + && result.Hitchance != HitChance.OutOfRange) { - if (result.Hitchance != HitChance.OutOfRange) - { - result.CastPosition = input.RangeCheckFrom - + (input.Range - * (result.UnitPosition - input.RangeCheckFrom).Normalized().SetZ()); - } - else - { - result.Hitchance = HitChance.OutOfRange; - } + result.CastPosition = input.RangeCheckFrom + + input.Range + * (result.UnitPosition - input.RangeCheckFrom).ToVector2() + .Normalized() + .ToVector3(); } } + // Calc hitchance again + if (result.Hitchance == HitChance.High) + { + result.Hitchance = GetHitChance(input); + } + // Check for collision - if (checkCollision && input.Collision) + if (checkCollision && input.Collision && Math.Abs(input.Speed - float.MaxValue) > float.Epsilon) { - var positions = new List { result.UnitPosition, result.CastPosition, input.Unit.Position }; - var originalUnit = input.Unit; + var positions = new List { result.UnitPosition, input.Unit.Position }; result.CollisionObjects = Collision.GetCollision(positions, input); - result.CollisionObjects.RemoveAll(x => x.NetworkId == originalUnit.NetworkId); - result.Hitchance = result.CollisionObjects.Count > 0 ? HitChance.Collision : result.Hitchance; + result.CollisionObjects.RemoveAll(x => x.Compare(input.Unit)); + + if (result.CollisionObjects.Count > 0) + { + result.Hitchance = HitChance.Collision; + } } return result; @@ -438,64 +431,252 @@ internal static PredictionOutput GetStandardPrediction(PredictionInput input) speed /= 1.5f; } - var result = GetPositionOnPath(input, input.Unit.GetWaypoints(), speed); + return GetPositionOnPath(input, input.Unit.GetWaypoints(), speed); + } + + /// + /// Returns if the unit is immobile and immobile time. + /// + /// The unit + /// Immobile Time left + internal static double UnitIsImmobileUntil(Obj_AI_Base unit) + { + var result = + unit.Buffs.Where( + buff => + buff.IsValid + && (buff.Type == BuffType.Knockup || buff.Type == BuffType.Snare || buff.Type == BuffType.Stun + || buff.Type == BuffType.Suppression)) + .Aggregate(0f, (current, buff) => Math.Max(buff.EndTime, current)); + return result - Game.Time; + } - if (result.Hitchance >= HitChance.High && input.Unit is Obj_AI_Hero) + private static double GetAngle(Vector2 from, Vector2 to, Vector2 wayPoint) + { + if (to == wayPoint) { + return 60; } - return result; + var a = Math.Pow(wayPoint.X - from.X, 2) + Math.Pow(wayPoint.Y - from.Y, 2); + var b = Math.Pow(from.X - to.X, 2) + Math.Pow(from.Y - to.Y, 2); + var c = Math.Pow(wayPoint.X - to.X, 2) + Math.Pow(wayPoint.Y - to.Y, 2); + return Math.Cos((a + b - c) / (2 * Math.Sqrt(a) * Math.Sqrt(b))) * 180 / Math.PI; } - /// - /// Calculates the unit position after "t" - /// - /// Unit to track - /// Track time - /// Speed of unit - /// The of the after position - internal static Vector2 PositionAfter(Obj_AI_Base unit, float t, float speed = float.MaxValue) + private static HitChance GetHitChance(PredictionInput input) { - var distance = t * speed; - var path = unit.GetWaypoints(); + var hero = input.Unit as Obj_AI_Hero; - for (var i = 0; i < path.Count - 1; i++) + if (hero == null || !hero.IsValid || input.Radius <= 1f) { - var a = path[i]; - var b = path[i + 1]; - var d = a.Distance(b); + return HitChance.VeryHigh; + } + + if (hero.IsCastingInterruptableSpell(true) || hero.IsRecalling() + || (UnitTracker.GetLastStopTick(hero) < 0.1d && hero.IsRooted)) + { + return HitChance.VeryHigh; + } + + var wayPoints = hero.GetWaypoints(); + var lastWaypoint = wayPoints.Last(); + var heroPos = hero.ServerPosition.ToVector2(); + var distHeroToWaypoint = heroPos.Distance(lastWaypoint); + var distHeroToFrom = heroPos.Distance(input.From); + var distFromToWaypoint = input.From.Distance(lastWaypoint); + var angle = GetAngle(input.From.ToVector2(), heroPos, lastWaypoint); + var delay = input.Delay + + (Math.Abs(input.Speed - float.MaxValue) > float.Epsilon ? distHeroToFrom / input.Speed : 0); + var moveArea = hero.MoveSpeed * delay; + var fixRange = moveArea * 0.35f; + var minPath = 800 + moveArea; + var moveAngle = 32d; + + if (input.Type == SkillshotType.SkillshotCircle) + { + fixRange -= input.Radius / 2; + } + + if (distFromToWaypoint <= distHeroToFrom && distHeroToFrom > input.Range - fixRange) + { + return HitChance.Medium; + } + + var wallPoints = new List(); - if (d < distance) + for (var i = 1; i <= 15; i++) + { + var circleAngle = i * 2 * Math.PI / 15; + var point = new Vector2( + heroPos.X + 450 * (float)Math.Cos(circleAngle), + heroPos.Y + 450 * (float)Math.Sin(circleAngle)); + + if (point.IsWall()) { - distance -= d; + wallPoints.Add(point); } - else + } + + if (wallPoints.Count > 2) + { + var isOutWall = !wallPoints.Any(i => heroPos.Distance(i) > lastWaypoint.Distance(i)); + + if (isOutWall) { - return a + (distance * (b - a).Normalized()); + return HitChance.VeryHigh; } } - return path[path.Count - 1]; + if (wayPoints.Count == 1) + { + return UnitTracker.GetLastStopTick(hero) < 0.6d ? HitChance.High : HitChance.VeryHigh; + } + + if (UnitTracker.IsSpamSamePos(hero)) + { + return HitChance.VeryHigh; + } + + if (distHeroToFrom < 250 || hero.MoveSpeed < 250 || distFromToWaypoint < 250) + { + return HitChance.VeryHigh; + } + + if (distHeroToWaypoint > minPath) + { + return HitChance.VeryHigh; + } + + if (hero.HealthPercent < 20 || GameObjects.Player.HealthPercent < 20) + { + return HitChance.VeryHigh; + } + + if (angle < moveAngle && GamePath.PathTracker.GetCurrentPath(hero).Time < 0.1d) + { + return HitChance.VeryHigh; + } + + if (input.Type == SkillshotType.SkillshotCircle && GamePath.PathTracker.GetCurrentPath(hero).Time < 0.1d + && distHeroToWaypoint > fixRange) + { + return HitChance.VeryHigh; + } + + return HitChance.Medium; } - /// - /// Returns if the unit is immobile and immobile time. - /// - /// The unit - /// Immobile Time left - internal static double UnitIsImmobileUntil(Obj_AI_Base unit) + #endregion + } + + internal class UnitTracker + { + #region Static Fields + + private static readonly Dictionary DictData = new Dictionary(); + + #endregion + + #region Constructors and Destructors + + static UnitTracker() { - var result = - unit.Buffs.Where( - buff => - buff.IsActive && Game.Time <= buff.EndTime - && (buff.Type == BuffType.Charm || buff.Type == BuffType.Knockup || buff.Type == BuffType.Stun - || buff.Type == BuffType.Suppression || buff.Type == BuffType.Snare)) - .Aggregate(0d, (current, buff) => Math.Max(current, buff.EndTime)); - return result - Game.Time; + Obj_AI_Base.OnNewPath += OnNewPath; } #endregion + + #region Methods + + internal static double GetLastStopTick(Obj_AI_Hero hero) + { + UnitTrackerEntry data; + return DictData.TryGetValue(hero.NetworkId, out data) ? (Variables.TickCount - data.StopTick) / 1000d : 1; + } + + internal static bool IsSpamSamePos(Obj_AI_Hero hero) + { + UnitTrackerEntry data; + + if (!DictData.TryGetValue(hero.NetworkId, out data)) + { + return false; + } + + if (data.Path.Count < 3) + { + return false; + } + + if (data.Path[2].Tick - data.Path[1].Tick < 200 && Variables.TickCount - data.Path[2].Tick < 100) + { + var posHero = hero.Position; + var posPath1 = data.Path[1].Position; + var posPath2 = data.Path[2].Position; + + var a = Math.Pow(posPath2.X - posHero.X, 2) + Math.Pow(posPath2.Y - posHero.Y, 2); + var b = Math.Pow(posHero.X - posPath1.X, 2) + Math.Pow(posHero.Y - posPath1.Y, 2); + var c = Math.Pow(posPath2.X - posPath1.X, 2) + Math.Pow(posPath2.Y - posPath1.Y, 2); + + return data.Path[1].Position.Distance(data.Path[2].Position) < 150 + || Math.Cos((a + b - c) / (2 * Math.Sqrt(a) * Math.Sqrt(b))) * 180 / Math.PI < 31; + } + + return false; + } + + private static void OnNewPath(Obj_AI_Base sender, GameObjectNewPathEventArgs args) + { + if (!(sender is Obj_AI_Hero)) + { + return; + } + + if (!DictData.ContainsKey(sender.NetworkId)) + { + DictData.Add(sender.NetworkId, new UnitTrackerEntry()); + } + + if (args.Path.Length == 1) + { + DictData[sender.NetworkId].StopTick = Variables.TickCount; + } + else + { + DictData[sender.NetworkId].Path.Add( + new StoredPath { Position = args.Path.Last().ToVector2(), Tick = Variables.TickCount }); + } + + if (DictData[sender.NetworkId].Path.Count > 3) + { + DictData[sender.NetworkId].Path.RemoveAt(0); + } + } + + #endregion + + private class StoredPath + { + #region Properties + + internal Vector2 Position { get; set; } + + internal float Tick { get; set; } + + #endregion + } + + private class UnitTrackerEntry + { + #region Properties + + internal List Path { get; } = new List(); + + internal int StopTick { get; set; } + + #endregion + } } #region Prediction Input/Output @@ -505,14 +686,14 @@ internal static double UnitIsImmobileUntil(Obj_AI_Base unit) /// prediction for both a unit position and a skill-shot casting area which is then returned as a /// /// - public class PredictionInput + public class PredictionInput : ICloneable { #region Fields /// /// From source location on a 3D-Space. /// - private Vector3 @from; + private Vector3 from; /// /// Range check from location on a 3D-Space. @@ -553,12 +734,12 @@ public Vector3 From { get { - return this.@from.IsValid() ? this.@from : ObjectManager.Player.ServerPosition; + return this.from.IsValid() ? this.from : ObjectManager.Player.ServerPosition; } set { - this.@from = value; + this.from = value; } } @@ -618,6 +799,21 @@ public Vector3 RangeCheckFrom internal float RealRadius => this.UseBoundingRadius ? this.Radius + this.Unit.BoundingRadius : this.Radius; #endregion + + #region Public Methods and Operators + + /// + /// Creates a new object that is a copy of the current instance. + /// + /// + /// A new object that is a copy of this instance. + /// + public object Clone() + { + return this.MemberwiseClone(); + } + + #endregion } /// @@ -666,7 +862,6 @@ public Vector3 CastPosition { return this.castPosition.IsValid() ? this.castPosition.SetZ() : this.Input.Unit.ServerPosition; } - set { this.castPosition = value; @@ -683,6 +878,11 @@ public Vector3 CastPosition /// public HitChance Hitchance { get; set; } = HitChance.Impossible; + /// + /// Gets or sets the input. + /// + public PredictionInput Input { get; set; } + /// /// Gets or sets where the unit is going to be when the skill-shot reaches his position. /// @@ -692,7 +892,6 @@ public Vector3 UnitPosition { return this.unitPosition.IsValid() ? this.unitPosition.SetZ() : this.Input.Unit.ServerPosition; } - set { this.unitPosition = value; @@ -700,15 +899,6 @@ public Vector3 UnitPosition } #endregion - - #region Properties - - /// - /// Gets or sets the input. - /// - internal PredictionInput Input { get; set; } - - #endregion } #endregion diff --git a/Core/Signals/Signal.cs b/Core/Signals/Signal.cs index b2b3067..eec4522 100644 --- a/Core/Signals/Signal.cs +++ b/Core/Signals/Signal.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Signals +namespace LeagueSharp.SDK.Signals { using System; using System.Collections.Generic; @@ -44,9 +44,9 @@ public class Signal : EventArgs /// The properties /// private Signal( - OnRaisedDelegate signalRaised, - SignalWaverDelegate signalWaver, - DateTimeOffset expiration, + OnRaisedDelegate signalRaised, + SignalWaverDelegate signalWaver, + DateTimeOffset expiration, IDictionary properties) { if (signalRaised != null) @@ -198,9 +198,9 @@ private Signal( /// A dictionary that contents will be dumped into /// The public static Signal Create( - OnRaisedDelegate onRaised = null, - SignalWaverDelegate signalWaver = null, - DateTimeOffset expiration = default(DateTimeOffset), + OnRaisedDelegate onRaised = null, + SignalWaverDelegate signalWaver = null, + DateTimeOffset expiration = default(DateTimeOffset), IDictionary defaultProperties = null) { if (expiration == default(DateTimeOffset)) @@ -209,9 +209,9 @@ public static Signal Create( } var signal = new Signal( - onRaised, - signalWaver, - expiration, + onRaised, + signalWaver, + expiration, defaultProperties ?? new Dictionary()); SignalManager.AddSignal(signal); diff --git a/Core/Signals/SignalManager.cs b/Core/Signals/SignalManager.cs index e207d25..ee6ab20 100644 --- a/Core/Signals/SignalManager.cs +++ b/Core/Signals/SignalManager.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Signals +namespace LeagueSharp.SDK.Signals { using System; using System.Collections.Generic; diff --git a/Core/UI/Animations/Animation.cs b/Core/UI/Animations/Animation.cs new file mode 100644 index 0000000..0c5f532 --- /dev/null +++ b/Core/UI/Animations/Animation.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + /// + /// Animation base + /// + public class Animation + { + #region Fields + + /// + /// Duration which will be used for the specified mode + /// + protected float duration; + + /// + /// Start time of a start method + /// + protected float startTime; + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected duration for the defined animation + public Animation (float duration) + { + this.duration = duration; + } + + #endregion + + #region Public Properties + + /// + /// Is caluclating a new value + /// + public bool IsWorking => this.startTime + this.duration > Game.ClockTime; + + #endregion + + #region Methods + + /// + /// Instant changes the value to the end value + /// + public void Stop() + { + this.startTime = float.MaxValue; + } + + #endregion + + #region Linear Methods + + /// + /// Calculates in a linear manner + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + protected double Linear(double curTime, double startVal, double endVal, double dur) + { + return endVal * curTime / dur + startVal; + } + + /// + /// Calculates in a inverse linear manner + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// New calculated value + protected double InverseLinear(double curTime, double startVal, double dur) + { + return startVal - (curTime / dur) * startVal; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationBlind.cs b/Core/UI/Animations/AnimationBlind.cs new file mode 100644 index 0000000..7224f32 --- /dev/null +++ b/Core/UI/Animations/AnimationBlind.cs @@ -0,0 +1,220 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationBlind : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get blinded + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get blinded + /// + private Rectangle? endValue; + + /// + /// Defines which Blind method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 4 Modes + /// + public enum Mode + { + /// + /// Vertically decrease height to 0 + /// + VerticalDecrease, + /// + /// Vertically increase height to max height + /// + VerticalIncrease, + /// + /// Horizontally decrease width to 0 + /// + HorizontalDecrease, + /// + /// Horizontally increase width to max width + /// + HorizontalIncrease + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationBlind(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationBlind(Mode mode, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, double dur) + { + switch (this.mode) + { + case Mode.VerticalDecrease: + this.endValue = this.VerticalDecrease(curTime, startVal, dur); + break; + + case Mode.VerticalIncrease: + this.endValue = this.VerticalIncrease(curTime, startVal, dur); + break; + + case Mode.HorizontalDecrease: + this.endValue = this.HorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.HorizontalIncrease: + this.endValue = this.HorizontalIncrease(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + public void Start(Rectangle startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Blind Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle HorizontalDecrease(double curTime, Rectangle val, double dur) + { + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + return val; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle HorizontalIncrease(double curTime, Rectangle val, double dur) + { + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + return val; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle VerticalDecrease(double curTime, Rectangle val, double dur) + { + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle VerticalIncrease(double curTime, Rectangle val, double dur) + { + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationClip.cs b/Core/UI/Animations/AnimationClip.cs new file mode 100644 index 0000000..97ba665 --- /dev/null +++ b/Core/UI/Animations/AnimationClip.cs @@ -0,0 +1,224 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationClip : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get clipped + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get clipped + /// + private Rectangle? endValue; + + /// + /// Defines which Clip method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 4 Modes + /// + public enum Mode + { + /// + /// Vertically decrease height to 0 + /// + VerticalDecrease, + /// + /// Vertically increase height to max height + /// + VerticalIncrease, + /// + /// Horizontally decrease width to 0 + /// + HorizontalDecrease, + /// + /// Horizontally increase width to max width + /// + HorizontalIncrease + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationClip(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationClip(Mode mode, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, double dur) + { + switch (this.mode) + { + case Mode.VerticalDecrease: + this.endValue = this.VerticalDecrease(curTime, startVal, dur); + break; + + case Mode.VerticalIncrease: + this.endValue = this.VerticalIncrease(curTime, startVal, dur); + break; + + case Mode.HorizontalDecrease: + this.endValue = this.HorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.HorizontalIncrease: + this.endValue = this.HorizontalIncrease(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + public void Start(Rectangle startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Clip Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle HorizontalDecrease(double curTime, Rectangle val, double dur) + { + val.X = (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) + 1; + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + return val; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle HorizontalIncrease(double curTime, Rectangle val, double dur) + { + val.X = val.Width / 2 - (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) - 1; + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + return val; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle VerticalDecrease(double curTime, Rectangle val, double dur) + { + val.Y = (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) + 1; + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle VerticalIncrease(double curTime, Rectangle val, double dur) + { + val.Y = val.Height / 2 - (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) - 1; + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationDrop.cs b/Core/UI/Animations/AnimationDrop.cs new file mode 100644 index 0000000..7049eb0 --- /dev/null +++ b/Core/UI/Animations/AnimationDrop.cs @@ -0,0 +1,273 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationDrop : Animation + { + #region Fields + + /// + /// Start AnimationDropData of the element which will get dropped + /// + private AnimationDropData startValue; + + /// + /// Final AnimationDropData of the element which will get dropped + /// + private AnimationDropData endValue; + + /// + /// Defines which Drop method will be used to calculate the new element AnimationDropData + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 4 Modes + /// + public enum Mode + { + /// + /// Vertically decrease height to 0 + /// + VerticalDecrease, + /// + /// Vertically increase height to max height + /// + VerticalIncrease, + /// + /// Horizontally decrease width to 0 + /// + HorizontalDecrease, + /// + /// Horizontally increase width to max width + /// + HorizontalIncrease + } + + #endregion + + #region Classes + + /// + /// Data class for class to save and + /// + public class AnimationDropData + { + #region Fields + + /// + /// Used to save rectangle data + /// + public Rectangle Rectangle; + + /// + /// Used to save color data + /// + public ColorBGRA Color { get; set; } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + public AnimationDropData(Rectangle rectangle, ColorBGRA color) + { + this.Rectangle = rectangle; + this.Color = color; + } + + #endregion + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationDrop(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default AnimationDropData of the element + public AnimationDrop(Mode mode, float duration, AnimationDropData defaultAnimDropData) + : base(duration) + { + this.mode = mode; + this.startValue = defaultAnimDropData; + } + + #endregion + + #region Methods + + /// + /// Returns the current AnimationDropData of the element + /// + public AnimationDropData GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private AnimationDropData Calculate(double curTime, AnimationDropData startVal, double dur) + { + switch (this.mode) + { + case Mode.VerticalDecrease: + this.endValue = this.VerticalDecrease(curTime, startVal, dur); + break; + + case Mode.VerticalIncrease: + this.endValue = this.VerticalIncrease(curTime, startVal, dur); + break; + + case Mode.HorizontalDecrease: + this.endValue = this.HorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.HorizontalIncrease: + this.endValue = this.HorizontalIncrease(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting AnimationDropData of the element + public void Start(AnimationDropData startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Drop Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// AnimationDropData + /// Duration + /// New calculated AnimationDropData + private AnimationDropData HorizontalDecrease(double curTime, AnimationDropData val, double dur) + { + Rectangle rec = val.Rectangle; + Color col = val.Color; + rec.Width = val.Rectangle.Width - (int)this.Linear(curTime, 0, val.Rectangle.Width, dur) - 1; + col.A = (byte)(this.InverseLinear(curTime, val.Color.A, dur)); + AnimationDropData data = new AnimationDropData(rec, col); + return data; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// AnimationDropData + /// Duration + /// New calculated AnimationDropData + private AnimationDropData HorizontalIncrease(double curTime, AnimationDropData val, double dur) + { + Rectangle rec = val.Rectangle; + Color col = val.Color; + rec.Width = (int)this.Linear(curTime, 0, val.Rectangle.Width, dur) + 1; + col = new ColorBGRA(val.Color.B, val.Color.G, val.Color.R, (byte)this.Linear(curTime, val.Color.A, 255 - val.Color.A, dur)); + AnimationDropData data = new AnimationDropData(rec, col); + return data; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// AnimationDropData + /// Duration + /// New calculated AnimationDropData + private AnimationDropData VerticalDecrease(double curTime, AnimationDropData val, double dur) + { + Rectangle rec = val.Rectangle; + Color col = val.Color; + rec.Height = val.Rectangle.Height - (int)this.Linear(curTime, 0, val.Rectangle.Height, dur) - 1; + col.A = (byte)(this.InverseLinear(curTime, val.Color.A, dur)); + AnimationDropData data = new AnimationDropData(rec, col); + return data; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// AnimationDropData + /// Duration + /// New calculated AnimationDropData + private AnimationDropData VerticalIncrease(double curTime, AnimationDropData val, double dur) + { + Rectangle rec = val.Rectangle; + Color col = val.Color; + rec.Height = (int)this.Linear(curTime, 0, val.Rectangle.Height, dur) + 1; + col = new ColorBGRA(val.Color.B, val.Color.G, val.Color.R, (byte)this.Linear(curTime, val.Color.A, 255 - val.Color.A, dur)); + AnimationDropData data = new AnimationDropData(rec, col); + return data; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationEase.cs b/Core/UI/Animations/AnimationEase.cs new file mode 100644 index 0000000..79832ad --- /dev/null +++ b/Core/UI/Animations/AnimationEase.cs @@ -0,0 +1,1173 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using System; + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationEase : Animation + { + #region Fields + + /// + /// Start Position of the element which will get moved + /// + private Vector2 startPosition; + + /// + /// End Position of the element which will get moved + /// + private Vector2 endPosition; + + /// + /// Defines which Ease method will be used to calculate the new element position + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 41 Modes + /// + public enum Mode + { + /// + /// Linear calculation + /// + Linear, + + /// + /// BackEaseIn calculation + /// + BackEaseIn, + /// + /// BackEaseOut calculation + /// + BackEaseOut, + /// + /// BackEaseInOut calculation + /// + BackEaseInOut, + /// + /// BackEaseOutIn calculation + /// + BackEaseOutIn, + + /// + /// BounceEaseIn calculation + /// + BounceEaseIn, + /// + /// BounceEaseOut calculation + /// + BounceEaseOut, + /// + /// BounceEaseInOut calculation + /// + BounceEaseInOut, + /// + /// BounceEaseOutIn calculation + /// + BounceEaseOutIn, + + /// + /// CircEaseIn calculation + /// + CircEaseIn, + /// + /// CircEaseOut calculation + /// + CircEaseOut, + /// + /// CircEaseInOut calculation + /// + CircEaseInOut, + /// + /// CircEaseOutIn calculation + /// + CircEaseOutIn, + + /// + /// CubicEaseIn calculation + /// + CubicEaseIn, + /// + /// CubicEaseOut calculation + /// + CubicEaseOut, + /// + /// CubicEaseInOut calculation + /// + CubicEaseInOut, + /// + /// CubicEaseOutIn calculation + /// + CubicEaseOutIn, + + /// + /// ElasticEaseIn calculation + /// + ElasticEaseIn, + /// + /// ElasticEaseOut calculation + /// + ElasticEaseOut, + /// + /// ElasticEaseInOut calculation + /// + ElasticEaseInOut, + /// + /// ElasticEaseOutIn calculation + /// + ElasticEaseOutIn, + + /// + /// ExpoEaseIn calculation + /// + ExpoEaseIn, + /// + /// ExpoEaseOut calculation + /// + ExpoEaseOut, + /// + /// ExpoEaseInOut calculation + /// + ExpoEaseInOut, + /// + /// ExpoEaseOutIn calculation + /// + ExpoEaseOutIn, + + /// + /// QuadEaseIn calculation + /// + QuadEaseIn, + /// + /// QuadEaseOut calculation + /// + QuadEaseOut, + /// + /// QuadEaseInOut calculation + /// + QuadEaseInOut, + /// + /// QuadEaseOutIn calculation + /// + QuadEaseOutIn, + + /// + /// QuartEaseIn calculation + /// + QuartEaseIn, + /// + /// QuartEaseOut calculation + /// + QuartEaseOut, + /// + /// QuartEaseInOut calculation + /// + QuartEaseInOut, + /// + /// QuartEaseOutIn calculation + /// + QuartEaseOutIn, + + /// + /// QuintEaseIn calculation + /// + QuintEaseIn, + /// + /// QuintEaseOut calculation + /// + QuintEaseOut, + /// + /// QuintEaseInOut calculation + /// + QuintEaseInOut, + /// + /// QuintEaseOutIn calculation + /// + QuintEaseOutIn, + + /// + /// SineEaseIn calculation + /// + SineEaseIn, + /// + /// SineEaseOut calculation + /// + SineEaseOut, + /// + /// SineEaseInOut calculation + /// + SineEaseInOut, + /// + /// SineEaseOutIn calculation + /// + SineEaseOutIn, + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationEase(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Position of the element + public AnimationEase(Mode mode, float duration, Vector2 defaultPos) + : base(duration) + { + this.mode = mode; + this.endPosition = defaultPos; + } + + #endregion + + #region Methods + + /// + /// Returns the current position of the element + /// + public Vector2 GetCurrentPosition + { + get + { + if (!this.IsWorking) + { + return this.endPosition; + } + return this.startPosition.Extend( + this.endPosition, + (float)this.Calculate(Game.ClockTime - this.startTime, + 0, this.endPosition.Distance(this.startPosition), this.duration)); + } + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private double Calculate(double curTime, double startVal, double endVal, double dur) + { + switch (this.mode) + { + case Mode.Linear: + return this.Linear(curTime, startVal, endVal, dur); + + case Mode.BackEaseIn: + return this.BackEaseIn(curTime, startVal, endVal, dur); + + case Mode.BackEaseOut: + return this.BackEaseOut(curTime, startVal, endVal, dur); + + case Mode.BackEaseInOut: + return this.BackEaseInOut(curTime, startVal, endVal, dur); + + case Mode.BackEaseOutIn: + return this.BackEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.BounceEaseIn: + return this.BounceEaseIn(curTime, startVal, endVal, dur); + + case Mode.BounceEaseOut: + return this.BounceEaseOut(curTime, startVal, endVal, dur); + + case Mode.BounceEaseInOut: + return this.BounceEaseInOut(curTime, startVal, endVal, dur); + + case Mode.BounceEaseOutIn: + return this.BounceEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.CircEaseIn: + return this.CircEaseIn(curTime, startVal, endVal, dur); + + case Mode.CircEaseOut: + return this.CircEaseOut(curTime, startVal, endVal, dur); + + case Mode.CircEaseInOut: + return this.CircEaseInOut(curTime, startVal, endVal, dur); + + case Mode.CircEaseOutIn: + return this.CircEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.CubicEaseIn: + return this.CubicEaseIn(curTime, startVal, endVal, dur); + + case Mode.CubicEaseOut: + return this.CubicEaseOut(curTime, startVal, endVal, dur); + + case Mode.CubicEaseInOut: + return this.CubicEaseInOut(curTime, startVal, endVal, dur); + + case Mode.CubicEaseOutIn: + return this.CubicEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.ElasticEaseIn: + return this.ElasticEaseIn(curTime, startVal, endVal, dur); + + case Mode.ElasticEaseOut: + return this.ElasticEaseOut(curTime, startVal, endVal, dur); + + case Mode.ElasticEaseInOut: + return this.ElasticEaseInOut(curTime, startVal, endVal, dur); + + case Mode.ElasticEaseOutIn: + return this.ElasticEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.ExpoEaseIn: + return this.ExpoEaseIn(curTime, startVal, endVal, dur); + + case Mode.ExpoEaseOut: + return this.ExpoEaseOut(curTime, startVal, endVal, dur); + + case Mode.ExpoEaseInOut: + return this.ExpoEaseInOut(curTime, startVal, endVal, dur); + + case Mode.ExpoEaseOutIn: + return this.ExpoEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.QuadEaseIn: + return this.QuadEaseIn(curTime, startVal, endVal, dur); + + case Mode.QuadEaseOut: + return this.QuadEaseOut(curTime, startVal, endVal, dur); + + case Mode.QuadEaseInOut: + return this.QuadEaseInOut(curTime, startVal, endVal, dur); + + case Mode.QuadEaseOutIn: + return this.QuadEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.QuartEaseIn: + return this.QuartEaseIn(curTime, startVal, endVal, dur); + + case Mode.QuartEaseOut: + return this.QuartEaseOut(curTime, startVal, endVal, dur); + + case Mode.QuartEaseInOut: + return this.QuartEaseInOut(curTime, startVal, endVal, dur); + + case Mode.QuartEaseOutIn: + return this.QuartEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.QuintEaseIn: + return this.QuintEaseIn(curTime, startVal, endVal, dur); + + case Mode.QuintEaseOut: + return this.QuintEaseOut(curTime, startVal, endVal, dur); + + case Mode.QuintEaseInOut: + return this.QuintEaseInOut(curTime, startVal, endVal, dur); + + case Mode.QuintEaseOutIn: + return this.QuintEaseOutIn(curTime, startVal, endVal, dur); + + case Mode.SineEaseIn: + return this.SineEaseIn(curTime, startVal, endVal, dur); + + case Mode.SineEaseOut: + return this.SineEaseOut(curTime, startVal, endVal, dur); + + case Mode.SineEaseInOut: + return this.SineEaseInOut(curTime, startVal, endVal, dur); + + case Mode.SineEaseOutIn: + return this.SineEaseOutIn(curTime, startVal, endVal, dur); + + + } + return endVal; + } + + /// + /// Starts the animation + /// After start you can get the current value by calling method + /// + /// Starting Position of the element + /// Final Position of the element + public void Start(Vector2 startPos, Vector2 endPos) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startPosition = startPos; + this.endPosition = endPos; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Ease Methods + //For a preview check http://easings.net/en + + #region Back + + /// + /// Easing equation: Back Ease In + /// Overshooting cubic easing (s+1)*t^3 - s*t^2 + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BackEaseIn(double curTime, double startVal, double endVal, double dur) + { + double indicator = 1.70158; + return endVal * (curTime /= dur) * curTime * ((indicator + 1) * curTime - indicator) + startVal; + } + + /// + /// Easing equation: Back Ease Out + /// Overshooting cubic easing (s+1)*t^3 - s*t^2 + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BackEaseOut(double curTime, double startVal, double endVal, double dur) + { + double indicator = 1.70158; + return endVal * ((curTime = curTime / dur - 1) * curTime * ((indicator + 1) * curTime + indicator) + 1) + startVal; + } + + /// + /// Easing equation: Back Ease In Out + /// Overshooting cubic easing (s+1)*t^3 - s*t^2 + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BackEaseInOut(double curTime, double startVal, double endVal, double dur) + { + double indicator1 = 1.70158; + double indicator2 = 1.525; + if ((curTime /= dur / 2) < 1) + return endVal / 2 * (curTime * curTime * (((indicator1 *= (indicator2)) + 1) * curTime - indicator1)) + startVal; + return endVal / 2 * ((curTime -= 2) * curTime * (((indicator1 *= (indicator2)) + 1) * curTime + indicator1) + 2) + startVal; + } + + /// + /// Easing equation: Back Ease Out In + /// Overshooting cubic easing (s+1)*t^3 - s*t^2 + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BackEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.BackEaseOut(curTime * 2, startVal, endVal / 2, dur); + return this.BackEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Bounce + + /// + /// Easing equation: Bounce Ease In + /// Exponentially decaying parabolic bounce + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BounceEaseIn(double curTime, double startVal, double endVal, double dur) + { + return endVal - this.BounceEaseOut(dur - curTime, 0, endVal, dur) + startVal; + } + + /// + /// Easing equation: Bounce Ease Out + /// Exponentially decaying parabolic bounce + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BounceEaseOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur) < (1 / 2.75)) + return endVal * (7.5625 * curTime * curTime) + startVal; + else if (curTime < (2 / 2.75)) + return endVal * (7.5625 * (curTime -= (1.5 / 2.75)) * curTime + 0.75) + startVal; + else if (curTime < (2.5 / 2.75)) + return endVal * (7.5625 * (curTime -= (2.25 / 2.75)) * curTime + 0.9375) + startVal; + else + return endVal * (7.5625 * (curTime -= (2.625 / 2.75)) * curTime + 0.984375) + startVal; + } + + /// + /// Easing equation: Bounce Ease In Out + /// Exponentially decaying parabolic bounce + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BounceEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.BounceEaseIn(curTime * 2, 0, endVal, dur) * .5 + startVal; + else + return this.BounceEaseOut(curTime * 2 - dur, 0, endVal, dur) * .5 + endVal * .5 + startVal; + } + + /// + /// Easing equation: Bounce Ease Out In + /// Exponentially decaying parabolic bounce + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double BounceEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.BounceEaseOut(curTime * 2, startVal, endVal / 2, dur); + return this.BounceEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Circular + + /// + /// Easing equation: Circular Ease In + /// Circular (sqrt(1-t^2)) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CircEaseIn(double curTime, double startVal, double endVal, double dur) + { + return -endVal * (Math.Sqrt(1 - (curTime /= dur) * curTime) - 1) + startVal; + } + + /// + /// Easing equation: Circular Ease Out + /// Circular (sqrt(1-t^2)) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CircEaseOut(double curTime, double startVal, double endVal, double dur) + { + return endVal * Math.Sqrt(1 - (curTime = curTime / dur - 1) * curTime) + startVal; + } + + /// + /// Easing equation: Circular Ease In Out + /// Circular (sqrt(1-t^2)) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CircEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return -endVal / 2 * (Math.Sqrt(1 - curTime * curTime) - 1) + startVal; + + return endVal / 2 * (Math.Sqrt(1 - (curTime -= 2) * curTime) + 1) + startVal; + } + + /// + /// Easing equation: Circular Ease Out In + /// Circular (sqrt(1-t^2)) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CircEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.CircEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.CircEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Cubic + + /// + /// Easing equation: Cubic Ease In + /// Cubic (t^3) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CubicEaseIn(double curTime, double startVal, double endVal, double dur) + { + return endVal * (curTime /= dur) * curTime * curTime + startVal; + } + + /// + /// Easing equation: Cubic Ease Out + /// Cubic (t^3) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CubicEaseOut(double curTime, double startVal, double endVal, double dur) + { + return endVal * ((curTime = curTime / dur - 1) * curTime * curTime + 1) + startVal; + } + + /// + /// Easing equation: Cubic Ease In Out + /// Cubic (t^3) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CubicEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return endVal / 2 * curTime * curTime * curTime + startVal; + + return endVal / 2 * ((curTime -= 2) * curTime * curTime + 2) + startVal; + } + + /// + /// Easing equation: Cubic Ease Out In + /// Cubic (t^3) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double CubicEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.CubicEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.CubicEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Elastic + + /// + /// Easing equation: Elastic Ease In + /// Exponentially decaying sine wave + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ElasticEaseIn(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur).Equals(1)) + return startVal + endVal; + + double p = dur * .3; + double s = p / 4; + + return -(endVal * Math.Pow(2, 10 * (curTime -= 1)) * Math.Sin((curTime * dur - s) * (2 * Math.PI) / p)) + startVal; + } + + /// + /// Easing equation: Elastic Ease Out + /// Exponentially decaying sine wave + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ElasticEaseOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur).Equals(1)) + return startVal + endVal; + + double p = dur * .3; + double s = p / 4; + + return (endVal * Math.Pow(2, -10 * curTime) * Math.Sin((curTime * dur - s) * (2 * Math.PI) / p) + endVal + startVal); + } + + /// + /// Easing equation: Elastic Ease In Out + /// Exponentially decaying sine wave + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ElasticEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2).Equals(2)) + return startVal + endVal; + + double p = dur * (.3 * 1.5); + double s = p / 4; + + if (curTime < 1) + return -.5 * (endVal * Math.Pow(2, 10 * (curTime -= 1)) * Math.Sin((curTime * dur - s) * (2 * Math.PI) / p)) + startVal; + return endVal * Math.Pow(2, -10 * (curTime -= 1)) * Math.Sin((curTime * dur - s) * (2 * Math.PI) / p) * .5 + endVal + startVal; + } + + /// + /// Easing equation: Elastic Ease Out In + /// Exponentially decaying sine wave + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ElasticEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.ElasticEaseOut(curTime * 2, startVal, endVal / 2, dur); + return this.ElasticEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Exponential + + /// + /// Easing equation: Exponential Ease In + /// Exponential (2^t) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ExpoEaseIn(double curTime, double startVal, double endVal, double dur) + { + return (curTime.Equals(0)) ? startVal : endVal * Math.Pow(2, 10 * (curTime / dur - 1)) + startVal; + } + + /// + /// Easing equation: Exponential Ease Out + /// Exponential (2^t) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ExpoEaseOut(double curTime, double startVal, double endVal, double dur) + { + return (curTime.Equals(dur)) ? startVal + endVal : endVal * (-Math.Pow(2, -10 * curTime / dur) + 1) + startVal; + } + + /// + /// Easing equation: Exponential Ease In Out + /// Exponential (2^t) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ExpoEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if (curTime.Equals(0)) + return startVal; + + if (curTime.Equals(dur)) + return startVal + endVal; + + if ((curTime /= dur / 2) < 1) + return endVal / 2 * Math.Pow(2, 10 * (curTime - 1)) + startVal; + + return endVal / 2 * (-Math.Pow(2, -10 * --curTime) + 2) + startVal; + } + + /// + /// Easing equation: Exponential Ease Out In + /// Exponential (2^t) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double ExpoEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.ExpoEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.ExpoEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Quadratic + + /// + /// Easing equation: Quadratic Ease In + /// Quadratic (t^2) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuadEaseIn(double curTime, double startVal, double endVal, double dur) + { + return endVal * (curTime /= dur) * curTime + startVal; + } + + /// + /// Easing equation: Quadratic Ease Out + /// Quadratic (t^2) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuadEaseOut(double curTime, double startVal, double endVal, double dur) + { + return -endVal * (curTime /= dur) * (curTime - 2) + startVal; + } + + /// + /// Easing equation: Quadratic Ease In Out + /// Quadratic (t^2) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuadEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return endVal / 2 * curTime * curTime + startVal; + + return -endVal / 2 * ((--curTime) * (curTime - 2) - 1) + startVal; + } + + /// + /// Easing equation: Quadratic Ease Out In + /// Quadratic (t^2) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuadEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.QuadEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.QuadEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Quartic + + /// + /// Easing equation: Quartic Ease In + /// Quartic (t^4) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuartEaseIn(double curTime, double startVal, double endVal, double dur) + { + return endVal * (curTime /= dur) * curTime * curTime * curTime + startVal; + } + + /// + /// Easing equation: Quartic Ease Out + /// Quartic (t^4) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuartEaseOut(double curTime, double startVal, double endVal, double dur) + { + return -endVal * ((curTime = curTime / dur - 1) * curTime * curTime * curTime - 1) + startVal; + } + + /// + /// Easing equation: Quartic Ease In Out + /// Quartic (t^4) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuartEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return endVal / 2 * curTime * curTime * curTime * curTime + startVal; + + return -endVal / 2 * ((curTime -= 2) * curTime * curTime * curTime - 2) + startVal; + } + + /// + /// Easing equation: Quartic Ease Out In + /// Quartic (t^4) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuartEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.QuartEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.QuartEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Quintic + + /// + /// Easing equation: Quintic Ease In + /// Quintic (t^5) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuintEaseIn(double curTime, double startVal, double endVal, double dur) + { + return endVal * (curTime /= dur) * curTime * curTime * curTime * curTime + startVal; + } + + /// + /// Easing equation: Quintic Ease Out + /// Quintic (t^5) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuintEaseOut(double curTime, double startVal, double endVal, double dur) + { + return endVal * ((curTime = curTime / dur - 1) * curTime * curTime * curTime * curTime + 1) + startVal; + } + + /// + /// Easing equation: Quintic Ease In Out + /// Quintic (t^5) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuintEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return endVal / 2 * curTime * curTime * curTime * curTime * curTime + startVal; + return endVal / 2 * ((curTime -= 2) * curTime * curTime * curTime * curTime + 2) + startVal; + } + + /// + /// Easing equation: Quintic Ease Out In + /// Quintic (t^5) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double QuintEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.QuintEaseOut(curTime * 2, startVal, endVal / 2, dur); + return this.QuintEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #region Sinusoidal + + /// + /// Easing equation: Sinusoidal Ease In + /// Sinusoidal (sin(t)) + /// Accelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double SineEaseIn(double curTime, double startVal, double endVal, double dur) + { + return -endVal * Math.Cos(curTime / dur * (Math.PI / 2)) + endVal + startVal; + } + + /// + /// Easing equation: Sinusoidal Ease Out + /// Sinusoidal (sin(t)) + /// Decelerating from zero velocity + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double SineEaseOut(double curTime, double startVal, double endVal, double dur) + { + return endVal * Math.Sin(curTime / dur * (Math.PI / 2)) + startVal; + } + + /// + /// Easing equation: Sinusoidal Ease In Out + /// Sinusoidal (sin(t)) + /// Accelerating from zero velocity until half then decelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double SineEaseInOut(double curTime, double startVal, double endVal, double dur) + { + if ((curTime /= dur / 2) < 1) + return endVal / 2 * (Math.Sin(Math.PI * curTime / 2)) + startVal; + + return -endVal / 2 * (Math.Cos(Math.PI * --curTime / 2) - 2) + startVal; + } + + /// + /// Easing equation: Sinusoidal Ease Out In + /// Sinusoidal (sin(t)) + /// Decelerating from zero velocity until half then accelerating + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// New calculated value + private double SineEaseOutIn(double curTime, double startVal, double endVal, double dur) + { + if (curTime < dur / 2) + return this.SineEaseOut(curTime * 2, startVal, endVal / 2, dur); + + return this.SineEaseIn((curTime * 2) - dur, startVal + endVal / 2, endVal / 2, dur); + } + + #endregion + + #endregion + } +} diff --git a/Core/UI/Animations/AnimationFade.cs b/Core/UI/Animations/AnimationFade.cs new file mode 100644 index 0000000..c2e0b13 --- /dev/null +++ b/Core/UI/Animations/AnimationFade.cs @@ -0,0 +1,176 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationFade : Animation + { + #region Fields + + /// + /// Start Color of the element which will get faded + /// + private ColorBGRA startValue; + + /// + /// Final Color of the element which will get faded + /// + private ColorBGRA? endValue; + + /// + /// Defines which Fade method will be used to calculate the new element color + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 2 Modes + /// + public enum Mode + { + /// + /// FadeIn Transparency 100% + /// + FadeIn, + /// + /// FadeIn Transparency 0% + /// + FadeOut + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationFade(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Color of the element + public AnimationFade(Mode mode, float duration, ColorBGRA defaultCol) + : base(duration) + { + this.mode = mode; + this.startValue = defaultCol; + } + + #endregion + + #region Methods + + /// + /// Returns the current color of the element + /// + public ColorBGRA GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private ColorBGRA Calculate(double curTime, ColorBGRA startVal, double dur) + { + switch (this.mode) + { + case Mode.FadeIn: + this.endValue = this.FadeIn(curTime, startVal, dur); + break; + + case Mode.FadeOut: + this.endValue = this.FadeOut(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Color of the element + public void Start(ColorBGRA startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Fade Methods + + /// + /// Changes the transparency of a color to 100% + /// + /// Current Time (seconds) + /// Color + /// Duration + /// New calculated color + private ColorBGRA FadeIn(double curTime, ColorBGRA val, double dur) + { + return new ColorBGRA(val.B, val.G, val.R, (byte)this.Linear(curTime, val.A, 255 - val.A, dur)); + } + + /// + /// Changes the transparency of a color to 0% + /// + /// Current Time (seconds) + /// Color + /// Duration + /// New calculated color + private ColorBGRA FadeOut(double curTime, ColorBGRA val, double dur) + { + return new ColorBGRA(val.B, val.G, val.R, (byte)(this.InverseLinear(curTime, val.A, dur))); + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationMisc.cs b/Core/UI/Animations/AnimationMisc.cs new file mode 100644 index 0000000..0d6208f --- /dev/null +++ b/Core/UI/Animations/AnimationMisc.cs @@ -0,0 +1,370 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationMisc : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get adjusted + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get adjusted + /// + private Rectangle? endValue; + + /// + /// Defines which Misc method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 12 Modes + /// + public enum Mode + { + BlindVerticalDecrease, + BlindVerticalIncrease, + BlindHorizontalDecrease, + BlindHorizontalIncrease, + + ClipVerticalDecrease, + ClipVerticalIncrease, + ClipHorizontalDecrease, + ClipHorizontalIncrease, + + DropVerticalDecrease, + DropVerticalIncrease, + DropHorizontalDecrease, + DropHorizontalIncrease, + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationMisc(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationMisc(Mode mode, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, double dur) + { + switch (this.mode) + { + case Mode.BlindVerticalDecrease: + this.endValue = this.BlindVerticalDecrease(curTime, startVal, dur); + break; + + case Mode.BlindVerticalIncrease: + this.endValue = this.BlindVerticalIncrease(curTime, startVal, dur); + break; + + case Mode.BlindHorizontalDecrease: + this.endValue = this.BlindHorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.BlindHorizontalIncrease: + this.endValue = this.BlindHorizontalIncrease(curTime, startVal, dur); + break; + + case Mode.ClipVerticalDecrease: + this.endValue = this.ClipVerticalDecrease(curTime, startVal, dur); + break; + + case Mode.ClipVerticalIncrease: + this.endValue = this.ClipVerticalIncrease(curTime, startVal, dur); + break; + + case Mode.ClipHorizontalDecrease: + this.endValue = this.ClipHorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.ClipHorizontalIncrease: + this.endValue = this.ClipHorizontalIncrease(curTime, startVal, dur); + break; + + case Mode.DropVerticalDecrease: + this.endValue = this.DropVerticalDecrease(curTime, startVal, dur); + break; + + case Mode.DropVerticalIncrease: + this.endValue = this.DropVerticalIncrease(curTime, startVal, dur); + break; + + case Mode.DropHorizontalDecrease: + this.endValue = this.DropHorizontalDecrease(curTime, startVal, dur); + break; + + case Mode.DropHorizontalIncrease: + this.endValue = this.DropHorizontalIncrease(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + public void Start(Rectangle startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Blind Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle BlindHorizontalDecrease(double curTime, Rectangle val, double dur) + { + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + return val; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle BlindHorizontalIncrease(double curTime, Rectangle val, double dur) + { + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + return val; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle BlindVerticalDecrease(double curTime, Rectangle val, double dur) + { + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle BlindVerticalIncrease(double curTime, Rectangle val, double dur) + { + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + #region Clip Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ClipHorizontalDecrease(double curTime, Rectangle val, double dur) + { + val.X = (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) + 1; + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + return val; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ClipHorizontalIncrease(double curTime, Rectangle val, double dur) + { + val.X = val.Width / 2 - (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) - 1; + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + return val; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ClipVerticalDecrease(double curTime, Rectangle val, double dur) + { + val.Y = (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) + 1; + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ClipVerticalIncrease(double curTime, Rectangle val, double dur) + { + val.Y = val.Height / 2 - (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) - 1; + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + #region Drop Methods + + /// + /// Decreases the Width until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle DropHorizontalDecrease(double curTime, Rectangle val, double dur) + { + val.X = (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) + 1; + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + return val; + } + + /// + /// Increases the Width from 0 to specified width + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle DropHorizontalIncrease(double curTime, Rectangle val, double dur) + { + val.X = val.Width / 2 - (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) - 1; + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + return val; + } + + /// + /// Decreases the Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle DropVerticalDecrease(double curTime, Rectangle val, double dur) + { + val.Y = (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) + 1; + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Height from 0 to specified height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle DropVerticalIncrease(double curTime, Rectangle val, double dur) + { + val.Y = val.Height / 2 - (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) - 1; + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationPulsate.cs b/Core/UI/Animations/AnimationPulsate.cs new file mode 100644 index 0000000..377eff0 --- /dev/null +++ b/Core/UI/Animations/AnimationPulsate.cs @@ -0,0 +1,138 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationPulsate : Animation + { + #region Fields + + /// + /// Start Color of the element which will get pulsated + /// + private ColorBGRA startValue; + + /// + /// Final Color of the element which will get pulsated + /// + private ColorBGRA? endValue; + + /// + /// How many times it should pulsate + /// + private readonly int pulsateTimes; + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Pulsationtimes + /// Selected duration for the defined animation + public AnimationPulsate(int pulsateTimes, float duration) + : base(duration) + { + this.pulsateTimes = pulsateTimes; + } + + /// + /// Initializes a new instance of the class. + /// + /// Pulsationtimes + /// Selected duration for the defined animation + /// Default Color of the element + public AnimationPulsate(int pulsateTimes, float duration, ColorBGRA defaultCol) + : base(duration) + { + this.pulsateTimes = pulsateTimes; + this.startValue = defaultCol; + } + + #endregion + + #region Methods + + /// + /// Returns the current color of the element + /// + public ColorBGRA GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.pulsateTimes, this.startValue, this.duration); + } + + /// + /// Calculates the value + /// + /// Current Time (seconds) + /// Pulsate times + /// Start Value + /// Duration of the animation + /// Returns the calculated value + private ColorBGRA Calculate(double curTime, int times, ColorBGRA startVal, double dur) + { + this.endValue = this.Pulsate(curTime, times, startVal, dur); + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Color of the element + public void Start(ColorBGRA startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Pulsate Methods + + /// + /// Changes the transparency of a color to 100% + /// + /// Current Time (seconds) + /// Pulsate times + /// Color + /// Duration + /// New calculated color + private ColorBGRA Pulsate(double curTime, int times, ColorBGRA val, double dur) + { + return (curTime % (dur / times) < (dur / times) / 2) ? new ColorBGRA(val.B, val.G, val.R, 0) : val; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationResize.cs b/Core/UI/Animations/AnimationResize.cs new file mode 100644 index 0000000..e13ad8c --- /dev/null +++ b/Core/UI/Animations/AnimationResize.cs @@ -0,0 +1,162 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationResize : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get resized + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get resized + /// + private Rectangle endValue; + + /// + /// Defines which Resize method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 1 Modes + /// + public enum Mode + { + /// + /// Resizes Width and Height + /// + Resize, + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationResize(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationResize(Mode mode, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.endValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Final Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, Rectangle endVal, double dur) + { + switch (this.mode) + { + case Mode.Resize: + return this.Resize(curTime, startVal, endVal, dur); + + } + return this.endValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + /// Final Rectangle of the element + public void Start(Rectangle startVal, Rectangle endVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.endValue = endVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Resize Methods + + /// + /// Decreases the Width / Height until it reaches 0 + /// + /// Current Time (seconds) + /// Starting Rectangle + /// Final Rectangle + /// Duration + /// New calculated rectangle + private Rectangle Resize(double curTime, Rectangle startVal, Rectangle endVal, double dur) + { + startVal.Width = (int)this.Linear(curTime, startVal.Width, endVal.Width - startVal.Width, dur) + 1; + startVal.Height = (int)this.Linear(curTime, startVal.Height, endVal.Height - startVal.Height, dur) + 1; + return startVal; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationScale.cs b/Core/UI/Animations/AnimationScale.cs new file mode 100644 index 0000000..99ed395 --- /dev/null +++ b/Core/UI/Animations/AnimationScale.cs @@ -0,0 +1,184 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationScale : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get scaled + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get scaled + /// + private Rectangle? endValue; + + /// + /// Defines which Clip method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + #endregion + + #region Enums + + /// + /// Contains 2 Modes + /// + public enum Mode + { + /// + /// Decrease height / width to 0 + /// + ScaleDecrease, + /// + /// Increase height / width to max height / width + /// + ScaleIncrease, + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + public AnimationScale(Mode mode, float duration) + : base(duration) + { + this.mode = mode; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationScale(Mode mode, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, double dur) + { + switch (this.mode) + { + case Mode.ScaleDecrease: + this.endValue = this.ScaleDecrease(curTime, startVal, dur); + break; + + case Mode.ScaleIncrease: + this.endValue = this.ScaleIncrease(curTime, startVal, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + public void Start(Rectangle startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Scale Methods + + /// + /// Decreases the Width / Height until it reaches 0 + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ScaleDecrease(double curTime, Rectangle val, double dur) + { + val.X = (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) + 1; + val.Width = val.Width - (int)this.Linear(curTime, 0, val.Width, dur) - 1; + val.Y = (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) + 1; + val.Height = val.Height - (int)this.Linear(curTime, 0, val.Height, dur) - 1; + return val; + } + + /// + /// Increases the Width / Height from 0 to specified width / height + /// + /// Current Time (seconds) + /// Rectangle + /// Duration + /// New calculated rectangle + private Rectangle ScaleIncrease(double curTime, Rectangle val, double dur) + { + val.X = val.Width / 2 - (int)this.Linear(curTime, 0, (double)val.Width / 2, dur) - 1; + val.Width = (int)this.Linear(curTime, 0, val.Width, dur) + 1; + val.Y = val.Height / 2 - (int)this.Linear(curTime, 0, (double)val.Height / 2, dur) - 1; + val.Height = (int)this.Linear(curTime, 0, val.Height, dur) + 1; + return val; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationShake.cs b/Core/UI/Animations/AnimationShake.cs new file mode 100644 index 0000000..547471c --- /dev/null +++ b/Core/UI/Animations/AnimationShake.cs @@ -0,0 +1,260 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using System; + + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationShake : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get shaked + /// + private Rectangle startValue; + + /// + /// Final Rectangle of the element which will get shaked + /// + private Rectangle? endValue; + + /// + /// Defines which Shake method will be used to calculate the new element rectangle + /// + private readonly Mode mode; + + /// + /// Defines the distance from the start initial point to shake + /// + private readonly double distance; + + /// + /// How many times the element should get shaked + /// + private readonly int shakeTimes; + + #endregion + + #region Enums + + /// + /// Contains 2 Modes + /// + public enum Mode + { + /// + /// Horizontal shake + /// + Horizontal, + /// + /// Vertical shake + /// + Vertical + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Shaking distance from main point + /// Shake times until it stops + /// Selected duration for the defined animation + public AnimationShake(Mode mode, double distance, int shakeTimes, float duration) + : base(duration) + { + this.mode = mode; + this.distance = distance; + this.shakeTimes = shakeTimes; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Shaking distance from main point + /// Shake times until it stops + /// Selected duration for the defined animation + /// Default Rectangle of the element + public AnimationShake(Mode mode, double distance, int shakeTimes, float duration, Rectangle defaultRect) + : base(duration) + { + this.mode = mode; + this.distance = distance; + this.shakeTimes = shakeTimes; + this.startValue = defaultRect; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Rectangle GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.distance, this.shakeTimes, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Distance + /// Shake Times + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Rectangle Calculate(double curTime, Rectangle startVal, double dist, int times, double dur) + { + switch (this.mode) + { + case Mode.Vertical: + this.endValue = this.Vertical(curTime, startVal, dist, times, dur); + break; + + case Mode.Horizontal: + this.endValue = this.Horizontal(curTime, startVal, dist, times, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Rectangle of the element + public void Start(Rectangle startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Shake Methods + + /// + /// Shakes in vertical position + /// + /// Current Time (seconds) + /// Color + /// Distance + /// Shake Times + /// Duration + /// New calculated color + private Rectangle Vertical(double curTime, Rectangle val, double dist, int times, double dur) + { + Rectangle retRec = val; + double b = this.Linear(curTime % (dur / times / 2), 0, dist, (dur / times) / 2); + + if (curTime / ((dur / times) / 2) % 2 <= 1) + { + if (curTime / ((dur / times) / 2) < 1) + { + retRec.Y += (int)b; + } + else + { + retRec.Y -= (int)dist; + retRec.Y += (int)b * 2; + } + } + else + { + if (curTime / ((dur / times) / 2) > times * 2 - 1) + { + retRec.Y += (int)dist; + retRec.Y -= (int)b; + } + else + { + retRec.Y += (int)dist; + retRec.Y -= (int)b * 2; + } + } + + return retRec; + } + + /// + /// Shakes in horizontal position + /// + /// Current Time (seconds) + /// Color + /// Distance + /// Shake Times + /// Duration + /// New calculated color + private Rectangle Horizontal(double curTime, Rectangle val, double dist, int times, double dur) + { + Rectangle retRec = val; + double b = this.Linear(curTime % (dur / times / 2), 0, dist, (dur / times) / 2); + + if (curTime / ((dur / times) / 2) % 2 <= 1) + { + if (curTime / ((dur / times) / 2) < 1) + { + retRec.X += (int)b; + } + else + { + retRec.X -= (int)dist; + retRec.X += (int)b * 2; + } + } + else + { + if (curTime / ((dur / times) / 2) > times * 2 - 1) + { + retRec.X += (int)dist; + retRec.X -= (int)b; + } + else + { + retRec.X += (int)dist; + retRec.X -= (int)b * 2; + } + } + + return retRec; + } + + #endregion + + } +} diff --git a/Core/UI/Animations/AnimationSlide.cs b/Core/UI/Animations/AnimationSlide.cs new file mode 100644 index 0000000..5f67acc --- /dev/null +++ b/Core/UI/Animations/AnimationSlide.cs @@ -0,0 +1,234 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK.Core.UI.Animations +{ + using SharpDX; + + /// + /// A implementation of a + /// + public class AnimationSlide : Animation + { + #region Fields + + /// + /// Start Rectangle of the element which will get slided + /// + private Vector2 startValue; + + /// + /// Final Rectangle of the element which will get slided + /// + private Vector2? endValue; + + /// + /// Defines which Slide method will be used to calculate the new element position + /// + private readonly Mode mode; + + /// + /// Distance for the element which get moved + /// + private readonly double distance; + + #endregion + + #region Enums + + /// + /// Contains 4 Modes + /// + public enum Mode + { + /// + /// Adjust to left + /// + Left, + /// + /// Adjust to top + /// + Top, + /// + /// Adjust to right + /// + Right, + /// + /// Adjust to bottom + /// + Bottom + } + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Distance for the defined animation + /// Selected duration for the defined animation + public AnimationSlide(Mode mode, double distance, float duration) + : base(duration) + { + this.mode = mode; + this.distance = distance; + } + + /// + /// Initializes a new instance of the class. + /// + /// Selected mode for calculation + /// Distance for the defined animation + /// Selected duration for the defined animation + /// Default Position of the element + public AnimationSlide(Mode mode, double distance, float duration, Vector2 defaultPos) + : base(duration) + { + this.mode = mode; + this.distance = distance; + this.startValue = defaultPos; + } + + #endregion + + #region Methods + + /// + /// Returns the current rectangle of the element + /// + public Vector2 GetCurrentValue() + { + if (!this.IsWorking) + { + return this.endValue ?? this.startValue; + } + return this.Calculate(Game.ClockTime - this.startTime, this.startValue, this.distance, this.duration); + } + + /// + /// Calculates the value of the specified mode + /// + /// Current Time (seconds) + /// Start Value + /// Distance + /// Duration of the animation + /// Returns the calculated value of the specified mode + private Vector2 Calculate(double curTime, Vector2 startVal, double dist, double dur) + { + switch (this.mode) + { + case Mode.Left: + this.endValue = this.Left(curTime, startVal, dist, dur); + break; + + case Mode.Top: + this.endValue = this.Top(curTime, startVal, dist, dur); + break; + + case Mode.Right: + this.endValue = this.Right(curTime, startVal, dist, dur); + break; + + case Mode.Bottom: + this.endValue = this.Bottom(curTime, startVal, dist, dur); + break; + } + return this.endValue ?? this.startValue; + } + + /// + /// Starts the animation + /// After start you can get the current value in method + /// + /// Starting Position of the element + public void Start(Vector2 startVal) + { + if (this.IsWorking) + { + this.Stop(); + } + + this.startValue = startVal; + this.startTime = Game.ClockTime; + } + + #endregion + + #region Slide Methods + + /// + /// Moves element to left + /// + /// Current Time (seconds) + /// Position + /// Distance + /// Duration + /// New calculated rectangle + private Vector2 Left(double curTime, Vector2 val, double dist, double dur) + { + val.X -= (int)this.Linear(curTime, 0, dist, dur); + return val; + } + + /// + /// Moves element to top + /// + /// Current Time (seconds) + /// Position + /// Distance + /// Duration + /// New calculated rectangle + private Vector2 Top(double curTime, Vector2 val, double dist, double dur) + { + val.Y -= (int)this.Linear(curTime, 0, dist, dur); + return val; + } + + /// + /// Moves element to right + /// + /// Current Time (seconds) + /// Position + /// Distance + /// Duration + /// New calculated rectangle + private Vector2 Right(double curTime, Vector2 val, double dist, double dur) + { + val.X += (int)this.Linear(curTime, 0, dist, dur); + return val; + } + + /// + /// Moves element to bottom + /// + /// Current Time (seconds) + /// Position + /// Distance + /// Duration + /// New calculated rectangle + private Vector2 Bottom(double curTime, Vector2 val, double dist, double dur) + { + val.Y += (int)this.Linear(curTime, 0, dist, dur); + return val; + } + + #endregion + + } +} diff --git a/Core/UI/IMenu/Abstracts/AMenuComponent.cs b/Core/UI/IMenu/Abstracts/AMenuComponent.cs index 1bef573..b0039e8 100644 --- a/Core/UI/IMenu/Abstracts/AMenuComponent.cs +++ b/Core/UI/IMenu/Abstracts/AMenuComponent.cs @@ -15,15 +15,16 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Abstracts +namespace LeagueSharp.SDK.UI { using System; using System.Dynamic; using System.Linq; - using Core.Utils; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; + using SharpDX; - using Skins; - using Values; /// /// Abstract build of a menu component. diff --git a/Core/UI/IMenu/ColorSpectrum.cs b/Core/UI/IMenu/ColorSpectrum.cs index bc7e363..8bce1b7 100644 --- a/Core/UI/IMenu/ColorSpectrum.cs +++ b/Core/UI/IMenu/ColorSpectrum.cs @@ -1,92 +1,91 @@ -using System; - -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { + using System; using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = System.Drawing.Color; - using Math = System.Math; internal class ColorSpectrum { } /// - /// The ColorBox + /// The ColorBox /// public class ColorBox { #region Fields /// - /// Is User dragging the slider + /// Height of the ColorBox /// - private bool mDragging; + private readonly int mHeight; /// - /// Defines the Display Style + /// Width of the ColorBox /// - private EDrawStyle mEDrawStyle; + private readonly int mWidth; /// - /// Height of the ColorBox + /// Colorbox disabled /// - private readonly int mHeight; + private bool mDisabled; /// - /// Width of the ColorBox + /// Is User dragging the slider /// - private readonly int mWidth; + private bool mDragging; /// - /// Hue, Saturation, Lightness + /// Defines the Display Style /// - private Hsl mHsl; + private EDrawStyle mEDrawStyle; /// - /// Reg, Green, Blue + /// Hue, Saturation, Lightness /// - private Color mRgb; + private Hsl mHsl; /// - /// Marker X Position + /// Marker Color /// - private int mMarkerX; + private Color mMarkerColor; /// - /// Marker Y Position + /// Marker X Position /// - private int mMarkerY; + private int mMarkerX; /// - /// Marker Color + /// Marker Y Position /// - private Color mMarkerColor; + private int mMarkerY; /// - /// Position on the Screen + /// Position on the Screen /// private Vector2 mPos; /// - /// Colorbox disabled + /// Reg, Green, Blue /// - private bool mDisabled; + private Color mRgb; #endregion #region Constructors and Destructors /// - /// Init the ColorBox + /// Init the ColorBox /// /// The size of the new ColorBox + /// public ColorBox(Size size, bool disabled = false) { this.mHsl = new Hsl { H = 1, S = 1, L = 1 }; @@ -107,7 +106,7 @@ public ColorBox(Size size, bool disabled = false) #region Delegates /// - /// EventHandler for the event + /// EventHandler for the event /// public delegate void ColorBoxScrolledEventHandler(); @@ -116,7 +115,7 @@ public ColorBox(Size size, bool disabled = false) #region Public Events /// - /// The event which gets fired when the color get changed + /// The event which gets fired when the color get changed /// public event ColorBoxScrolledEventHandler ColorBoxScrolled; @@ -125,47 +124,53 @@ public ColorBox(Size size, bool disabled = false) #region Enums /// - /// The DrawStyle enum + /// The DrawStyle enum /// public enum EDrawStyle { /// - /// Hue Style + /// Hue Style /// Hue, + /// - /// Saturation Style + /// Saturation Style /// Saturation, + /// - /// Brightness Style + /// Brightness Style /// Brightness, + /// - /// Red Style + /// Red Style /// Red, + /// - /// Green Style + /// Green Style /// Green, + /// - /// Blue Style + /// Blue Style /// Blue } /// - /// The Orientation enum for the Gradient to draw + /// The Orientation enum for the Gradient to draw /// public enum Orientation { /// - /// Horizontal Orientation + /// Horizontal Orientation /// Horizontal, + /// - /// Vertical Orientation + /// Vertical Orientation /// Vertical }; @@ -175,70 +180,70 @@ public enum Orientation #region Public Properties /// - /// Hue, Saturation, Lightness Property + /// The DrawStyle Property /// - public Hsl Hsl + public EDrawStyle DrawStyle { get { - return this.mHsl; + return this.mEDrawStyle; } set { - this.mHsl = value; - this.mRgb = Utilities.HslToRgb(this.mHsl); + this.mEDrawStyle = value; this.ResetMarker(true); } } /// - /// Red, Green, Blue Property + /// Hue, Saturation, Lightness Property /// - public Color Rgb + public Hsl Hsl { get { - return this.mRgb; + return this.mHsl; } set { - this.mRgb = value; - this.mHsl = Utilities.RgbToHsl(this.mRgb); + this.mHsl = value; + this.mRgb = Utilities.HslToRgb(this.mHsl); this.ResetMarker(true); } } /// - /// The DrawStyle Property + /// The MarkerColor Property /// - public EDrawStyle DrawStyle + public Color MarkerColor { get { - return this.mEDrawStyle; + return this.mMarkerColor; } set { - this.mEDrawStyle = value; - - this.ResetMarker(true); + this.mMarkerColor = value; } } /// - /// The MarkerColor Property + /// Red, Green, Blue Property /// - public Color MarkerColor + public Color Rgb { get { - return this.mMarkerColor; + return this.mRgb; } set { - this.mMarkerColor = value; + this.mRgb = value; + this.mHsl = Utilities.RgbToHsl(this.mRgb); + + this.ResetMarker(true); } } @@ -247,7 +252,7 @@ public Color MarkerColor #region Public Methods and Operators /// - /// Gets fired when the left mouse button is pressed + /// Gets fired when the left mouse button is pressed /// /// Keys public void ColorBoxMouseDown(WindowsKeys args) @@ -284,15 +289,12 @@ public void ColorBoxMouseDown(WindowsKeys args) this.ResetHslrgb(); // Reset the color - if (this.ColorBoxScrolled != null) - { - this.ColorBoxScrolled(); - } + this.ColorBoxScrolled?.Invoke(); } } /// - /// Gets fired when the mouse is moved and pressed before + /// Gets fired when the mouse is moved and pressed before /// /// Keys public void ColorBoxMouseMove(WindowsKeys args) @@ -328,15 +330,12 @@ public void ColorBoxMouseMove(WindowsKeys args) this.ResetHslrgb(); // Reset the color - if (this.ColorBoxScrolled != null) - { - this.ColorBoxScrolled(); - } + this.ColorBoxScrolled?.Invoke(); } } /// - /// Gets fired when the mouse is released and pressed before + /// Gets fired when the mouse is released and pressed before /// /// Keys public void ColorBoxMouseUp(WindowsKeys args) @@ -373,15 +372,28 @@ public void ColorBoxMouseUp(WindowsKeys args) this.ResetHslrgb(); // Reset the color - if (this.ColorBoxScrolled != null) - { - this.ColorBoxScrolled(); - } + this.ColorBoxScrolled?.Invoke(); + } + } + + /// + /// Draws the ColorBox + /// + /// Sets a new Position + public void DrawControl(Vector2 newPos = new Vector2()) + { + if (!newPos.IsZero) + { + this.mPos = newPos; } + + this.DrawBorder(); + this.DrawContent(); + this.DrawMarker(this.mMarkerX, this.mMarkerY, true); } /// - /// Draws a Gradient. + /// Draws a Gradient. /// /// Position X /// Position Y @@ -449,28 +461,131 @@ public void GradientRect( vertices.Dispose(); } + #endregion + + #region Methods + /// - /// Draws the ColorBox + /// Draws the Border around the ColorBox /// - /// Sets a new Position - public void DrawControl(Vector2 newPos = new Vector2()) + private void DrawBorder() { - if (!newPos.IsZero) + ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); + + Utils.DrawLine(this.mPos.X - 1, this.mPos.Y - 1, this.mPos.X + this.mWidth - 4, this.mPos.Y - 1, 1, color); + //Top + Utils.DrawLine(this.mPos.X - 1, this.mPos.Y - 1, this.mPos.X - 1, this.mPos.Y + this.mHeight - 1, 1, color); + //Left + Utils.DrawLine( + this.mPos.X - 1, + this.mPos.Y + this.mHeight - 2, + this.mPos.X + this.mWidth - 3, + this.mPos.Y + this.mHeight - 2, + 1, + color); //Bot + Utils.DrawLine( + this.mPos.X + this.mWidth - 4, + this.mPos.Y - 1, + this.mPos.X + this.mWidth - 4, + this.mPos.Y + this.mHeight - 1, + 1, + color); //Right + } + + /// + /// Draws in Content of the ColorBox + /// + private void DrawContent() + { + switch (this.mEDrawStyle) { - this.mPos = newPos; - } + case EDrawStyle.Hue: + this.DrawStyleHue(); - this.DrawBorder(); - this.DrawContent(); - this.DrawMarker(this.mMarkerX, this.mMarkerY, true); + break; + case EDrawStyle.Saturation: + this.DrawStyleSaturation(); + + break; + case EDrawStyle.Brightness: + this.DrawStyleLuminance(); + + break; + case EDrawStyle.Red: + this.DrawStyleRed(); + + break; + case EDrawStyle.Green: + this.DrawStyleGreen(); + + break; + case EDrawStyle.Blue: + this.DrawStyleBlue(); + + break; + } } - #endregion + /// + /// Draws the Marker + /// + private void DrawMarker(int x, int y, bool unconditional) + { + if (x < 0) + { + x = 0; + } + if (x > (this.mWidth - 4)) + { + x = (this.mWidth - 4); + } - #region Methods + if (y < 0) + { + x = 0; + } + if (y > (this.mHeight - 4)) + { + y = (this.mHeight - 4); + } + + if (this.mMarkerY == y & this.mMarkerX == x & !unconditional) + { + return; + } + + this.mMarkerX = x; + this.mMarkerY = y; + + // The selected color will determine whether our marker is white or black + var hsl = this.GetColor(x, y); + + if (hsl.L < Convert.ToDouble(200d / 255d)) + { + this.mMarkerColor = Color.White; + } + else if ((hsl.H < Convert.ToDouble(26d / 360d)) | (hsl.H > Convert.ToDouble(200d / 360d))) + { + this.mMarkerColor = hsl.S > Convert.ToDouble(70d / 255d) ? Color.White : Color.Black; + } + else + { + this.mMarkerColor = Color.Black; + } + + Utils.DrawCircle( + this.mPos.X + x + 2, + this.mPos.Y + y + 2, + 5, + 0, + Utils.CircleType.Full, + false, + 16, + this.mMarkerColor.ToSharpDxColor()); + } /// - /// Draws in Blue Style + /// Draws in Blue Style /// private void DrawStyleBlue() { @@ -493,7 +608,7 @@ private void DrawStyleBlue() } /// - /// Draws in Green Style + /// Draws in Green Style /// private void DrawStyleGreen() { @@ -516,7 +631,7 @@ private void DrawStyleGreen() } /// - /// Draws in Hue Style + /// Draws in Hue Style /// private void DrawStyleHue() { @@ -524,10 +639,7 @@ private void DrawStyleHue() var hslEnd = new Hsl(); if ((this.mHsl == null)) { - this.mHsl = new Hsl(); - this.mHsl.H = 1; - this.mHsl.S = 1; - this.mHsl.L = 1; + this.mHsl = new Hsl { H = 1, S = 1, L = 1 }; this.mRgb = Utilities.HslToRgb(this.mHsl); } @@ -557,7 +669,7 @@ private void DrawStyleHue() } /// - /// Draws in Luminance Style + /// Draws in Luminance Style /// private void DrawStyleLuminance() { @@ -589,7 +701,7 @@ private void DrawStyleLuminance() } /// - /// Draws in Red Style + /// Draws in Red Style /// private void DrawStyleRed() { @@ -612,7 +724,7 @@ private void DrawStyleRed() } /// - /// Draws in Saturation Style + /// Draws in Saturation Style /// private void DrawStyleSaturation() { @@ -644,195 +756,125 @@ private void DrawStyleSaturation() } /// - /// Draws the Border around the ColorBox + /// Gets the Color of the given Position /// - private void DrawBorder() + /// Position X + /// Position Y + /// HSL Color + private Hsl GetColor(int x, int y) { - ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); - - Utils.DrawLine(this.mPos.X - 1, this.mPos.Y - 1, this.mPos.X + this.mWidth - 4, this.mPos.Y - 1, 1, color); - //Top - Utils.DrawLine(this.mPos.X - 1, this.mPos.Y - 1, this.mPos.X - 1, this.mPos.Y + this.mHeight - 1, 1, color); - //Left - Utils.DrawLine( - this.mPos.X - 1, - this.mPos.Y + this.mHeight - 2, - this.mPos.X + this.mWidth - 3, - this.mPos.Y + this.mHeight - 2, - 1, - color); //Bot - Utils.DrawLine( - this.mPos.X + this.mWidth - 4, - this.mPos.Y - 1, - this.mPos.X + this.mWidth - 4, - this.mPos.Y + this.mHeight - 1, - 1, - color); //Right - } + var hsl = new Hsl(); - /// - /// Draws in Content of the ColorBox - /// - private void DrawContent() - { switch (this.mEDrawStyle) { case EDrawStyle.Hue: - this.DrawStyleHue(); + hsl.H = this.mHsl.H; + hsl.S = Convert.ToDouble(x / (this.mWidth - 4d)); + hsl.L = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); break; case EDrawStyle.Saturation: - this.DrawStyleSaturation(); + hsl.S = this.mHsl.S; + hsl.H = Convert.ToDouble(x / (this.mWidth - 4d)); + hsl.L = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); break; case EDrawStyle.Brightness: - this.DrawStyleLuminance(); + hsl.L = this.mHsl.L; + hsl.H = Convert.ToDouble(x / (this.mWidth - 4d)); + hsl.S = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); break; case EDrawStyle.Red: - this.DrawStyleRed(); + hsl = + Utilities.RgbToHsl( + Color.FromArgb( + this.mRgb.R, + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), + Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))))); break; case EDrawStyle.Green: - this.DrawStyleGreen(); - - break; - case EDrawStyle.Blue: - this.DrawStyleBlue(); + hsl = + Utilities.RgbToHsl( + Color.FromArgb( + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), + this.mRgb.G, + Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))))); break; - } - } - - /// - /// Draws the Marker - /// - private void DrawMarker(int x, int y, bool unconditional) - { - if (x < 0) - { - x = 0; - } - if (x > (this.mWidth - 4)) - { - x = (this.mWidth - 4); - } - - if (y < 0) - { - x = 0; - } - if (y > (this.mHeight - 4)) - { - y = (this.mHeight - 4); - } - - if (this.mMarkerY == y & this.mMarkerX == x & !unconditional) - { - return; - } - - this.mMarkerX = x; - this.mMarkerY = y; - - // The selected color will determine whether our marker is white or black - var hsl = this.GetColor(x, y); + case EDrawStyle.Blue: + hsl = + Utilities.RgbToHsl( + Color.FromArgb( + Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))), + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), + this.mRgb.B)); - if (hsl.L < Convert.ToDouble(200d / 255d)) - { - this.mMarkerColor = Color.White; - } - else if ((hsl.H < Convert.ToDouble(26d / 360d)) | (hsl.H > Convert.ToDouble(200d / 360d))) - { - if (hsl.S > Convert.ToDouble(70d / 255d)) - { - this.mMarkerColor = Color.White; - } - else - { - this.mMarkerColor = Color.Black; - } - } - else - { - this.mMarkerColor = Color.Black; + break; } - Utils.DrawCircle( - this.mPos.X + x + 2, - this.mPos.Y + y + 2, - 5, - 0, - Utils.CircleType.Full, - false, - 16, - this.mMarkerColor.ToSharpDxColor()); + return hsl; } /// - /// Gets the Color of the given Position + /// Resets the Color /// - /// Position X - /// Position Y - /// HSL Color - private Hsl GetColor(int x, int y) + private void ResetHslrgb() { - var hsl = new Hsl(); + int red; + int green; + int blue; switch (this.mEDrawStyle) { case EDrawStyle.Hue: - hsl.H = this.mHsl.H; - hsl.S = Convert.ToDouble(x / (this.mWidth - 4d)); - hsl.L = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); + this.mHsl.S = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); + this.mHsl.L = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Saturation: - hsl.S = this.mHsl.S; - hsl.H = Convert.ToDouble(x / (this.mWidth - 4d)); - hsl.L = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); + this.mHsl.H = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); + this.mHsl.L = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Brightness: - hsl.L = this.mHsl.L; - hsl.H = Convert.ToDouble(x / (this.mWidth - 4d)); - hsl.S = 1.0 - Convert.ToDouble(y / (this.mHeight - 4d)); + this.mHsl.H = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); + this.mHsl.S = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Red: - hsl = - Utilities.RgbToHsl( - Color.FromArgb( - this.mRgb.R, - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), - Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))))); + blue = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); + green = + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); + this.mRgb = Color.FromArgb(this.mRgb.R, green, blue); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Green: - hsl = - Utilities.RgbToHsl( - Color.FromArgb( - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), - this.mRgb.G, - Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))))); + blue = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); + red = + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); + this.mRgb = Color.FromArgb(red, this.mRgb.G, blue); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Blue: - hsl = - Utilities.RgbToHsl( - Color.FromArgb( - Convert.ToInt32(Math.Round(255 * Convert.ToDouble(x / (this.mWidth - 4d)))), - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(y / (this.mHeight - 4d))))), - this.mRgb.B)); + red = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); + green = + Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); + this.mRgb = Color.FromArgb(red, green, this.mRgb.B); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; } - - return hsl; } /// - /// Resets the Marker + /// Resets the Marker /// /// Force Redraw private void ResetMarker(bool redraw) @@ -878,67 +920,11 @@ private void ResetMarker(bool redraw) } } - /// - /// Resets the Color - /// - private void ResetHslrgb() - { - int red; - int green; - int blue; - - switch (this.mEDrawStyle) - { - case EDrawStyle.Hue: - this.mHsl.S = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); - this.mHsl.L = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Saturation: - this.mHsl.H = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); - this.mHsl.L = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Brightness: - this.mHsl.H = Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)); - this.mHsl.S = 1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Red: - blue = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); - green = - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); - this.mRgb = Color.FromArgb(this.mRgb.R, green, blue); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Green: - blue = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); - red = - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); - this.mRgb = Color.FromArgb(red, this.mRgb.G, blue); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Blue: - red = Convert.ToInt32(Math.Round(255 * Convert.ToDouble(this.mMarkerX / (this.mWidth - 4d)))); - green = - Convert.ToInt32(Math.Round(255 * (1.0 - Convert.ToDouble(this.mMarkerY / (this.mHeight - 4d))))); - this.mRgb = Color.FromArgb(red, green, this.mRgb.B); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - } - } - #endregion } /// - /// The VerticalColorSlider + /// The VerticalColorSlider /// public class VerticalColorSlider { @@ -947,62 +933,59 @@ public class VerticalColorSlider /// /// The line. /// - private static readonly SharpDX.Direct3D9.Line Line = new SharpDX.Direct3D9.Line(Drawing.Direct3DDevice) { GLLines = true }; + private static readonly Line Line = new Line(Drawing.Direct3DDevice) { GLLines = true }; #endregion #region Fields /// - /// Is User dragging the slider + /// Height of the ColorBox /// - private bool mDragging; + private readonly int mHeight; /// - /// Defines the Display Style + /// Width of the ColorBox /// - private EDrawStyle mEDrawStyle; + private readonly int mWidth; /// - /// Height of the ColorBox + /// VerticalColorSlider disabled /// - private readonly int mHeight; + private bool mDisabled; /// - /// Width of the ColorBox + /// Is User dragging the slider /// - private readonly int mWidth; + private bool mDragging; /// - /// Hue, Saturation, Lightness + /// Defines the Display Style /// - private Hsl mHsl; + private EDrawStyle mEDrawStyle; /// - /// Reg, Green, Blue + /// Hue, Saturation, Lightness /// - private Color mRgb; + private Hsl mHsl; /// - /// VerticalColorSlider disabled + /// Reg, Green, Blue /// - private bool mDisabled; + private Color mRgb; #endregion #region Constructors and Destructors /// - /// Init the VerticalColorSlider + /// Init the VerticalColorSlider /// /// /// public VerticalColorSlider(Size size, bool disabled = false) { - this.mHsl = new Hsl(); - this.mHsl.H = 1; - this.mHsl.S = 1; - this.mHsl.L = 1; + this.mHsl = new Hsl { H = 1, S = 1, L = 1 }; this.mRgb = Utilities.HslToRgb(this.mHsl); this.mEDrawStyle = EDrawStyle.Hue; @@ -1020,15 +1003,16 @@ public VerticalColorSlider(Size size, bool disabled = false) #region Delegates /// - /// EventHandler for the event + /// EventHandler for the event /// public delegate void ColorSliderScrollEventHandler(); #endregion #region Public Events + /// - /// The event which gets fired when the color get changed + /// The event which gets fired when the color get changed /// public event ColorSliderScrollEventHandler ColorSliderScroll; @@ -1037,32 +1021,37 @@ public VerticalColorSlider(Size size, bool disabled = false) #region Enums /// - /// The DrawStyle enum + /// The DrawStyle enum /// public enum EDrawStyle { /// - /// Hue Style + /// Hue Style /// Hue, + /// - /// Saturation Style + /// Saturation Style /// Saturation, + /// - /// Brightness Style + /// Brightness Style /// Brightness, + /// - /// Red Style + /// Red Style /// Red, + /// - /// Green Style + /// Green Style /// Green, + /// - /// Blue Style + /// Blue Style /// Blue } @@ -1072,12 +1061,12 @@ public enum EDrawStyle #region Public Properties /// - /// Position of the two Arrows + /// Position of the two Arrows /// public int ArrowPos { get; private set; } /// - /// Hue, Saturation, Lightness Property + /// Hue, Saturation, Lightness Property /// public Hsl CbHsl { @@ -1096,7 +1085,7 @@ public Hsl CbHsl } /// - /// The DrawStyle Property + /// The DrawStyle Property /// public EDrawStyle DrawStyle { @@ -1114,12 +1103,12 @@ public EDrawStyle DrawStyle } /// - /// Position of the ColorSlider + /// Position of the ColorSlider /// public Vector2 Position { get; set; } /// - /// Red, Green, Blue Property + /// Red, Green, Blue Property /// public Color Rgb { @@ -1142,7 +1131,7 @@ public Color Rgb #region Public Methods and Operators /// - /// Draws the ColorSlider + /// Draws the ColorSlider /// /// Sets a new Position public void DrawControl(Vector2 newPos = new Vector2()) @@ -1155,10 +1144,10 @@ public Color Rgb } /// - /// Gets fired when the left mouse button is pressed + /// Gets fired when the left mouse button is pressed /// /// Keys - public void VerticalColorSlider_MouseDown(WindowsKeys args) + public void VerticalColorSliderMouseDown(WindowsKeys args) { if (args.Msg == WindowsMessages.LBUTTONDOWN && !this.mDisabled) { @@ -1179,18 +1168,15 @@ public void VerticalColorSlider_MouseDown(WindowsKeys args) this.DrawSlider(y, false); this.ResetHslrgb(); - if (this.ColorSliderScroll != null) - { - this.ColorSliderScroll(); - } + this.ColorSliderScroll?.Invoke(); } } /// - /// Gets fired when the mouse is moved and pressed before + /// Gets fired when the mouse is moved and pressed before /// /// Keys - public void VerticalColorSlider_MouseMove(WindowsKeys args) + public void VerticalColorSliderMouseMove(WindowsKeys args) { if (this.mDragging && args.Msg == WindowsMessages.MOUSEMOVE && !this.mDisabled) { @@ -1208,18 +1194,15 @@ public void VerticalColorSlider_MouseMove(WindowsKeys args) this.ArrowPos = y; this.DrawSlider(y, false); this.ResetHslrgb(); - if (this.ColorSliderScroll != null) - { - this.ColorSliderScroll(); - } + this.ColorSliderScroll?.Invoke(); } } /// - /// Gets fired when the mouse is released and pressed before + /// Gets fired when the mouse is released and pressed before /// /// Keys - public void VerticalColorSlider_MouseUp(WindowsKeys args) + public void VerticalColorSliderMouseUp(WindowsKeys args) { if (this.mDragging && args.Msg == WindowsMessages.LBUTTONUP && !this.mDisabled) { @@ -1239,10 +1222,7 @@ public void VerticalColorSlider_MouseUp(WindowsKeys args) this.ArrowPos = y; this.DrawSlider(y, false); this.ResetHslrgb(); - if (this.ColorSliderScroll != null) - { - this.ColorSliderScroll(); - } + this.ColorSliderScroll?.Invoke(); } } @@ -1251,7 +1231,114 @@ public void VerticalColorSlider_MouseUp(WindowsKeys args) #region Methods /// - /// Draws in Blue Style + /// Draws the Border around the ColorSlider + /// + private void DrawBorder() + { + ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); + + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + 3, + this.Position.X + this.mWidth - 10, + this.Position.Y + 3, + 1, + color); //Top + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + 3, + this.Position.X + 10, + this.Position.Y + this.mHeight - 3, + 1, + color); //Left + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + this.mHeight - 4, + this.Position.X + this.mWidth - 10, + this.Position.Y + this.mHeight - 4, + 1, + color); + //Bot + Utils.DrawLine( + this.Position.X + this.mWidth - 11, + this.Position.Y + 3, + this.Position.X + this.mWidth - 11, + this.Position.Y + this.mHeight - 3, + 1, + color); + //Right + } + + /// + /// Draws in Content of the ColorSlider + /// + private void DrawContent() + { + switch (this.mEDrawStyle) + { + case EDrawStyle.Hue: + this.DrawStyleHue(); + + break; + case EDrawStyle.Saturation: + this.DrawStyleSaturation(); + + break; + case EDrawStyle.Brightness: + this.DrawStyleLuminance(); + + break; + case EDrawStyle.Red: + this.DrawStyleRed(); + + break; + case EDrawStyle.Green: + this.DrawStyleGreen(); + + break; + case EDrawStyle.Blue: + this.DrawStyleBlue(); + + break; + } + } + + /// + /// Draws the Arrows + /// + private void DrawSlider(int position, bool unconditional) + { + if (position < 0) + { + position = 0; + } + if (position > (this.mHeight - 9)) + { + position = (this.mHeight - 9); + } + + if (this.ArrowPos == position & !unconditional) + { + return; + } + + this.ArrowPos = position; + + ColorBGRA color = Color.FromArgb(4, 188, 252).ToSharpDxColor(); + + Utils.DrawBoxFilled(this.Position.X, this.Position.Y + position, 2, 7, color); + Utils.DrawBoxFilled(this.Position.X + 2, this.Position.Y + position + 1, 2, 5, color); + Utils.DrawBoxFilled(this.Position.X + 4, this.Position.Y + position + 2, 2, 3, color); + Utils.DrawBoxFilled(this.Position.X + 6, this.Position.Y + position + 3, 2, 1, color); + + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2, this.Position.Y + position, 2, 7, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 2, this.Position.Y + position + 1, 2, 5, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 4, this.Position.Y + position + 2, 2, 3, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 6, this.Position.Y + position + 3, 2, 1, color); + } + + /// + /// Draws in Blue Style /// private void DrawStyleBlue() { @@ -1273,7 +1360,7 @@ private void DrawStyleBlue() } /// - /// Draws in Green Style + /// Draws in Green Style /// private void DrawStyleGreen() { @@ -1295,14 +1382,12 @@ private void DrawStyleGreen() } /// - /// Draws in Hue Style + /// Draws in Hue Style /// private void DrawStyleHue() { - var hsl = new Hsl(); + var hsl = new Hsl { S = 1, L = 1 }; - hsl.S = 1; - hsl.L = 1; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -1321,14 +1406,12 @@ private void DrawStyleHue() } /// - /// Draws in Luminance Style + /// Draws in Luminance Style /// private void DrawStyleLuminance() { - var hsl = new Hsl(); + var hsl = new Hsl { H = this.mHsl.H, S = this.mHsl.S }; - hsl.H = this.mHsl.H; - hsl.S = this.mHsl.S; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -1347,7 +1430,7 @@ private void DrawStyleLuminance() } /// - /// Draws in Red Style + /// Draws in Red Style /// private void DrawStyleRed() { @@ -1369,14 +1452,12 @@ private void DrawStyleRed() } /// - /// Draws in Saturation Style + /// Draws in Saturation Style /// private void DrawStyleSaturation() { - var hsl = new Hsl(); + var hsl = new Hsl { H = this.mHsl.H, L = this.mHsl.L }; - hsl.H = this.mHsl.H; - hsl.L = this.mHsl.L; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -1395,114 +1476,57 @@ private void DrawStyleSaturation() } /// - /// Draws the Border around the ColorSlider - /// - private void DrawBorder() - { - ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); - - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + 3, - this.Position.X + this.mWidth - 10, - this.Position.Y + 3, - 1, - color); //Top - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + 3, - this.Position.X + 10, - this.Position.Y + this.mHeight - 3, - 1, - color); //Left - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + this.mHeight - 4, - this.Position.X + this.mWidth - 10, - this.Position.Y + this.mHeight - 4, - 1, - color); - //Bot - Utils.DrawLine( - this.Position.X + this.mWidth - 11, - this.Position.Y + 3, - this.Position.X + this.mWidth - 11, - this.Position.Y + this.mHeight - 3, - 1, - color); - //Right - } - - /// - /// Draws in Content of the ColorSlider + /// Resets the Color /// - private void DrawContent() + private void ResetHslrgb() { switch (this.mEDrawStyle) { case EDrawStyle.Hue: - this.DrawStyleHue(); + this.mHsl.H = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Saturation: - this.DrawStyleSaturation(); + this.mHsl.S = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Brightness: - this.DrawStyleLuminance(); + this.mHsl.L = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Red: - this.DrawStyleRed(); + this.mRgb = + Color.FromArgb( + 255 + - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), + this.mRgb.G, + this.mRgb.B); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Green: - this.DrawStyleGreen(); + this.mRgb = Color.FromArgb( + this.mRgb.R, + 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), + this.mRgb.B); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Blue: - this.DrawStyleBlue(); - + this.mRgb = Color.FromArgb( + this.mRgb.R, + this.mRgb.G, + 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d))))); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; } } /// - /// Draws the Arrows - /// - private void DrawSlider(int position, bool unconditional) - { - if (position < 0) - { - position = 0; - } - if (position > (this.mHeight - 9)) - { - position = (this.mHeight - 9); - } - - if (this.ArrowPos == position & !unconditional) - { - return; - } - - this.ArrowPos = position; - - ColorBGRA color = Color.FromArgb(4, 188, 252).ToSharpDxColor(); - - Utils.DrawBoxFilled(this.Position.X, this.Position.Y + position, 2, 7, color); - Utils.DrawBoxFilled(this.Position.X + 2, this.Position.Y + position + 1, 2, 5, color); - Utils.DrawBoxFilled(this.Position.X + 4, this.Position.Y + position + 2, 2, 3, color); - Utils.DrawBoxFilled(this.Position.X + 6, this.Position.Y + position + 3, 2, 1, color); - - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2, this.Position.Y + position, 2, 7, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 2, this.Position.Y + position + 1, 2, 5, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 4, this.Position.Y + position + 2, 2, 3, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 6, this.Position.Y + position + 3, 2, 1, color); - } - - /// - /// Resets the Arrows + /// Resets the Arrows /// /// Force Redraw private void ResetSlider(bool redraw) @@ -1547,61 +1571,11 @@ private void ResetSlider(bool redraw) } } - /// - /// Resets the Color - /// - private void ResetHslrgb() - { - switch (this.mEDrawStyle) - { - case EDrawStyle.Hue: - this.mHsl.H = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Saturation: - this.mHsl.S = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Brightness: - this.mHsl.L = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Red: - this.mRgb = - Color.FromArgb( - 255 - - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), - this.mRgb.G, - this.mRgb.B); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Green: - this.mRgb = Color.FromArgb( - this.mRgb.R, - 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), - this.mRgb.B); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Blue: - this.mRgb = Color.FromArgb( - this.mRgb.R, - this.mRgb.G, - 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d))))); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - break; - } - } - #endregion } /// - /// The VerticalAlphaSlider + /// The VerticalAlphaSlider /// public class VerticalAlphaSlider { @@ -1610,61 +1584,59 @@ public class VerticalAlphaSlider /// /// The line. /// - private static readonly SharpDX.Direct3D9.Line Line = new SharpDX.Direct3D9.Line(Drawing.Direct3DDevice) { GLLines = true }; + private static readonly Line Line = new Line(Drawing.Direct3DDevice) { GLLines = true }; #endregion #region Fields /// - /// Is User dragging the slider + /// Is User dragging the slider /// private bool mBDragging; /// - /// Defines the Display Style + /// VerticalAlphaSlider disabled /// - private EDrawStyle mEDrawStyle = EDrawStyle.Brightness; + private bool mDisabled; /// - /// Height of the ColorBox + /// Defines the Display Style /// - private int mHeight; + private EDrawStyle mEDrawStyle; /// - /// Width of the ColorBox + /// Height of the ColorBox /// - private int mWidth; + private int mHeight; /// - /// Hue, Saturation, Lightness + /// Hue, Saturation, Lightness /// private Hsl mHsl; /// - /// Reg, Green, Blue + /// Reg, Green, Blue /// private Color mRgb; /// - /// VerticalAlphaSlider disabled + /// Width of the ColorBox /// - private bool mDisabled; + private int mWidth; #endregion #region Constructors and Destructors /// - /// Init the VerticalAlphaSlider + /// Init the VerticalAlphaSlider /// /// + /// public VerticalAlphaSlider(Size size, bool disabled = false) { - this.mHsl = new Hsl(); - this.mHsl.H = 1; - this.mHsl.S = 0; - this.mHsl.L = 1; + this.mHsl = new Hsl { H = 1, S = 0, L = 1 }; this.mRgb = Utilities.HslToRgb(this.mHsl); this.mEDrawStyle = EDrawStyle.Brightness; @@ -1682,7 +1654,7 @@ public VerticalAlphaSlider(Size size, bool disabled = false) #region Delegates /// - /// EventHandler for the event + /// EventHandler for the event /// public delegate void AlphaSliderScrollEventHandler(); @@ -1691,7 +1663,7 @@ public VerticalAlphaSlider(Size size, bool disabled = false) #region Public Events /// - /// The event which gets fired when the color get changed + /// The event which gets fired when the color get changed /// public event AlphaSliderScrollEventHandler AlphaSliderScroll; @@ -1700,32 +1672,37 @@ public VerticalAlphaSlider(Size size, bool disabled = false) #region Enums /// - /// The DrawStyle enum + /// The DrawStyle enum /// public enum EDrawStyle { /// - /// Hue Style + /// Hue Style /// Hue, + /// - /// Saturation Style + /// Saturation Style /// Saturation, + /// - /// Brightness Style + /// Brightness Style /// Brightness, + /// - /// Red Style + /// Red Style /// Red, + /// - /// Green Style + /// Green Style /// Green, + /// - /// Blue Style + /// Blue Style /// Blue } @@ -1735,12 +1712,12 @@ public enum EDrawStyle #region Public Properties /// - /// Position of the two Arrows + /// Position of the two Arrows /// public int ArrowPos { get; private set; } /// - /// Hue, Saturation, Lightness Property + /// Hue, Saturation, Lightness Property /// public Hsl CbHsl { @@ -1759,7 +1736,7 @@ public Hsl CbHsl } /// - /// The DrawStyle Property + /// The DrawStyle Property /// public EDrawStyle DrawStyle { @@ -1777,12 +1754,12 @@ public EDrawStyle DrawStyle } /// - /// Position of the ColorSlider + /// Position of the ColorSlider /// public Vector2 Position { get; set; } /// - /// Red, Green, Blue Property + /// Red, Green, Blue Property /// public Color Rgb { @@ -1805,7 +1782,7 @@ public Color Rgb #region Public Methods and Operators /// - /// Draws the AlphaSlider + /// Draws the AlphaSlider /// /// Sets a new Position public void DrawControl(Vector2 newPos = new Vector2()) @@ -1818,12 +1795,12 @@ public Color Rgb } /// - /// Gets fired when the left mouse button is pressed + /// Gets fired when the left mouse button is pressed /// /// Keys - public void VerticalAlphaSlider_MouseDown(WindowsKeys args) + public void VerticalAlphaSliderMouseDown(WindowsKeys args) { - if (args.Msg == WindowsMessages.LBUTTONDOWN && !mDisabled) + if (args.Msg == WindowsMessages.LBUTTONDOWN && !this.mDisabled) { this.mBDragging = true; @@ -1842,79 +1819,177 @@ public void VerticalAlphaSlider_MouseDown(WindowsKeys args) this.DrawSlider(y, false); this.ResetHslrgb(); - if (this.AlphaSliderScroll != null) + this.AlphaSliderScroll?.Invoke(); + } + } + + /// + /// Gets fired when the mouse is moved and pressed before + /// + /// Keys + public void VerticalAlphaSliderMouseMove(WindowsKeys args) + { + if (this.mBDragging && args.Msg == WindowsMessages.MOUSEMOVE && !this.mDisabled) + { + var y = (int)args.Cursor.Y - (int)this.Position.Y; + y -= 4; + if (y < 0) + { + y = 0; + } + if (y > (this.mHeight - 9)) + { + y = (this.mHeight - 9); + } + + this.ArrowPos = y; + this.DrawSlider(y, false); + this.ResetHslrgb(); + this.AlphaSliderScroll?.Invoke(); + } + } + + /// + /// Gets fired when the mouse is released and pressed before + /// + /// Keys + public void VerticalAlphaSliderMouseUp(WindowsKeys args) + { + if (this.mBDragging && args.Msg == WindowsMessages.LBUTTONUP && !this.mDisabled) + { + this.mBDragging = false; + + var y = (int)args.Cursor.Y - (int)this.Position.Y; + y -= 4; + if (y < 0) + { + y = 0; + } + if (y > (this.mHeight - 9)) { - this.AlphaSliderScroll(); + y = (this.mHeight - 9); } + + this.ArrowPos = y; + this.DrawSlider(y, false); + this.ResetHslrgb(); + this.AlphaSliderScroll?.Invoke(); } } + #endregion + + #region Methods + + /// + /// Draws the Border around the AlphaSlider + /// + private void DrawBorder() + { + ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); + + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + 3, + this.Position.X + this.mWidth - 10, + this.Position.Y + 3, + 1, + color); //Top + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + 3, + this.Position.X + 10, + this.Position.Y + this.mHeight - 3, + 1, + color); //Left + Utils.DrawLine( + this.Position.X + 10, + this.Position.Y + this.mHeight - 4, + this.Position.X + this.mWidth - 10, + this.Position.Y + this.mHeight - 4, + 1, + color); + //Bot + Utils.DrawLine( + this.Position.X + this.mWidth - 11, + this.Position.Y + 3, + this.Position.X + this.mWidth - 11, + this.Position.Y + this.mHeight - 3, + 1, + color); + //Right + } + /// - /// Gets fired when the mouse is moved and pressed before + /// Draws in Content of the AlphaSlider /// - /// Keys - public void VerticalAlphaSlider_MouseMove(WindowsKeys args) + private void DrawContent() { - if (this.mBDragging && args.Msg == WindowsMessages.MOUSEMOVE && !mDisabled) + switch (this.mEDrawStyle) { - var y = (int)args.Cursor.Y - (int)this.Position.Y; - y -= 4; - if (y < 0) - { - y = 0; - } - if (y > (this.mHeight - 9)) - { - y = (this.mHeight - 9); - } + case EDrawStyle.Hue: + this.DrawStyleHue(); - this.ArrowPos = y; - this.DrawSlider(y, false); - this.ResetHslrgb(); - if (this.AlphaSliderScroll != null) - { - this.AlphaSliderScroll(); - } + break; + case EDrawStyle.Saturation: + this.DrawStyleSaturation(); + + break; + case EDrawStyle.Brightness: + this.DrawStyleLuminance(); + + break; + case EDrawStyle.Red: + this.DrawStyleRed(); + + break; + case EDrawStyle.Green: + this.DrawStyleGreen(); + + break; + case EDrawStyle.Blue: + this.DrawStyleBlue(); + + break; } } /// - /// Gets fired when the mouse is released and pressed before + /// Draws the Arrows /// - /// Keys - public void VerticalAlphaSlider_MouseUp(WindowsKeys args) + private void DrawSlider(int position, bool unconditional) { - if (this.mBDragging && args.Msg == WindowsMessages.LBUTTONUP && !mDisabled) + if (position < 0) { - this.mBDragging = false; - - var y = (int)args.Cursor.Y - (int)this.Position.Y; - y -= 4; - if (y < 0) - { - y = 0; - } - if (y > (this.mHeight - 9)) - { - y = (this.mHeight - 9); - } + position = 0; + } + if (position > (this.mHeight - 9)) + { + position = (this.mHeight - 9); + } - this.ArrowPos = y; - this.DrawSlider(y, false); - this.ResetHslrgb(); - if (this.AlphaSliderScroll != null) - { - this.AlphaSliderScroll(); - } + if (this.ArrowPos == position & !unconditional) + { + return; } - } - #endregion + this.ArrowPos = position; - #region Methods + ColorBGRA color = Color.FromArgb(4, 188, 252).ToSharpDxColor(); + + Utils.DrawBoxFilled(this.Position.X, this.Position.Y + position, 2, 7, color); + Utils.DrawBoxFilled(this.Position.X + 2, this.Position.Y + position + 1, 2, 5, color); + Utils.DrawBoxFilled(this.Position.X + 4, this.Position.Y + position + 2, 2, 3, color); + Utils.DrawBoxFilled(this.Position.X + 6, this.Position.Y + position + 3, 2, 1, color); + + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2, this.Position.Y + position, 2, 7, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 2, this.Position.Y + position + 1, 2, 5, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 4, this.Position.Y + position + 2, 2, 3, color); + Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 6, this.Position.Y + position + 3, 2, 1, color); + } /// - /// Draws in Blue Style + /// Draws in Blue Style /// private void DrawStyleBlue() { @@ -1936,7 +2011,7 @@ private void DrawStyleBlue() } /// - /// Draws in Green Style + /// Draws in Green Style /// private void DrawStyleGreen() { @@ -1958,14 +2033,12 @@ private void DrawStyleGreen() } /// - /// Draws in Hue Style + /// Draws in Hue Style /// private void DrawStyleHue() { - var hsl = new Hsl(); + var hsl = new Hsl { S = 1, L = 1 }; - hsl.S = 1; - hsl.L = 1; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -1984,14 +2057,12 @@ private void DrawStyleHue() } /// - /// Draws in Luminance Style + /// Draws in Luminance Style /// private void DrawStyleLuminance() { - var hsl = new Hsl(); + var hsl = new Hsl { H = this.mHsl.H, S = this.mHsl.S }; - hsl.H = this.mHsl.H; - hsl.S = this.mHsl.S; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -2010,7 +2081,7 @@ private void DrawStyleLuminance() } /// - /// Draws in Red Style + /// Draws in Red Style /// private void DrawStyleRed() { @@ -2032,14 +2103,12 @@ private void DrawStyleRed() } /// - /// Draws in Saturation Style + /// Draws in Saturation Style /// private void DrawStyleSaturation() { - var hsl = new Hsl(); + var hsl = new Hsl { H = this.mHsl.H, L = this.mHsl.L }; - hsl.H = this.mHsl.H; - hsl.L = this.mHsl.L; Line.Begin(); for (var iCx = 0; iCx <= this.mHeight - 9; iCx++) { @@ -2058,114 +2127,57 @@ private void DrawStyleSaturation() } /// - /// Draws the Border around the AlphaSlider - /// - private void DrawBorder() - { - ColorBGRA color = Color.FromArgb(37, 37, 37).ToSharpDxColor(); - - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + 3, - this.Position.X + this.mWidth - 10, - this.Position.Y + 3, - 1, - color); //Top - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + 3, - this.Position.X + 10, - this.Position.Y + this.mHeight - 3, - 1, - color); //Left - Utils.DrawLine( - this.Position.X + 10, - this.Position.Y + this.mHeight - 4, - this.Position.X + this.mWidth - 10, - this.Position.Y + this.mHeight - 4, - 1, - color); - //Bot - Utils.DrawLine( - this.Position.X + this.mWidth - 11, - this.Position.Y + 3, - this.Position.X + this.mWidth - 11, - this.Position.Y + this.mHeight - 3, - 1, - color); - //Right - } - - /// - /// Draws in Content of the AlphaSlider + /// Resets the Color /// - private void DrawContent() + private void ResetHslrgb() { switch (this.mEDrawStyle) { case EDrawStyle.Hue: - this.DrawStyleHue(); + this.mHsl.H = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Saturation: - this.DrawStyleSaturation(); + this.mHsl.S = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Brightness: - this.DrawStyleLuminance(); + this.mHsl.L = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); + this.mRgb = Utilities.HslToRgb(this.mHsl); break; case EDrawStyle.Red: - this.DrawStyleRed(); + this.mRgb = + Color.FromArgb( + 255 + - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), + this.mRgb.G, + this.mRgb.B); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Green: - this.DrawStyleGreen(); + this.mRgb = Color.FromArgb( + this.mRgb.R, + 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), + this.mRgb.B); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; case EDrawStyle.Blue: - this.DrawStyleBlue(); - + this.mRgb = Color.FromArgb( + this.mRgb.R, + this.mRgb.G, + 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d))))); + this.mHsl = Utilities.RgbToHsl(this.mRgb); break; } } /// - /// Draws the Arrows - /// - private void DrawSlider(int position, bool unconditional) - { - if (position < 0) - { - position = 0; - } - if (position > (this.mHeight - 9)) - { - position = (this.mHeight - 9); - } - - if (this.ArrowPos == position & !unconditional) - { - return; - } - - this.ArrowPos = position; - - ColorBGRA color = Color.FromArgb(4, 188, 252).ToSharpDxColor(); - - Utils.DrawBoxFilled(this.Position.X, this.Position.Y + position, 2, 7, color); - Utils.DrawBoxFilled(this.Position.X + 2, this.Position.Y + position + 1, 2, 5, color); - Utils.DrawBoxFilled(this.Position.X + 4, this.Position.Y + position + 2, 2, 3, color); - Utils.DrawBoxFilled(this.Position.X + 6, this.Position.Y + position + 3, 2, 1, color); - - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2, this.Position.Y + position, 2, 7, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 2, this.Position.Y + position + 1, 2, 5, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 4, this.Position.Y + position + 2, 2, 3, color); - Utils.DrawBoxFilled(this.Position.X + this.mWidth - 2 - 6, this.Position.Y + position + 3, 2, 1, color); - } - - /// - /// Resets the Arrows + /// Resets the Arrows /// /// Force Redraw private void ResetSlider(bool redraw) @@ -2210,68 +2222,18 @@ private void ResetSlider(bool redraw) } } - /// - /// Resets the Color - /// - private void ResetHslrgb() - { - switch (this.mEDrawStyle) - { - case EDrawStyle.Hue: - this.mHsl.H = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Saturation: - this.mHsl.S = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Brightness: - this.mHsl.L = 1.0 - Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)); - this.mRgb = Utilities.HslToRgb(this.mHsl); - - break; - case EDrawStyle.Red: - this.mRgb = - Color.FromArgb( - 255 - - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), - this.mRgb.G, - this.mRgb.B); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Green: - this.mRgb = Color.FromArgb( - this.mRgb.R, - 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d)))), - this.mRgb.B); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - - break; - case EDrawStyle.Blue: - this.mRgb = Color.FromArgb( - this.mRgb.R, - this.mRgb.G, - 255 - Convert.ToInt32(Math.Round(255d * Convert.ToDouble(this.ArrowPos / (this.mHeight - 9d))))); - this.mHsl = Utilities.RgbToHsl(this.mRgb); - break; - } - } - #endregion } /// - /// Adobe Color Utitlies for HSL + /// Adobe Color Utitlies for HSL /// public class AdobeColors { #region Public Methods and Operators /// - /// Modifies brightness of c by brightness + /// Modifies brightness of c by brightness /// /// /// @@ -2284,7 +2246,7 @@ public Color ModifyBrightness(Color c, double brightness) } /// - /// Modifies hue of c by hue + /// Modifies hue of c by hue /// /// /// @@ -2297,7 +2259,7 @@ public Color ModifyHue(Color c, double hue) } /// - /// Modifies saturation of c by saturation + /// Modifies saturation of c by saturation /// /// /// @@ -2310,41 +2272,38 @@ public Color ModifySaturation(Color c, double saturation) } /// - /// Sets brightness of c by brightness + /// Sets brightness of c by brightness /// /// /// /// New color public Color SetBrightness(Color c, double brightness) { - var hsl = new Hsl(); - hsl.L = brightness; + var hsl = new Hsl { L = brightness }; return Utilities.HslToRgb(hsl); } /// - /// Sets hue of c by hue + /// Sets hue of c by hue /// /// /// /// New color public Color SetHue(Color c, double hue) { - var hsl = new Hsl(); - hsl.H = hue; + var hsl = new Hsl { H = hue }; return Utilities.HslToRgb(hsl); } /// - /// Sets saturation of c by saturation + /// Sets saturation of c by saturation /// /// /// /// New color public Color SetSaturation(Color c, double saturation) { - var hsl = new Hsl(); - hsl.S = saturation; + var hsl = new Hsl { S = saturation }; return Utilities.HslToRgb(hsl); } @@ -2352,29 +2311,29 @@ public Color SetSaturation(Color c, double saturation) } /// - /// Color spectrum CMYK + /// Color spectrum CMYK /// public class Cmyk { #region Fields /// - /// Cyan + /// Cyan /// private double c; /// - /// Key plate (black) + /// Key plate (black) /// private double k; /// - /// Magenta + /// Magenta /// private double m; /// - /// Yellow + /// Yellow /// private double y; @@ -2383,7 +2342,7 @@ public class Cmyk #region Public Properties /// - /// Cyan + /// Cyan /// public double C { @@ -2406,7 +2365,7 @@ public double C } /// - /// Key plate (black) + /// Key plate (black) /// public double K { @@ -2429,7 +2388,7 @@ public double K } /// - /// Magenta + /// Magenta /// public double M { @@ -2452,7 +2411,7 @@ public double M } /// - /// Yellow + /// Yellow /// public double Y { @@ -2478,24 +2437,24 @@ public double Y } /// - /// Color spectrum HSL + /// Color spectrum HSL /// public class Hsl { #region Fields /// - /// Hue + /// Hue /// private double h; /// - /// Lightness + /// Lightness /// private double l; /// - /// Saturation + /// Saturation /// private double s; @@ -2504,7 +2463,7 @@ public class Hsl #region Public Properties /// - /// Hue + /// Hue /// public double H { @@ -2527,7 +2486,7 @@ public double H } /// - /// Lightness + /// Lightness /// public double L { @@ -2550,7 +2509,7 @@ public double L } /// - /// Saturation + /// Saturation /// public double S { @@ -2576,50 +2535,43 @@ public double S } /// - /// Color Utilities + /// Color Utilities /// internal static class Utilities { #region Public Methods and Operators /// - /// Converts the CMYK color format to RGB + /// Converts the CMYK color format to RGB /// /// /// Converted color public static Color CmykToRgb(Cmyk cmyk) { - var red = 0; - var green = 0; - var blue = 0; - // To convert CMYK to RGB we first have to convert CMYK to CMY var cyan = (cmyk.C * (1 - cmyk.K)) + cmyk.K; var magenta = (cmyk.M * (1 - cmyk.K)) + cmyk.K; var yellow = (cmyk.Y * (1 - cmyk.K)) + cmyk.K; - red = Convert.ToInt32(Math.Round(cyan * 255d)); - green = Convert.ToInt32(Math.Round(magenta * 255d)); - blue = Convert.ToInt32(Math.Round(yellow * 255d)); + var red = Convert.ToInt32(Math.Round(cyan * 255d)); + var green = Convert.ToInt32(Math.Round(magenta * 255d)); + var blue = Convert.ToInt32(Math.Round(yellow * 255d)); return Color.FromArgb(red, green, blue); } /// - /// Converts the HSL color format to RGB + /// Converts the HSL color format to RGB /// /// /// Converted color public static Color HslToRgb(Hsl hsl) { - var max = 0; - var min = 0; - var mid = 0; - double q = 0; + int mid; - max = Convert.ToInt32(Math.Round(hsl.L * 255d)); - min = Convert.ToInt32(Math.Round((1.0d - hsl.S) * (hsl.L / 1.0d) * 255d)); - q = Convert.ToDouble((max - min) / 255d); + var max = Convert.ToInt32(Math.Round(hsl.L * 255d)); + var min = Convert.ToInt32(Math.Round((1.0d - hsl.S) * (hsl.L / 1.0d) * 255d)); + var q = Convert.ToDouble((max - min) / 255d); if (hsl.H >= 0 & hsl.H <= (1d / 6d)) { @@ -2655,7 +2607,7 @@ public static Color HslToRgb(Hsl hsl) } /// - /// Converts the RGB color format to CMYK + /// Converts the RGB color format to CMYK /// /// /// Converted color @@ -2691,7 +2643,7 @@ public static Cmyk RgbToCmyk(Color c) } /// - /// Converts the RGB color format to HSL + /// Converts the RGB color format to HSL /// /// /// Converted color @@ -2699,10 +2651,8 @@ public static Hsl RgbToHsl(Color c) { var hsl = new Hsl(); - var max = 0; - var min = 0; - var diff = 0; - var sum = 0; + int max; + int min; // Of the RBG Values - assign the highest value to _Max and the lowest to _min if (c.R > c.G) @@ -2724,35 +2674,19 @@ public static Hsl RgbToHsl(Color c) min = c.B; } - diff = max - min; - sum = max + min; + var diff = max - min; // Luminance (aka Brightness) hsl.L = Convert.ToDouble(max / 255d); // Saturation - if (max == 0) - { - hsl.S = 0; - } - else - { - hsl.S = Convert.ToDouble(diff / (double)max); - } + hsl.S = max == 0 ? 0 : Convert.ToDouble(diff / (double)max); // Hue // R is situated at the angle of 360 eller noll degrees // G vid 120 degrees // B vid 240 degrees - double q = 0; - if (diff == 0) - { - q = 0; - } - else - { - q = Convert.ToDouble(60d / diff); - } + var q = diff == 0 ? 0 : Convert.ToDouble(60d / diff); if (max == Convert.ToInt32(c.R)) { @@ -2779,4 +2713,4 @@ public static Hsl RgbToHsl(Color c) #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Customizer/MenuCustomizer.cs b/Core/UI/IMenu/Customizer/MenuCustomizer.cs index 1753040..cce2db2 100644 --- a/Core/UI/IMenu/Customizer/MenuCustomizer.cs +++ b/Core/UI/IMenu/Customizer/MenuCustomizer.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Customizer +namespace LeagueSharp.SDK.UI { + using LeagueSharp.SDK.UI.Skins; + using SharpDX; using SharpDX.Direct3D9; - using Skins; - using Values; /// /// This menu allows the user to modify several properties in . diff --git a/Core/UI/IMenu/Menu.cs b/Core/UI/IMenu/Menu.cs index 70526d8..d4d1500 100644 --- a/Core/UI/IMenu/Menu.cs +++ b/Core/UI/IMenu/Menu.cs @@ -15,17 +15,18 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; - using Abstracts; - using Core.Utils; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; + using SharpDX; - using Skins; /// /// Menu Value Changed delegate diff --git a/Core/UI/IMenu/MenuItem.cs b/Core/UI/IMenu/MenuItem.cs index 8faeb87..f1490a0 100644 --- a/Core/UI/IMenu/MenuItem.cs +++ b/Core/UI/IMenu/MenuItem.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { using System; using System.Diagnostics.CodeAnalysis; @@ -24,8 +24,7 @@ namespace LeagueSharp.SDK.Core.UI.IMenu using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; - using Abstracts; - using Core.Utils; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -101,7 +100,7 @@ public override string Path { return System.IO.Path.Combine( - MenuManager.ConfigFolder.CreateSubdirectory(this.AssemblyName).FullName, + MenuManager.ConfigFolder.CreateSubdirectory(this.AssemblyName).FullName, fileName); } diff --git a/Core/UI/IMenu/MenuManager.cs b/Core/UI/IMenu/MenuManager.cs index 1992ac0..4b91842 100644 --- a/Core/UI/IMenu/MenuManager.cs +++ b/Core/UI/IMenu/MenuManager.cs @@ -15,17 +15,20 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Windows.Forms; - using Core.Utils; - using LeagueSharp.SDK; + + using LeagueSharp.Sandbox; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; + using SharpDX.Direct3D9; - using Skins; /// /// Menu Interface class, used to control the menu. @@ -39,7 +42,7 @@ public class MenuManager /// public static readonly DirectoryInfo ConfigFolder = Directory.CreateDirectory( - System.IO.Path.Combine( + Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "LS" + Environment.UserName.GetHashCode().ToString("X"), "MenuConfigSDK")); @@ -49,6 +52,16 @@ public class MenuManager /// public static readonly MenuManager Instance = new MenuManager(); + /// + /// The show menu hotkey + /// + private static Keys menuPressKeybind = Keys.None; + + /// + /// The show menu toggle hotkey + /// + private static Keys menuToggleKeybind = Keys.None; + #endregion #region Fields @@ -58,11 +71,6 @@ public class MenuManager /// private readonly Queue delayedDrawActions = new Queue(); - /// - /// The menus list. - /// - private readonly List menus = new List(); - /// /// The forced open. /// @@ -142,7 +150,7 @@ public bool ForcedOpen /// /// The menus. /// - public List Menus => this.menus; + public List Menus { get; } = new List(); /// /// Gets or sets a value indicating whether the menu is visible. @@ -156,11 +164,10 @@ public bool MenuVisible { return this.menuVisible; } - set { this.menuVisible = value; - foreach (var menu in this.menus) + foreach (var menu in this.Menus) { menu.Visible = value; } @@ -174,23 +181,71 @@ public bool MenuVisible #endregion + #region Properties + + private static Keys MenuPressKeybind + { + get + { + if (menuPressKeybind == Keys.None) + { + try + { + menuPressKeybind = (Keys)SandboxConfig.MenuKey; + if (menuPressKeybind == Keys.None) + { + menuPressKeybind = Keys.ShiftKey; + } + menuPressKeybind = FixVirtualKey(menuPressKeybind); + } + catch + { + menuPressKeybind = Keys.ShiftKey; + } + } + + return menuPressKeybind; + } + } + + private static Keys MenuToggleKeybind + { + get + { + if (menuToggleKeybind == Keys.None) + { + try + { + menuToggleKeybind = (Keys)SandboxConfig.MenuToggleKey; + if (menuToggleKeybind == Keys.None) + { + menuToggleKeybind = Keys.F9; + } + menuToggleKeybind = FixVirtualKey(menuToggleKeybind); + } + catch + { + menuToggleKeybind = Keys.F9; + } + } + + return menuToggleKeybind; + } + } + + #endregion + #region Public Indexers /// /// Gets the with the specified name. /// /// - /// The . + /// The . /// /// The name. /// The requested menu - public Menu this[string name] - { - get - { - return this.menus.FirstOrDefault(menu => menu.Name.Equals(name)); - } - } + public Menu this[string name] => this.Menus.FirstOrDefault(menu => menu.Name.Equals(name)); #endregion @@ -202,9 +257,9 @@ public Menu this[string name] /// The menu. public void Add(Menu menu) { - if (!this.menus.Contains(menu)) + if (!this.Menus.Contains(menu)) { - this.menus.Add(menu); + this.Menus.Add(menu); } } @@ -248,6 +303,21 @@ protected virtual void FireOnOpen() this.OnOpen?.Invoke(this, EventArgs.Empty); } + private static Keys FixVirtualKey(Keys key) + { + switch (key) + { + case Keys.LShiftKey: + case Keys.RShiftKey: + return Keys.ShiftKey; + case Keys.LControlKey: + case Keys.RControlKey: + return Keys.ControlKey; + default: + return key; + } + } + /// /// OnUpdate event. /// @@ -315,9 +385,11 @@ private void Game_OnWndProc(WndEventArgs args) } var keys = new WindowsKeys(args); + if (!this.ForcedOpen) { - if (keys.SingleKey == Keys.ShiftKey || keys.Key == (Keys.Return | Keys.Shift)) + if (keys.SingleKey == MenuPressKeybind + || (MenuPressKeybind == Keys.ShiftKey && keys.Key == (Keys.Return | Keys.Shift))) { var keyDown = keys.Msg == WindowsMessages.KEYDOWN; var keyUp = keys.Msg == WindowsMessages.KEYUP || keys.Msg == WindowsMessages.CHAR; @@ -339,9 +411,10 @@ private void Game_OnWndProc(WndEventArgs args) } } } - else if (keys.SingleKey == Keys.CapsLock && keys.Msg == WindowsMessages.KEYDOWN) + else if (keys.SingleKey == MenuToggleKeybind && keys.Msg == WindowsMessages.KEYDOWN) { this.MenuVisible = !this.MenuVisible; + if (this.MenuVisible) { this.FireOnOpen(); @@ -353,7 +426,7 @@ private void Game_OnWndProc(WndEventArgs args) } } - foreach (var component in this.menus) + foreach (var component in this.Menus) { component.OnWndProc(keys); } @@ -364,7 +437,7 @@ private void Game_OnWndProc(WndEventArgs args) /// private void SaveSettings() { - foreach (var menu in this.menus) + foreach (var menu in this.Menus) { try { diff --git a/Core/UI/IMenu/MenuValueChangedEventArgs.cs b/Core/UI/IMenu/MenuValueChangedEventArgs.cs index 5cad086..cb78f65 100644 --- a/Core/UI/IMenu/MenuValueChangedEventArgs.cs +++ b/Core/UI/IMenu/MenuValueChangedEventArgs.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { using System; diff --git a/Core/UI/IMenu/RadioMenu.cs b/Core/UI/IMenu/RadioMenu.cs index 437602c..f02ceb3 100644 --- a/Core/UI/IMenu/RadioMenu.cs +++ b/Core/UI/IMenu/RadioMenu.cs @@ -15,12 +15,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu +namespace LeagueSharp.SDK.UI { using System; - using Values; - /// /// RadioMenu Item. /// diff --git a/Core/UI/IMenu/Skins/ADrawable.cs b/Core/UI/IMenu/Skins/ADrawable.cs index c9f3549..d26cf48 100644 --- a/Core/UI/IMenu/Skins/ADrawable.cs +++ b/Core/UI/IMenu/Skins/ADrawable.cs @@ -15,10 +15,9 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins +namespace LeagueSharp.SDK.UI.Skins { - using Abstracts; - using Core.Utils; + using LeagueSharp.SDK.Utils; /// /// Defines a handler which is responsible for the drawing and interactions of an . diff --git a/Core/UI/IMenu/Skins/ADrawableAdapter.cs b/Core/UI/IMenu/Skins/ADrawableAdapter.cs index ce82691..236e04d 100644 --- a/Core/UI/IMenu/Skins/ADrawableAdapter.cs +++ b/Core/UI/IMenu/Skins/ADrawableAdapter.cs @@ -15,10 +15,9 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins +namespace LeagueSharp.SDK.UI.Skins { - using Abstracts; - using Core.Utils; + using LeagueSharp.SDK.Utils; /// /// Provides an implementation of that does nothing. This is used to prevent exceptions when diff --git a/Core/UI/IMenu/Skins/Blue/BlueBool.cs b/Core/UI/IMenu/Skins/Blue/BlueBool.cs index 12ff09e..2597c9b 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueBool.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueBool.cs @@ -19,11 +19,11 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,7 +67,7 @@ public BlueBool(MenuBool component) public Rectangle ButtonBoundaries(MenuBool component) { return new Rectangle( - (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), + (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), (int)component.Position.Y, MenuSettings.ContainerHeight, MenuSettings.ContainerHeight); @@ -89,13 +89,17 @@ public override void Draw() var centerY = (int) BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -106,31 +110,31 @@ public override void Draw() { new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1) - + MenuSettings.ContainerHeight / 2f, - this.Component.Position.Y + 1 + 3), + + MenuSettings.ContainerHeight / 2f, + this.Component.Position.Y + 1 + 3), new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1) - + MenuSettings.ContainerHeight / 2f, + + MenuSettings.ContainerHeight / 2f, this.Component.Position.Y + MenuSettings.ContainerHeight - 3) - }, + }, this.Component.Value ? new ColorBGRA(0, 186, 255, 255) : new ColorBGRA(36, 36, 36, 255)); Line.End(); var centerX = (int) new Rectangle( - (int)(this.Component.Position.X + this.Component.MenuWidth - 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.Value ? "On" : "Off", + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.Value ? "On" : "Off"), CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value ? "On" : "Off", - centerX, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.Value ? "On" : "Off"), + centerX, centerY, this.Component.Value ? new ColorBGRA(0, 27, 41, 255) : MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Blue/BlueButton.cs b/Core/UI/IMenu/Skins/Blue/BlueButton.cs index 3b0d93d..408ace9 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueButton.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueButton.cs @@ -19,11 +19,11 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -94,8 +94,8 @@ public Rectangle ButtonBoundaries(MenuButton component) var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, component.ButtonText, 0).Width; return new Rectangle( - (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), - (int)component.Position.Y, + (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), + (int)component.Position.Y, (2 * TextGap) + buttonTextWidth, MenuSettings.ContainerHeight); } @@ -114,12 +114,16 @@ public override void Dispose() public override void Draw() { var rectangleName = BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -146,19 +150,19 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( - this.Component.Position.X + this.Component.MenuWidth - 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), - }, + this.Component.Position.X + this.Component.MenuWidth - 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + }, this.Component.Hovering ? this.buttonHoverColor : this.buttonColor); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.ButtonText, - (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.ButtonText), + (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), (int)rectangleName.Y, MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Blue/BlueColorPicker.cs b/Core/UI/IMenu/Skins/Blue/BlueColorPicker.cs index 7d83162..d616b85 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueColorPicker.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueColorPicker.cs @@ -19,21 +19,20 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Rectangle = SharpDX.Rectangle; - using Utilities = LeagueSharp.SDK.Core.UI.IMenu.Utilities; + using Utilities = LeagueSharp.SDK.UI.Utilities; internal class BlueColorPicker : ADrawable { @@ -130,17 +129,17 @@ internal class BlueColorPicker : ADrawable /// /// The ColorBox to display the color spectrum. /// - protected ColorBox colorBox; + protected ColorBox ColorBox; /// /// The VerticalAlphaSlider to change the opacity. /// - protected VerticalAlphaSlider verticalAlphaSlider; + protected VerticalAlphaSlider VerticalAlphaSlider; /// /// The VerticalColorSlider to change the color spectrum. /// - protected VerticalColorSlider verticalColorSlider; + protected VerticalColorSlider VerticalColorSlider; #endregion @@ -156,27 +155,27 @@ public BlueColorPicker(MenuColor component) : base(component) { Hsl tempHsl; - this.colorBox = new ColorBox(new Size(200, 200), true) + this.ColorBox = new ColorBox(new Size(200, 200), true) { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) + this.VerticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider.ColorSliderScroll += () => + this.VerticalColorSlider.ColorSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.H = this.verticalColorSlider.CbHsl.H; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.H = this.VerticalColorSlider.CbHsl.H; + this.ColorBox.Hsl = tempHsl; }; - this.verticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); - tempHsl = this.verticalAlphaSlider.CbHsl; - tempHsl.L = this.colorBox.Hsl.L; - this.verticalAlphaSlider.CbHsl = tempHsl; - this.verticalAlphaSlider.AlphaSliderScroll += () => + this.VerticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); + tempHsl = this.VerticalAlphaSlider.CbHsl; + tempHsl.L = this.ColorBox.Hsl.L; + this.VerticalAlphaSlider.CbHsl = tempHsl; + this.VerticalAlphaSlider.AlphaSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.L = this.verticalAlphaSlider.CbHsl.L; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.L = this.VerticalAlphaSlider.CbHsl.L; + this.ColorBox.Hsl = tempHsl; }; } @@ -217,11 +216,15 @@ public override void Dispose() public override void Draw() { var rectangleName = BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -247,11 +250,11 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + 1 + 3), - new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + Line.Width + 3) + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + 1 + 3), + new Vector2( + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); @@ -262,87 +265,100 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - Line.Width = ColorPickerBoundaries().Width; + Line.Width = this.ColorPickerBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), + new Vector2(this.ColorPickerBoundaries().X + 165, this.ColorPickerBoundaries().Y), new Vector2( - ColorPickerBoundaries().X + 165, - ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) + this.ColorPickerBoundaries().X + 165, + this.ColorPickerBoundaries().Y + this.ColorPickerBoundaries().Height) }, MenuSettings.RootContainerColor); Line.End(); - colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); - verticalColorSlider.DrawControl( - new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); - verticalAlphaSlider.DrawControl( - new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); + this.ColorBox.DrawControl( + new Vector2(this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y)); + this.VerticalColorSlider.DrawControl( + new Vector2( + this.VerticalColorSliderBoundaries().X, + this.VerticalColorSliderBoundaries().Y)); + this.VerticalAlphaSlider.DrawControl( + new Vector2( + this.VerticalAlphaSliderBoundaries().X, + this.VerticalAlphaSliderBoundaries().Y)); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, Color.Black); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - colorBox.Rgb.ToSharpDxColor()); + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + this.ColorBox.Rgb.ToSharpDxColor()); var applyButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; var cancelButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; - Line.Width = ApplyButtonBoundaries().Width; + Line.Width = this.ApplyButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), + new Vector2(this.ApplyButtonBoundaries().X + 25, this.ApplyButtonBoundaries().Y), new Vector2( - ApplyButtonBoundaries().X + 25, - ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) + this.ApplyButtonBoundaries().X + 25, + this.ApplyButtonBoundaries().Y + this.ApplyButtonBoundaries().Height) }, new ColorBGRA(4, 187, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Apply", - ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Apply"), + this.ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Apply"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(0, 27, 41, 255)); - Line.Width = CancelButtonBoundaries().Width; + Line.Width = this.CancelButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), + new Vector2(this.CancelButtonBoundaries().X + 25, this.CancelButtonBoundaries().Y), new Vector2( - CancelButtonBoundaries().X + 25, - CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) + this.CancelButtonBoundaries().X + 25, + this.CancelButtonBoundaries().Y + this.CancelButtonBoundaries().Height) }, new ColorBGRA(4, 187, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Cancel", - CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Cancel"), + this.CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Cancel"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(0, 27, 41, 255)); }); @@ -376,15 +392,15 @@ public override void OnWndProc(WindowsKeys args) { if (this.InteractingColorBox) { - this.colorBox.ColorBoxMouseMove(args); + this.ColorBox.ColorBoxMouseMove(args); } else if (this.InteractingVerticalColorSlider) { - this.verticalColorSlider.VerticalColorSlider_MouseMove(args); + this.VerticalColorSlider.VerticalColorSliderMouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { - this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseMove(args); } } } @@ -394,17 +410,17 @@ public override void OnWndProc(WindowsKeys args) if (this.InteractingColorBox) { this.InteractingColorBox = false; - this.colorBox.ColorBoxMouseUp(args); + this.ColorBox.ColorBoxMouseUp(args); } if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; - this.verticalColorSlider.VerticalColorSlider_MouseUp(args); + this.VerticalColorSlider.VerticalColorSliderMouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseUp(args); } } @@ -424,7 +440,7 @@ public override void OnWndProc(WindowsKeys args) this.ColorBoxBoundaries().Height)) { this.InteractingColorBox = true; - this.colorBox.ColorBoxMouseDown(args); + this.ColorBox.ColorBoxMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalColorSliderBoundaries().X, @@ -433,7 +449,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; - this.verticalColorSlider.VerticalColorSlider_MouseDown(args); + this.VerticalColorSlider.VerticalColorSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, @@ -442,7 +458,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, @@ -451,7 +467,7 @@ public override void OnWndProc(WindowsKeys args) this.ApplyButtonBoundaries().Height)) { this.Component.Active = false; - this.Component.Color = this.colorBox.Rgb.ToSharpDxColor(); + this.Component.Color = this.ColorBox.Rgb.ToSharpDxColor(); } else if (args.Cursor.IsUnderRectangle( this.CancelButtonBoundaries().X, @@ -460,9 +476,9 @@ public override void OnWndProc(WindowsKeys args) this.CancelButtonBoundaries().Height)) { this.Component.Active = false; - this.colorBox.Rgb = this.Component.Color.ToSystemColor(); - this.verticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); - this.verticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); + this.ColorBox.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); } } else if (args.Cursor.IsUnderRectangle( diff --git a/Core/UI/IMenu/Skins/Blue/BlueKeyBind.cs b/Core/UI/IMenu/Skins/Blue/BlueKeyBind.cs index aa90a4d..7f45092 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueKeyBind.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueKeyBind.cs @@ -20,13 +20,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue +namespace LeagueSharp.SDK.UI.Skins.Blue { using System.Windows.Forms; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -92,11 +91,15 @@ public override void Draw() var centerY = (int) BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + MultiLanguage.Translation(this.Component.Interacting ? "Press a key" : this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -140,11 +143,11 @@ public override void Draw() MenuSettings.ContainerHeight).GetCenteredText( null, MenuSettings.Font, - this.Component.Active ? "On" : "Off", + MultiLanguage.Translation(this.Component.Active ? "On" : "Off"), CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Active ? "On" : "Off", + MultiLanguage.Translation(this.Component.Active ? "On" : "Off"), centerX, centerY, this.Component.Active ? new ColorBGRA(0, 27, 41, 255) : MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Blue/BlueList.cs b/Core/UI/IMenu/Skins/Blue/BlueList.cs index f88817a..5dc00e9 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueList.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueList.cs @@ -19,13 +19,13 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -102,27 +102,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor); Line.Width = 1f; @@ -157,22 +161,23 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - (Line.Width / 2), + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), + position.X + this.Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight) - }, dropdownColor); + }, + dropdownColor); Line.End(); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -180,11 +185,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -198,49 +203,49 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( - position.X + Component.MenuWidth - 10, + position.X + this.Component.MenuWidth - 10, position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(valueStrings[i]), + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } } - Line.Width = 1f; - Line.Begin(); - Line.Draw( + Line.Width = 1f; + Line.Begin(); + Line.Draw( new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -260,8 +265,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -277,9 +282,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -297,8 +302,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -337,9 +342,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -352,9 +357,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Blue/BlueMenu.cs b/Core/UI/IMenu/Skins/Blue/BlueMenu.cs index 800eec4..b16f5fd 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueMenu.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueMenu.cs @@ -19,28 +19,22 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class BlueMenu : ADrawable { - #region Constants - - #endregion - #region Static Fields /// @@ -51,7 +45,7 @@ public class BlueMenu : ADrawable #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -93,7 +87,6 @@ public class BlueMenu : ADrawable public BlueMenu(Menu component) : base(component) { - } #endregion @@ -120,9 +113,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -136,19 +129,19 @@ public override void Draw() .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - "»", + MenuManager.Instance.Sprite, + "»", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - - MenuSettings.ContainerTextMarkOffset), - centerY, + - MenuSettings.ContainerTextMarkOffset), + centerY, this.Component.Components.Count > 0 ? MenuSettings.TextColor : MenuSettings.ContainerSeparatorColor); if (this.Component.Toggled) @@ -158,9 +151,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), + new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), new Vector2( - position.X + this.Component.MenuWidth / 2f, + position.X + this.Component.MenuWidth / 2f, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSelectedColor); @@ -178,21 +171,19 @@ public override void Draw() Line.Draw( new[] { - new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), + new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height) }, MenuSettings.RootContainerColor); Line.End(); - - for (var i = 0; i < this.Component.Components.Count; ++i) { var childComponent = this.Component.Components.Values.ToList()[i]; if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); if (i < this.Component.Components.Count - 1) @@ -202,9 +193,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight), + new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight), new Vector2( - childPos.X - 15 + childComponent.MenuWidth, + childPos.X - 15 + childComponent.MenuWidth, childPos.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -222,33 +213,32 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y + height), + new Vector2(position.X + this.Component.MenuWidth, position.Y + height), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth + width, position.Y), + new Vector2(position.X + this.Component.MenuWidth + width, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.End(); - } if (this.hasDragged && !MenuCustomizer.Instance.LockPosition.Value) @@ -268,9 +258,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -287,13 +277,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -333,7 +327,7 @@ public override int Width() { return (int) - (BlueUtilities.MeasureString(this.Component.DisplayName + " »").Width + (BlueUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " »").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Blue/BlueMenuSettings.cs b/Core/UI/IMenu/Skins/Blue/BlueMenuSettings.cs index 6cd5174..4fb1ed3 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueMenuSettings.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueMenuSettings.cs @@ -22,9 +22,8 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue +namespace LeagueSharp.SDK.UI.Skins.Blue { - using SharpDX; using SharpDX.Direct3D9; @@ -66,7 +65,7 @@ static BlueMenuSettings() FontQuality.ClearType, FontPitchAndFamily.DontCare | FontPitchAndFamily.Decorative | FontPitchAndFamily.Modern, "Tahoma"); - + TextCaptionColor = new ColorBGRA(0, 185, 252, 255); KeyBindColor = new ColorBGRA(5, 168, 235, 255); SliderColor = new ColorBGRA(0, 75, 101, 255); @@ -93,11 +92,6 @@ public static Font FontCaption } } - /// - /// Gets or sets the Global Text Caption Color. - /// - public static ColorBGRA TextCaptionColor { get; set; } - /// /// Gets or sets the Global KeyBind Color. /// @@ -108,6 +102,11 @@ public static Font FontCaption /// public static ColorBGRA SliderColor { get; set; } + /// + /// Gets or sets the Global Text Caption Color. + /// + public static ColorBGRA TextCaptionColor { get; set; } + #endregion #region Public Methods and Operators @@ -117,10 +116,8 @@ public static Font FontCaption /// public static void LoadSettings() { - } #endregion - } } \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Blue/BlueSeparator.cs b/Core/UI/IMenu/Skins/Blue/BlueSeparator.cs index 139702c..829449a 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueSeparator.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueSeparator.cs @@ -19,11 +19,11 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Implements as a default skin. @@ -64,12 +64,12 @@ public override void Draw() .GetCenteredText( null, BlueMenuSettings.FontCaption, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); BlueMenuSettings.FontCaption.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)centerY.X, (int)centerY.Y, BlueMenuSettings.TextCaptionColor); diff --git a/Core/UI/IMenu/Skins/Blue/BlueSlider.cs b/Core/UI/IMenu/Skins/Blue/BlueSlider.cs index 43de56a..9bf0f9c 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueSlider.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueSlider.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -104,7 +104,11 @@ public override void Draw() var centeredY = (int) BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.Value - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -113,25 +117,25 @@ public override void Draw() Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(0, 39, 54, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), + MenuManager.Instance.Sprite, + this.Component.Value.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), centeredY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Blue/BlueSliderButton.cs b/Core/UI/IMenu/Skins/Blue/BlueSliderButton.cs index bf244b3..7a1673d 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueSliderButton.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueSliderButton.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,20 +67,6 @@ public BlueSliderButton(MenuSliderButton component) #region Public Methods and Operators - /// - /// Returns the Rectangle that defines the Slider - /// - /// The - /// The - public Rectangle SliderBoundaries(MenuSliderButton component) - { - return new Rectangle( - (int)component.Position.X + Offset, - (int)component.Position.Y, - component.MenuWidth - MenuSettings.ContainerHeight - Offset, - MenuSettings.ContainerHeight); - } - /// /// Returns the Rectangle that defines the on/off Button /// @@ -114,34 +100,39 @@ public override void Draw() var centeredY = (int) BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(0, 39, 54, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), centeredY, MenuSettings.TextColor); @@ -188,7 +179,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.BValue ? "On" : "Off", + MultiLanguage.Translation(this.Component.BValue ? "ON" : "OFF"), centerX, centeredY, this.Component.BValue ? new ColorBGRA(0, 27, 41, 255) : MenuSettings.TextColor); @@ -236,6 +227,20 @@ public override void OnWndProc(WindowsKeys args) } } + /// + /// Returns the Rectangle that defines the Slider + /// + /// The + /// The + public Rectangle SliderBoundaries(MenuSliderButton component) + { + return new Rectangle( + (int)component.Position.X + Offset, + (int)component.Position.Y, + component.MenuWidth - MenuSettings.ContainerHeight - Offset, + MenuSettings.ContainerHeight); + } + /// /// Calculates the width of this component /// diff --git a/Core/UI/IMenu/Skins/Blue/BlueTextures.cs b/Core/UI/IMenu/Skins/Blue/BlueTextures.cs index ae9496d..2646b20 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueTextures.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueTextures.cs @@ -19,14 +19,15 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue +namespace LeagueSharp.SDK.UI.Skins.Blue { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum BlueTexture @@ -36,35 +37,58 @@ internal enum BlueTexture internal class BlueTextures { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly BlueTextures Instance = new BlueTextures(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private BlueTextures() { - this.textures[BlueTexture.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[BlueTexture.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~BlueTextures() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } - public BlueTextureWrapper this[BlueTexture textureType] + #endregion + + #region Public Indexers + + public BlueTextureWrapper this[BlueTexture textureType] => this.textures[textureType]; + + #endregion + + #region Public Methods and Operators + + public BlueTextureWrapper AddTexture(Image bmp, int width, int height, BlueTexture textureType) { - get - { - return this.textures[textureType]; - } + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; } + #endregion + + #region Methods + private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -81,19 +105,12 @@ private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) return new BlueTextureWrapper(texture, width, height); } - public BlueTextureWrapper AddTexture(Image bmp, int width, int height, BlueTexture textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class BlueTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public BlueTextureWrapper(Texture texture, int width, int height) { @@ -101,6 +118,17 @@ public BlueTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Blue/BlueTheme.cs b/Core/UI/IMenu/Skins/Blue/BlueTheme.cs index 4fd8025..17cfb11 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueTheme.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueTheme.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue + +namespace LeagueSharp.SDK.UI.Skins.Blue { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new BlueSlider(component); + return new BlueSliderButton(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new BlueSliderButton(component); + return new BlueSlider(component); } /// @@ -166,7 +165,7 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X + (width / 2f), position.Y), + new Vector2(position.X + (width / 2f), position.Y), new Vector2(position.X + (width / 2), position.Y + height) }, MenuSettings.RootContainerColor); @@ -200,13 +199,12 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), - new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), + new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), + new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), new Vector2(position.X, position.Y) }, new ColorBGRA(21, 26, 45, 255)); Line.End(); - } #endregion diff --git a/Core/UI/IMenu/Skins/Blue/BlueUtilities.cs b/Core/UI/IMenu/Skins/Blue/BlueUtilities.cs index 509be98..254dca1 100644 --- a/Core/UI/IMenu/Skins/Blue/BlueUtilities.cs +++ b/Core/UI/IMenu/Skins/Blue/BlueUtilities.cs @@ -20,9 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue +namespace LeagueSharp.SDK.UI.Skins.Blue { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -40,7 +40,10 @@ public class BlueUtilities /// The width public static int CalcWidthItem(MenuItem menuItem) { - return (int)(MeasureString(menuItem.DisplayName).Width + (MenuSettings.ContainerTextOffset * 2)); + return + (int) + (MeasureString(MultiLanguage.Translation(menuItem.DisplayName)).Width + + (MenuSettings.ContainerTextOffset * 2)); } /// @@ -50,7 +53,7 @@ public static int CalcWidthItem(MenuItem menuItem) /// The public static int CalcWidthText(string text) { - return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, text, 0).Width; + return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, MultiLanguage.Translation(text), 0).Width; } /// @@ -65,9 +68,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/Blue2/BlueBool2.cs b/Core/UI/IMenu/Skins/Blue2/BlueBool2.cs index b134011..01a3d1c 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueBool2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueBool2.cs @@ -19,10 +19,11 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Blue; + using SharpDX.Direct3D9; /// diff --git a/Core/UI/IMenu/Skins/Blue2/BlueButton2.cs b/Core/UI/IMenu/Skins/Blue2/BlueButton2.cs index 616c304..a74dee6 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueButton2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueButton2.cs @@ -19,10 +19,10 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Blue; /// /// A default implementation of diff --git a/Core/UI/IMenu/Skins/Blue2/BlueColorPicker2.cs b/Core/UI/IMenu/Skins/Blue2/BlueColorPicker2.cs index 90ab627..d66a55e 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueColorPicker2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueColorPicker2.cs @@ -19,10 +19,10 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Blue; internal class BlueColorPicker2 : BlueColorPicker { @@ -37,7 +37,6 @@ internal class BlueColorPicker2 : BlueColorPicker public BlueColorPicker2(MenuColor component) : base(component) { - } #endregion diff --git a/Core/UI/IMenu/Skins/Blue2/BlueKeyBind2.cs b/Core/UI/IMenu/Skins/Blue2/BlueKeyBind2.cs index d6abc2d..b473e88 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueKeyBind2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueKeyBind2.cs @@ -20,10 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Blue; /// /// A default implementation of diff --git a/Core/UI/IMenu/Skins/Blue2/BlueList2.cs b/Core/UI/IMenu/Skins/Blue2/BlueList2.cs index 0ddf6b0..4f9e421 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueList2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueList2.cs @@ -19,14 +19,14 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Blue; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -103,27 +103,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = BlueUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor); Line.Width = 1f; @@ -158,22 +162,23 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - (Line.Width / 2), + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), + position.X + this.Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight) - }, dropdownColor); + }, + dropdownColor); Line.End(); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -181,11 +186,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -199,49 +204,49 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( - position.X + Component.MenuWidth - 10, + position.X + this.Component.MenuWidth - 10, position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + valueStrings[i], + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } } - Line.Width = 1f; - Line.Begin(); - Line.Draw( + Line.Width = 1f; + Line.Begin(); + Line.Draw( new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -261,8 +266,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -278,9 +283,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -298,8 +303,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -338,9 +343,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -353,9 +358,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Blue2/BlueMenu2.cs b/Core/UI/IMenu/Skins/Blue2/BlueMenu2.cs index cadce52..d5134a7 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueMenu2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueMenu2.cs @@ -19,29 +19,23 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Blue; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class BlueMenu2 : BlueMenu { - #region Constants - - #endregion - #region Static Fields /// @@ -52,7 +46,7 @@ public class BlueMenu2 : BlueMenu #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -94,7 +88,6 @@ public class BlueMenu2 : BlueMenu public BlueMenu2(Menu component) : base(component) { - } #endregion @@ -121,9 +114,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -137,19 +130,19 @@ public override void Draw() .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u25B6", + "\u25B6", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - - MenuSettings.ContainerTextMarkOffset), - centerY, + - MenuSettings.ContainerTextMarkOffset), + centerY, this.Component.Components.Count > 0 ? MenuSettings.TextColor : MenuSettings.ContainerSeparatorColor); if (this.Component.Toggled) @@ -159,9 +152,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), + new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), new Vector2( - position.X + this.Component.MenuWidth / 2f, + position.X + this.Component.MenuWidth / 2f, position.Y + MenuSettings.ContainerHeight) }, BlueMenuSettings2.ContainerSelectedColor); @@ -179,21 +172,19 @@ public override void Draw() Line.Draw( new[] { - new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), + new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height) }, MenuSettings.RootContainerColor); Line.End(); - - for (var i = 0; i < this.Component.Components.Count; ++i) { var childComponent = this.Component.Components.Values.ToList()[i]; if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); childComponent.OnDraw(childPos); @@ -207,33 +198,32 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y + height), + new Vector2(position.X + this.Component.MenuWidth, position.Y + height), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth + width, position.Y), + new Vector2(position.X + this.Component.MenuWidth + width, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.End(); - } if (this.hasDragged && !MenuCustomizer.Instance.LockPosition.Value) @@ -253,9 +243,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -272,13 +262,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -318,7 +312,7 @@ public override int Width() { return (int) - (BlueUtilities.MeasureString(this.Component.DisplayName + " \u25B6").Width + (BlueUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " \u25B6").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Blue2/BlueMenuSettings2.cs b/Core/UI/IMenu/Skins/Blue2/BlueMenuSettings2.cs index 70680cd..30e7d06 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueMenuSettings2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueMenuSettings2.cs @@ -22,9 +22,9 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; + using LeagueSharp.SDK.UI.Skins.Blue; using SharpDX; @@ -46,11 +46,15 @@ static BlueMenuSettings2() #endregion + #region Public Properties + /// /// Gets or sets the Global Container Selected Color. /// public static ColorBGRA ContainerSelectedColor { get; set; } + #endregion + #region Public Methods and Operators /// @@ -62,6 +66,5 @@ public static void LoadSettings() } #endregion - } } \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Blue2/BlueSeparator2.cs b/Core/UI/IMenu/Skins/Blue2/BlueSeparator2.cs index 2d1d55f..0efa42c 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueSeparator2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueSeparator2.cs @@ -19,11 +19,11 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Blue; /// /// Implements as a default skin. @@ -55,15 +55,15 @@ public override void Draw() var centerY = BlueUtilities.GetContainerRectangle(this.Component) .GetCenteredText( null, - BlueMenuSettings.FontCaption, - this.Component.DisplayName.ToUpper(), + BlueMenuSettings.FontCaption, + this.Component.DisplayName.ToUpper(), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); BlueMenuSettings.FontCaption.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName.ToUpper(), - (int)centerY.X, - (int)centerY.Y, + MenuManager.Instance.Sprite, + this.Component.DisplayName.ToUpper(), + (int)centerY.X, + (int)centerY.Y, BlueMenuSettings.TextCaptionColor); } diff --git a/Core/UI/IMenu/Skins/Blue2/BlueSlider2.cs b/Core/UI/IMenu/Skins/Blue2/BlueSlider2.cs index fc6b106..ef6b44c 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueSlider2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueSlider2.cs @@ -19,13 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Blue; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -84,25 +85,25 @@ public override void Draw() Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(0, 74, 103, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.Value.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), centeredY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Blue2/BlueSliderButton2.cs b/Core/UI/IMenu/Skins/Blue2/BlueSliderButton2.cs index 787b838..75fb344 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueSliderButton2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueSliderButton2.cs @@ -19,13 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Blue; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -81,30 +82,31 @@ public override void Draw() .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(0, 74, 103, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SValue.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), centeredY, MenuSettings.TextColor); @@ -151,7 +153,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.BValue ? "On" : "Off", + MultiLanguage.Translation(this.Component.BValue ? "On" : "Off"), centerX, centeredY, this.Component.BValue ? new ColorBGRA(0, 27, 41, 255) : MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Blue2/BlueTextures2.cs b/Core/UI/IMenu/Skins/Blue2/BlueTextures2.cs index 35e45ae..1db02ba 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueTextures2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueTextures2.cs @@ -20,14 +20,14 @@ // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; - -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 +namespace LeagueSharp.SDK.UI.Skins.Blue2 { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum BlueTexture2 @@ -37,35 +37,58 @@ internal enum BlueTexture2 internal class BlueTextures2 { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly BlueTextures2 Instance = new BlueTextures2(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private BlueTextures2() { - this.textures[BlueTexture2.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[BlueTexture2.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~BlueTextures2() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } - public BlueTextureWrapper this[BlueTexture2 textureType] + #endregion + + #region Public Indexers + + public BlueTextureWrapper this[BlueTexture2 textureType] => this.textures[textureType]; + + #endregion + + #region Public Methods and Operators + + public BlueTextureWrapper AddTexture(Image bmp, int width, int height, BlueTexture2 textureType) { - get - { - return this.textures[textureType]; - } + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; } + #endregion + + #region Methods + private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -82,19 +105,12 @@ private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) return new BlueTextureWrapper(texture, width, height); } - public BlueTextureWrapper AddTexture(Image bmp, int width, int height, BlueTexture2 textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class BlueTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public BlueTextureWrapper(Texture texture, int width, int height) { @@ -102,6 +118,17 @@ public BlueTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Blue2/BlueTheme2.cs b/Core/UI/IMenu/Skins/Blue2/BlueTheme2.cs index cf385ae..e333a28 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueTheme2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueTheme2.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 + +namespace LeagueSharp.SDK.UI.Skins.Blue2 { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new BlueSlider2(component); + return new BlueSliderButton2(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new BlueSliderButton2(component); + return new BlueSlider2(component); } /// @@ -166,7 +165,7 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X + (width / 2f), position.Y), + new Vector2(position.X + (width / 2f), position.Y), new Vector2(position.X + (width / 2), position.Y + height) }, MenuSettings.RootContainerColor); @@ -200,13 +199,12 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), - new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), + new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), + new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), new Vector2(position.X, position.Y) }, new ColorBGRA(21, 26, 45, 255)); Line.End(); - } #endregion diff --git a/Core/UI/IMenu/Skins/Blue2/BlueUtilities2.cs b/Core/UI/IMenu/Skins/Blue2/BlueUtilities2.cs index 19e9c78..20b5ab0 100644 --- a/Core/UI/IMenu/Skins/Blue2/BlueUtilities2.cs +++ b/Core/UI/IMenu/Skins/Blue2/BlueUtilities2.cs @@ -20,10 +20,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Blue2 +namespace LeagueSharp.SDK.UI.Skins.Blue2 { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using SharpDX; /// @@ -65,9 +63,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/Colored/ColoredBool.cs b/Core/UI/IMenu/Skins/Colored/ColoredBool.cs index 2088011..1edf767 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredBool.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredBool.cs @@ -19,11 +19,11 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,7 +67,7 @@ public ColoredBool(MenuBool component) public Rectangle ButtonBoundaries(MenuBool component) { return new Rectangle( - (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), + (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), (int)component.Position.Y, MenuSettings.ContainerHeight, MenuSettings.ContainerHeight); @@ -89,33 +89,53 @@ public override void Draw() var centerY = (int) ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); var centerX = (int) new Rectangle( - (int)(this.Component.Position.X + this.Component.MenuWidth - 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.Value ? "On" : "Off", + null, + MenuSettings.Font, + this.Component.Value ? "On" : "Off", CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Top Line.Width = 1; @@ -142,8 +162,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.Value ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.Value ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.Value ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Colored/ColoredButton.cs b/Core/UI/IMenu/Skins/Colored/ColoredButton.cs index d4628bb..f6127cd 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredButton.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredButton.cs @@ -19,14 +19,13 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; - using SharpDX.Direct3D9; /// /// A default implementation of @@ -42,15 +41,6 @@ public class ColoredButton : ADrawable #endregion - #region Static Fields - - /// - /// The line. - /// - private static readonly Line Line = new Line(Drawing.Direct3DDevice) { GLLines = true }; - - #endregion - #region Fields /// @@ -58,11 +48,6 @@ public class ColoredButton : ADrawable /// private readonly ColorBGRA buttonColor = new ColorBGRA(203, 203, 203, 255); - /// - /// The button hover color. - /// - private readonly ColorBGRA buttonHoverColor = new ColorBGRA(171, 171, 171, 200); - #endregion #region Constructors and Destructors @@ -94,8 +79,8 @@ public Rectangle ButtonBoundaries(MenuButton component) var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, component.ButtonText, 0).Width; return new Rectangle( - (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), - (int)component.Position.Y, + (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), + (int)component.Position.Y, (2 * TextGap) + buttonTextWidth, MenuSettings.ContainerHeight); } @@ -114,29 +99,37 @@ public override void Dispose() public override void Draw() { var rectangleName = ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, this.Component.ButtonText, 0).Width; - Utils.DrawBoxRounded(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, + Utils.DrawBoxRounded( + this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, this.Component.Position.Y + (MenuSettings.ContainerHeight / 8f), - (this.Component.Position.X + this.Component.MenuWidth - 2) - (this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2), - MenuSettings.ContainerHeight - 5, 8, true, - this.Component.Hovering ? MenuSettings.ContainerSelectedColor : this.buttonColor, + (this.Component.Position.X + this.Component.MenuWidth - 2) + - (this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2), + MenuSettings.ContainerHeight - 5, + 8, + true, + this.Component.Hovering ? MenuSettings.ContainerSelectedColor : this.buttonColor, this.Component.Hovering ? MenuSettings.ContainerSelectedColor : this.buttonColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.ButtonText, - (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.ButtonText), + (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), (int)rectangleName.Y, MenuSettings.TextColor); } @@ -159,9 +152,9 @@ public override void OnWndProc(WindowsKeys args) if (args.Cursor.IsUnderRectangle(rect.X, rect.Y, rect.Width, rect.Height)) { this.Component.Hovering = true; - if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Action != null) + if (args.Msg == WindowsMessages.LBUTTONDOWN) { - this.Component.Action(); + this.Component.Action?.Invoke(); } } else diff --git a/Core/UI/IMenu/Skins/Colored/ColoredColorPicker.cs b/Core/UI/IMenu/Skins/Colored/ColoredColorPicker.cs index 20a047d..2989cec 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredColorPicker.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredColorPicker.cs @@ -19,21 +19,20 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Rectangle = SharpDX.Rectangle; - using Utilities = LeagueSharp.SDK.Core.UI.IMenu.Utilities; + using Utilities = LeagueSharp.SDK.UI.Utilities; internal class ColoredColorPicker : ADrawable { @@ -130,17 +129,17 @@ internal class ColoredColorPicker : ADrawable /// /// The ColorBox to display the color spectrum. /// - protected ColorBox colorBox; + protected ColorBox ColorBox; /// /// The VerticalAlphaSlider to change the opacity. /// - protected VerticalAlphaSlider verticalAlphaSlider; + protected VerticalAlphaSlider VerticalAlphaSlider; /// /// The VerticalColorSlider to change the color spectrum. /// - protected VerticalColorSlider verticalColorSlider; + protected VerticalColorSlider VerticalColorSlider; #endregion @@ -156,27 +155,27 @@ public ColoredColorPicker(MenuColor component) : base(component) { Hsl tempHsl; - this.colorBox = new ColorBox(new Size(200, 200), true) + this.ColorBox = new ColorBox(new Size(200, 200), true) { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) + this.VerticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider.ColorSliderScroll += () => + this.VerticalColorSlider.ColorSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.H = this.verticalColorSlider.CbHsl.H; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.H = this.VerticalColorSlider.CbHsl.H; + this.ColorBox.Hsl = tempHsl; }; - this.verticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); - tempHsl = this.verticalAlphaSlider.CbHsl; - tempHsl.L = this.colorBox.Hsl.L; - this.verticalAlphaSlider.CbHsl = tempHsl; - this.verticalAlphaSlider.AlphaSliderScroll += () => + this.VerticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); + tempHsl = this.VerticalAlphaSlider.CbHsl; + tempHsl.L = this.ColorBox.Hsl.L; + this.VerticalAlphaSlider.CbHsl = tempHsl; + this.VerticalAlphaSlider.AlphaSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.L = this.verticalAlphaSlider.CbHsl.L; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.L = this.VerticalAlphaSlider.CbHsl.L; + this.ColorBox.Hsl = tempHsl; }; } @@ -221,7 +220,7 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -247,11 +246,11 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + 1 + 3), - new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + Line.Width + 3) + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + 1 + 3), + new Vector2( + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); @@ -262,53 +261,58 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - Line.Width = ColorPickerBoundaries().Width; + Line.Width = this.ColorPickerBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), + new Vector2(this.ColorPickerBoundaries().X + 165, this.ColorPickerBoundaries().Y), new Vector2( - ColorPickerBoundaries().X + 165, - ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) + this.ColorPickerBoundaries().X + 165, + this.ColorPickerBoundaries().Y + this.ColorPickerBoundaries().Height) }, MenuSettings.RootContainerColor); Line.End(); - colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); - verticalColorSlider.DrawControl( - new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); - verticalAlphaSlider.DrawControl( - new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); + this.ColorBox.DrawControl( + new Vector2(this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y)); + this.VerticalColorSlider.DrawControl( + new Vector2( + this.VerticalColorSliderBoundaries().X, + this.VerticalColorSliderBoundaries().Y)); + this.VerticalAlphaSlider.DrawControl( + new Vector2( + this.VerticalAlphaSliderBoundaries().X, + this.VerticalAlphaSliderBoundaries().Y)); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, Color.Black); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - colorBox.Rgb.ToSharpDxColor()); + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + this.ColorBox.Rgb.ToSharpDxColor()); var applyButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; var cancelButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; - Line.Width = ApplyButtonBoundaries().Width; + Line.Width = this.ApplyButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), + new Vector2(this.ApplyButtonBoundaries().X + 25, this.ApplyButtonBoundaries().Y), new Vector2( - ApplyButtonBoundaries().X + 25, - ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) + this.ApplyButtonBoundaries().X + 25, + this.ApplyButtonBoundaries().Y + this.ApplyButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); @@ -316,22 +320,22 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "Apply", - ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, + this.ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() + this.CancelButtonBoundaries() .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); - Line.Width = CancelButtonBoundaries().Width; + Line.Width = this.CancelButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), + new Vector2(this.CancelButtonBoundaries().X + 25, this.CancelButtonBoundaries().Y), new Vector2( - CancelButtonBoundaries().X + 25, - CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) + this.CancelButtonBoundaries().X + 25, + this.CancelButtonBoundaries().Y + this.CancelButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); @@ -339,9 +343,9 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, "Cancel", - CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, + this.CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() + this.CancelButtonBoundaries() .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); @@ -376,15 +380,15 @@ public override void OnWndProc(WindowsKeys args) { if (this.InteractingColorBox) { - this.colorBox.ColorBoxMouseMove(args); + this.ColorBox.ColorBoxMouseMove(args); } else if (this.InteractingVerticalColorSlider) { - this.verticalColorSlider.VerticalColorSlider_MouseMove(args); + this.VerticalColorSlider.VerticalColorSliderMouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { - this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseMove(args); } } } @@ -394,17 +398,17 @@ public override void OnWndProc(WindowsKeys args) if (this.InteractingColorBox) { this.InteractingColorBox = false; - this.colorBox.ColorBoxMouseUp(args); + this.ColorBox.ColorBoxMouseUp(args); } if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; - this.verticalColorSlider.VerticalColorSlider_MouseUp(args); + this.VerticalColorSlider.VerticalColorSliderMouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseUp(args); } } @@ -424,7 +428,7 @@ public override void OnWndProc(WindowsKeys args) this.ColorBoxBoundaries().Height)) { this.InteractingColorBox = true; - this.colorBox.ColorBoxMouseDown(args); + this.ColorBox.ColorBoxMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalColorSliderBoundaries().X, @@ -433,7 +437,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; - this.verticalColorSlider.VerticalColorSlider_MouseDown(args); + this.VerticalColorSlider.VerticalColorSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, @@ -442,7 +446,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, @@ -451,7 +455,7 @@ public override void OnWndProc(WindowsKeys args) this.ApplyButtonBoundaries().Height)) { this.Component.Active = false; - this.Component.Color = this.colorBox.Rgb.ToSharpDxColor(); + this.Component.Color = this.ColorBox.Rgb.ToSharpDxColor(); } else if (args.Cursor.IsUnderRectangle( this.CancelButtonBoundaries().X, @@ -460,9 +464,9 @@ public override void OnWndProc(WindowsKeys args) this.CancelButtonBoundaries().Height)) { this.Component.Active = false; - this.colorBox.Rgb = this.Component.Color.ToSystemColor(); - this.verticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); - this.verticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); + this.ColorBox.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); } } else if (args.Cursor.IsUnderRectangle( diff --git a/Core/UI/IMenu/Skins/Colored/ColoredKeyBind.cs b/Core/UI/IMenu/Skins/Colored/ColoredKeyBind.cs index b9aeba6..eae3e0f 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredKeyBind.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredKeyBind.cs @@ -20,13 +20,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored +namespace LeagueSharp.SDK.UI.Skins.Colored { using System.Windows.Forms; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -96,7 +95,7 @@ public override void Draw() .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + MultiLanguage.Translation(this.Component.Interacting ? "Press a key" : this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -127,10 +126,26 @@ public override void Draw() CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Top Line.Width = 1; @@ -157,8 +172,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.Active ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.Active ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.Active ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Colored/ColoredList.cs b/Core/UI/IMenu/Skins/Colored/ColoredList.cs index b721a41..6e15276 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredList.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredList.cs @@ -19,13 +19,13 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -102,27 +102,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, this.Component.Active ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor); @@ -133,20 +137,24 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - var color = MenuSettings.RootContainerColor; - - Utils.DrawBoxRounded(position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + MenuSettings.ContainerHeight, - dropdownMenuWidth, dropdownMenuHeight, 4, true, - MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); + Utils.DrawBoxRounded( + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight, + dropdownMenuWidth, + dropdownMenuHeight, + 4, + true, + MenuSettings.RootContainerColor, + new ColorBGRA(55, 76, 95, 255)); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -154,11 +162,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -166,37 +174,38 @@ public override void Draw() Line.End(); } - if (i != 0) { + if (i != 0) + { Line.Width = 1f; Line.Begin(); Line.Draw( new[] { - new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), - new Vector2( - position.X + Component.MenuWidth - 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))) + new Vector2( + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), + new Vector2( + position.X + this.Component.MenuWidth - 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); } - + y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(valueStrings[i]), + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } @@ -216,8 +225,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -233,9 +242,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -253,8 +262,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -293,9 +302,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -308,9 +317,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Colored/ColoredMenu.cs b/Core/UI/IMenu/Skins/Colored/ColoredMenu.cs index 72bc145..c124e3f 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredMenu.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredMenu.cs @@ -19,28 +19,22 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class ColoredMenu : ADrawable { - #region Constants - - #endregion - #region Static Fields /// @@ -51,7 +45,7 @@ public class ColoredMenu : ADrawable #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -93,13 +87,180 @@ public class ColoredMenu : ADrawable public ColoredMenu(Menu component) : base(component) { - } #endregion #region Public Methods and Operators + /// + /// Draws a rounded Box. If Smoothing is true it will draw also a border. + /// + /// Position X + /// Position Y + /// Width + /// Height + /// Radius + /// Color + /// Border Color + public static void DrawBoxBotRounded( + float x, + float y, + float w, + float h, + float radius, + Color color, + Color bcolor) + { + Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. + Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. + Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. + Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. + Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. + + Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); + // Top-left corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + radius, + radius - 1, + 90, + Utils.CircleType.Quarter, + true, + 16, + color); // Top-right corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius - 1, + 180, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-right corner + Utils.DrawCircleFilled( + x + radius, + y + h - radius - 1, + radius - 1, + 270, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-left corner + + Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-left corner + Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-right corner + Utils.DrawCircle( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-right corner + Utils.DrawCircle( + x + radius + 1, + y + h - radius - 1, + radius, + 270, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-left corner + + Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line + Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line + Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line + Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line + } + + /// + /// Draws a rounded Box. If Smoothing is true it will draw also a border. + /// + /// Position X + /// Position Y + /// Width + /// Height + /// Radius + /// Color + /// Border Color + public static void DrawBoxTopRounded( + float x, + float y, + float w, + float h, + float radius, + Color color, + Color bcolor) + { + Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. + Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. + Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. + Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. + Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. + + Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); + // Top-left corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + radius, + radius - 1, + 90, + Utils.CircleType.Quarter, + true, + 16, + color); // Top-right corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius - 1, + 180, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-right corner + Utils.DrawCircleFilled( + x + radius, + y + h - radius - 1, + radius - 1, + 270, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-left corner + + Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-left corner + Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-right corner + Utils.DrawCircle( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-right corner + Utils.DrawCircle( + x + radius + 1, + y + h - radius - 1, + radius, + 270, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-left corner + + Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line + Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line + Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line + Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line + } + /// /// Disposes any resources used in this handler. /// @@ -120,9 +281,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -132,14 +293,18 @@ public override void Draw() var centerY = (int) ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; if (this.Component.Toggled) { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, new ColorBGRA(237, 245, 254, 255)); @@ -148,7 +313,7 @@ public override void Draw() { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -158,14 +323,18 @@ public override void Draw() delegate { var symbolCenterY = - (int) - ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, ColoredMenuSettings.FontMenuSymbol, this.Component.DisplayName, CenteredFlags.VerticalCenter) - .Y; + (int) + ColoredUtilities.GetContainerRectangle(this.Component) + .GetCenteredText( + null, + ColoredMenuSettings.FontMenuSymbol, + this.Component.DisplayName, + CenteredFlags.VerticalCenter) + .Y; Utils.DrawCircleFilled( (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - - MenuSettings.ContainerTextMarkOffset) + 4, + - MenuSettings.ContainerTextMarkOffset) + 4, symbolCenterY + 11, 6, 0, @@ -178,9 +347,11 @@ public override void Draw() "›", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - - MenuSettings.ContainerTextMarkOffset) + 1, + - MenuSettings.ContainerTextMarkOffset) + 1, symbolCenterY, - this.Component.Components.Count > 0 ? ColoredMenuSettings.TextCaptionColor : MenuSettings.ContainerSeparatorColor); + this.Component.Components.Count > 0 + ? ColoredMenuSettings.TextCaptionColor + : MenuSettings.ContainerSeparatorColor); }); if (this.Component.Toggled) @@ -190,9 +361,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth / 2f - 1, position.Y + 1), + new Vector2(position.X + this.Component.MenuWidth / 2f - 1, position.Y + 1), new Vector2( - position.X + this.Component.MenuWidth / 2f - 1, + position.X + this.Component.MenuWidth / 2f - 1, position.Y + MenuSettings.ContainerHeight - 1) }, MenuSettings.ContainerSelectedColor); @@ -205,8 +376,15 @@ public override void Draw() width = this.Component.Components.First().Value.MenuWidth; } - Utils.DrawBoxRounded(position.X + this.Component.MenuWidth, position.Y, width, height, 4, true, - MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); + Utils.DrawBoxRounded( + position.X + this.Component.MenuWidth, + position.Y, + width, + height, + 4, + true, + MenuSettings.RootContainerColor, + new ColorBGRA(55, 76, 95, 255)); for (var i = 0; i < this.Component.Components.Count; ++i) { @@ -214,7 +392,7 @@ public override void Draw() if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); childComponent.OnDraw(childPos); @@ -239,9 +417,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -258,13 +436,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -294,74 +476,6 @@ public override void OnWndProc(WindowsKeys args) } } - /// - /// Draws a rounded Box. If Smoothing is true it will draw also a border. - /// - /// Position X - /// Position Y - /// Width - /// Height - /// Radius - /// Color - /// Border Color - public static void DrawBoxTopRounded(float x, float y, float w, float h, float radius, Color color, Color bcolor) - { - Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. - Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. - Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. - Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. - Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. - - Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); // Top-left corner - Utils.DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, Utils.CircleType.Quarter, true, 16, color); // Top-right corner - Utils.DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius - 1, 180, Utils.CircleType.Quarter, true, 16, color); // Bottom-right corner - Utils.DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, Utils.CircleType.Quarter, true, 16, color); // Bottom-left corner - - Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); // Top-left corner - Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); // Top-right corner - Utils.DrawCircle(x + w - radius - 1, y + h - radius - 1, radius, 180, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-right corner - Utils.DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-left corner - - Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line - Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line - Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line - Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line - } - - /// - /// Draws a rounded Box. If Smoothing is true it will draw also a border. - /// - /// Position X - /// Position Y - /// Width - /// Height - /// Radius - /// Color - /// Border Color - public static void DrawBoxBotRounded(float x, float y, float w, float h, float radius, Color color, Color bcolor) - { - Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. - Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. - Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. - Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. - Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. - - Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); // Top-left corner - Utils.DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, Utils.CircleType.Quarter, true, 16, color); // Top-right corner - Utils.DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius - 1, 180, Utils.CircleType.Quarter, true, 16, color); // Bottom-right corner - Utils.DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, Utils.CircleType.Quarter, true, 16, color); // Bottom-left corner - - Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); // Top-left corner - Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); // Top-right corner - Utils.DrawCircle(x + w - radius - 1, y + h - radius - 1, radius, 180, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-right corner - Utils.DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-left corner - - Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line - Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line - Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line - Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line - } - /// /// Calculates the Width of an AMenuComponent /// @@ -372,7 +486,7 @@ public override int Width() { return (int) - (ColoredUtilities.MeasureString(this.Component.DisplayName + " »").Width + (ColoredUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " »").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Colored/ColoredMenuSettings.cs b/Core/UI/IMenu/Skins/Colored/ColoredMenuSettings.cs index eea3326..8cef30b 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredMenuSettings.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredMenuSettings.cs @@ -22,9 +22,8 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored +namespace LeagueSharp.SDK.UI.Skins.Colored { - using SharpDX; using SharpDX.Direct3D9; @@ -126,11 +125,6 @@ public static Font FontMenuSymbol } } - /// - /// Gets or sets the Global Text Caption Color. - /// - public static ColorBGRA TextCaptionColor { get; set; } - /// /// Gets or sets the Global KeyBind Color. /// @@ -141,6 +135,11 @@ public static Font FontMenuSymbol /// public static ColorBGRA SliderColor { get; set; } + /// + /// Gets or sets the Global Text Caption Color. + /// + public static ColorBGRA TextCaptionColor { get; set; } + #endregion #region Public Methods and Operators @@ -150,7 +149,6 @@ public static Font FontMenuSymbol /// public static void LoadSettings() { - } #endregion diff --git a/Core/UI/IMenu/Skins/Colored/ColoredSeparator.cs b/Core/UI/IMenu/Skins/Colored/ColoredSeparator.cs index af08fd6..78942cd 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredSeparator.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredSeparator.cs @@ -19,13 +19,14 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; @@ -34,7 +35,6 @@ namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored /// public class ColoredSeparator : ADrawable { - #region Static Fields /// @@ -83,12 +83,12 @@ public override void Draw() .GetCenteredText( null, ColoredMenuSettings.FontCaption, - this.Component.DisplayName.ToUpper(), + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); ColoredMenuSettings.FontCaption.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName.ToUpper(), + MultiLanguage.Translation(this.Component.DisplayName), (int)centerY.X, (int)centerY.Y, ColoredMenuSettings.TextCaptionColor); @@ -98,16 +98,28 @@ public override void Draw() Line.Draw( new[] { - new Vector2(this.Component.Position.X + Offset, ColoredUtilities.GetContainerRectangle(this.Component).Center.Y), - new Vector2(Math.Max(this.Component.Position.X + Offset, centerY.X - 5), ColoredUtilities.GetContainerRectangle(this.Component).Center.Y) + new Vector2( + this.Component.Position.X + Offset, + ColoredUtilities.GetContainerRectangle(this.Component).Center.Y), + new Vector2( + Math.Max(this.Component.Position.X + Offset, centerY.X - 5), + ColoredUtilities.GetContainerRectangle(this.Component).Center.Y) }, MenuSettings.ContainerSelectedColor); - int newX = ColoredMenuSettings.FontCaption.MeasureText(MenuManager.Instance.Sprite, this.Component.DisplayName.ToUpper(), 0).Width; + var newX = + ColoredMenuSettings.FontCaption.MeasureText( + MenuManager.Instance.Sprite, + this.Component.DisplayName.ToUpper(), + 0).Width; Line.Draw( new[] { - new Vector2(centerY.X + newX + 5, ColoredUtilities.GetContainerRectangle(this.Component).Center.Y), - new Vector2(Math.Max(centerY.X + newX + 5, ColoredUtilities.GetContainerRectangle(this.Component).Right - Offset), ColoredUtilities.GetContainerRectangle(this.Component).Center.Y) + new Vector2(centerY.X + newX + 5, ColoredUtilities.GetContainerRectangle(this.Component).Center.Y), + new Vector2( + Math.Max( + centerY.X + newX + 5, + ColoredUtilities.GetContainerRectangle(this.Component).Right - Offset), + ColoredUtilities.GetContainerRectangle(this.Component).Center.Y) }, MenuSettings.ContainerSelectedColor); Line.End(); diff --git a/Core/UI/IMenu/Skins/Colored/ColoredSlider.cs b/Core/UI/IMenu/Skins/Colored/ColoredSlider.cs index 5184566..780c4a1 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredSlider.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredSlider.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -104,7 +104,11 @@ public override void Draw() var centeredY = (int) ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.Value - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -126,20 +130,20 @@ public override void Draw() }); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset), + MenuManager.Instance.Sprite, + this.Component.Value.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Colored/ColoredSliderButton.cs b/Core/UI/IMenu/Skins/Colored/ColoredSliderButton.cs index ad6b43f..5052df1 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredSliderButton.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredSliderButton.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,20 +67,6 @@ public ColoredSliderButton(MenuSliderButton component) #region Public Methods and Operators - /// - /// Returns the Rectangle that defines the Slider - /// - /// The - /// The - public Rectangle SliderBoundaries(MenuSliderButton component) - { - return new Rectangle( - (int)component.Position.X + Offset, - (int)component.Position.Y, - component.MenuWidth - MenuSettings.ContainerHeight - Offset, - MenuSettings.ContainerHeight); - } - /// /// Returns the Rectangle that defines the on/off Button /// @@ -114,11 +100,16 @@ public override void Draw() var centeredY = (int) ColoredUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); var maxX = position.X + Offset + ((this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); MenuManager.Instance.DrawDelayed( @@ -136,20 +127,20 @@ public override void Draw() }); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SValue.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset - MenuSettings.ContainerHeight), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); @@ -190,10 +181,26 @@ public override void Draw() CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, MenuSettings.TextColor); + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, + MenuSettings.TextColor); //Top Line.Width = 1; @@ -220,8 +227,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.BValue ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.BValue ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.BValue ? MenuSettings.ContainerSelectedColor : MenuSettings.TextColor); } @@ -267,6 +280,20 @@ public override void OnWndProc(WindowsKeys args) } } + /// + /// Returns the Rectangle that defines the Slider + /// + /// The + /// The + public Rectangle SliderBoundaries(MenuSliderButton component) + { + return new Rectangle( + (int)component.Position.X + Offset, + (int)component.Position.Y, + component.MenuWidth - MenuSettings.ContainerHeight - Offset, + MenuSettings.ContainerHeight); + } + /// /// Calculates the width of this component /// diff --git a/Core/UI/IMenu/Skins/Colored/ColoredTextures.cs b/Core/UI/IMenu/Skins/Colored/ColoredTextures.cs index 23f6c79..6141da5 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredTextures.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredTextures.cs @@ -19,14 +19,15 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored +namespace LeagueSharp.SDK.UI.Skins.Colored { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum ColoredTexture @@ -36,35 +37,58 @@ internal enum ColoredTexture internal class ColoredTextures { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly ColoredTextures Instance = new ColoredTextures(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private ColoredTextures() { - this.textures[ColoredTexture.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[ColoredTexture.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~ColoredTextures() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } - public ColoredTextureWrapper this[ColoredTexture textureType] + #endregion + + #region Public Indexers + + public ColoredTextureWrapper this[ColoredTexture textureType] => this.textures[textureType]; + + #endregion + + #region Public Methods and Operators + + public ColoredTextureWrapper AddTexture(Image bmp, int width, int height, ColoredTexture textureType) { - get - { - return this.textures[textureType]; - } + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; } + #endregion + + #region Methods + private ColoredTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -81,19 +105,12 @@ private ColoredTextureWrapper BuildTexture(Image bmp, int height, int width) return new ColoredTextureWrapper(texture, width, height); } - public ColoredTextureWrapper AddTexture(Image bmp, int width, int height, ColoredTexture textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class ColoredTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public ColoredTextureWrapper(Texture texture, int width, int height) { @@ -101,6 +118,17 @@ public ColoredTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; private set; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Colored/ColoredTheme.cs b/Core/UI/IMenu/Skins/Colored/ColoredTheme.cs index 1f39d5d..faf73b3 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredTheme.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredTheme.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored + +namespace LeagueSharp.SDK.UI.Skins.Colored { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new ColoredSlider(component); + return new ColoredSliderButton(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new ColoredSliderButton(component); + return new ColoredSlider(component); } /// @@ -161,8 +160,15 @@ public void Draw() width = menuManager.Menus.First().MenuWidth; } - Utils.DrawBoxRounded(position.X, position.Y, width, height, 4, true, - MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); + Utils.DrawBoxRounded( + position.X, + position.Y, + width, + height, + 4, + true, + MenuSettings.RootContainerColor, + new ColorBGRA(55, 76, 95, 255)); for (var i = 0; i < menuManager.Menus.Count; ++i) { diff --git a/Core/UI/IMenu/Skins/Colored/ColoredUtilities.cs b/Core/UI/IMenu/Skins/Colored/ColoredUtilities.cs index 72f682d..6b651ec 100644 --- a/Core/UI/IMenu/Skins/Colored/ColoredUtilities.cs +++ b/Core/UI/IMenu/Skins/Colored/ColoredUtilities.cs @@ -20,9 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Colored +namespace LeagueSharp.SDK.UI.Skins.Colored { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -40,7 +40,10 @@ public class ColoredUtilities /// The width public static int CalcWidthItem(MenuItem menuItem) { - return (int)(MeasureString(menuItem.DisplayName).Width + (MenuSettings.ContainerTextOffset * 2)); + return + (int) + (MeasureString(MultiLanguage.Translation(menuItem.DisplayName)).Width + + (MenuSettings.ContainerTextOffset * 2)); } /// @@ -50,7 +53,7 @@ public static int CalcWidthItem(MenuItem menuItem) /// The public static int CalcWidthText(string text) { - return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, text, 0).Width; + return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, MultiLanguage.Translation(text), 0).Width; } /// @@ -65,9 +68,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/Default/DefaultBool.cs b/Core/UI/IMenu/Skins/Default/DefaultBool.cs index 4c660de..0094062 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultBool.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultBool.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { - using Core.Utils; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of a @@ -62,9 +62,9 @@ public DefaultBool(MenuBool component) public Rectangle ButtonBoundaries(MenuBool 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); } @@ -84,14 +84,18 @@ public override void Draw() var centerY = (int) DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), - centerY, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + centerY, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight; @@ -101,32 +105,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.Value ? 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.Value ? "ON" : "OFF", + null, + MenuSettings.Font, + this.Component.Value ? "ON" : "OFF", CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value ? "ON" : "OFF", - centerX, - centerY, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.Value ? "ON" : "OFF"), + centerX, + centerY, MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Default/DefaultButton.cs b/Core/UI/IMenu/Skins/Default/DefaultButton.cs index e5555cf..d886969 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultButton.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultButton.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { - using Core.Utils; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of @@ -89,9 +89,9 @@ public Rectangle ButtonBoundaries(MenuButton component) var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, component.ButtonText, 0).Width; return new Rectangle( - (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), - (int)component.Position.Y, - (2 * TextGap) + buttonTextWidth, + (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), + (int)component.Position.Y, + (2 * TextGap) + buttonTextWidth, MenuSettings.ContainerHeight); } @@ -109,13 +109,17 @@ public override void Dispose() public override void Draw() { var rectangleName = DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), - (int)rectangleName.Y, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + (int)rectangleName.Y, MenuSettings.TextColor); var buttonTextWidth = @@ -127,12 +131,12 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap), - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap), + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( - this.Component.Position.X + this.Component.MenuWidth, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), - }, + this.Component.Position.X + this.Component.MenuWidth, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + }, MenuSettings.HoverColor); Line.End(); Line.Width = MenuSettings.ContainerHeight - 5; @@ -141,20 +145,20 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( - this.Component.Position.X + this.Component.MenuWidth - 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), - }, + this.Component.Position.X + this.Component.MenuWidth - 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + }, this.Component.Hovering ? this.buttonHoverColor : this.buttonColor); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.ButtonText, - (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), - (int)rectangleName.Y, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.ButtonText), + (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), + (int)rectangleName.Y, MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Default/DefaultColorPicker.cs b/Core/UI/IMenu/Skins/Default/DefaultColorPicker.cs index c036d46..9838d37 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultColorPicker.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultColorPicker.cs @@ -15,14 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { - using Abstracts; - using Core.Utils; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of an @@ -137,7 +136,7 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -222,7 +221,7 @@ public override void Draw() CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - detail, + MultiLanguage.Translation(detail), (int)rectanglePreview.X, (int)rectanglePreview.Y, new ColorBGRA( @@ -249,7 +248,7 @@ public override void Draw() { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - lineNames[i], + MultiLanguage.Translation(lineNames[i]), this.pickerX + BorderOffset, textY + (i * (SliderOffset + SliderHeight)), Color.White); diff --git a/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs b/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs index adcfd88..9d1ae42 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultKeyBind.cs @@ -15,14 +15,15 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System.Windows.Forms; - using Core.Utils; - using LeagueSharp.SDK; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of @@ -89,7 +90,7 @@ public override void Draw() .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + MultiLanguage.Translation(this.Component.Interacting ? "Press a key" : this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -137,7 +138,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Active ? "ON" : "OFF", + MultiLanguage.Translation(this.Component.Active ? "ON" : "OFF"), centerX, centerY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Default/DefaultList.cs b/Core/UI/IMenu/Skins/Default/DefaultList.cs index daf7ca8..e5ea52e 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultList.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultList.cs @@ -15,14 +15,15 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System.Collections.Generic; - using Core.Utils; - using LeagueSharp.SDK; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of a @@ -96,11 +97,15 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -155,7 +160,7 @@ public override void Draw() Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - this.Component.MaxStringWidth, (int)rectangleName.Y, @@ -245,7 +250,7 @@ public override void Draw() y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - valueStrings[i], + MultiLanguage.Translation(valueStrings[i]), x, y, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Default/DefaultMenu.cs b/Core/UI/IMenu/Skins/Default/DefaultMenu.cs index 394b509..b38d383 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultMenu.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultMenu.cs @@ -15,12 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System.Linq; - using Core.Utils; - using Customizer; - using LeagueSharp.SDK; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; @@ -119,12 +120,16 @@ public override void Draw() var centerY = (int) DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -321,7 +326,7 @@ public override int Width() { return (int) - (DefaultUtilities.MeasureString(this.Component.DisplayName + " »").Width + (DefaultUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " »").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Default/DefaultSeparator.cs b/Core/UI/IMenu/Skins/Default/DefaultSeparator.cs index c5b0f44..31f9972 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultSeparator.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultSeparator.cs @@ -15,11 +15,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { - using Core.Utils; - using LeagueSharp.SDK; - using Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Implements as a default skin. @@ -58,16 +57,16 @@ public override void Draw() { var centerY = DefaultUtilities.GetContainerRectangle(this.Component) .GetCenteredText( - null, - MenuSettings.Font, - this.Component.DisplayName, + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)centerY.X, - (int)centerY.Y, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)centerY.X, + (int)centerY.Y, MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Default/DefaultSlider.cs b/Core/UI/IMenu/Skins/Default/DefaultSlider.cs index fa68f11..4d853bd 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultSlider.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultSlider.cs @@ -15,15 +15,16 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System; using System.Globalization; - using Core.Utils; - using LeagueSharp.SDK; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of an @@ -93,7 +94,11 @@ public override void Draw() var centeredY = (int) DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.Value - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -102,26 +107,26 @@ public override void Draw() Line.Width = 2; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(255, 0, 0, 255) : new ColorBGRA(50, 154, 205, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), - centeredY, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), + centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), - centeredY, + MenuManager.Instance.Sprite, + this.Component.Value.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), + centeredY, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight; @@ -129,9 +134,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + (MenuSettings.ContainerHeight / 2f)), + new Vector2(position.X, position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2(x, position.Y + (MenuSettings.ContainerHeight / 2f)) - }, + }, MenuSettings.HoverColor); Line.End(); } @@ -196,7 +201,7 @@ private void CalculateNewValue(MenuSlider component, WindowsKeys args) Math.Round( component.MinValue + (((args.Cursor.X - component.Position.X) * (component.MaxValue - component.MinValue)) - / component.MenuWidth)); + / component.MenuWidth)); if (newValue < component.MinValue) { newValue = component.MinValue; diff --git a/Core/UI/IMenu/Skins/Default/DefaultSliderButton.cs b/Core/UI/IMenu/Skins/Default/DefaultSliderButton.cs index d2f7a77..42ca60c 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultSliderButton.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultSliderButton.cs @@ -15,15 +15,16 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System; using System.Globalization; - using Core.Utils; - using LeagueSharp.SDK; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// A default implementation of an @@ -56,20 +57,6 @@ public DefaultSliderButton(MenuSliderButton component) #region Public Methods and Operators - /// - /// Returns the Rectangle that defines the Slider - /// - /// The - /// The - public Rectangle SliderBoundaries(MenuSliderButton component) - { - return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth - MenuSettings.ContainerHeight, - MenuSettings.ContainerHeight); - } - /// /// Returns the Rectangle that defines the on/off Button /// @@ -103,7 +90,11 @@ public override void Draw() var centeredY = (int) DefaultUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -112,26 +103,26 @@ public override void Draw() Line.Width = 2; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(255, 0, 0, 255) : new ColorBGRA(50, 154, 205, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), - centeredY, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), + centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), - centeredY, + MenuManager.Instance.Sprite, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), + centeredY, MenuSettings.TextColor); Line.Width = MenuSettings.ContainerHeight; @@ -139,9 +130,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + (MenuSettings.ContainerHeight / 2f)), + new Vector2(position.X, position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2(x, position.Y + (MenuSettings.ContainerHeight / 2f)) - }, + }, MenuSettings.HoverColor); Line.End(); @@ -177,7 +168,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.BValue ? "ON" : "OFF", + MultiLanguage.Translation(this.Component.BValue ? "ON" : "OFF"), centerX, centeredY, MenuSettings.TextColor); @@ -225,6 +216,20 @@ public override void OnWndProc(WindowsKeys args) } } + /// + /// Returns the Rectangle that defines the Slider + /// + /// The + /// The + public Rectangle SliderBoundaries(MenuSliderButton component) + { + return new Rectangle( + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth - MenuSettings.ContainerHeight, + MenuSettings.ContainerHeight); + } + /// /// Calculates the width of this component /// @@ -254,7 +259,7 @@ private void CalculateNewValue(MenuSliderButton component, WindowsKeys args) Math.Round( component.MinValue + (((args.Cursor.X - component.Position.X) * (component.MaxValue - component.MinValue)) - / (component.MenuWidth - MenuSettings.ContainerHeight))); + / (component.MenuWidth - MenuSettings.ContainerHeight))); if (newValue < component.MinValue) { newValue = component.MinValue; diff --git a/Core/UI/IMenu/Skins/Default/DefaultTextures.cs b/Core/UI/IMenu/Skins/Default/DefaultTextures.cs index 5f49f02..98692f5 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultTextures.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultTextures.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System.Collections.Generic; using System.Drawing; using System.Linq; - using Properties; + using LeagueSharp.SDK.Properties; using SharpDX.Direct3D9; diff --git a/Core/UI/IMenu/Skins/Default/DefaultTheme.cs b/Core/UI/IMenu/Skins/Default/DefaultTheme.cs index 943c095..0f3fc1a 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultTheme.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultTheme.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { using System.Linq; + using SharpDX; using SharpDX.Direct3D9; - using Values; /// /// Implements a default ITheme. @@ -109,23 +109,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new DefaultSlider(component); + return new DefaultSliderButton(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new DefaultSliderButton(component); + return new DefaultSlider(component); } /// diff --git a/Core/UI/IMenu/Skins/Default/DefaultUtilities.cs b/Core/UI/IMenu/Skins/Default/DefaultUtilities.cs index 86292d7..12f53e1 100644 --- a/Core/UI/IMenu/Skins/Default/DefaultUtilities.cs +++ b/Core/UI/IMenu/Skins/Default/DefaultUtilities.cs @@ -15,9 +15,9 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Default +namespace LeagueSharp.SDK.UI.Skins.Default { - using Abstracts; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -35,7 +35,10 @@ public class DefaultUtilities /// The width public static int CalcWidthItem(MenuItem menuItem) { - return (int)(MeasureString(menuItem.DisplayName).Width + (MenuSettings.ContainerTextOffset * 2)); + return + (int) + (MeasureString(MultiLanguage.Translation(menuItem.DisplayName)).Width + + (MenuSettings.ContainerTextOffset * 2)); } /// @@ -45,7 +48,7 @@ public static int CalcWidthItem(MenuItem menuItem) /// The public static int CalcWidthText(string text) { - return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, text, 0).Width; + return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, MultiLanguage.Translation(text), 0).Width; } /// @@ -60,9 +63,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/ITheme.cs b/Core/UI/IMenu/Skins/ITheme.cs index 601cc79..16e46d0 100644 --- a/Core/UI/IMenu/Skins/ITheme.cs +++ b/Core/UI/IMenu/Skins/ITheme.cs @@ -15,10 +15,8 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins +namespace LeagueSharp.SDK.UI.Skins { - using Values; - /// /// Defines a Theme used to draw components of the menu. /// @@ -80,14 +78,14 @@ public interface ITheme /// /// The where this handler is responsible for. /// The handler - ADrawable BuildSliderHandler(MenuSlider component); + ADrawable BuildSliderButtonHandler(MenuSliderButton component); /// /// Builds a new handler for the given . /// /// The where this handler is responsible for. /// The handler - ADrawable BuildSliderButtonHandler(MenuSliderButton component); + ADrawable BuildSliderHandler(MenuSlider component); /// /// Draws the list of root menus on the given position. diff --git a/Core/UI/IMenu/Skins/Light/LightBool.cs b/Core/UI/IMenu/Skins/Light/LightBool.cs index 9f20c84..0a5a01f 100644 --- a/Core/UI/IMenu/Skins/Light/LightBool.cs +++ b/Core/UI/IMenu/Skins/Light/LightBool.cs @@ -19,11 +19,11 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,7 +67,7 @@ public LightBool(MenuBool component) public Rectangle ButtonBoundaries(MenuBool component) { return new Rectangle( - (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), + (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), (int)component.Position.Y, MenuSettings.ContainerHeight, MenuSettings.ContainerHeight); @@ -89,13 +89,17 @@ public override void Draw() var centerY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -106,31 +110,31 @@ public override void Draw() { new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1) - + MenuSettings.ContainerHeight / 2f, - this.Component.Position.Y + 1 + 3), + + MenuSettings.ContainerHeight / 2f, + this.Component.Position.Y + 1 + 3), new Vector2( (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - 1) - + MenuSettings.ContainerHeight / 2f, + + MenuSettings.ContainerHeight / 2f, this.Component.Position.Y + MenuSettings.ContainerHeight - 3) - }, + }, this.Component.Value ? new ColorBGRA(68, 160, 255, 255) : new ColorBGRA(151, 151, 151, 255)); Line.End(); var centerX = (int) new Rectangle( - (int)(this.Component.Position.X + this.Component.MenuWidth - 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.Value ? "On" : "Off", + null, + MenuSettings.Font, + this.Component.Value ? "On" : "Off", CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value ? "On" : "Off", - centerX, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.Value ? "On" : "Off"), + centerX, centerY, new ColorBGRA(221, 233, 255, 255)); } diff --git a/Core/UI/IMenu/Skins/Light/LightButton.cs b/Core/UI/IMenu/Skins/Light/LightButton.cs index 2131e85..beb8228 100644 --- a/Core/UI/IMenu/Skins/Light/LightButton.cs +++ b/Core/UI/IMenu/Skins/Light/LightButton.cs @@ -19,11 +19,11 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -94,8 +94,8 @@ public Rectangle ButtonBoundaries(MenuButton component) var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, component.ButtonText, 0).Width; return new Rectangle( - (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), - (int)component.Position.Y, + (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), + (int)component.Position.Y, (2 * TextGap) + buttonTextWidth, MenuSettings.ContainerHeight); } @@ -114,12 +114,16 @@ public override void Dispose() public override void Draw() { var rectangleName = LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -132,19 +136,19 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - (2 * TextGap) + 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), new Vector2( - this.Component.Position.X + this.Component.MenuWidth - 2, - this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), - }, + this.Component.Position.X + this.Component.MenuWidth - 2, + this.Component.Position.Y + (MenuSettings.ContainerHeight / 2f)), + }, this.Component.Hovering ? this.buttonHoverColor : this.buttonColor); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.ButtonText, - (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.ButtonText), + (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), (int)rectangleName.Y, new ColorBGRA(221, 233, 255, 255)); } @@ -167,9 +171,9 @@ public override void OnWndProc(WindowsKeys args) if (args.Cursor.IsUnderRectangle(rect.X, rect.Y, rect.Width, rect.Height)) { this.Component.Hovering = true; - if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Action != null) + if (args.Msg == WindowsMessages.LBUTTONDOWN) { - this.Component.Action(); + this.Component.Action?.Invoke(); } } else diff --git a/Core/UI/IMenu/Skins/Light/LightColorPicker.cs b/Core/UI/IMenu/Skins/Light/LightColorPicker.cs index 1595093..262711f 100644 --- a/Core/UI/IMenu/Skins/Light/LightColorPicker.cs +++ b/Core/UI/IMenu/Skins/Light/LightColorPicker.cs @@ -19,21 +19,20 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Rectangle = SharpDX.Rectangle; - using Utilities = LeagueSharp.SDK.Core.UI.IMenu.Utilities; + using Utilities = LeagueSharp.SDK.UI.Utilities; internal class LightColorPicker : ADrawable { @@ -130,17 +129,17 @@ internal class LightColorPicker : ADrawable /// /// The ColorBox to display the color spectrum. /// - protected ColorBox colorBox; + protected ColorBox ColorBox; /// /// The VerticalAlphaSlider to change the opacity. /// - protected VerticalAlphaSlider verticalAlphaSlider; + protected VerticalAlphaSlider VerticalAlphaSlider; /// /// The VerticalColorSlider to change the color spectrum. /// - protected VerticalColorSlider verticalColorSlider; + protected VerticalColorSlider VerticalColorSlider; #endregion @@ -156,27 +155,27 @@ public LightColorPicker(MenuColor component) : base(component) { Hsl tempHsl; - this.colorBox = new ColorBox(new Size(200, 200), true) + this.ColorBox = new ColorBox(new Size(200, 200), true) { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) + this.VerticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider.ColorSliderScroll += () => + this.VerticalColorSlider.ColorSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.H = this.verticalColorSlider.CbHsl.H; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.H = this.VerticalColorSlider.CbHsl.H; + this.ColorBox.Hsl = tempHsl; }; - this.verticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); - tempHsl = this.verticalAlphaSlider.CbHsl; - tempHsl.L = this.colorBox.Hsl.L; - this.verticalAlphaSlider.CbHsl = tempHsl; - this.verticalAlphaSlider.AlphaSliderScroll += () => + this.VerticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); + tempHsl = this.VerticalAlphaSlider.CbHsl; + tempHsl.L = this.ColorBox.Hsl.L; + this.VerticalAlphaSlider.CbHsl = tempHsl; + this.VerticalAlphaSlider.AlphaSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.L = this.verticalAlphaSlider.CbHsl.L; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.L = this.VerticalAlphaSlider.CbHsl.L; + this.ColorBox.Hsl = tempHsl; }; } @@ -217,11 +216,15 @@ public override void Dispose() public override void Draw() { var rectangleName = LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -247,11 +250,11 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + 1 + 3), - new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + Line.Width + 3) + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + 1 + 3), + new Vector2( + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); @@ -262,87 +265,100 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - Line.Width = ColorPickerBoundaries().Width; + Line.Width = this.ColorPickerBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), + new Vector2(this.ColorPickerBoundaries().X + 165, this.ColorPickerBoundaries().Y), new Vector2( - ColorPickerBoundaries().X + 165, - ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) + this.ColorPickerBoundaries().X + 165, + this.ColorPickerBoundaries().Y + this.ColorPickerBoundaries().Height) }, MenuSettings.RootContainerColor); Line.End(); - colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); - verticalColorSlider.DrawControl( - new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); - verticalAlphaSlider.DrawControl( - new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); + this.ColorBox.DrawControl( + new Vector2(this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y)); + this.VerticalColorSlider.DrawControl( + new Vector2( + this.VerticalColorSliderBoundaries().X, + this.VerticalColorSliderBoundaries().Y)); + this.VerticalAlphaSlider.DrawControl( + new Vector2( + this.VerticalAlphaSliderBoundaries().X, + this.VerticalAlphaSliderBoundaries().Y)); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, Color.Black); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - colorBox.Rgb.ToSharpDxColor()); + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + this.ColorBox.Rgb.ToSharpDxColor()); var applyButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; var cancelButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; - Line.Width = ApplyButtonBoundaries().Width; + Line.Width = this.ApplyButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), + new Vector2(this.ApplyButtonBoundaries().X + 25, this.ApplyButtonBoundaries().Y), new Vector2( - ApplyButtonBoundaries().X + 25, - ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) + this.ApplyButtonBoundaries().X + 25, + this.ApplyButtonBoundaries().Y + this.ApplyButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Apply", - ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Apply"), + this.ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Apply"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); - Line.Width = CancelButtonBoundaries().Width; + Line.Width = this.CancelButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), + new Vector2(this.CancelButtonBoundaries().X + 25, this.CancelButtonBoundaries().Y), new Vector2( - CancelButtonBoundaries().X + 25, - CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) + this.CancelButtonBoundaries().X + 25, + this.CancelButtonBoundaries().Y + this.CancelButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Cancel", - CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Cancel"), + this.CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Cancel"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); }); @@ -376,15 +392,15 @@ public override void OnWndProc(WindowsKeys args) { if (this.InteractingColorBox) { - this.colorBox.ColorBoxMouseMove(args); + this.ColorBox.ColorBoxMouseMove(args); } else if (this.InteractingVerticalColorSlider) { - this.verticalColorSlider.VerticalColorSlider_MouseMove(args); + this.VerticalColorSlider.VerticalColorSliderMouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { - this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseMove(args); } } } @@ -394,17 +410,17 @@ public override void OnWndProc(WindowsKeys args) if (this.InteractingColorBox) { this.InteractingColorBox = false; - this.colorBox.ColorBoxMouseUp(args); + this.ColorBox.ColorBoxMouseUp(args); } if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; - this.verticalColorSlider.VerticalColorSlider_MouseUp(args); + this.VerticalColorSlider.VerticalColorSliderMouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseUp(args); } } @@ -424,7 +440,7 @@ public override void OnWndProc(WindowsKeys args) this.ColorBoxBoundaries().Height)) { this.InteractingColorBox = true; - this.colorBox.ColorBoxMouseDown(args); + this.ColorBox.ColorBoxMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalColorSliderBoundaries().X, @@ -433,7 +449,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; - this.verticalColorSlider.VerticalColorSlider_MouseDown(args); + this.VerticalColorSlider.VerticalColorSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, @@ -442,7 +458,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, @@ -451,7 +467,7 @@ public override void OnWndProc(WindowsKeys args) this.ApplyButtonBoundaries().Height)) { this.Component.Active = false; - this.Component.Color = this.colorBox.Rgb.ToSharpDxColor(); + this.Component.Color = this.ColorBox.Rgb.ToSharpDxColor(); } else if (args.Cursor.IsUnderRectangle( this.CancelButtonBoundaries().X, @@ -460,9 +476,9 @@ public override void OnWndProc(WindowsKeys args) this.CancelButtonBoundaries().Height)) { this.Component.Active = false; - this.colorBox.Rgb = this.Component.Color.ToSystemColor(); - this.verticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); - this.verticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); + this.ColorBox.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); } } else if (args.Cursor.IsUnderRectangle( diff --git a/Core/UI/IMenu/Skins/Light/LightKeyBind.cs b/Core/UI/IMenu/Skins/Light/LightKeyBind.cs index f4d17c8..3ef3bfb 100644 --- a/Core/UI/IMenu/Skins/Light/LightKeyBind.cs +++ b/Core/UI/IMenu/Skins/Light/LightKeyBind.cs @@ -20,13 +20,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light +namespace LeagueSharp.SDK.UI.Skins.Light { using System.Windows.Forms; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -92,11 +91,15 @@ public override void Draw() var centerY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + MultiLanguage.Translation(this.Component.Interacting ? "Press a key" : this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -144,7 +147,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Active ? "On" : "Off", + MultiLanguage.Translation(this.Component.Active ? "On" : "Off"), centerX, centerY, new ColorBGRA(221, 233, 255, 255)); diff --git a/Core/UI/IMenu/Skins/Light/LightList.cs b/Core/UI/IMenu/Skins/Light/LightList.cs index 15073fd..9e52c18 100644 --- a/Core/UI/IMenu/Skins/Light/LightList.cs +++ b/Core/UI/IMenu/Skins/Light/LightList.cs @@ -19,13 +19,13 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -102,27 +102,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor); Line.Width = 1f; @@ -157,22 +161,23 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - (Line.Width / 2), + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), + position.X + this.Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight) - }, dropdownColor); + }, + dropdownColor); Line.End(); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -180,11 +185,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -198,49 +203,49 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( - position.X + Component.MenuWidth - 10, + position.X + this.Component.MenuWidth - 10, position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(valueStrings[i]), + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } } - Line.Width = 1f; - Line.Begin(); - Line.Draw( + Line.Width = 1f; + Line.Begin(); + Line.Draw( new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -260,8 +265,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -277,9 +282,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -297,8 +302,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -337,9 +342,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -352,9 +357,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Light/LightMenu.cs b/Core/UI/IMenu/Skins/Light/LightMenu.cs index 543aa48..95bdaf9 100644 --- a/Core/UI/IMenu/Skins/Light/LightMenu.cs +++ b/Core/UI/IMenu/Skins/Light/LightMenu.cs @@ -19,28 +19,22 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class LightMenu : ADrawable { - #region Constants - - #endregion - #region Static Fields /// @@ -51,7 +45,7 @@ public class LightMenu : ADrawable #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -93,7 +87,6 @@ public class LightMenu : ADrawable public LightMenu(Menu component) : base(component) { - } #endregion @@ -120,9 +113,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -139,7 +132,7 @@ public override void Draw() { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, new ColorBGRA(237, 245, 254, 255)); @@ -151,13 +144,15 @@ public override void Draw() (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset), centerY, - this.Component.Components.Count > 0 ? new ColorBGRA(237, 245, 254, 255) : MenuSettings.ContainerSeparatorColor); + this.Component.Components.Count > 0 + ? new ColorBGRA(237, 245, 254, 255) + : MenuSettings.ContainerSeparatorColor); } else { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -179,9 +174,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), + new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), new Vector2( - position.X + this.Component.MenuWidth / 2f, + position.X + this.Component.MenuWidth / 2f, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSelectedColor); @@ -199,21 +194,19 @@ public override void Draw() Line.Draw( new[] { - new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), + new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height) }, MenuSettings.RootContainerColor); Line.End(); - - for (var i = 0; i < this.Component.Components.Count; ++i) { var childComponent = this.Component.Components.Values.ToList()[i]; if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); if (i < this.Component.Components.Count - 1) @@ -223,9 +216,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight), + new Vector2(childPos.X + 15, childPos.Y + MenuSettings.ContainerHeight), new Vector2( - childPos.X - 15 + childComponent.MenuWidth, + childPos.X - 15 + childComponent.MenuWidth, childPos.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -243,33 +236,32 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y + height), + new Vector2(position.X + this.Component.MenuWidth, position.Y + height), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth + width, position.Y), + new Vector2(position.X + this.Component.MenuWidth + width, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.End(); - } if (this.hasDragged && !MenuCustomizer.Instance.LockPosition.Value) @@ -289,9 +281,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -308,13 +300,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -354,7 +350,7 @@ public override int Width() { return (int) - (LightUtilities.MeasureString(this.Component.DisplayName + " »").Width + (LightUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " »").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Light/LightMenuSettings.cs b/Core/UI/IMenu/Skins/Light/LightMenuSettings.cs index fba9ee0..9d5554f 100644 --- a/Core/UI/IMenu/Skins/Light/LightMenuSettings.cs +++ b/Core/UI/IMenu/Skins/Light/LightMenuSettings.cs @@ -22,9 +22,8 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light +namespace LeagueSharp.SDK.UI.Skins.Light { - using SharpDX; using SharpDX.Direct3D9; @@ -33,15 +32,6 @@ namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light /// public class LightMenuSettings : MenuSettings { - #region Static Fields - - /// - /// Local Caption Font. - /// - private static Font fontCaption; - - #endregion - #region Constructors and Destructors /// @@ -66,7 +56,7 @@ static LightMenuSettings() FontQuality.ClearType, FontPitchAndFamily.DontCare | FontPitchAndFamily.Decorative | FontPitchAndFamily.Modern, "Tahoma"); - + TextColor = new ColorBGRA(17, 17, 17, 255); TextCaptionColor = new ColorBGRA(72, 157, 248, 255); KeyBindColor = new ColorBGRA(67, 159, 255, 255); @@ -80,23 +70,7 @@ static LightMenuSettings() /// /// Gets or sets the Global Caption Font. /// - public static Font FontCaption - { - get - { - return fontCaption; - } - - set - { - fontCaption = value; - } - } - - /// - /// Gets or sets the Global Text Caption Color. - /// - public static ColorBGRA TextCaptionColor { get; set; } + public static Font FontCaption { get; set; } /// /// Gets or sets the Global KeyBind Color. @@ -108,6 +82,11 @@ public static Font FontCaption /// public static ColorBGRA SliderColor { get; set; } + /// + /// Gets or sets the Global Text Caption Color. + /// + public static ColorBGRA TextCaptionColor { get; set; } + #endregion #region Public Methods and Operators @@ -117,7 +96,6 @@ public static Font FontCaption /// public static void LoadSettings() { - } #endregion diff --git a/Core/UI/IMenu/Skins/Light/LightSeparator.cs b/Core/UI/IMenu/Skins/Light/LightSeparator.cs index 2df22dd..82add22 100644 --- a/Core/UI/IMenu/Skins/Light/LightSeparator.cs +++ b/Core/UI/IMenu/Skins/Light/LightSeparator.cs @@ -19,11 +19,11 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Implements as a default skin. @@ -64,12 +64,12 @@ public override void Draw() .GetCenteredText( null, LightMenuSettings.FontCaption, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); LightMenuSettings.FontCaption.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)centerY.X, (int)centerY.Y, LightMenuSettings.TextCaptionColor); diff --git a/Core/UI/IMenu/Skins/Light/LightSlider.cs b/Core/UI/IMenu/Skins/Light/LightSlider.cs index 04c74d9..54e9161 100644 --- a/Core/UI/IMenu/Skins/Light/LightSlider.cs +++ b/Core/UI/IMenu/Skins/Light/LightSlider.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -104,7 +104,11 @@ public override void Draw() var centeredY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.Value - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -113,25 +117,25 @@ public override void Draw() Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(94, 170, 246, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), + MenuManager.Instance.Sprite, + this.Component.Value.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), centeredY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Light/LightSliderButton.cs b/Core/UI/IMenu/Skins/Light/LightSliderButton.cs index abaae0e..9a54203 100644 --- a/Core/UI/IMenu/Skins/Light/LightSliderButton.cs +++ b/Core/UI/IMenu/Skins/Light/LightSliderButton.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,20 +67,6 @@ public LightSliderButton(MenuSliderButton component) #region Public Methods and Operators - /// - /// Returns the Rectangle that defines the Slider - /// - /// The - /// The - public Rectangle SliderBoundaries(MenuSliderButton component) - { - return new Rectangle( - (int)component.Position.X + Offset, - (int)component.Position.Y, - component.MenuWidth - MenuSettings.ContainerHeight - Offset, - MenuSettings.ContainerHeight); - } - /// /// Returns the Rectangle that defines the on/off Button /// @@ -114,34 +100,39 @@ public override void Draw() var centeredY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); Line.Width = 3; Line.Begin(); Line.Draw( - new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, + new[] { new Vector2(x, position.Y + 1), new Vector2(x, position.Y + MenuSettings.ContainerHeight) }, this.Component.Interacting ? new ColorBGRA(90, 129, 144, 255) : new ColorBGRA(94, 170, 246, 255)); Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), centeredY, MenuSettings.TextColor); @@ -188,7 +179,7 @@ public override void Draw() CenteredFlags.HorizontalCenter).X; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.BValue ? "On" : "Off", + MultiLanguage.Translation(this.Component.BValue ? "On" : "Off"), centerX, centeredY, new ColorBGRA(221, 233, 255, 255)); @@ -236,6 +227,20 @@ public override void OnWndProc(WindowsKeys args) } } + /// + /// Returns the Rectangle that defines the Slider + /// + /// The + /// The + public Rectangle SliderBoundaries(MenuSliderButton component) + { + return new Rectangle( + (int)component.Position.X + Offset, + (int)component.Position.Y, + component.MenuWidth - MenuSettings.ContainerHeight - Offset, + MenuSettings.ContainerHeight); + } + /// /// Calculates the width of this component /// diff --git a/Core/UI/IMenu/Skins/Light/LightTextures.cs b/Core/UI/IMenu/Skins/Light/LightTextures.cs index cf61cf9..46a9859 100644 --- a/Core/UI/IMenu/Skins/Light/LightTextures.cs +++ b/Core/UI/IMenu/Skins/Light/LightTextures.cs @@ -19,52 +19,76 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light +namespace LeagueSharp.SDK.UI.Skins.Light { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum LightTexture { - Dragging, + Dragging } internal class LightTextures { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly LightTextures Instance = new LightTextures(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private LightTextures() { - this.textures[LightTexture.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[LightTexture.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~LightTextures() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } - public BlueTextureWrapper this[LightTexture textureType] + #endregion + + #region Public Indexers + + public BlueTextureWrapper this[LightTexture textureType] => this.textures[textureType]; + + #endregion + + #region Public Methods and Operators + + public BlueTextureWrapper AddTexture(Image bmp, int width, int height, LightTexture textureType) { - get - { - return this.textures[textureType]; - } + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; } + #endregion + + #region Methods + private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -81,19 +105,12 @@ private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) return new BlueTextureWrapper(texture, width, height); } - public BlueTextureWrapper AddTexture(Image bmp, int width, int height, LightTexture textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class BlueTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public BlueTextureWrapper(Texture texture, int width, int height) { @@ -101,6 +118,17 @@ public BlueTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; private set; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Light/LightTheme.cs b/Core/UI/IMenu/Skins/Light/LightTheme.cs index df00d1d..cf2998d 100644 --- a/Core/UI/IMenu/Skins/Light/LightTheme.cs +++ b/Core/UI/IMenu/Skins/Light/LightTheme.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light + +namespace LeagueSharp.SDK.UI.Skins.Light { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new LightSlider(component); + return new LightSliderButton(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new LightSliderButton(component); + return new LightSlider(component); } /// @@ -166,7 +165,7 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X + (width / 2f), position.Y), + new Vector2(position.X + (width / 2f), position.Y), new Vector2(position.X + (width / 2), position.Y + height) }, MenuSettings.RootContainerColor); @@ -200,13 +199,12 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), - new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), + new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), + new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), new Vector2(position.X, position.Y) }, new ColorBGRA(254, 255, 255, 255)); Line.End(); - } #endregion diff --git a/Core/UI/IMenu/Skins/Light/LightUtilities.cs b/Core/UI/IMenu/Skins/Light/LightUtilities.cs index 44be311..d40ccfb 100644 --- a/Core/UI/IMenu/Skins/Light/LightUtilities.cs +++ b/Core/UI/IMenu/Skins/Light/LightUtilities.cs @@ -20,9 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light +namespace LeagueSharp.SDK.UI.Skins.Light { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -40,7 +40,10 @@ public class LightUtilities /// The width public static int CalcWidthItem(MenuItem menuItem) { - return (int)(MeasureString(menuItem.DisplayName).Width + (MenuSettings.ContainerTextOffset * 2)); + return + (int) + (MeasureString(MultiLanguage.Translation(menuItem.DisplayName)).Width + + (MenuSettings.ContainerTextOffset * 2)); } /// @@ -50,7 +53,7 @@ public static int CalcWidthItem(MenuItem menuItem) /// The public static int CalcWidthText(string text) { - return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, text, 0).Width; + return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, MultiLanguage.Translation(text), 0).Width; } /// @@ -65,9 +68,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/Light2/LightBool2.cs b/Core/UI/IMenu/Skins/Light2/LightBool2.cs index 376afd5..8ff2570 100644 --- a/Core/UI/IMenu/Skins/Light2/LightBool2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightBool2.cs @@ -19,26 +19,16 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX.Direct3D9; + using LeagueSharp.SDK.UI.Skins.Light; /// /// A blue implementation of a /// public class LightBool2 : LightBool { - #region Static Fields - - /// - /// The line. - /// - private static readonly Line Line = new Line(Drawing.Direct3DDevice) { GLLines = true }; - - #endregion - #region Constructors and Destructors /// diff --git a/Core/UI/IMenu/Skins/Light2/LightButton2.cs b/Core/UI/IMenu/Skins/Light2/LightButton2.cs index 4c0ff1d..e84e441 100644 --- a/Core/UI/IMenu/Skins/Light2/LightButton2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightButton2.cs @@ -19,10 +19,10 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Light; /// /// A default implementation of diff --git a/Core/UI/IMenu/Skins/Light2/LightColorPicker2.cs b/Core/UI/IMenu/Skins/Light2/LightColorPicker2.cs index 13d89db..bfcb63a 100644 --- a/Core/UI/IMenu/Skins/Light2/LightColorPicker2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightColorPicker2.cs @@ -19,22 +19,21 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Rectangle = SharpDX.Rectangle; - using Utilities = LeagueSharp.SDK.Core.UI.IMenu.Utilities; + using Utilities = LeagueSharp.SDK.UI.Utilities; internal class LightColorPicker2 : LightColorPicker { @@ -158,27 +157,27 @@ public LightColorPicker2(MenuColor component) { Hsl tempHsl; this.colorBox = new ColorBox(new Size(200, 200)) - { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; + { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; this.verticalColorSlider = new VerticalColorSlider(new Size(40, 200)) - { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; + { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; this.verticalColorSlider.ColorSliderScroll += () => - { - tempHsl = this.colorBox.Hsl; - tempHsl.H = this.verticalColorSlider.CbHsl.H; - this.colorBox.Hsl = tempHsl; - }; + { + tempHsl = this.colorBox.Hsl; + tempHsl.H = this.verticalColorSlider.CbHsl.H; + this.colorBox.Hsl = tempHsl; + }; this.verticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); tempHsl = this.verticalAlphaSlider.CbHsl; tempHsl.L = this.colorBox.Hsl.L; this.verticalAlphaSlider.CbHsl = tempHsl; this.verticalAlphaSlider.AlphaSliderScroll += () => - { - tempHsl = this.colorBox.Hsl; - tempHsl.L = this.verticalAlphaSlider.CbHsl.L; - this.colorBox.Hsl = tempHsl; - }; + { + tempHsl = this.colorBox.Hsl; + tempHsl.L = this.verticalAlphaSlider.CbHsl.L; + this.colorBox.Hsl = tempHsl; + }; } #endregion @@ -222,7 +221,7 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -248,11 +247,11 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + 1 + 3), - new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + Line.Width + 3) + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + 1 + 3), + new Vector2( + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); @@ -262,91 +261,104 @@ public override void Draw() { MenuManager.Instance.DrawDelayed( delegate - { - Line.Width = ColorPickerBoundaries().Width; - Line.Begin(); - Line.Draw( - new[] - { - new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), + { + Line.Width = this.ColorPickerBoundaries().Width; + Line.Begin(); + Line.Draw( + new[] + { + new Vector2(this.ColorPickerBoundaries().X + 165, this.ColorPickerBoundaries().Y), new Vector2( - ColorPickerBoundaries().X + 165, - ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) - }, - new ColorBGRA(254, 255, 255, 255)); - Line.End(); - - colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); - verticalColorSlider.DrawControl( - new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); - verticalAlphaSlider.DrawControl( - new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); - - Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - Color.Black); - - Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - colorBox.Rgb.ToSharpDxColor()); - - var applyButtonTextWidth = - MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; - var cancelButtonTextWidth = - MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; - - Line.Width = ApplyButtonBoundaries().Width; - Line.Begin(); - Line.Draw( - new[] - { - new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), + this.ColorPickerBoundaries().X + 165, + this.ColorPickerBoundaries().Y + this.ColorPickerBoundaries().Height) + }, + new ColorBGRA(254, 255, 255, 255)); + Line.End(); + + this.colorBox.DrawControl( + new Vector2(this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y)); + this.verticalColorSlider.DrawControl( + new Vector2( + this.VerticalColorSliderBoundaries().X, + this.VerticalColorSliderBoundaries().Y)); + this.verticalAlphaSlider.DrawControl( + new Vector2( + this.VerticalAlphaSliderBoundaries().X, + this.VerticalAlphaSliderBoundaries().Y)); + + Utils.DrawBoxFilled( + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + Color.Black); + + Utils.DrawBoxFilled( + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + this.colorBox.Rgb.ToSharpDxColor()); + + var applyButtonTextWidth = + MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; + var cancelButtonTextWidth = + MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; + + Line.Width = this.ApplyButtonBoundaries().Width; + Line.Begin(); + Line.Draw( + new[] + { + new Vector2(this.ApplyButtonBoundaries().X + 25, this.ApplyButtonBoundaries().Y), new Vector2( - ApplyButtonBoundaries().X + 25, - ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) - }, - new ColorBGRA(68, 160, 255, 255)); - Line.End(); - - MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - "Apply", - ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, - (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) - .Y, - new ColorBGRA(221, 233, 255, 255)); - - Line.Width = CancelButtonBoundaries().Width; - Line.Begin(); - Line.Draw( - new[] - { - new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), + this.ApplyButtonBoundaries().X + 25, + this.ApplyButtonBoundaries().Y + this.ApplyButtonBoundaries().Height) + }, + new ColorBGRA(68, 160, 255, 255)); + Line.End(); + + MenuSettings.Font.DrawText( + MenuManager.Instance.Sprite, + MultiLanguage.Translation("Apply"), + this.ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, + (int) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Apply"), + CenteredFlags.VerticalCenter) + .Y, + new ColorBGRA(221, 233, 255, 255)); + + Line.Width = this.CancelButtonBoundaries().Width; + Line.Begin(); + Line.Draw( + new[] + { + new Vector2(this.CancelButtonBoundaries().X + 25, this.CancelButtonBoundaries().Y), new Vector2( - CancelButtonBoundaries().X + 25, - CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) - }, - new ColorBGRA(68, 160, 255, 255)); - Line.End(); - - MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - "Cancel", - CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, - (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) - .Y, - new ColorBGRA(221, 233, 255, 255)); - }); + this.CancelButtonBoundaries().X + 25, + this.CancelButtonBoundaries().Y + this.CancelButtonBoundaries().Height) + }, + new ColorBGRA(68, 160, 255, 255)); + Line.End(); + + MenuSettings.Font.DrawText( + MenuManager.Instance.Sprite, + MultiLanguage.Translation("Cancel"), + this.CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, + (int) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Cancel"), + CenteredFlags.VerticalCenter) + .Y, + new ColorBGRA(221, 233, 255, 255)); + }); } } @@ -381,11 +393,11 @@ public override void OnWndProc(WindowsKeys args) } else if (this.InteractingVerticalColorSlider) { - this.verticalColorSlider.VerticalColorSlider_MouseMove(args); + this.verticalColorSlider.VerticalColorSliderMouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { - this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); + this.verticalAlphaSlider.VerticalAlphaSliderMouseMove(args); } } } @@ -400,12 +412,12 @@ public override void OnWndProc(WindowsKeys args) if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; - this.verticalColorSlider.VerticalColorSlider_MouseUp(args); + this.verticalColorSlider.VerticalColorSliderMouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); + this.verticalAlphaSlider.VerticalAlphaSliderMouseUp(args); } } @@ -434,7 +446,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; - this.verticalColorSlider.VerticalColorSlider_MouseDown(args); + this.verticalColorSlider.VerticalColorSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, @@ -443,7 +455,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); + this.verticalAlphaSlider.VerticalAlphaSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, diff --git a/Core/UI/IMenu/Skins/Light2/LightKeyBind2.cs b/Core/UI/IMenu/Skins/Light2/LightKeyBind2.cs index 401fcc2..7157d5e 100644 --- a/Core/UI/IMenu/Skins/Light2/LightKeyBind2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightKeyBind2.cs @@ -20,10 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.UI.Skins.Light; /// /// A default implementation of diff --git a/Core/UI/IMenu/Skins/Light2/LightList2.cs b/Core/UI/IMenu/Skins/Light2/LightList2.cs index 4b5b485..f00119b 100644 --- a/Core/UI/IMenu/Skins/Light2/LightList2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightList2.cs @@ -19,14 +19,14 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -103,27 +103,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, this.Component.Active ? new ColorBGRA(0, 186, 255, 255) : MenuSettings.TextColor); Line.Width = 1f; @@ -158,22 +162,23 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - (Line.Width / 2), + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - (Line.Width / 2), + position.X + this.Component.MenuWidth - (Line.Width / 2), position.Y + MenuSettings.ContainerHeight + dropdownMenuHeight) - }, dropdownColor); + }, + dropdownColor); Line.End(); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -181,11 +186,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -199,49 +204,49 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), new Vector2( - position.X + Component.MenuWidth - 10, + position.X + this.Component.MenuWidth - 10, position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(valueStrings[i]), + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } } - Line.Width = 1f; - Line.Begin(); - Line.Draw( + Line.Width = 1f; + Line.Begin(); + Line.Draw( new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight), new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, - position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), + position.X + this.Component.MenuWidth, + position.Y + MenuSettings.ContainerHeight * (valueStrings.Length + 1)), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSeparatorColor); @@ -261,8 +266,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -278,9 +283,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -298,8 +303,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -338,9 +343,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -353,9 +358,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Light2/LightMenu2.cs b/Core/UI/IMenu/Skins/Light2/LightMenu2.cs index b045cad..57a7f48 100644 --- a/Core/UI/IMenu/Skins/Light2/LightMenu2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightMenu2.cs @@ -19,29 +19,23 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class LightMenu2 : LightMenu { - #region Constants - - #endregion - #region Static Fields /// @@ -52,7 +46,7 @@ public class LightMenu2 : LightMenu #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -94,7 +88,6 @@ public class LightMenu2 : LightMenu public LightMenu2(Menu component) : base(component) { - } #endregion @@ -121,9 +114,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -133,14 +126,18 @@ public override void Draw() var centerY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; if (this.Component.Toggled) { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, new ColorBGRA(237, 245, 254, 255)); @@ -152,13 +149,15 @@ public override void Draw() (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset), centerY, - this.Component.Components.Count > 0 ? new ColorBGRA(237, 245, 254, 255) : MenuSettings.ContainerSeparatorColor); + this.Component.Components.Count > 0 + ? new ColorBGRA(237, 245, 254, 255) + : MenuSettings.ContainerSeparatorColor); } else { MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, new ColorBGRA(62, 151, 251, 255)); @@ -170,7 +169,9 @@ public override void Draw() (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - MenuSettings.ContainerTextMarkOffset), centerY, - this.Component.Components.Count > 0 ? new ColorBGRA(5, 151, 250, 255) : MenuSettings.ContainerSeparatorColor); + this.Component.Components.Count > 0 + ? new ColorBGRA(5, 151, 250, 255) + : MenuSettings.ContainerSeparatorColor); } if (this.Component.Toggled) @@ -180,9 +181,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), + new Vector2(position.X + this.Component.MenuWidth / 2f, position.Y), new Vector2( - position.X + this.Component.MenuWidth / 2f, + position.X + this.Component.MenuWidth / 2f, position.Y + MenuSettings.ContainerHeight) }, MenuSettings.ContainerSelectedColor); @@ -200,21 +201,19 @@ public override void Draw() Line.Draw( new[] { - new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), + new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y), new Vector2((position.X + this.Component.MenuWidth) + width / 2, position.Y + height) }, new ColorBGRA(255, 255, 255, 255)); Line.End(); - - for (var i = 0; i < this.Component.Components.Count; ++i) { var childComponent = this.Component.Components.Values.ToList()[i]; if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); childComponent.OnDraw(childPos); @@ -228,33 +227,32 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y + height), + new Vector2(position.X + this.Component.MenuWidth, position.Y + height), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth, position.Y), + new Vector2(position.X + this.Component.MenuWidth, position.Y), new Vector2(position.X + this.Component.MenuWidth, position.Y + height) }, contourColor); Line.Draw( new[] { - new Vector2(position.X + this.Component.MenuWidth + width, position.Y), + new Vector2(position.X + this.Component.MenuWidth + width, position.Y), new Vector2(position.X + this.Component.MenuWidth + width, position.Y + height) }, contourColor); Line.End(); - } if (this.hasDragged && !MenuCustomizer.Instance.LockPosition.Value) @@ -274,9 +272,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -293,13 +291,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -339,7 +341,7 @@ public override int Width() { return (int) - (LightUtilities.MeasureString(this.Component.DisplayName + " \u25B6").Width + (LightUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " \u25B6").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Light2/LightMenuSettings2.cs b/Core/UI/IMenu/Skins/Light2/LightMenuSettings2.cs index 375a4b1..f14292d 100644 --- a/Core/UI/IMenu/Skins/Light2/LightMenuSettings2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightMenuSettings2.cs @@ -22,9 +22,9 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; + using LeagueSharp.SDK.UI.Skins.Light; using SharpDX; using SharpDX.Direct3D9; @@ -67,41 +67,12 @@ static LightMenuSettings2() #endregion - #region Static Fields - - /// - /// Local Caption Font. - /// - private static Font fontCaption; - - #endregion - - #region Constructors and Destructors - - #endregion - #region Public Properties /// /// Gets or sets the Global Caption Font. /// - public static Font FontCaption - { - get - { - return fontCaption; - } - - set - { - fontCaption = value; - } - } - - /// - /// Gets or sets the Global Text Caption Color. - /// - public static ColorBGRA TextCaptionColor { get; set; } + public static Font FontCaption { get; set; } /// /// Gets or sets the Global KeyBind Color. @@ -113,6 +84,11 @@ public static Font FontCaption /// public static ColorBGRA SliderColor { get; set; } + /// + /// Gets or sets the Global Text Caption Color. + /// + public static ColorBGRA TextCaptionColor { get; set; } + #endregion #region Public Methods and Operators @@ -126,6 +102,5 @@ public static void LoadSettings() } #endregion - } } \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Light2/LightSeparator2.cs b/Core/UI/IMenu/Skins/Light2/LightSeparator2.cs index e078a45..173a788 100644 --- a/Core/UI/IMenu/Skins/Light2/LightSeparator2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightSeparator2.cs @@ -19,11 +19,12 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -57,14 +58,14 @@ public override void Draw() var centerY = LightUtilities.GetContainerRectangle(this.Component) .GetCenteredText( null, - LightMenuSettings.FontCaption, - this.Component.DisplayName.ToUpper(), + LightMenuSettings.FontCaption, + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); LightMenuSettings.FontCaption.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName.ToUpper(), - (int)centerY.X, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)centerY.X, (int)centerY.Y, new ColorBGRA(40, 40, 40, 255)); } diff --git a/Core/UI/IMenu/Skins/Light2/LightSlider2.cs b/Core/UI/IMenu/Skins/Light2/LightSlider2.cs index 8450e02..301fcb2 100644 --- a/Core/UI/IMenu/Skins/Light2/LightSlider2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightSlider2.cs @@ -19,13 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -75,7 +76,11 @@ public override void Draw() var centeredY = (int) LightUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.Value - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); @@ -89,20 +94,20 @@ public override void Draw() Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.Value.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width), centeredY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Light2/LightSliderButton2.cs b/Core/UI/IMenu/Skins/Light2/LightSliderButton2.cs index 5ab61ef..29a7bf0 100644 --- a/Core/UI/IMenu/Skins/Light2/LightSliderButton2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightSliderButton2.cs @@ -19,13 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Skins.Light; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -81,7 +82,8 @@ public override void Draw() .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight / 2)); Line.Width = 3; Line.Begin(); @@ -91,20 +93,20 @@ public override void Draw() Line.End(); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), centeredY, MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SValue.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - 5 - measureText.Width - MenuSettings.ContainerHeight), centeredY, MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Light2/LightTextures2.cs b/Core/UI/IMenu/Skins/Light2/LightTextures2.cs index b520e22..70ee506 100644 --- a/Core/UI/IMenu/Skins/Light2/LightTextures2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightTextures2.cs @@ -20,52 +20,75 @@ // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; - -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 +namespace LeagueSharp.SDK.UI.Skins.Light2 { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum LightTexture2 { - Dragging, + Dragging } internal class LightTextures2 { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly LightTextures2 Instance = new LightTextures2(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private LightTextures2() { - this.textures[LightTexture2.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[LightTexture2.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~LightTextures2() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } - public BlueTextureWrapper this[LightTexture2 textureType] + #endregion + + #region Public Indexers + + public BlueTextureWrapper this[LightTexture2 textureType] => this.textures[textureType]; + + #endregion + + #region Public Methods and Operators + + public BlueTextureWrapper AddTexture(Image bmp, int width, int height, LightTexture2 textureType) { - get - { - return this.textures[textureType]; - } + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; } + #endregion + + #region Methods + private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -82,19 +105,12 @@ private BlueTextureWrapper BuildTexture(Image bmp, int height, int width) return new BlueTextureWrapper(texture, width, height); } - public BlueTextureWrapper AddTexture(Image bmp, int width, int height, LightTexture2 textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class BlueTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public BlueTextureWrapper(Texture texture, int width, int height) { @@ -102,6 +118,17 @@ public BlueTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; private set; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Light2/LightTheme2.cs b/Core/UI/IMenu/Skins/Light2/LightTheme2.cs index dffde31..18f1306 100644 --- a/Core/UI/IMenu/Skins/Light2/LightTheme2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightTheme2.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 + +namespace LeagueSharp.SDK.UI.Skins.Light2 { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new LightSlider2(component); + return new LightSliderButton2(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new LightSliderButton2(component); + return new LightSlider2(component); } /// @@ -166,7 +165,7 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X + (width / 2f), position.Y), + new Vector2(position.X + (width / 2f), position.Y), new Vector2(position.X + (width / 2), position.Y + height) }, MenuSettings.RootContainerColor); @@ -200,13 +199,12 @@ public void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), - new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), + new Vector2(position.X, position.Y), new Vector2(position.X + width, position.Y), + new Vector2(position.X + width, position.Y + height), new Vector2(position.X, position.Y + height), new Vector2(position.X, position.Y) }, new ColorBGRA(254, 255, 255, 255)); Line.End(); - } #endregion diff --git a/Core/UI/IMenu/Skins/Light2/LightUtilities2.cs b/Core/UI/IMenu/Skins/Light2/LightUtilities2.cs index c002050..8bfcfce 100644 --- a/Core/UI/IMenu/Skins/Light2/LightUtilities2.cs +++ b/Core/UI/IMenu/Skins/Light2/LightUtilities2.cs @@ -20,10 +20,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Light2 +namespace LeagueSharp.SDK.UI.Skins.Light2 { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using SharpDX; /// @@ -65,9 +63,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/MenuSettings.cs b/Core/UI/IMenu/Skins/MenuSettings.cs index dd8cdce..e4614cf 100644 --- a/Core/UI/IMenu/Skins/MenuSettings.cs +++ b/Core/UI/IMenu/Skins/MenuSettings.cs @@ -19,11 +19,9 @@ // Default Skin Settings. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins -{ - - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; +namespace LeagueSharp.SDK.UI.Skins +{ using SharpDX; using SharpDX.Direct3D9; @@ -38,7 +36,8 @@ public class MenuSettings /// Local Font. /// private static Font font; - + + private static Vector2 position; #endregion @@ -56,16 +55,16 @@ static MenuSettings() Position = new Vector2(30, 30); ContainerWidth = 200f; Font = new Font( - Drawing.Direct3DDevice, - 14, - 0, - FontWeight.DoNotCare, - 0, - false, + Drawing.Direct3DDevice, + 14, + 0, + FontWeight.DoNotCare, + 0, + false, FontCharacterSet.Default, FontPrecision.TrueType, FontQuality.ClearTypeNatural, - FontPitchAndFamily.DontCare | FontPitchAndFamily.Decorative | FontPitchAndFamily.Modern, + FontPitchAndFamily.DontCare | FontPitchAndFamily.Decorative | FontPitchAndFamily.Modern, "Tahoma"); ContainerTextMarkOffset = 8f; ContainerTextOffset = 15f; @@ -135,19 +134,17 @@ public static Font Font /// public static ColorBGRA HoverColor { get; set; } - private static Vector2 position; - /// /// Gets or sets the default menu zero-position. /// - public static Vector2 Position { + public static Vector2 Position + { get { return position; } set { - if (MenuCustomizer.Instance != null) { position = value; diff --git a/Core/UI/IMenu/Skins/Tech/TechBool.cs b/Core/UI/IMenu/Skins/Tech/TechBool.cs index db2055c..c0d3c2e 100644 --- a/Core/UI/IMenu/Skins/Tech/TechBool.cs +++ b/Core/UI/IMenu/Skins/Tech/TechBool.cs @@ -19,11 +19,11 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,7 +67,7 @@ public TechBool(MenuBool component) public Rectangle ButtonBoundaries(MenuBool component) { return new Rectangle( - (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), + (int)(component.Position.X + component.MenuWidth - MenuSettings.ContainerHeight), (int)component.Position.Y, MenuSettings.ContainerHeight, MenuSettings.ContainerHeight); @@ -89,34 +89,52 @@ public override void Draw() var centerY = (int) TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); var centerX = (int) new Rectangle( - (int)(this.Component.Position.X + this.Component.MenuWidth - 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.Value ? "On" : "Off", + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.Value ? "On" : "Off"), CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, this.Component.Value ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, this.Component.Value ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Top @@ -144,8 +162,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.Value ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.Value ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.Value ? new Color(73, 227, 139, 255) : new Color(17, 65, 65, 255)); } diff --git a/Core/UI/IMenu/Skins/Tech/TechButton.cs b/Core/UI/IMenu/Skins/Tech/TechButton.cs index 52e1742..9eac907 100644 --- a/Core/UI/IMenu/Skins/Tech/TechButton.cs +++ b/Core/UI/IMenu/Skins/Tech/TechButton.cs @@ -19,11 +19,11 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -94,8 +94,8 @@ public Rectangle ButtonBoundaries(MenuButton component) var buttonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, component.ButtonText, 0).Width; return new Rectangle( - (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), - (int)component.Position.Y, + (int)(component.Position.X + component.MenuWidth - buttonTextWidth - (2 * TextGap)), + (int)component.Position.Y, (2 * TextGap) + buttonTextWidth, MenuSettings.ContainerHeight); } @@ -114,12 +114,16 @@ public override void Dispose() public override void Draw() { var rectangleName = TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -138,9 +142,9 @@ public override void Draw() this.Component.Hovering ? new ColorBGRA(17, 65, 65, 255) : this.buttonColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.ButtonText, - (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.ButtonText), + (int)(this.Component.Position.X + this.Component.MenuWidth - buttonTextWidth - TextGap), (int)rectangleName.Y, MenuSettings.TextColor); } diff --git a/Core/UI/IMenu/Skins/Tech/TechColorPicker.cs b/Core/UI/IMenu/Skins/Tech/TechColorPicker.cs index 028a9f4..27c77a1 100644 --- a/Core/UI/IMenu/Skins/Tech/TechColorPicker.cs +++ b/Core/UI/IMenu/Skins/Tech/TechColorPicker.cs @@ -19,21 +19,20 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System.Drawing; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Rectangle = SharpDX.Rectangle; - using Utilities = LeagueSharp.SDK.Core.UI.IMenu.Utilities; + using Utilities = LeagueSharp.SDK.UI.Utilities; internal class TechColorPicker : ADrawable { @@ -130,17 +129,17 @@ internal class TechColorPicker : ADrawable /// /// The ColorBox to display the color spectrum. /// - protected ColorBox colorBox; + protected ColorBox ColorBox; /// /// The VerticalAlphaSlider to change the opacity. /// - protected VerticalAlphaSlider verticalAlphaSlider; + protected VerticalAlphaSlider VerticalAlphaSlider; /// /// The VerticalColorSlider to change the color spectrum. /// - protected VerticalColorSlider verticalColorSlider; + protected VerticalColorSlider VerticalColorSlider; #endregion @@ -156,27 +155,27 @@ public TechColorPicker(MenuColor component) : base(component) { Hsl tempHsl; - this.colorBox = new ColorBox(new Size(200, 200), true) + this.ColorBox = new ColorBox(new Size(200, 200), true) { Hsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) + this.VerticalColorSlider = new VerticalColorSlider(new Size(40, 200), true) { CbHsl = Utilities.RgbToHsl(this.Component.Color.ToSystemColor()) }; - this.verticalColorSlider.ColorSliderScroll += () => + this.VerticalColorSlider.ColorSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.H = this.verticalColorSlider.CbHsl.H; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.H = this.VerticalColorSlider.CbHsl.H; + this.ColorBox.Hsl = tempHsl; }; - this.verticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); - tempHsl = this.verticalAlphaSlider.CbHsl; - tempHsl.L = this.colorBox.Hsl.L; - this.verticalAlphaSlider.CbHsl = tempHsl; - this.verticalAlphaSlider.AlphaSliderScroll += () => + this.VerticalAlphaSlider = new VerticalAlphaSlider(new Size(40, 200)); + tempHsl = this.VerticalAlphaSlider.CbHsl; + tempHsl.L = this.ColorBox.Hsl.L; + this.VerticalAlphaSlider.CbHsl = tempHsl; + this.VerticalAlphaSlider.AlphaSliderScroll += () => { - tempHsl = this.colorBox.Hsl; - tempHsl.L = this.verticalAlphaSlider.CbHsl.L; - this.colorBox.Hsl = tempHsl; + tempHsl = this.ColorBox.Hsl; + tempHsl.L = this.VerticalAlphaSlider.CbHsl.L; + this.ColorBox.Hsl = tempHsl; }; } @@ -217,11 +216,15 @@ public override void Dispose() public override void Draw() { var rectangleName = TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); @@ -247,11 +250,11 @@ public override void Draw() new[] { new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + 1 + 3), - new Vector2( - this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, - this.Component.Position.Y + Line.Width + 3) + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + 1 + 3), + new Vector2( + this.Component.Position.X + this.Component.MenuWidth - (Line.Width / 2f) - 4, + this.Component.Position.Y + Line.Width + 3) }, MenuSettings.HoverColor); Line.End(); @@ -262,87 +265,100 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - Line.Width = ColorPickerBoundaries().Width; + Line.Width = this.ColorPickerBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ColorPickerBoundaries().X + 165, ColorPickerBoundaries().Y), + new Vector2(this.ColorPickerBoundaries().X + 165, this.ColorPickerBoundaries().Y), new Vector2( - ColorPickerBoundaries().X + 165, - ColorPickerBoundaries().Y + ColorPickerBoundaries().Height) + this.ColorPickerBoundaries().X + 165, + this.ColorPickerBoundaries().Y + this.ColorPickerBoundaries().Height) }, MenuSettings.RootContainerColor); Line.End(); - colorBox.DrawControl(new Vector2(ColorBoxBoundaries().X, ColorBoxBoundaries().Y)); - verticalColorSlider.DrawControl( - new Vector2(VerticalColorSliderBoundaries().X, VerticalColorSliderBoundaries().Y)); - verticalAlphaSlider.DrawControl( - new Vector2(VerticalAlphaSliderBoundaries().X, VerticalAlphaSliderBoundaries().Y)); + this.ColorBox.DrawControl( + new Vector2(this.ColorBoxBoundaries().X, this.ColorBoxBoundaries().Y)); + this.VerticalColorSlider.DrawControl( + new Vector2( + this.VerticalColorSliderBoundaries().X, + this.VerticalColorSliderBoundaries().Y)); + this.VerticalAlphaSlider.DrawControl( + new Vector2( + this.VerticalAlphaSliderBoundaries().X, + this.VerticalAlphaSliderBoundaries().Y)); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, Color.Black); Utils.DrawBoxFilled( - PreviewBoundaries().X, - PreviewBoundaries().Y, - PreviewBoundaries().Width, - PreviewBoundaries().Height, - colorBox.Rgb.ToSharpDxColor()); + this.PreviewBoundaries().X, + this.PreviewBoundaries().Y, + this.PreviewBoundaries().Width, + this.PreviewBoundaries().Height, + this.ColorBox.Rgb.ToSharpDxColor()); var applyButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Apply", 0).Width; var cancelButtonTextWidth = MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, "Cancel", 0).Width; - Line.Width = ApplyButtonBoundaries().Width; + Line.Width = this.ApplyButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(ApplyButtonBoundaries().X + 25, ApplyButtonBoundaries().Y), + new Vector2(this.ApplyButtonBoundaries().X + 25, this.ApplyButtonBoundaries().Y), new Vector2( - ApplyButtonBoundaries().X + 25, - ApplyButtonBoundaries().Y + ApplyButtonBoundaries().Height) + this.ApplyButtonBoundaries().X + 25, + this.ApplyButtonBoundaries().Y + this.ApplyButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Apply", - ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Apply"), + this.ApplyButtonBoundaries().X - applyButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Apply", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Apply"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); - Line.Width = CancelButtonBoundaries().Width; + Line.Width = this.CancelButtonBoundaries().Width; Line.Begin(); Line.Draw( new[] { - new Vector2(CancelButtonBoundaries().X + 25, CancelButtonBoundaries().Y), + new Vector2(this.CancelButtonBoundaries().X + 25, this.CancelButtonBoundaries().Y), new Vector2( - CancelButtonBoundaries().X + 25, - CancelButtonBoundaries().Y + CancelButtonBoundaries().Height) + this.CancelButtonBoundaries().X + 25, + this.CancelButtonBoundaries().Y + this.CancelButtonBoundaries().Height) }, new ColorBGRA(68, 160, 255, 255)); Line.End(); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "Cancel", - CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, + MultiLanguage.Translation("Cancel"), + this.CancelButtonBoundaries().X - cancelButtonTextWidth / 2 + 25, (int) - CancelButtonBoundaries() - .GetCenteredText(null, MenuSettings.Font, "Cancel", CenteredFlags.VerticalCenter) + this.CancelButtonBoundaries() + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation("Cancel"), + CenteredFlags.VerticalCenter) .Y, new ColorBGRA(221, 233, 255, 255)); }); @@ -376,15 +392,15 @@ public override void OnWndProc(WindowsKeys args) { if (this.InteractingColorBox) { - this.colorBox.ColorBoxMouseMove(args); + this.ColorBox.ColorBoxMouseMove(args); } else if (this.InteractingVerticalColorSlider) { - this.verticalColorSlider.VerticalColorSlider_MouseMove(args); + this.VerticalColorSlider.VerticalColorSliderMouseMove(args); } else if (this.InteractingVerticalAlphaSlider) { - this.verticalAlphaSlider.VerticalAlphaSlider_MouseMove(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseMove(args); } } } @@ -394,17 +410,17 @@ public override void OnWndProc(WindowsKeys args) if (this.InteractingColorBox) { this.InteractingColorBox = false; - this.colorBox.ColorBoxMouseUp(args); + this.ColorBox.ColorBoxMouseUp(args); } if (this.InteractingVerticalColorSlider) { this.InteractingVerticalColorSlider = false; - this.verticalColorSlider.VerticalColorSlider_MouseUp(args); + this.VerticalColorSlider.VerticalColorSliderMouseUp(args); } if (this.InteractingVerticalAlphaSlider) { this.InteractingVerticalAlphaSlider = false; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseUp(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseUp(args); } } @@ -424,7 +440,7 @@ public override void OnWndProc(WindowsKeys args) this.ColorBoxBoundaries().Height)) { this.InteractingColorBox = true; - this.colorBox.ColorBoxMouseDown(args); + this.ColorBox.ColorBoxMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalColorSliderBoundaries().X, @@ -433,7 +449,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalColorSliderBoundaries().Height)) { this.InteractingVerticalColorSlider = true; - this.verticalColorSlider.VerticalColorSlider_MouseDown(args); + this.VerticalColorSlider.VerticalColorSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.VerticalAlphaSliderBoundaries().X, @@ -442,7 +458,7 @@ public override void OnWndProc(WindowsKeys args) this.VerticalAlphaSliderBoundaries().Height)) { this.InteractingVerticalAlphaSlider = true; - this.verticalAlphaSlider.VerticalAlphaSlider_MouseDown(args); + this.VerticalAlphaSlider.VerticalAlphaSliderMouseDown(args); } else if (args.Cursor.IsUnderRectangle( this.ApplyButtonBoundaries().X, @@ -451,7 +467,7 @@ public override void OnWndProc(WindowsKeys args) this.ApplyButtonBoundaries().Height)) { this.Component.Active = false; - this.Component.Color = this.colorBox.Rgb.ToSharpDxColor(); + this.Component.Color = this.ColorBox.Rgb.ToSharpDxColor(); } else if (args.Cursor.IsUnderRectangle( this.CancelButtonBoundaries().X, @@ -460,9 +476,9 @@ public override void OnWndProc(WindowsKeys args) this.CancelButtonBoundaries().Height)) { this.Component.Active = false; - this.colorBox.Rgb = this.Component.Color.ToSystemColor(); - this.verticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); - this.verticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); + this.ColorBox.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalColorSlider.Rgb = this.Component.Color.ToSystemColor(); + this.VerticalAlphaSlider.Rgb = this.Component.Color.ToSystemColor(); } } else if (args.Cursor.IsUnderRectangle( diff --git a/Core/UI/IMenu/Skins/Tech/TechKeyBind.cs b/Core/UI/IMenu/Skins/Tech/TechKeyBind.cs index a1d5237..89ad25e 100644 --- a/Core/UI/IMenu/Skins/Tech/TechKeyBind.cs +++ b/Core/UI/IMenu/Skins/Tech/TechKeyBind.cs @@ -20,13 +20,12 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech +namespace LeagueSharp.SDK.UI.Skins.Tech { using System.Windows.Forms; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -92,11 +91,15 @@ public override void Draw() var centerY = (int) TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.Interacting ? "Press a key" : this.Component.DisplayName, + MultiLanguage.Translation(this.Component.Interacting ? "Press a key" : this.Component.DisplayName), (int)(this.Component.Position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -110,12 +113,14 @@ public override void Draw() Line.Draw( new[] { - new Vector2((this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - - TechUtilities.CalcWidthText(keyString) / 2 - MenuSettings.ContainerTextOffset), - centerY - 2), - new Vector2((this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight - - TechUtilities.CalcWidthText(keyString) / 2 - MenuSettings.ContainerTextOffset), - centerY + TechUtilities.MeasureString(keyString).Height + 2) + new Vector2( + (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight + - TechUtilities.CalcWidthText(keyString) / 2f - MenuSettings.ContainerTextOffset), + centerY - 2), + new Vector2( + (this.Component.Position.X + this.Component.MenuWidth - MenuSettings.ContainerHeight + - TechUtilities.CalcWidthText(keyString) / 2f - MenuSettings.ContainerTextOffset), + centerY + TechUtilities.MeasureString(keyString).Height + 2) }, new Color(17, 32, 27, 255)); Line.End(); @@ -139,15 +144,29 @@ public override void Draw() MenuSettings.ContainerHeight).GetCenteredText( null, MenuSettings.Font, - this.Component.Active ? "On" : "Off", + MultiLanguage.Translation(this.Component.Active ? "On" : "Off"), CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, this.Component.Active ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Top @@ -175,8 +194,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.Active ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.Active ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.Active ? new Color(73, 227, 139, 255) : new Color(17, 65, 65, 255)); } diff --git a/Core/UI/IMenu/Skins/Tech/TechList.cs b/Core/UI/IMenu/Skins/Tech/TechList.cs index 4f7afea..f51202f 100644 --- a/Core/UI/IMenu/Skins/Tech/TechList.cs +++ b/Core/UI/IMenu/Skins/Tech/TechList.cs @@ -19,13 +19,13 @@ // A custom implementation of a // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System.Collections.Generic; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -102,27 +102,31 @@ public override void Draw() var dropdownMenuWidth = this.dropDownButtonWidth + (2 * TextSpacing) + this.Component.MaxStringWidth; var position = this.Component.Position; var rectangleName = TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter); + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, - (int)(position.X + MenuSettings.ContainerTextOffset), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), + (int)(position.X + MenuSettings.ContainerTextOffset), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u23EC", - (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), + "\u23EC", + (int)(position.X + this.Component.MenuWidth - this.dropDownButtonWidth + ArrowSpacing), (int)rectangleName.Y, MenuSettings.TextColor); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SelectedValueAsObject.ToString(), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SelectedValueAsObject.ToString()), (int)position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing - - this.Component.MaxStringWidth, + - this.Component.MaxStringWidth, (int)rectangleName.Y, MenuSettings.TextColor); @@ -133,20 +137,24 @@ public override void Draw() MenuManager.Instance.DrawDelayed( delegate { - var color = MenuSettings.RootContainerColor; - - Utils.DrawBoxRounded(position.X + Component.MenuWidth - dropdownMenuWidth, position.Y + MenuSettings.ContainerHeight, - dropdownMenuWidth, dropdownMenuHeight, 4, true, - MenuSettings.RootContainerColor, new ColorBGRA(55, 76, 95, 255)); + Utils.DrawBoxRounded( + position.X + this.Component.MenuWidth - dropdownMenuWidth, + position.Y + MenuSettings.ContainerHeight, + dropdownMenuWidth, + dropdownMenuHeight, + 4, + true, + MenuSettings.RootContainerColor, + new ColorBGRA(55, 76, 95, 255)); var x = (int) - (position.X + Component.MenuWidth - dropDownButtonWidth - TextSpacing - - Component.MaxStringWidth); + (position.X + this.Component.MenuWidth - this.dropDownButtonWidth - TextSpacing + - this.Component.MaxStringWidth); var y = (int)rectangleName.Y; for (var i = 0; i < valueStrings.Length; i++) { - if (i == Component.HoveringIndex) + if (i == this.Component.HoveringIndex) { Line.Width = MenuSettings.ContainerHeight; Line.Begin(); @@ -154,11 +162,11 @@ public override void Draw() new[] { new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth, + position.X + this.Component.MenuWidth - dropdownMenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) - + MenuSettings.ContainerHeight / 2f), + + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + ((i + 1) * MenuSettings.ContainerHeight) + MenuSettings.ContainerHeight / 2f) }, @@ -166,37 +174,38 @@ public override void Draw() Line.End(); } - if (i != 0) { + if (i != 0) + { Line.Width = 1f; Line.Begin(); Line.Draw( new[] { - new Vector2( - position.X + Component.MenuWidth - dropdownMenuWidth + 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))), - new Vector2( - position.X + Component.MenuWidth - 10, - position.Y + (MenuSettings.ContainerHeight * (i + 1))) + new Vector2( + position.X + this.Component.MenuWidth - dropdownMenuWidth + 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))), + new Vector2( + position.X + this.Component.MenuWidth - 10, + position.Y + (MenuSettings.ContainerHeight * (i + 1))) }, MenuSettings.ContainerSeparatorColor); Line.End(); } - + y += MenuSettings.ContainerHeight; MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - valueStrings[i], - x, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(valueStrings[i]), + x, y, MenuSettings.TextColor); - if (Component.Index == i) + if (this.Component.Index == i) { var checkmarkWidth = MenuSettings.Font.MeasureText(null, "\u2713", 0).Width; MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - "\u2713", - (int)(position.X + Component.MenuWidth - checkmarkWidth - TextSpacing), + "\u2713", + (int)(position.X + this.Component.MenuWidth - checkmarkWidth - TextSpacing), y, new ColorBGRA(1, 165, 226, 255)); } @@ -216,8 +225,8 @@ public Rectangle DropDownBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, + - component.MaxStringWidth), + (int)component.Position.Y, this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight); } @@ -233,9 +242,9 @@ public Rectangle DropDownExpandedBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)component.Position.Y, - this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, + - component.MaxStringWidth), + (int)component.Position.Y, + this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, (component.Count + 1) * MenuSettings.ContainerHeight); } @@ -253,8 +262,8 @@ public List DropDownListBoundaries(MenuList component) new Rectangle( (int) (component.Position.X + component.MenuWidth - this.dropDownButtonWidth - (2 * TextSpacing) - - component.MaxStringWidth), - (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), + - component.MaxStringWidth), + (int)(component.Position.Y + ((i + 1) * MenuSettings.ContainerHeight)), this.dropDownButtonWidth + (2 * TextSpacing) + component.MaxStringWidth, MenuSettings.ContainerHeight + 1)); } @@ -293,9 +302,9 @@ public override void OnWndProc(WindowsKeys args) const int Buffer = 20; if (this.Component.Active && !args.Cursor.IsUnderRectangle( - entireDropdownRect.X - Buffer, - entireDropdownRect.Y - Buffer, - entireDropdownRect.Width + (2 * Buffer), + entireDropdownRect.X - Buffer, + entireDropdownRect.Y - Buffer, + entireDropdownRect.Width + (2 * Buffer), entireDropdownRect.Height + (2 * Buffer))) { this.Component.Active = false; @@ -308,9 +317,9 @@ public override void OnWndProc(WindowsKeys args) for (var i = 0; i < dropdownRectangles.Count; i++) { if (args.Cursor.IsUnderRectangle( - dropdownRectangles[i].X, - dropdownRectangles[i].Y, - dropdownRectangles[i].Width, + dropdownRectangles[i].X, + dropdownRectangles[i].Y, + dropdownRectangles[i].Width, dropdownRectangles[i].Height)) { this.Component.HoveringIndex = i; diff --git a/Core/UI/IMenu/Skins/Tech/TechMenu.cs b/Core/UI/IMenu/Skins/Tech/TechMenu.cs index d2da792..ee13f1b 100644 --- a/Core/UI/IMenu/Skins/Tech/TechMenu.cs +++ b/Core/UI/IMenu/Skins/Tech/TechMenu.cs @@ -19,29 +19,22 @@ // Provides a custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System.Linq; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Customizer; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; - using Color = SharpDX.Color; - /// /// Provides a default implementation of /// public class TechMenu : ADrawable { - #region Constants - - #endregion - #region Static Fields /// @@ -52,7 +45,7 @@ public class TechMenu : ADrawable #endregion #region Fields - + /// /// Gets or sets a value indicating whether the user is dragging the menu. /// @@ -94,13 +87,180 @@ public class TechMenu : ADrawable public TechMenu(Menu component) : base(component) { - } #endregion #region Public Methods and Operators + /// + /// Draws a rounded Box. If Smoothing is true it will draw also a border. + /// + /// Position X + /// Position Y + /// Width + /// Height + /// Radius + /// Color + /// Border Color + public static void DrawBoxBotRounded( + float x, + float y, + float w, + float h, + float radius, + Color color, + Color bcolor) + { + Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. + Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. + Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. + Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. + Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. + + Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); + // Top-left corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + radius, + radius - 1, + 90, + Utils.CircleType.Quarter, + true, + 16, + color); // Top-right corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius - 1, + 180, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-right corner + Utils.DrawCircleFilled( + x + radius, + y + h - radius - 1, + radius - 1, + 270, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-left corner + + Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-left corner + Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-right corner + Utils.DrawCircle( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-right corner + Utils.DrawCircle( + x + radius + 1, + y + h - radius - 1, + radius, + 270, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-left corner + + Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line + Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line + Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line + Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line + } + + /// + /// Draws a rounded Box. If Smoothing is true it will draw also a border. + /// + /// Position X + /// Position Y + /// Width + /// Height + /// Radius + /// Color + /// Border Color + public static void DrawBoxTopRounded( + float x, + float y, + float w, + float h, + float radius, + Color color, + Color bcolor) + { + Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. + Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. + Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. + Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. + Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. + + Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); + // Top-left corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + radius, + radius - 1, + 90, + Utils.CircleType.Quarter, + true, + 16, + color); // Top-right corner + Utils.DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius - 1, + 180, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-right corner + Utils.DrawCircleFilled( + x + radius, + y + h - radius - 1, + radius - 1, + 270, + Utils.CircleType.Quarter, + true, + 16, + color); // Bottom-left corner + + Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-left corner + Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); + // Top-right corner + Utils.DrawCircle( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-right corner + Utils.DrawCircle( + x + radius + 1, + y + h - radius - 1, + radius, + 270, + Utils.CircleType.Quarter, + true, + 16, + bcolor); // Bottom-left corner + + Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line + Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line + Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line + Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line + } + /// /// Disposes any resources used in this handler. /// @@ -121,9 +281,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), + new Vector2(position.X, position.Y + MenuSettings.ContainerHeight / 2f), new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + MenuSettings.ContainerHeight / 2f) }, MenuSettings.HoverColor); @@ -138,7 +298,7 @@ public override void Draw() MenuSettings.Font.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), centerY, MenuSettings.TextColor); @@ -147,19 +307,25 @@ public override void Draw() delegate { var symbolCenterY = - (int) - TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, TechMenuSettings.FontMenuSymbol, this.Component.DisplayName, CenteredFlags.VerticalCenter) - .Y; + (int) + TechUtilities.GetContainerRectangle(this.Component) + .GetCenteredText( + null, + TechMenuSettings.FontMenuSymbol, + this.Component.DisplayName, + CenteredFlags.VerticalCenter) + .Y; TechMenuSettings.FontMenuSymbol.DrawText( MenuManager.Instance.Sprite, "›", (int) (position.X + this.Component.MenuWidth - MenuSettings.ContainerTextMarkWidth - - MenuSettings.ContainerTextMarkOffset) + 1, + - MenuSettings.ContainerTextMarkOffset) + 1, symbolCenterY, - this.Component.Components.Count > 0 ? TechMenuSettings.TextCaptionColor : MenuSettings.ContainerSeparatorColor); + this.Component.Components.Count > 0 + ? TechMenuSettings.TextCaptionColor + : MenuSettings.ContainerSeparatorColor); }); if (this.Component.Toggled) @@ -184,8 +350,15 @@ public override void Draw() width = this.Component.Components.First().Value.MenuWidth; } - Utils.DrawBoxRounded(position.X + this.Component.MenuWidth, position.Y, width, height + 1, 4, true, - MenuSettings.RootContainerColor, MenuSettings.TextColor); + Utils.DrawBoxRounded( + position.X + this.Component.MenuWidth, + position.Y, + width, + height + 1, + 4, + true, + MenuSettings.RootContainerColor, + MenuSettings.TextColor); for (var i = 0; i < this.Component.Components.Count; ++i) { @@ -193,7 +366,7 @@ public override void Draw() if (childComponent != null) { var childPos = new Vector2( - position.X + this.Component.MenuWidth, + position.X + this.Component.MenuWidth, position.Y + i * MenuSettings.ContainerHeight); childComponent.OnDraw(childPos); @@ -210,37 +383,37 @@ public override void Draw() Line.Draw( new[] { - new Vector2(rec.Left + 1, rec.Bottom - 2), - new Vector2(rec.Right - 2, rec.Bottom - 2) + new Vector2(rec.Left + 1, rec.Bottom - 2), + new Vector2(rec.Right - 2, rec.Bottom - 2) }, TechMenuSettings.TextCaptionColor); - } - else if (childComponent is MenuBool || childComponent is MenuButton || childComponent is MenuColor || childComponent is MenuKeyBind - || childComponent is MenuList || childComponent is MenuSlider) + else if (childComponent is MenuBool || childComponent is MenuButton + || childComponent is MenuColor || childComponent is MenuKeyBind + || childComponent is MenuList || childComponent is MenuSlider) { Line.Begin(); Line.Draw( new[] { - new Vector2(rec.Left + 1, rec.Bottom), - new Vector2(rec.Right - 2, rec.Bottom) + new Vector2(rec.Left + 1, rec.Bottom), + new Vector2(rec.Right - 2, rec.Bottom) }, new Color(13, 34, 37, 255)); Line.Draw( new[] { - new Vector2(rec.Left + 1, rec.Bottom), - new Vector2(rec.Left + 5, rec.Bottom) + new Vector2(rec.Left + 1, rec.Bottom), + new Vector2(rec.Left + 5, rec.Bottom) }, TechMenuSettings.TextCaptionColor); Line.Draw( new[] { - new Vector2(rec.Right - 6, rec.Bottom), - new Vector2(rec.Right - 2, rec.Bottom) + new Vector2(rec.Right - 6, rec.Bottom), + new Vector2(rec.Right - 2, rec.Bottom) }, TechMenuSettings.TextCaptionColor); } @@ -250,8 +423,8 @@ public override void Draw() Line.Draw( new[] { - new Vector2(rec.Left + 1, rec.Bottom), - new Vector2(rec.Right - 2, rec.Bottom) + new Vector2(rec.Left + 1, rec.Bottom), + new Vector2(rec.Right - 2, rec.Bottom) }, TechMenuSettings.TextCaptionColor); } @@ -278,9 +451,9 @@ public override void Draw() Line.Draw( new[] { - new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), - new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), - new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), + new Vector2(x - 1, y + 1), new Vector2(x - 1 + dragTexture.Width, y + 1), + new Vector2(x - 1 + dragTexture.Width, y + dragTexture.Width + 2), + new Vector2(x - 2, y + dragTexture.Width + 2), new Vector2(x - 2, y), }, MenuSettings.ContainerSeparatorColor); Line.End(); @@ -297,13 +470,17 @@ public override void OnWndProc(WindowsKeys args) { if (this.Component.Visible) { - if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging && !MenuCustomizer.Instance.LockPosition.Value) + if (args.Msg == WindowsMessages.MOUSEMOVE && this.dragging + && !MenuCustomizer.Instance.LockPosition.Value) { MenuSettings.Position = new Vector2(args.Cursor.X - this.xd, args.Cursor.Y - this.yd); this.hasDragged = true; } - if (args.Cursor.IsUnderRectangle(this.Component.Position.X, this.Component.Position.Y, this.Component.MenuWidth, + if (args.Cursor.IsUnderRectangle( + this.Component.Position.X, + this.Component.Position.Y, + this.Component.MenuWidth, MenuSettings.ContainerHeight)) { if (args.Msg == WindowsMessages.LBUTTONDOWN && this.Component.Root) @@ -333,74 +510,6 @@ public override void OnWndProc(WindowsKeys args) } } - /// - /// Draws a rounded Box. If Smoothing is true it will draw also a border. - /// - /// Position X - /// Position Y - /// Width - /// Height - /// Radius - /// Color - /// Border Color - public static void DrawBoxTopRounded(float x, float y, float w, float h, float radius, Color color, Color bcolor) - { - Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. - Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. - Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. - Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. - Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. - - Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); // Top-left corner - Utils.DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, Utils.CircleType.Quarter, true, 16, color); // Top-right corner - Utils.DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius - 1, 180, Utils.CircleType.Quarter, true, 16, color); // Bottom-right corner - Utils.DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, Utils.CircleType.Quarter, true, 16, color); // Bottom-left corner - - Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); // Top-left corner - Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); // Top-right corner - Utils.DrawCircle(x + w - radius - 1, y + h - radius - 1, radius, 180, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-right corner - Utils.DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-left corner - - Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line - Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line - Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line - Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line - } - - /// - /// Draws a rounded Box. If Smoothing is true it will draw also a border. - /// - /// Position X - /// Position Y - /// Width - /// Height - /// Radius - /// Color - /// Border Color - public static void DrawBoxBotRounded(float x, float y, float w, float h, float radius, Color color, Color bcolor) - { - Utils.DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. - Utils.DrawBoxFilled(x + radius, y + 1, w - 2 * radius - 1, radius - 1, color); // Top rect. - Utils.DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. - Utils.DrawBoxFilled(x + 1, y + radius, radius - 1, h - 2 * radius - 1, color); // Left rect. - Utils.DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. - - Utils.DrawCircleFilled(x + radius, y + radius, radius - 1, 0, Utils.CircleType.Quarter, true, 16, color); // Top-left corner - Utils.DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, Utils.CircleType.Quarter, true, 16, color); // Top-right corner - Utils.DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius - 1, 180, Utils.CircleType.Quarter, true, 16, color); // Bottom-right corner - Utils.DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, Utils.CircleType.Quarter, true, 16, color); // Bottom-left corner - - Utils.DrawCircle(x + radius + 1, y + radius + 1, radius, 0, Utils.CircleType.Quarter, true, 16, bcolor); // Top-left corner - Utils.DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, Utils.CircleType.Quarter, true, 16, bcolor); // Top-right corner - Utils.DrawCircle(x + w - radius - 1, y + h - radius - 1, radius, 180, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-right corner - Utils.DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, Utils.CircleType.Quarter, true, 16, bcolor); // Bottom-left corner - - Utils.DrawLine(x + radius, y + 1, x + w - radius - 1, y + 1, 1, bcolor); // Top line - Utils.DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line - Utils.DrawLine(x + 1, y + radius, x + 1, y + h - radius - 1, 1, bcolor); // Left line - Utils.DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line - } - /// /// Calculates the Width of an AMenuComponent /// @@ -411,7 +520,7 @@ public override int Width() { return (int) - (TechUtilities.MeasureString(this.Component.DisplayName + " »").Width + (TechUtilities.MeasureString(MultiLanguage.Translation(this.Component.DisplayName) + " »").Width + (MenuSettings.ContainerTextOffset * 2) + MenuSettings.ContainerTextMarkWidth); } diff --git a/Core/UI/IMenu/Skins/Tech/TechMenuSettings.cs b/Core/UI/IMenu/Skins/Tech/TechMenuSettings.cs index 869fd65..327d731 100644 --- a/Core/UI/IMenu/Skins/Tech/TechMenuSettings.cs +++ b/Core/UI/IMenu/Skins/Tech/TechMenuSettings.cs @@ -22,9 +22,8 @@ //Concept by User Vasconcellos -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech +namespace LeagueSharp.SDK.UI.Skins.Tech { - using SharpDX; using SharpDX.Direct3D9; @@ -33,20 +32,6 @@ namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech /// public class TechMenuSettings : MenuSettings { - #region Static Fields - - /// - /// Local Caption Font. - /// - private static Font fontCaption; - - /// - /// Local Caption Font. - /// - private static Font fontMenuSymbol; - - #endregion - #region Constructors and Destructors /// @@ -110,39 +95,12 @@ static TechMenuSettings() /// /// Gets or sets the Global Caption Font. /// - public static Font FontCaption - { - get - { - return fontCaption; - } - - set - { - fontCaption = value; - } - } + public static Font FontCaption { get; set; } /// /// Gets or sets the Global Symbol Menu Font. /// - public static Font FontMenuSymbol - { - get - { - return fontMenuSymbol; - } - - set - { - fontMenuSymbol = value; - } - } - - /// - /// Gets or sets the Global Text Caption Color. - /// - public static ColorBGRA TextCaptionColor { get; set; } + public static Font FontMenuSymbol { get; set; } /// /// Gets or sets the Global KeyBind Color. @@ -154,6 +112,11 @@ public static Font FontMenuSymbol /// public static ColorBGRA SliderColor { get; set; } + /// + /// Gets or sets the Global Text Caption Color. + /// + public static ColorBGRA TextCaptionColor { get; set; } + #endregion #region Public Methods and Operators @@ -163,7 +126,6 @@ public static Font FontMenuSymbol /// public static void LoadSettings() { - } #endregion diff --git a/Core/UI/IMenu/Skins/Tech/TechSeparator.cs b/Core/UI/IMenu/Skins/Tech/TechSeparator.cs index ea68cf8..ea95eba 100644 --- a/Core/UI/IMenu/Skins/Tech/TechSeparator.cs +++ b/Core/UI/IMenu/Skins/Tech/TechSeparator.cs @@ -19,12 +19,12 @@ // Implements as a custom skin. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; using SharpDX.Direct3D9; /// @@ -32,7 +32,6 @@ namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech /// public class TechSeparator : ADrawable { - #region Static Fields /// @@ -81,12 +80,12 @@ public override void Draw() .GetCenteredText( null, TechMenuSettings.FontCaption, - this.Component.DisplayName.ToUpper(), + MultiLanguage.Translation(this.Component.DisplayName), CenteredFlags.VerticalCenter | CenteredFlags.HorizontalCenter); TechMenuSettings.FontCaption.DrawText( MenuManager.Instance.Sprite, - this.Component.DisplayName.ToUpper(), + MultiLanguage.Translation(this.Component.DisplayName), (int)centerY.X, (int)centerY.Y, TechMenuSettings.TextCaptionColor); diff --git a/Core/UI/IMenu/Skins/Tech/TechSlider.cs b/Core/UI/IMenu/Skins/Tech/TechSlider.cs index f493b3b..995ae17 100644 --- a/Core/UI/IMenu/Skins/Tech/TechSlider.cs +++ b/Core/UI/IMenu/Skins/Tech/TechSlider.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -126,20 +126,20 @@ public override void Draw() }); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.Value.ToString(CultureInfo.InvariantCulture), + null, + this.Component.Value.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.Value.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset), + MenuManager.Instance.Sprite, + this.Component.Value.ToString(CultureInfo.InvariantCulture), + (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); diff --git a/Core/UI/IMenu/Skins/Tech/TechSliderButton.cs b/Core/UI/IMenu/Skins/Tech/TechSliderButton.cs index 40568e4..7c85a67 100644 --- a/Core/UI/IMenu/Skins/Tech/TechSliderButton.cs +++ b/Core/UI/IMenu/Skins/Tech/TechSliderButton.cs @@ -19,14 +19,14 @@ // A custom implementation of an // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System; using System.Globalization; - using LeagueSharp.SDK; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; @@ -67,20 +67,6 @@ public TechSliderButton(MenuSliderButton component) #region Public Methods and Operators - /// - /// Returns the Rectangle that defines the Slider - /// - /// The - /// The - public Rectangle SliderBoundaries(MenuSliderButton component) - { - return new Rectangle( - (int)component.Position.X + Offset, - (int)component.Position.Y, - component.MenuWidth - MenuSettings.ContainerHeight - (int)(Offset * 1.1), - MenuSettings.ContainerHeight); - } - /// /// Returns the Rectangle that defines the on/off Button /// @@ -114,11 +100,16 @@ public override void Draw() var centeredY = (int) TechUtilities.GetContainerRectangle(this.Component) - .GetCenteredText(null, MenuSettings.Font, this.Component.DisplayName, CenteredFlags.VerticalCenter) + .GetCenteredText( + null, + MenuSettings.Font, + MultiLanguage.Translation(this.Component.DisplayName), + CenteredFlags.VerticalCenter) .Y; var percent = (this.Component.SValue - this.Component.MinValue) / (float)(this.Component.MaxValue - this.Component.MinValue); - var x = position.X + Offset + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); + var x = position.X + Offset + + (percent * (this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); var maxX = position.X + Offset + ((this.Component.MenuWidth - Offset * 2 - MenuSettings.ContainerHeight)); MenuManager.Instance.DrawDelayed( @@ -136,20 +127,20 @@ public override void Draw() }); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.DisplayName, + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.DisplayName), (int)(position.X + MenuSettings.ContainerTextOffset), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); var measureText = MenuSettings.Font.MeasureText( - null, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), + null, + this.Component.SValue.ToString(CultureInfo.InvariantCulture), 0); MenuSettings.Font.DrawText( - MenuManager.Instance.Sprite, - this.Component.SValue.ToString(CultureInfo.InvariantCulture), - (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset - MenuSettings.ContainerHeight), + MenuManager.Instance.Sprite, + MultiLanguage.Translation(this.Component.SValue.ToString(CultureInfo.InvariantCulture)), + (int)(position.X + this.Component.MenuWidth - measureText.Width - Offset - MenuSettings.ContainerHeight), (int)(position.Y + (centeredY - position.Y) / 2), MenuSettings.TextColor); @@ -190,11 +181,25 @@ public override void Draw() CenteredFlags.HorizontalCenter).X - 5; //Left - Utils.DrawCircle(centerX, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 270, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 270, + Utils.CircleType.Half, + true, + 32, this.Component.BValue ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Right - Utils.DrawCircle(centerX + 15, this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 7, 90, Utils.CircleType.Half, true, 32, + Utils.DrawCircle( + centerX + 15, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 7, + 90, + Utils.CircleType.Half, + true, + 32, this.Component.BValue ? new Color(75, 215, 128, 255) : new Color(36, 204, 205, 255)); //Top @@ -222,8 +227,14 @@ public override void Draw() Line.End(); //FullCircle - Utils.DrawCircleFilled(this.Component.BValue ? centerX + 14 : centerX + 1, - this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, 6, 0, Utils.CircleType.Full, true, 32, + Utils.DrawCircleFilled( + this.Component.BValue ? centerX + 14 : centerX + 1, + this.Component.Position.Y + MenuSettings.ContainerHeight / 2f, + 6, + 0, + Utils.CircleType.Full, + true, + 32, this.Component.BValue ? new Color(73, 227, 139, 255) : new Color(17, 65, 65, 255)); } @@ -269,6 +280,20 @@ public override void OnWndProc(WindowsKeys args) } } + /// + /// Returns the Rectangle that defines the Slider + /// + /// The + /// The + public Rectangle SliderBoundaries(MenuSliderButton component) + { + return new Rectangle( + (int)component.Position.X + Offset, + (int)component.Position.Y, + component.MenuWidth - MenuSettings.ContainerHeight - (int)(Offset * 1.1), + MenuSettings.ContainerHeight); + } + /// /// Calculates the width of this component /// diff --git a/Core/UI/IMenu/Skins/Tech/TechTextures.cs b/Core/UI/IMenu/Skins/Tech/TechTextures.cs index f54db80..d38e022 100644 --- a/Core/UI/IMenu/Skins/Tech/TechTextures.cs +++ b/Core/UI/IMenu/Skins/Tech/TechTextures.cs @@ -19,14 +19,15 @@ // A custom implementation of // // -------------------------------------------------------------------------------------------------------------------- -using System.Collections.Generic; -using System.Linq; -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech +namespace LeagueSharp.SDK.UI.Skins.Tech { + using System.Collections.Generic; using System.Drawing; + using System.Linq; using LeagueSharp.SDK.Properties; + using SharpDX.Direct3D9; internal enum TechTexture @@ -36,23 +37,38 @@ internal enum TechTexture internal class TechTextures { - - private readonly Dictionary textures = new Dictionary(); + #region Static Fields public static readonly TechTextures Instance = new TechTextures(); + #endregion + + #region Fields + + private readonly Dictionary textures = + new Dictionary(); + + #endregion + + #region Constructors and Destructors + private TechTextures() { - this.textures[TechTexture.Dragging] = BuildTexture(Resources.cursor_drag, 16, 16); + this.textures[TechTexture.Dragging] = this.BuildTexture(Resources.cursor_drag, 16, 16); } ~TechTextures() { - foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) { + foreach (var entry in this.textures.Where(entry => !entry.Value.Texture.IsDisposed)) + { entry.Value.Texture.Dispose(); } } + #endregion + + #region Public Indexers + public TechTextureWrapper this[TechTexture textureType] { get @@ -61,10 +77,24 @@ public TechTextureWrapper this[TechTexture textureType] } } + #endregion + + #region Public Methods and Operators + + public TechTextureWrapper AddTexture(Image bmp, int width, int height, TechTexture textureType) + { + this.textures[textureType] = this.BuildTexture(bmp, height, width); + return this.textures[textureType]; + } + + #endregion + + #region Methods + private TechTextureWrapper BuildTexture(Image bmp, int height, int width) { var resized = new Bitmap(bmp, width, height); - var texture = Texture.FromMemory( + var texture = Texture.FromMemory( Drawing.Direct3DDevice, (byte[])new ImageConverter().ConvertTo(resized, typeof(byte[])), resized.Width, @@ -81,19 +111,12 @@ private TechTextureWrapper BuildTexture(Image bmp, int height, int width) return new TechTextureWrapper(texture, width, height); } - public TechTextureWrapper AddTexture(Image bmp, int width, int height, TechTexture textureType) - { - this.textures[textureType] = BuildTexture(bmp, height, width); - return this.textures[textureType]; - } - + #endregion } internal class TechTextureWrapper { - public Texture Texture { get; private set; } - public int Width { get; private set; } - public int Height { get; private set; } + #region Constructors and Destructors public TechTextureWrapper(Texture texture, int width, int height) { @@ -101,6 +124,17 @@ public TechTextureWrapper(Texture texture, int width, int height) this.Width = width; this.Height = height; } - + + #endregion + + #region Public Properties + + public int Height { get; private set; } + + public Texture Texture { get; private set; } + + public int Width { get; private set; } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/IMenu/Skins/Tech/TechTheme.cs b/Core/UI/IMenu/Skins/Tech/TechTheme.cs index ec67665..a661b75 100644 --- a/Core/UI/IMenu/Skins/Tech/TechTheme.cs +++ b/Core/UI/IMenu/Skins/Tech/TechTheme.cs @@ -19,12 +19,11 @@ // Implements a custom ITheme. // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech + +namespace LeagueSharp.SDK.UI.Skins.Tech { using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using SharpDX; using SharpDX.Direct3D9; @@ -128,23 +127,23 @@ public ADrawable BuildSeparatorHandler(MenuSeparator component) } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderHandler(MenuSlider component) + public ADrawable BuildSliderButtonHandler(MenuSliderButton component) { - return new TechSlider(component); + return new TechSliderButton(component); } /// - /// Builds a new handler for the given . + /// Builds a new handler for the given . /// - /// The where this handler is responsible for. + /// The where this handler is responsible for. /// The handler - public ADrawable BuildSliderButtonHandler(MenuSliderButton component) + public ADrawable BuildSliderHandler(MenuSlider component) { - return new TechSliderButton(component); + return new TechSlider(component); } /// @@ -161,8 +160,16 @@ public void Draw() width = menuManager.Menus.First().MenuWidth; } - Utils.DrawBoxRounded(position.X - 1, position.Y - 1, width + 2, height + 3, 4, true, - MenuSettings.RootContainerColor, new ColorBGRA(13, 37, 37, 255), new ColorBGRA(30, 126, 125, 255)); + Utils.DrawBoxRounded( + position.X - 1, + position.Y - 1, + width + 2, + height + 3, + 4, + true, + MenuSettings.RootContainerColor, + new ColorBGRA(13, 37, 37, 255), + new ColorBGRA(30, 126, 125, 255)); for (var i = 0; i < menuManager.Menus.Count; ++i) { diff --git a/Core/UI/IMenu/Skins/Tech/TechUtilities.cs b/Core/UI/IMenu/Skins/Tech/TechUtilities.cs index ba5ebec..19bc907 100644 --- a/Core/UI/IMenu/Skins/Tech/TechUtilities.cs +++ b/Core/UI/IMenu/Skins/Tech/TechUtilities.cs @@ -20,9 +20,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins.Tech +namespace LeagueSharp.SDK.UI.Skins.Tech { - using LeagueSharp.SDK.Core.UI.IMenu.Abstracts; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -40,7 +40,10 @@ public class TechUtilities /// The width public static int CalcWidthItem(MenuItem menuItem) { - return (int)(MeasureString(menuItem.DisplayName).Width + (MenuSettings.ContainerTextOffset * 2)); + return + (int) + (MeasureString(MultiLanguage.Translation(menuItem.DisplayName)).Width + + (MenuSettings.ContainerTextOffset * 2)); } /// @@ -50,7 +53,7 @@ public static int CalcWidthItem(MenuItem menuItem) /// The public static int CalcWidthText(string text) { - return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, text, 0).Width; + return MenuSettings.Font.MeasureText(MenuManager.Instance.Sprite, MultiLanguage.Translation(text), 0).Width; } /// @@ -65,9 +68,9 @@ public static int CalcWidthText(string text) public static Rectangle GetContainerRectangle(AMenuComponent component) { return new Rectangle( - (int)component.Position.X, - (int)component.Position.Y, - component.MenuWidth, + (int)component.Position.X, + (int)component.Position.Y, + component.MenuWidth, MenuSettings.ContainerHeight); } diff --git a/Core/UI/IMenu/Skins/ThemeManager.cs b/Core/UI/IMenu/Skins/ThemeManager.cs index 7f3d593..180ff8b 100644 --- a/Core/UI/IMenu/Skins/ThemeManager.cs +++ b/Core/UI/IMenu/Skins/ThemeManager.cs @@ -15,9 +15,15 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Skins +namespace LeagueSharp.SDK.UI.Skins { - using Default; + using LeagueSharp.SDK.UI.Skins.Blue; + using LeagueSharp.SDK.UI.Skins.Blue2; + using LeagueSharp.SDK.UI.Skins.Colored; + using LeagueSharp.SDK.UI.Skins.Default; + using LeagueSharp.SDK.UI.Skins.Light; + using LeagueSharp.SDK.UI.Skins.Light2; + using LeagueSharp.SDK.UI.Skins.Tech; /// /// Manages themes. @@ -65,5 +71,69 @@ public static ITheme Current public static ITheme Default => @default ?? (@default = new DefaultTheme()); #endregion + + #region Properties + + /// + /// Gets or sets the menu. + /// + private static Menu Menu { get; set; } + + #endregion + + #region Public Methods and Operators + + /// + /// Initializes static members of the class. + /// + /// + /// The menu. + /// + public static void Initialize(Menu menu) + { + Events.OnLoad += (sender, args) => + { + Menu = new Menu("thememanager", "Theme Manager"); + + Menu.Add( + new MenuList( + "themeID", + "Theme", + new[] { "Default", "Blue", "Blue 2", "Light", "Light 2", "Colored", "Tech" })).ValueChanged + += (o, eventArgs) => + { + Notifications.Add(new Notification("Theme Manager", "Please reload Menu !")); + }; + + menu.Add(Menu); + + switch (Menu["themeID"].GetValue().Index) + { + case 0: + Current = new DefaultTheme(); + break; + case 1: + Current = new BlueTheme(); + break; + case 2: + Current = new BlueTheme2(); + break; + case 3: + Current = new LightTheme(); + break; + case 4: + Current = new LightTheme2(); + break; + case 5: + Current = new ColoredTheme(); + break; + case 6: + Current = new TechTheme(); + break; + } + }; + } + + #endregion } } \ No newline at end of file diff --git a/Core/UI/IMenu/Values/MenuBool.cs b/Core/UI/IMenu/Values/MenuBool.cs index bc373af..a5e37b7 100644 --- a/Core/UI/IMenu/Values/MenuBool.cs +++ b/Core/UI/IMenu/Values/MenuBool.cs @@ -15,13 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Runtime.Serialization; using System.Security.Permissions; - using Core.Utils; - using Skins; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// Menu boolean. diff --git a/Core/UI/IMenu/Values/MenuButton.cs b/Core/UI/IMenu/Values/MenuButton.cs index d85be8d..92a177a 100644 --- a/Core/UI/IMenu/Values/MenuButton.cs +++ b/Core/UI/IMenu/Values/MenuButton.cs @@ -15,10 +15,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { - using Core.Utils; - using Skins; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// A Button designed to perform an action when clicked diff --git a/Core/UI/IMenu/Values/MenuColor.cs b/Core/UI/IMenu/Values/MenuColor.cs index 2f17317..e3bc31f 100644 --- a/Core/UI/IMenu/Values/MenuColor.cs +++ b/Core/UI/IMenu/Values/MenuColor.cs @@ -15,14 +15,16 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Runtime.Serialization; using System.Security.Permissions; - using Core.Utils; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; + using SharpDX; - using Skins; /// /// The menu color. diff --git a/Core/UI/IMenu/Values/MenuKeyBind.cs b/Core/UI/IMenu/Values/MenuKeyBind.cs index 536f9f6..dedfa81 100644 --- a/Core/UI/IMenu/Values/MenuKeyBind.cs +++ b/Core/UI/IMenu/Values/MenuKeyBind.cs @@ -15,16 +15,16 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Runtime.Serialization; using System.Security.Permissions; using System.Windows.Forms; - using Core.Utils; - using LeagueSharp.SDK; - using Skins; - using MenuItem = MenuItem; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// Menu KeyBind. @@ -80,11 +80,6 @@ public MenuKeyBind(string name, string displayName, Keys key, KeyBindType type, Game.OnWndProc += this.Game_OnWndProc; } - private void Game_OnWndProc(WndEventArgs args) - { - this.Handler.OnWndProc(new WindowsKeys(args)); - } - /// /// Initializes a new instance of the class. /// @@ -265,6 +260,11 @@ protected virtual void GetObjectData(SerializationInfo info, StreamingContext co info.AddValue("active", this.active, typeof(bool)); } + private void Game_OnWndProc(WndEventArgs args) + { + this.Handler.OnWndProc(new WindowsKeys(args)); + } + #endregion } } \ No newline at end of file diff --git a/Core/UI/IMenu/Values/MenuList.cs b/Core/UI/IMenu/Values/MenuList.cs index a64ddaf..efa213f 100644 --- a/Core/UI/IMenu/Values/MenuList.cs +++ b/Core/UI/IMenu/Values/MenuList.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Collections.Generic; @@ -23,8 +23,8 @@ namespace LeagueSharp.SDK.Core.UI.IMenu.Values using System.Runtime.Serialization; using System.Security.Permissions; - using LeagueSharp.SDK.Core.UI.IMenu.Skins; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// A list of values. @@ -46,7 +46,9 @@ public abstract class MenuList : MenuItem /// /// Initializes a new instance of the class. /// - internal MenuList() {} + internal MenuList() + { + } /// /// Initializes a new instance of the class. @@ -55,7 +57,9 @@ internal MenuList() {} /// Display name of the component /// String to make this component unique protected MenuList(string name, string displayName, string uniqueString = "") - : base(name, displayName, uniqueString) {} + : base(name, displayName, uniqueString) + { + } #endregion @@ -219,7 +223,9 @@ public MenuList(string name, string displayName, IEnumerable objects, string /// The unique String. /// public MenuList(string name, string displayName, string uniqueString = "") - : this(name, displayName, Enum.GetValues(typeof(T)).Cast(), uniqueString) {} + : this(name, displayName, Enum.GetValues(typeof(T)).Cast(), uniqueString) + { + } /// /// Initializes a new instance of the class. diff --git a/Core/UI/IMenu/Values/MenuSeparator.cs b/Core/UI/IMenu/Values/MenuSeparator.cs index 1e2382c..465ee68 100644 --- a/Core/UI/IMenu/Values/MenuSeparator.cs +++ b/Core/UI/IMenu/Values/MenuSeparator.cs @@ -15,10 +15,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { - using Core.Utils; - using Skins; + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// A menu separator. diff --git a/Core/UI/IMenu/Values/MenuSlider.cs b/Core/UI/IMenu/Values/MenuSlider.cs index d674b45..b11dee5 100644 --- a/Core/UI/IMenu/Values/MenuSlider.cs +++ b/Core/UI/IMenu/Values/MenuSlider.cs @@ -15,13 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Runtime.Serialization; using System.Security.Permissions; - using Core.Utils; - using Skins; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// Menu Slider. @@ -67,11 +68,11 @@ public class MenuSlider : MenuItem, ISerializable /// String used in saving settings /// public MenuSlider( - string name, - string displayName, - int value = 0, - int minValue = 0, - int maxValue = 100, + string name, + string displayName, + int value = 0, + int minValue = 0, + int maxValue = 100, string uniqueString = "") : base(name, displayName, uniqueString) { diff --git a/Core/UI/IMenu/Values/MenuSliderButton.cs b/Core/UI/IMenu/Values/MenuSliderButton.cs index 20aa66a..0d7059e 100644 --- a/Core/UI/IMenu/Values/MenuSliderButton.cs +++ b/Core/UI/IMenu/Values/MenuSliderButton.cs @@ -15,13 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.UI.IMenu.Values +namespace LeagueSharp.SDK.UI { using System; using System.Runtime.Serialization; using System.Security.Permissions; - using Core.Utils; - using Skins; + + using LeagueSharp.SDK.UI.Skins; + using LeagueSharp.SDK.Utils; /// /// Menu Slider. @@ -31,26 +32,26 @@ public class MenuSliderButton : MenuItem, ISerializable { #region Fields - /// - /// The original. - /// - private readonly int original; - /// /// The boriginal. /// private readonly bool bOriginal; /// - /// The value. + /// The original. /// - private int value; + private readonly int original; /// /// The Button value. /// private bool bValue; + /// + /// The value. + /// + private int value; + #endregion #region Constructors and Destructors @@ -80,10 +81,10 @@ public class MenuSliderButton : MenuItem, ISerializable /// String used in saving settings /// public MenuSliderButton( - string name, - string displayName, - int value = 0, - int minValue = 0, + string name, + string displayName, + int value = 0, + int minValue = 0, int maxValue = 100, bool bValue = false, string uniqueString = "") @@ -112,6 +113,11 @@ protected MenuSliderButton(SerializationInfo info, StreamingContext context) #region Public Properties + /// + /// Gets or sets a value indicating whether the boolean value is true or false. + /// + public bool BValue { get; set; } + /// /// Gets or sets a value indicating whether this is interacting. /// @@ -130,17 +136,6 @@ protected MenuSliderButton(SerializationInfo info, StreamingContext context) /// public int MinValue { get; set; } - /// - /// Gets the Slider Value if Button is active. - /// - public int Value - { - get - { - return this.SValue != this.MinValue && this.BValue ? this.value : -1; - } - } - /// /// Gets or sets the Slider Current Value. /// @@ -169,9 +164,9 @@ public int SValue } /// - /// Gets or sets a value indicating whether the boolean value is true or false. + /// Gets the Slider Value if Button is active. /// - public bool BValue { get; set; } + public int Value => this.SValue != this.MinValue && this.BValue ? this.value : -1; /// /// Slider Item Width. @@ -283,4 +278,4 @@ protected virtual void GetObjectData(SerializationInfo info, StreamingContext co #endregion } -} +} \ No newline at end of file diff --git a/Core/UI/Notifications/ANotification.cs b/Core/UI/Notifications/ANotification.cs index e8b536b..fc993ac 100644 --- a/Core/UI/Notifications/ANotification.cs +++ b/Core/UI/Notifications/ANotification.cs @@ -17,7 +17,7 @@ namespace LeagueSharp.SDK { - using Core.Utils; + using LeagueSharp.SDK.Utils; using SharpDX; diff --git a/Core/UI/Notifications/Notification.cs b/Core/UI/Notifications/Notification.cs index f8170cd..1bb6553 100644 --- a/Core/UI/Notifications/Notification.cs +++ b/Core/UI/Notifications/Notification.cs @@ -21,14 +21,16 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Drawing; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; using LeagueSharp.SDK.Properties; + using LeagueSharp.SDK.Utils; using SharpDX; using SharpDX.Direct3D9; using Color = SharpDX.Color; using Font = SharpDX.Direct3D9.Font; + using Rectangle = SharpDX.Rectangle; /// /// The notification. @@ -102,8 +104,8 @@ public class Notification : ANotification /// /// The line. /// - private static readonly SharpDX.Direct3D9.Line Line = new SharpDX.Direct3D9.Line(Drawing.Direct3DDevice) - { Antialias = true, GLLines = true, Width = 300f }; + private static readonly Line Line = new Line(Drawing.Direct3DDevice) + { Antialias = true, GLLines = true, Width = 300f }; /// /// The sprite. @@ -638,7 +640,7 @@ public override void OnDraw(Vector2 basePosition) Sprite.Draw( HideTexture, Color.White, - new SharpDX.Rectangle(0, 0, HideBitmap.Width, (int)this.DrawFooterHeight)); + new Rectangle(0, 0, HideBitmap.Width, (int)this.DrawFooterHeight)); } Sprite.Transform = matrix; @@ -760,14 +762,14 @@ public override void OnWndProc(Vector2 basePosition, WindowsKeys windowsKeys, bo /// /// The . /// - private SharpDX.Rectangle GetBodyRectangle(Vector2 basePosition) + private Rectangle GetBodyRectangle(Vector2 basePosition) { const int BaseLeftPosition = 144; var x = basePosition.X - (this.Width / 2f) - BaseLeftPosition; var y = basePosition.Y + this.HeaderHeight + 2f; - return new SharpDX.Rectangle((int)x, (int)y, (int)this.Width, (int)this.DrawBodyHeight); + return new Rectangle((int)x, (int)y, (int)this.Width, (int)this.DrawBodyHeight); } /// @@ -777,20 +779,20 @@ private SharpDX.Rectangle GetBodyRectangle(Vector2 basePosition) /// The base Position. /// /// - /// The . + /// The . /// - private SharpDX.Rectangle GetHeaderRectangle(Vector2 basePosition) + private Rectangle GetHeaderRectangle(Vector2 basePosition) { const int BaseLeftPosition = 140; var x = basePosition.X - (this.Width / 2f) - BaseLeftPosition; var y = basePosition.Y - + new SharpDX.Rectangle(0, 0, 0, (int)this.HeaderHeight).GetCenteredText( + + new Rectangle(0, 0, 0, (int)this.HeaderHeight).GetCenteredText( Sprite, this.Header, CenteredFlags.VerticalCenter).Y; - return new SharpDX.Rectangle((int)x, (int)y, (int)this.Width, (int)this.HeaderHeight); + return new Rectangle((int)x, (int)y, (int)this.Width, (int)this.HeaderHeight); } #endregion diff --git a/Core/UI/Notifications/NotificationIcons.cs b/Core/UI/Notifications/NotificationIcons.cs index 78f5460..169e43b 100644 --- a/Core/UI/Notifications/NotificationIcons.cs +++ b/Core/UI/Notifications/NotificationIcons.cs @@ -20,7 +20,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Drawing; using System.Linq; - using Properties; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Properties; using SharpDX.Direct3D9; @@ -37,9 +39,9 @@ public class NotificationIcons private static readonly IDictionary IconBitmaps = new Dictionary { - { NotificationIconType.Error, Resources.notifications_error }, - { NotificationIconType.Warning, Resources.notifications_warning }, - { NotificationIconType.Check, Resources.notifications_check }, + { NotificationIconType.Error, Resources.notifications_error }, + { NotificationIconType.Warning, Resources.notifications_warning }, + { NotificationIconType.Check, Resources.notifications_check }, { NotificationIconType.Select, Resources.notifications_select } }; @@ -61,18 +63,18 @@ static NotificationIcons() foreach (var bitmap in IconBitmaps.Where(bitmap => !IconTextures.ContainsKey(bitmap.Key))) { IconTextures.Add( - bitmap.Key, + bitmap.Key, Texture.FromMemory( - Drawing.Direct3DDevice, - (byte[])new ImageConverter().ConvertTo(bitmap.Value, typeof(byte[])), - bitmap.Value.Width, - bitmap.Value.Height, - 0, - Usage.None, - Format.A1, - Pool.Managed, - Filter.Default, - Filter.Default, + Drawing.Direct3DDevice, + (byte[])new ImageConverter().ConvertTo(bitmap.Value, typeof(byte[])), + bitmap.Value.Width, + bitmap.Value.Height, + 0, + Usage.None, + Format.A1, + Pool.Managed, + Filter.Default, + Filter.Default, 0)); } } diff --git a/Core/UI/Notifications/Notifications.cs b/Core/UI/Notifications/Notifications.cs index 5c70f33..ecc003e 100644 --- a/Core/UI/Notifications/Notifications.cs +++ b/Core/UI/Notifications/Notifications.cs @@ -21,11 +21,12 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; using SharpDX; + using SharpDX.Direct3D9; /// /// The notifications main handler. @@ -42,7 +43,7 @@ public class Notifications /// /// The line. /// - private static SharpDX.Direct3D9.Line line; + private static Line line; #endregion @@ -65,7 +66,7 @@ public class Notifications /// /// Gets the line. /// - private static SharpDX.Direct3D9.Line Line + private static Line Line { get { @@ -74,7 +75,7 @@ private static SharpDX.Direct3D9.Line Line return line; } - return line = new SharpDX.Direct3D9.Line(Drawing.Direct3DDevice) { Antialias = false, GLLines = true }; + return line = new Line(Drawing.Direct3DDevice) { Antialias = false, GLLines = true }; } } diff --git a/Core/UI/Utils.cs b/Core/UI/Utils.cs index 6f1502c..b933eb4 100644 --- a/Core/UI/Utils.cs +++ b/Core/UI/Utils.cs @@ -1,4 +1,4 @@ -namespace LeagueSharp.SDK.Core.UI +namespace LeagueSharp.SDK.UI { using System; using System.Collections.Generic; @@ -6,43 +6,87 @@ using SharpDX; using SharpDX.Direct3D9; - class Utils + internal class Utils { + #region Static Fields + /// /// The line. /// private static readonly Line Line = new Line(Drawing.Direct3DDevice) { GLLines = true }; + #endregion + + #region Enums + /// - /// Draws a line from X to Y with a width and a color + /// Circle Type Enum /// - /// Position X1 - /// Position Y1 - /// Position X2 - /// Position Y2 - /// Width - /// Color - public static void DrawLine(float xa, float ya, float xb, float yb, float dwWidth, Color color) + public enum CircleType { - Vector2[] vLine = new Vector2[2]; - Line.Width = dwWidth; - Line.Begin(); + Full, - vLine[0][0] = xa; // Set points into array - vLine[0][1] = ya; - vLine[1][0] = xb; - vLine[1][1] = yb; + Half, - Line.Draw(new[] - { - vLine[0], - vLine[1] - }, color); // Draw with Line, number of lines, and color - Line.End(); // finish + Quarter + } + + #endregion + + #region Public Methods and Operators + + /// + /// Draws a Box + /// + /// Position X + /// Position Y + /// Width + /// Height + /// Line Width + /// Color + public static void DrawBox(float x, float y, float w, float h, float linewidth, Color color) + { + if (linewidth.Equals(0) || linewidth.Equals(1)) + { + DrawBoxFilled(x, y, w, 1, color); // Top + DrawBoxFilled(x, y + h - 1, w, 1, color); // Bottom + DrawBoxFilled(x, y + 1, 1, h - 2 * 1, color); // Left + DrawBoxFilled(x + w - 1, y + 1, 1, h - 2 * 1, color); // Right + } + else + { + DrawBoxFilled(x, y, w, linewidth, color); // Top + DrawBoxFilled(x, y + h - linewidth, w, linewidth, color); // Bottom + DrawBoxFilled(x, y + linewidth, linewidth, h - 2 * linewidth, color); // Left + DrawBoxFilled(x + w - linewidth, y + linewidth, linewidth, h - 2 * linewidth, color); // Right + } + } + + /// + /// Draws a bordered Box + /// + /// Position X + /// Position Y + /// Width + /// Height + /// The border width + /// Color + /// Border Color + public static void DrawBoxBordered( + float x, + float y, + float w, + float h, + float borderWidth, + Color color, + Color colorBorder) + { + DrawBoxFilled(x, y, w, h, color); + DrawBox(x - borderWidth, y - borderWidth, w + 2 * borderWidth, h + borderWidth, borderWidth, colorBorder); } /// - /// Draws a filled Box + /// Draws a filled Box /// /// Position X /// Position Y @@ -51,7 +95,7 @@ public static void DrawLine(float xa, float ya, float xb, float yb, float dwWidt /// Color public static void DrawBoxFilled(float x, float y, float w, float h, Color color) { - Vector2[] vLine = new Vector2[2]; + var vLine = new Vector2[2]; Line.Width = w; Line.Begin(); @@ -60,77 +104,103 @@ public static void DrawBoxFilled(float x, float y, float w, float h, Color color vLine[1][0] = x + w / 2; vLine[1][1] = y + h; - Line.Draw(new[] - { - vLine[0], - vLine[1] - }, color); + Line.Draw(new[] { vLine[0], vLine[1] }, color); Line.End(); } /// - /// Draws a rounded Rectangle + /// Draws a rounded Box. If Smoothing is true it will draw a border too. /// /// Position X /// Position Y /// Width /// Height - /// Smooth + /// Radius + /// Smoothing /// Color - public static void RoundedRectangle(int x, int y, int w, int h, int iSmooth, Color color) + /// Border Color + /// Corner Color + public static void DrawBoxRounded( + float x, + float y, + float w, + float h, + float radius, + bool smoothing, + Color color, + Color bcolor, + Color? ccolor = null) { - Vector2[] pt = new Vector2[4]; - - // Get all corners - pt[0].X = x + (w - iSmooth); - pt[0].Y = y + (h - iSmooth); - - pt[1].X = x + iSmooth; - pt[1].Y = y + (h - iSmooth); - - pt[2].X = x + iSmooth; - pt[2].Y = y + iSmooth; - - pt[3].X = x + w - iSmooth; - pt[3].Y = y + iSmooth; + var cornerColor = ccolor ?? bcolor; + DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. + DrawBoxFilled(x + radius, y, w - 2 * radius - 1, radius, color); // Top rect. + DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. + DrawBoxFilled(x, y + radius, radius, h - 2 * radius - 1, color); // Left rect. + DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. - // Draw cross - DrawBoxFilled(x, y + iSmooth, w, h - iSmooth * 2, color); - - DrawBoxFilled(x + iSmooth, y, w - iSmooth * 2, h, color); - - - float fDegree = 0; - - for (int i = 0; i < 4; i++) + // Smoothing method + if (smoothing) { - for (float k = fDegree; k < fDegree + (Math.PI * 2) / 4f; k += (float)((1) * (Math.PI / 180.0f))) - { - // Draw quarter circles on every corner - DrawLine(pt[i].X, pt[i].Y, - pt[i].X + (float)(Math.Cos(k) * iSmooth), - pt[i].Y + (float)(Math.Sin(k) * iSmooth), - 1, color); // 3 is with line width - } - - fDegree += (float)(Math.PI * 2) / 4; // quarter circle offset + DrawCircleFilled(x + radius, y + radius, radius - 1, 0, CircleType.Quarter, true, 16, color); + // Top-left corner + DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, CircleType.Quarter, true, 16, color); + // Top-right corner + DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius - 1, + 180, + CircleType.Quarter, + true, + 16, + color); // Bottom-right corner + DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, CircleType.Quarter, true, 16, color); + // Bottom-left corner + + DrawCircle(x + radius + 1, y + radius + 1, radius, 0, CircleType.Quarter, true, 16, cornerColor); + // Top-left corner + DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, CircleType.Quarter, true, 16, cornerColor); + // Top-right corner + DrawCircle( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + CircleType.Quarter, + true, + 16, + cornerColor); // Bottom-right corner + DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, CircleType.Quarter, true, 16, cornerColor); + // Bottom-left corner + + DrawLine(x + radius, y, x + w - radius - 1, y, 1, bcolor); // Top line + DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line + DrawLine(x, y + radius, x, y + h - radius - 1, 1, bcolor); // Left line + DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line + } + else + { + DrawCircleFilled(x + radius, y + radius, radius, 0, CircleType.Quarter, false, 16, color); + // Top-left corner + DrawCircleFilled(x + w - radius - 1, y + radius, radius, 90, CircleType.Quarter, false, 16, color); + // Top-right corner + DrawCircleFilled( + x + w - radius - 1, + y + h - radius - 1, + radius, + 180, + CircleType.Quarter, + false, + 16, + color); // Bottom-right corner + DrawCircleFilled(x + radius, y + h - radius - 1, radius, 270, CircleType.Quarter, false, 16, color); + // Bottom-left corner } - - } - - /// - /// Circle Type Enum - /// - public enum CircleType - { - Full, - Half, - Quarter } /// - /// Draws a Circle (not filled) + /// Draws a Circle (not filled) /// /// Position X /// Position Y @@ -140,51 +210,82 @@ public enum CircleType /// Smooth Antialiasing /// Real smooth value /// Color - public static void DrawCircle(float x, float y, float radius, int rotate, CircleType type, bool smoothing, int resolution, Color color) + public static void DrawCircle( + float x, + float y, + float radius, + int rotate, + CircleType type, + bool smoothing, + int resolution, + Color color) { - VertexBuffer vertices = new VertexBuffer( - Drawing.Direct3DDevice, Utilities.SizeOf() * 2 * (resolution + 4), Usage.WriteOnly, VertexFormat.Diffuse | VertexFormat.PositionRhw, Pool.Default); + var vertices = new VertexBuffer( + Drawing.Direct3DDevice, + SharpDX.Utilities.SizeOf() * 2 * (resolution + 4), + Usage.WriteOnly, + VertexFormat.Diffuse | VertexFormat.PositionRhw, + Pool.Default); - float angle = rotate * (float)Math.PI / 180f; - float pi = 0.0f; + var angle = rotate * (float)Math.PI / 180f; + var pi = 0.0f; - if (type == CircleType.Full) pi = (float)Math.PI; // Full circle - if (type == CircleType.Half) pi = (float)Math.PI / 2f; // 1/2 circle - if (type == CircleType.Quarter) pi = (float)Math.PI / 4f; // 1/4 circle + if (type == CircleType.Full) + { + pi = (float)Math.PI; // Full circle + } + if (type == CircleType.Half) + { + pi = (float)Math.PI / 2f; // 1/2 circle + } + if (type == CircleType.Quarter) + { + pi = (float)Math.PI / 4f; // 1/4 circle + } - List data = new List(); + var data = new List(); - for (int i = 0; i < resolution + 4; i++) + for (var i = 0; i < resolution + 4; i++) { - float x1 = x - radius * (float)Math.Cos(i * (2f * pi / resolution)); - float y1 = y - radius * (float)Math.Sin(i * (2f * pi / resolution)); - data.AddRange(new[] - { - new Vector4(x1, y1, 0f, 1.0f), color.ToVector4() - }); + var x1 = x - radius * (float)Math.Cos(i * (2f * pi / resolution)); + var y1 = y - radius * (float)Math.Sin(i * (2f * pi / resolution)); + data.AddRange(new[] { new Vector4(x1, y1, 0f, 1.0f), color.ToVector4() }); } // Rotate matrix - int res = 2 * resolution + 4; - for (int i = 0; i < res; i = i + 2) + var res = 2 * resolution + 4; + for (var i = 0; i < res; i = i + 2) { - data[i] = new Vector4((float)(x + Math.Cos(angle) * (data[i].X - x) - Math.Sin(angle) * (data[i].Y - y)), + data[i] = new Vector4( + (float)(x + Math.Cos(angle) * (data[i].X - x) - Math.Sin(angle) * (data[i].Y - y)), (float)(y + Math.Sin(angle) * (data[i].X - x) + Math.Cos(angle) * (data[i].Y - y)), - data[i].Z, data[i].W); + data[i].Z, + data[i].W); } vertices.Lock(0, 0, LockFlags.None).WriteRange(data.ToArray()); vertices.Unlock(); - VertexElement[] vertexElements = { + VertexElement[] vertexElements = + { new VertexElement( - 0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0), + 0, + 0, + DeclarationType.Float4, + DeclarationMethod.Default, + DeclarationUsage.Position, + 0), new VertexElement( - 0, 16, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Color, 0), + 0, + 16, + DeclarationType.Float4, + DeclarationMethod.Default, + DeclarationUsage.Color, + 0), VertexElement.VertexDeclarationEnd - }; + }; - VertexDeclaration vertexDeclaration = new VertexDeclaration(Drawing.Direct3DDevice, vertexElements); + var vertexDeclaration = new VertexDeclaration(Drawing.Direct3DDevice, vertexElements); if (smoothing) { @@ -198,7 +299,7 @@ public static void DrawCircle(float x, float y, float radius, int rotate, Circle } var olddec = Drawing.Direct3DDevice.VertexDeclaration; - Drawing.Direct3DDevice.SetStreamSource(0, vertices, 0, Utilities.SizeOf() * 2); + Drawing.Direct3DDevice.SetStreamSource(0, vertices, 0, SharpDX.Utilities.SizeOf() * 2); Drawing.Direct3DDevice.VertexDeclaration = vertexDeclaration; Drawing.Direct3DDevice.DrawPrimitives(PrimitiveType.LineStrip, 0, resolution); Drawing.Direct3DDevice.VertexDeclaration = olddec; @@ -208,7 +309,7 @@ public static void DrawCircle(float x, float y, float radius, int rotate, Circle } /// - /// Draws a filled Circle + /// Draws a filled Circle /// /// Position X /// Position Y @@ -218,54 +319,83 @@ public static void DrawCircle(float x, float y, float radius, int rotate, Circle /// Smooth Antialiasing /// Real smooth value /// Color - public static void DrawCircleFilled(float x, float y, float rad, float rotate, CircleType type, bool smoothing, int resolution, Color color) + public static void DrawCircleFilled( + float x, + float y, + float rad, + float rotate, + CircleType type, + bool smoothing, + int resolution, + Color color) { - VertexBuffer vertices = new VertexBuffer( - Drawing.Direct3DDevice, Utilities.SizeOf() * 2 * (resolution + 4), Usage.WriteOnly, VertexFormat.Diffuse | VertexFormat.PositionRhw, Pool.Default); + var vertices = new VertexBuffer( + Drawing.Direct3DDevice, + SharpDX.Utilities.SizeOf() * 2 * (resolution + 4), + Usage.WriteOnly, + VertexFormat.Diffuse | VertexFormat.PositionRhw, + Pool.Default); - double angle = rotate * Math.PI / 180d; - double pi = 0.0d; + var angle = rotate * Math.PI / 180d; + var pi = 0.0d; - if (type == CircleType.Full) pi = Math.PI; // Full circle - if (type == CircleType.Half) pi = Math.PI / 2d; // 1/2 circle - if (type == CircleType.Quarter) pi = Math.PI / 4d; // 1/4 circle + if (type == CircleType.Full) + { + pi = Math.PI; // Full circle + } + if (type == CircleType.Half) + { + pi = Math.PI / 2d; // 1/2 circle + } + if (type == CircleType.Quarter) + { + pi = Math.PI / 4d; // 1/4 circle + } - List data = new List(new [] - { - new Vector4(x, y, 0f, 1f), color.ToVector4() - }); + var data = new List(new[] { new Vector4(x, y, 0f, 1f), color.ToVector4() }); - for (int i = 1; i < resolution + 4; i++) + for (var i = 1; i < resolution + 4; i++) { - float x1 = (float)(x - rad * Math.Cos(pi * ((i - 1) / (resolution / 2.0f)))); - float y1 = (float)(y - rad * Math.Sin(pi * ((i - 1) / (resolution / 2.0f)))); - data.AddRange(new[] - { - new Vector4(x1, y1, 0f, 1.0f), color.ToVector4() - }); + var x1 = (float)(x - rad * Math.Cos(pi * ((i - 1) / (resolution / 2.0f)))); + var y1 = (float)(y - rad * Math.Sin(pi * ((i - 1) / (resolution / 2.0f)))); + data.AddRange(new[] { new Vector4(x1, y1, 0f, 1.0f), color.ToVector4() }); } // Rotate matrix - int res = 2 * resolution + 4; - for (int i = 0; i < res; i = i + 2) + var res = 2 * resolution + 4; + for (var i = 0; i < res; i = i + 2) { - data[i] = new Vector4((float)(x + Math.Cos(angle) * (data[i].X - x) - Math.Sin(angle) * (data[i].Y - y)), + data[i] = new Vector4( + (float)(x + Math.Cos(angle) * (data[i].X - x) - Math.Sin(angle) * (data[i].Y - y)), (float)(y + Math.Sin(angle) * (data[i].X - x) + Math.Cos(angle) * (data[i].Y - y)), - data[i].Z, data[i].W); + data[i].Z, + data[i].W); } - vertices.Lock(0, Utilities.SizeOf() * 2 * (resolution + 4), LockFlags.None).WriteRange(data.ToArray()); + vertices.Lock(0, SharpDX.Utilities.SizeOf() * 2 * (resolution + 4), LockFlags.None) + .WriteRange(data.ToArray()); vertices.Unlock(); - VertexElement[] vertexElements = { + VertexElement[] vertexElements = + { new VertexElement( - 0, 0, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Position, 0), + 0, + 0, + DeclarationType.Float4, + DeclarationMethod.Default, + DeclarationUsage.Position, + 0), new VertexElement( - 0, 16, DeclarationType.Float4, DeclarationMethod.Default, DeclarationUsage.Color, 0), + 0, + 16, + DeclarationType.Float4, + DeclarationMethod.Default, + DeclarationUsage.Color, + 0), VertexElement.VertexDeclarationEnd - }; + }; - VertexDeclaration vertexDeclaration = new VertexDeclaration(Drawing.Direct3DDevice, vertexElements); + var vertexDeclaration = new VertexDeclaration(Drawing.Direct3DDevice, vertexElements); if (smoothing) { @@ -279,7 +409,7 @@ public static void DrawCircleFilled(float x, float y, float rad, float rotate, C } var olddec = Drawing.Direct3DDevice.VertexDeclaration; - Drawing.Direct3DDevice.SetStreamSource(0, vertices, 0, Utilities.SizeOf() * 2); + Drawing.Direct3DDevice.SetStreamSource(0, vertices, 0, SharpDX.Utilities.SizeOf() * 2); Drawing.Direct3DDevice.VertexDeclaration = vertexDeclaration; Drawing.Direct3DDevice.DrawPrimitives(PrimitiveType.TriangleFan, 0, resolution); Drawing.Direct3DDevice.VertexDeclaration = olddec; @@ -289,103 +419,80 @@ public static void DrawCircleFilled(float x, float y, float rad, float rotate, C } /// - /// Draws a Box + /// Draws a line from X to Y with a width and a color /// - /// Position X - /// Position Y - /// Width - /// Height - /// Line Width + /// Position X1 + /// Position Y1 + /// Position X2 + /// Position Y2 + /// Width /// Color - public static void DrawBox(float x, float y, float w, float h, float linewidth, Color color) + public static void DrawLine(float xa, float ya, float xb, float yb, float dwWidth, Color color) { - if (linewidth.Equals(0) || linewidth.Equals(1)) - { - DrawBoxFilled(x, y, w, 1, color); // Top - DrawBoxFilled(x, y + h - 1, w, 1, color); // Bottom - DrawBoxFilled(x, y + 1, 1, h - 2 * 1, color); // Left - DrawBoxFilled(x + w - 1, y + 1, 1, h - 2 * 1, color); // Right - } - else - { - DrawBoxFilled(x, y, w, linewidth, color); // Top - DrawBoxFilled(x, y + h - linewidth, w, linewidth, color); // Bottom - DrawBoxFilled(x, y + linewidth, linewidth, h - 2 * linewidth, color); // Left - DrawBoxFilled(x + w - linewidth, y + linewidth, linewidth, h - 2 * linewidth, color); // Right - } - } + var vLine = new Vector2[2]; + Line.Width = dwWidth; + Line.Begin(); - /// - /// Draws a bordered Box - /// - /// Position X - /// Position Y - /// Width - /// Height - /// The border width - /// Color - /// Border Color - public static void DrawBoxBordered(float x, float y, float w, float h, float borderWidth, Color color, Color colorBorder) - { - DrawBoxFilled(x, y, w, h, color); - DrawBox(x - borderWidth, y - borderWidth, w + 2 * borderWidth, h + borderWidth, borderWidth, colorBorder); + vLine[0][0] = xa; // Set points into array + vLine[0][1] = ya; + vLine[1][0] = xb; + vLine[1][1] = yb; + + Line.Draw(new[] { vLine[0], vLine[1] }, color); // Draw with Line, number of lines, and color + Line.End(); // finish } /// - /// Draws a rounded Box. If Smoothing is true it will draw a border too. + /// Draws a rounded Rectangle /// /// Position X /// Position Y /// Width /// Height - /// Radius - /// Smoothing + /// Smooth /// Color - /// Border Color - /// Corner Color - public static void DrawBoxRounded(float x, float y, float w, float h, float radius, bool smoothing, Color color, Color bcolor, Color? ccolor = null) + public static void RoundedRectangle(int x, int y, int w, int h, int iSmooth, Color color) { - Color cornerColor; - if (!ccolor.HasValue) - { - cornerColor = bcolor; - } - else - { - cornerColor = ccolor.Value; - } + var pt = new Vector2[4]; - DrawBoxFilled(x + radius, y + radius, w - 2 * radius - 1, h - 2 * radius - 1, color); // Center rect. - DrawBoxFilled(x + radius, y, w - 2 * radius - 1, radius, color); // Top rect. - DrawBoxFilled(x + radius, y + h - radius - 1, w - 2 * radius - 1, radius, color); // Bottom rect. - DrawBoxFilled(x, y + radius, radius, h - 2 * radius - 1, color); // Left rect. - DrawBoxFilled(x + w - radius - 1, y + radius, radius, h - 2 * radius - 1, color); // Right rect. + // Get all corners + pt[0].X = x + (w - iSmooth); + pt[0].Y = y + (h - iSmooth); - // Smoothing method - if (smoothing) - { - DrawCircleFilled(x + radius, y + radius, radius - 1, 0, CircleType.Quarter, true, 16, color); // Top-left corner - DrawCircleFilled(x + w - radius - 1, y + radius, radius - 1, 90, CircleType.Quarter, true, 16, color); // Top-right corner - DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius - 1, 180, CircleType.Quarter, true, 16, color); // Bottom-right corner - DrawCircleFilled(x + radius, y + h - radius - 1, radius - 1, 270, CircleType.Quarter, true, 16, color); // Bottom-left corner - - DrawCircle(x + radius + 1, y + radius + 1, radius, 0, CircleType.Quarter, true, 16, cornerColor); // Top-left corner - DrawCircle(x + w - radius - 1, y + radius + 1, radius, 90, CircleType.Quarter, true, 16, cornerColor); // Top-right corner - DrawCircle(x + w - radius - 1, y + h - radius - 1, radius, 180, CircleType.Quarter, true, 16, cornerColor); // Bottom-right corner - DrawCircle(x + radius + 1, y + h - radius - 1, radius, 270, CircleType.Quarter, true, 16, cornerColor); // Bottom-left corner - - DrawLine(x + radius, y, x + w - radius - 1, y, 1, bcolor); // Top line - DrawLine(x + radius, y + h - 2, x + w - radius - 1, y + h - 2, 1, bcolor); // Bottom line - DrawLine(x, y + radius, x, y + h - radius - 1, 1, bcolor); // Left line - DrawLine(x + w - 2, y + radius, x + w - 2, y + h - radius - 1, 1, bcolor); // Right line - } - else + pt[1].X = x + iSmooth; + pt[1].Y = y + (h - iSmooth); + + pt[2].X = x + iSmooth; + pt[2].Y = y + iSmooth; + + pt[3].X = x + w - iSmooth; + pt[3].Y = y + iSmooth; + + // Draw cross + DrawBoxFilled(x, y + iSmooth, w, h - iSmooth * 2, color); + + DrawBoxFilled(x + iSmooth, y, w - iSmooth * 2, h, color); + + float fDegree = 0; + + for (var i = 0; i < 4; i++) { - DrawCircleFilled(x + radius, y + radius, radius, 0, CircleType.Quarter, false, 16, color); // Top-left corner - DrawCircleFilled(x + w - radius - 1, y + radius, radius, 90, CircleType.Quarter, false, 16, color); // Top-right corner - DrawCircleFilled(x + w - radius - 1, y + h - radius - 1, radius, 180, CircleType.Quarter, false, 16, color); // Bottom-right corner - DrawCircleFilled(x + radius, y + h - radius - 1, radius, 270, CircleType.Quarter, false, 16, color); // Bottom-left corner + for (var k = fDegree; k < fDegree + (Math.PI * 2) / 4f; k += (float)((1) * (Math.PI / 180.0f))) + { + // Draw quarter circles on every corner + DrawLine( + pt[i].X, + pt[i].Y, + pt[i].X + (float)(Math.Cos(k) * iSmooth), + pt[i].Y + (float)(Math.Sin(k) * iSmooth), + 1, + color); // 3 is with line width + } + + fDegree += (float)(Math.PI * 2) / 4; // quarter circle offset } } + + #endregion } -} +} \ No newline at end of file diff --git a/Core/Utils/ActionQueue.cs b/Core/Utils/ActionQueue.cs index 3b0f8b9..59245ea 100644 --- a/Core/Utils/ActionQueue.cs +++ b/Core/Utils/ActionQueue.cs @@ -1,11 +1,11 @@ -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Reflection; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// Queues actions. diff --git a/Core/Utils/AutoAttack.cs b/Core/Utils/AutoAttack.cs index 23352ac..e948fef 100644 --- a/Core/Utils/AutoAttack.cs +++ b/Core/Utils/AutoAttack.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Linq; @@ -143,15 +143,19 @@ public static float GetRealAutoAttackRange(this AttackableUnit target) /// public static float GetRealAutoAttackRange(this Obj_AI_Base sender, AttackableUnit target) { - if (sender == null) + if (!sender.IsValid()) { return 0; } - var result = sender.AttackRange + sender.BoundingRadius + (target?.BoundingRadius ?? 0); + + var result = sender.AttackRange + sender.BoundingRadius + + (target != null && target.IsValid ? target.BoundingRadius : 0); var heroSource = sender as Obj_AI_Hero; + if (heroSource != null && heroSource.ChampionName == "Caitlyn") { var aiBaseTarget = target as Obj_AI_Base; + if (aiBaseTarget != null && aiBaseTarget.HasBuff("caitlynyordletrapinternal")) { result += 650; @@ -168,15 +172,17 @@ public static float GetRealAutoAttackRange(this Obj_AI_Base sender, AttackableUn public static float GetTimeToHit(this AttackableUnit target) { var time = (GameObjects.Player.AttackCastDelay * 1000) - 100 + (Game.Ping / 2f); + if (Math.Abs(GameObjects.Player.GetProjectileSpeed() - float.MaxValue) > float.Epsilon) { var aiBaseTarget = target as Obj_AI_Base; time += 1000 * Math.Max( - 0, GameObjects.Player.Distance(aiBaseTarget?.ServerPosition ?? target.Position) - - GameObjects.Player.BoundingRadius) / GameObjects.Player.BasicAttack.MissileSpeed; + - GameObjects.Player.BoundingRadius, + 0) / GameObjects.Player.BasicAttack.MissileSpeed; } + return time; } diff --git a/Core/Utils/BinarySerializer.cs b/Core/Utils/BinarySerializer.cs index c7c3043..25b2d0d 100644 --- a/Core/Utils/BinarySerializer.cs +++ b/Core/Utils/BinarySerializer.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System.IO; using System.Runtime.Serialization; @@ -44,7 +44,7 @@ public static T Deserialize(byte[] data) { using ( var reader = XmlDictionaryReader.CreateBinaryReader( - new MemoryStream(data), + new MemoryStream(data), XmlDictionaryReaderQuotas.Max)) { return (T)new DataContractSerializer(typeof(T)).ReadObject(reader); diff --git a/Core/Utils/Cache.cs b/Core/Utils/Cache.cs index 82b0405..5e8a3d0 100644 --- a/Core/Utils/Cache.cs +++ b/Core/Utils/Cache.cs @@ -15,149 +15,88 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Linq; using System.Runtime.Caching; - using LeagueSharp.SDK; - /// - /// Provides an implementation of ObjectCache, for any object. Check for - /// implemented abilities. + /// Represents the type that implements an in-memory cache. /// public class Cache : ObjectCache { - #region Static Fields + #region Constants /// - /// The instance. + /// The default cache region name. /// - private static Cache instance; + public const string DefaultCacheRegionName = "Default"; #endregion - #region Fields - - /// - /// Main Cache. - /// - internal readonly Dictionary> InternalCache; - - /// - /// Holds callbacks that are called before cached item is removed. - /// - private readonly SortedDictionary cacheEntryUpdateCallbacks; + #region Static Fields /// - /// Holds callbacks that are called after cached item is removed. + /// The instance /// - private readonly SortedDictionary cacheRemovedCallbacks; + private static Cache instance; #endregion - #region Constructors and Destructors + #region Public Properties /// - /// Prevents a default instance of the class from being created. + /// Gets the instance. /// - private Cache() - { - this.InternalCache = new Dictionary>(); - this.CreateRegion("Default"); - - this.cacheEntryUpdateCallbacks = new SortedDictionary(); - this.cacheRemovedCallbacks = new SortedDictionary(); - } - - #endregion - - #region Delegates + /// + /// The instance. + /// + public static Cache Instance => instance ?? (instance = new Cache()); - /// - /// Delegate when a value is added. - /// - /// The Sender - /// Passed Arguments Container - public delegate void OnEntryAddedDelegate(object sender, EntryAddedArgs e); + /// Gets a description of the features that a cache implementation provides. + /// A bitwise combination of flags that indicate the default capabilities of a cache implementation. + public override DefaultCacheCapabilities DefaultCacheCapabilities + => + DefaultCacheCapabilities.AbsoluteExpirations | DefaultCacheCapabilities.CacheEntryRemovedCallback + | DefaultCacheCapabilities.CacheEntryUpdateCallback | DefaultCacheCapabilities.CacheRegions + | DefaultCacheCapabilities.InMemoryProvider; - /// - /// Delegate for . - /// - /// The Sender - /// The Arguments - public delegate void OnValueChangedDelegate(object sender, ValueChangedArgs e); + /// Gets the name of a specific instance. + /// The name of a specific cache instance. + public override string Name => "SDK-Cache"; #endregion - #region Public Events + #region Properties /// - /// Gets called when a new value is added to the InternalCache. + /// Gets or sets the internal cache. /// - public static event OnEntryAddedDelegate OnEntryAdded; - - /// - /// Called when an entry in the InternalCache is modified. - /// - public static event OnValueChangedDelegate OnValueChanged; - - #endregion - - #region Public Properties - - /// - /// Gets the instance of Cache - /// - public static Cache Instance - { - get - { - if (instance != null) - { - return instance; - } - - instance = new Cache(); - return instance; - } - } - - /// - /// The capabilities of this implementation of ObjectCache. - /// - public override DefaultCacheCapabilities DefaultCacheCapabilities - => - DefaultCacheCapabilities.AbsoluteExpirations | DefaultCacheCapabilities.CacheRegions - | DefaultCacheCapabilities.CacheEntryRemovedCallback | DefaultCacheCapabilities.CacheEntryUpdateCallback - ; - - /// - /// Returns the name of the Cache. - /// - public override string Name => "SDK Cache"; + /// + /// The internal cache. + /// + private Dictionary> InternalCache { get; } = + new Dictionary>(); #endregion #region Public Indexers - /// - /// Gets/Sets the value of a key in the Cache, using the default region name. - /// - /// The Key - /// Value matching the key + /// Gets or sets the default indexer for the class. + /// A key that serves as an indexer into the cache instance. + /// A unique identifier for a cache entry in the cache. public override object this[string key] { get { - return this.InternalCache["Default"][key]; + return this.Get(key); } - set { - this.InternalCache["Default"][key] = value; + this.Set(key, value, new CacheItemPolicy()); } } @@ -166,542 +105,464 @@ public override object this[string key] #region Public Methods and Operators /// - /// Adds or Gets an existing key/value, executing the function if the key does not exist. + /// Tries to insert a cache entry into the cache as a instance, + /// and adds details about how the entry should be evicted. /// - /// The Key - /// Function that will get the value - /// The name of the region in the InternalCache - /// The Object of the given function - public object AddOrGetExisting(string key, Func function, string regionName = null) + /// + /// true if insertion succeeded, or false if there is an already an entry in the cache that has the same key as + /// . + /// + /// The object to add. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// + public override bool Add(CacheItem item, CacheItemPolicy policy) { - regionName = regionName ?? "Default"; + if (item == null) + { + throw new ArgumentNullException(nameof(item)); + } - object cachedObject; - var contains = this.InternalCache[regionName].TryGetValue(key, out cachedObject); + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } - if (contains) + var cacheRegion = this.AddOrGetExistingCacheRegion(item); + + if (cacheRegion.ContainsKey(item.Key)) { - return cachedObject; + return false; } - var result = function(); - this.InternalCache[regionName].Add(key, result); + var entryItem = new CacheEntryItem(item, policy); + cacheRegion.Add(item.Key, entryItem); - OnEntryAdded?.Invoke(this, new EntryAddedArgs { Key = key, Value = result, RegionName = regionName }); + this.ValidatePolicy(entryItem); - return result; + return true; } - /// - /// Adds a key and a value, in the InternalCache region. However, if the item exists, it will return the cached item. - /// This - /// KeyValuePair does not expire. - /// - /// The Key - /// The Value - /// The name of the region in the InternalCache. - /// The cached value. - public object AddOrGetExisting(string key, object value, string regionName = "Default") + /// Inserts a cache entry into the cache without overwriting any existing cache entry. + /// + /// true if insertion succeeded, or false if there is an already an entry in the cache that has the same key as + /// . + /// + /// A unique identifier for the cache entry. + /// The object to insert. + /// + /// The fixed date and time at which the cache entry will expire. This parameter is + /// required when the method is called. + /// + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. Because regions are not implemented in .NET Framework 4, the default value is null. + /// + public override bool Add(string key, object value, DateTimeOffset absoluteExpiration, string regionName = null) + { + return this.Add( + new CacheItem(key, value), + new CacheItemPolicy() { AbsoluteExpiration = absoluteExpiration }); + } + + /// Inserts a cache entry into the cache, specifying information about how the entry will be evicted. + /// + /// true if the insertion try succeeds, or false if there is an already an entry in the cache with the same key as + /// . + /// + /// A unique identifier for the cache entry. + /// The object to insert. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. The default value for the optional parameter is null. + /// + public override bool Add(string key, object value, CacheItemPolicy policy, string regionName = null) { - return this.AddOrGetExisting(key, value, InfiniteAbsoluteExpiration, regionName); + return this.Add(new CacheItem(key, value, regionName), policy); } /// - /// Adds a key, a value, and an expiration to the InternalCache, returns the value if the key exists. + /// Inserts a cache entry into the cache, by using a key, an object for the + /// cache entry, an absolute expiration value, and an optional region to add the cache into. /// - /// The Key - /// The Value - /// Time the KeyPair expires - /// The name of the region in the InternalCache - /// The object stored in the InternalCache + /// If a cache entry with the same key exists, the specified cache entry's value; otherwise, null. + /// A unique identifier for the cache entry. + /// The object to insert. + /// The fixed date and time at which the cache entry will expire. + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. The default value for the optional parameter is null. + /// public override object AddOrGetExisting( string key, object value, DateTimeOffset absoluteExpiration, string regionName = null) { - regionName = regionName ?? "Default"; - - object internalValue; - var contains = this.InternalCache[regionName].TryGetValue(key, out internalValue); - - if (contains) - { - return internalValue; - } - - OnEntryAdded?.Invoke(this, new EntryAddedArgs { Key = key, Value = value, RegionName = regionName }); - - this.InternalCache[regionName].Add(key, value); - - DelayAction.Add( - (int)(absoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(key)) - { - return; - } - - var cacheValue = this.InternalCache[regionName][key]; - - this.CallEntryUpdates(key, CacheEntryRemovedReason.Expired, regionName); - this.InternalCache[regionName].Remove(key); - this.CallEntryRemoved(key, cacheValue, CacheEntryRemovedReason.Expired, regionName); - }); - - return value; + return + this.AddOrGetExisting( + new CacheItem(key, value, regionName), + new CacheItemPolicy() { AbsoluteExpiration = absoluteExpiration }).Value; } /// - /// Adds a CacheItem following the policy provided to the InternalCache, but returns the CacheItem if it exists. + /// Inserts the specified + /// object into the cache, specifying information about how the entry will be evicted. /// - /// The Value - /// The Policy - /// The CacheItem in the InternalCache + /// If a cache entry with the same key exists, the specified cache entry; otherwise, null. + /// The object to insert. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// public override CacheItem AddOrGetExisting(CacheItem value, CacheItemPolicy policy) { - var regionName = value.RegionName ?? "Default"; + var cacheRegion = this.AddOrGetExistingCacheRegion(value); - object internalValue; - var contains = this.InternalCache[regionName].TryGetValue(value.Key, out internalValue); - - if (contains) + if (cacheRegion.ContainsKey(value.Key)) { - return new CacheItem(value.Key, internalValue, regionName); + return new CacheItem(value.Key, this.Get(value.Key, value.RegionName), value.RegionName); } - OnEntryAdded?.Invoke( - this, - new EntryAddedArgs { Key = value.Key, Value = value.Value, RegionName = regionName }); - - this.InternalCache[regionName].Add(value.Key, value.Value); - - this.cacheEntryUpdateCallbacks[value.Key + value.RegionName] = policy.UpdateCallback; - this.cacheRemovedCallbacks[value.Key + value.RegionName] = policy.RemovedCallback; - - DelayAction.Add( - (int)(policy.AbsoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(value.Key)) - { - return; - } - - var cachedValue = this.InternalCache[regionName][value.Key]; - - this.CallEntryUpdates(value.Key, CacheEntryRemovedReason.Expired, value.RegionName); - this.InternalCache[regionName].Remove(value.Key); - this.CallEntryRemoved(value.Key, cachedValue, CacheEntryRemovedReason.Expired, value.RegionName); - }); - - return new CacheItem(value.Key, value.Value, regionName); + this.Add(value, policy); + return value; } /// - /// Adds a key and a value to the InternalCache, following the policy, returns the cached value if it exists. + /// Inserts a cache entry into the cache, specifying a key and a value for the + /// cache entry, and information about how the entry will be evicted. /// - /// The Key - /// The Value - /// The Policy - /// The name of the region in the InternalCache - /// Cached value + /// If a cache entry with the same key exists, the specified cache entry's value; otherwise, null. + /// A unique identifier for the cache entry. + /// The object to insert. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. The default value for the optional parameter is null. + /// public override object AddOrGetExisting( string key, object value, CacheItemPolicy policy, string regionName = null) { - regionName = regionName ?? "Default"; - - object internalValue; - var contains = this.InternalCache[regionName].TryGetValue(key, out internalValue); - - if (contains) - { - return internalValue; - } - - OnEntryAdded?.Invoke(this, new EntryAddedArgs { Key = key, Value = value, RegionName = regionName }); - - this.InternalCache[regionName].Add(key, value); - - this.cacheEntryUpdateCallbacks[key + regionName] = policy.UpdateCallback; - this.cacheRemovedCallbacks[key + regionName] = policy.RemovedCallback; - - DelayAction.Add( - (int)(policy.AbsoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(key)) - { - return; - } - - var cachedValue = this.InternalCache[regionName][key]; - - this.CallEntryUpdates(key, CacheEntryRemovedReason.Expired, regionName); - this.InternalCache[regionName].Remove(key); - this.CallEntryRemoved(key, cachedValue, CacheEntryRemovedReason.Expired, regionName); - }); - - return value; + return this.AddOrGetExisting(new CacheItem(key, value, regionName), policy); } - /// - /// Checks if the InternalCache contains the key. - /// - /// The Key - /// The name of the region in the InternalCache - /// Whether the key is in the InternalCache + /// Checks whether the cache entry already exists in the cache. + /// true if the cache contains a cache entry with the same key value as ; otherwise, false. + /// A unique identifier for the cache entry. + /// + /// Optional. A named region in the cache where the cache can be found, if regions are + /// implemented. The default value for the optional parameter is null. + /// public override bool Contains(string key, string regionName = null) { - regionName = regionName ?? "Default"; - return this.InternalCache[regionName].ContainsKey(key); + return this.InternalCache[regionName ?? DefaultCacheRegionName].ContainsKey(key); } /// - /// Not supported. Please use the events. + /// Creates a + /// object that can trigger events in response to changes to specified cache entries. /// - /// The Keys - /// The name of the region in the InternalCache - /// instance + /// A change monitor that monitors cache entries in the cache. + /// The unique identifiers for cache entries to monitor. + /// + /// Optional. A named region in the cache where the cache keys in the + /// parameter exist, if regions are implemented. The default value for the optional parameter is null. + /// public override CacheEntryChangeMonitor CreateCacheEntryChangeMonitor( IEnumerable keys, string regionName = null) { - throw new NotSupportedException("CacheEntryChangeMonitors are not implemented."); - } + if (keys == null) + { + throw new ArgumentNullException(nameof(keys)); + } - /// - /// Creates a new region to use. The default region is automatically created. - /// - /// The name of the region in the InternalCache - public void CreateRegion(string regionName) - { - this.InternalCache.Add(regionName, new Dictionary()); - } + var keyList = keys as IList ?? keys.ToList(); - /// - /// Gets a value in the InternalCache by the key. - /// - /// The Key - /// The name of the region in the InternalCache - /// The object the key pairs with - public override object Get(string key, string regionName = null) - { - regionName = regionName ?? "Default"; - return this.InternalCache[regionName][key]; + if (keyList.Any(key => key == null)) + { + throw new ArgumentException("Collection contains a null element."); + } + + return new CacheEntryChangeMonitorImpl( + Guid.NewGuid().ToString(), + new ReadOnlyCollection(keyList), + DateTime.Now, + regionName ?? DefaultCacheRegionName); } - /// - /// Gets a value from the InternalCache, and casts it to the type. - /// - /// Type to cast to - /// The Key - /// The name of the region in the InternalCache - /// The object casted into T - public T Get(string key, string regionName = null) + /// Gets the specified cache entry from the cache as an object. + /// The cache entry that is identified by . + /// A unique identifier for the cache entry to get. + /// + /// Optional. A named region in the cache to which the cache entry was added, if regions are + /// implemented. The default value for the optional parameter is null. + /// + public override object Get(string key, string regionName = null) { - regionName = regionName ?? "Default"; + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } - var value = this.InternalCache[regionName][key]; - return value is T ? (T)value : default(T); + return this.GetCacheItem(key, regionName)?.Value; } /// - /// Gets the CacheItem from the Key. + /// Gets the specified cache entry from the cache as a + /// instance. /// - /// The Key - /// The Region Name - /// CacheItem in the InternalCache + /// The cache entry that is identified by . + /// A unique identifier for the cache entry to get. + /// + /// Optional. A named region in the cache to which the cache was added, if regions are + /// implemented. Because regions are not implemented in .NET Framework 4, the default is null. + /// public override CacheItem GetCacheItem(string key, string regionName = null) { - regionName = regionName ?? "Default"; - return new CacheItem(key, this.InternalCache[regionName][key], regionName); + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + + var item = this.AddOrGetExistingCacheRegion(regionName)[key]; + this.ValidatePolicy(item); + + return item.ToCacheItem(); } - /// - /// Gets the count of KeyPairs in the Cache. - /// - /// The name of the region in the InternalCache - /// Count of KeyPairs in the Cache + /// Gets the total number of cache entries in the cache. + /// + /// The number of cache entries in the cache. If is not null, the count indicates + /// the number of entries that are in the specified cache region. + /// + /// + /// Optional. A named region in the cache for which the cache entry count should be computed, if + /// regions are implemented. The default value for the optional parameter is null. + /// public override long GetCount(string regionName = null) { - regionName = regionName ?? "Default"; - return this.InternalCache[regionName].Count; + return this.AddOrGetExistingCacheRegion(regionName).Count; } - /// - /// Gets the values of all the keys provided. - /// - /// Keys to get the values of - /// The name of the region in the InternalCache - /// Dictionary of all the keys, with the perspective values. + /// Gets a set of cache entries that correspond to the specified keys. + /// A dictionary of key/value pairs that represent cache entries. + /// A collection of unique identifiers for the cache entries to get. + /// + /// Optional. A named region in the cache to which the cache entry or entries were added, if + /// regions are implemented. The default value for the optional parameter is null. + /// public override IDictionary GetValues(IEnumerable keys, string regionName = null) { - regionName = regionName ?? "Default"; - return keys.Where(x => this.InternalCache[regionName].ContainsKey(x)) - .ToDictionary(x => x, x => this.InternalCache[regionName][x]); + var cacheRegion = this.AddOrGetExistingCacheRegion(regionName); + var values = keys.Where(x => cacheRegion.ContainsKey(x)).ToDictionary(x => x, x => cacheRegion[x]); + + foreach (var item in values.Values) + { + this.ValidatePolicy(item); + } + + return values.ToDictionary(x => x.Key, x => x.Value.Value); } - /// - /// Removes KeyPair by the key in the InternalCache. - /// - /// The Key - /// The name of the region in the InternalCache - /// The value of the key being removed - public override object Remove(string key, string regionName = null) + /// Gets a set of cache entries that correspond to the specified keys. + /// A dictionary of key/value pairs that represent cache entries. + /// + /// Optional. A named region in the cache to which the cache entry or entries were added, if + /// regions are implemented. Because regions are not implemented in .NET Framework 4, the default is null. + /// + /// A collection of unique identifiers for the cache entries to get. + public override IDictionary GetValues(string regionName, params string[] keys) { - regionName = regionName ?? "Default"; + return this.GetValues(keys, regionName); + } - if (!this.InternalCache[regionName].ContainsKey(key)) + /// Removes the cache entry from the cache. + /// + /// An object that represents the value of the removed cache entry that was specified by the key, or null if the + /// specified entry was not found. + /// + /// A unique identifier for the cache entry. + /// + /// Optional. A named region in the cache to which the cache entry was added, if regions are + /// implemented. The default value for the optional parameter is null. + /// + public override object Remove(string key, string regionName = null) + { + if (key == null) { - return null; + throw new ArgumentNullException(nameof(key)); } - if (this.cacheEntryUpdateCallbacks.ContainsKey(key + regionName)) + CacheEntryItem item; + var cacheRegion = this.AddOrGetExistingCacheRegion(regionName); + + if (!cacheRegion.TryGetValue(key, out item)) { - this.cacheEntryUpdateCallbacks[key + regionName].Invoke( - new CacheEntryUpdateArguments(this, CacheEntryRemovedReason.Removed, key, regionName)); + return null; } - var value = this.InternalCache[regionName][key]; - this.InternalCache[regionName].Remove(key); + item.EntryRemovedCallback( + new CacheEntryRemovedArguments(this, CacheEntryRemovedReason.Removed, item.ToCacheItem())); + item.EntryUpdateCallback( + new CacheEntryUpdateArguments(this, CacheEntryRemovedReason.Removed, item.Key, item.RegionName)); - if (this.cacheRemovedCallbacks.ContainsKey(key + regionName)) - { - this.cacheRemovedCallbacks[key + regionName].Invoke( - new CacheEntryRemovedArguments( - this, - CacheEntryRemovedReason.Removed, - new CacheItem(key, value, regionName))); - } + cacheRegion.Remove(key); - return value; + return item.Value; } /// - /// Sets the value of a key in the InternalCache, and expires at a set time. The key does not have to be created. + /// Inserts a cache entry into the cache, specifying time-based expiration + /// details. /// - /// The Key - /// The Value - /// The Expiration - /// The name of the region in the InternalCache + /// A unique identifier for the cache entry. + /// The object to insert. + /// The fixed date and time at which the cache entry will expire. + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. The default value for the optional parameter is null. + /// public override void Set(string key, object value, DateTimeOffset absoluteExpiration, string regionName = null) { - regionName = regionName ?? "Default"; - - if (OnValueChanged != null && this.InternalCache[regionName].ContainsKey(key)) - { - OnValueChanged(this, new ValueChangedArgs(key, this.InternalCache[regionName][key], value, regionName)); - } - - this.InternalCache[regionName][key] = value; - - DelayAction.Add( - (int)(absoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(key)) - { - return; - } - - var cachedValue = this.InternalCache[regionName][key]; - - this.CallEntryUpdates(key, CacheEntryRemovedReason.Expired, regionName); - this.InternalCache[regionName].Remove(key); - this.CallEntryRemoved(key, cachedValue, CacheEntryRemovedReason.Expired, regionName); - }); + this.Set( + new CacheItem(key, value, regionName), + new CacheItemPolicy() { AbsoluteExpiration = absoluteExpiration }); } /// - /// Sets the value of a key by the CacheItem, following the policy provided. + /// Inserts the cache entry into the cache as a + /// instance, specifying information about how the entry will be + /// evicted. /// - /// The Item - /// The Policy + /// The cache item to add. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// public override void Set(CacheItem item, CacheItemPolicy policy) { - var regionName = item.RegionName ?? "Default"; - - if (OnValueChanged != null && this.InternalCache[regionName].ContainsKey(item.Key)) + if (item == null) { - OnValueChanged( - this, - new ValueChangedArgs(item.Key, this.InternalCache[regionName][item.Key], item.Value, regionName)); + throw new ArgumentNullException(nameof(item)); } - this.InternalCache[regionName][item.Key] = item.Value; - - DelayAction.Add( - (int)(policy.AbsoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(item.Key)) - { - return; - } + if (policy == null) + { + throw new ArgumentNullException(nameof(policy)); + } - var cachedValue = this.InternalCache[regionName][item.Key]; + CacheEntryItem entry; + var cacheRegion = this.AddOrGetExistingCacheRegion(item.RegionName); - this.CallEntryUpdates(item.Key, CacheEntryRemovedReason.Expired, item.RegionName); - this.InternalCache[regionName].Remove(item.Key); - this.CallEntryRemoved(item.Key, cachedValue, CacheEntryRemovedReason.Expired, item.RegionName); - }); + if (!cacheRegion.TryGetValue(item.Key, out entry)) + { + this.Add(item, policy); + } + else + { + cacheRegion[item.Key] = new CacheEntryItem(item, policy); + this.ValidatePolicy(cacheRegion[item.Key]); + } } - /// - /// Sets the value of a key, following the policy provided. - /// - /// The Key - /// The Value - /// The Policy - /// The name of the region in the InternalCache + /// Inserts a cache entry into the cache. + /// A unique identifier for the cache entry. + /// The object to insert. + /// + /// An object that contains eviction details for the cache entry. This object provides more options + /// for eviction than a simple absolute expiration. + /// + /// + /// Optional. A named region in the cache to which the cache entry can be added, if regions are + /// implemented. The default value for the optional parameter is null. + /// public override void Set(string key, object value, CacheItemPolicy policy, string regionName = null) { - regionName = regionName ?? "Default"; - - if (OnValueChanged != null && this.InternalCache[regionName].ContainsKey(key)) - { - OnValueChanged(this, new ValueChangedArgs(key, this.InternalCache[regionName][key], value, regionName)); - } - - this.InternalCache[regionName][key] = value; - - DelayAction.Add( - (int)(policy.AbsoluteExpiration - DateTime.Now).TotalMilliseconds, - () => - { - if (!this.InternalCache[regionName].ContainsKey(key)) - { - return; - } - - var cachedValue = this.InternalCache[regionName][key]; - - this.CallEntryUpdates(key, CacheEntryRemovedReason.Expired, regionName); - this.InternalCache[regionName].Remove(key); - this.CallEntryRemoved(key, cachedValue, CacheEntryRemovedReason.Expired, regionName); - }); + this.Set(new CacheItem(key, value, regionName), policy); } - /// - /// Tries to get the value, returns false if the InternalCache does not contain that key. - /// - /// The Key - /// Value(Null if doesn't exist) - /// The name of the region in the InternalCache - /// If the InternalCache contains the value - public bool TryGetValue(string key, out object value, string regionName = null) - => this.InternalCache[regionName ?? "Default"].TryGetValue(key, out value); - #endregion #region Methods /// - /// Gets the enumerator of the default internal InternalCache. + /// Creates an enumerator that can be used to iterate through a collection of + /// cache entries. /// - /// Enumerator of InternalCache + /// The enumerator object that provides access to the cache entries in the cache. protected override IEnumerator> GetEnumerator() - => this.InternalCache["Default"].GetEnumerator(); + { + return + this.InternalCache[DefaultCacheRegionName].ToDictionary(x => x.Key, x => x.Value.Value).GetEnumerator(); + } - /// - /// Calls the for the selected key. - /// - /// The Key - /// The Value - /// Reason why the value was removed - /// The name of the region in the InternalCache - private void CallEntryRemoved( - string key, - object value, - CacheEntryRemovedReason reason = CacheEntryRemovedReason.Removed, - string regionName = null) + private Dictionary AddOrGetExistingCacheRegion(CacheItem item) { - CacheEntryRemovedCallback callback; - var contains = this.cacheRemovedCallbacks.TryGetValue(key + regionName, out callback); + return this.AddOrGetExistingCacheRegion(item.RegionName); + } - if (!contains) - { - return; - } + private Dictionary AddOrGetExistingCacheRegion(string regionName) + { + Dictionary cacheRegion; - try - { - callback.Invoke(new CacheEntryRemovedArguments(this, reason, new CacheItem(key, value, regionName))); - } - catch (Exception e) + if (this.InternalCache.TryGetValue(regionName ?? DefaultCacheRegionName, out cacheRegion)) { - Logging.Write()( - LogLevel.Error, - "An exception occured while invoking the CacheEntryRemovedCallback: {0}", - e); + return cacheRegion; } + + cacheRegion = new Dictionary(); + this.InternalCache[regionName ?? DefaultCacheRegionName] = cacheRegion; + + return cacheRegion; } - /// - /// Calls the for the selected key. - /// - /// The Key - /// Reason why the value was removed - /// The name of the region in the InternalCache - private void CallEntryUpdates( - string key, - CacheEntryRemovedReason reason = CacheEntryRemovedReason.Removed, - string regionName = null) + private void ValidatePolicy(CacheEntryItem item) { - CacheEntryUpdateCallback callback; - var contains = this.cacheEntryUpdateCallbacks.TryGetValue(key + regionName, out callback); - - if (!contains) + if (DateTime.Now - item.LastAccessed < item.SlidingExpiration + && item.Expiration.Ticks - DateTime.Now.Ticks > 0) { + item.LastAccessed = DateTime.Now; return; } - try - { - callback.Invoke(new CacheEntryUpdateArguments(this, reason, key, regionName)); - } - catch (Exception e) - { - Logging.Write()(LogLevel.Error, "An exception occured while invoking the EntryUpdateCallbacks: {0}", e); - } + item.EntryRemovedCallback( + new CacheEntryRemovedArguments(this, CacheEntryRemovedReason.Expired, item.ToCacheItem())); + this.InternalCache[item.RegionName].Remove(item.Key); } #endregion } /// - /// Arguments for the event. + /// An entry in the cache. /// - public class ValueChangedArgs : EventArgs + internal class CacheEntryItem { #region Constructors and Destructors - /// - /// Initializes a new instance of the class. - /// - /// - /// The key - /// - /// - /// The old value - /// - /// - /// The new value - /// - /// - /// The region name - /// - internal ValueChangedArgs(string key, object oldValue, object newValue, string regionName) + public CacheEntryItem(CacheItem item, CacheItemPolicy policy) { - this.Key = key; - this.OldValue = oldValue; - this.NewValue = newValue; - this.RegionName = regionName; + this.Key = item.Key; + this.Value = item.Value; + this.RegionName = item.RegionName; + + this.Expiration = policy.AbsoluteExpiration; + this.ChangeMonitors = policy.ChangeMonitors; + this.EntryRemovedCallback = policy.RemovedCallback; + this.EntryUpdateCallback = policy.UpdateCallback; + this.SlidingExpiration = policy.SlidingExpiration; } #endregion @@ -709,49 +570,159 @@ internal ValueChangedArgs(string key, object oldValue, object newValue, string r #region Public Properties /// - /// Gets or sets the Key. + /// Gets or sets the change monitors. /// - public string Key { get; set; } + /// + /// The change monitors. + /// + public Collection ChangeMonitors { get; set; } /// - /// Gets or sets the new value after it was changed. + /// Gets or sets the entry removed callback. /// - public object NewValue { get; set; } + /// + /// The entry removed callback. + /// + public CacheEntryRemovedCallback EntryRemovedCallback { get; set; } /// - /// Gets or sets the old value prior to changing. + /// Gets or sets the entry update callback. /// - public object OldValue { get; set; } + /// + /// The entry update callback. + /// + public CacheEntryUpdateCallback EntryUpdateCallback { get; set; } /// - /// Gets or sets the name of the region in the InternalCache. + /// Gets or sets the expiration. /// + /// + /// The expiration. + /// + public DateTimeOffset Expiration { get; set; } + + /// + /// Gets or sets the key. + /// + /// + /// The key. + /// + public string Key { get; } + + /// + /// Gets or sets the last accessed. + /// + /// + /// The last accessed. + /// + public DateTime LastAccessed { get; set; } + + /// + /// Gets or sets the name of the region. + /// + /// + /// The name of the region. + /// public string RegionName { get; set; } + /// + /// Gets or sets the sliding expiration. + /// + /// + /// The sliding expiration. + /// + public TimeSpan SlidingExpiration { get; set; } + + /// + /// Gets or sets the value. + /// + /// + /// The value. + /// + public object Value { get; set; } + + #endregion + + #region Public Methods and Operators + + /// + /// Converts this instance into a + /// + /// + public CacheItem ToCacheItem() + { + return new CacheItem(this.Key, this.Value, this.RegionName); + } + #endregion } /// - /// Arguments for the event. + /// The implemenation for the class. /// - public class EntryAddedArgs : EventArgs + /// + public class CacheEntryChangeMonitorImpl : CacheEntryChangeMonitor { - #region Public Properties + #region Constructors and Destructors /// - /// Gets or sets the Key. + /// Initializes a new instance of the class. /// - public string Key { get; set; } + /// The unique identifier. + /// The cache keys. + /// The last modified. + /// Name of the region. + internal CacheEntryChangeMonitorImpl( + string uniqueId, + ReadOnlyCollection cacheKeys, + DateTimeOffset lastModified, + string regionName) + { + this.UniqueId = uniqueId; + this.CacheKeys = cacheKeys; + this.LastModified = lastModified; + this.RegionName = regionName; + } - /// - /// Gets or sets the name of the region in the InternalCache. - /// - public string RegionName { get; set; } + #endregion + + #region Public Properties + + /// Gets a collection of cache keys that are monitored for changes. + /// A collection of cache keys. + public override ReadOnlyCollection CacheKeys { get; } + + /// Gets a value that indicates the latest time (in UTC time) that the monitored cache entry was changed. + /// The elapsed time. + public override DateTimeOffset LastModified { get; } + + /// Gets the name of a region of the cache. + /// The name of a region in the cache. + public override string RegionName { get; } + + /// Gets a value that represents the class instance. + /// The identifier for a change-monitor instance. + public override string UniqueId { get; } + + #endregion + + #region Methods /// - /// Gets or sets the Value. + /// Releases all managed and unmanaged resources and any references to the + /// instance. This overload must be implemented by derived + /// change-monitor classes. /// - public object Value { get; set; } + /// + /// true to release managed and unmanaged resources and any references to a + /// instance; false to release only unmanaged resources. When + /// false is passed, the method is called + /// by a finalizer thread and any external managed references are likely no longer valid because they have already been + /// garbage collected. + /// + protected override void Dispose(bool disposing) + { + } #endregion } diff --git a/Core/Utils/CallbackPerformance.cs b/Core/Utils/CallbackPerformance.cs index 33bc027..0f6a4d2 100644 --- a/Core/Utils/CallbackPerformance.cs +++ b/Core/Utils/CallbackPerformance.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Diagnostics; using System.Runtime.CompilerServices; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// Performance class, measures how much time does a function takes to execute. @@ -42,8 +42,8 @@ public class CallbackPerformance /// Member name of the function that called the measurement request. /// Elapsed Milliseconds the function took (long-units) public static long MeasureMilliseconds( - Action funcCallback, - int iterations = 1, + Action funcCallback, + int iterations = 1, [CallerMemberName] string memberName = "") { try @@ -58,9 +58,9 @@ public static long MeasureMilliseconds( stopwatch.Stop(); Logging.Write()( - LogLevel.Info, - "{0} has taken {1} elapsed milliseconds to execute, and was executed successfuly.", - memberName, + LogLevel.Info, + "{0} has taken {1} elapsed milliseconds to execute, and was executed successfuly.", + memberName, stopwatch.ElapsedMilliseconds); return stopwatch.ElapsedMilliseconds; @@ -68,8 +68,8 @@ public static long MeasureMilliseconds( catch (Exception) { Logging.Write()( - LogLevel.Error, - "{0} had an error during execution and was unable to be measured.", + LogLevel.Error, + "{0} had an error during execution and was unable to be measured.", memberName); return -1L; } @@ -84,8 +84,8 @@ public static long MeasureMilliseconds( /// Member name of the function that called the measurement request. /// Elapsed Ticks the function took (long-units) public static long MeasureTicks( - Action funcCallback, - int iterations = 1, + Action funcCallback, + int iterations = 1, [CallerMemberName] string memberName = "") { try @@ -100,9 +100,9 @@ public static long MeasureTicks( stopwatch.Stop(); Logging.Write()( - LogLevel.Info, - "{0} has taken {1} elapsed ticks to execute, and was executed successfuly.", - memberName, + LogLevel.Info, + "{0} has taken {1} elapsed ticks to execute, and was executed successfuly.", + memberName, stopwatch.ElapsedTicks); return stopwatch.ElapsedTicks; @@ -110,8 +110,8 @@ public static long MeasureTicks( catch (Exception) { Logging.Write()( - LogLevel.Error, - "{0} had an error during execution and was unable to be measured.", + LogLevel.Error, + "{0} had an error during execution and was unable to be measured.", memberName); return -1L; } @@ -126,8 +126,8 @@ public static long MeasureTicks( /// Member name of the function that called the measurement request. /// Elapsed Time Span the function took (long-units) public static TimeSpan MeasureTimeSpan( - Action funcCallback, - int iterations = 1, + Action funcCallback, + int iterations = 1, [CallerMemberName] string memberName = "") { try @@ -142,9 +142,9 @@ public static TimeSpan MeasureTimeSpan( stopwatch.Stop(); Logging.Write()( - LogLevel.Info, - "{0} has taken {1} elapsed time span to execute, and was executed successfuly.", - memberName, + LogLevel.Info, + "{0} has taken {1} elapsed time span to execute, and was executed successfuly.", + memberName, stopwatch.Elapsed); return stopwatch.Elapsed; @@ -152,8 +152,8 @@ public static TimeSpan MeasureTimeSpan( catch (Exception) { Logging.Write()( - LogLevel.Error, - "{0} had an error during execution and was unable to be measured.", + LogLevel.Error, + "{0} had an error during execution and was unable to be measured.", memberName); return TimeSpan.Zero; } diff --git a/Core/Utils/Cursor.cs b/Core/Utils/Cursor.cs index 994cb7e..db36894 100644 --- a/Core/Utils/Cursor.cs +++ b/Core/Utils/Cursor.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using SharpDX; diff --git a/Core/Utils/DelayAction.cs b/Core/Utils/DelayAction.cs index bb3f3b6..4661d6a 100644 --- a/Core/Utils/DelayAction.cs +++ b/Core/Utils/DelayAction.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; using System.Threading; - using Signals; + using LeagueSharp.SDK.Signals; /// /// Delays actions by a set time. diff --git a/Core/Utils/DynamicInitializer.cs b/Core/Utils/DynamicInitializer.cs index 3cf36d9..cfa07f1 100644 --- a/Core/Utils/DynamicInitializer.cs +++ b/Core/Utils/DynamicInitializer.cs @@ -15,16 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { - #region - using System; using System.Reflection.Emit; - using LeagueSharp.SDK; - - #endregion + using LeagueSharp.SDK.Enumerations; /// /// Dynamic instantiation from classes diff --git a/Core/Utils/IFilter.cs b/Core/Utils/IFilter.cs index 29358d7..1cbb16d 100644 --- a/Core/Utils/IFilter.cs +++ b/Core/Utils/IFilter.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { internal interface IFilter { diff --git a/Core/Utils/Invulnerable.cs b/Core/Utils/Invulnerable.cs index 499ed03..275e178 100644 --- a/Core/Utils/Invulnerable.cs +++ b/Core/Utils/Invulnerable.cs @@ -15,18 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { - #region - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; - using LeagueSharp.SDK; - - #endregion + using LeagueSharp.SDK.Enumerations; /// /// Invulnerable utility class @@ -57,21 +53,23 @@ static Invulnerable() ChampionName = "Alistar", CheckFunction = (target, type) => - GameObjects.Player.CountEnemyHeroesInRange(GameObjects.Player.GetRealAutoAttackRange()) > 1 + GameObjects.Player.CountEnemyHeroesInRange( + GameObjects.Player.GetRealAutoAttackRange()) > 1 }, new InvulnerableEntry("Meditate") { ChampionName = "MasterYi", CheckFunction = (target, type) => - GameObjects.Player.CountEnemyHeroesInRange(GameObjects.Player.GetRealAutoAttackRange()) > 1 + GameObjects.Player.CountEnemyHeroesInRange( + GameObjects.Player.GetRealAutoAttackRange()) > 1 }, new InvulnerableEntry("UndyingRage") { ChampionName = "Tryndamere", MinHealthPercent = 1, CheckFunction = (target, type) => target.HealthPercent <= 5 }, - new InvulnerableEntry("Kayle") { ChampionName = "JudicatorIntervention", IsShield = true }, + new InvulnerableEntry("JudicatorIntervention") { IsShield = true }, new InvulnerableEntry("fizztrickslamsounddummy") { ChampionName = "Fizz" }, new InvulnerableEntry("VladimirSanguinePool") { ChampionName = "Vladimir" }, new InvulnerableEntry("FioraW") { ChampionName = "Fiora" }, @@ -79,11 +77,13 @@ static Invulnerable() { ChampionName = "Jax", DamageType = DamageType.Physical }, new InvulnerableEntry("BlackShield") { IsShield = true, DamageType = DamageType.Magical }, new InvulnerableEntry("BansheesVeil") { IsShield = true, DamageType = DamageType.Magical }, - new InvulnerableEntry("SivirE") - { ChampionName = "Sivir", IsShield = true, MinHealthPercent = 0 }, - new InvulnerableEntry("ShroudofDarkness") { ChampionName = "Nocturne", IsShield = true }, + new InvulnerableEntry("SivirE") { ChampionName = "Sivir", IsShield = true }, + new InvulnerableEntry("NocturneShroudofDarkness") { ChampionName = "Nocturne", IsShield = true }, new InvulnerableEntry("KindredrNoDeathBuff") - { MinHealthPercent = 10, CheckFunction = (target, type) => target.HealthPercent <= 10 } + { + ChampionName = "Kindred", MinHealthPercent = 10, + CheckFunction = (target, type) => target.HealthPercent <= 10 + } }); } @@ -279,4 +279,4 @@ public InvulnerableEntry(string buffName) #endregion } -} +} \ No newline at end of file diff --git a/Core/Utils/JsonFactory.cs b/Core/Utils/JsonFactory.cs index 5b7986b..eb24fd7 100644 --- a/Core/Utils/JsonFactory.cs +++ b/Core/Utils/JsonFactory.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.IO; @@ -38,102 +38,116 @@ namespace LeagueSharp.SDK.Core.Utils /// public static class JsonFactory { - /// - /// Default JsonSerializerSettings - /// - public static JsonSerializerSettings DefaultSettings { get; set; } + #region Constructors and Destructors static JsonFactory() { DefaultSettings = new JsonSerializerSettings - { - Formatting = Formatting.Indented, - ReferenceLoopHandling = ReferenceLoopHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.Include, - NullValueHandling = NullValueHandling.Include - }; + { + Formatting = Formatting.Indented, + ReferenceLoopHandling = ReferenceLoopHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.Include, + NullValueHandling = NullValueHandling.Include + }; DefaultSettings.Converters.Add(new StringEnumConverter()); DefaultSettings.Converters.Add(new VersionConverter()); JsonConvert.DefaultSettings = () => DefaultSettings; } + #endregion + + #region Public Properties + /// - /// Deserialize Object from Resource + /// Default JsonSerializerSettings + /// + public static JsonSerializerSettings DefaultSettings { get; set; } + + #endregion + + #region Public Methods and Operators + + /// + /// Deserialize Object from File /// /// /// - /// /// /// [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - public static T JsonResource(string file, Assembly assembly = null, JsonSerializerSettings settings = null) + public static T JsonFile(string file, JsonSerializerSettings settings = null) { if (file == null) { throw new ArgumentNullException(nameof(file)); } - return JsonConvert.DeserializeObject(ResourceFactory.StringResource(file, assembly), settings); + return JsonConvert.DeserializeObject(File.ReadAllText(file), settings); } /// - /// Deserialize Object from Resource + /// Deserialize Object from File /// /// /// - /// /// /// [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - public static object JsonResource(string file, Type type = null, Assembly assembly = null, JsonSerializerSettings settings = null) + public static object JsonFile(string file, Type type = null, JsonSerializerSettings settings = null) { if (file == null) { throw new ArgumentNullException(nameof(file)); } - return JsonConvert.DeserializeObject(ResourceFactory.StringResource(file, assembly), type, settings); + return JsonConvert.DeserializeObject(File.ReadAllText(file), type, settings); } /// - /// Deserialize Object from File + /// Deserialize Object from Resource /// /// /// + /// /// /// [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - public static T JsonFile(string file, JsonSerializerSettings settings = null) + public static T JsonResource(string file, Assembly assembly = null, JsonSerializerSettings settings = null) { if (file == null) { throw new ArgumentNullException(nameof(file)); } - return JsonConvert.DeserializeObject(File.ReadAllText(file), settings); + return JsonConvert.DeserializeObject(ResourceFactory.StringResource(file, assembly), settings); } /// - /// Deserialize Object from File + /// Deserialize Object from Resource /// /// /// + /// /// /// [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - public static object JsonFile(string file, Type type = null, JsonSerializerSettings settings = null) + public static object JsonResource( + string file, + Type type = null, + Assembly assembly = null, + JsonSerializerSettings settings = null) { if (file == null) { throw new ArgumentNullException(nameof(file)); } - return JsonConvert.DeserializeObject(File.ReadAllText(file), type, settings); + return JsonConvert.DeserializeObject(ResourceFactory.StringResource(file, assembly), type, settings); } /// - /// Deserialize Object from String + /// Deserialize Object from String /// /// /// @@ -151,7 +165,7 @@ public static T JsonString(string s, JsonSerializerSettings settings = null) } /// - /// Deserialize Object from String + /// Deserialize Object from String /// /// /// @@ -169,7 +183,7 @@ public static object JsonString(string s, Type type = null, JsonSerializerSettin } /// - /// Serialize Object to File + /// Serialize Object to File /// /// /// @@ -191,7 +205,7 @@ public static void ToFile(string file, object obj, JsonSerializerSettings settin } /// - /// Serialize Object to String + /// Serialize Object to String /// /// /// @@ -206,5 +220,7 @@ public static string ToString(object obj, JsonSerializerSettings settings = null return JsonConvert.SerializeObject(obj, settings); } + + #endregion } } \ No newline at end of file diff --git a/Core/Utils/Jungle.cs b/Core/Utils/Jungle.cs index c045c4d..5bce714 100644 --- a/Core/Utils/Jungle.cs +++ b/Core/Utils/Jungle.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System.Linq; using System.Text.RegularExpressions; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// The jungle utility class, provides utils for jungle related items. diff --git a/Core/Utils/Logging.cs b/Core/Utils/Logging.cs index 0135be7..786ba75 100644 --- a/Core/Utils/Logging.cs +++ b/Core/Utils/Logging.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.IO; using System.Runtime.CompilerServices; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// Logging class for LeagueSharp.SDK, used to log output data into a file and the console. diff --git a/Core/Utils/MathUtils.cs b/Core/Utils/MathUtils.cs index 1099a9e..40745f0 100644 --- a/Core/Utils/MathUtils.cs +++ b/Core/Utils/MathUtils.cs @@ -15,13 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; using System.Linq; - using Clipper; + using LeagueSharp.SDK.Clipper; + using LeagueSharp.SDK.Polygons; using SharpDX; diff --git a/Core/Utils/Minion.cs b/Core/Utils/Minion.cs index 58fa532..05aed16 100644 --- a/Core/Utils/Minion.cs +++ b/Core/Utils/Minion.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; using SharpDX; @@ -237,7 +237,7 @@ public static FarmLocation GetBestLineFarmLocation(List minions, float /// List of Points in type /// public static List GetMinionsPredictedPositions( - List minions, + List minions, float delay, float width, float speed, @@ -247,7 +247,7 @@ public static List GetMinionsPredictedPositions( SkillshotType stype, Vector3 rangeCheckFrom = default(Vector3)) { - from = from.ToVector2().IsValid() ? from : ObjectManager.Player.ServerPosition; + from = from.IsValid() ? from : ObjectManager.Player.ServerPosition; return (from minion in minions select @@ -363,4 +363,4 @@ public FarmLocation(Vector2 position, int minionsHit) #endregion } -} \ No newline at end of file +} diff --git a/Core/Utils/MultiLanguage.cs b/Core/Utils/MultiLanguage.cs new file mode 100644 index 0000000..edddf40 --- /dev/null +++ b/Core/Utils/MultiLanguage.cs @@ -0,0 +1,117 @@ +namespace LeagueSharp.SDK.Utils +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Resources; + using System.Security.Cryptography; + using System.Text; + + using LeagueSharp.Sandbox; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Properties; + + using Newtonsoft.Json; + + /// + /// Provides multi-lingual strings. + /// + public static class MultiLanguage + { + #region Static Fields + + /// + /// The translations + /// + private static Dictionary translations = new Dictionary(); + + #endregion + + #region Public Methods and Operators + + /// + /// Loads the translation. + /// + /// Name of the language. + /// true if the operation succeeded, false otherwise false. + public static bool LoadLanguage(string languageName) + { + try + { + var languageStrings = + new ResourceManager("LeagueSharp.SDK.Properties.Resources", typeof(Resources).Assembly).GetString( + languageName + "Json"); + + if (string.IsNullOrEmpty(languageStrings)) + { + return false; + } + + translations = JsonConvert.DeserializeObject>(languageStrings); + return true; + } + catch (Exception ex) + { + Logging.Write()(LogLevel.Error, $"[MultiLanguage] Load Language Catch Exception:{ex.Message}"); + return false; + } + } + + /// + /// judge the select language + /// + public static void LoadTranslation() + { + try + { + var selectLanguage = SandboxConfig.SelectedLanguage; + + if (selectLanguage == "Chinese") + { + LoadLanguage("Chinese"); + } + else + { + // ignore + } + } + catch (Exception ex) + { + Logging.Write()(LogLevel.Error, $"[MultiLanguage] Load Translation Catch Exception:{ex.Message}"); + } + } + + /// + /// Translates the text into the loaded language. + /// + /// The text to translate. + /// System.String. + public static string Translation(string textToTranslate) + { + var textToTranslateToLower = textToTranslate.ToLower(); + + return translations.ContainsKey(textToTranslateToLower) + ? translations[textToTranslateToLower] + : (translations.ContainsKey(textToTranslate) ? translations[textToTranslate] : textToTranslate); + } + + #endregion + + #region Methods + + private static string DesDecrypt(string decryptString, string key) + { + var keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8)); + var keyIV = keyBytes; + var inputByteArray = Convert.FromBase64String(decryptString); + var provider = new DESCryptoServiceProvider(); + var mStream = new MemoryStream(); + var cStream = new CryptoStream(mStream, provider.CreateDecryptor(keyBytes, keyIV), CryptoStreamMode.Write); + cStream.Write(inputByteArray, 0, inputByteArray.Length); + cStream.FlushFinalBlock(); + return Encoding.UTF8.GetString(mStream.ToArray()); + } + + #endregion + } +} \ No newline at end of file diff --git a/Core/Utils/Performance.cs b/Core/Utils/Performance.cs index 770a8d0..2bc177a 100644 --- a/Core/Utils/Performance.cs +++ b/Core/Utils/Performance.cs @@ -15,13 +15,13 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Diagnostics; using System.Runtime.CompilerServices; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// Performance block class, for block method performance logging. diff --git a/Core/Utils/Render.cs b/Core/Utils/Render.cs index 0b13894..739ca9c 100644 --- a/Core/Utils/Render.cs +++ b/Core/Utils/Render.cs @@ -1,4 +1,4 @@ -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; @@ -8,6 +8,8 @@ using System.Linq; using System.Threading; + using LeagueSharp.SDK.Enumerations; + using SharpDX; using SharpDX.Direct3D9; @@ -36,11 +38,8 @@ public static class Render static Render() { Drawing.OnEndScene += OnEndScene; - Drawing.OnPreReset += OnPreReset; - Drawing.OnPostReset += OnPostReset; Drawing.OnDraw += OnDraw; - AppDomain.CurrentDomain.DomainUnload += OnDomainUnload; - AppDomain.CurrentDomain.ProcessExit += OnDomainUnload; + var thread = new Thread(PrepareObjects); thread.SetApartmentState(ApartmentState.STA); thread.Start(); @@ -102,12 +101,6 @@ public static void Remove(this RenderObject renderObject) #region Methods - private static void OnDomainUnload(object sender, EventArgs eventArgs) - { - cancelThread = true; - RenderObjects.ForEach(i => i.Dispose()); - } - private static void OnDraw(EventArgs args) { if (Device == null || Device.IsDisposed) @@ -129,16 +122,6 @@ private static void OnEndScene(EventArgs args) renderVisibleObjects.ForEach(i => i.OnEndScene()); } - private static void OnPostReset(EventArgs args) - { - RenderObjects.ForEach(i => i.OnPostReset()); - } - - private static void OnPreReset(EventArgs args) - { - RenderObjects.ForEach(i => i.OnPreReset()); - } - private static void PrepareObjects() { while (!cancelThread) @@ -203,6 +186,7 @@ public Circle(GameObject unit, float radius, Color color, int width = 1, bool zD this.Radius = radius; this.Width = width; this.ZDeep = zDeep; + this.SubscribeToResetEvents(); } /// @@ -222,6 +206,7 @@ public Circle(GameObject unit, Vector3 offset, float radius, Color color, int wi this.Width = width; this.ZDeep = zDeep; this.Offset = offset; + this.SubscribeToResetEvents(); } /// @@ -247,6 +232,7 @@ public Circle( this.Width = width; this.ZDeep = zDeep; this.Offset = offset; + this.SubscribeToResetEvents(); } /// @@ -264,6 +250,7 @@ public Circle(Vector3 position, float radius, Color color, int width = 1, bool z this.Radius = radius; this.Width = width; this.ZDeep = zDeep; + this.SubscribeToResetEvents(); } #endregion @@ -621,7 +608,7 @@ public static void DrawCircle( Vector3 position, float radius, Color color, - int width = 5, + int width = 3, bool zDeep = false) { try @@ -704,6 +691,8 @@ public override void OnDraw() private static void CircleDispose(object sender, EventArgs e) { + CircleOnPreReset(EventArgs.Empty); + if (effect != null && !effect.IsDisposed) { effect.Dispose(); @@ -774,6 +763,7 @@ public Line(Vector2 start, Vector2 end, int width, ColorBGRA color) this.Start = start; this.End = end; Game.OnUpdate += this.LineOnUpdate; + this.SubscribeToResetEvents(); } #endregion @@ -840,6 +830,8 @@ public int Width /// public override void Dispose() { + this.OnPreReset(); + if (!this.line.IsDisposed) { this.line.Dispose(); @@ -940,6 +932,7 @@ public Rectangle(int x, int y, int width, int height, ColorBGRA color) this.Color = color; this.line = new SharpDX.Direct3D9.Line(Device) { Width = height }; Game.OnUpdate += this.RectangleOnUpdate; + this.SubscribeToResetEvents(); } #endregion @@ -995,6 +988,8 @@ public Rectangle(int x, int y, int width, int height, ColorBGRA color) /// public override void Dispose() { + this.OnPreReset(); + if (!this.line.IsDisposed) { this.line.Dispose(); @@ -1086,6 +1081,15 @@ public class RenderObject : IDisposable #endregion + #region Constructors and Destructors + + ~RenderObject() + { + this.OnPreReset(); + } + + #endregion + #region Delegates /// @@ -1161,6 +1165,17 @@ public virtual void OnPreReset() } #endregion + + #region Methods + + internal void SubscribeToResetEvents() + { + Drawing.OnPreReset += delegate { this.OnPreReset(); }; + Drawing.OnPostReset += delegate { this.OnPostReset(); }; + AppDomain.CurrentDomain.DomainUnload += delegate { this.OnPreReset(); }; + } + + #endregion } /// @@ -1249,6 +1264,7 @@ public Sprite(string fileLocation, Vector2 position) private Sprite() { Game.OnUpdate += this.SpriteOnUpdate; + this.SubscribeToResetEvents(); } #endregion @@ -1415,7 +1431,9 @@ public void Crop(SharpDX.Rectangle rect, bool scale = false) /// public override void Dispose() { + this.OnPreReset(); Game.OnUpdate -= this.SpriteOnUpdate; + if (!this.sprite.IsDisposed) { this.sprite.Dispose(); @@ -1489,7 +1507,10 @@ public override void OnEndScene() /// public override void OnPostReset() { - this.sprite.OnResetDevice(); + if (this.sprite != null && !this.sprite.IsDisposed) + { + this.sprite?.OnResetDevice(); + } } /// @@ -1497,7 +1518,10 @@ public override void OnPostReset() /// public override void OnPreReset() { - this.sprite.OnLostDevice(); + if (this.sprite != null && !this.sprite.IsDisposed) + { + this.sprite?.OnLostDevice(); + } } /// @@ -1781,6 +1805,7 @@ private Text(string text, string fontName, int size, ColorBGRA color) this.Color = color; this.TextString = text; Game.OnUpdate += this.TextOnUpdate; + this.SubscribeToResetEvents(); } #endregion @@ -1912,6 +1937,8 @@ public int Y public override void Dispose() { Game.OnUpdate -= this.TextOnUpdate; + this.OnPreReset(); + if (!this.textFont.IsDisposed) { this.textFont.Dispose(); diff --git a/Core/Utils/ResourceFactory.cs b/Core/Utils/ResourceFactory.cs index 166c816..55937d7 100644 --- a/Core/Utils/ResourceFactory.cs +++ b/Core/Utils/ResourceFactory.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.IO; @@ -26,16 +26,7 @@ namespace LeagueSharp.SDK.Core.Utils public static class ResourceFactory { - [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - public static string StringResource(string file, Assembly assembly = null) - { - if (file == null) - { - throw new ArgumentNullException(nameof(file)); - } - - return Encoding.Default.GetString(ByteResource(file, assembly)); - } + #region Public Methods and Operators [PermissionSet(SecurityAction.Assert, Unrestricted = true)] public static byte[] ByteResource(string file, Assembly assembly = null) @@ -62,5 +53,18 @@ public static byte[] ByteResource(string file, Assembly assembly = null) return ms.ToArray(); } } + + [PermissionSet(SecurityAction.Assert, Unrestricted = true)] + public static string StringResource(string file, Assembly assembly = null) + { + if (file == null) + { + throw new ArgumentNullException(nameof(file)); + } + + return Encoding.Default.GetString(ByteResource(file, assembly)); + } + + #endregion } } \ No newline at end of file diff --git a/Core/Utils/ResourceImportAttribute.cs b/Core/Utils/ResourceImportAttribute.cs index 3ee00c8..6a19099 100644 --- a/Core/Utils/ResourceImportAttribute.cs +++ b/Core/Utils/ResourceImportAttribute.cs @@ -15,13 +15,15 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property)] internal class ResourceImportAttribute : Attribute { + #region Constructors and Destructors + public ResourceImportAttribute() { } @@ -36,8 +38,14 @@ public ResourceImportAttribute(string file) this.File = file; } + #endregion + + #region Public Properties + public string File { get; set; } public Type Filter { get; set; } + + #endregion } } \ No newline at end of file diff --git a/Core/Utils/ResourceLoader.cs b/Core/Utils/ResourceLoader.cs index d842f53..6f92018 100644 --- a/Core/Utils/ResourceLoader.cs +++ b/Core/Utils/ResourceLoader.cs @@ -15,15 +15,19 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; using System.Linq; using System.Reflection; + using LeagueSharp.SDK.Enumerations; + internal static class ResourceLoader { + #region Public Methods and Operators + public static void Initialize() { var importClasses = @@ -42,7 +46,9 @@ public static void Initialize() if (import.Filter != null) { - if (!import.Filter.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IFilter<>))) + if ( + !import.Filter.GetInterfaces() + .Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IFilter<>))) { throw new Exception($"{nameof(import.Filter)} does not implement {nameof(IFilter)}"); } @@ -63,6 +69,17 @@ public static void Initialize() } } + #endregion + + #region Methods + + private static IEnumerable GetFieldsAndProperties( + Type type, + BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) + { + return type.GetMembers(flags).Where(m => m.IsDefined(typeof(ResourceImportAttribute), false)); + } + private static Type GetMemberType(this MemberInfo member) { switch (member.MemberType) @@ -74,7 +91,9 @@ private static Type GetMemberType(this MemberInfo member) return ((PropertyInfo)member).PropertyType; default: - throw new ArgumentException($"{nameof(MemberInfo)} must be if type {nameof(FieldInfo)} or {nameof(PropertyInfo)}", nameof(member)); + throw new ArgumentException( + $"{nameof(MemberInfo)} must be if type {nameof(FieldInfo)} or {nameof(PropertyInfo)}", + nameof(member)); } } @@ -91,15 +110,12 @@ private static void SetValue(this MemberInfo member, object target, object value break; default: - throw new ArgumentException($"{nameof(MemberInfo)} must be if type {nameof(FieldInfo)} or {nameof(PropertyInfo)}", nameof(member)); + throw new ArgumentException( + $"{nameof(MemberInfo)} must be if type {nameof(FieldInfo)} or {nameof(PropertyInfo)}", + nameof(member)); } } - private static IEnumerable GetFieldsAndProperties( - Type type, - BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) - { - return type.GetMembers(flags).Where(m => m.IsDefined(typeof(ResourceImportAttribute), false)); - } + #endregion } } \ No newline at end of file diff --git a/Core/Utils/Storage.cs b/Core/Utils/Storage.cs index 79ad77c..4868fe8 100644 --- a/Core/Utils/Storage.cs +++ b/Core/Utils/Storage.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections; @@ -25,7 +25,7 @@ namespace LeagueSharp.SDK.Core.Utils using System.Reflection; using System.Runtime.Serialization; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; /// /// The storage, main purpose is to save share-able settings between assemblies. diff --git a/Core/Utils/TickOperation.cs b/Core/Utils/TickOperation.cs index 76eb7d7..dccdc86 100644 --- a/Core/Utils/TickOperation.cs +++ b/Core/Utils/TickOperation.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; diff --git a/Core/Utils/WeightedRandom.cs b/Core/Utils/WeightedRandom.cs index f835942..887a488 100644 --- a/Core/Utils/WeightedRandom.cs +++ b/Core/Utils/WeightedRandom.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Collections.Generic; diff --git a/Core/Utils/WindowsKeys.cs b/Core/Utils/WindowsKeys.cs index dd8eb38..d7a99f7 100644 --- a/Core/Utils/WindowsKeys.cs +++ b/Core/Utils/WindowsKeys.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Utils +namespace LeagueSharp.SDK.Utils { using System; using System.Windows.Forms; - using LeagueSharp.SDK; + using LeagueSharp.SDK.Enumerations; using SharpDX; @@ -71,22 +71,10 @@ public WindowsKeys(WndEventArgs args) /// Gets the full name of the mapped key. /// public Keys Key - { - get - { - Keys keyData; - if ((Keys)((int)this.args.WParam) != Control.ModifierKeys) - { - keyData = (Keys)((int)this.args.WParam) | Control.ModifierKeys; - } - else - { - keyData = (Keys)((int)this.args.WParam); - } - - return keyData; - } - } + => + (Keys)((int)this.args.WParam) != Control.ModifierKeys + ? (Keys)((int)this.args.WParam) | Control.ModifierKeys + : (Keys)((int)this.args.WParam); /// /// Gets the message of the key. @@ -117,10 +105,12 @@ public Keys SideButton get { var bytes = BitConverter.GetBytes(this.args.WParam); + if (bytes.Length > 2) { int buttonId = bytes[2]; var sideButton = Keys.None; + if (buttonId == 1) { sideButton = Keys.XButton1; diff --git a/Core/Variables.cs b/Core/Variables.cs index 2eb4ca0..48c8221 100644 --- a/Core/Variables.cs +++ b/Core/Variables.cs @@ -19,7 +19,7 @@ namespace LeagueSharp.SDK { using System; - using LeagueSharp.SDK.Core.UI.IMenu; + using LeagueSharp.SDK.UI; /// /// Variables of the LeagueSharp development kit. @@ -28,11 +28,6 @@ public class Variables { #region Static Fields - /// - /// The game version. - /// - public static readonly Version GameVersion = new Version("6.7"); - /// /// The kit version. /// @@ -68,4 +63,4 @@ public class Variables #endregion } -} +} \ No newline at end of file diff --git a/Core/Wrappers/Damages/Damage.cs b/Core/Wrappers/Damages/Damage.cs index ea1f5fc..1769cf7 100644 --- a/Core/Wrappers/Damages/Damage.cs +++ b/Core/Wrappers/Damages/Damage.cs @@ -15,13 +15,15 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Wrappers.Damages +namespace LeagueSharp.SDK { using System; using System.Linq; - using System.Text.RegularExpressions; - using Utils; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.Data.Enumerations; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; /// /// Damage wrapper class, contains functions to calculate estimated damage to a unit and also provides damage details. @@ -67,7 +69,7 @@ public static double CalculateDamage( damage = source.CalculateMixedDamage(target, damage / 2, damage / 2); break; case DamageType.True: - damage = Math.Floor(source.PassivePercentMod(target, Math.Max(amount, 0), DamageType.True)); + damage = Math.Max(Math.Floor(amount), 0); break; } @@ -208,7 +210,7 @@ public static double GetAutoAttackDamage(this Obj_AI_Base source, Obj_AI_Base ta } // Fervor Of Battle - if (hero.GetFerocity(DamageMastery.Ferocity.FervorofBattle).IsValid()) + if (hero.GetFerocity(Ferocity.FervorofBattle).IsValid()) { var fervorBuffCount = hero.GetBuffCount("MasteryOnHitDamageStacker"); if (fervorBuffCount > 0) @@ -222,15 +224,14 @@ public static double GetAutoAttackDamage(this Obj_AI_Base source, Obj_AI_Base ta else if (target is Obj_AI_Minion) { // Savagery - var savagery = hero.GetCunning(DamageMastery.Cunning.Savagery); + var savagery = hero.GetCunning(Cunning.Savagery); if (savagery.IsValid()) { dmgPhysical += savagery.Points; } // RiftHerald P - if (!hero.IsMelee() && target.Team == GameObjectTeam.Neutral - && Regex.IsMatch(target.Name, "SRU_RiftHerald")) + if (!hero.IsMelee() && target.Team == GameObjectTeam.Neutral && target.Name == "SRU_RiftHerald") { dmgReduce *= 0.65; } @@ -354,7 +355,7 @@ public static double GetSpellDamage( } else if (targetMinion != null) { - var savagery = source.GetCunning(DamageMastery.Cunning.Savagery); + var savagery = source.GetCunning(Cunning.Savagery); if (savagery.IsValid()) { dmgBase += savagery.Points; @@ -395,7 +396,7 @@ public static double GetSpellDamage( } else if (targetMinion == null) { - var savagery = source.GetCunning(DamageMastery.Cunning.Savagery); + var savagery = source.GetCunning(Cunning.Savagery); if (savagery.IsValid()) { dmg += savagery.Points; @@ -438,7 +439,7 @@ public static double GetSpellDamage( { dmgReduce *= 0.9; } - if (source.GetFerocity(DamageMastery.Ferocity.FervorofBattle).IsValid()) + if (source.GetFerocity(Ferocity.FervorofBattle).IsValid()) { var fervorBuffCount = source.GetBuffCount("MasteryOnHitDamageStacker"); if (fervorBuffCount > 0) @@ -658,21 +659,11 @@ private static double DamageReductionMod( DamageType damageType) { var targetHero = target as Obj_AI_Hero; - - // Dragon Buff - if (source is Obj_AI_Turret && targetHero != null) - { - var dragonBuff = targetHero.GetBuffCount("s5test_dragonslayerbuff"); - if (dragonBuff >= 4) - { - amount *= dragonBuff == 5 ? 0.6 : 0.8; - } - } - + if (source is Obj_AI_Hero) { // Exhaust - if (source.HasBuff("Exhaust")) + if (source.HasBuff("SummonerExhaust")) { amount *= 0.6; } @@ -704,7 +695,7 @@ private static double DamageReductionMod( if (targetHero != null) { // Bond Of Stone - if (targetHero.GetResolve(DamageMastery.Resolve.BondofStone).IsValid()) + if (targetHero.GetResolve(Resolve.BondofStone).IsValid()) { amount *= 0.96; } @@ -816,7 +807,7 @@ private static double PassiveFlatMod(this GameObject source, Obj_AI_Base target) var targetHero = target as Obj_AI_Hero; // ToughSkin - if (targetHero != null && targetHero.GetResolve(DamageMastery.Resolve.ToughSkin).IsValid() + if (targetHero != null && targetHero.GetResolve(Resolve.ToughSkin).IsValid() && (source is Obj_AI_Hero || (source is Obj_AI_Minion && source.Team == GameObjectTeam.Neutral))) { value -= 2; @@ -874,13 +865,13 @@ private static double PassivePercentMod( if (hero != null) { // DoubleEdgedSword - if (damageType != DamageType.True && hero.GetFerocity(DamageMastery.Ferocity.DoubleEdgedSword).IsValid()) + if (damageType != DamageType.True && hero.GetFerocity(Ferocity.DoubleEdgedSword).IsValid()) { amount *= hero.IsMelee() ? 1.03 : 1.02; } // Oppressor - if (hero.GetFerocity(DamageMastery.Ferocity.Oppressor).IsValid() && target.IsMoveImpaired()) + if (hero.GetFerocity(Ferocity.Oppressor).IsValid() && target.IsMoveImpaired()) { amount *= 1.025; } @@ -896,7 +887,7 @@ private static double PassivePercentMod( } // Assassin - if (hero.GetCunning(DamageMastery.Cunning.Assassin).IsValid() + if (hero.GetCunning(Cunning.Assassin).IsValid() && !GameObjects.Heroes.Any( h => h.Team == hero.Team && !h.Compare(hero) && h.Distance(hero) < 800)) { @@ -904,7 +895,7 @@ private static double PassivePercentMod( } // Merciless - var merciless = hero.GetCunning(DamageMastery.Cunning.Merciless); + var merciless = hero.GetCunning(Cunning.Merciless); if (merciless.IsValid() && targetHero.HealthPercent < 40) { amount *= 1 + (merciless.Points / 100); @@ -923,7 +914,7 @@ private static double PassivePercentMod( // DoubleEdgedSword if (targetHero != null && damageType != DamageType.True - && targetHero.GetFerocity(DamageMastery.Ferocity.DoubleEdgedSword).IsValid()) + && targetHero.GetFerocity(Ferocity.DoubleEdgedSword).IsValid()) { amount *= targetHero.IsMelee() ? 1.015 : 1.02; } diff --git a/Core/Wrappers/Damages/DamageJson.cs b/Core/Wrappers/Damages/DamageJson.cs deleted file mode 100644 index 92ebf74..0000000 --- a/Core/Wrappers/Damages/DamageJson.cs +++ /dev/null @@ -1,365 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK.Core.Wrappers.Damages -{ - using System.Collections.Generic; - - /// - /// Damage wrapper class, contains functions to calculate estimated damage to a unit and also provides damage details. - /// - public static partial class Damage - { - #region Enums - - /// - /// The Damage Scaling Target Type enumeration. - /// - public enum DamageScalingTarget - { - /// - /// The Source target type. - /// - Source, - - /// - /// The Target target type. - /// - Target - } - - /// - /// The Damage Scaling Type enumeration. - /// - public enum DamageScalingType - { - /// - /// The Bonus Attack Points scaling type. - /// - BonusAttackPoints, - - /// - /// The Ability Points scaling type. - /// - AbilityPoints, - - /// - /// The Attack Points scaling type. - /// - AttackPoints, - - /// - /// The Max Health scaling type. - /// - MaxHealth, - - /// - /// The Current Health scaling type. - /// - CurrentHealth, - - /// - /// The Missing Health scaling type. - /// - MissingHealth, - - /// - /// The Bonus Health scaling type. - /// - BonusHealth, - - /// - /// The Armor scaling type. - /// - Armor, - - /// - /// The Mana scaling type. - /// - MaxMana - } - - /// - /// The Damage Stage enumeration. - /// - public enum DamageStage - { - /// - /// The Default stage. - /// - Default, - - /// - /// The WayBack stage. - /// - WayBack, - - /// - /// The Detonation stage. - /// - Detonation, - - /// - /// The Damage Per Second stage. - /// - DamagePerSecond, - - /// - /// The Second Form stage. - /// - SecondForm, - - /// - /// The Second Cast stage. - /// - SecondCast, - - /// - /// The Buff stage. - /// - Buff, - - /// - /// The Empowered stage. - /// - Empowered - } - - /// - /// - public enum SpellEffectType - { - /// - /// - None, - - /// - /// - AoE, - - /// - /// - Single, - - /// - /// - OverTime, - - /// - /// - Attack - } - - #endregion - - /// - /// The Champion Damage class container. - /// - internal class ChampionDamage - { - #region Public Properties - - /// - /// Gets the 'E' spell damage classes. - /// - public List E { get; set; } - - /// - /// Gets the 'Q' spell damage classes. - /// - public List Q { get; set; } - - /// - /// Gets the 'R' spell damage classes. - /// - public List R { get; set; } - - /// - /// Gets the 'W' spell damage classes. - /// - public List W { get; set; } - - #endregion - - #region Public Methods and Operators - - /// - /// Resolves the spell damage classes entry through the SpellSlot component. - /// - /// - /// The SpellSlot. - /// - /// - /// The spell damage classes of the requested Spell Slot. - /// - public IEnumerable GetSlot(SpellSlot slot) - { - switch (slot) - { - case SpellSlot.Q: - return this.Q; - case SpellSlot.W: - return this.W; - case SpellSlot.E: - return this.E; - case SpellSlot.R: - return this.R; - } - - return null; - } - - #endregion - } - - /// - /// The Champion Damage Spell class container. - /// - internal class ChampionDamageSpell - { - #region Public Properties - - /// - /// Gets the Spell Data. - /// - public ChampionDamageSpellData SpellData { get; set; } - - /// - /// Gets the Spell Stage. - /// - public DamageStage Stage { get; set; } - - #endregion - } - - /// - /// The Champion Damage Spell Bonus class container. - /// - internal class ChampionDamageSpellBonus - { - #region Public Properties - - public List BonusDamageOnMinion { get; set; } - - /// - /// Gets the Damage Percentages. - /// - public List DamagePercentages { get; set; } - - /// - /// Gets the Damage Type. - /// - public DamageType DamageType { get; set; } - - public List MaxDamageOnMinion { get; set; } - - public List MinDamage { get; set; } - - public double ScalePer100Ad { get; set; } - - public double ScalePer100Ap { get; set; } - - public double ScalePer100BonusAd { get; set; } - - /// - /// Gets the Scaling Buff. - /// - public string ScalingBuff { get; set; } - - /// - /// Gets the Scaling Buff Offset. - /// - public int ScalingBuffOffset { get; set; } - - /// - /// Gets the Scaling Buff Target. - /// - public DamageScalingTarget ScalingBuffTarget { get; set; } - - /// - /// Gets the Scaling Target Type. - /// - public DamageScalingTarget ScalingTarget { get; set; } - - /// - /// Gets the Scaling Type. - /// - public DamageScalingType ScalingType { get; set; } - - #endregion - } - - /// - /// The Champion Damage Spell Data class container. - /// - internal class ChampionDamageSpellData - { - #region Public Properties - - public List BonusDamageOnMinion { get; set; } - - /// - /// Gets the Bonus Damages. - /// - public List BonusDamages { get; set; } - - /// - /// Gets the Main Damages. - /// - public List Damages { get; set; } - - public List DamagesPerLvl { get; set; } - - /// - /// Gets the Damage Type. - /// - public DamageType DamageType { get; set; } - - public bool IsApplyOnHit { get; set; } - - public bool IsModifiedDamage { get; set; } - - public List MaxDamageOnMinion { get; set; } - - public double ScalePerTargetMissHealth { get; set; } - - /// - /// Gets the Scaling Slot. - /// - public SpellSlot ScaleSlot { get; set; } = SpellSlot.Unknown; - - /// - /// Gets the Scaling Buff. - /// - public string ScalingBuff { get; set; } - - /// - /// Gets the Scaling Buff Offset. - /// - public int ScalingBuffOffset { get; set; } - - /// - /// Gets the Scaling Buff Target. - /// - public DamageScalingTarget ScalingBuffTarget { get; set; } - - public SpellEffectType SpellEffectType { get; set; } - - #endregion - } - } -} \ No newline at end of file diff --git a/Core/Wrappers/Damages/DamageLibrary.cs b/Core/Wrappers/Damages/DamageLibrary.cs index 4819959..a8e0054 100644 --- a/Core/Wrappers/Damages/DamageLibrary.cs +++ b/Core/Wrappers/Damages/DamageLibrary.cs @@ -15,19 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Wrappers.Damages +namespace LeagueSharp.SDK { using System; using System.Collections.Generic; - using System.Linq; - using System.Security.Permissions; - using System.Text; - using Utils; - using Properties; - - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.Data.Enumerations; /// /// Damage wrapper class, contains functions to calculate estimated damage to a unit and also provides damage details. @@ -36,20 +31,10 @@ public static partial class Damage { #region Static Fields - /// - /// The damage version files. - /// - private static readonly IDictionary DamageFiles = new Dictionary - { { "6.7", Resources._6_7 } }; - - #endregion - - #region Properties - /// /// Gets the Damage Collection. /// - internal static IDictionary DamageCollection { get; } = + internal static IReadOnlyDictionary DamageCollection = new Dictionary(); #endregion @@ -59,53 +44,15 @@ public static partial class Damage /// /// Initializes a new instance of the class. /// - /// - /// The client version. - /// - internal static void Initialize(Version gameVersion) + internal static void Initialize() { Events.OnLoad += (sender, args) => { - OnLoad(gameVersion); + DamageCollection = Data.Get().Damage; CreatePassives(); }; } - /// - /// Creates the damage collection. - /// - /// - /// The converted s of damages into a dictionary collection. - /// - [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - private static void CreateDamages(IDictionary damages) - { - foreach (var champion in GameObjects.Heroes.Select(h => h.ChampionName).Distinct()) - { - JToken value; - if (damages.TryGetValue(champion, out value)) - { - DamageCollection.Add(champion, JsonConvert.DeserializeObject(value.ToString())); - } - } - } - - private static void OnLoad(Version version) - { - var versionString = $"{version.Major}.{version.Minor}"; - - var fileBytes = DamageFiles.ContainsKey(versionString) - ? DamageFiles[versionString] - : DamageFiles.OrderByDescending(o => o.Key).FirstOrDefault().Value; - if (fileBytes != null) - { - CreateDamages(JObject.Parse(Encoding.Default.GetString(fileBytes))); - return; - } - - Logging.Write()(LogLevel.Fatal, "No suitable damage library is available."); - } - /// /// Resolves the spell bonus damage. /// diff --git a/Core/Wrappers/Damages/DamageMastery.cs b/Core/Wrappers/Damages/DamageMastery.cs index 6e16bac..1cc4277 100644 --- a/Core/Wrappers/Damages/DamageMastery.cs +++ b/Core/Wrappers/Damages/DamageMastery.cs @@ -1,8 +1,8 @@ -namespace LeagueSharp.SDK.Core.Wrappers.Damages +namespace LeagueSharp.SDK { using System.Linq; - public static class DamageMastery + public static partial class Damage { #region Enums diff --git a/Core/Wrappers/Damages/DamagePassives.cs b/Core/Wrappers/Damages/DamagePassives.cs index 6d96737..a59f08e 100644 --- a/Core/Wrappers/Damages/DamagePassives.cs +++ b/Core/Wrappers/Damages/DamagePassives.cs @@ -15,12 +15,14 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Core.Wrappers.Damages +namespace LeagueSharp.SDK { using System; using System.Collections.Generic; using System.Linq; + using LeagueSharp.Data.Enumerations; + /// /// Damage wrapper class, contains functions to calculate estimated damage to a unit and also provides damage details. /// @@ -133,9 +135,9 @@ private static void CreatePassives() }); AddPassiveAttack( string.Empty, - (hero, @base) => hero.GetBuffCount("rageblade") == 8, + (hero, @base) => Items.HasItem(3124, hero), DamageType.Magical, - (hero, @base) => 20 + (0.15 * hero.FlatPhysicalDamageMod) + (0.075 * hero.TotalMagicalDamage)); + (hero, @base) => 15); /*AddPassiveAttack( string.Empty, (hero, @base) => hero.HasBuff("Sheen"), @@ -159,7 +161,7 @@ private static void CreatePassives() string.Empty, (hero, @base) => hero.HasBuff("Mastery6261") && @base is Obj_AI_Hero, DamageType.Magical, - (hero, @base) => (hero.IsMelee() ? 0.03 : 0.015) * hero.MaxHealth); + (hero, @base) => (hero.IsMelee() ? 0.025 : 0.0125) * hero.MaxHealth); var excluded = new List(); foreach (var name in GameObjects.Heroes.Select(h => h.ChampionName).Where(name => !excluded.Contains(name))) @@ -297,12 +299,11 @@ private static void CreatePassives() case "Darius": AddPassiveAttack( "Darius", - (hero, @base) => true, + (hero, @base) => @base is Obj_AI_Hero, DamageType.Physical, (hero, @base) => ((9 + hero.Level + (hero.FlatPhysicalDamageMod * 0.3)) - * Math.Min(Math.Max(@base.GetBuffCount("dariushemo"), 0) + 1, 5)) - * (@base is Obj_AI_Minion ? 0.25 : 1)); + * Math.Min(Math.Max(0, @base.GetBuffCount("dariushemo")) + 1, 5))); AddPassiveAttack( "Darius", (hero, @base) => hero.HasBuff("DariusNoxianTacticsONH"), @@ -385,7 +386,7 @@ private static void CreatePassives() case "Fizz": AddPassiveAttack( "Fizz", - (hero, @base) => hero.Spellbook.GetSpell(SpellSlot.W).Level > 0, + (hero, @base) => hero.Spellbook.GetSpell(SpellSlot.W).Level > 0 && @base is Obj_AI_Hero, DamageType.Magical, (hero, @base) => hero.GetSpellDamage(@base, SpellSlot.W) * 0.5 / 3, true); @@ -399,7 +400,7 @@ private static void CreatePassives() case "Gangplank": AddPassiveAttack( "Gangplank", - (hero, @base) => hero.HasBuff("gangplankpassiveattack"), + (hero, @base) => hero.HasBuff("gangplankpassiveattack") && @base is Obj_AI_Hero, DamageType.True, (hero, @base) => 20 + (10 * hero.Level) + hero.FlatPhysicalDamageMod); break; @@ -733,7 +734,7 @@ private static void CreatePassives() DamageType.Physical, (hero, @base) => hero.GetSpellDamage(@base, SpellSlot.Q) * hero.GetCritMultiplier(true) - + Math.Max(hero.GetBuffCount("nasusqstacks"), 0), + + Math.Max(0, hero.GetBuffCount("nasusqstacks")), true); break; case "Nautilus": @@ -744,9 +745,9 @@ private static void CreatePassives() (hero, @base) => 2 + (6 * hero.Level)); AddPassiveAttack( "Nautilus", - (hero, @base) => hero.HasBuff("nautiluspiercinggazeshield"), + (hero, @base) => hero.HasBuff("nautiluspiercinggazeshield") && @base is Obj_AI_Hero, DamageType.Magical, - (hero, @base) => hero.GetSpellDamage(@base, SpellSlot.W) / (@base is Obj_AI_Hero ? 1 : 2), + (hero, @base) => hero.GetSpellDamage(@base, SpellSlot.W), true); break; case "Nidalee": @@ -1012,8 +1013,9 @@ private static void CreatePassives() DamageType.Magical, (hero, @base) => hero.GetSpellDamage(@base, SpellSlot.E) - + (hero.GetSpellDamage(@base, SpellSlot.E, DamageStage.DamagePerSecond) - / (@base is Obj_AI_Hero ? 1 : 4)), + + (@base is Obj_AI_Hero + ? hero.GetSpellDamage(@base, SpellSlot.E, DamageStage.DamagePerSecond) + : 0), true); break; case "Thresh": @@ -1088,14 +1090,13 @@ private static void CreatePassives() case "Twitch": AddPassiveAttack( "Twitch", - (hero, @base) => true, + (hero, @base) => @base is Obj_AI_Hero, DamageType.True, (hero, @base) => (hero.Level < 5 ? 12 : (hero.Level < 9 ? 18 : (hero.Level < 13 ? 24 : (hero.Level < 17 ? 30 : 36)))) - * Math.Min(Math.Max(@base.GetBuffCount("twitchdeadlyvenom"), 0) + 1, 6) - / (@base is Obj_AI_Minion ? 1 : 6d)); + * Math.Min(Math.Max(0, @base.GetBuffCount("twitchdeadlyvenom")) + 1, 6)); break; case "Udyr": AddPassiveAttack( @@ -1245,8 +1246,7 @@ private static void CreatePassives() { var level = hero.Level; var dmg = (16 + ((level < 7 ? 4 : (level < 13 ? 8 : 12)) * level)) - + (hero.TotalMagicalDamage - * (level < 7 ? 0.25 : (level < 13 ? 0.3 : 0.35))); + + (hero.TotalMagicalDamage * (level < 7 ? 0.3 : (level < 13 ? 0.4 : 0.5))); return dmg; }); break; diff --git a/Core/Wrappers/Items.cs b/Core/Wrappers/Items.cs index 34ab1e0..542bca2 100644 --- a/Core/Wrappers/Items.cs +++ b/Core/Wrappers/Items.cs @@ -80,7 +80,7 @@ public static bool CanUseItem(int id) /// public static InventorySlot GetWardSlot() { - var wardIds = new[] { 3340, 3363, 2049, 2045, 2301, 2302, 2303, 3711, 1408, 1409, 1410, 1411, 3932, 2043 }; + var wardIds = new[] { 2049, 2045, 2301, 2302, 2303, 3711, 1408, 1409, 1410, 1411, 3932, 3340, 2043 }; return (from wardId in wardIds where CanUseItem(wardId) select GameObjects.Player.InventoryItems.FirstOrDefault(slot => slot.Id == (ItemId)wardId)) @@ -200,7 +200,7 @@ public static bool UseItem(int id, Vector2 position) /// public static bool UseItem(int id, Vector3 position) { - return position != Vector3.Zero + return position.IsValid() && GameObjects.Player.InventoryItems.Where(slot => slot.Id == (ItemId)id) .Select(slot => GameObjects.Player.Spellbook.CastSpell(slot.SpellSlot, position)) .FirstOrDefault(); @@ -236,6 +236,7 @@ public class Item public Item(int id, float range) { var item = ItemData.Entries.FirstOrDefault(i => (int)i.Id == id); + if (item == null) { throw new MissingMemberException($"Unable to find item with the id {id}"); @@ -260,6 +261,7 @@ public Item(int id, float range) public Item(ItemId id, float range) { var item = ItemData.Entries.FirstOrDefault(x => x.Id == id); + if (item == null) { throw new MissingMemberException($"Unable to find item with the id {id}"); @@ -459,7 +461,7 @@ public bool IsInRange(Vector2 position) /// public bool IsInRange(Vector3 position) { - return GameObjects.Player.ServerPosition.DistanceSquared(position) < this.RangeSqr; + return GameObjects.Player.DistanceSquared(position) < this.RangeSqr; } /// diff --git a/Core/Wrappers/Map.cs b/Core/Wrappers/Map.cs index 9fe37bd..086a7ba 100644 --- a/Core/Wrappers/Map.cs +++ b/Core/Wrappers/Map.cs @@ -19,54 +19,22 @@ namespace LeagueSharp.SDK { using System.Collections.Generic; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; using SharpDX; /// /// Utility for the Maps in League of Legends. /// - [ResourceImport] public class Map { #region Static Fields - [ResourceImport("Data.Map.json")] - private static Dictionary MapById = new Dictionary(); - /// /// Map by ID list. /// - public static IReadOnlyDictionary Maps => MapById; - - #endregion - - #region Public Properties - - /// - /// Gets the Grid of the Map - /// - public Vector2 Grid { get; set; } - - /// - /// Gets the MapType - /// - public GameMapId MapId { get; set; } - - /// - /// Gets the name of the map - /// - public string Name { get; set; } - - /// - /// Gets the short name of the map. - /// - public string ShortName { get; set; } - - /// - /// Gets the level the players start at - /// - public int StartingLevel { get; set; } + public static IReadOnlyDictionary Maps = Data.Get().Maps; #endregion @@ -78,14 +46,14 @@ public class Map /// /// The current map information. /// - public static Map GetMap() + public static MapDataEntry GetMap() { - if (MapById.ContainsKey((int)Game.MapId)) + if (Maps.ContainsKey((int)Game.MapId)) { - return MapById[(int)Game.MapId]; + return Maps[(int)Game.MapId]; } - return new Map + return new MapDataEntry { Name = "Unknown", ShortName = "unknown", MapId = 0, Grid = new Vector2(0, 0), StartingLevel = 1 }; diff --git a/Core/Wrappers/Orbwalking/Orbwalker.cs b/Core/Wrappers/Orbwalking/Orbwalker.cs index f9c5576..72dfc32 100644 --- a/Core/Wrappers/Orbwalking/Orbwalker.cs +++ b/Core/Wrappers/Orbwalking/Orbwalker.cs @@ -21,14 +21,14 @@ namespace LeagueSharp.SDK using System.Linq; using System.Windows.Forms; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; using SharpDX; using Color = System.Drawing.Color; - using Menu = LeagueSharp.SDK.Core.UI.IMenu.Menu; + using Menu = LeagueSharp.SDK.UI.Menu; /// /// The Orbwalker system. @@ -434,7 +434,7 @@ private void OnDrawingDraw(EventArgs args) Render.Circle.DrawCircle( GameObjects.Player.Position, GameObjects.Player.GetRealAutoAttackRange(), - Color.Blue); + Color.PaleGreen); } if (this.Menu["drawings"]["drawExtraHoldPosition"].GetValue().Value @@ -457,7 +457,7 @@ private void OnDrawingDraw(EventArgs args) Render.Circle.DrawCircle( enemy.Position, enemy.GetRealAutoAttackRange(GameObjects.Player), - Color.Blue); + Color.PaleVioletRed); } } @@ -499,4 +499,4 @@ private void OnDrawingDraw(EventArgs args) #endregion } -} \ No newline at end of file +} diff --git a/Core/Wrappers/Orbwalking/OrbwalkerBase.cs b/Core/Wrappers/Orbwalking/OrbwalkerBase.cs index 9c4b2aa..42a4c96 100644 --- a/Core/Wrappers/Orbwalking/OrbwalkerBase.cs +++ b/Core/Wrappers/Orbwalking/OrbwalkerBase.cs @@ -20,7 +20,8 @@ namespace LeagueSharp.SDK using System; using System.Reflection; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -56,6 +57,7 @@ internal OrbwalkerBase() } var enumValues = Enum.GetValues(typeof(TK)); + if (enumValues.Length <= 0) { throw new ArgumentException("TK must contain at least one value."); @@ -305,7 +307,7 @@ public TK GetActiveMode() } /// - /// Gets the player's range. + /// Gets the target's AA range. /// /// /// The target. @@ -313,7 +315,7 @@ public TK GetActiveMode() /// /// The range. /// - public float GetMyRange(T target) + public float GetAutoAttackRange(T target) { return target.GetRealAutoAttackRange(); } @@ -345,7 +347,7 @@ public float GetMyRange(T target) /// public virtual void Orbwalk(T target = null, Vector3? position = null) { - if (this.CanAttack() && this.AttackState) + if (this.CanAttack() && this.AttackState && !GameObjects.Player.IsCastingInterruptableSpell()) { var gTarget = target ?? this.GetTarget(); if (gTarget.InAutoAttackRange()) @@ -354,7 +356,7 @@ public virtual void Orbwalk(T target = null, Vector3? position = null) } } - if (this.CanMove() && this.MovementState) + if (this.CanMove() && this.MovementState && !GameObjects.Player.IsCastingInterruptableSpell(true)) { this.Move(position.HasValue && position.Value.IsValid() ? position.Value : Game.CursorPos); } @@ -428,7 +430,8 @@ private void ObjAiBaseOnOnBuffAdd(Obj_AI_Base sender, Obj_AI_BaseBuffAddEventArg { return; } - if (args.Buff.DisplayName == "PoppyPassiveBuff" || args.Buff.DisplayName == "SonaPassiveReady") + + if (args.Buff.DisplayName == "SonaPassiveReady") { this.ResetSwingTimer(); } @@ -442,8 +445,7 @@ private void ObjAiBaseOnOnBuffAdd(Obj_AI_Base sender, Obj_AI_BaseBuffAddEventArg /// private void OnGameUpdate(EventArgs args) { - if (GameObjects.Player == null || !GameObjects.Player.IsValid || GameObjects.Player.IsDead - || GameObjects.Player.IsCastingInterruptableSpell(true)) + if (GameObjects.Player == null || !GameObjects.Player.IsValid || GameObjects.Player.IsDead || MenuGUI.IsShopOpen) { return; } diff --git a/Core/Wrappers/Orbwalking/OrbwalkerSelector.cs b/Core/Wrappers/Orbwalking/OrbwalkerSelector.cs index 5b1bd9c..938e384 100644 --- a/Core/Wrappers/Orbwalking/OrbwalkerSelector.cs +++ b/Core/Wrappers/Orbwalking/OrbwalkerSelector.cs @@ -21,9 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; /// /// The target selecting system for Orbwalker. @@ -122,7 +122,7 @@ public List GetEnemyMinions(float range = 0) { return GameObjects.EnemyMinions.Where( - m => this.IsValidUnit(m, range) && !this.ignoreMinions.Any(b => b.Equals(m.CharData.BaseSkinName))) + m => IsValidUnit(m, range) && !this.ignoreMinions.Any(b => b.Equals(m.CharData.BaseSkinName))) .ToList(); } @@ -478,6 +478,23 @@ public bool ShouldWaitUnderTurret(Obj_AI_Minion noneKillableMinion = null) #region Methods + /// + /// Determines whether the unit is valid. + /// + /// + /// The unit. + /// + /// + /// The range. + /// + /// + /// The . + /// + private static bool IsValidUnit(AttackableUnit unit, float range = 0f) + { + return unit.IsValidTarget(range > 0 ? range : unit.GetRealAutoAttackRange()); + } + /// /// Orders the enemy minions. /// @@ -521,7 +538,7 @@ private List GetMinions(OrbwalkingMode mode) var cloneList = new List(); var wardList = new List(); foreach (var minion in - GameObjects.EnemyMinions.Where(m => this.IsValidUnit(m))) + GameObjects.EnemyMinions.Where(m => IsValidUnit(m))) { var baseName = minion.CharData.BaseSkinName.ToLower(); if (minions && minion.IsMinion()) @@ -544,12 +561,12 @@ private List GetMinions(OrbwalkingMode mode) minionList.AddRange( this.OrderJungleMinions( GameObjects.Jungle.Where( - j => this.IsValidUnit(j) && !j.CharData.BaseSkinName.Equals("gangplankbarrel")).ToList())); + j => IsValidUnit(j) && !j.CharData.BaseSkinName.Equals("gangplankbarrel")).ToList())); } if (attackWards) { - wardList.AddRange(GameObjects.EnemyWards.Where(w => this.IsValidUnit(w))); + wardList.AddRange(GameObjects.EnemyWards.Where(w => IsValidUnit(w))); } var finalMinionList = new List(); @@ -582,7 +599,7 @@ private List GetMinions(OrbwalkingMode mode) { finalMinionList.AddRange( GameObjects.Jungle.Where( - j => this.IsValidUnit(j) && j.Health <= 1 && j.CharData.BaseSkinName.Equals("gangplankbarrel")) + j => IsValidUnit(j) && j.Health <= 1 && j.CharData.BaseSkinName.Equals("gangplankbarrel")) .ToList()); } @@ -594,25 +611,6 @@ private List GetMinions(OrbwalkingMode mode) return finalMinionList.Where(m => !this.ignoreMinions.Any(b => b.Equals(m.CharData.BaseSkinName))).ToList(); } - /// - /// Determines whether the unit is valid. - /// - /// - /// The unit. - /// - /// - /// The range. - /// - /// - /// The . - /// - private bool IsValidUnit(AttackableUnit unit, float range = 0f) - { - var minion = unit as Obj_AI_Minion; - return unit.IsValidTarget(range > 0 ? range : unit.GetRealAutoAttackRange()) - && (minion == null || minion.IsHPBarRendered); - } - /// /// Orders the jungle minions. /// diff --git a/Core/Wrappers/Spells/Database/SpellDatabase.cs b/Core/Wrappers/Spells/Database/SpellDatabase.cs index d9a43c6..6d23c18 100644 --- a/Core/Wrappers/Spells/Database/SpellDatabase.cs +++ b/Core/Wrappers/Spells/Database/SpellDatabase.cs @@ -21,12 +21,12 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; /// /// The spell database. /// - [ResourceImport] public static class SpellDatabase { #region Static Fields @@ -34,10 +34,8 @@ public static class SpellDatabase /// /// A list of all the entries in the SpellDatabase. /// - public static IReadOnlyList Spells => SpellsList; - - [ResourceImport("Data.Database.json")] - private static List SpellsList = new List(); + public static IReadOnlyList Spells = + Data.Get().Spells; #endregion @@ -90,10 +88,19 @@ public static SpellDatabaseEntry GetByName(string spellName) spellData.SpellName.ToLower() == spellName || spellData.ExtraSpellNames.Contains(spellName)); } + /// + /// Queries a search through the spell collection by object name. + /// + /// The object name. + /// + /// The + /// public static SpellDatabaseEntry GetBySourceObjectName(string objectName) { objectName = objectName.ToLowerInvariant(); - return Spells.Where(spellData => spellData.SourceObjectName.Length != 0).FirstOrDefault(spellData => objectName.Contains(spellData.SourceObjectName)); + return + Spells.Where(spellData => spellData.SourceObjectName.Length != 0) + .FirstOrDefault(spellData => objectName.Contains(spellData.SourceObjectName)); } #endregion diff --git a/Core/Wrappers/Spells/Database/SpellDatabaseEntry.cs b/Core/Wrappers/Spells/Database/SpellDatabaseEntry.cs deleted file mode 100644 index 6fcbe65..0000000 --- a/Core/Wrappers/Spells/Database/SpellDatabaseEntry.cs +++ /dev/null @@ -1,337 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK -{ - /// - /// The spell database entry. - /// - public class SpellDatabaseEntry - { - #region Fields - - /// - /// The angle which the skillshot makes. - /// - public int Angle { get; set; } = 45; - - /// - /// The buffs applied by the spell on allies - /// - public BuffType[] AppliedBuffsOnAllies { get; set; } - - /// - /// The buffs applied by the spell on the target enemy champion/s - /// - public BuffType[] AppliedBuffsOnEnemies { get; set; } - - /// - /// The buffs applied by the spell on my hero - /// - public BuffType[] AppliedBuffsOnSelf { get; set; } - - /// - /// The name of the buff that the spell applies on the caster. - /// - public string AppliedBuffOnSelfName { get; set; } - - /// - /// The name of the buff applied on an ally. - /// - public string AppliedBuffOnAllyName { get; set; } - - /// - /// The name of the buff applied on an enemy. - /// - public string AppliedBuffOnEnemyName { get; set; } - - /// - /// The name of the buff that the spell applies on the target. - /// - public string AppliedBuffName { get; set; } - - /// - /// Indicates if the spell can be cast further than the range. For example that's True for Oriannas Q. - /// - public bool AvoidMaxRangeReduction { get; set; } - - /// - /// Indicates wether the spell has a varying range - /// - public bool FixedRange { get; set; } = false; - - /// - /// Indicates whether the spell can be removed. - /// - public bool CanBeRemoved { get; set; } = false; - - /// - /// Array indicating the possible cast types (on enemy champion, on self, on a position) - /// - public CastType[] CastType { get; set; } - - /// - /// SpellData Entry's Champion Name - /// - public string ChampionName { get; set; } - - /// - /// What the spell missile (if any) can collide with. - /// - public CollisionableObjects[] CollisionObjects { get; set; } = { }; - - /// - /// Specifies on a scale from 1 to 5 how dangerous our spell is - /// - public int DangerValue { get; set; } = 1; - - /// - /// The Spell Delay - /// - public int Delay { get; set; } = 250; - - /// - /// Extra missile names - /// - public string[] ExtraMissileNames { get; set; } = { }; - - /// - /// The extra range of the Spell, used on skillshots. - /// - public int ExtraRange { get; set; } = 0; - - /// - /// Extra spell names - /// - public string[] ExtraSpellNames { get; set; } = { }; - - /// - /// Indicates whether the spell is forcefully removed. - /// - public bool ForceRemove { get; set; } = false; - - /// - /// Source object name - /// - public string FromObject { get; set; } = string.Empty; - - /// - /// Source objects' names - /// - public string[] FromObjects { get; set; } = { }; - - /// - /// Is our spell dangerous? - /// - public bool IsDangerous { get; set; } = false; - - /// - /// The spell's missile acceleration - /// - public int MissileAccel { get; set; } = 0; - - /// - /// Is the missile delayed? - /// - public bool MissileDelayed { get; set; } - - /// - /// Does the missile follow the caster? - /// - public bool MissileFollowsCaster { get; set; } - - /// - /// The max speed the spell missile can reach - /// - public int MissileMaxSpeed { get; set; } = 0; - - /// - /// The min speed you can find the missile at - /// - public int MissileMinSpeed { get; set; } = 0; - - /// - /// Our spell missile average travel speed - /// - public int MissileSpeed { get; set; } = 1000; - - /// - /// The spell's missile name - /// - public string MissileSpellName { get; set; } = string.Empty; - - /// - /// The Arc Skillshot Angle. - /// - public int ArcAngle { get; set; } - - /// - /// The Ring Skillshot Radius. - /// - public int RingRadius { get; set; } - - /// - /// The raw radius of the spell (skillshots only) - /// - public int Radius { get; set; } - - /// - /// The Raw Spell Range - /// - public int Range { get; set; } = int.MaxValue; - - /// - /// Does the spell reset the autoattack timer? - /// - public bool ResetsAutoAttackTimer { get; set; } - - /// - /// The SpellSlot - /// - public SpellSlot Slot { get; set; } - - /// - /// Source object name - /// - public string SourceObjectName { get; set; } = string.Empty; - - /// - /// The SData Spell Name - /// - public string SpellName { get; set; } = string.Empty; - - /// - /// Tags which define the spell (is it a heal? does it deal damage? etc. see . - /// - public SpellTags[] SpellTags { get; set; } - - /// - /// The Spell Type (skillshotline, skillshotcircle, targeted and so on) - /// - public SpellType SpellType { get; set; } - - /// - /// Particle name on toggle - /// - public string ToggleParticleName { get; set; } = string.Empty; - - /// - /// The width of the skillshot. - /// - public int Width { get; set; } = 50; - - /// - /// The minimum timeframe taken to channel the spell. - /// - public int MinChannelDuration { get; set; } = 0; - - /// - /// The maximum timeframe the spell can be channeled for. - /// - public int MaxChannelDuration { get; set; } = 0; - - #endregion - - #region Constructors and Destructors - - /// - /// Initializes a new instance of the class. - /// - public SpellDatabaseEntry() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The champion name. - /// - /// - /// The spell name. - /// - /// - /// The slot. - /// - /// - /// The spell type. - /// - /// - /// The cast type. - /// - /// - /// The spell tags. - /// - /// - /// Indicates whether the spell resets the auto attack timer. - /// - /// - /// The range. - /// - /// - /// The delay. - /// - /// - /// The radius. - /// - /// - /// The width. - /// - /// - /// The missile speed. - /// - /// - /// The angle. - /// - /// - /// The default danger value. - /// - public SpellDatabaseEntry( - string championName, - string spellName, - SpellSlot slot, - SpellType spellType, - CastType[] castType, - SpellTags[] spellTags, - bool resetsAutoAttackTimer = false, - int range = int.MaxValue, - int delay = 250, - int radius = 50, - int width = 300, - int missileSpeed = 1400, - int angle = 360, - int defaultDangerValue = 1) - { - this.ChampionName = championName; - this.SpellName = spellName; - this.Slot = slot; - this.SpellType = spellType; - this.CastType = castType; - this.SpellTags = spellTags; - this.ResetsAutoAttackTimer = resetsAutoAttackTimer; - this.Delay = delay; - this.Range = range; - this.Radius = radius; - this.Width = width; - this.MissileSpeed = missileSpeed; - this.Angle = angle; - this.DangerValue = defaultDangerValue; - } - - #endregion - } -} diff --git a/Core/Wrappers/Spells/Spell.cs b/Core/Wrappers/Spells/Spell.cs index 0c49c37..37da77c 100644 --- a/Core/Wrappers/Spells/Spell.cs +++ b/Core/Wrappers/Spells/Spell.cs @@ -21,8 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.Data.Enumerations; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -183,7 +184,7 @@ public Vector3 From { get { - return !this.@from.ToVector2().IsValid() ? GameObjects.Player.ServerPosition : this.@from; + return !this.@from.IsValid() ? GameObjects.Player.ServerPosition : this.@from; } set @@ -276,9 +277,7 @@ public Vector3 RangeCheckFrom { get { - return !this.rangeCheckFrom.ToVector2().IsValid() - ? GameObjects.Player.ServerPosition - : this.rangeCheckFrom; + return !this.rangeCheckFrom.IsValid() ? GameObjects.Player.ServerPosition : this.rangeCheckFrom; } set @@ -352,10 +351,10 @@ public bool CanCast(Obj_AI_Base unit) /// /// The Target /// - /// The of the spell. + /// The of the spell. /// /// Can spell kill target - public bool CanKill(Obj_AI_Base unit, Damage.DamageStage stage = Damage.DamageStage.Default) + public bool CanKill(Obj_AI_Base unit, DamageStage stage = DamageStage.Default) { return unit.IsValidTarget() && this.GetDamage(unit, stage) > unit.Health; } @@ -708,7 +707,7 @@ public int CountHits(List points, Vector3 castPosition) /// /// Farm Location. /// - public FarmLocation GetCircularFarmLocation(List minions, float overrideWidth = -1) + public FarmLocation GetCircularFarmLocation(List minions, float overrideWidth = -1) { var positions = Minion.GetMinionsPredictedPositions( minions, @@ -776,12 +775,12 @@ public List GetCollision(Vector2 fromVector2, List to, flo /// The target. /// /// - /// The of the spell. + /// The of the spell. /// /// /// The damage value to target unit. /// - public float GetDamage(Obj_AI_Base target, Damage.DamageStage stage = Damage.DamageStage.Default) + public float GetDamage(Obj_AI_Base target, DamageStage stage = DamageStage.Default) { return (float)GameObjects.Player.GetSpellDamage(target, this.Slot, stage); } @@ -831,7 +830,7 @@ public float GetHitCount(HitChance hitChance = HitChance.High) /// /// Farm Location. /// - public FarmLocation GetLineFarmLocation(List minionPositions, float overrideWidth = -1) + public FarmLocation GetLineFarmLocation(List minionPositions, float overrideWidth = -1) { var positions = Minion.GetMinionsPredictedPositions( minionPositions, @@ -888,7 +887,7 @@ public PredictionOutput GetPrediction( Obj_AI_Base unit, bool aoe = false, float overrideRange = -1, - CollisionableObjects collisionable = CollisionableObjects.Heroes | CollisionableObjects.Minions) + CollisionableObjects collisionable = CollisionableObjects.Minions | CollisionableObjects.YasuoWall) { return Movement.GetPrediction( @@ -1409,4 +1408,4 @@ private void SpellbookOnCastSpell(Spellbook spellbook, SpellbookCastSpellEventAr #endregion } -} \ No newline at end of file +} diff --git a/Core/Wrappers/Spells/SpellTypes/BaseSpell.cs b/Core/Wrappers/Spells/SpellTypes/BaseSpell.cs index 6791ed6..b29d370 100644 --- a/Core/Wrappers/Spells/SpellTypes/BaseSpell.cs +++ b/Core/Wrappers/Spells/SpellTypes/BaseSpell.cs @@ -2,12 +2,21 @@ { using System; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Enumerations; + using SharpDX; using Color = System.Drawing.Color; public abstract class BaseSpell { + #region Fields + + public SpellDatabaseEntry SData; + + #endregion + #region Constructors and Destructors public BaseSpell(string spellName) @@ -24,46 +33,24 @@ public BaseSpell(SpellDatabaseEntry entry) #region Public Properties - public SpellDatabaseEntry SData; + public virtual Obj_AI_Base Caster { get; set; } public virtual SkillshotDetectionType DetectionType { get; set; } - public virtual Obj_AI_Base Caster { get; set; } + public virtual Vector2 EndPosition { get; set; } - public virtual Vector2 StartPosition { get; set; } + public bool HasMissile => this is SkillshotMissile; - public virtual Vector2 EndPosition { get; set; } + public virtual Vector2 StartPosition { get; set; } public virtual int StartTime { get; set; } - public bool HasMissile => this is SkillshotMissile; - #endregion #region Public Methods and Operators - public override string ToString() + public virtual void Draw(Color color, Color missileColor, int borderWidth = 1) { - return "BaseSpell: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType - + " SpellName=" + this.SData.SpellName; - } - - public void PrintSpellData() - { - Console.WriteLine(@"================="); - var properties = new[] - { - "ChampionName", "SpellType", "SpellName", "Range", "Radius", "Delay", "MissileSpeed", - "CanBeRemoved", "Angle", "FixedRange" - }; - properties.ForEach( - property => - { - Console.WriteLine( - "{0} => {1}", - property, - this.SData.GetType().GetProperty(property).GetValue(this.SData, null)); - }); } public virtual bool HasExpired() @@ -93,9 +80,37 @@ public virtual bool IsAboutToHit(Vector3 position, int afterTime) return false; } - internal virtual void Game_OnUpdate() { } + public void PrintSpellData() + { + Console.WriteLine(@"================="); + var properties = new[] + { + "ChampionName", "SpellType", "SpellName", "Range", "Radius", "Delay", "MissileSpeed", + "CanBeRemoved", "Angle", "FixedRange" + }; + properties.ForEach( + property => + { + Console.WriteLine( + "{0} => {1}", + property, + this.SData.GetType().GetProperty(property).GetValue(this.SData, null)); + }); + } + + public override string ToString() + { + return "BaseSpell: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods - public virtual void Draw(Color color, Color missileColor, int borderWidth = 1) { } + internal virtual void Game_OnUpdate() + { + } #endregion } diff --git a/Core/Wrappers/Spells/SpellTypes/Skillshot.cs b/Core/Wrappers/Spells/SpellTypes/Skillshot.cs index 5d15247..15e7134 100644 --- a/Core/Wrappers/Spells/SpellTypes/Skillshot.cs +++ b/Core/Wrappers/Spells/SpellTypes/Skillshot.cs @@ -2,15 +2,17 @@ { using System; using System.Collections.Generic; - using System.ComponentModel; + using LeagueSharp.Data.DataTypes; using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; - public class Skillshot : BaseSpell + using Color = System.Drawing.Color; + + public class Skillshot : BaseSpell { #region Constructors and Destructors @@ -26,11 +28,6 @@ public Skillshot(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "Skillshot: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - #region Public Properties public virtual SkillshotDetectionType DetectionType { get; set; } @@ -43,6 +40,25 @@ public override string ToString() #region Public Methods and Operators + public override void Draw(Color color, Color missileColor, int borderWidth = 1) + { + if (this.Path == null) + { + return; + } + //TODO: use playsharp.sdk for this when it's ready :waiting: + var zValue = ObjectManager.Player.Position.Z; + for (var i = 0; i < this.Path.Count; i++) + { + var startPoint = this.Path[i]; + var endPoint = this.Path[i + 1 == this.Path.Count ? 0 : i + 1]; + var startPointOnScreen = Drawing.WorldToScreen(new Vector3(startPoint.X, startPoint.Y, zValue)); + var endPointOnScreen = Drawing.WorldToScreen(new Vector3(endPoint.X, endPoint.Y, zValue)); + + Drawing.DrawLine(startPointOnScreen, endPointOnScreen, borderWidth, Color.White); + } + } + public virtual bool Process() { if (this.DetectionType == SkillshotDetectionType.ProcessSpell) @@ -61,7 +77,11 @@ public virtual bool Process() if (this.StartPosition == Vector2.Zero) { - Logging.Write()(LogLevel.Warn, "[Skillshot] Couldn't find the start position for skillshot: {0}, FromObject: {1}", this, this.SData.FromObject); + Logging.Write()( + LogLevel.Warn, + "[Skillshot] Couldn't find the start position for skillshot: {0}, FromObject: {1}", + this, + this.SData.FromObject); return false; } } @@ -69,69 +89,58 @@ public virtual bool Process() { this.StartPosition = this.Caster.ServerPosition.ToVector2(); } - + //TODO FromObjects //TODO Lucian Q ? } - if (this.DetectionType == SkillshotDetectionType.MissileCreate) { - } //Calculate the real end Point: this.Direction = (this.EndPosition - this.StartPosition).Normalized(); - if (!this.SData.AvoidMaxRangeReduction && this.StartPosition.DistanceSquared(this.EndPosition) > this.SData.Range * this.SData.Range || this.SData.FixedRange) + if (!this.SData.AvoidMaxRangeReduction + && this.StartPosition.DistanceSquared(this.EndPosition) > this.SData.Range * this.SData.Range + || this.SData.FixedRange) { this.EndPosition = this.StartPosition + this.Direction * this.SData.Range; } if (this.SData.ExtraRange != 0) { - this.EndPosition = this.EndPosition + - Math.Min(this.SData.ExtraRange, this.SData.Range - this.EndPosition.Distance(this.StartPosition)) * this.Direction; + this.EndPosition = this.EndPosition + + Math.Min( + this.SData.ExtraRange, + this.SData.Range - this.EndPosition.Distance(this.StartPosition)) + * this.Direction; } - + this.UpdatePolygon(); return true; } - internal virtual void Game_OnUpdate() + public override string ToString() { - + return "Skillshot: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; } - internal virtual void UpdatePolygon() - { + #endregion + + #region Methods + internal virtual void Game_OnUpdate() + { } internal virtual void UpdatePath() { - } - public override void Draw(System.Drawing.Color color, System.Drawing.Color missileColor, int borderWidth = 1) + internal virtual void UpdatePolygon() { - if (this.Path == null) - { - return; - } - //TODO: use playsharp.sdk for this when it's ready :waiting: - var zValue = ObjectManager.Player.Position.Z; - for (int i = 0; i < this.Path.Count; i++) - { - var startPoint = this.Path[i]; - var endPoint = this.Path[i + 1 == this.Path.Count ? 0 : i + 1]; - var startPointOnScreen = - Drawing.WorldToScreen(new Vector3(startPoint.X, startPoint.Y, zValue)); - var endPointOnScreen = - Drawing.WorldToScreen(new Vector3(endPoint.X, endPoint.Y, zValue)); - - Drawing.DrawLine(startPointOnScreen, endPointOnScreen, borderWidth, System.Drawing.Color.White); - } } #endregion diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotCircle.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotCircle.cs index 3db7181..d427bf2 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotCircle.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotCircle.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotCircle : Skillshot { @@ -25,12 +19,7 @@ public SkillshotCircle(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotCircle: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal CirclePoly Circle { get; set; } @@ -38,6 +27,21 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotCircle: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + + internal override void UpdatePath() + { + this.Path = this.Circle.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Circle == null) @@ -47,11 +51,6 @@ internal override void UpdatePolygon() } } - internal override void UpdatePath() - { - this.Path = this.Circle.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotCone.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotCone.cs index 29a99ec..8a569fe 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotCone.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotCone.cs @@ -1,13 +1,9 @@ namespace LeagueSharp.SDK { using System; - using System.Collections.Generic; - using System.ComponentModel; - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotCone : SkillshotMissile { @@ -25,12 +21,7 @@ public SkillshotCone(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotCone: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal SectorPoly Sector { get; set; } @@ -38,20 +29,35 @@ public override string ToString() #region Public Methods and Operators - internal override void UpdatePolygon() + public override string ToString() { - if (this.Sector == null) - { - this.Sector = new SectorPoly(this.StartPosition, this.EndPosition, (float) (this.SData.Angle * Math.PI / 180), this.SData.Range, 20); - this.UpdatePath(); - } + return "SkillshotCone: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; } + #endregion + + #region Methods + internal override void UpdatePath() { this.Path = this.Sector.ToClipperPath(); } + internal override void UpdatePolygon() + { + if (this.Sector == null) + { + this.Sector = new SectorPoly( + this.StartPosition, + this.EndPosition, + (float)(this.SData.Angle * Math.PI / 180), + this.SData.Range, + 20); + this.UpdatePath(); + } + } + #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotLine.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotLine.cs index c74ec81..d2f3da6 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotLine.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotLine.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotLine : SkillshotMissile { @@ -25,12 +19,7 @@ public SkillshotLine(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotLine: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal RectanglePoly Rectangle { get; set; } @@ -38,6 +27,21 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotLine: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + + internal override void UpdatePath() + { + this.Path = this.Rectangle.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Rectangle == null) @@ -47,11 +51,6 @@ internal override void UpdatePolygon() } } - internal override void UpdatePath() - { - this.Path = this.Rectangle.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotMissile.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotMissile.cs index 0463c34..164ed1b 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotMissile.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotMissile.cs @@ -1,11 +1,8 @@ namespace LeagueSharp.SDK { using System; - using System.Collections.Generic; - using System.ComponentModel; - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data.DataTypes; using SharpDX; @@ -25,16 +22,12 @@ public SkillshotMissile(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotMissile: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - #region Public Properties public MissileClient Missile { get; set; } - + public bool MissileDestroyed { get; set; } + #endregion #region Public Methods and Operators @@ -54,23 +47,22 @@ public virtual Vector2 GetMissilePosition(int afterTime) else { var t1 = (this.SData.MissileAccel > 0 - ? this.SData.MissileMaxSpeed - : this.SData.MissileMinSpeed - this.SData.MissileSpeed) * 1000f / this.SData.MissileAccel; + ? this.SData.MissileMaxSpeed + : this.SData.MissileMinSpeed - this.SData.MissileSpeed) * 1000f / this.SData.MissileAccel; if (t <= t1) { x = (int) - (t * this.SData.MissileSpeed / 1000d + 0.5d * this.SData.MissileAccel * Math.Pow(t / 1000d, 2)); + (t * this.SData.MissileSpeed / 1000d + 0.5d * this.SData.MissileAccel * Math.Pow(t / 1000d, 2)); } else { x = (int) - (t1 * this.SData.MissileSpeed / 1000d + - 0.5d * this.SData.MissileAccel * Math.Pow(t1 / 1000d, 2) + - (t - t1) / 1000d * - (this.SData.MissileAccel < 0 ? this.SData.MissileMaxSpeed : this.SData.MissileMinSpeed)); + (t1 * this.SData.MissileSpeed / 1000d + 0.5d * this.SData.MissileAccel * Math.Pow(t1 / 1000d, 2) + + (t - t1) / 1000d + * (this.SData.MissileAccel < 0 ? this.SData.MissileMaxSpeed : this.SData.MissileMinSpeed)); } } @@ -82,6 +74,12 @@ public virtual Vector2 GetMissilePosition(int afterTime) return this.StartPosition + this.Direction * t; } + public override string ToString() + { + return "SkillshotMissile: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileArc.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileArc.cs index ef9af00..11a7432 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileArc.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileArc.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotMissileArc : SkillshotMissile { @@ -25,12 +19,7 @@ public SkillshotMissileArc(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotMissileArc: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal ArcPoly Arc { get; set; } @@ -38,6 +27,21 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotMissileArc: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + + internal override void UpdatePath() + { + this.Path = this.Arc.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Arc == null) @@ -47,11 +51,6 @@ internal override void UpdatePolygon() } } - internal override void UpdatePath() - { - this.Path = this.Arc.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileCircle.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileCircle.cs index bf66030..0e6a46d 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileCircle.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileCircle.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotMissileCircle : SkillshotMissile { @@ -25,12 +19,7 @@ public SkillshotMissileCircle(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotMissileCircle: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal CirclePoly Circle { get; set; } @@ -38,6 +27,21 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotMissileCircle: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + + internal override void UpdatePath() + { + this.Path = this.Circle.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Circle == null) @@ -47,11 +51,6 @@ internal override void UpdatePolygon() } } - internal override void UpdatePath() - { - this.Path = this.Circle.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileLine.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileLine.cs index 7a067a1..b3dddb7 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotMissileLine.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotMissileLine.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotMissileLine : SkillshotMissile { @@ -25,12 +19,7 @@ public SkillshotMissileLine(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotMissileLine: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal RectanglePoly Rectangle { get; set; } @@ -38,6 +27,16 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotMissileLine: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + internal override void Game_OnUpdate() { if (this.SData.MissileFollowsCaster && this.Caster.IsVisible) @@ -49,6 +48,11 @@ internal override void Game_OnUpdate() this.UpdatePolygon(); } + internal override void UpdatePath() + { + this.Path = this.Rectangle.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Rectangle == null) @@ -63,11 +67,6 @@ internal override void UpdatePolygon() this.UpdatePath(); } - internal override void UpdatePath() - { - this.Path = this.Rectangle.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/SkillshotRing.cs b/Core/Wrappers/Spells/SpellTypes/SkillshotRing.cs index 2e6cd8b..e61516e 100644 --- a/Core/Wrappers/Spells/SpellTypes/SkillshotRing.cs +++ b/Core/Wrappers/Spells/SpellTypes/SkillshotRing.cs @@ -1,13 +1,7 @@ namespace LeagueSharp.SDK { - using System; - using System.Collections.Generic; - using System.ComponentModel; - - using LeagueSharp.SDK.Clipper; - using LeagueSharp.SDK.Core.Utils; - - using SharpDX; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.Polygons; public class SkillshotRing : SkillshotMissile { @@ -25,12 +19,7 @@ public SkillshotRing(SpellDatabaseEntry entry) #endregion - public override string ToString() - { - return "SkillshotRing: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + " SpellName=" + this.SData.SpellName; - } - - #region Public Properties + #region Properties internal RingPoly Ring { get; set; } @@ -38,6 +27,21 @@ public override string ToString() #region Public Methods and Operators + public override string ToString() + { + return "SkillshotRing: Champion=" + this.SData.ChampionName + " SpellType=" + this.SData.SpellType + + " SpellName=" + this.SData.SpellName; + } + + #endregion + + #region Methods + + internal override void UpdatePath() + { + this.Path = this.Ring.ToClipperPath(); + } + internal override void UpdatePolygon() { if (this.Ring == null) @@ -47,11 +51,6 @@ internal override void UpdatePolygon() } } - internal override void UpdatePath() - { - this.Path = this.Ring.ToClipperPath(); - } - #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/Targeted.cs b/Core/Wrappers/Spells/SpellTypes/Targeted.cs index 83434ef..61d7771 100644 --- a/Core/Wrappers/Spells/SpellTypes/Targeted.cs +++ b/Core/Wrappers/Spells/SpellTypes/Targeted.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes +namespace LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes { class Targeted { } -} +} \ No newline at end of file diff --git a/Core/Wrappers/Spells/SpellTypes/TargetedMissile.cs b/Core/Wrappers/Spells/SpellTypes/TargetedMissile.cs index 01fdb94..b71d7a5 100644 --- a/Core/Wrappers/Spells/SpellTypes/TargetedMissile.cs +++ b/Core/Wrappers/Spells/SpellTypes/TargetedMissile.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes +namespace LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes { class TargetedMissile { } -} +} \ No newline at end of file diff --git a/Core/Wrappers/Spells/Tracker/Detector.cs b/Core/Wrappers/Spells/Tracker/Detector.cs index 9b2463b..7e16f1e 100644 --- a/Core/Wrappers/Spells/Tracker/Detector.cs +++ b/Core/Wrappers/Spells/Tracker/Detector.cs @@ -1,13 +1,12 @@ namespace LeagueSharp.SDK { using System; - using System.Collections.Generic; - using System.Runtime.CompilerServices; - using System.Runtime.Remoting.Messaging; using System.Security.Permissions; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Core.Wrappers.Spells.SpellTypes; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.Data.Enumerations; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -18,8 +17,8 @@ public class Detector static Detector() { Obj_AI_Base.OnProcessSpellCast += Obj_AI_Base_OnProcessSpellCast; - MissileClient.OnCreate +=MissileClient_OnCreate; - GameObject.OnCreate +=GameObject_OnCreate; + GameObject.OnCreate += MissileClient_OnCreate; + GameObject.OnCreate += GameObject_OnCreate; } #endregion @@ -30,29 +29,17 @@ static Detector() #endregion - #region Public Events + #region Events internal static event OnDetectSkillshotH OnDetectSkillshot; #endregion #region Methods - - private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) - { - var spellDatabaseEntry = SpellDatabase.GetByName(args.SData.Name); - - if (spellDatabaseEntry == null) - { - return; - } - - TriggerOnDetectSkillshot(spellDatabaseEntry, sender, SkillshotDetectionType.ProcessSpell, args.Start.ToVector2(), args.End.ToVector2(), Variables.TickCount - Game.Ping / 2); - } static void GameObject_OnCreate(GameObject sender, EventArgs args) { - var spellDatabaseEntry = SpellDatabase.GetBySourceObjectName(sender.Name); + var spellDatabaseEntry = SpellDatabase.GetBySourceObjectName(sender.Name); if (spellDatabaseEntry == null) { @@ -61,7 +48,9 @@ static void GameObject_OnCreate(GameObject sender, EventArgs args) TriggerOnDetectSkillshot( spellDatabaseEntry, - GameObjects.Heroes.MinOrDefault(h => h.IsAlly || h.ChampionName != spellDatabaseEntry.ChampionName ? 1 : 0), //Since we can't really know the owner of the object we just assume is enemy :kappa: + GameObjects.Heroes.MinOrDefault( + h => h.IsAlly || h.ChampionName != spellDatabaseEntry.ChampionName ? 1 : 0), + //Since we can't really know the owner of the object we just assume is enemy :kappa: SkillshotDetectionType.CreateObject, sender.Position.ToVector2(), sender.Position.ToVector2(), @@ -82,12 +71,9 @@ static void MissileClient_OnCreate(GameObject sender, EventArgs args) { return; } - + //Looks useless, but it's not :nerd: - DelayAction.Add(0, delegate - { - MissileClient_OnCreate_Delayed(missile, spellDatabaseEntry); - }); + DelayAction.Add(0, delegate { MissileClient_OnCreate_Delayed(missile, spellDatabaseEntry); }); } static void MissileClient_OnCreate_Delayed(MissileClient missile, SpellDatabaseEntry spellDatabaseEntry) @@ -97,14 +83,48 @@ static void MissileClient_OnCreate_Delayed(MissileClient missile, SpellDatabaseE return; } - var castTime = Variables.TickCount - Game.Ping / 2 - (spellDatabaseEntry.MissileDelayed ? 0 : spellDatabaseEntry.Delay) - - (int)(1000f * missile.Position.Distance(missile.StartPosition) / spellDatabaseEntry.MissileSpeed); + var castTime = Variables.TickCount - Game.Ping / 2 + - (spellDatabaseEntry.MissileDelayed ? 0 : spellDatabaseEntry.Delay) + - (int) + (1000f * missile.Position.Distance(missile.StartPosition) / spellDatabaseEntry.MissileSpeed); + + TriggerOnDetectSkillshot( + spellDatabaseEntry, + missile.SpellCaster, + SkillshotDetectionType.MissileCreate, + missile.StartPosition.ToVector2(), + missile.EndPosition.ToVector2(), + castTime, + missile); + } + + private static void Obj_AI_Base_OnProcessSpellCast(Obj_AI_Base sender, GameObjectProcessSpellCastEventArgs args) + { + var spellDatabaseEntry = SpellDatabase.GetByName(args.SData.Name); - TriggerOnDetectSkillshot(spellDatabaseEntry, missile.SpellCaster, SkillshotDetectionType.MissileCreate, missile.StartPosition.ToVector2(), missile.EndPosition.ToVector2(), castTime, missile); + if (spellDatabaseEntry == null) + { + return; + } + + TriggerOnDetectSkillshot( + spellDatabaseEntry, + sender, + SkillshotDetectionType.ProcessSpell, + args.Start.ToVector2(), + args.End.ToVector2(), + Variables.TickCount - Game.Ping / 2); } - + [PermissionSet(SecurityAction.Assert, Unrestricted = true)] - private static void TriggerOnDetectSkillshot(SpellDatabaseEntry spellDatabaseEntry, Obj_AI_Base caster, SkillshotDetectionType detectionType, Vector2 start, Vector2 end, int time, MissileClient missile = null) + private static void TriggerOnDetectSkillshot( + SpellDatabaseEntry spellDatabaseEntry, + Obj_AI_Base caster, + SkillshotDetectionType detectionType, + Vector2 start, + Vector2 end, + int time, + MissileClient missile = null) { Skillshot skillshot = null; @@ -132,15 +152,15 @@ private static void TriggerOnDetectSkillshot(SpellDatabaseEntry spellDatabaseEnt skillshot = new SkillshotRing(spellDatabaseEntry); break; } - + if (skillshot == null) { return; } var type = - Type.GetType( - $"LeagueSharp.SDK.Core.Wrappers.Spells.Detector.Skillshots_{skillshot.SData.ChampionName}{skillshot.SData.Slot}"); + Type.GetType( + $"LeagueSharp.SDK.Core.Wrappers.Spells.Detector.Skillshots_{skillshot.SData.ChampionName}{skillshot.SData.Slot}"); if (type != null) { skillshot = (Skillshot)Activator.CreateInstance(type); @@ -158,11 +178,13 @@ private static void TriggerOnDetectSkillshot(SpellDatabaseEntry spellDatabaseEnt { ((SkillshotMissile)skillshot).Missile = missile; } - catch (Exception ex) + catch (Exception) { - Logging.Write()(LogLevel.Warn, "Wrong SpellType for Skillshot {0}, a Missile Type was expected", skillshot.SData.SpellName); + Logging.Write()( + LogLevel.Warn, + "Wrong SpellType for Skillshot {0}, a Missile Type was expected", + skillshot.SData.SpellName); } - } if (!skillshot.Process()) @@ -174,7 +196,8 @@ private static void TriggerOnDetectSkillshot(SpellDatabaseEntry spellDatabaseEnt } /// - /// Gets called when a skillshot is detected, take into account that it can trigger twice for the same skillshot, one when OnProcessSpellCast is called and another when OnMissileCreate is called. + /// Gets called when a skillshot is detected, take into account that it can trigger twice for the same skillshot, one + /// when OnProcessSpellCast is called and another when OnMissileCreate is called. /// /// The detected skillshot private static void TriggerOnDetectSkillshot(Skillshot skillshot) diff --git a/Core/Wrappers/Spells/Tracker/Tracker.cs b/Core/Wrappers/Spells/Tracker/Tracker.cs index ac7a62c..044078e 100644 --- a/Core/Wrappers/Spells/Tracker/Tracker.cs +++ b/Core/Wrappers/Spells/Tracker/Tracker.cs @@ -2,73 +2,39 @@ { using System; using System.Collections.Generic; - using System.Runtime.CompilerServices; - using System.Runtime.Remoting.Messaging; - using System.Security.Permissions; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.Utils; public class Tracker { + #region Static Fields + + public static readonly List DetectedSkillshots = new List(); + + #endregion + #region Constructors and Destructors static Tracker() { Game.OnUpdate += Game_OnUpdate; Detector.OnDetectSkillshot += Detector_OnDetectSkillshot; - MissileClient.OnDelete += MissileClient_OnDelete; + GameObject.OnDelete += MissileClient_OnDelete; } #endregion - #region Public Events + #region Events internal static event Detector.OnDetectSkillshotH OnDetectSkillshot; #endregion - #region Static Fields - - public static readonly List DetectedSkillshots = new List(); - - #endregion - #region Methods - - private static void MissileClient_OnDelete(GameObject sender, EventArgs args) - { - if (!(sender is MissileClient)) - { - return; - } - - //Remove the detected skillshots that have collided. - for (int i = DetectedSkillshots.Count - 1; i >= 0; i--) - { - var skillshot = DetectedSkillshots[i] as SkillshotMissile; - - if (skillshot?.Missile != null && skillshot.SData.CanBeRemoved && skillshot.Missile.NetworkId == sender.NetworkId) - { - skillshot.MissileDestroyed = true; - DetectedSkillshots.RemoveAt(i); - } - } - } - - static void Game_OnUpdate(EventArgs args) - { - //Remove the detected skillshots that have expired. - DetectedSkillshots.RemoveAll(skillshot => skillshot.HasExpired()); - - //Trigger Game_OnUpdate on each skillshot to update the polygon and other calculations :nerd: - foreach (var skillshot in DetectedSkillshots) - { - skillshot.Game_OnUpdate(); - } - } /// - /// Gets called when a new skillshot gets detected. It only gets called once per skillshot. + /// Gets called when a new skillshot gets detected. It only gets called once per skillshot. /// /// static void Detector_OnDetectSkillshot(Skillshot skillshot) @@ -76,16 +42,17 @@ static void Detector_OnDetectSkillshot(Skillshot skillshot) var isAlreadyDetected = false; foreach (var detectedSkillshot in DetectedSkillshots) { - if (detectedSkillshot.SData.SpellName != skillshot.SData.SpellName || detectedSkillshot.Caster.NetworkId != skillshot.Caster.NetworkId) + if (detectedSkillshot.SData.SpellName != skillshot.SData.SpellName + || detectedSkillshot.Caster.NetworkId != skillshot.Caster.NetworkId) { continue; } - + //TODO: additional distance check(s) might be required. if (skillshot.Direction.AngleBetween(detectedSkillshot.Direction) < 5) { isAlreadyDetected = true; - + //Add the missile information to the detected skillshot. if (skillshot.DetectionType == SkillshotDetectionType.MissileCreate) { @@ -93,9 +60,12 @@ static void Detector_OnDetectSkillshot(Skillshot skillshot) { ((SkillshotMissile)detectedSkillshot).Missile = ((SkillshotMissile)skillshot).Missile; } - catch (Exception ex) + catch (Exception) { - Logging.Write()(LogLevel.Warn, "Wrong SpellType for Skillshot {0}, a Missile Type was expected", skillshot.SData.SpellName); + Logging.Write()( + LogLevel.Warn, + "Wrong SpellType for Skillshot {0}, a Missile Type was expected", + skillshot.SData.SpellName); } } } @@ -111,6 +81,39 @@ static void Detector_OnDetectSkillshot(Skillshot skillshot) OnDetectSkillshot?.Invoke(skillshot); } + static void Game_OnUpdate(EventArgs args) + { + //Remove the detected skillshots that have expired. + DetectedSkillshots.RemoveAll(skillshot => skillshot.HasExpired()); + + //Trigger Game_OnUpdate on each skillshot to update the polygon and other calculations :nerd: + foreach (var skillshot in DetectedSkillshots) + { + skillshot.Game_OnUpdate(); + } + } + + private static void MissileClient_OnDelete(GameObject sender, EventArgs args) + { + if (!(sender is MissileClient)) + { + return; + } + + //Remove the detected skillshots that have collided. + for (var i = DetectedSkillshots.Count - 1; i >= 0; i--) + { + var skillshot = DetectedSkillshots[i] as SkillshotMissile; + + if (skillshot?.Missile != null && skillshot.SData.CanBeRemoved + && skillshot.Missile.NetworkId == sender.NetworkId) + { + skillshot.MissileDestroyed = true; + DetectedSkillshots.RemoveAt(i); + } + } + } + #endregion } } \ No newline at end of file diff --git a/Core/Wrappers/TargetSelector/ITargetSelectorMode.cs b/Core/Wrappers/TargetSelector/ITargetSelectorMode.cs index fce83f5..3524d5f 100644 --- a/Core/Wrappers/TargetSelector/ITargetSelectorMode.cs +++ b/Core/Wrappers/TargetSelector/ITargetSelectorMode.cs @@ -19,7 +19,7 @@ namespace LeagueSharp.SDK { using System.Collections.Generic; - using LeagueSharp.SDK.Core.UI.IMenu; + using LeagueSharp.SDK.UI; /// /// Interface for modes. diff --git a/Core/Wrappers/TargetSelector/Modes/Closest.cs b/Core/Wrappers/TargetSelector/Modes/Closest.cs index a24bfc5..21ddfff 100644 --- a/Core/Wrappers/TargetSelector/Modes/Closest.cs +++ b/Core/Wrappers/TargetSelector/Modes/Closest.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - - using LeagueSharp.SDK.Core.UI.IMenu; + + using LeagueSharp.SDK.UI; /// /// The closest Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/IWeightItem.cs b/Core/Wrappers/TargetSelector/Modes/IWeightItem.cs index b68b88c..9172826 100644 --- a/Core/Wrappers/TargetSelector/Modes/IWeightItem.cs +++ b/Core/Wrappers/TargetSelector/Modes/IWeightItem.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { /// /// Interface for weight item diff --git a/Core/Wrappers/TargetSelector/Modes/LeastHealth.cs b/Core/Wrappers/TargetSelector/Modes/LeastHealth.cs index 631174e..c3bd6a3 100644 --- a/Core/Wrappers/TargetSelector/Modes/LeastHealth.cs +++ b/Core/Wrappers/TargetSelector/Modes/LeastHealth.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; + using LeagueSharp.SDK.UI; /// /// The least health Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/LessAttacksToKill.cs b/Core/Wrappers/TargetSelector/Modes/LessAttacksToKill.cs index 523ae53..752cedc 100644 --- a/Core/Wrappers/TargetSelector/Modes/LessAttacksToKill.cs +++ b/Core/Wrappers/TargetSelector/Modes/LessAttacksToKill.cs @@ -15,13 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.Wrappers.Damages; + using LeagueSharp.SDK.UI; /// /// The less attacks to kill Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/LessCastsToKill.cs b/Core/Wrappers/TargetSelector/Modes/LessCastsToKill.cs index 527dc12..a681c8e 100644 --- a/Core/Wrappers/TargetSelector/Modes/LessCastsToKill.cs +++ b/Core/Wrappers/TargetSelector/Modes/LessCastsToKill.cs @@ -15,16 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { - #region - using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - - #endregion + using LeagueSharp.SDK.UI; /// /// The less casts to kill Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/MostAbilityPower.cs b/Core/Wrappers/TargetSelector/Modes/MostAbilityPower.cs index 1d9aabb..8678d7f 100644 --- a/Core/Wrappers/TargetSelector/Modes/MostAbilityPower.cs +++ b/Core/Wrappers/TargetSelector/Modes/MostAbilityPower.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; + using LeagueSharp.SDK.UI; /// /// The most ability power Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/MostAttackDamage.cs b/Core/Wrappers/TargetSelector/Modes/MostAttackDamage.cs index 0383ab9..8cd9a4a 100644 --- a/Core/Wrappers/TargetSelector/Modes/MostAttackDamage.cs +++ b/Core/Wrappers/TargetSelector/Modes/MostAttackDamage.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; + using LeagueSharp.SDK.UI; /// /// The most attack damage Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/NearMouse.cs b/Core/Wrappers/TargetSelector/Modes/NearMouse.cs index e255215..aed07b2 100644 --- a/Core/Wrappers/TargetSelector/Modes/NearMouse.cs +++ b/Core/Wrappers/TargetSelector/Modes/NearMouse.cs @@ -15,12 +15,12 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System.Collections.Generic; using System.Linq; - - using LeagueSharp.SDK.Core.UI.IMenu; + + using LeagueSharp.SDK.UI; /// /// The near mouse Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/Priority.cs b/Core/Wrappers/TargetSelector/Modes/Priority.cs index 933e57b..5a00bf3 100644 --- a/Core/Wrappers/TargetSelector/Modes/Priority.cs +++ b/Core/Wrappers/TargetSelector/Modes/Priority.cs @@ -15,20 +15,19 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System; using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.Data; + using LeagueSharp.Data.DataTypes; + using LeagueSharp.SDK.UI; /// /// The priority Mode. /// - [ResourceImport] public class Priority : ITargetSelectorMode { #region Constants @@ -50,10 +49,8 @@ public class Priority : ITargetSelectorMode /// /// The priority categories /// - public static IReadOnlyList PriorityCategories => PriorityCategoriesList; - - [ResourceImport("Data.Priority.json")] - private static List PriorityCategoriesList = new List(); + public static readonly IReadOnlyList PriorityCategories = + Data.Get().PriorityCategories; #endregion diff --git a/Core/Wrappers/TargetSelector/Modes/PriorityCategory.cs b/Core/Wrappers/TargetSelector/Modes/PriorityCategory.cs deleted file mode 100644 index 4433814..0000000 --- a/Core/Wrappers/TargetSelector/Modes/PriorityCategory.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) 2015 LeagueSharp. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// - -namespace LeagueSharp.SDK.Modes -{ - using System.Collections.Generic; - - /// - /// Category class for Priorities - /// - public class PriorityCategory - { - #region Public Properties - - /// - /// Gets or sets the champions. - /// - /// - /// The champions. - /// - public HashSet Champions { get; set; } - - /// - /// Gets or sets the value. - /// - /// - /// The value. - /// - public int Value { get; set; } - - #endregion - } -} \ No newline at end of file diff --git a/Core/Wrappers/TargetSelector/Modes/Weight.cs b/Core/Wrappers/TargetSelector/Modes/Weight.cs index 145c0cd..8a4a446 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weight.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weight.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System; using System.Collections.Generic; @@ -24,10 +24,10 @@ namespace LeagueSharp.SDK.Modes using System.Reflection; using System.Windows.Forms; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; - using Menu = LeagueSharp.SDK.Core.UI.IMenu.Menu; + using Menu = LeagueSharp.SDK.UI.Menu; /// /// The weight Mode. diff --git a/Core/Wrappers/TargetSelector/Modes/WeightItemWrapper.cs b/Core/Wrappers/TargetSelector/Modes/WeightItemWrapper.cs index 6e5a0db..f519b1c 100644 --- a/Core/Wrappers/TargetSelector/Modes/WeightItemWrapper.cs +++ b/Core/Wrappers/TargetSelector/Modes/WeightItemWrapper.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes +namespace LeagueSharp.SDK.TSModes { using System; diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/AbilityPower.cs b/Core/Wrappers/TargetSelector/Modes/Weights/AbilityPower.cs index deeb36b..5fb637e 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/AbilityPower.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/AbilityPower.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { using System.Linq; diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/Aggro.cs b/Core/Wrappers/TargetSelector/Modes/Weights/Aggro.cs index f33740b..708a765 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/Aggro.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/Aggro.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { using System.Collections.Generic; using System.Collections.ObjectModel; @@ -58,7 +58,8 @@ static Aggro() /// /// Gets the sender items. /// - /// The sender. + /// + /// The sender. /// /// /// The of . @@ -71,9 +72,11 @@ public static IEnumerable GetSenderItems(Obj_AI_Base sender) /// /// Gets the sender target item. /// - /// The sender. + /// + /// The sender. /// - /// The target. + /// + /// The target. /// /// /// The . @@ -86,7 +89,8 @@ public static AggroEntry GetSenderTargetItem(Obj_AI_Base sender, Obj_AI_Base tar /// /// Gets the target items. /// - /// The target. + /// + /// The target. /// /// /// The of . @@ -118,6 +122,7 @@ private static void OnObjAiBaseAggro(Obj_AI_Base sender, GameObjectAggroEventArg var hero = sender as Obj_AI_Hero; var target = GameObjects.EnemyHeroes.FirstOrDefault(h => h.NetworkId == args.NetworkId); + if (hero != null && target != null) { AggroEntry aggro; diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/AttackDamage.cs b/Core/Wrappers/TargetSelector/Modes/Weights/AttackDamage.cs index a97b0b7..a21b29c 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/AttackDamage.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/AttackDamage.cs @@ -15,15 +15,11 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { - #region - using System.Collections.Generic; using System.Linq; - #endregion - /// /// Attack Damage /// diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/CrowdControl.cs b/Core/Wrappers/TargetSelector/Modes/Weights/CrowdControl.cs index 3fee9ac..77541ac 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/CrowdControl.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/CrowdControl.cs @@ -15,15 +15,11 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { - #region - using System.Collections.Generic; using System.Linq; - #endregion - /// /// Crowd Control /// diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/FocusMe.cs b/Core/Wrappers/TargetSelector/Modes/Weights/FocusMe.cs index e1752fa..237b048 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/FocusMe.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/FocusMe.cs @@ -15,14 +15,10 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { - #region - using System; - #endregion - /// /// Focus Me /// diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/Gold.cs b/Core/Wrappers/TargetSelector/Modes/Weights/Gold.cs index 9fd450e..d505b10 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/Gold.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/Gold.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { /// /// Acquired Gold diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/Killable.cs b/Core/Wrappers/TargetSelector/Modes/Weights/Killable.cs index 07b1483..9ead9c8 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/Killable.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/Killable.cs @@ -15,10 +15,8 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { - using LeagueSharp.SDK.Core.Wrappers.Damages; - /// /// AA Killable /// diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/LowHealth.cs b/Core/Wrappers/TargetSelector/Modes/Weights/LowHealth.cs index 1f9ab90..7f35355 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/LowHealth.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/LowHealth.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { /// /// Low Health diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/LowResists.cs b/Core/Wrappers/TargetSelector/Modes/Weights/LowResists.cs index 464fae5..aa86f26 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/LowResists.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/LowResists.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { /// /// Low Resists diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistanceCursor.cs b/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistanceCursor.cs index 84397b0..f93cac8 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistanceCursor.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistanceCursor.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { /// /// Short Distance to Cursor diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistancePlayer.cs b/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistancePlayer.cs index 0c451f9..079a3f6 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistancePlayer.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/ShortDistancePlayer.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { /// /// Short Distance to Player diff --git a/Core/Wrappers/TargetSelector/Modes/Weights/TeamFocus.cs b/Core/Wrappers/TargetSelector/Modes/Weights/TeamFocus.cs index 958a37f..2c4b506 100644 --- a/Core/Wrappers/TargetSelector/Modes/Weights/TeamFocus.cs +++ b/Core/Wrappers/TargetSelector/Modes/Weights/TeamFocus.cs @@ -15,7 +15,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/ // -namespace LeagueSharp.SDK.Modes.Weights +namespace LeagueSharp.SDK.TSModes.Weights { using System; using System.Linq; diff --git a/Core/Wrappers/TargetSelector/TargetSelector.cs b/Core/Wrappers/TargetSelector/TargetSelector.cs index 3486b1a..e9e561e 100644 --- a/Core/Wrappers/TargetSelector/TargetSelector.cs +++ b/Core/Wrappers/TargetSelector/TargetSelector.cs @@ -20,9 +20,10 @@ namespace LeagueSharp.SDK using System; using System.Collections.Generic; using System.Linq; - - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.Utils; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; using SharpDX; @@ -31,6 +32,15 @@ namespace LeagueSharp.SDK /// public sealed class TargetSelector { + #region Static Fields + + /// + /// Initialized flag. + /// + private static bool initialized; + + #endregion + #region Fields /// @@ -50,6 +60,13 @@ public sealed class TargetSelector /// public TargetSelector(Menu menu) { + if (initialized) + { + return; + } + + initialized = true; + Events.OnLoad += (sender, args) => { menu.Add(this.menu); @@ -58,6 +75,7 @@ public TargetSelector(Menu menu) this.Humanizer = new TargetSelectorHumanizer(this.menu); this.Mode = new TargetSelectorMode(this.menu); this.Drawing = new TargetSelectorDrawing(this.menu, this.Selected, this.Mode); + this.Locked = new TargetSelectorLockTarget(this.menu); // Keep submenus at top this.menu.Components = @@ -76,6 +94,11 @@ public TargetSelector(Menu menu) /// public TargetSelectorHumanizer Humanizer { get; private set; } + /// + /// Gets the locked instance. + /// + public TargetSelectorLockTarget Locked { get; private set; } + /// /// Gets the mode instance. /// @@ -107,7 +130,7 @@ public TargetSelector(Menu menu) /// public Obj_AI_Hero GetSelectedTarget() { - return this.Selected.Target; + return this.Locked.LockedTarget ?? this.Selected.Target; } /// @@ -225,6 +248,11 @@ public List GetTargets( Vector3 from = default(Vector3), IEnumerable ignoreChampions = null) { + if (this.Locked.Enabled && this.Locked.LockedTarget != null) + { + return new List { this.Locked.LockedTarget }; + } + if (this.Selected.Focus && this.Selected.Force) { if (IsValidTarget(this.Selected.Target, float.MaxValue, damageType, ignoreShields, from)) diff --git a/Core/Wrappers/TargetSelector/TargetSelectorDrawing.cs b/Core/Wrappers/TargetSelector/TargetSelectorDrawing.cs index 536f896..cbe7069 100644 --- a/Core/Wrappers/TargetSelector/TargetSelectorDrawing.cs +++ b/Core/Wrappers/TargetSelector/TargetSelectorDrawing.cs @@ -21,10 +21,9 @@ namespace LeagueSharp.SDK using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; - using LeagueSharp.SDK.Modes; + using LeagueSharp.SDK.TSModes; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; using SharpDX; diff --git a/Core/Wrappers/TargetSelector/TargetSelectorHumanizer.cs b/Core/Wrappers/TargetSelector/TargetSelectorHumanizer.cs index 8fea46f..b89d825 100644 --- a/Core/Wrappers/TargetSelector/TargetSelectorHumanizer.cs +++ b/Core/Wrappers/TargetSelector/TargetSelectorHumanizer.cs @@ -17,16 +17,11 @@ namespace LeagueSharp.SDK { - #region - using System; using System.Collections.Generic; using System.Linq; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - - #endregion + using LeagueSharp.SDK.UI; /// /// Humanize the target selector process diff --git a/Core/Wrappers/TargetSelector/TargetSelectorLockTarget.cs b/Core/Wrappers/TargetSelector/TargetSelectorLockTarget.cs new file mode 100644 index 0000000..411ff1a --- /dev/null +++ b/Core/Wrappers/TargetSelector/TargetSelectorLockTarget.cs @@ -0,0 +1,417 @@ +// +// Copyright (c) 2015 LeagueSharp. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// + +namespace LeagueSharp.SDK +{ + using System; + using System.Drawing; + using System.Linq; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; + + using static Drawing; + + /// + /// The lock target option. + /// + public class TargetSelectorLockTarget + { + #region Constants + + /// + /// Use this to clear any timer in this class + /// + private const double ClearTime = 0F; + + /// + /// The max range allowed to lock targets + /// + private const double MaxRange = 2500F; + + #endregion + + #region Fields + + /// + /// Internal field that represents the targeted champion + /// + private Obj_AI_Hero lockedTarget; + + /// + /// Internal field to control when the must be released + /// + private double lockedTil; + + /// + /// Internal field that represents the menu: + /// Target Selector >> Lock target >> Enabled + /// + private MenuBool menuItemEnabled; + + /// + /// Internal field that represents the menu: + /// Target Selector >> Lock target >> Show notification + /// + private MenuBool menuItemNotifications; + + /// + /// Internal field that represents the menu: + /// Target Selector >> Lock target >> Show countdown + /// + private MenuBool menuItemShowCountdown; + + /// + /// Internal field that represents the menu: + /// Target Selector >> Lock target >> Lock target on MIA (ms) + /// + private MenuSlider menuItemTime; + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + /// + /// The root menu. + /// + public TargetSelectorLockTarget(Menu menu) + { + this.LoadMenu(menu); + + this.LockedTarget = null; + + Game.OnWndProc += this.Game_OnWndProc_SetTarget; + OnDraw += this.Drawing_OnDraw_Countdown; + OnDraw += this.Drawing_OnDraw_Target; + Game.OnUpdate += this.Game_OnUpdate_DeadTarget; + } + + #endregion + + #region Public Properties + + /// + /// Gets the value setted on menu: + /// Target Selector >> Lock target >> Enabled + /// + public bool Enabled => this.menuItemEnabled.Value; + + /// + /// Gets or sets the targeted champion. + /// + public Obj_AI_Hero LockedTarget + { + get + { + return this.lockedTarget; + } + + private set + { + this.lockedTil = ClearTime; + this.lockedTarget = value; + + if (value != null) + { + Game.OnUpdate += this.Game_OnUpdate_Trigger; + } + else + { + Game.OnUpdate -= this.Game_OnUpdate_Trigger; + Game.OnUpdate -= this.Game_OnUpdate_CheckTargeted; + } + } + } + + /// + /// Gets the value setted on menu: + /// Target Selector >> Lock target >> Show countdown + /// + public bool ShowCountdown => this.menuItemShowCountdown.Value; + + /// + /// Gets the value setted on menu: + /// Target Selector >> Lock target >> Show notification + /// + public bool ShowNotification => this.menuItemNotifications.Value; + + /// + /// Gets the value setted on menu: + /// Target Selector >> Lock target >> Lock target on MIA (ms) + /// + public int Time => this.menuItemTime.Value; + + #endregion + + #region Public Methods and Operators + + /// + /// Lock an especific champion. + /// + /// + /// The targeted champion. + /// + public void LockTarget(Obj_AI_Hero target) + { + this.LockTarget(target, true); + } + + #endregion + + #region Methods + + /// + /// Draws the countdown animation + /// + /// + private void Drawing_OnDraw_Countdown(EventArgs args) + { + if (!this.ShowCountdown || this.LockedTarget == null || this.LockedTarget.IsDead + || this.lockedTil.Equals(ClearTime)) + { + return; + } + + var textPosition = ObjectManager.Player.HPBarPosition; + textPosition.Y += 160F; + + double time = Convert.ToInt32((this.lockedTil - Game.Time) * 1000); + time = time / this.Time; + time = time * 100F; + time = Convert.ToInt32(time); + time = 100 - time; + + var line1 = "MIA Locked target"; + + var i = Convert.ToInt32(time / 10); + var line2 = ""; + line2 = line2.PadRight(i, 'o'); + line2 = line2.PadRight(10, '_'); + line2 = $"[{line2}] {time}%"; + + var layer1 = "[oooooooooo]"; + var layer3 = "[__________]"; + + DrawText(textPosition.X + 8F, textPosition.Y, Color.White, line1); + DrawText(textPosition.X + 5F, textPosition.Y + 20F, Color.Black, layer1); + DrawText(textPosition.X + 5F, textPosition.Y + 20F, Color.White, line2); + DrawText(textPosition.X + 5F, textPosition.Y + 20F, Color.Red, layer3); + } + + /// + /// Draws the red and white target under the locked champion. + /// + /// + private void Drawing_OnDraw_Target(EventArgs args) + { + if (this.LockedTarget == null || !this.LockedTarget.IsVisible) + { + return; + } + + var position = this.LockedTarget.Position; + position.Y -= 120F; + position.X += 10F; + + Render.Circle.DrawCircle(position, 30, Color.Red, 5); + Render.Circle.DrawCircle(position, 20, Color.White, 5); + Render.Circle.DrawCircle(position, 10, Color.Red, 5); + Render.Circle.DrawCircle(position, 0, Color.White, 5); + } + + /// + /// Checks if the targeted champion is MIA or out of range. + /// + /// + private void Game_OnUpdate_CheckTargeted(EventArgs args) + { + if (this.LockedTarget != null && !this.lockedTil.Equals(ClearTime) && Game.Time > this.lockedTil) + { + var championName = this.LockedTarget.ChampionName; + Game.OnUpdate -= this.Game_OnUpdate_CheckTargeted; + + this.LockTarget(null, false); + + this.Notify( + $"Target released - {championName}", + $"{championName} is MIA or out of range for {this.Time}ms."); + } + } + + /// + /// Remove the red and white target under the dead champion. + /// + /// + private void Game_OnUpdate_DeadTarget(EventArgs args) + { + if (this.LockedTarget != null && this.LockedTarget.IsDead) + { + this.lockedTil = ClearTime; + this.LockTarget(null, false); + } + } + + /// + /// Triggers the lock event. + /// + /// + private void Game_OnUpdate_Trigger(EventArgs args) + { + if (this.LockedTarget == null) + { + return; + } + + if (this.lockedTil.Equals(ClearTime) + && (!this.LockedTarget.IsVisible || GameObjects.Player.Distance(this.lockedTarget) > MaxRange)) + { + this.lockedTil = Game.Time + ((double)this.Time / 1000); + Game.OnUpdate += this.Game_OnUpdate_CheckTargeted; + } + else if (this.LockedTarget.IsVisible && GameObjects.Player.Distance(this.lockedTarget) <= MaxRange) + { + Game.OnUpdate -= this.Game_OnUpdate_CheckTargeted; + this.lockedTil = ClearTime; + } + } + + /// + /// Gets the double clicked champion and Locks him. + /// + /// + private void Game_OnWndProc_SetTarget(WndEventArgs args) + { + if (args.Msg != (ulong)WindowsMessages.LBUTTONDBLCLK) + { + return; + } + + var selection = + GameObjects.EnemyHeroes.Where( + h => h.IsValidTarget() && h.Distance(Game.CursorPos) < h.BoundingRadius + 150F) + .OrderBy(h => h.Distance(Game.CursorPos)) + .FirstOrDefault(); + + if (this.LockedTarget != selection) + { + var notify = true; + + if (selection == null) + { + this.Notify($"Target released - {this.LockedTarget.ChampionName}", "You released the target."); + notify = false; + } + + this.LockTarget(selection, notify); + } + } + + /// + /// Load the Lock target menu. + /// + /// + /// The root menu. + /// + private void LoadMenu(Menu menu) + { + var lockTargetMenu = new Menu("lockTarget", "Lock target"); + + this.menuItemEnabled = new MenuBool("lockTargetEnabled", "Enabled", true); + lockTargetMenu.Add(this.menuItemEnabled); + + this.menuItemTime = new MenuSlider("lockTargetTime", "Lock target on MIA (ms)", 1500, 500, 5000); + lockTargetMenu.Add(this.menuItemTime); + + this.menuItemShowCountdown = new MenuBool("lockTargetCountdown", "Show countdown", true); + lockTargetMenu.Add(this.menuItemShowCountdown); + + this.menuItemNotifications = new MenuBool("lockTargetNotification", "Show notification", true); + lockTargetMenu.Add(this.menuItemNotifications); + + menu.Add(lockTargetMenu); + } + + /// + /// Private method to lock targets and notify. + /// + /// + /// The targeted champion. + /// + /// + /// Indicates if the event must be notified. + /// + private void LockTarget(Obj_AI_Hero target, bool notify) + { + if (!this.Enabled) + { + return; + } + + this.LockedTarget = target; + + if (!notify) + { + return; + } + + if (target != null) + { + this.Notify( + $"Target locked - {this.LockedTarget.ChampionName}", + $"Your damage will be concentrated on {this.LockedTarget.ChampionName}."); + } + else + { + this.Notify("Target released", "You released the target."); + } + } + + /// + /// Notify an event. + /// + /// + /// The header text. + /// + /// + /// The body text. + /// + private void Notify(string header, string body) + { + if (!this.ShowNotification) + { + return; + } + + var targetReleasedNotification = new Notification( + header, + body + "\n\nTo disable this feature goto: Menu Leaguesharp > \nTarget Selector > Lock target > Enabled") + { + HeaderTextColor = SharpDX.Color.White, + BodyTextColor = SharpDX.Color.BlanchedAlmond, + Icon = NotificationIconType.None, IconFlash = false, + }; + Notifications.Add(targetReleasedNotification); + DelayAction.Add(6000, () => { Notifications.Remove(targetReleasedNotification); }); + } + + #endregion + } +} \ No newline at end of file diff --git a/Core/Wrappers/TargetSelector/TargetSelectorMode.cs b/Core/Wrappers/TargetSelector/TargetSelectorMode.cs index 595a44c..131a212 100644 --- a/Core/Wrappers/TargetSelector/TargetSelectorMode.cs +++ b/Core/Wrappers/TargetSelector/TargetSelectorMode.cs @@ -22,9 +22,10 @@ namespace LeagueSharp.SDK using System.Collections.ObjectModel; using System.Linq; using System.Reflection; - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; - using LeagueSharp.SDK.Core.Utils; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; + using LeagueSharp.SDK.Utils; /// /// The mode menu for the TargetSelector @@ -66,7 +67,9 @@ public TargetSelectorMode(Menu menu) this.pEntries = this.pEntries.OrderBy(p => p.DisplayName).ToList(); - this.menu.Add(new MenuList("mode", "Mode", this.pEntries.Select(e => e.DisplayName)) { SelectedValue = "Weight" }); + this.menu.Add( + new MenuList("mode", "Mode", this.pEntries.Select(e => e.DisplayName)) + { SelectedValue = "Weight" }); this.menu.MenuValueChanged += (sender, args) => { diff --git a/Core/Wrappers/TargetSelector/TargetSelectorSelected.cs b/Core/Wrappers/TargetSelector/TargetSelectorSelected.cs index dddb8b8..373af70 100644 --- a/Core/Wrappers/TargetSelector/TargetSelectorSelected.cs +++ b/Core/Wrappers/TargetSelector/TargetSelectorSelected.cs @@ -18,9 +18,9 @@ namespace LeagueSharp.SDK { using System.Linq; - - using LeagueSharp.SDK.Core.UI.IMenu; - using LeagueSharp.SDK.Core.UI.IMenu.Values; + + using LeagueSharp.SDK.Enumerations; + using LeagueSharp.SDK.UI; /// /// Manages the selection of targets diff --git a/LeagueSharp.SDK.csproj b/LeagueSharp.SDK.csproj index 532c026..2835ef6 100644 --- a/LeagueSharp.SDK.csproj +++ b/LeagueSharp.SDK.csproj @@ -51,6 +51,12 @@ C:\Program Files (x86)\LeagueSharp\System\LeagueSharp.dll + + C:\Program Files (x86)\LeagueSharp\System\LeagueSharp.Data.dll + + + C:\Program Files (x86)\LeagueSharp\System\LeagueSharp.Sandbox.dll + packages\Newtonsoft.Json.8.0.1-beta4\lib\net45\Newtonsoft.Json.dll True @@ -79,12 +85,8 @@ - - - - @@ -97,8 +99,6 @@ - - @@ -134,6 +134,17 @@ + + + + + + + + + + + @@ -265,6 +276,7 @@ + @@ -276,7 +288,6 @@ - @@ -290,7 +301,6 @@ - @@ -308,8 +318,8 @@ + - @@ -386,13 +396,6 @@ - - - - - - - @@ -415,6 +418,9 @@ Designer + + +