Relintais-Enemy-Kooldown-Tr.../data/options.lua
Relintai ca3296c6f6 -Implemented types and colors.
-Implemented type based sorting.
-DRs now gets cleaned up in PLAYER_ENTER_WORLD.
2016-05-06 16:05:24 +02:00

410 lines
8.9 KiB
Lua

--"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');
--Utility Functions for the options
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
--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();
local colorframe = Vect.fremes[which][i]["colorframe"];
colorframe: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:ReassignDRs(which);
end
end
function Vect:isSpecDetectionEnabled()
local db = Vect.db.profile;
return db["specdetection"];
end
function Vect:setSpecDetectionEnabledorDisabled(enable)
local db = Vect.db.profile;
db["specdetection"] = enable;
--call the remapcooldowns, and then update
--self:ReassignCds(which);
end
function Vect:getColorFrameEnabled(which)
local db = Vect.db.profile;
return db[which]["colorframeenabled"];
end
function Vect:setColorFrameEnabled(which, enable)
local db = Vect.db.profile;
db[which]["colorframeenabled"] = enable;
--hide all those frames
if not enable then
for i = 1, 23 do
local colorframe = Vect.frames[which][i]["colorframe"];
colorframe:Hide();
end
else
self:ReassignCds(which);
end
end
function Vect:getCDTypeSortingEnable()
local db = Vect.db.profile;
return db["cdtypesortorder"]["enabled"];
end
function Vect:setCDTypeSortingEnable(v)
local db = Vect.db.profile;
db["cdtypesortorder"]["enabled"] = v;
self:ReassignCds("target");
self:ReassignCds("focus");
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
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]["size"] = size;
Vect:MoveDRTimersStop(which)
end
function Vect:getColorFrameSize(which)
local db = Vect.db.profile;
return db[which]["colorframesize"];
end
function Vect:setColorFrameSize(which, size)
local db = Vect.db.profile;
db[which]["colorframesize"] = size;
Vect:MoveTimersStop(which);
Vect:ReassignCds(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
function Vect:getTypeSortOrder(which)
local db = Vect.db.profile;
return db["cdtypesortorder"][which];
end
function Vect:setTypeSortOrder(which, v)
local db = Vect.db.profile;
db["cdtypesortorder"][which] = v;
Vect:ReassignCds("target");
Vect:ReassignCds("focus");
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
--Color options
function Vect:getColor(part)
local db = Vect.db.profile;
if not db["color"] then db["color"] = {} end
if not db["color"][part] then
db["color"][part] = {};
db["color"][part]["r"] = 1;
db["color"][part]["g"] = 0;
db["color"][part]["b"] = 0;
db["color"][part]["a"] = 1;
end
return db["color"][part]["r"], db["color"][part]["g"], db["color"][part]["b"], db["color"][part]["a"];
end
function Vect:setColor(part, r, g, b, a)
local db = Vect.db.profile;
if not db["color"][part] then db["color"][part] = {} end
db["color"][part]["r"] = r;
db["color"][part]["g"] = g;
db["color"][part]["b"] = b;
db["color"][part]["a"] = a;
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