Skip to content

Commit

Permalink
added new library to avoid DropDown taint using blizz API
Browse files Browse the repository at this point in the history
  • Loading branch information
Taidtuskecyh authored and Taidtuskecyh committed Sep 2, 2021
1 parent a8aed7c commit 7e117d6
Show file tree
Hide file tree
Showing 27 changed files with 2,855 additions and 186 deletions.
29 changes: 16 additions & 13 deletions CommunityDKP.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ local CommDKP = core.CommDKP;
local L = core.L;

local OptionsLoaded = false;
local LibDD = LibStub:GetLibrary("LibUIDropDownMenu-4.0");


function CommDKP_RestoreFilterOptions() -- restores default filter selections
CommDKP.UIConfig.search:SetText(L["SEARCH"])
Expand Down Expand Up @@ -373,22 +375,23 @@ function CommDKP:CreateMenu()
SortButtons.class.t = CreateFrame("FRAME", "CommDKPSortColDropdown", SortButtons.class, "CommunityDKPTableHeaderDropDownMenuTemplate")
SortButtons.class.t:SetPoint("CENTER", SortButtons.class, "CENTER", 4, -3)
UIDropDownMenu_JustifyText(SortButtons.class.t, "CENTER")
UIDropDownMenu_SetWidth(SortButtons.class.t, 80)
LibDD:UIDropDownMenu_SetWidth(SortButtons.class.t, 80)
UIDropDownMenu_SetText(SortButtons.class.t, L["CLASS"])
UIDropDownMenu_Initialize(SortButtons.class.t, function(self, level, menuList)
local reason = UIDropDownMenu_CreateInfo()
LibDD:UIDropDownMenu_Initialize(SortButtons.class.t, function(self, level, menuList)

local reason = LibDD:UIDropDownMenu_CreateInfo()
reason.func = self.SetValue
reason.fontObject = "CommDKPSmallCenter"
reason.text, reason.arg1, reason.arg2, reason.checked, reason.isNotRadio = L["CLASS"], "class", L["CLASS"], "class" == core.CenterSort, true
UIDropDownMenu_AddButton(reason)
LibDD:UIDropDownMenu_AddButton(reason)
reason.text, reason.arg1, reason.arg2, reason.checked, reason.isNotRadio = L["SPEC"], "spec", L["SPEC"], "spec" == core.CenterSort, true
UIDropDownMenu_AddButton(reason)
LibDD:UIDropDownMenu_AddButton(reason)
reason.text, reason.arg1, reason.arg2, reason.checked, reason.isNotRadio = L["RANK"], "rank", L["RANK"], "rank" == core.CenterSort, true
UIDropDownMenu_AddButton(reason)
LibDD:UIDropDownMenu_AddButton(reason)
reason.text, reason.arg1, reason.arg2, reason.checked, reason.isNotRadio = L["ROLE"], "role", L["ROLE"], "role" == core.CenterSort, true
UIDropDownMenu_AddButton(reason)
LibDD:UIDropDownMenu_AddButton(reason)
reason.text, reason.arg1, reason.arg2, reason.checked, reason.isNotRadio = L["VERSION"], "version", L["VERSION"], "version" == core.CenterSort, true
UIDropDownMenu_AddButton(reason)
LibDD:UIDropDownMenu_AddButton(reason)
end)
-- Dropdown Menu Function
function SortButtons.class.t:SetValue(newValue, arg2)
Expand Down Expand Up @@ -522,14 +525,14 @@ function CommDKP:CreateMenu()
GameTooltip:Hide()
end
)
UIDropDownMenu_SetWidth(CommDKP.UIConfig.TeamViewChangerDropDown, 150)
LibDD:UIDropDownMenu_SetWidth(CommDKP.UIConfig.TeamViewChangerDropDown, 150)
UIDropDownMenu_SetText(CommDKP.UIConfig.TeamViewChangerDropDown, CommDKP:GetCurrentTeamName())

-- Create and bind the initialization function to the dropdown menu
UIDropDownMenu_Initialize(CommDKP.UIConfig.TeamViewChangerDropDown,
LibDD:UIDropDownMenu_Initialize(CommDKP.UIConfig.TeamViewChangerDropDown,
function(self, level, menuList)

local dropDownMenuItem = UIDropDownMenu_CreateInfo()
local dropDownMenuItem = LibDD:UIDropDownMenu_CreateInfo()
dropDownMenuItem.func = self.SetValue
dropDownMenuItem.fontObject = "CommDKPSmallCenter"

Expand All @@ -541,7 +544,7 @@ function CommDKP:CreateMenu()
dropDownMenuItem.arg2 = teamList[i][1] -- index
dropDownMenuItem.checked = teamList[i][1] == tonumber(CommDKP:GetCurrentTeamIndex())
dropDownMenuItem.isNotRadio = true
UIDropDownMenu_AddButton(dropDownMenuItem)
LibDD:UIDropDownMenu_AddButton(dropDownMenuItem)
end
end
)
Expand Down
2 changes: 1 addition & 1 deletion CommunityDKP.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Title: |cff9900ffCommunity|r |cff595959DKP|r
## Author: Vapok-BloodsailBuccaneers
## Notes: Feature-rich DKP Management Tool
## Version: 3.2.7
## Version: 3.2.9
## DefaultState: enabled
## SavedVariables: CommDKP_DB, CommDKP_Loot, CommDKP_DKPTable, CommDKP_DKPHistory, CommDKP_MinBids, CommDKP_MaxBids, CommDKP_Whitelist, CommDKP_Standby, CommDKP_Archive, CommDKP_Profiles

Expand Down
44 changes: 44 additions & 0 deletions Libs/LibUIDropDownMenu/LibEasyMenu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
--$Id: LibEasyMenu.lua 64 2020-11-18 13:13:15Z arithmandar $
-- //////////////////////////////////////////////////////////////
-- Notes:
-- Functions have been moved to under LibUIDropDownMenu.lua
-- New function calls are as below:
--
-- - lib:EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay )
-- - lib:EasyMenu_Initialize( frame, level, menuList )
--
-- //////////////////////////////////////////////////////////////
-- Simplified Menu Display System
-- This is a basic system for displaying a menu from a structure table.
--
-- See UIDropDownMenu.lua for the menuList details.
--
-- Args:
-- menuList - menu table
-- menuFrame - the UI frame to populate
-- anchor - where to anchor the frame (e.g. CURSOR)
-- x - x offset
-- y - y offset
-- displayMode - border type
-- autoHideDelay - how long until the menu disappears
--
--
--[[
function EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay )
if ( displayMode == "MENU" ) then
menuFrame.displayMode = displayMode;
end
UIDropDownMenu_Initialize(menuFrame, EasyMenu_Initialize, displayMode, nil, menuList);
ToggleDropDownMenu(1, nil, menuFrame, anchor, x, y, menuList, nil, autoHideDelay);
end
function EasyMenu_Initialize( frame, level, menuList )
for index = 1, #menuList do
local value = menuList[index]
if (value.text) then
value.index = index;
UIDropDownMenu_AddButton( value, level );
end
end
end
]]
Loading

0 comments on commit 7e117d6

Please sign in to comment.