Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SharpDX;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Csavo
- {
- public class CustomSkillPainter : ITransparentCollection // Modified SkillPainter. Credits to KillerJohn (http://www.ownedcore.com/forums/members/863466-killerjohn.html) for the SkillPainter
- {
- public bool Enabled { get; set; }
- public IController Hud { get; set; }
- public IFont CooldownFont { get; set; }
- public IFont SkillCDRFont { get; set; }
- public IFont SkillRCFont { get; set; }
- public float TextureOpacity { get; set; }
- public CustomSkillPainter(IController hud, bool setDefaultStyle)
- {
- Enabled = true;
- Hud = hud;
- if (setDefaultStyle)
- {
- CooldownFont = Hud.Render.CreateFont("arial", 14, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
- SkillCDRFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, false, false, 160, 0, 0, 0, true);
- SkillRCFont = Hud.Render.CreateFont("tahoma", 5, 255, 255, 255, 255, false, false, 160, 0, 0, 0, true);
- }
- }
- public void Paint(IPlayerSkill skill, RectangleF rect)
- {
- if (skill == null) return;
- if (TextureOpacity > 0)
- {
- var texture = Hud.Texture.GetTexture(skill.SnoPower.NormalIconTextureId);
- if (texture != null)
- {
- texture.Draw(rect.X, rect.Y, rect.Width, rect.Height, TextureOpacity);
- }
- }
- if (skill.IsOnCooldown && (skill.CooldownFinishTick > Hud.Game.CurrentGameTick))
- {
- var remaining = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
- var text = remaining > 1.0f ? remaining.ToString("F0", CultureInfo.InvariantCulture) : remaining.ToString("F1", CultureInfo.InvariantCulture);
- var textLayout = CooldownFont.GetTextLayout(text);
- CooldownFont.DrawText(textLayout, rect.X + (rect.Width - (float)Math.Ceiling(textLayout.Metrics.Width)) / 2.0f, rect.Y + (rect.Height - textLayout.Metrics.Height) / 2);
- var SkillCDR = (skill.CooldownFinishTick - skill.CooldownStartTick) / 60.0d;
- var CDRtext = SkillCDR.ToString("F2", CultureInfo.InvariantCulture) + " sec";
- var CDRLayout = SkillCDRFont.GetTextLayout(CDRtext);
- SkillCDRFont.DrawText(CDRLayout, rect.Left + (rect.Width / 2) - (CDRLayout.Metrics.Width / 2), rect.Bottom - CDRLayout.Metrics.Height);
- }
- var resourceCost = skill.ResourceCost;
- if (resourceCost != -1)
- {
- if (Hud.Window.CursorInsideRect(rect.Left, rect.Top, rect.Width, rect.Height))
- {
- if (skill.SnoPower.Sno == 111215 && Hud.Game.Me.Powers.BuffIsActive(111215, 1)) // Vault - Tumble
- {
- var RCtext = BasePlugin.ValueToString(skill.GetResourceRequirement() * 0.5, ValueFormat.NormalNumber) + " " + (resourceCost > 0 ? Hud.Game.Me.HeroClassDefinition.PrimaryResourceName : Hud.Game.Me.HeroClassDefinition.SecondaryResourceName);
- var RCLayout = SkillRCFont.GetTextLayout(RCtext);
- SkillRCFont.DrawText(RCLayout, rect.Right - (rect.Width / 2) - (RCLayout.Metrics.Width / 2) - 1, rect.Top);
- }
- else if (skill.SnoPower.Sno == 129214/* && Hud.Game.Me.Powers.BuffIsActive(446318, 1)*/) // Cluster Arrow + Manticore NOTE: Manticore detection not working, so the RC will include Manticore RCR until I find a fix. Also I don't know how to detect the legendary affix value, so it will display with min and max affixes as well
- {
- var RCtext = BasePlugin.ValueToString(skill.GetResourceRequirement() * 0.6, ValueFormat.NormalNumber) + "-" + BasePlugin.ValueToString(skill.GetResourceRequirement() * 0.5, ValueFormat.NormalNumber) + " " + (resourceCost > 0 ? Hud.Game.Me.HeroClassDefinition.PrimaryResourceName : Hud.Game.Me.HeroClassDefinition.SecondaryResourceName);
- var RCLayout = SkillRCFont.GetTextLayout(RCtext);
- SkillRCFont.DrawText(RCLayout, rect.Right - (rect.Width / 2) - (RCLayout.Metrics.Width / 2) - 1, rect.Top);
- }
- else
- {
- var RCtext = BasePlugin.ValueToString(skill.GetResourceRequirement(), ValueFormat.NormalNumber) + " " + (resourceCost > 0 ? Hud.Game.Me.HeroClassDefinition.PrimaryResourceName : Hud.Game.Me.HeroClassDefinition.SecondaryResourceName);
- var RCLayout = SkillRCFont.GetTextLayout(RCtext);
- SkillRCFont.DrawText(RCLayout, rect.Right - (rect.Width / 2) - (RCLayout.Metrics.Width / 2) - 1, rect.Top);
- }
- }
- }
- }
- public IEnumerable<ITransparent> GetTransparents()
- {
- yield return CooldownFont;
- yield return SkillCDRFont;
- yield return SkillRCFont;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement