Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Turbo.Plugins.ZX
- {
- using System.Collections.Generic;
- using Turbo.Plugins.Default;
- public class BuffSideBarPlugin : BasePlugin, ICustomizer, IInGameTopPainter
- {
- public class IBuffBarsList
- {
- public string Shorthand, Description;
- public uint SNO;
- public int IconIndex;
- public HeroClass OnlyHeroClass;
- public IBuffBarsList(string inpShorthand, string inpDescription, uint inpSNO, int inpIconIndex)
- {
- this.Shorthand = inpShorthand;
- this.Description = inpDescription;
- this.SNO = inpSNO;
- this.IconIndex = inpIconIndex;
- this.OnlyHeroClass = HeroClass.None;
- }
- public IBuffBarsList(string inpShorthand, string inpDescription, uint inpSNO, int inpIconIndex, HeroClass inpHeroclass)
- {
- this.Shorthand = inpShorthand;
- this.Description = inpDescription;
- this.SNO = inpSNO;
- this.IconIndex = inpIconIndex;
- this.OnlyHeroClass = inpHeroclass;
- }
- }
- public List<IBuffBarsList> BuffBarsList { get; set; }
- public TopLabelDecorator BuffBar_Active_Label { get; set; }
- public TopLabelDecorator BuffBar_Inactive_Label { get; set; }
- public float barW, barH, barX, barY;
- public bool ShowAsVertical, HorizontalShowCentered;
- public int LastBuffsDiplayedCount;
- private ITexture buttonTextureGray, buttonTextureBlue, buttonTextureOrange;
- private ITexture bgTextureOrange, bgTextureGreen, bgTextureYellow, bgTextureBlue;
- public BuffSideBarPlugin()
- {
- // Inits
- Enabled = true;
- BuffBarsList = new List<IBuffBarsList>();
- LastBuffsDiplayedCount = 0;
- ShowAsVertical = true;
- HorizontalShowCentered = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- BuffBar_Active_Label = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 7, 120, 255, 240, 0, true, false, false),
- BackgroundTexture1 = Hud.Texture.ButtonTextureOrange,
- BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
- BackgroundTextureOpacity2 = 0.5f
- };
- BuffBar_Inactive_Label = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 7, 100, 192, 192, 192, false, false, false),
- BackgroundTexture1 = Hud.Texture.ButtonTextureGray,
- BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
- BackgroundTextureOpacity2 = 0.5f
- };
- }
- public void Customize()
- {
- ShowAsVertical = true;
- HorizontalShowCentered = true;
- // Unlike the old XML system where it draws x,y,w,h in terms of percentage of screen size, the new plugin uses actual pixel coordinates
- // To convert x,y,w,h sizes from the XML system to the new plugin system, multiply the screensize with percentage. ie. XML size of 2 => 0.02f * screensize
- // Below is equivalent to x=98, y=40, w=2, h=2 in old XML system
- barW = Hud.Window.Size.Width * 0.02f;
- barH = Hud.Window.Size.Height * 0.02f;
- if (ShowAsVertical)
- {
- // Vertical alignment
- barX = Hud.Window.Size.Width - barW;
- barY = Hud.Window.Size.Height * 0.4f;
- }
- else
- {
- // Horizontal alignment
- // If not-centered these are the starting X for the first buff, if centered it is where the point of the center is
- barX = Hud.Window.Size.Width / 2;
- barY = Hud.Window.Size.Height * 0.52f;
- }
- // Add the list of buff bars
- // BuffBarsList.Clear();
- BuffBarsList.Add(new IBuffBarsList("NB", "Nemesis Bracers", 318820, -1));
- BuffBarsList.Add(new IBuffBarsList("GW", "Goldwrap", 318875, 1));
- BuffBarsList.Add(new IBuffBarsList("OR", "Oculus Ring", 402461, 2));
- //BuffBarsList.Add(new IBuffBarsList("CE", "Convention of Elements", 430674, 5)); //1 Arcane, 2 Cold, 3 Fire, 4 Holy, 5 Lightning, 6 Physical, 7 Poison
- //BuffBarsList.Add(new IBuffBarsList("BP", "Broken Promises", 402462, 2));
- BuffBarsList.Add(new IBuffBarsList("IS", "Inner Sanctuary", 317076, -1, HeroClass.Monk));
- BuffBarsList.Add(new IBuffBarsList("FD", "Flying Dragon", 246562, 1, HeroClass.Monk));
- BuffBarsList.Add(new IBuffBarsList("SM", "Swiftmount", 359537, -1, HeroClass.Monk));
- BuffBarsList.Add(new IBuffBarsList("MS", "Mantra of Salvation", 375050, 1, HeroClass.Monk));
- BuffBarsList.Add(new IBuffBarsList("CS", "Command Skeleton", 453801, -1, HeroClass.Necromancer));
- BuffBarsList.Add(new IBuffBarsList("DB", "Dayntee Binding DR", 476689, 1, HeroClass.Necromancer));
- /*
- HeroClass.
- DemonHunter 0
- Barbarian 1
- Wizard 2
- WitchDoctor 3
- Monk 4
- Crusader 5
- Necromancer 6
- None
- */
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- // Inits
- TopLabelDecorator BuffBarLabel;
- var loopCtr = 0;
- // Determine starting X coordinate for horizontal alignment
- var h_barX = (!ShowAsVertical && HorizontalShowCentered) ? barX - (LastBuffsDiplayedCount * barW / 2) : barX;
- // Iterate the BuffBarList
- foreach (var ctrBuffBar in BuffBarsList)
- {
- // If the buff in the list is not for all class AND not for current specific heroclass, skip drawing it
- if (ctrBuffBar.OnlyHeroClass == HeroClass.None || ctrBuffBar.OnlyHeroClass == Hud.Game.Me.Hero.ClassDefinition.HeroClass)
- {
- // Check if this specific buff is currently active or not, and use the correct Label type
- BuffBarLabel = (Hud.Game.Me.Powers.BuffIsActive(ctrBuffBar.SNO, ctrBuffBar.IconIndex)) ? BuffBar_Active_Label : BuffBar_Inactive_Label;
- // Text of the labels
- BuffBarLabel.TextFunc = () => ctrBuffBar.Shorthand;
- BuffBarLabel.HintFunc = () => ctrBuffBar.Description;
- // Draw the label
- if (ShowAsVertical)
- { BuffBarLabel.Paint(barX, barY + (loopCtr * barH), barW, barH, HorizontalAlign.Center); }
- else
- { BuffBarLabel.Paint(h_barX + (loopCtr * barW), barY, barW, barH, HorizontalAlign.Center); }
- loopCtr++;
- }
- }
- LastBuffsDiplayedCount = loopCtr;
- } // endfunc PaintTopInGame
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement