/trunk
------------------------------------------------ |
-- DagAssist -- |
-- Dagos of Cenarius -- |
------------------------------------------------ |
4.01 |
* Configurable! |
2.07 |
* Updated Paladin and Warlock menus with suggestions from Raloo @ Wowinterface. Thanks! |
2.06 |
* Added Aspect of the Dragonhawk |
2.05 |
* Updated for 3.0.8 |
2.04 |
* Added Deathgate and Runeforging for Death Knights |
* Fixed the redundant Track Humanoids |
2.03 |
* Fixed problem with items not in the cache causing an error on first startup |
* Self-cast and focus-cast shortcuts now work |
* Glowing-hand selection now functions properly |
* Added spell cooldowns |
* Fixed the %d problem with spell & item cooldowns |
2.02 |
* Fixed the buff type |
2.01 |
* Fixed several small bugs |
2.0 |
* Initial release for 3.0 / WotLK |
* Complete rewrite of inner workings |
* Added many abilities and professions |
* Translations are no longer necessary. Using the built-in localization for everything |
## Interface: 40000 |
## Title: DagAssist |
## Author: Dagos (Cenarius) |
## Notes: Convenient shortcut menu |
## Version: 4.02 |
## DefaultState: enabled |
## LoadOnDemand: 0 |
## SavedVariablesPerCharacter: DA_Vars |
DagAssist_Menu.lua |
DagAssist.xml |
DagAssist.lua |
DagAssistConfig.xml |
DagAssistConfig.lua |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXMLx\UI.xsd"> |
<Font name="DagAssistConfigFont" font="Fonts\ARIALN.TTF" virtual="true"> |
<FontHeight> |
<AbsValue val="14"/> |
</FontHeight> |
<Color r="0" g="0" b="0"/> |
</Font> |
<Button name="DA_Button" virtual="true"> |
<NormalTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Up"/> |
<PushedTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Down"/> |
<HighlightTexture file="Interface\Buttons\UI-Panel-MinimizeButton-Highlight" alphaMode="ADD"/> |
</Button> |
<Button name="DA_Button2" virtual="true"> |
<NormalTexture inherits="DialogButtonNormalTexture"/> |
<PushedTexture inherits="DialogButtonPushedTexture"/> |
<HighlightTexture inherits="DialogButtonHighlightTexture"/> |
<NormalFont style="GameFontNormal"/> |
<HighlightFont style="GameFontHighlight"/> |
</Button> |
<Button name="DAConfig_MenuButtonTemplate" inherits="DA_MenuButtonTemplate" virtual="true"> |
<Size><AbsDimension y="21"/></Size> |
<Anchors> |
<Anchor point="LEFT" relativePoint="LEFT" /> |
<Anchor point="RIGHT" relativePoint="RIGHT" /> |
</Anchors> |
<ButtonText name="$parentText" justifyH="LEFT" justifyV="MIDDLE" > |
<Anchors> |
<Anchor point="LEFT"> |
<Offset> |
<AbsDimension x="25" /> |
</Offset> |
</Anchor> |
</Anchors> |
</ButtonText> |
<NormalTexture file="Interface\Buttons\UI-Quickslot2"> |
<Size><AbsDimension x="32" y="32"/></Size> |
<Anchors> |
<Anchor point="TOPLEFT"> |
<Offset> |
<AbsDimension x="-6.5" y="6.5" /> |
</Offset> |
</Anchor> |
</Anchors> |
</NormalTexture> |
<PushedTexture file="Interface\Buttons\UI-Quickslot-Depress"> |
<Size><AbsDimension x="18" y="18"/></Size> |
<Anchors><Anchor point="TOPLEFT"/></Anchors> |
</PushedTexture> |
<HighlightTexture name="$parentHighlight" file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"> |
<Size><AbsDimension x="18" y="18"/></Size> |
<Anchors><Anchor point="TOPLEFT"/></Anchors> |
</HighlightTexture> |
</Button> |
<Frame name="DA_Combobox" virtual="true" inherits="UIDropDownMenuTemplate"> |
<Scripts> |
<OnLoad> |
local cboBox = self; |
cboBox.OnClick = function(self) |
UIDropDownMenu_SetSelectedID(cboBox, self:GetID()); |
cboBox.PreviousItem = cboBox.SelectedItem; |
cboBox.SelectedItem = self.value; |
if (type(cboBox["OnClickEvent"]) == 'function') then |
cboBox["OnClickEvent"](cboBox, cboBox.SelectedItem); |
end |
end |
cboBox.AddRange = function(items) |
cboBox.ComboItems = items; |
UIDropDownMenu_Initialize(cboBox, cboBox.Initialize); |
UIDropDownMenu_SetSelectedID(cboBox, 1); |
cboBox.PreviousItem = nil; |
cboBox.SelectedItem = items[1]; |
end |
cboBox.Initialize = function(self, level) |
local info = UIDropDownMenu_CreateInfo(); |
for k,v in pairs(cboBox.ComboItems) do |
info = UIDropDownMenu_CreateInfo(); |
info.text = v; |
info.value = v; |
info.func = cboBox.OnClick; |
UIDropDownMenu_AddButton(info, level); |
end |
end |
UIDropDownMenu_SetWidth(cboBox, 120); |
UIDropDownMenu_SetButtonWidth(cboBox, 174) |
UIDropDownMenu_JustifyText(cboBox, "LEFT") |
</OnLoad> |
</Scripts> |
</Frame> |
<EditBox name="DA_Editbox" virtual="true" letters="80"> |
<TextInsets> |
<AbsInset left="6" right="6" top="0" bottom="0" /> |
</TextInsets> |
<Layers> |
<Layer level="BACKGROUND"> |
<Texture name="$parentTopLeft" file="Interface\Common\Common-Input-Border-TL"> |
<Size> |
<AbsDimension x="8" y="8"/> |
</Size> |
<Anchors> |
<Anchor point="TOPLEFT"> |
<Offset x="0" y="0"/> |
</Anchor> |
</Anchors> |
</Texture> |
<Texture name="$parentTopRight" file="Interface\Common\Common-Input-Border-TR"> |
<Size> |
<AbsDimension x="8" y="8"/> |
</Size> |
<Anchors> |
<Anchor point="TOPRIGHT"> |
<Offset x="0" y="0"/> |
</Anchor> |
</Anchors> |
</Texture> |
<Texture name="$parentTop" file="Interface\Common\Common-Input-Border-T"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentTopRight" relativePoint="BOTTOMLEFT"/> |
</Anchors> |
</Texture> |
<Texture name="$parentBottomLeft" file="Interface\Common\Common-Input-Border-BL"> |
<Size> |
<AbsDimension x="8" y="8"/> |
</Size> |
<Anchors> |
<Anchor point="BOTTOMLEFT"> |
<Offset x="0" y="0"/> |
</Anchor> |
</Anchors> |
</Texture> |
<Texture name="$parentBottomRight" file="Interface\Common\Common-Input-Border-BR"> |
<Size> |
<AbsDimension x="8" y="8"/> |
</Size> |
<Anchors> |
<Anchor point="BOTTOMRIGHT"> |
<Offset x="0" y="0"/> |
</Anchor> |
</Anchors> |
</Texture> |
<Texture name="$parentBottom" file="Interface\Common\Common-Input-Border-B"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentBottomLeft" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="BOTTOMLEFT"/> |
</Anchors> |
</Texture> |
<Texture name="$parentLeft" file="Interface\Common\Common-Input-Border-L"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="BOTTOMLEFT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomLeft" relativePoint="TOPRIGHT"/> |
</Anchors> |
</Texture> |
<Texture name="$parentRight" file="Interface\Common\Common-Input-Border-R"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentTopRight" relativePoint="BOTTOMLEFT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="TOPRIGHT"/> |
</Anchors> |
</Texture> |
<Texture name="$parentMiddle" file="Interface\Common\Common-Input-Border-M"> |
<Anchors> |
<Anchor point="TOPLEFT" relativeTo="$parentLeft" relativePoint="TOPRIGHT"/> |
<Anchor point="BOTTOMRIGHT" relativeTo="$parentRight" relativePoint="BOTTOMLEFT"/> |
</Anchors> |
</Texture> |
</Layer> |
</Layers> |
<Scripts> |
<OnShow> |
self:SetBackdropColor(0, 0, 0, 1); |
self:ClearFocus(); |
</OnShow> |
<OnEscapePressed> |
self:ClearFocus(); |
</OnEscapePressed> |
<OnEnterPressed> |
if (type(self["OnEnterEvent"]) == 'function') then |
self["OnEnterEvent"](self, self:GetText()); |
end |
</OnEnterPressed> |
</Scripts> |
<FontString inherits="ChatFontNormal"></FontString> |
</EditBox> |
</Ui> |
------------------------------------------------ |
-- DagAssistConfig -- |
-- Dagos of Cenarius -- |
------------------------------------------------ |
if (not DagAssist) then |
DagAssist = {}; |
end |
--Set up the config frame |
DagAssist.Config = CreateFrame("Frame", "DA_ConfigFrame", UIParent); |
local fraConfig = DagAssist.Config; |
fraConfig:EnableMouse(true); |
fraConfig:RegisterForDrag("LeftButton"); |
fraConfig:SetToplevel(true); |
fraConfig:SetMovable(true); |
fraConfig:SetSize(384, 512); |
fraConfig:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 100, -100); |
fraConfig:SetClampedToScreen(true); |
fraConfig:Hide(); |
local configBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, |
tileSize = 32, |
edgeSize = 13, |
insets = {left = 4, right = 4, top = 4, bottom = 4} |
} |
fraConfig:SetBackdrop(configBackdrop); |
fraConfig:SetBackdropColor(0, 0, 0, 0.9); |
fraConfig:SetScript("OnMouseDown", |
function(self, event, ...) |
self:StartMoving(); |
end |
) |
fraConfig:SetScript("OnMouseUp", |
function(self, event, ...) |
self:StopMovingOrSizing(); |
end |
) |
local DagAssistLoaded = false; |
fraConfig:SetScript("OnEvent", |
function(self, event, ...) |
if (event == "ADDON_LOADED") then |
local name = ...; |
if (name == "DagAssist") then |
DagAssistLoaded = true; |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = {{Name="Default", Actions={}}}; |
end |
end |
elseif (event == "PLAYER_ENTERING_WORLD") then |
if (DagAssistLoaded) then |
fraConfig:UnregisterEvent("PLAYER_ENTERING_WORLD"); |
DagAssistConfigLoadHeaders(); |
end |
end |
end |
) |
fraConfig:RegisterEvent("ADDON_LOADED"); |
fraConfig:RegisterEvent("PLAYER_ENTERING_WORLD"); |
--Title |
local lblTitle = fraConfig:CreateFontString(nil, "OVERLAY", "NumberFont_Outline_Large"); |
lblTitle:SetPoint("TOP", fraConfig, "TOP", 0, -2); |
lblTitle:SetHeight(25); |
lblTitle:SetText("DagAssist Configuration"); |
--Header list |
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 |
local lblMenuSection = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblMenuSection:SetPoint("BOTTOMLEFT", cboHeaders, "TOPLEFT", 18, 0); |
lblMenuSection:SetHeight(15); |
lblMenuSection:SetText("Sections"); |
--Delete button |
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 |
return; |
end |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == cboHeaders.SelectedItem) then |
table.remove(DA_Vars.Menu, index); |
break; |
end |
end |
DagAssistConfigLoadHeaders(); |
end |
end |
) |
--New header editbox |
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 = {{Name="Default"}}; |
end |
DagAssistConfigSaveSection(cboHeaders.SelectedItem); |
local newSection = {}; |
newSection.Name = editText; |
newSection.Actions = {}; |
table.insert(DA_Vars.Menu, newSection); |
DagAssistConfigLoadHeaders(editText); |
self:SetText(""); |
self:ClearFocus(); |
end |
--New section label |
local lblNewSection = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblNewSection:SetPoint("BOTTOMLEFT", txtNewHeader, "TOPLEFT", 0, 0); |
lblNewSection:SetHeight(15); |
lblNewSection:SetText("New Section"); |
--Close button |
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(cboHeaders.SelectedItem); |
fraConfig:Hide(); |
DagAssist:LoadMenu(); |
end |
) |
--[[ |
--Hide minimap button |
local chkHideMinimap = CreateFrame("CheckButton", "DagAssistConfigHideMinimapButton", fraConfig, "ChatConfigCheckButtonTemplate"); |
chkHideMinimap:SetPoint("BOTTOMLEFT", fraConfig, "BOTTOMLEFT", 10, 10); |
--Hide minimap button label |
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, ...) |
if (GetCursorInfo()) then |
local oldActionType, oldActionData, oldActionSubType; |
if (self.DA_ActionData) then |
oldActionType = self.DA_ActionType; |
oldActionData = self.DA_ActionData; |
oldActionSubType = self.DA_ActionSubType; |
end |
local cursorType, cursorData, cursorSubType; |
cursorType, cursorData, cursorSubType = GetCursorInfo(); |
ClearCursor(); |
local itemName, itemID; |
if cursorType == "companion" then |
_, itemName = GetCompanionInfo(cursorSubType, cursorData); |
cursorData = itemName; |
elseif cursorType == "item" then |
_, link, _, _, _, _, _, _, _, itemTexture, _ = GetItemInfo(cursorData); |
local _, _, parts = strsplit("|", link); |
_, itemID = strsplit(":", parts); |
cursorData = itemID; |
elseif cursorType == "spell" then |
local link = GetSpellLink(cursorData, cursorSubType); |
local _, _, parts = strsplit("|", link); |
_, itemID = strsplit(":", parts); |
cursorData = itemID; |
end |
DagAssistAssignConfigButtonAction(self, cursorType, cursorData, cursorSubType); |
if (oldActionData) then |
DagAssistPickupAction(oldActionType, oldActionData, oldActionSubType); |
end |
end |
end |
function DagAssistAssignConfigButtonAction(self, actionType, actionData, actionSubType) |
--local itemTexture, itemName; |
local actionInfo = DagAssistGetActionInfo(actionType, actionData, actionSubType); |
self.DA_ActionType = actionType; |
self.DA_ActionSubType = actionSubType; |
self.DA_ActionData = actionData; |
if (actionInfo.Texture) then self.Icon:SetTexture(actionInfo.Texture); end |
if (actionInfo.Name) then |
self:SetText(actionInfo.Name); |
else |
self:SetText("nil"); |
end |
end |
function DagAssistGetActionInfo(actionType, actionData, actionSubType) |
local itemTexture, itemName; |
local ret = {}; |
if actionType == "companion" then |
local companionID = GetCompanionID(actionSubType, actionData) |
_, itemName, _, itemTexture, _ = GetCompanionInfo(actionSubType, companionID); |
elseif actionType == "equipmentset" then |
itemName = actionData; |
itemTexture, _ = GetEquipmentSetInfoByName(actionData); |
itemTexture = "Interface\\Icons\\"..itemTexture; |
elseif actionType == "item" then |
itemName, _, _, _, _, _, _, _, _, itemTexture, _ = GetItemInfo(actionData); |
elseif actionType == "macro" then |
itemName, itemTexture, _ = GetMacroInfo(actionData); |
elseif actionType == "spell" then |
itemName = GetSpellInfo(actionData); |
itemTexture = GetSpellTexture(itemName); |
end |
if (itemName) then |
ret.Name = itemName; |
end |
if (itemTexture) then |
ret.Texture = itemTexture; |
end |
return ret; |
end |
function DagAssistClearConfigButtonAction(self) |
self:SetText(nil); |
self.Icon:SetTexture(nil); |
self.DA_ActionType = nil; |
self.DA_ActionData = nil; |
self.DA_ActionSubType = nil; |
end |
function DagAssistPickupAction(actionType, actionData, actionSubType) |
if actionType == "companion" then |
local companionID = GetCompanionID(actionSubType, actionData); |
PickupCompanion(actionSubType, companionID); |
elseif actionType == "equipmentset" then |
PickupEquipmentSetByName(actionData); |
elseif actionType == "item" then |
PickupItem(actionSubType); |
elseif actionType == "macro" then |
PickupMacro(actionData); |
elseif actionType == "spell" then |
local spellBookID = GetSpellBookID(actionData, actionSubType); |
if (spellBookID) then |
PickupSpell(spellBookID, actionSubType); |
end |
end |
end |
function GetCompanionID(subType, name) |
local i = 1; |
local _, itemName = GetCompanionInfo(subType, i); |
while (itemName) do |
if (itemName == name) then |
return i; |
end |
i = i + 1; |
_, itemName = GetCompanionInfo(subType, i); |
end |
end |
function GetSpellBookID(spellID, actionSubType) |
local i = 1; |
local link = GetSpellLink(i, actionSubType); |
while (link) do |
local absoluteID = string.match(link, "Hspell:([^\124]+)\124"); |
if (absoluteID == spellID) then |
return i; |
end |
i = i + 1; |
link = GetSpellLink(i, actionSubType); |
end |
end |
function DagAssistOnDragStart(self, event, ...) |
local cursorType, cursorData, cursorSubType; |
if (GetCursorInfo()) then |
cursorType, cursorData, cursorSubType = GetCursorInfo(); |
ClearCursor(); |
end |
if (self.DA_ActionData) then |
DagAssistPickupAction(self.DA_ActionType, self.DA_ActionData, self.DA_ActionSubType); |
if (cursorData) then |
DagAssistAssignConfigButtonAction(self, cursorType, cursorData, cursorSubType); |
else |
DagAssistClearConfigButtonAction(self); |
end |
end |
end |
--Items label |
local lblMenuItems = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); |
lblMenuItems:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 40, -125); |
lblMenuItems:SetHeight(15); |
lblMenuItems:SetText("Drag Actions Below:"); |
--Menu items |
local previousMenuItem = nil; |
local configButtons = {}; |
for index = 1, 15 do |
local currentItem = CreateFrame("Button", "DagAssistMenuItem"..index, fraConfig, "DAConfig_MenuButtonTemplate"); |
table.insert(configButtons, currentItem); |
currentItem:SetBackdropColor(1, 0, 0, 0.5); |
if (previousMenuItem) then |
currentItem:SetPoint("TOPLEFT", previousMenuItem, "BOTTOMLEFT"); |
else |
currentItem:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 50, -150); |
end |
currentItem.Icon = currentItem:CreateTexture("DagAssistMenuItemIcon"..index, "OVERLAY"); |
currentItem.Icon:SetSize(16, 16); |
currentItem.Icon:SetPoint("TOPLEFT", currentItem, "TOPLEFT", 2, -2); |
currentItem:RegisterForDrag("LeftButton"); |
currentItem:SetScript("OnDragStart", DagAssistOnDragStart); |
currentItem:SetScript("OnReceiveDrag", DagAssistRetrieveCursorItem); |
currentItem:SetScript("OnClick", DagAssistRetrieveCursorItem); |
previousMenuItem = currentItem; |
end |
function DagAssistConfigSaveSection(section) |
--Save the displayed menu section |
--Find the correct menu section |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == section) then |
sectionData.Actions = {}; |
for actionIndex = 1, table.getn(configButtons) do |
local configButton = configButtons[actionIndex]; |
if (configButton.DA_ActionData) then |
local saveData = {}; |
saveData.DA_ActionType = configButton.DA_ActionType; |
saveData.DA_ActionData = configButton.DA_ActionData; |
saveData.DA_ActionSubType = configButton.DA_ActionSubType; |
table.insert(sectionData.Actions, saveData); |
end |
end |
break; |
end |
end |
end |
function DagAssistConfigLoadHeaders(selectedHeader) |
if (DA_Vars.Menu) then |
local headers = {}; |
local selectedIndex = 1; |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (not selectedHeader) then |
selectedHeader = sectionData.Name; |
end |
if (sectionData.Name == selectedHeader) then |
selectedIndex = index; |
end |
table.insert(headers, sectionData.Name); |
end |
cboHeaders.AddRange(headers); |
UIDropDownMenu_SetSelectedID(cboHeaders, selectedIndex); |
cboHeaders.PreviousItem = cboHeaders.SelectedItem; |
cboHeaders.SelectedItem = selectedHeader; |
DagAssistConfigLoadSection(selectedHeader); |
end |
end |
function DagAssistConfigLoadSection(section) |
if (DA_Vars.Menu) then |
for index = 1, table.getn(configButtons) do |
local configButton = configButtons[index]; |
DagAssistClearConfigButtonAction(configButton); |
end |
for index = 1, table.getn(DA_Vars.Menu) do |
local sectionData = DA_Vars.Menu[index]; |
if (sectionData.Name == section) then |
if (sectionData.Actions) then |
for actionIndex = 1, table.getn(sectionData.Actions) do |
local configButton = configButtons[actionIndex]; |
local saveData = sectionData.Actions[actionIndex]; |
DagAssistAssignConfigButtonAction(configButton, saveData.DA_ActionType, saveData.DA_ActionData, saveData.DA_ActionSubType); |
end |
end |
break; |
end |
end |
end |
end |
function DagAssistConfigFrame_Toggle() |
if ( DagAssist.Config:IsVisible() ) then |
DagAssistConfigSaveSection(cboHeaders.SelectedItem); |
DagAssist.Config:Hide(); |
else |
DagAssist.Config:Show(); |
end |
end |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Frame name="DA_MenuContainer" toplevel="true" frameStrata="HIGH" virtual="true"> |
<Size><AbsDimension x="220" y="32"/></Size> |
<Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> |
<EdgeSize><AbsValue val="16"/></EdgeSize> |
<TileSize><AbsValue val="16"/></TileSize> |
<BackgroundInsets><AbsInset left="5" right="5" top="5" bottom="5"/></BackgroundInsets> |
</Backdrop> |
</Frame> |
<Button name="DA_MinimapButton" frameStrata="LOW" movable="true" virtual="true"> |
<Size><AbsDimension x="32" y="32"/></Size> |
<NormalTexture file="Interface\AddOns\DagAssist\Images\MinmapIcon" /> |
<PushedTexture file="Interface\AddOns\DagAssist\Images\MinmapIconDown" /> |
</Button> |
<Button name="DA_MenuButtonTemplate" virtual="true"> |
<Size> |
<AbsDimension x="200" y="18"/> |
</Size> |
<ButtonText name="$parentText" justifyH="LEFT" justifyV="MIDDLE" > |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT"> |
</Anchor> |
</Anchors> |
</ButtonText> |
<NormalFont style="GameFontHighlightSmall"/> |
<HighlightFont style="GameFontHighlightSmall"/> |
<DisabledFont style="GameFontDisableSmall"/> |
<HighlightTexture setAllPoints="true"> |
<Color r="1" g="1" b="0" a="0.1" /> |
</HighlightTexture> |
<PushedTexture setAllPoints="true"> |
<Color r="0" g="1" b="1" a="0.1" /> |
</PushedTexture > |
</Button> |
<Button name="DA_MenuSpellButtonTemplate" inherits="DA_MenuButtonTemplate" virtual="true"> |
<ButtonText name="$parentText" justifyH="LEFT" justifyV="MIDDLE" > |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT"> |
<Offset><AbsDimension x="29" y="0"/></Offset> |
</Anchor> |
</Anchors> |
</ButtonText> |
<Layers> |
<Layer level="OVERLAY"> |
<Texture name="$parentIcon"> |
<Size><AbsDimension x="17" y="17"/></Size> |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT"> |
<Offset><AbsDimension x="10" y="0"/></Offset> |
</Anchor> |
</Anchors> |
</Texture> |
</Layer> |
</Layers> |
</Button> |
<Button name="DA_MenuLabelTemplate" virtual="true" > |
<Size> |
<AbsDimension x="200" y="18"/> |
</Size> |
<ButtonText name="$parentText" justifyH="LEFT" justifyV="MIDDLE"> |
<Anchors> |
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT"> |
<Offset><AbsDimension x="5" y="0"/></Offset> |
</Anchor> |
</Anchors> |
</ButtonText> |
<NormalFont style="GameFontNormalSmall"/> |
<HighlightFont style="GameFontNormalSmall"/> |
<DisabledFont style="GameFontNormalSmall"/> |
<PushedTextOffset> |
<AbsDimension x="0" y="0" /> |
</PushedTextOffset> |
</Button> |
</Ui> |
------------------------------------------------ |
-- DagAssist -- |
-- Dagos of Cenarius -- |
------------------------------------------------ |
if (not DagAssist) then |
DagAssist = {}; |
end |
function DagAssist:Debug(msg) |
if (msg) then |
DEFAULT_CHAT_FRAME:AddMessage(msg); |
else |
DEFAULT_CHAT_FRAME:AddMessage("nil"); |
end |
end |
--Set up the minimap button |
DagAssist.MinimapButton = CreateFrame("Button", "DA_Minimap", Minimap, "SecureHandlerClickTemplate, DA_MinimapButton"); |
local btnMinimap = DagAssist.MinimapButton; |
btnMinimap:RegisterForDrag("LeftButton"); |
btnMinimap:SetClampedToScreen(true); |
local texture = btnMinimap:CreateTexture(nil, "ARTWORK"); |
texture:SetTexture("Interface\\AddOns\\DagAssist\\Images\\MinmapIconHighlight"); |
texture:SetBlendMode("BLEND"); |
texture:SetAllPoints(btnMinimap); |
btnMinimap:SetHighlightTexture(texture); |
DagAssist.Menu = CreateFrame("Frame", "DA_Menu", btnMinimap, "SecureHandlerBaseTemplate, DA_MenuContainer"); |
DagAssist.Menu:SetClampedToScreen(true); |
DagAssist.Menu:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b); |
DagAssist.Menu:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b, 1); |
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.HideOld = DagAssist.Menu.Hide; |
-- DagAssist.Menu.Hide = function(self) |
-- if (InCombatLockdown() ~= 1) then |
-- DagAssist.Menu:HideOld(); |
-- end |
-- end |
DagAssist.Menu:Hide(); |
btnMinimap:Execute([[ |
menuItems = table.new(); |
Close = [=[ |
self:GetFrameRef("dag_menu"):Hide(); |
]=] |
Show = [=[ |
local dag_menu = self:GetFrameRef("dag_menu"); |
dag_menu:Show(); |
dag_menu:SetPoint("TOPLEFT", self, "BOTTOMLEFT"); |
for i, button in ipairs(menuItems) do |
local enabled = button:GetAttribute("enabled"); |
if (enabled) then |
button:Enable(); |
else |
button:Disable(); |
end |
button:Show(); |
end |
]=] |
table.insert(menuItems, dag_menu); |
]]); |
btnMinimap:SetAttribute("_onclick", [[ |
if self:GetFrameRef("dag_menu"):IsVisible() then |
control:Run(Close); |
else |
control:Run(Show); |
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(); |
self.Dragging = true; |
if (InCombatLockdown() ~= 1) then |
btnMinimap:Execute([[ |
control:Run(Close); |
]]); |
end |
end |
) |
btnMinimap:SetScript("OnDragStop", |
function(self, event, ...) |
self:StopMovingOrSizing(); |
if (self.Dragging) then |
self.Dragging = false; |
local s = self:GetEffectiveScale(); |
DA_Vars.Minimap.X = self:GetLeft() * s; |
DA_Vars.Minimap.Y = self:GetTop() * s; |
end |
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](DagAssist, event); |
end |
end) |
btnMinimap:RegisterEvent("PLAYER_ENTERING_WORLD"); |
function DagAssist:PLAYER_ENTERING_WORLD(event) |
if (not DA_Vars) 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:SetPoint("CENTER", Minimap, "BOTTOMLEFT", 15, 15); |
end |
DagAssist:LoadMenu(); |
DagAssist.MinimapButton:Show(); |
btnMinimap:RegisterEvent("BAG_UPDATE"); |
btnMinimap:RegisterEvent("LEARNED_SPELL_IN_TAB"); |
btnMinimap:RegisterEvent("PLAYER_REGEN_DISABLED"); |
btnMinimap:RegisterEvent("PLAYER_REGEN_ENABLED"); |
end |
function DagAssist:LoadMenu() |
if (InCombatLockdown()) then |
DagAssist.ReloadNeeded = true; |
return; |
end |
btnMinimap:Execute([[ |
if (menuItems) then |
for i, button in ipairs(menuItems) do |
button:Hide(); |
end |
end |
menuItems = table.new(); |
]]); |
local menu = DagAssist.Menu; |
if (not DA_Vars.Menu) then |
DA_Vars.Menu = {{Name="Default", Actions={}}}; |
end |
local menuItems = DA_Vars.Menu; |
local btnMenuItem; |
for index = 1, table.getn(menuItems) do |
local section = menuItems[index]; |
--Create section header |
btnMenuItem = _G["DA_MenuHeader"..index]; |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuHeader"..index, menu, "SecureHandlerBaseTemplate, DA_MenuLabelTemplate"); |
end |
btnMenuItem:SetText(section.Name); |
btnMenuItem:SetFrameRef("dag_menu", DagAssist.Menu); |
btnMenuItem:Show(); |
btnMinimap:SetFrameRef("child", btnMenuItem); |
btnMinimap:Execute([[ |
table.insert(menuItems, self:GetFrameRef("child")); |
]]); |
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 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 |
buttonTexture = _G["DA_MenuButton"..buttonIndex.."Icon"]; |
btnMenuItem.Action = action; |
if action.DA_ActionType == "companion" then |
btnMenuItem:SetScript("OnClick", function(self) |
if (IsMounted()) then |
Dismount(); |
else |
local companionID = GetCompanionID(self.Action.DA_ActionSubType, self.Action.DA_ActionData); |
CallCompanion(self.Action.DA_ActionSubType, companionID); |
end |
end); |
elseif action.DA_ActionType == "equipmentset" then |
btnMenuItem:SetScript("OnClick", function(self) |
UseEquipmentSet(self.Action.DA_ActionData); |
end); |
end |
else |
btnMenuItem = _G["DA_MenuSecureButton"..buttonIndex]; |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuSecureButton"..buttonIndex, menu, "SecureActionButtonTemplate, SecureHandlerBaseTemplate, DA_MenuSpellButtonTemplate"); |
end |
buttonTexture = _G["DA_MenuSecureButton"..buttonIndex.."Icon"]; |
if action.DA_ActionType == "item" then |
btnMenuItem:SetAttribute("type","item"); |
btnMenuItem:SetAttribute("*item1", actionInfo.Name); |
elseif action.DA_ActionType == "macro" then |
btnMenuItem:SetAttribute("type","macro"); |
btnMenuItem:SetAttribute("*macro1", action.DA_ActionData); |
elseif action.DA_ActionType == "spell" then |
if (action.DA_ActionSubType == "spell") then |
btnMenuItem:SetAttribute("type","spell"); |
btnMenuItem:SetAttribute("*spell1", actionInfo.Name); |
else |
btnMenuItem:SetAttribute("type","pet"); |
btnMenuItem:SetAttribute("*pet1", actionInfo.Name); |
end |
end |
end |
btnMenuItem:SetAttribute("checkselfcast","1"); |
btnMenuItem:SetAttribute("checkfocuscast","1"); |
btnMenuItem:SetFrameRef("dag_menu", DagAssist.Menu); |
btnMinimap:WrapScript(btnMenuItem, "OnClick", [[control:Run(Close)]]) |
btnMenuItem:SetAttribute("enabled", true); |
btnMenuItem:SetFrameLevel(btnMenuItem:GetFrameLevel() + 1); |
buttonTexture:SetTexture(actionInfo.Texture); |
btnMenuItem:SetText(actionInfo.Name); |
btnMenuItem:Show(); |
btnMinimap:SetFrameRef("child", btnMenuItem); |
btnMinimap:Execute([[ |
table.insert(menuItems, self:GetFrameRef("child")); |
]]); |
end |
end |
--Add the config button |
btnMenuItem = _G["DA_MenuButtonConfig"]; |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuButtonConfig", menu, "SecureHandlerBaseTemplate, DA_MenuButtonTemplate"); |
end |
btnMenuItem:SetText("Config"); |
btnMenuItem:SetAttribute("visible", true); |
btnMenuItem:SetAttribute("enabled", true); |
btnMenuItem:SetScript("OnClick", |
function(self, event, ...) |
DagAssistConfigFrame_Toggle(); |
end |
); |
btnMinimap:WrapScript(btnMenuItem, "OnClick", [[control:Run(Close)]]) |
btnMinimap:SetFrameRef("child", btnMenuItem); |
btnMenuItem:Show(); |
btnMinimap:Execute([[ |
table.insert(menuItems, self:GetFrameRef("child")); |
]]); |
--Add the close button |
btnMenuItem = _G["DA_MenuButtonClose"]; |
if (not btnMenuItem) then |
btnMenuItem = CreateFrame("Button", "DA_MenuButtonClose", menu, "SecureActionButtonTemplate, SecureHandlerBaseTemplate, DA_MenuButtonTemplate"); |
end |
btnMenuItem:SetText("Close"); |
btnMenuItem:SetAttribute("type", "click"); |
btnMenuItem:SetAttribute("clickbutton", btnMinimap); |
btnMenuItem:SetAttribute("visible", true); |
btnMenuItem:SetAttribute("enabled", true); |
btnMinimap:SetFrameRef("child", btnMenuItem); |
btnMenuItem:Show(); |
btnMinimap:Execute([[ |
table.insert(menuItems, self:GetFrameRef("child")); |
]]); |
btnMinimap:Execute([[ |
local previous; |
local dag_menu = self:GetFrameRef("dag_menu"); |
local menuHeight = 20; |
for i, button in ipairs(menuItems) do |
menuHeight = menuHeight + 18; |
if (previous) then |
button:SetPoint("TOPLEFT", previous, "BOTTOMLEFT"); |
else |
button:SetPoint("TOPLEFT", dag_menu, "TOPLEFT", 10, -10); |
end |
previous = button; |
end |
dag_menu:SetHeight(menuHeight); |
]]); |
end |
function DagAssist:PLAYER_REGEN_ENABLED(event) |
if (DagAssist.ReloadNeeded) then |
DagAssist:LoadMenu(); |
DagAssist.ReloadNeeded = false; |
end |
end |