end |
|
local function handleClick(name, icon) |
if(IsShiftKeyDown() and IsAltKeyDown()) then |
if(IsShiftKeyDown()) then |
local dialog = StaticPopup_Show('CONFIRM_OVERWRITE_EQUIPMENT_SET', name) |
dialog.data = name |
dialog.selectedIcon = GetTextureIndex(icon) -- Blizzard sucks |
elseif(IsControlKeyDown()) then |
local dialog = StaticPopup_Show('CONFIRM_DELETE_EQUIPMENT_SET', name) |
dialog.data = name |
elseif(IsControlKeyDown() and IsAltKeyDown()) then |
local dialog = StaticPopup_Show('CONFIRM_OVERWRITE_EQUIPMENT_SET', name) |
dialog.data = name |
dialog.selectedIcon = GetTextureIndex(icon) -- blizzard sucks |
elseif(EquipmentSetContainsLockedItems(name) or UnitOnTaxi('player') or UnitCastingInfo('player') or InCombatLockdown()) then |
return |
else |
elseif(not InCombatLockdown()) then |
EquipmentManager_EquipSet(name) |
|
Broker_EquipmentDB.text = name |
Broker_EquipmentDB.icon = icon |
end |
end |
|
local function initDropDown() |
for k, v in next, menuList do |
UIDropDownMenu_AddButton(v, level or 1) |
end |
end |
local function updateMenu() |
pendingUpdate = nil |
menu = wipe(menu) |
|
local function createDropDown() |
wipe(menuList) |
local title = {text = 'Broker Equipment\n ', isTitle = true} |
table.insert(menu, title) |
|
for index = 1, GetNumEquipmentSets() do |
local name, icon = GetEquipmentSetInfo(index) |
local info = {} |
info.index = index |
info.text = name |
info.icon = icon |
info.func = function() handleClick(name, icon) end |
|
menuList[index] = info |
local temp = { |
text = name, |
icon = icon, |
func = function() handleClick(name, icon) end |
} |
table.insert(menu, temp) |
end |
|
table.sort(menuList, function(a, b) return a.index < b.index end) |
UIDropDownMenu_Initialize(addon, initDropDown, 'MENU') |
pendingUpdate = nil |
end |
|
local function onEvent(self, event, arg1) |
if(event == 'EQUIPMENT_SETS_CHANGED') then |
pendingUpdate = true |
else |
if(arg1 ~= addonName) then return end |
|
Broker_EquipmentDB = Broker_EquipmentDB or {text = L.NOSET, icon = broker.icon} |
broker.text = Broker_EquipmentDB.text |
broker.icon = Broker_EquipmentDB.icon |
|
self:UnregisterEvent(event) |
for index = 1, 3 do |
local temp = {text = L.HINT[index], disabled = true} |
table.insert(menu, temp) |
end |
end |
|
function broker:OnClick(button) |
if(GameTooltip:GetOwner() == self) then |
GameTooltip:Hide() |
end |
if(button == 'RightButton') then |
if(GearManagerDialog:IsVisible()) then |
if(PaperDollFrame:IsVisible()) then |
ToggleCharacter('PaperDollFrame') |
end |
GearManagerDialog:Hide() |
else |
if(not PaperDollFrame:IsVisible()) then |
ToggleCharacter('PaperDollFrame') |
end |
GearManagerDialog:Show() |
end |
else |
if(pendingUpdate) then updateMenu() end |
EasyMenu(menu, BEQ, self, 0, 0, 'MENU') |
|
if(pendingUpdate) then |
createDropDown() |
if(GameTooltip:GetOwner() == self) then GameTooltip:Hide() end |
end |
|
ToggleDropDownMenu(1, nil, addon, self, 0, 0) |
end |
|
function broker:OnTooltipShow() |
self:AddLine('|cff0090ffBroker Equipment|r') |
self:AddLine(L.TOOLTIP1) |
self:AddLine(L.TOOLTIP2) |
self:AddLine(L.TOOLTIP3) |
end |
|
function BEQ:ADDON_LOADED(event, addon) |
if(addon ~= 'Broker_Equipment') then return end |
|
Broker_EquipmentDB = Broker_EquipmentDB or {text = L.NOSET, icon = broker.defaultIcon} |
broker.text = Broker_EquipmentDB.text |
broker.icon = Broker_EquipmentDB.icon |
|
self:UnregisterEvent(event) |
end |
|
function BEQ:EQUIPMENT_SETS_CHANGED() |
pendingUpdate = true |
end |
|
function BEQ:VARIABLES_LOADED() |
SetCVar('equipmentManager', 1) |
GearManagerToggleButton:Show() |
end |
|
hooksecurefunc('EquipmentManager_EquipSet', function(name) |
if(name and name ~= broker.text) then |
if(name) then |
local icon = GetEquipmentSetInfoByName(name) |
local propericon = icon:match('Interface') and icon or [=[Interface\Icons\]=] .. icon -- fixing blizzard's bug |
-- Blizzard has some odd bug not always returning the whole icon location string |
-- This is a temporary fix around it |
icon = icon:sub(1, 9) ~= 'Interface' and [=[Interface\Icons\]=] .. icon or icon |
|
broker.text = name |
broker.icon = propericon |
|
Broker_EquipmentDB.text = name |
Broker_EquipmentDB.icon = propericon |
broker.icon = icon or failIcon |
else |
broker.text = L.NOSET |
broker.icon = defaultIcon |
end |
end) |
|
addon:RegisterEvent('ADDON_LOADED') |
addon:RegisterEvent('EQUIPMENT_SETS_CHANGED') |
addon:SetScript('OnEvent', onEvent) |