Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ImportantItems.cs "$Revision: 931 $" "$Date: 2019-02-02 12:40:48 +0200 (la, 02 helmi 2019) $"
- using System.Collections.Generic;
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.JarJar.DefaultUI
- {
- public class ImportantItems : BasePlugin, ICustomizer, IInGameTopPainter
- {
- public string ShowEquippedItemsChar { get; set; } = BC; // Override equipped items marker - set null to disable!
- public string MultiMatchIndicator { get; set; } = CAPI; // Indicator for multiple item matches, font is hard coded!
- public bool CheckItemRank { get; set; } = true; // Check item rank.
- public string HigherRankIndicator { get; set; } = RE; // Indicator for items that have higher ranked items elsewhere.
- // These must be compile time constants for our item table.
- const string BC = "\u25CF"; // black circle
- const string RE = "\u267A"; // recycling symbol
- const string FO = "\uD83D\uDEE1"; // shield
- const string CAPI = "\u24BE"; // circled latin capital letter i
- const string C1 = "\u2460"; // circled digit one
- const string C2 = "\u2461"; // circled digit two
- const string C3 = "\u2462"; // circled digit three
- const string C4 = "\u2463"; // circled digit four
- const string C5 = "\u2464"; // circled digit five
- const int DEFAULT = 0; // Default font index.
- const int FOLLOWER = 1; // Follower shield index.
- const int NOTICE = 2; // NoticeFont index.
- const int EQUIPPED = 3; // Default font with shadow index.
- const int MULTI = 4; // Multiple matches.
- const int HIGHER = 5; // Multiple matches.
- IFont[] Fonts; // Actual fonts.
- public ImportantItems() { Enabled = true; }
- public void Customize()
- {
- // Setup original InventoryAndStashPlugin & Co.!
- Hud.RunOnPlugin<Turbo.Plugins.Default.InventoryAndStashPlugin>(plugin =>
- {
- plugin.LooksGoodDisplayEnabled = false;
- plugin.NotGoodDisplayEnabled = false;
- plugin.DefinitelyBadDisplayEnabled = false;
- plugin.CanCubedEnabled = false;
- });
- Hud.TogglePlugin<Turbo.Plugins.Default.HoveredItemInfoPlugin>(false);
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- List<IFont> fonts = new List<IFont>();
- // Add fonts in font index order!
- fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 0, 255, true, false, false)); // DEFAULT Bright violet
- fonts.Add(Hud.Render.CreateFont("arial", 7, 255, 51, 204, 166, false, false, true)); // FOLLOWER Green-blue
- fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 128, 0, true, false, true)); // NOTICE Orange
- fonts.Add(Hud.Render.CreateFont("arial", 9, 255, 255, 0, 255, true, false, false)); // EQUIPPED Bright violet + shadow
- fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 51, 153, true, false, false)); // MULTI Bright reddish violet
- fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 0, 102, true, false, true)); // HIGHER Violet red
- // Grab fonts into an array because we need to access them by index for "Important" array.
- Fonts = fonts.ToArray();
- Fonts[EQUIPPED].SetShadowBrush(128, 63, 63, 63, true); // Almost black
- }
- private int stashPage, stashTab, stashTabAbs;
- private float rv;
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.Inventory) return;
- stashTab = Hud.Inventory.SelectedStashTabIndex;
- stashPage = Hud.Inventory.SelectedStashPageIndex;
- stashTabAbs = stashTab + stashPage * Hud.Inventory.MaxStashTabCountPerPage;
- rv = 32.0f / 600.0f * Hud.Window.Size.Height;
- var items = Hud.Game.Items.Where(x => x.Location >= ItemLocation.Stash || (x.Location >= ItemLocation.Inventory && x.Location <= ItemLocation.Neck));
- foreach (var item in items)
- {
- if (item.Location == ItemLocation.Stash)
- {
- var tabIndex = item.InventoryY / 10;
- if (tabIndex != stashTabAbs) continue;
- }
- if ((item.InventoryX < 0) || (item.InventoryY < 0)) continue;
- var rect = Hud.Inventory.GetItemRect(item);
- if (rect == System.Drawing.RectangleF.Empty) continue;
- // New paint logic.
- if (item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory)
- {
- if (item.Unidentified ||
- !item.IsLegendary ||
- item.SnoItem.Kind == ItemKind.gem ||
- item.SnoItem.Kind == ItemKind.uberstuff ||
- item.SnoItem.Kind == ItemKind.potion ||
- item.SnoItem.MainGroupCode == "gems_unique" ||
- item.SnoItem.MainGroupCode == "riftkeystone" ||
- item.SnoItem.MainGroupCode == "healthpotions" ||
- item.SnoItem.MainGroupCode == "consumable" ||
- item.SnoItem.MainGroupCode == "horadriccache")
- {
- continue;
- }
- }
- if ((item.SnoItem.NameEnglish == "Puzzle Ring" || item.SnoItem.NameEnglish == "Bovine Bardiche"))
- {
- ShowStar(rect, RE, Fonts[NOTICE], false);
- continue;
- }
- List<ImportantItem> important = Important.Where(x => x.Name == item.SnoItem.NameEnglish).ToList();
- if (important.Count > 0)
- {
- // Important item with our main stat (or wildcard).
- bool halfSize = item.Location == ItemLocation.Waist;
- if (item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory || ShowEquippedItemsChar == null)
- {
- int higherRankedItems = CheckItemRank ? countHigherRankedItems(item) : 0;
- if (higherRankedItems > 0)
- {
- if (HigherRankIndicator != null)
- {
- ShowStar(rect, HigherRankIndicator, Fonts[HIGHER], halfSize);
- }
- }
- else if (important.Count == 1)
- {
- ShowStar(rect, important[0], halfSize);
- }
- else
- {
- ShowStar(rect, MultiMatchIndicator, Fonts[MULTI], halfSize);
- }
- }
- else
- {
- ShowStar(rect, ShowEquippedItemsChar, Fonts[EQUIPPED], halfSize);
- }
- }
- else if (item.Location == ItemLocation.Inventory && item.SnoItem.CanKanaiCube && !Hud.Game.Me.IsCubed(item.SnoItem))
- {
- DrawItemCanCubed(rect, item);
- }
- }
- }
- int countHigherRankedItems(IItem item)
- {
- // Check only normal or ancient legendaries!
- if ((item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory) && item.AncientRank < 2)
- {
- return Hud.Game.Items.Count(x => x.SnoItem.NameEnglish == item.SnoItem.NameEnglish && x.AncientRank > item.AncientRank && x.ItemUniqueId != item.ItemUniqueId);
- }
- return 0;
- }
- void ShowStar(System.Drawing.RectangleF rect, ImportantItem important, bool halfSize)
- {
- ShowStar(rect, important.MarkerChar, Fonts[important.FontIndex], halfSize);
- }
- void ShowStar(System.Drawing.RectangleF rect, string symbol, IFont font, bool halfSize)
- {
- // Top right corner.
- var textLayout = font.GetTextLayout(symbol);
- font.DrawText(textLayout, rect.Right - rv / 15.0f - textLayout.Metrics.Width, rect.Top - rv / (halfSize ? 8.75f : 17.5f));
- }
- private void DrawItemCanCubed(System.Drawing.RectangleF rect, IItem item)
- {
- var cubeTexture = Hud.Texture.KanaiCubeTexture;
- var h = cubeTexture.Height * 0.6f / 1200.0f * Hud.Window.Size.Height;
- var x = rect.Right - h * 0.80f;
- var y = rect.Top - h * 0.20f;
- cubeTexture.Draw(x, y, h, h, 1);
- }
- public class ImportantItem
- {
- public readonly string Name;
- public readonly string MarkerChar;
- public readonly int FontIndex;
- public ImportantItem(string name, string markerChar, int fontIndex)
- {
- Name = name;
- MarkerChar = markerChar;
- FontIndex = fontIndex;
- }
- }
- static ImportantItem important(string name, string markerChar = BC, int fontIndex = 0)
- {
- return new ImportantItem(name, markerChar, fontIndex);
- }
- public static ImportantItem[] Important = new ImportantItem[]
- {
- important("Ring of Royal Grandeur", BC, NOTICE),
- important("Unity", BC, NOTICE),
- // Barbarian HotA
- important("Immortal King's Triumph", C1),
- important("Immortal King's Eternal Reign", C1),
- important("Immortal King's Irons", C1),
- important("Immortal King's Tribal Binding", C1),
- important("Immortal King's Stature", C1),
- important("Immortal King's Stride", C1),
- important("Fury of the Ancients", C1),
- important("Bracers of the First Men", C1),
- important("Magefist", C1),
- important("The Traveler's Pledge", C1),
- important("The Compass Rose", C1),
- important("Convention of Elements", C1),
- important("Little Rogue", C1),
- important("The Slanderer", C1),
- // Barbarian LeapQuake
- important("Eyes of the Earth", C2),
- important("Spires of the Earth", C2),
- important("Pull of the Earth", C2),
- important("Spirit of the Earth", C2),
- important("Girdle of Giants", C2),
- important("Weight of the Earth", C2),
- important("Foundation of the Earth", C2),
- important("Lut Socks", C2),
- important("Ancient Parthan Defenders", C2),
- important("Hellfire Amulet", C2),
- important("Focus", C2),
- important("Restraint", C2),
- important("Blade of the Tribes", C2),
- // Barbarian Whirlwind
- important("Helm of the Wastes", C3),
- important("Pauldrons of the Wastes", C3),
- important("Cuirass of the Wastes", C3),
- important("Ancient Parthan Defenders", C3),
- important("Strongarm Bracers", C3),
- important("Gauntlet of the Wastes", C3),
- important("Pride of Cassius", C3),
- important("Tasset of the Wastes", C3),
- important("Swamp Land Waders", C3),
- important("Sabaton of the Wastes", C3),
- important("Hellfire Amulet", C3),
- important("Mara's Kaleidoscope", C3),
- important("Eye of Etlich", C3),
- important("Obsidian Ring of the Zodiac", C3),
- important("Convention of Elements", C3),
- important("Bul-Kathos's Solemn Vow", C3),
- important("Bul-Kathos's Warrior Blood", C3),
- // Barbarian Raekor Furious Charge
- important("Raekor's Will", C4),
- important("Immortal King's Triumph", C4),
- important("Raekor's Burden", C4),
- important("Raekor's Heart", C4),
- important("Immortal King's Eternal Reign", C4),
- important("Ancient Parthan Defenders", C4),
- important("Skular's Salvation", C4),
- important("Bracers of Destruction", C4),
- important("Raekor's Wraps", C4),
- important("Immortal King's Irons", C4),
- important("Immortal King's Tribal Binding", C4),
- important("Raekor's Breeches", C4),
- important("Immortal King's Stature", C4),
- important("Raekor's Striders", C4),
- important("Immortal King's Stride", C4),
- important("Hellfire Amulet", C4),
- important("Mara's Kaleidoscope", C4),
- important("Eye of Etlich", C4),
- important("Band of Might", C4),
- important("Focus", C4),
- important("Convention of Elements", C4),
- important("Restraint", C4),
- important("Immortal King's Boulder Breaker", C4),
- // Follower - Templar
- // See: https://www.icy-veins.com/d3/follower-skills-and-gearing-patch-2-6-1
- important("Thunderfury, Blessed Blade of the Windseeker", FO, FOLLOWER),
- important("Eun-jang-do", FO, FOLLOWER),
- important("Freeze of Deflection", FO, FOLLOWER),
- important("Defender of Westmarch", FO, FOLLOWER),
- important("Lidless Wall", FO, FOLLOWER),
- important("The Ess of Johan", FO, FOLLOWER),
- important("Overwhelming Desire", FO, FOLLOWER),
- important("Wyrdward", FO, FOLLOWER),
- important("Oculus Ring", FO, FOLLOWER),
- important("Justice Lantern", FO, FOLLOWER),
- important("Enchanting Favor", FO, FOLLOWER),
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement