Skip to content

Commit

Permalink
Use LibDBIcon-1.0 for minimap icon
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuds authored and Rottenbeer committed May 20, 2021
1 parent 8f524a3 commit 55a927d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 160 deletions.
3 changes: 3 additions & 0 deletions .pkgmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package-as: ItemRack
externals:
ItemRack/Libs/LibStub: https://repos.curseforge.com/wow/libstub/trunk
ItemRack/Libs/CallbackHandler-1.0: https://repos.curseforge.com/wow/callbackhandler/trunk/CallbackHandler-1.0
ItemRack/Libs/LibDataBroker-1.1: https://github.com/tekkub/libdatabroker-1-1
ItemRack/Libs/LibDBIcon-1.0: https://repos.curseforge.com/wow/libdbicon-1-0/trunk/LibDBIcon-1.0
ItemRackOptions/Libs/LibStub: https://repos.curseforge.com/wow/libstub/trunk
move-folders:
ItemRack/ItemRack: ItemRack
Expand Down
89 changes: 27 additions & 62 deletions ItemRack/ItemRack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function ItemRack.IsBCC()
return WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
end

local LDB = LibStub("LibDataBroker-1.1")
local LDBIcon = LibStub("LibDBIcon-1.0")

ItemRackUser = {
Sets = {}, -- user's sets
ItemsUsed = {}, -- items that have been used (for notify purposes)
Expand Down Expand Up @@ -46,8 +49,7 @@ ItemRackSettings = {
AllowEmpty = "ON", -- allow empty slot as a choice in menus
HideTradables = "OFF", -- allow non-soulbound gear to appear in menu
AllowHidden = "ON", -- allow the ability to hide items/sets in the menu with alt+click
ShowMinimap = "ON", -- whether to show the minimap button
SquareMinimap = "OFF", -- whether to position minimap button as if on a square minimap
ShowMinimap = true, -- whether to show the minimap button
TrinketMenuMode = "OFF", -- whether to merge top/bottom trinkets to one menu (leftclick=top,rightclick=bottom)
AnotherOther = "OFF", -- whether to dock the merged trinket menu to bottom trinket
EquipToggle = "OFF", -- whether to toggle equipping a set when choosing to equip it
Expand Down Expand Up @@ -149,8 +151,6 @@ ItemRack.TooltipInfo = {

ItemRack.BankOpen = nil -- 1 if bank is open, nil if not

ItemRack.LastCurrentSet = nil -- last known current set

ItemRack.EventHandlers = {}
ItemRack.ExternalEventHandlers = {}

Expand Down Expand Up @@ -216,6 +216,7 @@ end
function ItemRack.OnPlayerLogin()
-- Normally some of these methods cannot be called in combat without causing errors, but since we run these IMMEDIATELY
-- on PLAYER_LOGIN event we get a grace period where it allows us to run secure code in combat.
ItemRack.InitBroker()
ItemRack.InitEventHandlers()
ItemRack.InitTimers()
ItemRack.InitCore()
Expand Down Expand Up @@ -445,9 +446,7 @@ function ItemRack.InitCore()
ItemRack.CreateTimer("MenuMouseover",ItemRack.MenuMouseover,.25,1)
ItemRack.CreateTimer("TooltipUpdate",ItemRack.TooltipUpdate,1,1)
ItemRack.CreateTimer("CooldownUpdate",ItemRack.CooldownUpdate,1,1)
ItemRack.CreateTimer("MinimapDragging",ItemRack.MinimapDragging,0,1)
ItemRack.CreateTimer("LocksChanged",ItemRack.LocksChanged,.2)
ItemRack.CreateTimer("MinimapShine",ItemRack.MinimapShineUpdate,0,1)
ItemRack.CreateTimer("DelayedCombatQueue",ItemRack.DelayedCombatQueue,.1)

for i=-2,11 do
Expand Down Expand Up @@ -483,7 +482,6 @@ function ItemRack.InitCore()
ItemRackFrame:RegisterEvent("UNIT_SPELLCAST_FAILED")
--end
ItemRack.StartTimer("CooldownUpdate")
ItemRack.MoveMinimap()
ItemRack.ReflectAlpha()
ItemRack.SetSetBindings()

Expand Down Expand Up @@ -519,11 +517,7 @@ function ItemRack.UpdateCurrentSet()
ItemRackButton20Icon:SetTexture(texture)
ItemRackButton20Name:SetText(setname)
end
ItemRackMinimapIcon:SetTexture(texture)
if setname ~= ItemRack.LastCurrentSet then
ItemRack.MinimapShineFadeIn()
ItemRack.LastCurrentSet = setname
end
ItemRack.Broker.icon = texture
end

--[[ Item info gathering ]]
Expand Down Expand Up @@ -1728,35 +1722,26 @@ end

--[[ Minimap button ]]

function ItemRack.MinimapDragging()
local xpos,ypos = GetCursorPosition()
local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()

xpos = xmin-xpos/Minimap:GetEffectiveScale()+70
ypos = ypos/Minimap:GetEffectiveScale()-ymin-70

ItemRackSettings.IconPos = math.deg(math.atan2(ypos,xpos))
ItemRack.MoveMinimap()
end

function ItemRack.MoveMinimap()
if ItemRackSettings.ShowMinimap=="ON" then
local xpos,ypos
local angle = ItemRackSettings.IconPos or -100
if ItemRackSettings.SquareMinimap=="ON" then
-- brute force method until trig solution figured out - min/max a point on a circle beyond square
xpos = 110 * cos(angle)
ypos = 110 * sin(angle)
xpos = math.max(-82,math.min(xpos,84))
ypos = math.max(-86,math.min(ypos,82))
else
xpos = 80*cos(angle)
ypos = 80*sin(angle)
end
ItemRackMinimapFrame:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-xpos,ypos-52)
ItemRackMinimapFrame:Show()
function ItemRack.InitBroker()
local texture = ItemRack.GetTextureBySlot(20)
texture = [[Interface\AddOns\ItemRack\ItemRackIcon]]
ItemRack.Broker = LDB:NewDataObject("ItemRack", {
type = "launcher",
text = "ItemRack",
icon = texture,
OnClick = ItemRack.MinimapOnClick,
OnEnter = ItemRack.MinimapOnEnter
})
ItemRackSettings.minimap = ItemRackSettings.minimap or { hide = false }
LDBIcon:Register("ItemRack", ItemRack.Broker, ItemRackSettings.minimap)
ItemRack.ShowMinimap()
end

function ItemRack.ShowMinimap()
if ItemRackSettings.ShowMinimap == "ON" then
LDBIcon:Show("ItemRack")
else
ItemRackMinimapFrame:Hide()
LDBIcon:Hide("ItemRack")
end
end

Expand All @@ -1773,9 +1758,9 @@ function ItemRack.MinimapOnClick(self,button)
else
local xpos,ypos = GetCursorPosition()
if ypos>400 then
ItemRack.DockWindows("TOPRIGHT",ItemRackMinimapFrame,"BOTTOMRIGHT","VERTICAL")
ItemRack.DockWindows("TOPRIGHT",self,"BOTTOMRIGHT","VERTICAL")
else
ItemRack.DockWindows("BOTTOMRIGHT",ItemRackMinimapFrame,"TOPRIGHT","VERTICAL")
ItemRack.DockWindows("BOTTOMRIGHT",self,"TOPRIGHT","VERTICAL")
end
ItemRack.BuildMenu(20, nil, 4)
end
Expand All @@ -1790,26 +1775,6 @@ function ItemRack.MinimapOnEnter(self)
end
end


function ItemRack.MinimapShineUpdate(elapsed)
ItemRack.MinimapShineAlpha = ItemRack.MinimapShineAlpha + (elapsed*2*ItemRack.MinimapShineDirection)
if ItemRack.MinimapShineAlpha < .1 then
ItemRack.StopTimer("MinimapShine")
ItemRackMinimapShine:Hide()
elseif ItemRack.MinimapShineAlpha > .9 then
ItemRack.MinimapShineDirection = -1
else
ItemRackMinimapShine:SetAlpha(ItemRack.MinimapShineAlpha)
end
end

function ItemRack.MinimapShineFadeIn()
ItemRack.MinimapShineAlpha = .1
ItemRack.MinimapShineDirection = 1
ItemRackMinimapShine:Show()
ItemRack.StartTimer("MinimapShine")
end

--[[ Non-LoD options support ]]

function ItemRack.ToggleOptions(self,tab)
Expand Down
93 changes: 0 additions & 93 deletions ItemRack/ItemRack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,99 +43,6 @@
</Scripts>
</GameTooltip>

<Button name="ItemRackMinimapFrame" toplevel="true" frameStrata="HIGH" parent="Minimap" enableMouse="true" movable="true">
<Size>
<AbsDimension x="33" y="33"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="-15" y="0"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="ItemRackMinimapIcon" file="Interface\AddOns\ItemRack\ItemRackIcon">
<Size>
<AbsDimension x="21" y="21"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="7" y="-6"/>
</Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
<Layer level="ARTWORK">
<Texture file="Interface\Minimap\MiniMap-TrackingBorder">
<Size>
<AbsDimension x="56" y="56"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT"/>
</Anchors>
</Texture>
</Layer>
<Layer level="OVERLAY">
<Texture name="ItemRackMinimapGear" file="Interface\AddOns\ItemRack\ItemRackGear" hidden="true">
<Size>
<AbsDimension x="16" y="16"/>
</Size>
<Anchors>
<Anchor point="CENTER" relativeTo="ItemRackMinimapIcon" relativePoint="TOPLEFT">
<Offset x="2" y="-2"/>
</Anchor>
</Anchors>
</Texture>
<Texture name="ItemRackMinimapShine" file="Interface\ComboFrame\ComboPoint" alphaMode="ADD" hidden="true">
<Size x="32" y="32"/>
<Anchors>
<Anchor point="CENTER">
<Offset x="3" y="3"/>
</Anchor>
</Anchors>
<TexCoords left="0.5625" right="1" top="0" bottom="1"/>
</Texture>
</Layer>
</Layers>
<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
<Scripts>
<OnLoad>
self:RegisterForClicks("LeftButtonUp","RightButtonUp")
self:RegisterForDrag("LeftButton")
</OnLoad>
<OnMouseDown>
ItemRackMinimapIcon:SetTexCoord(.075,.925,.075,.925)
</OnMouseDown>
<OnMouseUp>
ItemRackMinimapIcon:SetTexCoord(0,1,0,1)
</OnMouseUp>
<OnEnter>
ItemRack.MinimapOnEnter(self)
</OnEnter>
<OnLeave>
GameTooltip:Hide()
</OnLeave>
<OnDragStart>
self:LockHighlight()
ItemRack.StartTimer("MinimapDragging")
ItemRackMinimapIcon:SetTexCoord(.075,.925,.075,.925)
</OnDragStart>
<OnDragStop>
ItemRack.StopTimer("MinimapDragging")
self:UnlockHighlight()
ItemRackMinimapIcon:SetTexCoord(0,1,0,1)
</OnDragStop>
<OnClick>
ItemRack.MinimapOnClick(self,button)
ItemRackMinimapIcon:SetTexCoord(0,1,0,1)
</OnClick>
</Scripts>
</Button>

<Frame name="ItemRackQueueTemplate" enableMouse="false" virtual="true">
<Size>
<AbsDimension x="20" y="20"/>
Expand Down
8 changes: 6 additions & 2 deletions ItemRack/ItemRackEvents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,21 @@ function ItemRack.ProcessBuffEvent()
end
end

local prevIcon
function ItemRack.ReflectEventsRunning()
if ItemRackUser.EnableEvents=="ON" and next(ItemRackUser.Events.Enabled) then
-- if events enabled and an event is enabled, show gear icons on set and minimap button
if ItemRackUser.Buttons[20] then
ItemRackButton20Queue:Show()
end
ItemRackMinimapGear:Show()
prevIcon = ItemRack.Broker.icon
ItemRack.Broker.icon = [[Interface\AddOns\ItemRack\ItemRackGear]]
else
if ItemRackUser.Buttons[20] then
ItemRackButton20Queue:Hide()
end
ItemRackMinimapGear:Hide()
if prevIcon then
ItemRack.Broker.icon = prevIcon
end
end
end
3 changes: 3 additions & 0 deletions ItemRack/Libs/Libs.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="LibStub\LibStub.lua"/>
<Include file="CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Script file="LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Script file="LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
</Ui>
5 changes: 2 additions & 3 deletions ItemRackOptions/ItemRackOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ function ItemRackOpt.OnLoad(self)
{type="check",optset=ItemRackSettings,variable="AllowHidden",label="Allow hidden items",tooltip="Enable Alt+clicking of menu items to hide/show them in the menu. Hold Alt as you enter a menu to show all."},
{type="check",optset=ItemRackSettings,variable="HideTradables",label="Hide tradables",tooltip="Prevent tradable items from showing up in the menu."},
{type="check",optset=ItemRackSettings,variable="ShowMinimap",label="Show minimap button",tooltip="Show the minimap button to access options or change sets."},
{type="check",optset=ItemRackSettings,variable="SquareMinimap",depend="ShowMinimap",label="Square minimap",tooltip="If you use a square minimap, make the button drag along square edge."},
{type="check",optset=ItemRackSettings,variable="MinimapTooltip",depend="ShowMinimap",label="Show minimap tooltip",tooltip="If tooltips enabled, show what mouse clicks will do when clicking the minimap button."},
{type="check",optset=ItemRackSettings,variable="TrinketMenuMode",label="TrinketMenu mode",tooltip="When mouseover of either trinket slot, open anchored to the top trinket. Left click of a menu item will equip to the top trinket. Right click will equip to the bottom trinket."},
{type="check",optset=ItemRackSettings,variable="AnchorOther",depend="TrinketMenuMode",label="Anchor other trinket",tooltip="In TrinketMenu mode, trinket menus dock to the top trinket. Check this to anchor them to the bottom trinket."},
Expand Down Expand Up @@ -824,8 +823,8 @@ function ItemRackOpt.OptListCheckButtonOnClick(self,override)
ItemRack.WriteMenuCooldowns()
elseif opt.variable=="LargeNumbers" then
ItemRack.ReflectCooldownFont()
elseif opt.variable=="ShowMinimap" or opt.variable=="SquareMinimap" then
ItemRack.MoveMinimap()
elseif opt.variable=="ShowMinimap" then
ItemRack.ShowMinimap()
elseif opt.variable=="EnableQueues" or opt.variable=="EnablePerSetQueues" then
ItemRack.UpdateCombatQueue()
elseif opt.variable=="ShowHotKeys" then
Expand Down

0 comments on commit 55a927d

Please sign in to comment.