Implemented the gui settings for target and focus, implemented growOrder, added in skeleton for sorting,

added debug options.
This commit is contained in:
Relintai 2016-05-06 15:29:04 +02:00
parent 742b5fbdb7
commit 6f70741c40
4 changed files with 484 additions and 29 deletions

310
Vect.lua
View File

@ -1,4 +1,9 @@
--TODOS:
--Enable/disable on frames
--Player Entering World -> cleanup the db
--CD Sort Order
--"Globals" --"Globals"
local ALLOCATE_FRAME_NUM = 5; local ALLOCATE_FRAME_NUM = 5;
@ -7,6 +12,8 @@ local aceCDialog = LibStub("AceConfigDialog-3.0")
local aceConfig = LibStub("AceConfig-3.0") local aceConfig = LibStub("AceConfig-3.0")
local libSharedMedia = LibStub("LibSharedMedia-3.0") local libSharedMedia = LibStub("LibSharedMedia-3.0")
Vect.MovableFrames = nil
Vect.targets = { Vect.targets = {
["target"] = nil, ["target"] = nil,
["focus"] = nil ["focus"] = nil
@ -23,41 +30,51 @@ Vect.defaults = {
profile = { profile = {
enabled = true, enabled = true,
locked = true, locked = true,
spellDebug = false; debugLevel = 0,
spellCastDebug = false,
spellAuraDebug = false,
allCDebug = false,
target = { target = {
enabled = true, enabled = true,
size = 23, size = 27,
xPos = -150, xPos = 350,
yPos = -125 yPos = 350,
growOrder = 2,
sortOrder = 5
}, },
focus = { focus = {
enabled = true, enabled = true,
size = 23, size = 27,
xPos = 200, xPos = 380,
yPos = -28 yPos = 380,
growOrder = 2,
sortOrder = 5
} }
} }
} }
function Vect:Reset() function Vect:Reset()
self.cds = {} Vect.cds = {}
self.target = {unitGUID = -1, timers = {}} Vect.target = {unitGUID = -1, timers = {}}
self.focus = {unitGUID = -1, timers = {}} Vect.focus = {unitGUID = -1, timers = {}}
end end
function Vect:OnInitialize() function Vect:OnInitialize()
self.db = aceDB:New("VectDB", self.defaults); self.db = aceDB:New("VectDB", self.defaults);
self.db.RegisterCallback(self, "OnProfileChanged", function() self:ApplySettings() end) self.db.RegisterCallback(self, "OnProfileChanged", function() self:ApplySettings() end);
self.db.RegisterCallback(self, "OnProfileCopied", function() self:ApplySettings() end) self.db.RegisterCallback(self, "OnProfileCopied", function() self:ApplySettings() end);
self.db.RegisterCallback(self, "OnProfileReset", function() self:ApplySettings() end) self.db.RegisterCallback(self, "OnProfileReset", function() self:ApplySettings() end);
self:Print(self.appName .. " v. " .. Vect.version .. ". Chat command is /vect"); self:Print(self.appName .. " v. " .. Vect.version .. ". Chat command is /vect");
--AceConfig:RegisterOptionsTable(self.appName, self:getOptions()) aceConfig:RegisterOptionsTable("Vect", self:GetVectOptions());
self:RegisterChatCommand("vect", "ChatCommand") aceCDialog:AddToBlizOptions("Vect");
self:RegisterChatCommand("vect", "ChatCommand");
end end
function Vect:OnEnable() function Vect:OnEnable()
--local db = self.db.profile
self:Reset() self:Reset()
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("PLAYER_TARGET_CHANGED") self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:RegisterEvent("PLAYER_FOCUS_CHANGED") self:RegisterEvent("PLAYER_FOCUS_CHANGED")
@ -68,7 +85,7 @@ end
function Vect:OnDisable() function Vect:OnDisable()
--TODO: cleanup self.Reset();
end end
@ -80,12 +97,26 @@ function Vect:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, eventType, srcGUID, srcN
dstGUID, dstName, dstFlags, spellID, spellName, spellSchool, dstGUID, dstName, dstFlags, spellID, spellName, spellSchool,
detail1, detail2, detail3) detail1, detail2, detail3)
local db = Vect.db.profile; local db = Vect.db.profile;
if db["spellDebug"] then
--debugAll
if db["allCDebug"] then
self:Print("eventType: " .. eventType .. " id: " .. spellID .. " spellName: " .. spellName); self:Print("eventType: " .. eventType .. " id: " .. spellID .. " spellName: " .. spellName);
end end
--debugAura
if db["spellAuraDebug"] then
if eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_AURA_REMOVED" or eventType == "SPELL_AURA_APPLIED_DOSE" or
eventType == "SPELL_AURA_REMOVED_DOSE" or eventType == "SPELL_AURA_REFRESH" or eventType == "SPELL_AURA_BROKEN" or
eventType == "SPELL_AURA_BROKEN_SPELL" then
self:Print("eventType: " .. eventType .. " id: " .. spellID .. " spellName: " .. spellName);
end
end
if eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" then if eventType == "SPELL_CAST_SUCCESS" or eventType == "SPELL_AURA_APPLIED" then
--self:Print("id: " .. spellID .. " spellName: " .. spellName); --debug spell
if db["spellCastDebug"] and eventType == "SPELL_CAST_SUCCESS" then
self:Print("id: " .. spellID .. " spellName: " .. spellName);
end
if Vect.spells[spellID] then if Vect.spells[spellID] then
Vect:AddCd(srcGUID, spellID); Vect:AddCd(srcGUID, spellID);
@ -106,7 +137,15 @@ function Vect:PLAYER_FOCUS_CHANGED()
end end
function Vect:PLAYER_ENTERING_WORLD() function Vect:PLAYER_ENTERING_WORLD()
--TODO clean up the db
end
function Vect:ZONE_CHANGED_NEW_AREA()
local type = select(2, IsInInstance())
-- If we are entering an arena
if (type == "arena") then
self:Reset();
end
end end
--gets called when a cd is finished, reassigns the cds to frames. --gets called when a cd is finished, reassigns the cds to frames.
@ -116,8 +155,12 @@ function Vect:ReassignCds(which)
local frame = Vect.frames[which][i]["frame"]; local frame = Vect.frames[which][i]["frame"];
frame:Hide(); frame:Hide();
end end
--check if frames are unlocked
if not Vect.db.profile["locked"] then return end;
--check if we have cooldown for that unit --check if we have cooldown for that unit
if not self.cds[self.targets[which]] then return end if not self.cds[self.targets[which]] then return end;
--sort them
Vect:SortCDs(which);
--let's fill them up --let's fill them up
local i = 1; local i = 1;
for k, v in pairs(self.cds[self.targets[which]]) do for k, v in pairs(self.cds[self.targets[which]]) do
@ -178,10 +221,14 @@ function Vect:CdRemoval(srcGUID, resetArray)
end end
end end
function Vect:SortCDs(which)
--TODO
end
function Vect:CreateFrames(which) function Vect:CreateFrames(which)
for i = 1, 23 do for i = 1, 23 do
local frame = CreateFrame("Frame", nil, UIParent, nil); local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("BACKGROUND"); frame:SetFrameStrata("MEDIUM");
frame:SetWidth(150); frame:SetWidth(150);
frame:SetHeight(150); frame:SetHeight(150);
if i == 1 then if i == 1 then
@ -202,17 +249,32 @@ function Vect:CreateFrames(which)
end end
end end
function Vect:MoveTimersStop(which, x, y, size) function Vect:MoveTimersStop(which)
local db = Vect.db.profile;
local x = db[which]["xPos"];
local y = db[which]["yPos"];
local size = db[which]["size"];
local growOrder = db[which]["growOrder"];
for i = 1, 23 do for i = 1, 23 do
local frame = Vect.frames[which][i]["frame"]; local frame = Vect.frames[which][i]["frame"];
frame:ClearAllPoints(); frame:ClearAllPoints();
frame:SetFrameStrata("BACKGROUND"); frame:SetFrameStrata("MEDIUM");
frame:SetWidth(size); frame:SetWidth(size);
frame:SetHeight(size); frame:SetHeight(size);
local text = Vect.frames[which][i]["texture"]; local text = Vect.frames[which][i]["texture"];
text:SetAllPoints(frame); text:SetAllPoints(frame);
frame.texture = text; frame.texture = text;
frame:SetPoint("CENTER", x + ((i - 1) * size), y); --set them based on the grow type
if growOrder == "1" then --Up
frame:SetPoint("BOTTOMLEFT", x, y + ((i - 1) * size));
elseif growOrder == "2" then --Right
frame:SetPoint("BOTTOMLEFT", x + ((i - 1) * size), y);
elseif growOrder == "3" then --Down
frame:SetPoint("BOTTOMLEFT", x, y - ((i - 1) * size));
else --Left
frame:SetPoint("BOTTOMLEFT", x - ((i - 1) * size), y);
end
local CoolDown = Vect.frames[which][i]["cooldown"]; local CoolDown = Vect.frames[which][i]["cooldown"];
CoolDown:SetAllPoints(); CoolDown:SetAllPoints();
--frame:Show(); --frame:Show();
@ -221,11 +283,11 @@ end
function Vect:ApplySettings() function Vect:ApplySettings()
local db = Vect.db.profile; local db = Vect.db.profile;
--self:Print(db["target"]["yPos"]); Vect:MoveTimersStop("target");
Vect:MoveTimersStop("target", db["target"]["xPos"], db["target"]["yPos"], db["target"]["size"]); Vect:MoveTimersStop("focus");
Vect:MoveTimersStop("focus", db["focus"]["xPos"], db["focus"]["yPos"], db["focus"]["size"]);
Vect:ReassignCds("target"); Vect:ReassignCds("target");
Vect:ReassignCds("focus"); Vect:ReassignCds("focus");
if not db["locked"] then self:ShowMovableFrames() end;
end end
function Vect:VOnTimerUpdate(which) function Vect:VOnTimerUpdate(which)
@ -239,3 +301,197 @@ function Vect:VOnTimerUpdate(which)
end end
end end
end end
--Utility Functions for the options
--enable
function Vect:isEnabled()
local db = Vect.db.profile;
return db["enabled"];
end
function Vect:setEnabledOrDisabled(enable)
if enable then
Vect:Enable()
else
Vect:Disable()
end
end
function Vect:isPartEnabled(which)
local db = Vect.db.profile;
return db[which]["enabled"];
end
function Vect:SetPartEnabledOrDisabled(which, enable)
local db = Vect.db.profile;
db[which]["enabled"] = enable;
end
--lock
function Vect:isLocked()
return Vect.db.profile["locked"];
end
function Vect:LockFrames()
self:MoveTimersStop("target");
self:MoveTimersStop("focus");
self:HideMovableFrames()
self:ReassignCds("target");
self:ReassignCds("focus");
end
function Vect:UnlockFrames()
--this will hide the frames
self:ReassignCds("target");
self:ReassignCds("focus");
Vect:ShowMovableFrames();
end
function Vect:HideMovableFrames()
if not Vect.MovableFrames then return end;
--Hide them
for k, v in pairs(Vect.MovableFrames) do
v["frame"]:EnableMouse(false);
v["frame"]:SetMovable(false);
v["frame"]:Hide();
end
end
function Vect:ShowMovableFrames()
local db = Vect.db.profile;
--Create them if they doesn't exists
if not Vect.MovableFrames then
Vect.MovableFrames = {}
for i = 1, 2 do
local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("BACKGROUND");
frame:SetScript("OnDragStart", function() self:MovableFrameDragStart() end)
frame:SetScript("OnDragStop", function() self:MovableFrameDragStop() end)
local text = frame:CreateTexture();
text:SetTexture("Interface\\Icons\\Spell_Arcane_Blink")
text:SetAllPoints(frame);
frame.texture = text;
local which = "";
if i == 1 then
which = "target";
elseif i == 2 then
which = "focus";
end
frame.DragID = which;
Vect.MovableFrames[i] = {}
Vect.MovableFrames[i]["frame"] = frame;
Vect.MovableFrames[i]["texture"] = text;
end
end
--Show, resize them
for k, v in pairs(Vect.MovableFrames) do
v["frame"]:EnableMouse(true)
v["frame"]:SetMovable(true)
v["frame"]:RegisterForDrag("LeftButton")
v["frame"]:SetPoint("BOTTOMLEFT", db[v["frame"].DragID]["xPos"], db[v["frame"].DragID]["yPos"]);
v["frame"]:SetWidth(db[v["frame"].DragID]["size"]);
v["frame"]:SetHeight(db[v["frame"].DragID]["size"]);
v["frame"]:Show();
end
end
function Vect:MovableFrameDragStart()
this:StartMoving();
end
function Vect:MovableFrameDragStop()
local db = Vect.db.profile;
db[this.DragID]["xPos"] = this:GetLeft();
db[this.DragID]["yPos"] = this:GetBottom();
--Vect:Print(this:GetLeft() .. " " .. this:GetBottom());
this:StopMovingOrSizing();
end
--size Functions
function Vect:getFrameSize(which)
local db = Vect.db.profile;
return db[which]["size"];
end
function Vect:setFrameSize(which, size)
local db = Vect.db.profile;
db[which]["size"] = size;
Vect:MoveTimersStop(which)
if not db["locked"] then
Vect:ShowMovableFrames();
end
end
--Grow Order
function Vect:getGrowOrder(which)
local db = Vect.db.profile;
return db[which]["growOrder"];
end
function Vect:setGrowOrder(which, v)
local db = Vect.db.profile;
db[which]["growOrder"] = v;
Vect:MoveTimersStop(which)
end
--Sort Order
function Vect:getSortOrder(which)
local db = Vect.db.profile;
return db[which]["sortOrder"];
end
function Vect:setSortOrder(which, v)
local db = Vect.db.profile;
db[which]["sortOrder"] = v;
Vect:ReassignCds(which);
end
--Debug settings
function Vect:getDebugLevel()
local db = Vect.db.profile;
return db["debugLevel"];
end
function Vect:setDebugLevel(v)
local db = Vect.db.profile;
db["debugLevel"] = v;
end
function Vect:getSpellCastDebug()
local db = Vect.db.profile;
return db["spellCastDebug"];
end
function Vect:setSpellCastDebug(v)
local db = Vect.db.profile;
db["spellCastDebug"] = v;
end
function Vect:getSpellAuraDebug()
local db = Vect.db.profile;
return db["spellAuraDebug"];
end
function Vect:setSpellAuraDebug(v)
local db = Vect.db.profile;
db["spellAuraDebug"] = v;
end
function Vect:getAllCDebug()
local db = Vect.db.profile;
return db["allCDebug"];
end
function Vect:setAllCDebug(v)
local db = Vect.db.profile;
db["allCDebug"] = v;
end

View File

@ -4,11 +4,12 @@
## Title: Vect ## Title: Vect
## Notes: Verot's Enemy Cooldown Tracker. ## Notes: Verot's Enemy Cooldown Tracker.
## DefaultState: Enabled ## DefaultState: Enabled
## OptionalDeps: Ace3, LibSharedMedia-3.0 ## OptionalDeps: Ace3
## SavedVariables: VectDB ## SavedVariables: VectDB
## Version: 0.1 ## Version: 0.75
embeds.xml embeds.xml
data\global.lua data\global.lua
data\spells.lua data\spells.lua
data\options.lua
Vect.lua Vect.lua

View File

@ -1,3 +1,4 @@
Vect = LibStub("AceAddon-3.0"):NewAddon("Vect", "AceConsole-3.0", "AceEvent-3.0") Vect = LibStub("AceAddon-3.0"):NewAddon("Vect", "AceConsole-3.0", "AceEvent-3.0")
Vect.appName = "Vect" Vect.appName = "Vect"
Vect.dbName = "VectDB" Vect.dbName = "VectDB"

197
data/options.lua Normal file
View File

@ -0,0 +1,197 @@
local adbo = LibStub("AceDBOptions-3.0")
function Vect:GetVectOptions()
local db = self.db.profile;
local options = {
type = "group", name = "Vect", childGroups = "tab",
args = {
enabled = {
type = "toggle", name = "Enabled", desc = "Enable/Disable the addon", order = 0,
get = function() return Vect:IsEnabled() end,
set = function(_, v)
Vect:setEnabledOrDisabled(v);
end
},
lock = {
type = "toggle", name = "Lock", desc = "Uncheck to move the frames", order = 1,
get = function() return Vect:isLocked() end,
set = function(_, v)
db.locked = v;
if v then Vect:LockFrames() else Vect:UnlockFrames() end;
end
},
targetandfocus = {
type = "group", name = "T. and F. CDs", desc = "Cooldown frame's settings.", childGroups = "tab", order = 3,
args = Vect:getTargetandFocusOptions();
},
droptions = {
type = "group", name = "T. and F. DRs", desc = "DR frame's settings.", childGroups = "tab",order = 4,
args = Vect:getDROptions();
},
selfdr = {
type = "group", name = "Self DRs", desc = "Self DR frame's settings.", childGroups = "tab",order = 5,
args = Vect:getSelfDROptions()
},
debugoptions = {
type = "group", name = "Debug", desc = "Debug settings.", childGroups = "tab",order = 6,
args = Vect:getDebugOptions();
}
}
}
return options;
end
function Vect:getTargetandFocusOptions()
local args = {
targetHeader = {
type = "header", name = "Target's settings", order = 10
},
targettoggle = {
type = "toggle", name = "Target", desc = "Enable/Disable showing the target's cooldowns", order = 3,
get = function() return Vect:isPartEnabled("target") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("target", v);
end
},
targetrange = {
type = "range", name = "Target's size", order = 11, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("target") end,
set = function(_, v)
Vect:setFrameSize("target", v);
end
},
targetGrowSelect = {
type = "select", style = "dropdown", name = "targetGrow",
desc = "Change which way the target's cooldowns will grow", order = 12,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("target") end,
set = function(_, v)
Vect:setGrowOrder("target", v);
end
},
targetSortSelect = {
type = "select", style = "dropdown", name = "targetSortOrder",
desc = "Change the target's cooldowns's sort order", order = 13,
values = {
["1"] = "Ascending",
["2"] = "Descending",
["3"] = "Recent first",
["4"] = "Recent Last",
["5"] = "Random"
},
get = function() return Vect:getSortOrder("target") end,
set = function(_, v)
Vect:setSortOrder("target", v);
end
},
focusHeader = {
type = "header", name = "Focus's settings", order = 14
},
focustoggle = {
type = "toggle", name = "Focus", desc = "Enable/Disable showing the focus's cooldowns", order = 8,
get = function() return Vect:isPartEnabled("focus") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("focus", v);
end
},
focusRange = {
type = "range", name = "Focus's size", order = 15, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("focus") end,
set = function(_, v)
Vect:setFrameSize("focus", v);
end
},
focusGrowSelect = {
type = "select", style = "dropdown", name = "focusGrow",
desc = "Change which way the focus's cooldowns will grow", order = 16,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("focus") end,
set = function(_, v)
Vect:setGrowOrder("focus", v);
end
},
focusSortSelect = {
type = "select", style = "dropdown", name = "focusSortOrder",
desc = "Change the focus's cooldowns's sort order", order = 17,
values = {
["1"] = "Ascending",
["2"] = "Descending",
["3"] = "Recent first",
["4"] = "Recent Last",
["5"] = "Random"
},
get = function() return Vect:getSortOrder("focus") end,
set = function(_, v)
Vect:setSortOrder("focus", v);
end
}
}
return args;
end
--order 20-40
function Vect:getDROptions()
local args = {
}
return args;
end
--order 40-50
function Vect:getSelfDROptions()
local args = {
}
return args;
end
--order 50+
function Vect:getDebugOptions()
local args = {
spellcast = {
type = "toggle", name = "SpellCast", desc = "Enable/Disable writing out SPELL_CAST_SUCCESS events.", order = 50,
get = function() return Vect:getSpellCastDebug() end,
set = function(_, v)
Vect:setSpellCastDebug(v);
end
},
spellAura = {
type = "toggle", name = "SpellAura", desc = "Enable/Disablewriting out SPLL_AURA_* events", order = 51,
get = function() return Vect:getSpellAuraDebug() end,
set = function(_, v)
Vect:setSpellAuraDebug(v);
end
},
allLog = {
type = "toggle", name = "Uber debug", desc = "Enable/Disable writing out all combatlog events", order = 52,
get = function() return Vect:getAllCDebug() end,
set = function(_, v)
Vect:setAllCDebug(v);
end
},
debugselect = {
type = "select", style = "dropdown", name = "debuglevel",
desc = "Change the debuglevel", order = 53,
values = {
["0"] = "No Messages",
},
get = function() return Vect:getDebugLevel() end,
set = function(_, v)
Vect:setDebugLevel(v);
end
},
}
return args;
end