Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_MaterialCountPlugin : BasePlugin, IInGameTopPainter, ICustomizer {
- public IFont Font_Norm { get; set; }
- public IFont Font_Min { get; set; }
- public IFont Font_Max { get; set; }
- private ISnoItem[] _bMaterials, _bountyMats, _InfMachine, _DemonOrgan;
- private ITexture image_BG { get; set; }
- private IUiElement uiInv { get; set; }
- private IFont usedFont { get; set; }
- public DAV_MaterialCountPlugin() {
- Enabled = true;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- Font_Norm = Hud.Render.CreateFont("Arial", 8, 255, 255, 255, 255, false, false, false);
- Font_Min = Hud.Render.CreateFont("Arial", 8, 255, 255, 51, 51, false, false, false);
- Font_Max = Hud.Render.CreateFont("Arial", 8, 255, 51, 255, 51, false, false, false);
- image_BG = Hud.Texture.GetTexture("inventory_materials");
- _bMaterials = new ISnoItem[] {
- Hud.Sno.SnoItems.Crafting_AssortedParts_01, // 3931359676 - Reusable Parts
- Hud.Sno.SnoItems.Crafting_Magic_01, // 2709165134 - Arcane Dust
- Hud.Sno.SnoItems.Crafting_Rare_01, // 3689019703 - Veiled Crystal
- Hud.Sno.SnoItems.Crafting_Looted_Reagent_01, // 2087837753 - Death's Breath
- Hud.Sno.SnoItems.Crafting_Legendary_01, // 2073430088 - Forgotten Soul
- };
- _bountyMats = new ISnoItem[] {
- Hud.Sno.SnoItems.p2_ActBountyReagent_01, // 1948629088 - Khanduran Rune
- Hud.Sno.SnoItems.p2_ActBountyReagent_02, // 1948629089 - Caldeum Nightshade
- Hud.Sno.SnoItems.p2_ActBountyReagent_03, // 1948629090 - Arreat War Tapestry
- Hud.Sno.SnoItems.p2_ActBountyReagent_04, // 1948629091 - Corrupted Angel Flesh
- Hud.Sno.SnoItems.p2_ActBountyReagent_05, // 1948629092 - Westmarch Holy Water
- };
- _InfMachine = new ISnoItem[] {
- Hud.Sno.SnoItems.InfernalMachine_SkeletonKing_x1, // 1054965529 - Infernal Machine of Regret
- Hud.Sno.SnoItems.InfernalMachine_Ghom_x1, // 2788723894 - Infernal Machine of Putridness
- Hud.Sno.SnoItems.InfernalMachine_SiegeBreaker_x1, // 2622355732 - Infernal Machine of Terror
- Hud.Sno.SnoItems.InfernalMachine_Diablo_x1, // 1458185494 - Infernal Machine of Fright
- Hud.Sno.SnoItems.GreaterLootRunKey, // 2835237830 - Greater Rift Keystone
- };
- _DemonOrgan = new ISnoItem[] {
- Hud.Sno.SnoItems.DemonOrgan_SkeletonKing_x1, // 1102953247 - Leoric's Regret
- Hud.Sno.SnoItems.DemonOrgan_Ghom_x1,// 2029265596 - Vial of Putridness
- Hud.Sno.SnoItems.DemonOrgan_SiegeBreaker_x1, // 2670343450 - Idol of Terror
- Hud.Sno.SnoItems.DemonOrgan_Diablo_x1, // 3336787100 - Heart of Fright
- Hud.Sno.SnoItems.Unique_Ring_004_x1, // 3106130529 - Puzzle Ring
- };
- }
- public void PaintTopInGame(ClipState clipState) {
- if (clipState != ClipState.Inventory) return;
- if (Hud.Game.Me.CurrentLevelNormalCap != 70) return;
- uiInv = Hud.Inventory.InventoryMainUiElement;
- if (!uiInv.Visible) return;
- var y = uiInv.Rectangle.Top + uiInv.Rectangle.Height * 0.825f;
- y += DrawItemBar(_bMaterials, y);
- y += DrawItemBar(_bountyMats, y, true, 5);
- y += DrawItemBar(_DemonOrgan, y, true, 4);
- y += DrawItemBar(_InfMachine, y, true, 4);
- }
- private float DrawItemBar(ISnoItem[] itemsToDisplay, float barY, bool showMin = false, int maxArray = 1) {
- var rect = new SharpDX.RectangleF(uiInv.Rectangle.Left - 1, barY, uiInv.Rectangle.Width + 2, image_BG.Height * uiInv.Rectangle.Width / image_BG.Width);
- image_BG.Draw(rect.X, rect.Y, rect.Width, rect.Height);
- var itemCountList = new long[itemsToDisplay.Length];
- var minValue = long.MaxValue;
- var maxValue = (long) 0;
- for (var j = 0; j < itemsToDisplay.Length; j++) {
- itemCountList[j] = GetItemCount(itemsToDisplay[j]);
- if (minValue > itemCountList[j] && j < maxArray)
- minValue = itemCountList[j];
- if (maxValue < itemCountList[j] && j < maxArray)
- maxValue = itemCountList[j];
- }
- var w = rect.Width / (itemsToDisplay.Length + 1);
- var h = rect.Height * 0.85f;
- var y = rect.Top + ((rect.Height - h) / 2);
- for (var i = 0; i < itemsToDisplay.Length; i++) {
- var texture = Hud.Texture.GetItemTexture(itemsToDisplay[i]);
- if (texture != null) {
- var x = (w / 2) + rect.Left + (i * w);
- texture.Draw(x + w - h, y, h, h, 1);
- if (showMin) {
- if (itemCountList[i] == minValue)
- usedFont = Font_Min;
- else if (itemCountList[i] == maxValue)
- usedFont = Font_Max;
- else
- usedFont = Font_Norm;
- }
- else usedFont = Font_Norm;
- var layout = usedFont.GetTextLayout(ValueToString(itemCountList[i], ValueFormat.NormalNumberNoDecimal));
- usedFont.DrawText(layout, x + w - (h * 1.2f) - layout.Metrics.Width, y + ((h - layout.Metrics.Height) / 2));
- if (Hud.Window.CursorInsideRect(x + w - (h * 1.2f) - layout.Metrics.Width, y, (h * 1.2f) + layout.Metrics.Width, h))
- Hud.Render.SetHint(itemsToDisplay[i].NameLocalized);
- }
- }
- return rect.Height;
- }
- private long GetItemCount(ISnoItem snoItem) {
- switch (snoItem.Sno) {
- case 3931359676: return Hud.Game.Me.Materials.ReusableParts;
- case 2709165134: return Hud.Game.Me.Materials.ArcaneDust;
- case 3689019703: return Hud.Game.Me.Materials.VeiledCrystal;
- case 2087837753: return Hud.Game.Me.Materials.DeathsBreath;
- case 2073430088: return Hud.Game.Me.Materials.ForgottenSoul;
- case 1948629088: return Hud.Game.Me.Materials.KhanduranRune;
- case 1948629089: return Hud.Game.Me.Materials.CaldeumNightShade;
- case 1948629090: return Hud.Game.Me.Materials.ArreatWarTapestry;
- case 1948629091: return Hud.Game.Me.Materials.CorruptedAngelFlesh;
- case 1948629092: return Hud.Game.Me.Materials.WestmarchHolyWater;
- case 1102953247: return Hud.Game.Me.Materials.LeoricsRegret;
- case 2029265596: return Hud.Game.Me.Materials.VialOfPutridness;
- case 2670343450: return Hud.Game.Me.Materials.IdolOfTerror;
- case 3336787100: return Hud.Game.Me.Materials.HeartOfFright;
- case 2835237830: return Hud.Game.Me.Materials.GreaterRiftKeystone;
- }
- var count = 0;
- foreach (var item in Hud.Inventory.ItemsInStash) {
- if (item.SnoItem == snoItem)
- count += (int) (item.Quantity > 0 ? item.Quantity : 1);
- }
- foreach (var item in Hud.Inventory.ItemsInInventory) {
- if (item.SnoItem == snoItem)
- count += (int) (item.Quantity > 0 ? item.Quantity : 1);
- }
- return count;
- }
- public void Customize() {
- Hud.TogglePlugin<InventoryMaterialCountPlugin>(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement