Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UpgradeRareRecipe.cs "$Revision: 915 $" "$Date: 2019-01-31 17:52:57 +0200 (to, 31 tammi 2019) $"
- using SharpDX.Direct2D1;
- using System.Linq;
- using Turbo.Plugins;
- using Turbo.Plugins.Default;
- namespace Turbo.plugins.JarJar.DefaultUI
- {
- class UpgradeRareRecipe : BasePlugin, ICustomizer, IInGameWorldPainter, IInGameTopPainter
- {
- public bool ShowInventoryBorder { get; set; } = true;
- public bool ShowStashBorder { get; set; } = true;
- public bool ShowItemInfo { get; set; } = true;
- public string[] ItemTypes { get; set; } = { }; // = item.SnoItem.SnoItemType.Code
- public IFont ItemTypeFont { get; set; }
- public IBrush InventoryBorderBrush { get; set; }
- public WorldDecoratorCollection RareKeepDecorator { get; set; }
- int stashPage, stashTab, stashTabAbs;
- public UpgradeRareRecipe() { Enabled = true; }
- public void Customize()
- {
- // Disable original HoveredItemInfoPlugin.
- Hud.TogglePlugin<Turbo.Plugins.Default.HoveredItemInfoPlugin>(false);
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- ItemTypeFont = Hud.Render.CreateFont("tahoma", 7, 255, 154, 105, 24, true, false, 128, 0, 0, 0, true);
- InventoryBorderBrush = Hud.Render.CreateBrush(200, 204, 51, 0, 2f, DashStyle.DashDot); // brownish red
- RareKeepDecorator = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(192, 255, 255, 0, -2),
- Radius = 1.25f,
- RadiusTransformator = new StandardPingRadiusTransformator(Hud, 333),
- },
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, 255, 255, 0, 0),
- ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
- Radius = 6,
- RadiusTransformator = new StandardPingRadiusTransformator(Hud, 333),
- });
- }
- public void PaintWorld(WorldLayer layer)
- {
- var items = Hud.Game.Items.Where(item => item.Location == ItemLocation.Floor && item.IsRare && item.SnoItem.Level == 70);
- foreach (var item in items)
- {
- if (isRecipeItem(item))
- {
- RareKeepDecorator.Paint(layer, item, item.FloorCoordinate, null);
- }
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (ShowItemInfo && clipState == ClipState.AfterClip)
- {
- paintHoveredItem();
- return;
- }
- if ((ShowInventoryBorder || ShowStashBorder) && clipState == ClipState.Inventory)
- {
- paintItemBorder();
- return;
- }
- }
- void paintHoveredItem()
- {
- var item = Hud.Inventory.HoveredItem;
- if (item == null || item.Unidentified) return;
- var uicMain = Hud.Inventory.GetHoveredItemMainUiElement();
- var uicTop = Hud.Inventory.GetHoveredItemTopUiElement();
- var iLevelText = string.Format("{0} {1}", item.SnoItem.Level, item.SnoItem.SnoItemType.Code);
- var iLevelLayout = ItemTypeFont.GetTextLayout(iLevelText);
- ItemTypeFont.DrawText(iLevelLayout, uicTop.Rectangle.Left - Hud.Window.Size.Height * 0.0166f, uicTop.Rectangle.Top + (Hud.Window.Size.Height * 0.022f - iLevelLayout.Metrics.Height) / 2);
- }
- void paintItemBorder()
- {
- var uiInv = Hud.Inventory.InventoryMainUiElement;
- if (!uiInv.Visible) return;
- stashTab = Hud.Inventory.SelectedStashTabIndex;
- stashPage = Hud.Inventory.SelectedStashPageIndex;
- stashTabAbs = stashTab + stashPage * Hud.Inventory.MaxStashTabCountPerPage;
- var items = Hud.Game.Items.Where(item => (
- (ShowStashBorder && item.Location == ItemLocation.Stash) ||
- (ShowInventoryBorder && item.Location == ItemLocation.Inventory)) &&
- item.IsRare && item.SnoItem.Level == 70);
- 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;
- if (isRecipeItem(item))
- {
- var rect = Hud.Inventory.GetItemRect(item);
- rect.Inflate(1f, 1f);
- if (rect == System.Drawing.RectangleF.Empty) continue;
- InventoryBorderBrush.DrawRectangle(rect.X, rect.Y, rect.Width, rect.Height);
- }
- }
- }
- bool isRecipeItem(IItem item)
- {
- // Highlight everything without configuration.
- return ItemTypes.Length == 0 ? true : ItemTypes.Any(x => x == item.SnoItem.SnoItemType.Code);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement