Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2011 21:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1518409 to your computer and use it in GitHub Desktop.
Save anonymous/1518409 to your computer and use it in GitHub Desktop.
Wow Lua Code for inserting menu items into dropdowns
This is what I am using atm.
function MG:UnitPopup_HideButtons()
local k
local dropdownMenu = UIDROPDOWNMENU_INIT_MENU
for index, value in ipairs(UnitPopupMenus[UIDROPDOWNMENU_MENU_VALUE] or UnitPopupMenus[dropdownMenu.which]) do
if value == "METAGUILD_INVITE" then
k = (not self:CanInvite(dropdownMenu.name) or dropdownMenu.name == UnitName("player")) and 0 or 1
UnitPopupShown[UIDROPDOWNMENU_MENU_LEVEL][index] = k
elseif value == "METAGUILD_KICK" then
k = (not self:CanKick(dropdownMenu.name) or dropdownMenu.name == UnitName("player")) and 0 or 1
UnitPopupShown[UIDROPDOWNMENU_MENU_LEVEL][index] = k
end
end
end
function MG:UnitPopup_OnClick(widget)
local button = widget.value
local dropdownFrame = UIDROPDOWNMENU_INIT_MENU
local name = dropdownFrame.name
if button == "METAGUILD_INVITE" then
self:SendInvite(name)
elseif button == "METAGUILD_KICK" then
StaticPopup_Show("REMOVE_METAGUILDMEMBER")
elseif button == "METAGUILD_SYNC" then
self:SyncDatabaseWithPlayer(name)
end
PlaySound("UChatScrollButton")
end
function MG:InitRightClickMenu()
local function insertbefore(t, before, val)
for k,v in ipairs(t) do
if v == before then
return table.insert(t, k, val)
end
end
table.insert(t, val)
end
UnitPopupButtons["METAGUILD_INVITE"] = { text = "MetaGuild Invite", dist = 0 }
UnitPopupButtons["METAGUILD_KICK"] = { text = "MetaGuild Kick", dist = 0 }
UnitPopupButtons["METAGUILD_SYNC"] = { text = "MetaGuild Sync", dist = 0 }
rightClickFunctions = {["METAGUILD_INVITE"] = MetaGuildInvite, ["METAGUILD_KICK"] = MetaGuildKick}
insertbefore(UnitPopupMenus["PLAYER"], "CANCEL", "METAGUILD_INVITE")
insertbefore(UnitPopupMenus["RAID_PLAYER"], "CANCEL", "METAGUILD_INVITE")
insertbefore(UnitPopupMenus["PARTY"], "CANCEL", "METAGUILD_INVITE")
insertbefore(UnitPopupMenus["FRIEND"], "CANCEL", "METAGUILD_INVITE")
insertbefore(UnitPopupMenus["PLAYER"], "CANCEL", "METAGUILD_SYNC")
insertbefore(UnitPopupMenus["RAID_PLAYER"], "CANCEL", "METAGUILD_SYNC")
insertbefore(UnitPopupMenus["FRIEND"], "CANCEL", "METAGUILD_SYNC")
insertbefore(UnitPopupMenus["PARTY"], "CANCEL", "METAGUILD_SYNC")
insertbefore(UnitPopupMenus["SELF"], "CANCEL", "METAGUILD_SYNC")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment