AppearanceTooltip

AppearanceTooltip

319k Downloads

API support in Baganator

plusmouse opened this issue ยท 1 comments

commented

Edit: Latest Baganator alphas now contain this API

This is related to #17

I've (Baganator developer) got a working API for icon widgets in testing now. It meets the internal requirements for Baganator to use it. So looking for feedback on whether it will meet your requirements now, before I merge something that doesn't work.

Sample version of Baganator with the plugin API (edit: updated 2024-01-08 13:23 BST)
Baganator-0.113-1-gb3dde12.zip

Each widget registers in advance with a function to control visibility/contents (onUpdate) and another (onInit) to create the associated frame on each item button.

-- label: User facing text string describing this corner option.
-- id: unique value to be used internally for the settings
-- onUpdate: Function to update the frame placed in the corner. Return true to
--  cause this corner's visual to show.
--  function(cornerFrame, itemDetails) -> boolean.
-- onInit: Called once for each item icon to create the frame to show in the
--  icon corner. Return the frame to be positioned in the corner. This frame
--  will be hidden/shown/have its parent changed to control visiblity. It may
--  have the fields padding (number, multiplier for the padding used from the
--  icon's corner) and sizeFont (boolean sets the font size for a font string to
--  the user configured size)
--  function(itemButton) -> Frame
-- defaultPosition: {corner, priority}, optional
--  corner: string (top_left, top_right, bottom_left, bottom_right)
--  priority: number (priority for the corner to be placed at in the corner sort
--    order)
function Baganator.API.RegisterCornerWidget(label, id, onUpdate, onInit, defaultPosition)
  Baganator.API.RegisterCornerWidget("Pawn", "pawn", function(Arrow, details)
    if PawnShouldItemLinkHaveUpgradeArrowUnbudgeted(details.itemLink) then
      return true
    end
  end, function(itemButton)
    local Arrow = itemButton:CreateTexture(nil, "OVERLAY")
    Arrow:SetTexture("Interface\\AddOns\\Pawn\\Textures\\UpgradeArrow")
    Arrow:SetSize(13.5, 15)
    return Arrow
  end)

More examples here: https://github.com/plusmouse/Baganator/blob/corner-mods/API/ItemButton.lua

Each widget will be available to be added here:
image

With the defaultPosition being non-nil the widget will be inserted by default at the priority and corner specified.

Edit: Updated parameters description and removed note about defaultPosition not working yet, as it is now working.

commented

(That was just cleanup. I still need to actually refactor things to port to the new API.)