-
Notifications
You must be signed in to change notification settings - Fork 0
Minimap
The Minimap module (RGXMinimap) provides minimap button creation with circular drag tracking, angle persistence, and DataBroker integration.
Create a minimap button.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
config.texture |
string | Yes | — | Icon texture path |
config.position |
number | No | 225 | Initial angle in degrees (0=top, 90=right, etc.) |
config.storage |
table | No | — | Saved variable table for angle persistence |
config.storageKey |
string | No | — | Key within storage for angle value |
config.tooltip |
string | No | — | Tooltip text on hover |
config.onClick |
function | No | — |
onClick(button, clickType) handler |
config.onEnter |
function | No | — |
onEnter(button) handler |
config.onLeave |
function | No | — |
onLeave(button) handler |
A button object with the methods below.
Show or hide the minimap button:
button:SetVisible(true)
button:SetVisible(false)Whether the button is currently shown.
Get the current angle in radians.
Set the button position by angle (in radians):
button:SetAngle(math.rad(225))Update the tooltip text:
button:SetTooltip("MyAddon v2.0")Override the click handler:
button:OnClick(function(btn, clickType)
if clickType == "LeftButton" then
MyAddon:Toggle()
elseif clickType == "RightButton" then
MyAddon:OpenConfig()
end
end)When storage and storageKey are provided, the button's angle is automatically saved on drag end and restored on next login:
local button = Minimap:Create({
texture = "Interface\\Icons\\INV_Misc_QuestionMark",
storage = MyAddonDB.profile,
storageKey = "minimapAngle",
position = MyAddonDB.profile.minimapAngle or 225,
})If no storage is provided, the angle is not persisted between sessions.
- The button follows the cursor around the minimap edge while dragged
- Position is constrained to the minimap's circular border
- On drag end, the final angle is saved to
storage[storageKey](if configured) - The button's position is recalculated relative to the minimap center
Minimap buttons created via RGXMinimap are compatible with DataBroker display addons (like TitanPanel, ChocolateBar). For DataBroker APIs, see DataBroker.
local Minimap = RGX:GetMinimap()
local button = Minimap:Create({
texture = "Interface\\AddOns\\MyAddon\\icon.tga",
position = 225,
storage = MyAddonDB.profile,
storageKey = "minimapAngle",
tooltip = "MyAddon - Click to toggle",
onClick = function(btn, clickType)
if clickType == "LeftButton" then
MyAddon:Toggle()
elseif clickType == "RightButton" then
MyAddon:OpenConfig()
end
end,
})
-- Later: hide the button
button:SetVisible(false)
-- Later: change tooltip
button:SetTooltip("MyAddon - Active")