Skip to content

Commit

Permalink
Remove Bigwigs Packager substitution keywords in code
Browse files Browse the repository at this point in the history
This make code from repository directly usable in all suported versions of the game and make dev easier
  • Loading branch information
mrbuds authored and Rottenbeer committed May 20, 2021
1 parent 52c97a8 commit ab7acb8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 49 deletions.
66 changes: 25 additions & 41 deletions ItemRack/ItemRack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ local _

ItemRack.Version = "3.63"

function ItemRack.IsClassic()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end

function ItemRack.IsBCC()
return WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
end

ItemRackUser = {
Sets = {}, -- user's sets
ItemsUsed = {}, -- items that have been used (for notify purposes)
Expand Down Expand Up @@ -215,12 +223,8 @@ function ItemRack.OnPlayerLogin()
ItemRack.InitEvents()
end

--@version-classic@
local loader = CreateFrame("Frame") -- need a new temp frame here, ItemRackFrame is not created yet
--@end-version-classic@
--@version-bcc@
local loader = CreateFrame("Frame",nil, self, BackdropTemplateMixin and "BackdropTemplate") -- need a new temp frame here, ItemRackFrame is not created yet
--@end-version-bcc@

loader:RegisterEvent("PLAYER_LOGIN")
loader:SetScript("OnEvent", ItemRack.OnPlayerLogin)

Expand Down Expand Up @@ -1189,25 +1193,15 @@ function ItemRack.CreateMenuButton(idx,itemID)
if itemID=="MENU" then return end
local button
if not _G["ItemRackMenu"..idx] then
--@version-classic@
button = CreateFrame("CheckButton","ItemRackMenu"..idx,ItemRackMenuFrame,"ActionButtonTemplate")
--@end-version-classic@
--@version-bcc@
button = CreateFrame("CheckButton","ItemRackMenu"..idx,ItemRackMenuFrame,BackdropTemplateMixin and "ActionButtonTemplate")
--@end-version-bcc@
button:SetID(idx)
button:SetFrameStrata("HIGH")
-- button:SetFrameLevel(ItemRackMenuFrame:GetFrameLevel()+1)
button:RegisterForClicks("LeftButtonUp","RightButtonUp")
button:SetScript("OnClick",ItemRack.MenuOnClick)
button:SetScript("OnEnter",ItemRack.MenuTooltip)
button:SetScript("OnLeave",ItemRack.ClearTooltip)
--@version-classic@
CreateFrame("Frame",nil,button,"ItemRackTimeTemplate")
--@end-version-classic@
--@version-bcc@
CreateFrame("Frame",nil,button,BackdropTemplateMixin and "ItemRackTimeTemplate")
--@end-version-bcc@

ItemRack.SetFont("ItemRackMenu"..idx)
-- local font = button:CreateFontString("ItemRackMenu"..idx.."Time","OVERLAY","NumberFontNormal")
Expand Down Expand Up @@ -1833,27 +1827,23 @@ function ItemRack.ToggleOptions(self,tab)
end

function ItemRack.ReflectLock(override)
--@version-bcc@
Mixin(ItemRackMenuFrame, BackdropTemplateMixin)
--@end-version-bcc@
if BackdropTemplateMixin then
Mixin(ItemRackMenuFrame, BackdropTemplateMixin)
end
ItemRackMenuFrame:SetBackdrop(
{
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
}
);
if ItemRackUser.Locked=="ON" or override then
ItemRackMenuFrame:EnableMouse(0)
--@version-bcc@
ItemRackMenuFrame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }});
--@end-version-bcc@
ItemRackMenuFrame:SetBackdropBorderColor(0,0,0,0)
ItemRackMenuFrame:SetBackdropColor(0,0,0,0)
else
ItemRackMenuFrame:EnableMouse(1)
--@version-bcc@
ItemRackMenuFrame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 }});
--@end-version-bcc@
ItemRackMenuFrame:SetBackdropBorderColor(.3,.3,.3,1)
ItemRackMenuFrame:SetBackdropColor(1,1,1,1)
end
Expand Down Expand Up @@ -1951,12 +1941,7 @@ function ItemRack.SetSetBindings()
for i in pairs(ItemRackUser.Sets) do
if ItemRackUser.Sets[i].key then
buttonName = "ItemRack"..UnitName("player")..GetRealmName()..i
--@version-classic@
button = _G[buttonName] or CreateFrame("Button",buttonName,nil,"SecureActionButtonTemplate")
--@end-version-classic@
--@version-bcc@
button = _G[buttonName] or CreateFrame("Button",buttonName,nil,BackdropTemplateMixin and "SecureActionButtonTemplate")
--@end-version-bcc@

button:SetAttribute("type","macro")
local macrotext = "/script ItemRack.RunSetBinding(\""..i.."\")\n"
Expand All @@ -1972,12 +1957,11 @@ function ItemRack.SetSetBindings()
SetBindingClick(ItemRackUser.Sets[i].key,buttonName)
end
end
--@version-classic@
AttemptToSaveBindings(GetCurrentBindingSet())
--@end-version-classic@
--@version-bcc@
SaveBindings(GetCurrentBindingSet())
--@end-version-bcc@
if ItemRack.IsClassic() then
AttemptToSaveBindings(GetCurrentBindingSet())
elseif ItemRack.IsBCC() then
SaveBindings(GetCurrentBindingSet())
end
else
ItemRack.Print("Cannot save hotkeys in combat, please try again out of combat!")
end
Expand Down
5 changes: 0 additions & 5 deletions ItemRackOptions/ItemRackOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -912,12 +912,7 @@ end
function ItemRackOpt.BindSet()
local setname = ItemRackOptSetsName:GetText()
ItemRackOpt.Binding = { type="Set", name="Set \""..setname.."\"", buttonName="ItemRack"..UnitName("player")..GetRealmName()..setname }
--@version-classic@
ItemRackOpt.Binding.button = _G[buttonName] or CreateFrame("Button",ItemRackOpt.Binding.buttonName,nil,"SecureActionButtonTemplate")
--@end-version-classic@
--@version-bcc@
ItemRackOpt.Binding.button = _G[buttonName] or CreateFrame("Button",ItemRackOpt.Binding.buttonName,nil,BackdropTemplateMixin and "SecureActionButtonTemplate")
--@end-version-bcc@

ItemRackOptBindFrame:Show()
end
Expand Down
6 changes: 3 additions & 3 deletions ItemRackOptions/ItemRackOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3193,9 +3193,9 @@
</Frames>
<Scripts>
<OnLoad>
<!--@version-bcc@-->
Mixin(self, BackdropTemplateMixin)
<!--@end-version-bcc@-->
if BackdropTemplateMixin then
Mixin(self, BackdropTemplateMixin)
end
self:SetBackdropColor(.1,.1,.1,1)
</OnLoad>
</Scripts>
Expand Down

0 comments on commit ab7acb8

Please sign in to comment.