Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Text;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Csavo // Plugin for counting legendary drops. Credits to JackCeparou (http://www.ownedcore.com/forums/members/1164396-jackceparou.html) for helping out!
- {
- public class LegendaryCountPlugin : BasePlugin, IInGameTopPainter, ILootGeneratedHandler, IItemLocationChangedHandler // version 1.0 - April 7th 2017
- {
- public bool ShowPercent { get; set; }
- public bool Debug { get; set; }
- public int LegendaryCount { get; private set; }
- public int AncientCount { get; private set; }
- public int PrimalCount { get; private set; }
- public IFont TextFont { get; set; }
- public Dictionary<ISnoItem, string> SeenItemsCollection { get; set; }
- private StringBuilder lootBuilder;
- public LegendaryCountPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- ShowPercent = false;
- Debug = true;
- LegendaryCount = 0;
- AncientCount = 0;
- PrimalCount = 0;
- TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 235, 170, false, false, true);
- SeenItemsCollection = new Dictionary<ISnoItem, string>();
- lootBuilder = new StringBuilder();
- }
- public void OnLootGenerated(IItem item, bool gambled)
- {
- if (item.IsLegendary)
- {
- if (!SeenItemsCollection.ContainsKey(item.SnoItem))
- {
- SeenItemsCollection.Add(item.SnoItem, item.SnoItem.NameLocalized);
- if (item.AncientRank >= 0) LegendaryCount++;
- if (item.AncientRank == 1) AncientCount++;
- if (item.AncientRank == 2) PrimalCount++;
- }
- }
- }
- public void OnItemLocationChanged(IItem item, ItemLocation @from, ItemLocation to)
- {
- if (@from != ItemLocation.Floor || to != ItemLocation.Inventory) return;
- // do what you want with the item you just looted on ground
- if (item.IsLegendary && SeenItemsCollection.ContainsKey(item.SnoItem))
- {
- SeenItemsCollection.Remove(item.SnoItem);
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (TextFont == null) return;
- var uiMinimap = Hud.Render.MinimapUiElement.Rectangle;
- var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.minimap_dialog_backgroundScreen.minimap_dialog_pve.BoostWrapper.BoostsDifficultyStackPanel.clock").Rectangle;
- if (!ShowPercent)
- {
- var text = string.Format("Legos: {0} / {1} / {2}", LegendaryCount, AncientCount, PrimalCount);
- var layout = TextFont.GetTextLayout(text);
- TextFont.DrawText(layout, uiMinimap.Left, uiRect.Top + uiRect.Height * 1.15f);
- }
- else
- {
- var text = string.Format("Legos: {0} / {1} ({2:0.#}%) / {3} ({4:0.##}%)", LegendaryCount, AncientCount, (AncientCount > 0 ? ((float)AncientCount * 100 / LegendaryCount) : 0f), PrimalCount, (PrimalCount > 0 ? ((float)PrimalCount * 100 / LegendaryCount) : 0f));
- var layout = TextFont.GetTextLayout(text);
- TextFont.DrawText(layout, uiMinimap.Left, uiRect.Top + uiRect.Height * 1.15f);
- }
- if (Debug)
- {
- lootBuilder.Clear();
- lootBuilder.AppendFormat("Items:");
- lootBuilder.AppendLine();
- foreach (KeyValuePair<ISnoItem, string> type in SeenItemsCollection)
- {
- lootBuilder.AppendFormat("SnoItem: {0}", type.Key);
- lootBuilder.AppendLine();
- }
- var itemsLayout = TextFont.GetTextLayout(lootBuilder.ToString());
- TextFont.DrawText(itemsLayout, Hud.Window.Size.Width * 0.1f, Hud.Window.Size.Height * 0.1f);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement