Fix for changes made by Zenimax
Wobin [05-29-14 - 13:52]
Fix for changes made by Zenimax
Now swaps the Invite with whatever the last menu slot is to standardise location
diff --git a/PartyStarter.lua b/PartyStarter.lua
index 3ca5882..ac65021 100644
--- a/PartyStarter.lua
+++ b/PartyStarter.lua
@@ -13,10 +13,31 @@ end
function PartyStarter:AddLines(playerName, rawName)
local localPlayerIsGrouped = IsUnitGrouped("player")
local localPlayerIsGroupLeader = IsUnitGroupLeader("player")
+ local menu = ZO_Menu.items
+ local target = 0
+ for i,v in ipairs(menu) do
+ local label = GetControl(v.item, "Name")
+ if label:GetText() == GetString(SI_CHAT_PLAYER_CONTEXT_ADD_GROUP) then
+ target = i
+ end
+ end
+
+ -- This is rather messy, we can't just move menu items around as they're all
+ -- anchored to each other on -add-. So we just swap the functionality instead
+ local storedFunc = menu[target].item.OnSelect
+ local storedText = GetControl(menu[target].item, "Name"):GetText()
+
+ local lastFunc = menu[#menu].item.OnSelect
+ local lastText = GetControl(menu[#menu].item, "Name"):GetText()
+
+ menu[target].item.OnSelect = lastFunc
+ GetControl(menu[target].item, "Name"):SetText(lastText)
+ menu[#menu].item.OnSelect = storedFunc
+ GetControl(menu[#menu].item, "Name"):SetText(storedText)
- -- Our exceptions are guild members, or if you're in a group and not the leader (leaderbug)
- if IsDecoratedDisplayName(playerName) or (localPlayerIsGrouped and not localPlayerIsGroupLeader) then
- AddMenuItem(GetString(SI_CHAT_PLAYER_CONTEXT_ADD_GROUP), function() PartyStarter:Inform(playerName) TryGroupInviteByName(playerName) end)
+ -- If we can't find it, then lets add it
+ if target == 0 then
+ AddMenuItem(GetString(SI_CHAT_PLAYER_CONTEXT_ADD_GROUP), function() TryGroupInviteByName(playerName) end)
end
ShowMenu(nil, 1)
end
@@ -26,6 +47,7 @@ function PartyStarter:Loaded(...)
if addonName ~= "PartyStarter" then return end
ZO_PreHook(CHAT_SYSTEM, "ShowPlayerContextMenu", function(playerName, rawName) PartyStarter.ContextMenu(CHAT_SYSTEM, playerName, rawName) end)
+ ZO_PreHook("TryGroupInviteByName", function(name) PartyStarter:Inform(name) end)
end