Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Custom PlayerInfosPlugin (Original by GLQ & Refactoring by Jack)
- // C# version of XML Player Infos Table.
- // Go to config/ui_default/ui_default_main.xml and disable the portraits template : <portraits enabled="0">
- using System.Globalization;
- using System.Linq;
- using Turbo.Plugins.Default;
- using Turbo.Plugins.Extended.Resources;
- namespace Turbo.Plugins.Extended.Addons
- {
- public class PlayerInfosPlugin : BasePlugin, INewAreaHandler, IInGameTopPainter
- {
- public TopTable Table { get; set; }
- private int lastPlayerCount = -1;
- private int hoveredPlayerIndex = -1;
- public PlayerInfosPlugin()
- {
- Enabled = true;
- Order = int.MaxValue;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Table = new TopTable(Hud)
- {
- RatioPositionX = 0.5f,
- RatioPositionY = 0.03f,
- HorizontalCenter = true,
- VerticalCenter = false,
- PositionFromRight = false,
- PositionFromBottom = false,
- ShowHeaderLeft = false,
- ShowHeaderTop = true,
- ShowHeaderRight = false,
- ShowHeaderBottom = false,
- DefaultCellDecorator = new TopTableCellDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f),
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, false),
- },
- DefaultHighlightDecorator = new TopTableCellDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(128, 0, 0, 242, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f),
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, false),
- },
- DefaultHeaderDecorator = new TopTableCellDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f),
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, true),
- }
- };
- DefineColumns();
- }
- public void OnNewArea(bool newGame, ISnoArea area)
- {
- if (!newGame) return;
- lastPlayerCount = -1;
- }
- private void DefineTable()
- {
- Table.Reset(true); // keep columns
- foreach (var player in Hud.Game.Players.OrderBy(p => p.PortraitIndex))
- {
- if (player == null) continue;
- Table.AddLine(
- new TopTableHeader(Hud, (pos, curPos) => "")
- {
- RatioWidth = 120 / 1080f,
- RatioHeight = 28 / 1080f,
- HighlightFunc = (pos, curPos) => hoveredPlayerIndex == pos,
- HighlightDecorator = new TopTableCellDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(96, 255, 255, 128, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f),
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 0, 0, 0, true, false, false),
- },
- CellHighlightDecorator = new TopTableCellDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(96, 255, 0, 255, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 70, 56, 42, 1.5f),
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, true, false, true),
- },
- },
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c)),
- new TopTableCell(Hud, (l, c, ls, cs) => GetCellText(l, c))
- );
- }
- }
- private string GetCellText(int line, int column)
- {
- var player = Hud.Game.Players.FirstOrDefault(p => p.PortraitIndex == line);
- if (player == null) return string.Empty;
- switch (column)
- {
- case 0:
- return player.BattleTagAbovePortrait + IsZDPS(player);
- case 1:
- return ValueToString((long)player.Defense.EhpCur, ValueFormat.LongNumber);
- case 2:
- return ValueToString((long)player.Offense.SheetDps, ValueFormat.LongNumber) + " (" + ValueToString((long)((player.Offense.HighestElementalDamageBonus + 1) * (player.Offense.SheetDps)), ValueFormat.LongNumber) + ")";
- case 3:
- return ValueToString((long)((player.Offense.BonusToElites + 1) * ((player.Offense.HighestElementalDamageBonus + 1) * (player.Offense.SheetDps))), ValueFormat.LongNumber);
- case 4:
- return player.Stats.MainStat.ToString();
- case 5:
- return player.Offense.AttackSpeed.ToString("F2", CultureInfo.InvariantCulture) + "/s";
- case 6:
- return player.Offense.CriticalHitChance.ToString("F2", CultureInfo.InvariantCulture) + "%";
- case 7:
- return player.Offense.CritDamage.ToString("F0", CultureInfo.InvariantCulture) + "%";
- case 8:
- return (player.Stats.CooldownReduction * 100).ToString("F1", CultureInfo.InvariantCulture) + "%";
- case 9:
- return (player.Stats.ResourceCostReduction * 100).ToString("F1", CultureInfo.InvariantCulture) + "%";
- case 10:
- return player.Offense.AreaDamageBonus.ToString() + "%";
- case 11:
- return player.HighestSoloRiftLevel.ToString();
- default:
- return string.Empty;
- }
- }
- private void DefineColumns()
- {
- Table.DefineColumns(
- new TopTableHeader(Hud, (pos, curPos) => "Player")
- {
- RatioHeight = 28 / 1080f,
- RatioWidth = 120 / 1080f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "EHP")
- {
- RatioWidth = 0.065f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "DPS (Elem)")
- {
- RatioWidth = 0.09f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "Elite DPS")
- {
- RatioWidth = 0.07f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "Main Stat")
- {
- RatioWidth = 0.07f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "AS")
- {
- RatioWidth = 0.05f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "CHC")
- {
- RatioWidth = 0.06f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "CHD")
- {
- RatioWidth = 0.06f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "CDR")
- {
- RatioWidth = 0.05f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "RCR")
- {
- RatioWidth = 0.05f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "AD")
- {
- RatioWidth = 0.05f,
- },
- new TopTableHeader(Hud, (pos, curPos) => "Solo GR")
- {
- RatioWidth = 0.06f,
- }
- );
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (Hud.Inventory.StashMainUiElement.Visible) return;
- var myPortrait = Hud.Game.Me.PortraitUiElement.Rectangle;
- if (Hud.Window.CursorX > myPortrait.Right)
- {
- lastPlayerCount = -1;
- return; // cursor is too much to the right, no need to go further
- }
- if (lastPlayerCount != Hud.Game.Players.Count())
- {
- lastPlayerCount = Hud.Game.Players.Count();
- DefineTable();
- return; // no need to lose more time within this frame
- }
- var displayTable = false;
- foreach (var player in Hud.Game.Players.OrderBy(p => p.PortraitIndex))
- {
- if (player == null) continue;
- var portrait = player.PortraitUiElement.Rectangle;
- if (!Hud.Window.CursorInsideRect(portrait.X, portrait.Y, portrait.Width, portrait.Height)) continue;
- hoveredPlayerIndex = (Hud.Game.NumberOfPlayersInGame > 1) ? player.PortraitIndex : -1;
- displayTable = true;
- }
- if (displayTable && Table != null)
- Table.Paint();
- }
- private string IsZDPS(IPlayer player) // Thanks to Resu
- {
- int Points = 0;
- var IllusoryBoots = player.Powers.GetBuff(318761);
- if (IllusoryBoots == null || !IllusoryBoots.Active) {} else {Points++;}
- var LeoricsCrown = player.Powers.GetBuff(442353);
- if (LeoricsCrown == null || !LeoricsCrown.Active) {} else {Points++;}
- var EfficaciousToxin = player.Powers.GetBuff(403461);
- if (EfficaciousToxin == null || !EfficaciousToxin.Active) {} else {Points++;}
- var OculusRing = player.Powers.GetBuff(402461);
- if (OculusRing == null || !OculusRing.Active) {} else {Points++;}
- var ZodiacRing = player.Powers.GetBuff(402459);
- if (ZodiacRing == null || !ZodiacRing.Active) {} else {Points++;}
- if (player.Offense.SheetDps < 500000f) Points++;
- if (player.Offense.SheetDps > 1500000f) Points--;
- if (player.Defense.EhpMax > 80000000f) Points++;
- var ConventionRing = player.Powers.GetBuff(430674);
- if (ConventionRing == null || !ConventionRing.Active) {} else {Points--;}
- var Stricken = player.Powers.GetBuff(428348);
- if (Stricken == null || !Stricken.Active) {} else {Points--;}
- if (Points >= 4) { return " (Z)"; } else { return ""; }
- }
- // End
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement