Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // InventoryAndStashPlugin.cs "$Revision: 3697 $" "$Date: 2018-01-16 14:11:32 +0200 (ti, 16 tammi 2018) $"
- using System.Diagnostics;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.JarJar.Stolen
- {
- // Forked from: Turbo.Plugins.Default.InventoryAndStashPlugin.cs
- public class InventoryAndStashPlugin : BasePlugin, IKeyEventHandler, IInGameTopPainter
- {
- public bool ShowGreenStarEnabled { get; set; }
- public bool ShowRedStarEnabled { get; set; }
- public bool HoradricCacheEnabled { get; set; }
- public bool CanCubedEnabled { get; set; }
- public bool AncientRankEnabled { get; set; }
- public bool CaldesannRankEnabled { get; set; }
- public bool SocketedLegendaryGemRankEnabled { get; set; }
- public string StarChar { get; set; }
- public string RecycleChar { get; set; }
- public IFont LooksGoodFont { get; set; }
- public IFont LooksBadFont { get; set; }
- public IFont RecycleFont { get; set; }
- public IFont AncientRankFont { get; set; }
- public IFont PrimalRankFont { get; set; }
- public IFont SocketedLegendaryGemRankFont { get; set; }
- public IFont HoradricCacheFont { get; set; }
- public IFont QuantityFont { get; set; }
- public IBrush InventoryLockBorderBrush { get; set; }
- // Armory
- public bool ArmoryBordersEnabled { get; set; }
- public bool StashBorderEnabled { get; set; }
- public bool InventoryhBorderEnabled { get; set; }
- public bool EquippedhBorderEnabled { get; set; }
- public bool KeyboardEnabled { get; set; }
- public IFont ArmorySetFont { get; set; }
- public IBrush StashBorderBrush { get; set; }
- public IBrush InventoryBorderBrush { get; set; }
- public IBrush EquippedBorderBrush { get; set; }
- public IBrush GoodItemBrush { get; set; }
- private readonly Stopwatch _stopper = Stopwatch.StartNew();
- public InventoryAndStashPlugin()
- {
- // Must be explicitly enabled as this draws to same places as original InventoryAndStashPlugin!
- Enabled = false;
- ShowGreenStarEnabled = true;
- ShowRedStarEnabled = false;
- AncientRankEnabled = true;
- SocketedLegendaryGemRankEnabled = true;
- CaldesannRankEnabled = true;
- HoradricCacheEnabled = true;
- CanCubedEnabled = false;
- ArmoryBordersEnabled = false;
- StashBorderEnabled = true;
- InventoryhBorderEnabled = true;
- EquippedhBorderEnabled = true;
- KeyboardEnabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- StarChar = "\u2605"; // black star
- RecycleChar = "\u267A"; // recycling symbol for generic materials
- LooksGoodFont = Hud.Render.CreateFont("arial", 9, 255, 0, 255, 0, false, false, true); // Bright green
- LooksBadFont = Hud.Render.CreateFont("arial", 9, 255, 204, 0, 0, false, false, true); // Red
- RecycleFont = Hud.Render.CreateFont("arial", 10, 255, 255, 128, 0, true, false, true); // Orange
- HoradricCacheFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, false);
- HoradricCacheFont.SetShadowBrush(128, 0, 0, 0, true);
- AncientRankFont = Hud.Render.CreateFont("arial", 7, 255, 0, 0, 0, true, false, 220, 227, 153, 25, true);
- PrimalRankFont = Hud.Render.CreateFont("arial", 7, 255, 0, 0, 0, true, false, 180, 255, 64, 64, true);
- SocketedLegendaryGemRankFont = Hud.Render.CreateFont("arial", 7, 255, 0, 0, 0, true, false, false);
- SocketedLegendaryGemRankFont.SetShadowBrush(128, 240, 240, 64, true);
- QuantityFont = Hud.Render.CreateFont("tahoma", 8, 255, 200, 200, 200, false, false, false);
- QuantityFont.SetShadowBrush(128, 0, 0, 0, true);
- InventoryLockBorderBrush = Hud.Render.CreateBrush(100, 0, 150, 200, -1.6f);
- // Armory
- ArmorySetFont = Hud.Render.CreateFont("arial", 7, 255, 192, 192, 192, true, false, 220, 32, 32, 32, true); // light grey on drak grey
- StashBorderBrush = Hud.Render.CreateBrush(100, 0, 128, 128, -1.6f); // teal
- InventoryBorderBrush = Hud.Render.CreateBrush(200, 255, 0, 0, -1.6f); // red
- EquippedBorderBrush = Hud.Render.CreateBrush(100, 238, 232, 170, -1.6f); // pale golden rod
- GoodItemBrush = Hud.Render.CreateBrush(150, 255, 255, 0, -1.6f, SharpDX.Direct2D1.DashStyle.Dash); // yellow
- }
- bool _shiftPressed;
- public void OnKeyEvent(IKeyEvent keyEvent)
- {
- if (KeyboardEnabled) _shiftPressed = keyEvent.ShiftPressed;
- }
- private int stashPage, stashTab, stashTabAbs;
- private float rv;
- private StringBuilder builder = new StringBuilder();
- 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;
- if ((Hud.Inventory.InventoryLockArea.Width > 0) && (Hud.Inventory.InventoryLockArea.Height > 0))
- {
- var rect = Hud.Inventory.GetRectInInventory(Hud.Inventory.InventoryLockArea.X, Hud.Inventory.InventoryLockArea.Y, Hud.Inventory.InventoryLockArea.Width, Hud.Inventory.InventoryLockArea.Height);
- InventoryLockBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
- }
- builder.Length = 0;
- var items = Hud.Game.Items.Where(x => x.Location != ItemLocation.Merchant && x.Location != ItemLocation.Floor);
- 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;
- DrawItemSocketedLegendaryGemRank(item, rect);
- DrawItemAncientRank(item, rect);
- DrawItemHoradricCache(item, rect);
- DrawItemCanCubed(item, rect);
- // New paint logic.
- if (item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory)
- {
- if (!item.IsLegendary ||
- item.SnoItem.Kind == ItemKind.gem ||
- //item.SnoItem.Kind == ItemKind.craft ||
- item.SnoItem.Kind == ItemKind.uberstuff ||
- item.SnoItem.Kind == ItemKind.potion ||
- item.SnoItem.MainGroupCode == "riftkeystone" ||
- item.SnoItem.MainGroupCode == "gems_unique" ||
- item.SnoItem.MainGroupCode == "consumable" ||
- item.SnoItem.MainGroupCode == "horadriccache")
- {
- continue;
- }
- }
- if (ShowGreenStarEnabled || ShowRedStarEnabled)
- {
- if ((item.SnoItem.NameEnglish == "Puzzle Ring" || item.SnoItem.NameEnglish == "Bovine Bardiche") && RecycleFont != null)
- {
- ShowStar(rect, RecycleChar, RecycleFont, false);
- continue;
- }
- bool belt = item.Location == ItemLocation.Waist;
- if (ShowGreenStarEnabled)
- {
- if (item.KeepDecision == ItemKeepDecision.LooksGood) ShowStar(rect, StarChar, LooksGoodFont, belt);
- }
- if (ShowRedStarEnabled)
- {
- if (item.KeepDecision != ItemKeepDecision.LooksGood) ShowStar(rect, StarChar, LooksBadFont, belt);
- }
- }
- if (ArmoryBordersEnabled) checkArmorySets(item, rect);
- }
- }
- void ShowStar(System.Drawing.RectangleF rect, string symbol, IFont font, bool belt)
- {
- // Top right corner.
- var textLayout = font.GetTextLayout(symbol);
- font.DrawText(textLayout, rect.Right - rv / 15.0f - textLayout.Metrics.Width, rect.Top - rv / (belt ? 8.75f : 17.5f));
- }
- private void DrawItemSocketedLegendaryGemRank(IItem item, System.Drawing.RectangleF rect)
- {
- if (!SocketedLegendaryGemRankEnabled) return;
- if (item.ItemsInSocket == null) return;
- var legendaryGem = item.ItemsInSocket.FirstOrDefault(x => x.Quality == ItemQuality.Legendary && x.JewelRank > -1);
- if (legendaryGem == null) return;
- var jewelRank = legendaryGem.JewelRank;
- if (jewelRank > -1)
- {
- var text = jewelRank.ToString("D", CultureInfo.InvariantCulture);
- var layout = SocketedLegendaryGemRankFont.GetTextLayout(text);
- SocketedLegendaryGemRankFont.DrawText(layout, rect.X, rect.Y);
- }
- }
- private void DrawItemAncientRank(IItem item, System.Drawing.RectangleF rect)
- {
- if (!AncientRankEnabled) return;
- var ancientRank = item.AncientRank;
- if (ancientRank >= 1)
- {
- var caldesannRank = CaldesannRankEnabled ? item.CaldesannRank : 0;
- var ancientRankText = ancientRank == 1 ? "A" : "P";
- var font = ancientRank == 1 ? AncientRankFont : PrimalRankFont;
- var text = ancientRankText + (caldesannRank > 0 ? ("+" + caldesannRank.ToString("D", CultureInfo.InvariantCulture)) : "");
- var textLayout = font.GetTextLayout(text);
- font.DrawText(textLayout, rect.Right - rv / 15.0f - textLayout.Metrics.Width, rect.Bottom - rv / 35.0f - textLayout.Metrics.Height);
- }
- }
- private void DrawItemCanCubed(IItem item, System.Drawing.RectangleF rect)
- {
- if (!CanCubedEnabled) return;
- if ((item.Location != ItemLocation.Inventory) && (item.Location != ItemLocation.Stash)) return;
- var allowCube = item.SnoItem.CanKanaiCube && !Hud.Game.Me.IsCubed(item.SnoItem);
- if (allowCube && !item.IsInventoryLocked)
- {
- var cubeTexture = Hud.Texture.KanaiCubeTexture;
- var h = cubeTexture.Height * 0.6f / 1200.0f * Hud.Window.Size.Height;
- var rh = h;
- var mod = (_stopper.ElapsedMilliseconds) % 1000;
- var ratio = 0.8f + 1.2f / 1000.0f * (mod < 500 ? mod : 1000 - mod);
- rh *= ratio;
- var x = rect.Right - h * 0.80f - ((rh - h) / 2);
- var y = rect.Top - h * 0.20f - ((rh - h) / 2);
- cubeTexture.Draw(x, y, rh, rh, 1);
- }
- }
- private void DrawItemHoradricCache(IItem item, System.Drawing.RectangleF rect)
- {
- if (!HoradricCacheEnabled) return;
- if (item.SnoItem.MainGroupCode != "horadriccache") return;
- var text = "";
- if (item.SnoItem.Code.Contains("A1")) text = "A1";
- if (item.SnoItem.Code.Contains("A2")) text = "A2";
- if (item.SnoItem.Code.Contains("A3")) text = "A3";
- if (item.SnoItem.Code.Contains("A4")) text = "A4";
- if (item.SnoItem.Code.Contains("A5")) text = "A5";
- if (item.SnoItem.Code.Contains("Act1")) text = "A1";
- if (item.SnoItem.Code.Contains("Act2")) text = "A2";
- if (item.SnoItem.Code.Contains("Act3")) text = "A3";
- if (item.SnoItem.Code.Contains("Act4")) text = "A4";
- if (item.SnoItem.Code.Contains("Act5")) text = "A5";
- if (item.SnoItem.Code.Contains("Hard")) text += ": H";
- if (item.SnoItem.Code.Contains("Expert")) text += ": E";
- if (item.SnoItem.Code.Contains("Master")) text += ": M";
- if (item.SnoItem.Code.Contains("T13")) text += ": T13";
- else if (item.SnoItem.Code.Contains("T12")) text += ": T12";
- else if (item.SnoItem.Code.Contains("T11")) text += ": T11";
- else if (item.SnoItem.Code.Contains("T10")) text += ": T10";
- else if (item.SnoItem.Code.Contains("T9")) text += ": T9";
- else if (item.SnoItem.Code.Contains("T8")) text += ": T8";
- else if (item.SnoItem.Code.Contains("T7")) text += ": T7";
- else if (item.SnoItem.Code.Contains("T6")) text += ": T6";
- else if (item.SnoItem.Code.Contains("T5")) text += ": T5";
- else if (item.SnoItem.Code.Contains("T4")) text += ": T4";
- else if (item.SnoItem.Code.Contains("T3")) text += ": T3";
- else if (item.SnoItem.Code.Contains("T2")) text += ": T2";
- else if (item.SnoItem.Code.Contains("T1")) text += ": T1";
- if (item.SnoItem.Code.Contains("Torment13")) text += ": T13";
- else if (item.SnoItem.Code.Contains("Torment12")) text += ": T12";
- else if (item.SnoItem.Code.Contains("Torment11")) text += ": T11";
- else if (item.SnoItem.Code.Contains("Torment10")) text += ": T10";
- else if (item.SnoItem.Code.Contains("Torment9")) text += ": T9";
- else if (item.SnoItem.Code.Contains("Torment8")) text += ": T8";
- else if (item.SnoItem.Code.Contains("Torment7")) text += ": T7";
- else if (item.SnoItem.Code.Contains("Torment6")) text += ": T6";
- else if (item.SnoItem.Code.Contains("Torment5")) text += ": T5";
- else if (item.SnoItem.Code.Contains("Torment4")) text += ": T4";
- else if (item.SnoItem.Code.Contains("Torment3")) text += ": T3";
- else if (item.SnoItem.Code.Contains("Torment2")) text += ": T2";
- else if (item.SnoItem.Code.Contains("Torment1")) text += ": T1";
- if (text != null)
- {
- var textLayout = HoradricCacheFont.GetTextLayout(text);
- HoradricCacheFont.DrawText(textLayout, rect.Right - rv / 20.0f - textLayout.Metrics.Width, rect.Bottom - rv / 70.0f - textLayout.Metrics.Height);
- }
- }
- void checkArmorySets(IItem item, System.Drawing.RectangleF rect)
- {
- if (item.Location == ItemLocation.Stash)
- {
- if (!StashBorderEnabled) return;
- }
- else if (item.Location == ItemLocation.Inventory)
- {
- if (!InventoryhBorderEnabled) return;
- }
- else
- {
- if (!EquippedhBorderEnabled) return;
- }
- builder.Length = 0;
- for (int i = 0; i < Hud.Game.Me.ArmorySets.Length; ++i)
- {
- var set = Hud.Game.Me.ArmorySets[i];
- if (set.ContainsItem(item))
- {
- if (_shiftPressed)
- {
- if (builder.Length > 1) builder.Append(',');
- else if (builder.Length == 0) builder.Append('#');
- builder.Append(i + 1);
- }
- else
- {
- builder.Append('x');
- break;
- }
- }
- }
- if (builder.Length == 0)
- {
- return;
- }
- if (item.Location == ItemLocation.Stash)
- {
- if (StashBorderEnabled) StashBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
- }
- else if (item.Location == ItemLocation.Inventory)
- {
- if (InventoryhBorderEnabled) InventoryBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
- }
- else
- {
- if (EquippedhBorderEnabled) EquippedBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
- }
- if (_shiftPressed)
- {
- bool upper = item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory;
- var font = ArmorySetFont;
- var text = builder.ToString();
- var textLayout = font.GetTextLayout(text);
- var x = rect.Right - textLayout.Metrics.Width - (upper ? rv / 15.0f : 0f);
- var y = upper ? rect.Top + rv / 35.0f : rect.Bottom - 2 * (rv / 35.0f);
- font.DrawText(textLayout, x, y);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement