From 587b175e916d7d592df55b4092e0a6ee7c0fe55c Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 7 Jul 2017 18:02:55 +0200 Subject: [PATCH] player: clean up dropdown code --- api/unitframes.lua | 4 +++- modules/player.lua | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 3fb9ca30..e9e33114 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -991,7 +991,9 @@ function pfUI.uf:ClickAction(button) -- dropdown menues if button == "RightButton" then if label == "player" then - ToggleDropDownMenu(1, nil, pfUI.uf.player.Dropdown,"cursor") + UIDropDownMenu_Initialize(PlayerFrameDropDown, pfUI.uf.player.dropdown.Init, "MENU") + pfUI.uf.player.dropdown.rebuild = true + ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor") elseif label == "target" then ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor") elseif label == "pet" then diff --git a/modules/player.lua b/modules/player.lua index 4a7be05b..2eccaa28 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -40,15 +40,14 @@ pfUI:RegisterModule("player", function () pfUI.uf.player:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", -75, 125) UpdateMovable(pfUI.uf.player) - pfUI.uf.player.Dropdown = getglobal("PlayerFrameDropDown") - function pfUI.uf.player.Dropdowni() - -- add reset button when alone - if not (UnitInRaid("player") or GetNumPartyMembers() > 0) then + pfUI.uf.player.dropdown = {} + function pfUI.uf.player.dropdown:Init() + UnitPopup_ShowMenu(PlayerFrameDropDown, "SELF", "player") + if pfUI.uf.player.dropdown.rebuild and not CanShowResetInstances() then UIDropDownMenu_AddButton({text = RESET_INSTANCES, func = ResetInstances, notCheckable = 1}, 1) + pfUI.uf.player.dropdown.rebuild = nil end - UnitPopup_ShowMenu(pfUI.uf.player.Dropdown, "SELF", "player") end - UIDropDownMenu_Initialize(pfUI.uf.player.Dropdown, pfUI.uf.player.Dropdowni, "MENU") pfUI.uf.player:RegisterEvent("UPDATE_FACTION") -- pvp icon pfUI.uf.player:RegisterEvent("UNIT_FACTION") -- pvp icon