Advertisement
jarppaaja

ImportantItems rev 929

Feb 2nd, 2019
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.81 KB | None | 0 0
  1. // ImportantItems.cs "$Revision: 929 $" "$Date: 2019-02-02 09:56:09 +0200 (la, 02 helmi 2019) $"
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.JarJar.DefaultUI
  7. {
  8.     public class ImportantItems : BasePlugin, ICustomizer, IInGameTopPainter
  9.     {
  10.         public string ShowEquippedItemsChar { get; set; } = BC;         // Override equipped items marker - set null to disable!
  11.         public string MultiMatchIndicator { get; set; } = CAPI;         // Indicator for multiple item matches, font is hard coded!
  12.  
  13.         // These must be compile time constants for our item table.
  14.  
  15.         const string BC = "\u25CF";             // black circle
  16.         const string RE = "\u267A";             // recycling symbol
  17.         const string FO = "\uD83D\uDEE1";       // shield
  18.         const string CAPI = "\u24BE";           // circled latin capital letter i
  19.  
  20.         const string C1 = "\u2460";             // circled digit one
  21.         const string C2 = "\u2461";             // circled digit two
  22.         const string C3 = "\u2462";             // circled digit three
  23.         const string C4 = "\u2463";             // circled digit four
  24.         const string C5 = "\u2464";             // circled digit five
  25.  
  26.         const int DEFAULT = 0;                  // Default font index.
  27.         const int FOLLOWER = 1;                 // Follower shield index.
  28.         const int NOTICE = 2;                   // NoticeFont index.
  29.         const int EQUIPPED = 3;                 // Default font with shadow index.
  30.         const int MULTI = 4;                    // Multiple matches.
  31.  
  32.         IFont[] Fonts;                          // Actual fonts.
  33.  
  34.         public ImportantItems() { Enabled = true; }
  35.  
  36.         public void Customize()
  37.         {
  38.             // Setup original InventoryAndStashPlugin & Co.!
  39.             Hud.RunOnPlugin<Turbo.Plugins.Default.InventoryAndStashPlugin>(plugin =>
  40.             {
  41.                 plugin.LooksGoodDisplayEnabled = false;
  42.                 plugin.NotGoodDisplayEnabled = false;
  43.                 plugin.DefinitelyBadDisplayEnabled = false;
  44.                 plugin.CanCubedEnabled = false;
  45.             });
  46.             Hud.TogglePlugin<Turbo.Plugins.Default.HoveredItemInfoPlugin>(false);
  47.         }
  48.  
  49.         public override void Load(IController hud)
  50.         {
  51.             base.Load(hud);
  52.  
  53.             List<IFont> fonts = new List<IFont>();
  54.  
  55.             // Add fonts in font index order!
  56.             fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 0, 255, true, false, false));    // DEFAULT      Bright violet
  57.             fonts.Add(Hud.Render.CreateFont("arial", 7, 255, 51, 204, 166, false, false, true));    // FOLLOWER     Green-blue
  58.             fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 128, 0, true, false, true));     // NOTICE       Orange
  59.             fonts.Add(Hud.Render.CreateFont("arial", 9, 255, 255, 0, 255, true, false, false));     // EQUIPPED     Bright violet + shadow
  60.             fonts.Add(Hud.Render.CreateFont("arial", 10, 255, 255, 51, 153, true, false, false));   // MULTI        Bright reddish violet
  61.  
  62.             // Grab fonts into an array because we need to access them by index for "Important" array.
  63.             Fonts = fonts.ToArray();
  64.             Fonts[EQUIPPED].SetShadowBrush(128, 63, 63, 63, true);      // Almost black
  65.         }
  66.  
  67.         private int stashPage, stashTab, stashTabAbs;
  68.         private float rv;
  69.  
  70.         public void PaintTopInGame(ClipState clipState)
  71.         {
  72.             if (clipState != ClipState.Inventory) return;
  73.  
  74.             stashTab = Hud.Inventory.SelectedStashTabIndex;
  75.             stashPage = Hud.Inventory.SelectedStashPageIndex;
  76.             stashTabAbs = stashTab + stashPage * Hud.Inventory.MaxStashTabCountPerPage;
  77.  
  78.             rv = 32.0f / 600.0f * Hud.Window.Size.Height;
  79.  
  80.             var items = Hud.Game.Items.Where(x => x.Location >= ItemLocation.Stash || (x.Location >= ItemLocation.Inventory && x.Location <= ItemLocation.Neck));
  81.             foreach (var item in items)
  82.             {
  83.                 if (item.Location == ItemLocation.Stash)
  84.                 {
  85.                     var tabIndex = item.InventoryY / 10;
  86.                     if (tabIndex != stashTabAbs) continue;
  87.                 }
  88.                 if ((item.InventoryX < 0) || (item.InventoryY < 0)) continue;
  89.  
  90.                 var rect = Hud.Inventory.GetItemRect(item);
  91.                 if (rect == System.Drawing.RectangleF.Empty) continue;
  92.  
  93.                 // New paint logic.
  94.                 if (item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory)
  95.                 {
  96.                     if (item.Unidentified ||
  97.                         !item.IsLegendary ||
  98.                         item.SnoItem.Kind == ItemKind.gem ||
  99.                         item.SnoItem.Kind == ItemKind.uberstuff ||
  100.                         item.SnoItem.Kind == ItemKind.potion ||
  101.                         item.SnoItem.MainGroupCode == "gems_unique" ||
  102.                         item.SnoItem.MainGroupCode == "riftkeystone" ||
  103.                         item.SnoItem.MainGroupCode == "healthpotions" ||
  104.                         item.SnoItem.MainGroupCode == "consumable" ||
  105.                         item.SnoItem.MainGroupCode == "horadriccache")
  106.                     {
  107.                         continue;
  108.                     }
  109.                 }
  110.                 if ((item.SnoItem.NameEnglish == "Puzzle Ring" || item.SnoItem.NameEnglish == "Bovine Bardiche"))
  111.                 {
  112.                     ShowStar(rect, RE, Fonts[FOLLOWER], false);
  113.                     continue;
  114.                 }
  115.                 List<ImportantItem> important = Important.Where(x => x.Name == item.SnoItem.NameEnglish).ToList();
  116.                 if (important.Count > 0)
  117.                 {
  118.                     // Important item with our main stat (or wildcard).
  119.                     bool halfSize = item.Location == ItemLocation.Waist;
  120.                     if (item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory || ShowEquippedItemsChar == null)
  121.                     {
  122.                         if (important.Count == 1)
  123.                         {
  124.                             ShowStar(rect, important[0], halfSize);
  125.                         }
  126.                         else
  127.                         {
  128.                             ShowStar(rect, MultiMatchIndicator, Fonts[MULTI], halfSize);
  129.                         }
  130.                     }
  131.                     else
  132.                     {
  133.                         ShowStar(rect, ShowEquippedItemsChar, Fonts[EQUIPPED], halfSize);
  134.                     }
  135.                 }
  136.                 else if (item.Location == ItemLocation.Inventory && item.SnoItem.CanKanaiCube && !Hud.Game.Me.IsCubed(item.SnoItem))
  137.                 {
  138.                     DrawItemCanCubed(rect, item);
  139.                 }
  140.             }
  141.         }
  142.  
  143.         void ShowStar(System.Drawing.RectangleF rect, ImportantItem important, bool halfSize)
  144.         {
  145.             ShowStar(rect, important.MarkerChar, Fonts[important.FontIndex], halfSize);
  146.         }
  147.  
  148.         void ShowStar(System.Drawing.RectangleF rect, string symbol, IFont font, bool halfSize)
  149.         {
  150.             // Top right corner.
  151.             var textLayout = font.GetTextLayout(symbol);
  152.             font.DrawText(textLayout, rect.Right - rv / 15.0f - textLayout.Metrics.Width, rect.Top - rv / (halfSize ? 8.75f : 17.5f));
  153.         }
  154.  
  155.         private void DrawItemCanCubed(System.Drawing.RectangleF rect, IItem item)
  156.         {
  157.             var cubeTexture = Hud.Texture.KanaiCubeTexture;
  158.             var h = cubeTexture.Height * 0.6f / 1200.0f * Hud.Window.Size.Height;
  159.             var x = rect.Right - h * 0.80f;
  160.             var y = rect.Top - h * 0.20f;
  161.             cubeTexture.Draw(x, y, h, h, 1);
  162.         }
  163.  
  164.         public class ImportantItem
  165.         {
  166.             public readonly string Name;
  167.             public readonly string MarkerChar;
  168.             public readonly int FontIndex;
  169.  
  170.             public ImportantItem(string name, string markerChar, int fontIndex)
  171.             {
  172.                 Name = name;
  173.                 MarkerChar = markerChar;
  174.                 FontIndex = fontIndex;
  175.             }
  176.         }
  177.  
  178.         static ImportantItem important(string name, string markerChar = BC, int fontIndex = 0)
  179.         {
  180.             return new ImportantItem(name, markerChar, fontIndex);
  181.         }
  182.  
  183.         public static ImportantItem[] Important = new ImportantItem[]
  184.         {
  185.             important("Ring of Royal Grandeur", BC, NOTICE),
  186.             important("Unity", BC, NOTICE),
  187.             // Barbarian HotA
  188.             important("Immortal King's Triumph", C1),
  189.             important("Immortal King's Eternal Reign", C1),
  190.             important("Immortal King's Irons", C1),
  191.             important("Immortal King's Tribal Binding", C1),
  192.             important("Immortal King's Stature", C1),
  193.             important("Immortal King's Stride", C1),
  194.             important("Fury of the Ancients", C1),
  195.             important("Bracers of the First Men", C1),
  196.             important("Magefist", C1),
  197.             important("The Traveler's Pledge", C1),
  198.             important("The Compass Rose", C1),
  199.             important("Convention of Elements", C1),
  200.             important("Little Rogue", C1),
  201.             important("The Slanderer", C1),
  202.             // Barbarian LeapQuake
  203.             important("Eyes of the Earth", C2),
  204.             important("Spires of the Earth", C2),
  205.             important("Pull of the Earth", C2),
  206.             important("Spirit of the Earth", C2),
  207.             important("Girdle of Giants", C2),
  208.             important("Weight of the Earth", C2),
  209.             important("Foundation of the Earth", C2),
  210.             important("Lut Socks", C2),
  211.             important("Ancient Parthan Defenders", C2),
  212.             important("Hellfire Amulet", C2),
  213.             important("Focus", C2),
  214.             important("Restraint", C2),
  215.             important("Blade of the Tribes", C2),
  216.             // Barbarian Whirlwind
  217.             important("Helm of the Wastes", C3),
  218.             important("Pauldrons of the Wastes", C3),
  219.             important("Cuirass of the Wastes", C3),
  220.             important("Ancient Parthan Defenders", C3),
  221.             important("Strongarm Bracers", C3),
  222.             important("Gauntlet of the Wastes", C3),
  223.             important("Pride of Cassius", C3),
  224.             important("Tasset of the Wastes", C3),
  225.             important("Swamp Land Waders", C3),
  226.             important("Sabaton of the Wastes", C3),
  227.             important("Hellfire Amulet", C3),
  228.             important("Mara's Kaleidoscope", C3),
  229.             important("Eye of Etlich", C3),
  230.             important("Obsidian Ring of the Zodiac", C3),
  231.             important("Convention of Elements", C3),
  232.             important("Bul-Kathos's Solemn Vow", C3),
  233.             important("Bul-Kathos's Warrior Blood", C3),
  234.             // Barbarian Raekor Furious Charge
  235.             important("Raekor's Will", C4),
  236.             important("Immortal King's Triumph", C4),
  237.             important("Raekor's Burden", C4),
  238.             important("Raekor's Heart", C4),
  239.             important("Immortal King's Eternal Reign", C4),
  240.             important("Ancient Parthan Defenders", C4),
  241.             important("Skular's Salvation", C4),
  242.             important("Bracers of Destruction", C4),
  243.             important("Raekor's Wraps", C4),
  244.             important("Immortal King's Irons", C4),
  245.             important("Immortal King's Tribal Binding", C4),
  246.             important("Raekor's Breeches", C4),
  247.             important("Immortal King's Stature", C4),
  248.             important("Raekor's Striders", C4),
  249.             important("Immortal King's Stride", C4),
  250.             important("Hellfire Amulet", C4),
  251.             important("Mara's Kaleidoscope", C4),
  252.             important("Eye of Etlich", C4),
  253.             important("Band of Might", C4),
  254.             important("Focus", C4),
  255.             important("Convention of Elements", C4),
  256.             important("Restraint", C4),
  257.             important("Immortal King's Boulder Breaker", C4),
  258.             // Follower - Templar
  259.             // See: https://www.icy-veins.com/d3/follower-skills-and-gearing-patch-2-6-1
  260.             important("Thunderfury, Blessed Blade of the Windseeker", FO, FOLLOWER),
  261.             important("Eun-jang-do", FO, FOLLOWER),
  262.             important("Freeze of Deflection", FO, FOLLOWER),
  263.             important("Defender of Westmarch", FO, FOLLOWER),
  264.             important("Lidless Wall", FO, FOLLOWER),
  265.             important("The Ess of Johan", FO, FOLLOWER),
  266.             important("Overwhelming Desire", FO, FOLLOWER),
  267.             important("Wyrdward", FO, FOLLOWER),
  268.             important("Oculus Ring", FO, FOLLOWER),
  269.             important("Justice Lantern", FO, FOLLOWER),
  270.             important("Enchanting Favor", FO, FOLLOWER),
  271.         };
  272.     }
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement