Skip to content

Commit

Permalink
2.5.2
Browse files Browse the repository at this point in the history
- fix reworked DropDown error
- libs: replaced community patches with TaintLess
  • Loading branch information
exochron authored Oct 19, 2020
1 parent f169dc5 commit 22f4967
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 106 deletions.
63 changes: 63 additions & 0 deletions Libs/TaintLess.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<Ui><Script><![CDATA[--[[
TaintLess [20-10-19]
https://www.townlong-yak.com/addons/taintless
All rights reserved.
Permission is hereby granted to distribute unmodified copies of this file.
]]
local function purgeKey(t, k)
t[k] = nil
local c = 42
repeat
if t[c] == nil then
t[c] = nil
end
c = c + 1
until issecurevariable(t, k)
end
-- https://www.townlong-yak.com/bugs/Mx7CWN-RefreshOverread
if (tonumber(UIDD_REFRESH_OVERREAD_PATCH_VERSION) or 0) < 3 then
UIDD_REFRESH_OVERREAD_PATCH_VERSION = 3
hooksecurefunc("UIDropDownMenu_InitializeHelper", function()
if UIDD_REFRESH_OVERREAD_PATCH_VERSION ~= 3 then
return
end
for i=1, UIDROPDOWNMENU_MAXLEVELS do
for j=1+_G["DropDownList" .. i].numButtons, UIDROPDOWNMENU_MAXBUTTONS do
local b, _ = _G["DropDownList" .. i .. "Button" .. j]
_ = issecurevariable(b, "checked") or purgeKey(b, "checked")
_ = issecurevariable(b, "notCheckable") or purgeKey(b, "notCheckable")
end
end
end)
end
-- https://www.townlong-yak.com/bugs/Kjq4hm-DisplayModeTaint
if (tonumber(UIDROPDOWNMENU_OPEN_PATCH_VERSION) or 0) < 1 then
UIDROPDOWNMENU_OPEN_PATCH_VERSION = 1
hooksecurefunc("UIDropDownMenu_InitializeHelper", function(frame)
if UIDROPDOWNMENU_OPEN_PATCH_VERSION ~= 1 then
return
end
if UIDROPDOWNMENU_OPEN_MENU and UIDROPDOWNMENU_OPEN_MENU ~= frame
and not issecurevariable(UIDROPDOWNMENU_OPEN_MENU, "displayMode") then
purgeKey(_G, "UIDROPDOWNMENU_OPEN_MENU")
end
end)
end
-- https://www.townlong-yak.com/bugs/gXwH4P-IOFrameSelection
if (tonumber(IOFRAME_SELECTION_PATCH_VERSION) or 0) < 1 then
IOFRAME_SELECTION_PATCH_VERSION = 1
InterfaceOptionsFrame:HookScript("OnHide", function()
if IOFRAME_SELECTION_PATCH_VERSION == 1 then
InterfaceOptionsFrameCategories.selection = nil
end
end)
end
]]></Script></Ui>
58 changes: 0 additions & 58 deletions Libs/UIDropdownMenu.lua

This file was deleted.

21 changes: 14 additions & 7 deletions ToyBoxEnhanced.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ local function FireCallbacks(callbacks)
end
--endregion

function ADDON:LoadUI()
local function LoadUI()
PetJournal:HookScript("OnShow", function() if (not PetJournalPetCard.petID) then PetJournal_ShowPetCard(1) end end)

FireCallbacks(loadUICallbacks)
self:FilterAndRefresh()
ADDON:FilterAndRefresh()
end

function ADDON:FilterAndRefresh()
Expand Down Expand Up @@ -71,7 +71,7 @@ function ADDON:FilterToys()
self.filteredToyList = filteredToyList
end

function ADDON:OnLogin()
local function OnLogin()
ResetAPIFilters()

for toyIndex = 1, C_ToyBox.GetNumFilteredToys() do
Expand All @@ -84,20 +84,27 @@ function ADDON:OnLogin()
FireCallbacks(loginCallbacks)
end

local loggedIn = false
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("TOYS_UPDATED")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
frame:SetScript("OnEvent", function(self, event, arg1)
if event == "PLAYER_LOGIN" then
ADDON:OnLogin()
if event == "PLAYER_LOGIN" and false == loggedIn then
loggedIn = true
OnLogin()
end

if ToyBox and not ADDON.initialized and ADDON.settings then
if false == loggedIn then
loggedIn = true
frame:UnregisterEvent("PLAYER_LOGIN")
OnLogin()
end
frame:UnregisterEvent("ADDON_LOADED")
ADDON:LoadUI()
LoadUI()
ADDON.initialized = true
elseif ADDON.initialized and ToyBox:IsVisible() and (event == "TOYS_UPDATED" or event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_REGEN_DISABLED") then
ADDON:FilterAndRefresh()
Expand Down
2 changes: 1 addition & 1 deletion ToyBoxEnhanced.toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## SavedVariablesPerCharacter: ToyBoxEnhancedSettings
## X-Curse-Project-ID: 87878

Libs\UIDropdownMenu.lua
Libs\TaintLess.xml

Locals\enUS.lua
Locals\deDE.lua
Expand Down
91 changes: 51 additions & 40 deletions UI/OptionsMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,73 @@ local ADDON_NAME, ADDON = ...
local function InitMenu(sender, level)
local itemId = sender.itemId

local info = MSA_DropDownMenu_CreateInfo()
info.notCheckable = true
info.disabled = nil
local info

if (itemId and PlayerHasToy(itemId)) then
if itemId and PlayerHasToy(itemId) then
local isFavorite = C_ToyBox.GetIsFavorite(itemId)

if (isFavorite) then
info.text = BATTLE_PET_UNFAVORITE
info.func = function()
C_ToyBox.SetIsFavorite(itemId, false)
end
if isFavorite then
info = {
notCheckable = true,
text = BATTLE_PET_UNFAVORITE,
func = function()
C_ToyBox.SetIsFavorite(itemId, false)
end
}
UIDropDownMenu_AddButton(info, level)
else
info.text = BATTLE_PET_FAVORITE
info.func = function()
C_ToyBox.SetIsFavorite(itemId, true)
SetCVarBitfield("closedInfoFrames", LE_FRAME_TUTORIAL_TOYBOX_FAVORITE, true)
HelpTip:Hide(ToyBox, TOYBOX_FAVORITE_HELP)
end
info = {
notCheckable = true,
text = BATTLE_PET_FAVORITE,
func = function()
C_ToyBox.SetIsFavorite(itemId, true)
SetCVarBitfield("closedInfoFrames", LE_FRAME_TUTORIAL_TOYBOX_FAVORITE, true)
HelpTip:Hide(ToyBox, TOYBOX_FAVORITE_HELP)
end
}
UIDropDownMenu_AddButton(info, level)
end

MSA_DropDownMenu_AddButton(info, level)
info.disabled = nil
end

local isHidden = itemId and ADDON.settings.hiddenToys[itemId]
if (isHidden) then
info.text = SHOW
info.func = function()
ADDON.settings.hiddenToys[itemId] = nil
ADDON:FilterAndRefresh()
end
if isHidden then
info = {
notCheckable = true,
text = SHOW,
func = function()
ADDON.settings.hiddenToys[itemId] = nil
ADDON:FilterAndRefresh()
end
}
UIDropDownMenu_AddButton(info, level)
else
info.text = HIDE
info.func = function()
ADDON.settings.hiddenToys[itemId] = true
ADDON:FilterAndRefresh()
end
info = {
notCheckable = true,
text = HIDE,
func = function()
ADDON.settings.hiddenToys[itemId] = true
ADDON:FilterAndRefresh()
end
}
UIDropDownMenu_AddButton(info, level)
end
MSA_DropDownMenu_AddButton(info, level)
info.disabled = nil

info.text = CANCEL
info.func = nil
MSA_DropDownMenu_AddButton(info, level)
info = {
notCheckable = true,
text = CANCEL,
}
UIDropDownMenu_AddButton(info, level)
end

ADDON:RegisterLoadUICallback( function()
local menu = MSA_DropDownMenu_Create(ADDON_NAME .. "ToyMenu", ToyBox)
MSA_DropDownMenu_Initialize(menu, InitMenu, "MENU")
ADDON:RegisterLoadUICallback(function()
local menu = CreateFrame("Frame", ADDON_NAME .. "ToyMenu", ToyBox, "UIDropDownMenuTemplate")
UIDropDownMenu_Initialize(menu, InitMenu, "MENU")

for i = 1, ADDON.TOYS_PER_PAGE do
ToyBox.EnhancedLayer["spellButton"..i]:HookScript("OnClick", function(sender, button)
if (not IsModifiedClick() and not sender.isPassive and button ~= "LeftButton") then
ToyBox.EnhancedLayer["spellButton" .. i]:HookScript("OnClick", function(sender, button)
if not IsModifiedClick() and not sender.isPassive and button ~= "LeftButton" then
menu.itemId = sender.itemID
MSA_ToggleDropDownMenu(1, nil, menu, sender, 0, 0)
ToggleDropDownMenu(1, nil, menu, sender, 0, 0)
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
end
end)
Expand Down

0 comments on commit 22f4967

Please sign in to comment.