Skip to content

Commit

Permalink
Rework frame to with the new PlayerSpellsFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasvienna committed Jul 25, 2024
1 parent 8210c79 commit 6260196
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
38 changes: 19 additions & 19 deletions ClickCastingTab/ClickCastingTab.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<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">
<CheckButton name="ClickCastingSkillLineTab" inherits="SpellBookSkillLineTabTemplate" parent="SpellBookSideTabsFrame" hidden="false">
<Scripts>
<OnClick>
if InClickBindingMode() then
ClickBindingFrame.SaveButton:Click()
else
ToggleClickBindingFrame()
end
</OnClick>
<OnShow>
self:SetChecked(InClickBindingMode())
self:ClearAllPoints()
self:SetPoint("TOPLEFT", _G["SpellBookSkillLineTab" .. GetNumSpellTabs()], "BOTTOMLEFT", 0, -40)
</OnShow>
</Scripts>
<NormalTexture file="Interface\Icons\trade_engineering" />
</CheckButton>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../FrameXML/UI.xsd">

<Button name="ClickCastingToggleButton" inherits="MagicButtonTemplate" text="Click Binding">
<Size x="120" y="22" />
<Scripts>
<OnClick>
ToggleClickBindingFrame()
self:Hide()
</OnClick>
<OnEnter>
GameTooltip:SetOwner(self, 'ANCHOR_BOTTOM');
GameTooltip:SetText("Click Cast Bindings");
GameTooltip:AddLine('Click to toggle the Click Cast Bindings mode');
GameTooltip:Show();
</OnEnter>
<OnLeave>GameTooltip:Hide()</OnLeave>
</Scripts>
</Button>
</Ui>
34 changes: 30 additions & 4 deletions ClickCastingTab/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,42 @@ local addonName, addon = ...
-- Globals
local _G = _G
---@class CheckButton
local ClickCastingSkillLineTab = _G.ClickCastingSkillLineTab -- our frame name, see ClickCastingTab.xml
local ClickCastingToggleButton = _G.ClickCastingToggleButton -- our frame name, see ClickCastingTab.xml
local spellBookAddonName = 'Blizzard_PlayerSpells'

-- Hooks
function OnShowHook(self)
if self:IsMinimized() then
ClickCastingToggleButton:Hide()
else
ClickCastingToggleButton:Show()
end
end

function OnSetMinimizedHook(self, isMinimized)
if isMinimized then
ClickCastingToggleButton:Hide()
else
ClickCastingToggleButton:Show()
end
end

-- Addon Core
addon.eventFrame = CreateFrame("Frame", addonName .. "EventFrame", UIParent)
addon.eventFrame:RegisterEvent("ADDON_LOADED")
addon.eventFrame:SetScript("OnEvent", function(frame, event, ...)
addon.eventFrame:SetScript("OnEvent", function(_, event, ...)
if event == "ADDON_LOADED" then
if ... == addonName then
local name = ...
if name == spellBookAddonName then
addon.eventFrame:UnregisterEvent("ADDON_LOADED")
ClickCastingSkillLineTab.tooltip = "Click Cast Bindings"
local PlayerSpellsFrame = _G.PlayerSpellsFrame
local SpellBookFrame = PlayerSpellsFrame.SpellBookFrame
PlayerSpellsFrame:HookScript("OnShow", OnShowHook)
hooksecurefunc(PlayerSpellsFrame, "SetMinimized", OnSetMinimizedHook)
-- TODO: check if IsMinimized and change anchor
ClickCastingToggleButton:ClearAllPoints()
ClickCastingToggleButton:SetParent(SpellBookFrame)
ClickCastingToggleButton:SetPoint("RIGHT", SpellBookFrame.SearchBox, "LEFT", -30, 0)
end
end
end)

0 comments on commit 6260196

Please sign in to comment.