Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Turbro
- {
- public class InventoryMainStatPlugin : BasePlugin, IInGameTopPainter
- {
- public bool OverlayMainStatOnItems { get; set; }
- public IFont MainStatFont { get; set; }
- private int stashPage, stashTab, stashTabAbs;
- private float rv;
- public InventoryMainStatPlugin()
- {
- Enabled = true;
- OverlayMainStatOnItems = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- MainStatFont = Hud.Render.CreateFont("tahoma", 8, 255, 200, 200, 200, false, false, false);
- MainStatFont.SetShadowBrush(128, 0, 0, 0, true);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if(!OverlayMainStatOnItems) return;
- 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.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;
- DrawItemMainStat(item, rect);
- }
- }
- private static string GetMainStatString(IItem item)
- {
- if (item != null && item.Perfections != null)
- {
- foreach (IItemPerfection perfection in item.Perfections)
- {
- if (perfection.Attribute.Code == "Dexterity_Item") return "dex";
- if (perfection.Attribute.Code == "Intelligence_Item") return "int";
- if (perfection.Attribute.Code == "Strength_Item") return "str";
- }
- }
- return null;
- }
- private void DrawItemMainStat(IItem item, System.Drawing.RectangleF rect)
- {
- var text = GetMainStatString(item);
- if(text != null)
- {
- var font = MainStatFont;
- var textLayout = font.GetTextLayout(text);
- font.DrawText(textLayout, rect.Left + rv / 15.0f, rect.Top + rv / 35.0f);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement