WoWInterface SVN DagAssist

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 18 to Rev 19
    Reverse comparison

Rev 18 → Rev 19

ChangeLog.txt
2,6 → 2,10
-- DagAssist --
-- Dagos of Cenarius --
------------------------------------------------
4.04
* Added Cancel button to config window
* Raised frame strata of config window
 
4.03
* Added instructions to the configuration panel
* Added move up/down buttons to the section editor
DagAssist.toc
2,7 → 2,7
## Title: DagAssist
## Author: Dagos (Cenarius)
## Notes: Convenient shortcut menu
## Version: 4.03.wowi:revision
## Version: 4.04.wowi:revision
## DefaultState: enabled
## LoadOnDemand: 0
## SavedVariablesPerCharacter: DA_Vars
DagAssistConfig.lua
10,6 → 10,7
--Set up the config frame
DagAssist.Config = CreateFrame("Frame", "DA_ConfigFrame", UIParent);
local fraConfig = DagAssist.Config;
fraConfig:SetFrameStrata("DIALOG");
fraConfig:EnableMouse(true);
fraConfig:RegisterForDrag("LeftButton");
fraConfig:SetToplevel(true);
42,34 → 43,6
end
)
 
-- 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
 
-- 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
fraConfig.lblTitle = fraConfig:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge");
fraConfig.lblTitle:SetPoint("TOPLEFT", fraConfig, "TOPLEFT", 16, -16);
116,18 → 89,16
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);
DagAssistConfigSaveSection(sectionData.Name);
DagAssistConfigLoadHeaders(sectionData.Name);
end
return;
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then
if (index ~= 1) then
table.remove(fraConfig.EditMenu, index);
table.insert(fraConfig.EditMenu, index-1, sectionData);
DagAssistConfigSaveSection(sectionData.Name);
DagAssistConfigLoadHeaders(sectionData.Name);
end
return;
end
end
end
140,18 → 111,16
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);
DagAssistConfigSaveSection(sectionData.Name);
DagAssistConfigLoadHeaders(sectionData.Name);
end
return;
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then
if (index ~= table.getn(fraConfig.EditMenu)) then
table.remove(fraConfig.EditMenu, index);
table.insert(fraConfig.EditMenu, index+1, sectionData);
DagAssistConfigSaveSection(sectionData.Name);
DagAssistConfigLoadHeaders(sectionData.Name);
end
return;
end
end
end
164,20 → 133,18
fraConfig.btnDelete:SetText("Delete");
fraConfig.btnDelete:SetScript("OnClick",
function(self, event, ...)
if (DA_Vars.Menu) then
if (table.getn(DA_Vars.Menu) == 1) then
return;
if (table.getn(fraConfig.EditMenu) == 1) then
return;
end
 
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then
table.remove(fraConfig.EditMenu, index);
break;
end
 
for index = 1, table.getn(DA_Vars.Menu) do
local sectionData = DA_Vars.Menu[index];
if (sectionData.Name == fraConfig.cboHeaders.SelectedItem) then
table.remove(DA_Vars.Menu, index);
break;
end
end
DagAssistConfigLoadHeaders();
end
DagAssistConfigLoadHeaders();
end
)
 
187,16 → 154,12
fraConfig.txtNewHeader:SetPoint("TOPLEFT", fraConfig.cboHeaders, "BOTTOMRIGHT", -45, 5);
fraConfig.txtNewHeader:SetAutoFocus(false);
function fraConfig.txtNewHeader:OnEnterEvent(editText)
if (not DA_Vars.Menu) then
DA_Vars.Menu = DagAssist.LoadDefaultMenu();
end
 
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem);
 
local newSection = {};
newSection.Name = editText;
newSection.Actions = {};
table.insert(DA_Vars.Menu, newSection);
table.insert(fraConfig.EditMenu, newSection);
 
DagAssistConfigLoadHeaders(editText);
 
211,12 → 174,12
fraConfig.lblNewSection:SetText("New Section");
fraConfig.lblNewSection:SetTextColor(1,1,0,1);
 
--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",
--Cancel button
fraConfig.btnCancel = CreateFrame("Button", "DagAssistConfigCancelButton", fraConfig, "DA_Button2");
fraConfig.btnCancel:SetSize(75, 25);
fraConfig.btnCancel:SetPoint("BOTTOMRIGHT", fraConfig, "BOTTOMRIGHT", -10, 10);
fraConfig.btnCancel:SetText("Cancel");
fraConfig.btnCancel:SetScript("OnClick",
function(self, event, ...)
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem);
fraConfig:Hide();
224,6 → 187,20
end
)
 
--OK button
fraConfig.btnOk = CreateFrame("Button", "DagAssistConfigOKButton", fraConfig, "DA_Button2");
fraConfig.btnOk:SetSize(75, 25);
fraConfig.btnOk:SetPoint("TOPRIGHT", fraConfig.btnCancel, "TOPLEFT");
fraConfig.btnOk:SetText("Okay");
fraConfig.btnOk:SetScript("OnClick",
function(self, event, ...)
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem);
DA_Vars.Menu = fraConfig.EditMenu;
fraConfig:Hide();
DagAssist:LoadMenu();
end
)
 
--[[
--Hide minimap button
fraConfig.chkHideMinimap = CreateFrame("CheckButton", "DagAssistConfigHideMinimapButton", fraConfig, "ChatConfigCheckButtonTemplate");
306,7 → 283,9
elseif actionType == "equipmentset" then
itemName = actionData;
itemTexture, _ = GetEquipmentSetInfoByName(actionData);
itemTexture = "Interface\\Icons\\"..itemTexture;
if (itemTexture) then
itemTexture = "Interface\\Icons\\"..itemTexture;
end
elseif actionType == "item" then
itemName, _, _, _, _, _, _, _, _, itemTexture, _ = GetItemInfo(actionData);
elseif actionType == "macro" then
422,8 → 401,8
--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];
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
if (sectionData.Name == section) then
sectionData.Actions = {};
 
445,60 → 424,72
end
 
function DagAssistConfigLoadHeaders(selectedHeader)
if (DA_Vars.Menu) then
local headers = {};
local selectedIndex = 1;
local headers = {};
local selectedIndex = 1;
 
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
 
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);
if (not selectedHeader) then
selectedHeader = sectionData.Name;
end
fraConfig.cboHeaders.AddRange(headers);
if (sectionData.Name == selectedHeader) then
selectedIndex = index;
end
 
UIDropDownMenu_SetSelectedID(fraConfig.cboHeaders, selectedIndex);
fraConfig.cboHeaders.PreviousItem = fraConfig.cboHeaders.SelectedItem;
fraConfig.cboHeaders.SelectedItem = selectedHeader;
 
DagAssistConfigLoadSection(selectedHeader);
table.insert(headers, sectionData.Name);
end
fraConfig.cboHeaders.AddRange(headers);
 
UIDropDownMenu_SetSelectedID(fraConfig.cboHeaders, selectedIndex);
fraConfig.cboHeaders.PreviousItem = fraConfig.cboHeaders.SelectedItem;
fraConfig.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];
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 = fraConfig.configButtons[actionIndex];
local saveData = sectionData.Actions[actionIndex];
DagAssistAssignConfigButtonAction(configButton, saveData.DA_ActionType, saveData.DA_ActionData, saveData.DA_ActionSubType);
end
for index = 1, table.getn(fraConfig.configButtons) do
local configButton = fraConfig.configButtons[index];
DagAssistClearConfigButtonAction(configButton);
end
 
for index = 1, table.getn(fraConfig.EditMenu) do
local sectionData = fraConfig.EditMenu[index];
if (sectionData.Name == section) then
if (sectionData.Actions) then
for actionIndex = 1, table.getn(sectionData.Actions) do
local configButton = fraConfig.configButtons[actionIndex];
local saveData = sectionData.Actions[actionIndex];
DagAssistAssignConfigButtonAction(configButton, saveData.DA_ActionType, saveData.DA_ActionData, saveData.DA_ActionSubType);
end
break;
end
break;
end
end
end
 
function DagAssistConfigFrame_Toggle()
if ( DagAssist.Config:IsVisible() ) then
DagAssistConfigSaveSection(fraConfig.cboHeaders.SelectedItem);
DagAssist.Config:Hide();
else
function DagAssistCloneTable(t)
local ret = {};
local i, v = next(t, nil);
while i do
if type(v)=="table" then
v = DagAssistCloneTable(v);
end
ret[i] = v;
i, v = next(t, i);
end
return ret
end
 
function DagAssistConfigFrame_Show()
if ( not DagAssist.Config:IsVisible() ) then
if (DA_Vars.Menu) then
fraConfig.EditMenu = DagAssistCloneTable(DA_Vars.Menu);
else
fraConfig.EditMenu = DagAssist.LoadDefaultMenu();
end
 
DagAssistConfigLoadHeaders();
DagAssist.Config:Show();
end
DagAssist.lua
362,7 → 362,7
btnMenuItem:SetAttribute("enabled", true);
btnMenuItem:SetScript("OnClick",
function(self, event, ...)
DagAssistConfigFrame_Toggle();
DagAssistConfigFrame_Show();
end
);
btnMinimap:WrapScript(btnMenuItem, "OnClick", [[control:Run(Close)]])