/branches
end |
]]); |
-- btnMinimap:SetAttribute("_onattributechanged", [[ |
-- if (name == "escpressed") then |
-- if self:GetFrameRef("dag_menu"):IsVisible() then |
-- control:Run(Close); |
-- end |
-- end |
-- ]]); |
btnMinimap:SetScript("OnDragStart", |
function(self, event, ...) |
self:StartMoving(); |
end |
) |
-- btnMinimap:SetScript("OnKeyDown", |
-- function(self, key, ...) |
-- if (key == "ESCAPE") then |
-- btnMinimap:SetAttribute("EscPressed", ""); |
-- end |
-- end |
-- ) |
--btnMinimap:EnableKeyboard(true); |
btnMinimap:RegisterForClicks("AnyDown"); |
btnMinimap:SetScript("OnEvent", function(self, event, ...) |
if (type(DagAssist[event]) == 'function') then |
DagAssist[event](self, event, ...); |
DagAssist[event](DagAssist, event); |
end |
end) |
btnMinimap:RegisterEvent("PLAYER_ENTERING_WORLD"); |
function DagAssist.OnUpdate(self, elapsed, ...) |
if (not DagAssist.MenuLoaded) then |
return; |
end |
if (DagAssist.AllIconsSet) then |
btnMinimap:SetScript("OnUpdate", nil); |
return; |
end |
if (self.TimeSinceLastUpdate) then |
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed; |
if (self.TimeSinceLastUpdate > 0.1) then |
self.TimeSinceLastUpdate = 0; |
local allIconsSet = true; |
for buttonIndex = 1, table.getn(DagAssist.Buttons) do |
local btn = DagAssist.Buttons[buttonIndex]; |
if (not btn.IconSet) then |
local actionInfo = DagAssistGetActionInfo(btn.Action.DA_ActionType, btn.Action.DA_ActionData, btn.Action.DA_ActionSubType); |
if (actionInfo.Name) then |
btn:SetText(actionInfo.Name); |
if (actionInfo.Texture) then |
btn.Texture:SetTexture(actionInfo.Texture); |
btn.IconSet = true; |
else |
btn.IconSet = false; |
allIconsSet = false; |
end |
else |
btn.IconSet = false; |
allIconsSet = false; |
end |
end |
end |
DagAssist.AllIconsSet = allIconsSet; |
end |
else |
self.TimeSinceLastUpdate = 0; |
end |
end |
btnMinimap:SetScript("OnUpdate", DagAssist.OnUpdate); |
function DagAssist:PositionMinimapButton() |
if (not DA_Vars) then |
DA_Vars = {Minimap = {}}; |
end |
end |
function DagAssist:PLAYER_ENTERING_WORLD(self, event) |
function DagAssist:PLAYER_ENTERING_WORLD(event) |
DagAssist:PositionMinimapButton(); |
DagAssist:LoadMenu(); |
DagAssist.MinimapButton:Show(); |
return; |
end |
DagAssist.MenuLoaded = false; |
DagAssist.AllIconsSet = false; |
btnMinimap:SetScript("OnUpdate", DagAssist.OnUpdate); |
btnMinimap:Execute([[ |
if (menuItems) then |
for i, button in ipairs(menuItems) do |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = DagAssist.LoadDefaultMenu() |
end |
if (not DagAssist.Buttons) then |
DagAssist.Buttons = {}; |
end |
local menuItems = DA_Vars.Menu; |
local btnMenuItem; |
for index = 1, table.getn(menuItems) do |
for actionIndex = 1, table.getn(section.Actions) do |
local action = section.Actions[actionIndex]; |
local actionInfo = DagAssistGetActionInfo(action.DA_ActionType, action.DA_ActionData, action.DA_ActionSubType); |
local actionInfo = DagAssistGetActionInfo(action.DA_ActionType, action.DA_ActionData, action.DA_ActionSubType) |
local buttonIndex = actionIndex + (index * 100); |
local buttonTexture; |
if action.DA_ActionType == "companion" or action.DA_ActionType == "equipmentset" then |
btnMenuItem = _G["DA_MenuButton"..buttonIndex]; |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuButton"..buttonIndex, menu, "SecureHandlerBaseTemplate, DA_MenuSpellButtonTemplate"); |
end |
btnMenuItem.Texture = _G["DA_MenuButton"..buttonIndex.."Icon"]; |
buttonTexture = _G["DA_MenuButton"..buttonIndex.."Icon"]; |
btnMenuItem.Action = action; |
if action.DA_ActionType == "companion" then |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuSecureButton"..buttonIndex, menu, "SecureActionButtonTemplate, SecureHandlerBaseTemplate, DA_MenuSpellButtonTemplate"); |
end |
btnMenuItem.Texture = _G["DA_MenuSecureButton"..buttonIndex.."Icon"]; |
btnMenuItem.Action = action; |
buttonTexture = _G["DA_MenuSecureButton"..buttonIndex.."Icon"]; |
if action.DA_ActionType == "item" then |
btnMenuItem:SetAttribute("type","item"); |
btnMenuItem:SetAttribute("enabled", true); |
btnMenuItem:SetFrameLevel(btnMenuItem:GetFrameLevel() + 1); |
if (actionInfo.Name) then |
btnMenuItem:SetText(actionInfo.Name); |
if (actionInfo.Texture) then |
btnMenuItem.Texture:SetTexture(actionInfo.Texture); |
btnMenuItem.IconSet = true; |
else |
btnMenuItem.IconSet = false; |
end |
else |
btnMenuItem.IconSet = false; |
end |
buttonTexture:SetTexture(actionInfo.Texture); |
btnMenuItem:SetText(actionInfo.Name); |
btnMenuItem:Show(); |
btnMinimap:SetFrameRef("child", btnMenuItem); |
btnMinimap:Execute([[ |
table.insert(menuItems, self:GetFrameRef("child")); |
]]); |
table.insert(DagAssist.Buttons, btnMenuItem); |
end |
end |
dag_menu:SetHeight(menuHeight); |
]]); |
DagAssist.MenuLoaded = true; |
end |
function DagAssist:PLAYER_REGEN_DISABLED(self, event) |
--DagAssist:SetMenuItemVisibility(); |
end |
function DagAssist:PLAYER_REGEN_ENABLED(self, event) |
function DagAssist:PLAYER_REGEN_ENABLED(event) |
if (DagAssist.ReloadNeeded) then |
DagAssist:LoadMenu(); |
DagAssist.ReloadNeeded = false; |
end |
end |
function DagAssist:BAG_UPDATE(self, event) |
--DagAssist:SetMenuItemVisibility(); |
end |
function DagAssist:LEARNED_SPELL_IN_TAB(self, event) |
--DagAssist:SetMenuItemVisibility(); |
end |
end |
) |
-- fraConfig.DagAssistLoaded = false; |
-- fraConfig:SetScript("OnEvent", |
-- function(self, event, ...) |
-- if (event == "ADDON_LOADED") then |
-- local name = ...; |
-- if (name == "DagAssist") then |
-- fraConfig.DagAssistLoaded = true; |
fraConfig.DagAssistLoaded = false; |
fraConfig:SetScript("OnEvent", |
function(self, event, ...) |
if (event == "ADDON_LOADED") then |
local name = ...; |
if (name == "DagAssist") then |
fraConfig.DagAssistLoaded = true; |
-- if (not DA_Vars) then |
-- DA_Vars = {}; |
-- end |
-- if (not DA_Vars.Menu) then |
-- DA_Vars.Menu = DagAssist.LoadDefaultMenu(); |
-- end |
if (not DA_Vars) then |
DA_Vars = {}; |
end |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = DagAssist.LoadDefaultMenu(); |
end |
-- end |
-- elseif (event == "PLAYER_ENTERING_WORLD") then |
-- if (fraConfig.DagAssistLoaded) then |
-- fraConfig:UnregisterEvent("PLAYER_ENTERING_WORLD"); |
-- DagAssistConfigLoadHeaders(); |
-- end |
-- end |
-- end |
-- ) |
-- fraConfig:RegisterEvent("ADDON_LOADED"); |
-- fraConfig:RegisterEvent("PLAYER_ENTERING_WORLD"); |
end |
elseif (event == "PLAYER_ENTERING_WORLD") then |
if (fraConfig.DagAssistLoaded) then |
fraConfig:UnregisterEvent("PLAYER_ENTERING_WORLD"); |
DagAssistConfigLoadHeaders(); |
end |
end |
end |
) |
fraConfig:RegisterEvent("ADDON_LOADED"); |
fraConfig:RegisterEvent("PLAYER_ENTERING_WORLD"); |
--Title |
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem); |
DagAssist.Config:Hide(); |
else |
DagAssistConfigLoadHeaders(); |
DagAssist.Config:Show(); |
end |
end |