-Separated the addon into smaller files.

-Started implementing dr's number's
This commit is contained in:
Relintai 2016-05-06 15:49:39 +02:00
parent e23a7487f9
commit 57aba8eb77
7 changed files with 1180 additions and 1099 deletions

773
Vect.lua
View File

@ -1,6 +1,9 @@
--TODOS: --TODOS:
--DR timers --DR timers
--fix config for drs, add in displaying the number of drs, add in a config -> where to show them uncomment enableds
--fix libdrdata, its dr groups are bad
--spec detection
--Way to show pet cds on the master -> currently looks impossible --Way to show pet cds on the master -> currently looks impossible
--"Globals" --"Globals"
@ -60,7 +63,9 @@ Vect.defaults = {
xPos = 380, xPos = 380,
yPos = 380, yPos = 380,
growOrder = 2, growOrder = 2,
sortOrder = 5 sortOrder = 5,
drnumsize = 14,
drnumposition = 1
}, },
focusdr = { focusdr = {
enabled = true, enabled = true,
@ -68,7 +73,9 @@ Vect.defaults = {
xPos = 380, xPos = 380,
yPos = 380, yPos = 380,
growOrder = 2, growOrder = 2,
sortOrder = 5 sortOrder = 5,
drnumsize = 14,
drnumposition = 1
}, },
selfdr = { selfdr = {
enabled = true, enabled = true,
@ -76,7 +83,9 @@ Vect.defaults = {
xPos = 380, xPos = 380,
yPos = 380, yPos = 380,
growOrder = 2, growOrder = 2,
sortOrder = 5 sortOrder = 5,
drnumsize = 14,
drnumposition = 1
} }
} }
} }
@ -244,442 +253,6 @@ function Vect:ZONE_CHANGED_NEW_AREA()
end end
end end
--DR db functions
function Vect:DRDebuffGained(spellID, dstGUID, isPlayer)
local db = Vect.db.profile;
if not db["enabled"] then return end;
if not Vect.drs[dstGUID] then
Vect.drs[dstGUID] = {}
end
local drCat = libDRData:GetSpellCategory(spellID);
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
if not Vect.drs[dstGUID][drCat] then
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
local diminished = 1;
local isDiminishingStarted = false;
Vect.drs[dstGUID][drCat] = {
currentTime,
endTime,
cd,
spellIcon,
spellID,
diminished,
isDiminishingStarted,
drCat
}
else
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.drs[dstGUID][drCat][1] = currentTime;
Vect.drs[dstGUID][drCat][2] = currentTime + cd;
Vect.drs[dstGUID][drCat][4] = spellIcon;
Vect.drs[dstGUID][drCat][5] = spellID;
Vect.drs[dstGUID][drCat][6] = Vect.drs[dstGUID][drCat][6] + 1;
Vect.drs[dstGUID][drCat][7] = false;
end
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if self.targets["target"] == dstGUID then
self:ReassignDRs("targetdr");
end
if self.targets["focus"] == dstGUID then
self:ReassignDRs("focusdr");
end
if self.targets["self"] == dstGUID then
self:ReassignDRs("selfdr");
end
end
function Vect:DRDebuffFaded(spellID, dstGUID, isPlayer)
local db = Vect.db.profile;
--if not db["enabled"] then return end;
if not Vect.drs[dstGUID] then
Vect.drs[dstGUID] = {}
end
local drCat = libDRData:GetSpellCategory(spellID);
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
if not Vect.drs[dstGUID][drCat] then
--means we didn't see it applied
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
local diminished = 1;
local isDiminishingStarted = true;
Vect.drs[dstGUID][drCat] = {
currentTime,
endTime,
cd,
spellIcon,
spellID,
diminished,
isDiminishingStarted,
drCat
}
else
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.drs[dstGUID][drCat][1] = currentTime;
Vect.drs[dstGUID][drCat][2] = endTime;
Vect.drs[dstGUID][drCat][7] = true;
end
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if self.targets["target"] == dstGUID then
self:ReassignDRs("targetdr");
end
if self.targets["focus"] == dstGUID then
self:ReassignDRs("focusdr");
end
if self.targets["self"] == dstGUID then
self:ReassignDRs("selfdr");
end
end
--gets called when a cd is finished, reassigns the cds to frames.
function Vect:ReassignCds(which)
local db = Vect.db.profile;
--bail out early, if frames are disabled
if not db[which]["enabled"] or not db["enabled"] then return end;
--first hide all
for i = 1, 23 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
--check if frames are unlocked
if not db["locked"] then return end;
--check if we need to display them for the player
if not db["selfCDRegister"] and self.targets[which] == UnitGUID("player") then return end;
--check if we have cooldown for that unit
if not self.cds[self.targets[which]] then return end;
--sort them
local tmp = Vect:SortCDs(which);
--let's fill them up
local i = 1;
for k, v in ipairs(tmp) do
local frame = Vect.frames[which][i]["frame"];
local text = Vect.frames[which][i]["texture"];
text:SetTexture(v["spellIcon"]);
local CoolDown = Vect.frames[which][i]["cooldown"];
CoolDown:SetCooldown(v["currentTime"], v["cd"]);
frame:Show();
i = i + 1;
end
end
function Vect:ReassignDRs(which)
local db = Vect.db.profile;
--bail out early, if frames are disabled
--if not db[which]["enabled"] or not db["enabled"] then return end;
--first hide all
for i = 1, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
--check if frames are unlocked
if not db["locked"] then return end;
--check if we have cooldown for that unit
local whichs = "";
if which == "targetdr" then
whichs = "target";
elseif which == "focusdr" then
whichs = "focus";
else
whichs = "self";
end
if not self.drs[self.targets[whichs]] then return end;
--sort them
local tmp = Vect:SortDRs(whichs);
--let's fill them up
local i = 1;
for k, v in ipairs(tmp) do
--self:Print(v["spellID"]);
local frame = Vect.frames[which][i]["frame"];
local text = Vect.frames[which][i]["texture"];
text:SetTexture(v["spellIcon"]);
local CoolDown = Vect.frames[which][i]["cooldown"];
if v["isDiminishingStarted"] then
CoolDown:SetCooldown(v["currentTime"], v["cd"]);
else
CoolDown:SetCooldown(v["currentTime"], 0);
end
frame:Show();
i = i + 1;
end
end
function Vect:AddCd(srcGUID, spellID)
local db = Vect.db.profile;
if not db["enabled"] then return end;
if not Vect.cds[srcGUID] then Vect.cds[srcGUID] = {} end
local cd, reset = Vect.spells[spellID][1], Vect.spells[spellID][2];
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.cds[srcGUID][spellID] = {
currentTime,
endTime,
cd,
spellIcon,
spellID
}
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if reset then
Vect:CdRemoval(srcGUID, reset);
end
--self:Print(self.targets["target"]);
--self:Print(s
if self.targets["target"] == srcGUID then
self:ReassignCds("target");
end
if self.targets["focus"] == srcGUID then
self:ReassignCds("focus");
end
end
function Vect:CdRemoval(srcGUID, resetArray)
if not self.cds[srcGUID] then return end
for k, v in pairs(self.cds[srcGUID]) do
for j, x in pairs(resetArray) do
if v[5] == x then
--self:Print("Removed cd: " .. v[5]);
self.cds[srcGUID][v[5]] = nil;
end
end
end
end
function Vect:SortCDs(which)
local db = Vect.db.profile;
local tmp = {};
--make the tmp table
local i = 1;
for k, v in pairs(self.cds[self.targets[which]]) do
tmp[i] = {
currentTime = v[1],
endTime = v[2],
cd = v[3],
spellIcon = v[4],
spellID = v[5]
};
--self:Print(v[1] .. v[2] .. v[3] .. v[4] .. v[5])
--self:Print(tmp[i]["currentTime"] .. " " .. tmp[i]["endTime"] .. " " .. tmp[i]["cd"] .. " " .. tmp[i][4] .. " " .. tmp[i][5])
i = i + 1;
end
if not tmp then return end;
if db[which]["sortOrder"] == "1" then --["1"] = "Ascending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "2" then --["2"] = "Descending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "3" then --["3"] = "Ascending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "4" then --["4"] = "Descending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "5" then --["5"] = "Recent first",
table.sort(tmp, function(a, b) return Vect:ComparerRecentFirst(a, b) end);
elseif db[which]["sortOrder"] == "6" then --["6"] = "Recent Last",
table.sort(tmp, function(a, b) return Vect:ComparerRecentLast(a, b) end);
end
--["7"] = "No order"
return tmp;
end
function Vect:SortDRs(which)
local db = Vect.db.profile;
local tmp = {};
--make the tmp table
local i = 1;
for k, v in pairs(self.drs[self.targets[which]]) do
tmp[i] = {
currentTime = v[1],
endTime = v[2],
cd = v[3],
spellIcon = v[4],
spellID = v[5],
diminished = v[6],
isDiminishingStarted = v[7]
};
--self:Print(v[1] .. v[2] .. v[3] .. v[4] .. v[5])
--self:Print(tmp[i]["currentTime"] .. " " .. tmp[i]["endTime"] .. " " .. tmp[i]["cd"] .. " " .. tmp[i][4] .. " " .. tmp[i][5])
i = i + 1;
end
if not tmp then return end;
if which == "self" then which = "selfdr" end
if db[which]["sortOrder"] == "1" then --["1"] = "Ascending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "2" then --["2"] = "Descending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "3" then --["3"] = "Ascending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "4" then --["4"] = "Descending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "5" then --["5"] = "Recent first",
table.sort(tmp, function(a, b) return Vect:ComparerRecentFirst(a, b) end);
elseif db[which]["sortOrder"] == "6" then --["6"] = "Recent Last",
table.sort(tmp, function(a, b) return Vect:ComparerRecentLast(a, b) end);
end
--["7"] = "No order"
return tmp;
end
function Vect:CreateFrames(which)
for i = 1, 23 do
local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(150);
frame:SetHeight(150);
if i == 1 then
frame:SetScript("OnUpdate", function() self:VOnTimerUpdate(which) end)
end
local text = frame:CreateTexture();
text:SetTexture("Interface\\Icons\\Spell_Arcane_Blink")
text:SetAllPoints(frame);
frame.texture = text;
local CoolDown = CreateFrame("Cooldown", "VectCoolDown" .. i, frame);
CoolDown:SetAllPoints()
CoolDown:SetCooldown(GetTime(), 50);
frame:Hide();
Vect.frames[which][i] = {}
Vect.frames[which][i]["frame"] = frame;
Vect.frames[which][i]["texture"] = text;
Vect.frames[which][i]["cooldown"] = CoolDown;
end
end
function Vect:CreateDRFrames(which)
for i = 1, 18 do
local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(150);
frame:SetHeight(150);
local wh = "";
if which == "targetdr" then
wh = "target";
elseif which == "focusdr" then
wh = "focus";
else
wh = "self";
end
if i == 1 then
frame:SetScript("OnUpdate", function() self:VOnDRTimerUpdate(wh) end)
end
local text = frame:CreateTexture();
text:SetTexture("Interface\\Icons\\Spell_Arcane_Blink")
text:SetAllPoints(frame);
frame.texture = text;
local CoolDown = CreateFrame("Cooldown", "VectCoolDown" .. i, frame);
CoolDown:SetAllPoints()
CoolDown:SetCooldown(GetTime(), 50);
local t = frame:CreateFontString(nil, "OVERLAY");
t:SetNonSpaceWrap(false);
t:SetPoint("CENTER", frame, "CENTER", 0, 0);
t:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME")
--frame:Hide();
Vect.frames[which][i] = {}
Vect.frames[which][i]["frame"] = frame;
Vect.frames[which][i]["texture"] = text;
Vect.frames[which][i]["cooldown"] = CoolDown;
Vect.frames[which][i]["text"] = t;
end
end
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
local frame = Vect.frames[which][i]["frame"];
frame:ClearAllPoints();
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(size);
frame:SetHeight(size);
local text = Vect.frames[which][i]["texture"];
text:SetAllPoints(frame);
frame.texture = text;
--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"];
CoolDown:SetAllPoints();
--frame:Show();
end
end
function Vect:MoveDRTimersStop(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, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:ClearAllPoints();
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(size);
frame:SetHeight(size);
local text = Vect.frames[which][i]["texture"];
text:SetAllPoints(frame);
frame.texture = text;
--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"];
CoolDown:SetAllPoints();
--frame:Show();
end
end
function Vect:ApplySettings() function Vect:ApplySettings()
local db = Vect.db.profile; local db = Vect.db.profile;
Vect:MoveTimersStop("target"); Vect:MoveTimersStop("target");
@ -694,325 +267,3 @@ function Vect:ApplySettings()
Vect:ReassignDRs("selfdr"); Vect:ReassignDRs("selfdr");
if not db["locked"] then self:ShowMovableFrames() end; if not db["locked"] then self:ShowMovableFrames() end;
end end
function Vect:VOnTimerUpdate(which)
--check if we have cooldown for that unit
if not self.cds[self.targets[which]] then return end
local t = GetTime();
--let's check if one of the cooldowns finished
for k, v in pairs(self.cds[self.targets[which]]) do
if v[2] <= t then
self.cds[self.targets[which]][v[5]] = nil;
--we have to update both, because if somebody is targeted and focused since sorting is
--implemented it triggers only one update, probably it had bugs before too, but got unnoticed
self:ReassignCds("target");
self:ReassignCds("focus");
end
end
end
function Vect:VOnDRTimerUpdate(which)
--check if we have dr for that unit
if not self.drs[self.targets[which]] then return end
local t = GetTime();
--let's check if one of the cooldowns finished
for k, v in pairs(self.drs[self.targets[which]]) do
if v[7] == true and v[2] <= t then
self.drs[self.targets[which]][v[8]] = nil;
--we have to update every three, because if somebody is targeted and focused since sorting is
--implemented it triggers only one update, probably it had bugs before too, but got unnoticed
self:ReassignDRs("targetdr");
self:ReassignDRs("focusdr");
self:ReassignDRs("selfdr");
end
end
end
function Vect:VectDisable()
self:Reset();
self:ApplySettings();
--hide the frames
Vect:HideFrames();
--self:Disable();
end
function Vect:VectEnable()
--self:Enable();
self:Reset();
self:ApplySettings();
end
--global utility
function Vect:HideFrames()
for i = 1, 23 do
local frame = self.frames["target"][i]["frame"];
frame:Hide();
end
for i = 1, 23 do
local frame = self.frames["focus"][i]["frame"];
frame:Hide();
end
end
--Utility Functions for the options
--enable
function Vect:isEnabled()
local db = Vect.db.profile;
return db["enabled"];
end
function Vect:setEnabledOrDisabled(enable)
local db = Vect.db.profile;
db["enabled"] = enable;
if enable then
Vect:VectEnable()
else
Vect:VectDisable()
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;
--hide all those frames
if not enable then
for i = 1, 23 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
else
self:ReassignCds(which);
end
end
function Vect:SetDRPartEnabledOrDisabled(which, enable)
local db = Vect.db.profile;
db[which]["enabled"] = enable;
--hide all those frames
if not enable then
for i = 1, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
else
--self:ReassignCds(which);
end
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, 5 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 t = frame:CreateFontString(nil, "OVERLAY");
t:SetNonSpaceWrap(false);
t:SetPoint("CENTER", frame, "CENTER", 2, 0);
t:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME")
local ttext = "";
if i == 1 then
ttext = "T";
elseif i == 2 then
ttext = "F";
elseif i == 3 then
ttext = "TDR";
elseif i == 4 then
ttext = "FDR";
elseif i == 5 then
ttext = "SDR";
end
t:SetText(ttext);
local which = "";
if i == 1 then
which = "target";
elseif i == 2 then
which = "focus";
elseif i == 3 then
which = "targetdr";
elseif i == 4 then
which = "focusdr";
elseif i == 5 then
which = "selfdr";
end
frame.DragID = which;
Vect.MovableFrames[i] = {}
Vect.MovableFrames[i]["frame"] = frame;
Vect.MovableFrames[i]["texture"] = text;
Vect.MovableFrames[i]["text"] = t;
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
function Vect:setDRGrowOrder(which, v)
local db = Vect.db.profile;
db[which]["growOrder"] = v;
Vect:MoveDRTimersStop(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
function Vect:getSelfCDRegister()
local db = Vect.db.profile;
return db["selfCDRegister"];
end
function Vect:setSelfCDRegister(v)
local db = Vect.db.profile;
db["selfCDRegister"] = v;
Vect:ReassignCds("target");
Vect:ReassignCds("focus");
end

View File

@ -11,6 +11,9 @@
embeds.xml embeds.xml
data\global.lua data\global.lua
data\spells.lua data\spells.lua
data\optiontable.lua
data\options.lua data\options.lua
data\sorters.lua data\sorters.lua
data\drs.lua
data\cooldowns.lua
Vect.lua Vect.lua

196
data/cooldowns.lua Normal file
View File

@ -0,0 +1,196 @@
--"Globals"
local aceDB = LibStub("AceDB-3.0");
local aceCDialog = LibStub("AceConfigDialog-3.0");
local aceConfig = LibStub("AceConfig-3.0");
local libSharedMedia = LibStub("LibSharedMedia-3.0");
local libDRData = LibStub('DRData-1.0');
--gets called when a cd is finished, reassigns the cds to frames.
function Vect:ReassignCds(which)
local db = Vect.db.profile;
--bail out early, if frames are disabled
if not db[which]["enabled"] or not db["enabled"] then return end;
--first hide all
for i = 1, 23 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
--check if frames are unlocked
if not db["locked"] then return end;
--check if we need to display them for the player
if not db["selfCDRegister"] and self.targets[which] == UnitGUID("player") then return end;
--check if we have cooldown for that unit
if not self.cds[self.targets[which]] then return end;
--sort them
local tmp = Vect:SortCDs(which);
--let's fill them up
local i = 1;
for k, v in ipairs(tmp) do
local frame = Vect.frames[which][i]["frame"];
local text = Vect.frames[which][i]["texture"];
text:SetTexture(v["spellIcon"]);
local CoolDown = Vect.frames[which][i]["cooldown"];
CoolDown:SetCooldown(v["currentTime"], v["cd"]);
frame:Show();
i = i + 1;
end
end
function Vect:AddCd(srcGUID, spellID)
local db = Vect.db.profile;
if not db["enabled"] then return end;
if not Vect.cds[srcGUID] then Vect.cds[srcGUID] = {} end
local cd, reset = Vect.spells[spellID][1], Vect.spells[spellID][2];
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.cds[srcGUID][spellID] = {
currentTime,
endTime,
cd,
spellIcon,
spellID
}
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if reset then
Vect:CdRemoval(srcGUID, reset);
end
--self:Print(self.targets["target"]);
--self:Print(s
if self.targets["target"] == srcGUID then
self:ReassignCds("target");
end
if self.targets["focus"] == srcGUID then
self:ReassignCds("focus");
end
end
function Vect:CdRemoval(srcGUID, resetArray)
if not self.cds[srcGUID] then return end
for k, v in pairs(self.cds[srcGUID]) do
for j, x in pairs(resetArray) do
if v[5] == x then
--self:Print("Removed cd: " .. v[5]);
self.cds[srcGUID][v[5]] = nil;
end
end
end
end
function Vect:SortCDs(which)
local db = Vect.db.profile;
local tmp = {};
--make the tmp table
local i = 1;
for k, v in pairs(self.cds[self.targets[which]]) do
tmp[i] = {
currentTime = v[1],
endTime = v[2],
cd = v[3],
spellIcon = v[4],
spellID = v[5]
};
--self:Print(v[1] .. v[2] .. v[3] .. v[4] .. v[5])
--self:Print(tmp[i]["currentTime"] .. " " .. tmp[i]["endTime"] .. " " .. tmp[i]["cd"] .. " " .. tmp[i][4] .. " " .. tmp[i][5])
i = i + 1;
end
if not tmp then return end;
if db[which]["sortOrder"] == "1" then --["1"] = "Ascending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "2" then --["2"] = "Descending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "3" then --["3"] = "Ascending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "4" then --["4"] = "Descending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "5" then --["5"] = "Recent first",
table.sort(tmp, function(a, b) return Vect:ComparerRecentFirst(a, b) end);
elseif db[which]["sortOrder"] == "6" then --["6"] = "Recent Last",
table.sort(tmp, function(a, b) return Vect:ComparerRecentLast(a, b) end);
end
--["7"] = "No order"
return tmp;
end
function Vect:CreateFrames(which)
for i = 1, 23 do
local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(150);
frame:SetHeight(150);
if i == 1 then
frame:SetScript("OnUpdate", function() self:VOnTimerUpdate(which) end)
end
local text = frame:CreateTexture();
text:SetTexture("Interface\\Icons\\Spell_Arcane_Blink")
text:SetAllPoints(frame);
frame.texture = text;
local CoolDown = CreateFrame("Cooldown", "VectCoolDown" .. i, frame);
CoolDown:SetAllPoints()
CoolDown:SetCooldown(GetTime(), 50);
frame:Hide();
Vect.frames[which][i] = {}
Vect.frames[which][i]["frame"] = frame;
Vect.frames[which][i]["texture"] = text;
Vect.frames[which][i]["cooldown"] = CoolDown;
end
end
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
local frame = Vect.frames[which][i]["frame"];
frame:ClearAllPoints();
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(size);
frame:SetHeight(size);
local text = Vect.frames[which][i]["texture"];
text:SetAllPoints(frame);
frame.texture = text;
--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"];
CoolDown:SetAllPoints();
--frame:Show();
end
end
function Vect:VOnTimerUpdate(which)
--check if we have cooldown for that unit
if not self.cds[self.targets[which]] then return end
local t = GetTime();
--let's check if one of the cooldowns finished
for k, v in pairs(self.cds[self.targets[which]]) do
if v[2] <= t then
self.cds[self.targets[which]][v[5]] = nil;
--we have to update both, because if somebody is targeted and focused since sorting is
--implemented it triggers only one update, probably it had bugs before too, but got unnoticed
self:ReassignCds("target");
self:ReassignCds("focus");
end
end
end

289
data/drs.lua Normal file
View File

@ -0,0 +1,289 @@
--"Globals"
local aceDB = LibStub("AceDB-3.0");
local aceCDialog = LibStub("AceConfigDialog-3.0");
local aceConfig = LibStub("AceConfig-3.0");
local libSharedMedia = LibStub("LibSharedMedia-3.0");
local libDRData = LibStub('DRData-1.0');
--DR db functions
function Vect:DRDebuffGained(spellID, dstGUID, isPlayer)
local db = Vect.db.profile;
if not db["enabled"] then return end;
if not Vect.drs[dstGUID] then
Vect.drs[dstGUID] = {}
end
local drCat = libDRData:GetSpellCategory(spellID);
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
if not Vect.drs[dstGUID][drCat] then
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
local diminished = 1;
local isDiminishingStarted = false;
Vect.drs[dstGUID][drCat] = {
currentTime,
endTime,
cd,
spellIcon,
spellID,
diminished,
isDiminishingStarted,
drCat
}
else
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.drs[dstGUID][drCat][1] = currentTime;
Vect.drs[dstGUID][drCat][2] = currentTime + cd;
Vect.drs[dstGUID][drCat][4] = spellIcon;
Vect.drs[dstGUID][drCat][5] = spellID;
Vect.drs[dstGUID][drCat][6] = Vect.drs[dstGUID][drCat][6] + 1;
Vect.drs[dstGUID][drCat][7] = false;
end
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if self.targets["target"] == dstGUID then
self:ReassignDRs("targetdr");
end
if self.targets["focus"] == dstGUID then
self:ReassignDRs("focusdr");
end
if self.targets["self"] == dstGUID then
self:ReassignDRs("selfdr");
end
end
function Vect:DRDebuffFaded(spellID, dstGUID, isPlayer)
local db = Vect.db.profile;
--if not db["enabled"] then return end;
if not Vect.drs[dstGUID] then
Vect.drs[dstGUID] = {}
end
local drCat = libDRData:GetSpellCategory(spellID);
local spellName, spellRank, spellIcon = GetSpellInfo(spellID);
if not Vect.drs[dstGUID][drCat] then
--means we didn't see it applied
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
local diminished = 1;
local isDiminishingStarted = true;
Vect.drs[dstGUID][drCat] = {
currentTime,
endTime,
cd,
spellIcon,
spellID,
diminished,
isDiminishingStarted,
drCat
}
else
local cd = 18;
local currentTime = GetTime();
local endTime = currentTime + cd;
Vect.drs[dstGUID][drCat][1] = currentTime;
Vect.drs[dstGUID][drCat][2] = endTime;
Vect.drs[dstGUID][drCat][7] = true;
end
--self:Print(Vect.cds[srcGUID][spellID][1] .. " " .. Vect.cds[srcGUID][spellID][2] .. " " .. Vect.cds[srcGUID][spellID][3]);
if self.targets["target"] == dstGUID then
self:ReassignDRs("targetdr");
end
if self.targets["focus"] == dstGUID then
self:ReassignDRs("focusdr");
end
if self.targets["self"] == dstGUID then
self:ReassignDRs("selfdr");
end
end
function Vect:ReassignDRs(which)
local db = Vect.db.profile;
--bail out early, if frames are disabled
--if not db[which]["enabled"] or not db["enabled"] then return end;
--first hide all
for i = 1, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end
--check if frames are unlocked
if not db["locked"] then return end;
--check if we have cooldown for that unit
local whichs = "";
if which == "targetdr" then
whichs = "target";
elseif which == "focusdr" then
whichs = "focus";
else
whichs = "self";
end
if not self.drs[self.targets[whichs]] then return end;
--sort them
local tmp = Vect:SortDRs(whichs);
--let's fill them up
local i = 1;
for k, v in ipairs(tmp) do
--self:Print(v["spellID"]);
local frame = Vect.frames[which][i]["frame"];
local text = Vect.frames[which][i]["texture"];
text:SetTexture(v["spellIcon"]);
local CoolDown = Vect.frames[which][i]["cooldown"];
if v["isDiminishingStarted"] then
CoolDown:SetCooldown(v["currentTime"], v["cd"]);
else
CoolDown:SetCooldown(v["currentTime"], 0);
end
frame:Show();
i = i + 1;
end
end
function Vect:SortDRs(which)
local db = Vect.db.profile;
local tmp = {};
--make the tmp table
local i = 1;
for k, v in pairs(self.drs[self.targets[which]]) do
tmp[i] = {
currentTime = v[1],
endTime = v[2],
cd = v[3],
spellIcon = v[4],
spellID = v[5],
diminished = v[6],
isDiminishingStarted = v[7]
};
--self:Print(v[1] .. v[2] .. v[3] .. v[4] .. v[5])
--self:Print(tmp[i]["currentTime"] .. " " .. tmp[i]["endTime"] .. " " .. tmp[i]["cd"] .. " " .. tmp[i][4] .. " " .. tmp[i][5])
i = i + 1;
end
if not tmp then return end;
if which == "self" then which = "selfdr" end
if db[which]["sortOrder"] == "1" then --["1"] = "Ascending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "2" then --["2"] = "Descending (CD left)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDLeft(a, b) end);
elseif db[which]["sortOrder"] == "3" then --["3"] = "Ascending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerAscendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "4" then --["4"] = "Descending (CD total)",
table.sort(tmp, function(a, b) return Vect:ComparerDescendingCDTotal(a, b) end);
elseif db[which]["sortOrder"] == "5" then --["5"] = "Recent first",
table.sort(tmp, function(a, b) return Vect:ComparerRecentFirst(a, b) end);
elseif db[which]["sortOrder"] == "6" then --["6"] = "Recent Last",
table.sort(tmp, function(a, b) return Vect:ComparerRecentLast(a, b) end);
end
--["7"] = "No order"
return tmp;
end
function Vect:CreateDRFrames(which)
for i = 1, 18 do
local frame = CreateFrame("Frame", nil, UIParent, nil);
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(150);
frame:SetHeight(150);
local wh = "";
if which == "targetdr" then
wh = "target";
elseif which == "focusdr" then
wh = "focus";
else
wh = "self";
end
if i == 1 then
frame:SetScript("OnUpdate", function() self:VOnDRTimerUpdate(wh) end)
end
local text = frame:CreateTexture();
text:SetTexture("Interface\\Icons\\Spell_Arcane_Blink")
text:SetAllPoints(frame);
frame.texture = text;
local CoolDown = CreateFrame("Cooldown", "VectCoolDown" .. i, frame);
CoolDown:SetAllPoints()
CoolDown:SetCooldown(GetTime(), 50);
local t = frame:CreateFontString(nil, "OVERLAY");
t:SetNonSpaceWrap(false);
t:SetPoint("CENTER", frame, "CENTER", 0, 0);
t:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME")
--frame:Hide();
Vect.frames[which][i] = {}
Vect.frames[which][i]["frame"] = frame;
Vect.frames[which][i]["texture"] = text;
Vect.frames[which][i]["cooldown"] = CoolDown;
Vect.frames[which][i]["text"] = t;
end
end
function Vect:MoveDRTimersStop(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, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:ClearAllPoints();
frame:SetFrameStrata("MEDIUM");
frame:SetWidth(size);
frame:SetHeight(size);
local text = Vect.frames[which][i]["texture"];
text:SetAllPoints(frame);
frame.texture = text;
--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"];
CoolDown:SetAllPoints();
--frame:Show();
end
end
function Vect:VOnDRTimerUpdate(which)
--check if we have dr for that unit
if not self.drs[self.targets[which]] then return end
local t = GetTime();
--let's check if one of the cooldowns finished
for k, v in pairs(self.drs[self.targets[which]]) do
if v[7] == true and v[2] <= t then
self.drs[self.targets[which]][v[8]] = nil;
--we have to update every three, because if somebody is targeted and focused since sorting is
--implemented it triggers only one update, probably it had bugs before too, but got unnoticed
self:ReassignDRs("targetdr");
self:ReassignDRs("focusdr");
self:ReassignDRs("selfdr");
end
end
end

View File

@ -3,3 +3,14 @@ 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"
Vect.version = "0.1" Vect.version = "0.1"
function Vect:HideFrames()
for i = 1, 23 do
local frame = self.frames["target"][i]["frame"];
frame:Hide();
end
for i = 1, 23 do
local frame = self.frames["focus"][i]["frame"];
frame:Hide();
end
end

View File

@ -1,349 +1,307 @@
local aceDBOptions = LibStub("AceDBOptions-3.0") --"Globals"
local aceDB = LibStub("AceDB-3.0");
local aceCDialog = LibStub("AceConfigDialog-3.0");
local aceConfig = LibStub("AceConfig-3.0");
local libSharedMedia = LibStub("LibSharedMedia-3.0");
local libDRData = LibStub('DRData-1.0');
function Vect:GetVectOptions() --Utility Functions for the options
local db = self.db.profile;
local options = { function Vect:VectDisable()
type = "group", name = "Vect", childGroups = "tab", self:Reset();
args = { self:ApplySettings();
enabled = { --hide the frames
type = "toggle", name = "Enabled", desc = "Enable/Disable the addon", order = 0, Vect:HideFrames();
get = function() return Vect:isEnabled() end, --self:Disable();
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 = "CDs", desc = "Cooldown frame's settings.", childGroups = "tab", order = 2,
args = Vect:getTargetandFocusOptions();
},
droptions = {
type = "group", name = "DRs", desc = "DR frame's settings.", childGroups = "tab",order = 3,
args = Vect:getDROptions();
},
selfdr = {
type = "group", name = "Self DRs", desc = "Self DR frame's settings.", childGroups = "tab",order = 4,
args = Vect:getSelfDROptions()
},
debugoptions = {
type = "group", name = "Debug", desc = "Debug settings.", childGroups = "tab", order = 5,
args = Vect:getDebugOptions();
},
profileoptions = aceDBOptions:GetOptionsTable(self.db)
}
}
return options;
end
--order 10-20
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 = 11,
get = function() return Vect:isPartEnabled("target") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("target", v);
end
},
targetrange = {
type = "range", name = "Target's size", order = 12, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("target") end,
set = function(_, v)
Vect:setFrameSize("target", v);
end end
}, function Vect:VectEnable()
targetGrowSelect = { --self:Enable();
type = "select", style = "dropdown", name = "targetGrow", self:Reset();
desc = "Change which way the target's cooldowns will grow", order = 13, self:ApplySettings();
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 = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("target") end,
set = function(_, v)
Vect:setSortOrder("target", v);
end
},
focusHeader = {
type = "header", name = "Focus's settings", order = 15
},
focustoggle = {
type = "toggle", name = "Focus", desc = "Enable/Disable showing the focus's cooldowns", order = 16,
get = function() return Vect:isPartEnabled("focus") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("focus", v);
end
},
focusRange = {
type = "range", name = "Focus's size", order = 17, 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 = 18,
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 = 19,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("focus") end,
set = function(_, v)
Vect:setSortOrder("focus", v);
end
}
}
return args;
end end
--order 20-40
function Vect:getDROptions() --enable
local args = { function Vect:isEnabled()
targetdrHeader = { local db = Vect.db.profile;
type = "header", name = "Target's DR settings", order = 10 return db["enabled"];
},
targetdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the target's DRs.", order = 11,
get = function() return Vect:isPartEnabled("targetdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("targetdr", v);
end
},
targetdrrange = {
type = "range", name = "Target's DRs size", order = 12, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("targetdr") end,
set = function(_, v)
Vect:setFrameSize("targetdr", v);
end end
}, function Vect:setEnabledOrDisabled(enable)
targetdrGrowSelect = { local db = Vect.db.profile;
type = "select", style = "dropdown", name = "targetDRGrow", db["enabled"] = enable;
desc = "Change which way the target's cooldowns will grow", order = 13, if enable then
values = { Vect:VectEnable()
["1"] = "Up", else
["2"] = "Right", Vect:VectDisable()
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("targetdr") end,
set = function(_, v)
Vect:setDRGrowOrder("targetdr", v);
end end
},
targetdrSortSelect = {
type = "select", style = "dropdown", name = "targetDRSortOrder",
desc = "Change the target's DR's sort order", order = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("targetdr") end,
set = function(_, v)
Vect:setSortOrder("targetdr", v);
end
},
focusdrHeader = {
type = "header", name = "Focus's settings", order = 15
},
focusdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the focus's DRs.", order = 16,
get = function() return Vect:isPartEnabled("focusdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("focusdr", v);
end
},
focusdrRange = {
type = "range", name = "Focus's size", order = 17, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("focusdr") end,
set = function(_, v)
Vect:setFrameSize("focusdr", v);
end
},
focusdrGrowSelect = {
type = "select", style = "dropdown", name = "focusDRGrow",
desc = "Change which way the focus's DRs will grow", order = 18,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("focusdr") end,
set = function(_, v)
Vect:setDRGrowOrder("focusdr", v);
end
},
focusdrSortSelect = {
type = "select", style = "dropdown", name = "focusDRSortOrder",
desc = "Change the focus's DR's sort order", order = 19,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("focusdr") end,
set = function(_, v)
Vect:setSortOrder("focusdr", v);
end
}
}
return args;
end end
--order 40-50 function Vect:isPartEnabled(which)
function Vect:getSelfDROptions() local db = Vect.db.profile;
local args = { return db[which]["enabled"];
selfdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the your DRs.", order = 11,
get = function() return Vect:isPartEnabled("selfdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("selfdr", v);
end
},
selfdrrange = {
type = "range", name = "Self's DRs size", order = 12, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("selfdr") end,
set = function(_, v)
Vect:setFrameSize("selfdr", v);
end
},
selfdrGrowSelect = {
type = "select", style = "dropdown", name = "selfDRGrow",
desc = "Change which way the your DRs will grow", order = 13,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("selfdr") end,
set = function(_, v)
Vect:setDRGrowOrder("selfdr", v);
end
},
selfdrSortSelect = {
type = "select", style = "dropdown", name = "selfDRSortOrder",
desc = "Change the your DR's sort order", order = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("selfdr") end,
set = function(_, v)
Vect:setSortOrder("selfdr", v);
end
},
}
return args;
end end
--order 50+ function Vect:SetPartEnabledOrDisabled(which, enable)
function Vect:getDebugOptions() local db = Vect.db.profile;
local args = { db[which]["enabled"] = enable;
spellcast = { --hide all those frames
type = "toggle", name = "SpellCast", desc = "Enable/Disable writing out SPELL_CAST_SUCCESS events.", order = 50, if not enable then
get = function() return Vect:getSpellCastDebug() end, for i = 1, 23 do
set = function(_, v) local frame = Vect.frames[which][i]["frame"];
Vect:setSpellCastDebug(v); frame:Hide();
end end
}, else
spellAura = { self:ReassignCds(which);
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 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 end
},
selfcd = { function Vect:SetDRPartEnabledOrDisabled(which, enable)
type = "toggle", name = "Self CDs", desc = "Enable/Disable registering self CDs", order = 53, local db = Vect.db.profile;
get = function() return Vect:getSelfCDRegister() end, db[which]["enabled"] = enable;
set = function(_, v) --hide all those frames
Vect:setSelfCDRegister(v); if not enable then
for i = 1, 18 do
local frame = Vect.frames[which][i]["frame"];
frame:Hide();
end end
}, else
debugselect = { self:ReassignDRs(which);
type = "select", style = "dropdown", name = "debuglevel",
desc = "Change the debuglevel", order = 54,
values = {
["0"] = "No Messages",
},
get = function() return Vect:getDebugLevel() end,
set = function(_, v)
Vect:setDebugLevel(v);
end end
}, end
}
return args; --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, 5 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 t = frame:CreateFontString(nil, "OVERLAY");
t:SetNonSpaceWrap(false);
t:SetPoint("CENTER", frame, "CENTER", 2, 0);
t:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME")
local ttext = "";
if i == 1 then
ttext = "T";
elseif i == 2 then
ttext = "F";
elseif i == 3 then
ttext = "TDR";
elseif i == 4 then
ttext = "FDR";
elseif i == 5 then
ttext = "SDR";
end
t:SetText(ttext);
local which = "";
if i == 1 then
which = "target";
elseif i == 2 then
which = "focus";
elseif i == 3 then
which = "targetdr";
elseif i == 4 then
which = "focusdr";
elseif i == 5 then
which = "selfdr";
end
frame.DragID = which;
Vect.MovableFrames[i] = {}
Vect.MovableFrames[i]["frame"] = frame;
Vect.MovableFrames[i]["texture"] = text;
Vect.MovableFrames[i]["text"] = t;
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
function Vect:getDRNumSize(which)
local db = Vect.db.profile;
return db[which]["drnumsize"];
end
function Vect:setDRNumSize(which, size)
local db = Vect.db.profile;
db[which]["drnumsize"] = size;
Vect:MoveDRTimersStop(which)
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
function Vect:setDRGrowOrder(which, v)
local db = Vect.db.profile;
db[which]["growOrder"] = v;
Vect:MoveDRTimersStop(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
--Num Position functions
function Vect:getDRNumPosition(which)
local db = Vect.db.profile;
return db[which]["drnumposition"];
end
function Vect:setDRNumPosition(which, v)
local db = Vect.db.profile;
db[which]["drnumposition"] = v;
Vect:MoveDRTimersStop(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
function Vect:getSelfCDRegister()
local db = Vect.db.profile;
return db["selfCDRegister"];
end
function Vect:setSelfCDRegister(v)
local db = Vect.db.profile;
db["selfCDRegister"] = v;
Vect:ReassignCds("target");
Vect:ReassignCds("focus");
end end

373
data/optiontable.lua Normal file
View File

@ -0,0 +1,373 @@
local aceDBOptions = 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 = "CDs", desc = "Cooldown frame's settings.", childGroups = "tab", order = 2,
args = Vect:getTargetandFocusOptions();
},
droptions = {
type = "group", name = "DRs", desc = "DR frame's settings.", childGroups = "tab",order = 3,
args = Vect:getDROptions();
},
selfdr = {
type = "group", name = "Self DRs", desc = "Self DR frame's settings.", childGroups = "tab",order = 4,
args = Vect:getSelfDROptions()
},
debugoptions = {
type = "group", name = "Debug", desc = "Debug settings.", childGroups = "tab", order = 5,
args = Vect:getDebugOptions();
},
profileoptions = aceDBOptions:GetOptionsTable(self.db)
}
}
return options;
end
--order 10-20
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 = 11,
get = function() return Vect:isPartEnabled("target") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("target", v);
end
},
targetrange = {
type = "range", name = "Target's size", order = 12, 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 = 13,
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 = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("target") end,
set = function(_, v)
Vect:setSortOrder("target", v);
end
},
focusHeader = {
type = "header", name = "Focus's settings", order = 15
},
focustoggle = {
type = "toggle", name = "Focus", desc = "Enable/Disable showing the focus's cooldowns", order = 16,
get = function() return Vect:isPartEnabled("focus") end,
set = function(_, v)
Vect:SetPartEnabledOrDisabled("focus", v);
end
},
focusRange = {
type = "range", name = "Focus's size", order = 17, 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 = 18,
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 = 19,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
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 = {
targetdrHeader = {
type = "header", name = "Target's DR settings", order = 10
},
targetdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the target's DRs.", order = 11,
get = function() return Vect:isPartEnabled("targetdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("targetdr", v);
end
},
targetdrrange = {
type = "range", name = "Target's DRs size", order = 12, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("targetdr") end,
set = function(_, v)
Vect:setFrameSize("targetdr", v);
end
},
targetdrGrowSelect = {
type = "select", style = "dropdown", name = "targetDRGrow",
desc = "Change which way the target's cooldowns will grow", order = 13,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("targetdr") end,
set = function(_, v)
Vect:setDRGrowOrder("targetdr", v);
end
},
targetdrSortSelect = {
type = "select", style = "dropdown", name = "targetDRSortOrder",
desc = "Change the target's DR's sort order", order = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("targetdr") end,
set = function(_, v)
Vect:setSortOrder("targetdr", v);
end
},
targetdrnumsizerange = {
type = "range", name = "Number's size", desc = "Target's DR's Number's size",
order = 15, min = 1, max = 30, step = 1,
get = function() return Vect:getDRNumSize("targetdr") end,
set = function(_, v)
Vect:setDRNumSize("targetdr", v);
end
},
targetdrnumposselect = {
type = "select", style = "dropdown", name = "targetDRNumPos",
desc = "Change the target's DR's number's position.", order = 16,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left",
["5"] = "Middle"
},
get = function() return Vect:getDRNumPosition("targetdr") end,
set = function(_, v)
Vect:setDRNumPosition("targetdr", v);
end
},
focusdrHeader = {
type = "header", name = "Focus's settings", order = 15
},
focusdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the focus's DRs.", order = 16,
get = function() return Vect:isPartEnabled("focusdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("focusdr", v);
end
},
focusdrRange = {
type = "range", name = "Focus's size", order = 17, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("focusdr") end,
set = function(_, v)
Vect:setFrameSize("focusdr", v);
end
},
focusdrGrowSelect = {
type = "select", style = "dropdown", name = "focusDRGrow",
desc = "Change which way the focus's DRs will grow", order = 18,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("focusdr") end,
set = function(_, v)
Vect:setDRGrowOrder("focusdr", v);
end
},
focusdrSortSelect = {
type = "select", style = "dropdown", name = "focusDRSortOrder",
desc = "Change the focus's DR's sort order", order = 19,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("focusdr") end,
set = function(_, v)
Vect:setSortOrder("focusdr", v);
end
}
}
return args;
end
--order 40-50
function Vect:getSelfDROptions()
local args = {
selfdrtoggle = {
type = "toggle", name = "Enabled", desc = "Enable/Disable showing the your DRs.", order = 11,
get = function() return Vect:isPartEnabled("selfdr") end,
set = function(_, v)
Vect:SetDRPartEnabledOrDisabled("selfdr", v);
end
},
selfdrrange = {
type = "range", name = "Self's DRs size", order = 12, min = 10, max = 150, step = 1,
get = function() return Vect:getFrameSize("selfdr") end,
set = function(_, v)
Vect:setFrameSize("selfdr", v);
end
},
selfdrGrowSelect = {
type = "select", style = "dropdown", name = "selfDRGrow",
desc = "Change which way the your DRs will grow", order = 13,
values = {
["1"] = "Up",
["2"] = "Right",
["3"] = "Down",
["4"] = "Left"
},
get = function() return Vect:getGrowOrder("selfdr") end,
set = function(_, v)
Vect:setDRGrowOrder("selfdr", v);
end
},
selfdrSortSelect = {
type = "select", style = "dropdown", name = "selfDRSortOrder",
desc = "Change the your DR's sort order", order = 14,
values = {
["1"] = "Ascending (CD left)",
["2"] = "Descending (CD left)",
["3"] = "Ascending (CD total)",
["4"] = "Descending (CD total)",
["5"] = "Recent first",
["6"] = "Recent Last",
["7"] = "No order"
},
get = function() return Vect:getSortOrder("selfdr") end,
set = function(_, v)
Vect:setSortOrder("selfdr", v);
end
},
}
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
},
selfcd = {
type = "toggle", name = "Self CDs", desc = "Enable/Disable registering self CDs", order = 53,
get = function() return Vect:getSelfCDRegister() end,
set = function(_, v)
Vect:setSelfCDRegister(v);
end
},
debugselect = {
type = "select", style = "dropdown", name = "debuglevel",
desc = "Change the debuglevel", order = 54,
values = {
["0"] = "No Messages",
},
get = function() return Vect:getDebugLevel() end,
set = function(_, v)
Vect:setDebugLevel(v);
end
},
}
return args;
end