/branches
end |
end |
-- Setup slash command for resetting variables and position |
SLASH_DAGASSIST1, SLASH_DAGASSIST2 = '/dagassist', '/da'; |
function DagAssist.SlashHandler(msg, editbox) |
local title = GetAddOnMetadata("DagAssist", "title").." v"..GetAddOnMetadata("DagAssist", "version"); |
if msg == 'reset' then |
if (InCombatLockdown() == 1) then |
print("<"..title.."> Reset cannot be completed in combat!"); |
else |
DA_Vars = {Minimap = {}}; |
DagAssist.LoadMenu(); |
DagAssistConfigLoadHeaders(); |
DagAssist:PositionMinimapButton(); |
print("<"..title.."> Reset complete"); |
end |
else |
print("<"..title.."> Usage: /da [reset]"); |
end |
end |
SlashCmdList["DAGASSIST"] = DagAssist.SlashHandler; |
--Set up the minimap button |
DagAssist.MinimapButton = CreateFrame("Button", "DA_Minimap", Minimap, "SecureHandlerClickTemplate, DA_MinimapButton"); |
local btnMinimap = DagAssist.MinimapButton; |
btnMinimap:SetFrameRef("dag_menu", DagAssist.Menu); |
--Pressing ESC will close the menu out of combat |
tinsert(UISpecialFrames,DagAssist.Menu:GetName()); --http://forums.wowace.com/showthread.php?t=17709 |
DagAssist.Menu.IsShownOld = DagAssist.Menu.IsShown; |
DagAssist.Menu.IsShown = function(self, ...) |
if (InCombatLockdown() == 1) then |
return false; |
else |
return DagAssist.Menu:IsShownOld(); |
end |
end |
-- tinsert(UISpecialFrames,DagAssist.Menu:GetName()); --http://forums.wowace.com/showthread.php?t=17709 |
-- DagAssist.Menu.HideOld = DagAssist.Menu.Hide; |
-- DagAssist.Menu.Hide = function(self) |
-- if (InCombatLockdown() ~= 1) then |
-- DagAssist.Menu:HideOld(); |
-- end |
-- end |
DagAssist.Menu:Hide(); |
btnMinimap:Execute([[ |
end) |
btnMinimap:RegisterEvent("PLAYER_ENTERING_WORLD"); |
function DagAssist:PositionMinimapButton() |
function DagAssist:PLAYER_ENTERING_WORLD(event) |
if (not DA_Vars) then |
DA_Vars = {Minimap = {}}; |
end |
if (not DA_Vars.Minimap) then |
DA_Vars.Minimap = {}; |
end |
if (DA_Vars.Minimap.X and DA_Vars.Minimap.Y) then |
--Restore last position |
local s = btnMinimap:GetEffectiveScale(); |
btnMinimap:ClearAllPoints() |
btnMinimap:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", DA_Vars.Minimap.X / s, DA_Vars.Minimap.Y /s); |
else |
btnMinimap:ClearAllPoints() |
btnMinimap:SetPoint("CENTER", Minimap, "BOTTOMLEFT", 15, 15); |
end |
end |
function DagAssist:PLAYER_ENTERING_WORLD(event) |
DagAssist:PositionMinimapButton(); |
DagAssist:LoadMenu(); |
DagAssist.MinimapButton:Show(); |
local menu = DagAssist.Menu; |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = DagAssist.LoadDefaultMenu() |
DA_Vars.Menu = {{Name="Default", Actions={}}}; |
end |
local menuItems = DA_Vars.Menu; |
local btnMenuItem; |
-- DagAssist -- |
-- Dagos of Cenarius -- |
------------------------------------------------ |
4.03 |
* Added instructions to the configuration panel |
* Added move up/down buttons to the section editor |
* Pressing ESC will now close the menu except while in combat |
* Menu items are prepopulated with some defaults when first installed |
4.01 |
* Configurable! |
## Title: DagAssist |
## Author: Dagos (Cenarius) |
## Notes: Convenient shortcut menu |
## Version: 4.03 |
## Version: 4.02 |
## DefaultState: enabled |
## LoadOnDemand: 0 |
## SavedVariablesPerCharacter: DA_Vars |
------------------------------------------------ |
------------------------------------------------ |
-- DagAssistConfig -- |
-- Dagos of Cenarius -- |
------------------------------------------------ |
fraConfig:RegisterForDrag("LeftButton"); |
fraConfig:SetToplevel(true); |
fraConfig:SetMovable(true); |
fraConfig:SetSize(384, 572); |
fraConfig:SetSize(384, 512); |
fraConfig:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 100, -100); |
fraConfig:SetClampedToScreen(true); |
fraConfig:Hide(); |
fraConfig.configBackdrop = { |
local configBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, |
edgeSize = 13, |
insets = {left = 4, right = 4, top = 4, bottom = 4} |
} |
fraConfig:SetBackdrop(fraConfig.configBackdrop); |
fraConfig:SetBackdrop(configBackdrop); |
fraConfig:SetBackdropColor(0, 0, 0, 0.9); |
fraConfig:SetScript("OnMouseDown", |
end |
) |
fraConfig.DagAssistLoaded = false; |
local DagAssistLoaded = false; |
fraConfig:SetScript("OnEvent", |
function(self, event, ...) |
if (event == "ADDON_LOADED") then |
local name = ...; |
if (name == "DagAssist") then |
fraConfig.DagAssistLoaded = true; |
DagAssistLoaded = true; |
if (not DA_Vars) then |
DA_Vars = {}; |
end |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = DagAssist.LoadDefaultMenu(); |
DA_Vars.Menu = {{Name="Default", Actions={}}}; |
end |
end |
elseif (event == "PLAYER_ENTERING_WORLD") then |
if (fraConfig.DagAssistLoaded) then |
if (DagAssistLoaded) then |
fraConfig:UnregisterEvent("PLAYER_ENTERING_WORLD"); |
DagAssistConfigLoadHeaders(); |
end |
--Title |
fraConfig.lblTitle = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge"); |
fraConfig.lblTitle:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 16, -16); |
fraConfig.lblTitle:SetHeight(25); |
fraConfig.lblTitle:SetText(GetAddOnMetadata("DagAssist", "title").." v"..GetAddOnMetadata("DagAssist", "version")); |
local lblTitle = fraConfig:CreateFontString(nil, "OVERLAY", "NumberFont_Outline_Large"); |
lblTitle:SetPoint("TOP", fraConfig, "TOP", 0, -2); |
lblTitle:SetHeight(25); |
lblTitle:SetText("DagAssist Configuration"); |
-- Instructions |
fraConfig.lblInstructions = fraConfig:CreateFontString(nil, 'ARTWORK'); |
fraConfig.lblInstructions:SetFont("Fonts\\FRIZQT__.TTF", 10, nil); |
fraConfig.lblInstructions:SetPoint("TOPLEFT", fraConfig.lblTitle, "BOTTOMLEFT", 5, -5); |
fraConfig.lblInstructions:SetWidth(340); |
fraConfig.lblInstructions:SetJustifyH("LEFT"); |
fraConfig.lblInstructions:SetText("Please drag abilities/items for the selected menu section to the action slots below. ".. |
"New sections can be created by typing in the New Section box and pressing Enter."); |
fraConfig.lblInstructions:SetTextColor(1,1,1,1); |
--Set up the group frame |
DagAssist.SectionGroup = CreateFrame("Frame", "DA_ConfigFrame", fraConfig); |
DagAssist.SectionGroup:EnableMouse(true); |
DagAssist.SectionGroup:SetSize(344, 80); |
DagAssist.SectionGroup:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 18, -80); |
DagAssist.SectionGroup:SetBackdrop(fraConfig.configBackdrop); |
DagAssist.SectionGroup:SetBackdropColor(1, 1, 1, 0.2); |
--Header list |
fraConfig.cboHeaders = CreateFrame("Frame", "DagAssistConfigHeaderList", fraConfig, "DA_Combobox"); |
fraConfig.cboHeaders:SetPoint("TOPLEFT", DagAssist.SectionGroup, "TOPLEFT", -5, -20) |
function fraConfig.cboHeaders:OnClickEvent(selectedItem) |
DagAssistConfigSaveSection(fraConfig.cboHeaders.PreviousItem); |
local cboHeaders = CreateFrame("Frame", "DagAssistConfigHeaderList", fraConfig, "DA_Combobox"); |
cboHeaders:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 8, -60) |
function cboHeaders:OnClickEvent(selectedItem) |
DagAssistConfigSaveSection(cboHeaders.PreviousItem); |
DagAssistConfigLoadSection(selectedItem); |
end |
--Section label |
fraConfig.lblMenuSection = DagAssist.SectionGroup:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
fraConfig.lblMenuSection:SetPoint("BOTTOMLEFT", fraConfig.cboHeaders, "TOPLEFT", 18, 0); |
fraConfig.lblMenuSection:SetHeight(15); |
fraConfig.lblMenuSection:SetText("Section"); |
fraConfig.lblMenuSection:SetTextColor(1,1,0,1); |
local lblMenuSection = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblMenuSection:SetPoint("BOTTOMLEFT", cboHeaders, "TOPLEFT", 18, 0); |
lblMenuSection:SetHeight(15); |
lblMenuSection:SetText("Sections"); |
-- Move up button |
fraConfig.btnMoveUp = CreateFrame("Button", "DagAssistConfigMoveUpButton", DagAssist.SectionGroup, "DA_Button2"); |
fraConfig.btnMoveUp:SetSize(55, 25); |
fraConfig.btnMoveUp:SetPoint("TOPLEFT", fraConfig.cboHeaders, "TOPRIGHT", -15, 0); |
fraConfig.btnMoveUp:SetText("Up"); |
fraConfig.btnMoveUp:SetScript("OnClick", |
function(self, event, ...) |
if (DA_Vars.Menu) then |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then |
if (index ~= 1) then |
table.remove(DA_Vars.Menu, index); |
table.insert(DA_Vars.Menu, index-1, sectionData); |
DagAssistConfigLoadHeaders(sectionData.Name); |
end |
return; |
end |
end |
end |
end |
) |
-- Move up button |
fraConfig.btnMoveDown = CreateFrame("Button", "DagAssistConfigMoveDownButton", DagAssist.SectionGroup, "DA_Button2"); |
fraConfig.btnMoveDown:SetSize(55, 25); |
fraConfig.btnMoveDown:SetPoint("TOPLEFT", fraConfig.btnMoveUp, "TOPRIGHT", 2, 0); |
fraConfig.btnMoveDown:SetText("Down"); |
fraConfig.btnMoveDown:SetScript("OnClick", |
function(self, event, ...) |
if (DA_Vars.Menu) then |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then |
if (index ~= table.getn(DA_Vars.Menu)) then |
table.remove(DA_Vars.Menu, index); |
table.insert(DA_Vars.Menu, index+1, sectionData); |
DagAssistConfigLoadHeaders(sectionData.Name); |
end |
return; |
end |
end |
end |
end |
) |
--Delete button |
fraConfig.btnDelete = CreateFrame("Button", "DagAssistConfigDeleteButton", DagAssist.SectionGroup, "DA_Button2"); |
fraConfig.btnDelete:SetSize(65, 25); |
fraConfig.btnDelete:SetPoint("TOPLEFT", fraConfig.btnMoveDown, "TOPRIGHT", 2, 0); |
fraConfig.btnDelete:SetText("Delete"); |
fraConfig.btnDelete:SetScript("OnClick", |
local btnDelete = CreateFrame("Button", "DagAssistConfigDeleteButton", fraConfig, "DA_Button2"); |
btnDelete:SetSize(35, 25); |
btnDelete:SetPoint("TOPLEFT", cboHeaders, "TOPRIGHT", -15, 0); |
btnDelete:SetText("Del"); |
btnDelete:SetScript("OnClick", |
function(self, event, ...) |
if (DA_Vars.Menu) then |
if (table.getn(DA_Vars.Menu) == 1) then |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then |
if (sectionData.Name == cboHeaders.SelectedItem) then |
table.remove(DA_Vars.Menu, index); |
break; |
end |
) |
--New header editbox |
fraConfig.txtNewHeader = CreateFrame("EditBox", "DagAssistConfigNewHeader", DagAssist.SectionGroup, "DA_Editbox"); |
fraConfig.txtNewHeader:SetSize(150, 25); |
fraConfig.txtNewHeader:SetPoint("TOPLEFT", fraConfig.cboHeaders, "BOTTOMRIGHT", -45, 5); |
fraConfig.txtNewHeader:SetAutoFocus(false); |
function fraConfig.txtNewHeader:OnEnterEvent(editText) |
local txtNewHeader = CreateFrame("EditBox", "DagAssistConfigNewHeader", fraConfig, "DA_Editbox"); |
txtNewHeader:SetSize(150, 25); |
txtNewHeader:SetPoint("TOPLEFT", btnDelete, "TOPRIGHT", 5, 0); |
txtNewHeader:SetAutoFocus(false); |
function txtNewHeader:OnEnterEvent(editText) |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = DagAssist.LoadDefaultMenu(); |
DA_Vars.Menu = {{Name="Default"}}; |
end |
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem); |
DagAssistConfigSaveSection(cboHeaders.SelectedItem); |
local newSection = {}; |
newSection.Name = editText; |
end |
--New section label |
fraConfig.lblNewSection = DagAssist.SectionGroup:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
fraConfig.lblNewSection:SetPoint("RIGHT", fraConfig.txtNewHeader, "LEFT", -5, 0); |
fraConfig.lblNewSection:SetHeight(15); |
fraConfig.lblNewSection:SetText("New Section"); |
fraConfig.lblNewSection:SetTextColor(1,1,0,1); |
local lblNewSection = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblNewSection:SetPoint("BOTTOMLEFT", txtNewHeader, "TOPLEFT", 0, 0); |
lblNewSection:SetHeight(15); |
lblNewSection:SetText("New Section"); |
--Close button |
fraConfig.btnClose = CreateFrame("Button", "DagAssistConfigDeleteButton", fraConfig, "DA_Button2"); |
fraConfig.btnClose:SetSize(35, 20); |
fraConfig.btnClose:SetPoint("BOTTOMRIGHT", fraConfig, "BOTTOMRIGHT", -10, 10); |
fraConfig.btnClose:SetText("OK"); |
fraConfig.btnClose:SetScript("OnClick", |
local btnClose = CreateFrame("Button", "DagAssistConfigDeleteButton", fraConfig, "DA_Button2"); |
btnClose:SetSize(35, 20); |
btnClose:SetPoint("BOTTOMRIGHT", fraConfig, "BOTTOMRIGHT", -10, 10); |
btnClose:SetText("OK"); |
btnClose:SetScript("OnClick", |
function(self, event, ...) |
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem); |
DagAssistConfigSaveSection(cboHeaders.SelectedItem); |
fraConfig:Hide(); |
DagAssist:LoadMenu(); |
end |
) |
--[[ |
--Hide minimap button |
fraConfig.chkHideMinimap = CreateFrame("CheckButton", "DagAssistConfigHideMinimapButton", fraConfig, "ChatConfigCheckButtonTemplate"); |
fraConfig.chkHideMinimap:SetPoint("BOTTOMLEFT", fraConfig, "BOTTOMLEFT", 10, 10); |
local chkHideMinimap = CreateFrame("CheckButton", "DagAssistConfigHideMinimapButton", fraConfig, "ChatConfigCheckButtonTemplate"); |
chkHideMinimap:SetPoint("BOTTOMLEFT", fraConfig, "BOTTOMLEFT", 10, 10); |
--Hide minimap button label |
fraConfig.lblHideButton = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
fraConfig.lblHideButton:SetPoint("LEFT", fraConfig.chkHideMinimap, "RIGHT", 0, 2); |
fraConfig.lblHideButton:SetHeight(7); |
fraConfig.lblHideButton:SetText("Hide minimap button"); |
local lblHideButton = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblHideButton:SetPoint("LEFT", chkHideMinimap, "RIGHT", 0, 2); |
lblHideButton:SetHeight(7); |
lblHideButton:SetText("Hide minimap button"); |
--]] |
function DagAssistRetrieveCursorItem(self, event, ...) |
local ret = {}; |
if actionType == "companion" then |
local companionID = DagAssistGetCompanionID(actionSubType, actionData) |
local companionID = GetCompanionID(actionSubType, actionData) |
_, itemName, _, itemTexture, _ = GetCompanionInfo(actionSubType, companionID); |
elseif actionType == "equipmentset" then |
itemName = actionData; |
function DagAssistPickupAction(actionType, actionData, actionSubType) |
if actionType == "companion" then |
local companionID = DagAssistGetCompanionID(actionSubType, actionData); |
local companionID = GetCompanionID(actionSubType, actionData); |
PickupCompanion(actionSubType, companionID); |
elseif actionType == "equipmentset" then |
PickupEquipmentSetByName(actionData); |
elseif actionType == "macro" then |
PickupMacro(actionData); |
elseif actionType == "spell" then |
local spellBookID = DagAssistGetSpellBookID(actionData, actionSubType); |
local spellBookID = GetSpellBookID(actionData, actionSubType); |
if (spellBookID) then |
PickupSpell(spellBookID, actionSubType); |
end |
end |
end |
function DagAssistGetCompanionID(subType, name) |
function GetCompanionID(subType, name) |
local i = 1; |
local _, itemName = GetCompanionInfo(subType, i); |
end |
end |
function DagAssistGetSpellBookID(spellID, actionSubType) |
function GetSpellBookID(spellID, actionSubType) |
local i = 1; |
local link = GetSpellLink(i, actionSubType); |
--Items label |
fraConfig.lblMenuItems = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
fraConfig.lblMenuItems:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 40, -165); |
fraConfig.lblMenuItems:SetHeight(15); |
fraConfig.lblMenuItems:SetText("Drag Actions Below"); |
fraConfig.lblMenuItems:SetTextColor(1,1,0,1); |
local lblMenuItems = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblMenuItems:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 40, -125); |
lblMenuItems:SetHeight(15); |
lblMenuItems:SetText("Drag Actions Below:"); |
--Menu items |
fraConfig.previousMenuItem = nil; |
fraConfig.configButtons = {}; |
local previousMenuItem = nil; |
local configButtons = {}; |
for index = 1, 15 do |
local currentItem = CreateFrame("Button", "DagAssistMenuItem"..index, fraConfig, "DAConfig_MenuButtonTemplate"); |
table.insert(fraConfig.configButtons, currentItem); |
table.insert(configButtons, currentItem); |
currentItem:SetBackdropColor(1, 0, 0, 0.5); |
if (fraConfig.previousMenuItem) then |
currentItem:SetPoint("TOPLEFT", fraConfig.previousMenuItem, "BOTTOMLEFT"); |
if (previousMenuItem) then |
currentItem:SetPoint("TOPLEFT", previousMenuItem, "BOTTOMLEFT"); |
else |
currentItem:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 50, -185); |
currentItem:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 50, -150); |
end |
currentItem.Icon = currentItem:CreateTexture("DagAssistMenuItemIcon"..index, "OVERLAY"); |
currentItem:SetScript("OnReceiveDrag", DagAssistRetrieveCursorItem); |
currentItem:SetScript("OnClick", DagAssistRetrieveCursorItem); |
fraConfig.previousMenuItem = currentItem; |
previousMenuItem = currentItem; |
end |
function DagAssistConfigSaveSection(section) |
if (sectionData.Name == section) then |
sectionData.Actions = {}; |
for actionIndex = 1, table.getn(fraConfig.configButtons) do |
local configButton = fraConfig.configButtons[actionIndex]; |
for actionIndex = 1, table.getn(configButtons) do |
local configButton = configButtons[actionIndex]; |
if (configButton.DA_ActionData) then |
local saveData = {}; |
saveData.DA_ActionType = configButton.DA_ActionType; |
table.insert(headers, sectionData.Name); |
end |
fraConfig.cboHeaders.AddRange(headers); |
cboHeaders.AddRange(headers); |
UIDropDownMenu_SetSelectedID(fraConfig.cboHeaders, selectedIndex); |
fraConfig.cboHeaders.PreviousItem = fraConfig.cboHeaders.SelectedItem; |
fraConfig.cboHeaders.SelectedItem = selectedHeader; |
UIDropDownMenu_SetSelectedID(cboHeaders, selectedIndex); |
cboHeaders.PreviousItem = cboHeaders.SelectedItem; |
cboHeaders.SelectedItem = selectedHeader; |
DagAssistConfigLoadSection(selectedHeader); |
end |
function DagAssistConfigLoadSection(section) |
if (DA_Vars.Menu) then |
for index = 1, table.getn(fraConfig.configButtons) do |
local configButton = fraConfig.configButtons[index]; |
for index = 1, table.getn(configButtons) do |
local configButton = configButtons[index]; |
DagAssistClearConfigButtonAction(configButton); |
end |
if (sectionData.Name == section) then |
if (sectionData.Actions) then |
for actionIndex = 1, table.getn(sectionData.Actions) do |
local configButton = fraConfig.configButtons[actionIndex]; |
local configButton = configButtons[actionIndex]; |
local saveData = sectionData.Actions[actionIndex]; |
DagAssistAssignConfigButtonAction(configButton, saveData.DA_ActionType, saveData.DA_ActionData, saveData.DA_ActionSubType); |
end |
function DagAssistConfigFrame_Toggle() |
if ( DagAssist.Config:IsVisible() ) then |
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem); |
DagAssistConfigSaveSection(cboHeaders.SelectedItem); |
DagAssist.Config:Hide(); |
else |
DagAssist.Config:Show(); |