Add max buffs and max debuffs settings
- /tfb buffs 0-32 and /tfb debuffs 0-16, plus two options-panel sliders. - Saved settings are validated and reset when out of range. - A lowered debuff limit hides extra debuffs instead of spilling them into the buff row; the buff limit applies to spilled debuffs too. - Works on the native and ClassicAPI paths and with test mode. - Bump to 0.9.6; tests now 23 scenarios. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019W3rwutyoLNHxXPycYWSMc
This commit is contained in:
+29
-14
@@ -1,6 +1,7 @@
|
||||
-- Settings remain usable through /tfb on unmodified 1.12 clients.
|
||||
TargetFrameBuffDefaults = {
|
||||
timers = true, highlight = true, sweeps = false, timerSize = 9, warning = 5
|
||||
timers = true, highlight = true, sweeps = false, timerSize = 9, warning = 5,
|
||||
maxBuffs = 32, maxDebuffs = 16
|
||||
};
|
||||
|
||||
local function RefreshAuras()
|
||||
@@ -24,6 +25,12 @@ local function Validate()
|
||||
if (TargetFrameBuffDB.warning ~= TargetFrameBuffDB.warning or TargetFrameBuffDB.warning < 0 or TargetFrameBuffDB.warning > 30) then
|
||||
TargetFrameBuffDB.warning = 5;
|
||||
end
|
||||
if (TargetFrameBuffDB.maxBuffs ~= TargetFrameBuffDB.maxBuffs or TargetFrameBuffDB.maxBuffs < 0 or TargetFrameBuffDB.maxBuffs > 32) then
|
||||
TargetFrameBuffDB.maxBuffs = 32;
|
||||
end
|
||||
if (TargetFrameBuffDB.maxDebuffs ~= TargetFrameBuffDB.maxDebuffs or TargetFrameBuffDB.maxDebuffs < 0 or TargetFrameBuffDB.maxDebuffs > 16) then
|
||||
TargetFrameBuffDB.maxDebuffs = 16;
|
||||
end
|
||||
end
|
||||
|
||||
local panel;
|
||||
@@ -52,18 +59,20 @@ local function CreateOptions()
|
||||
checks[i] = check;
|
||||
end
|
||||
local sliders = {};
|
||||
local sliderKeys = {"timerSize", "warning"};
|
||||
local sliderLabels = {"Timer font size", "Warning threshold (seconds)"};
|
||||
for i = 1, 2 do
|
||||
local sliderKeys = {"timerSize", "warning", "maxBuffs", "maxDebuffs"};
|
||||
local sliderLabels = {"Timer font size", "Warning threshold (seconds)", "Max buffs shown", "Max debuffs shown"};
|
||||
local sliderMin = {6, 0, 0, 0};
|
||||
local sliderMax = {20, 30, 32, 16};
|
||||
for i = 1, 4 do
|
||||
local slider = CreateFrame("Slider", "TargetFrameBuffSlider"..i, panel, "OptionsSliderTemplate");
|
||||
slider:SetPoint("TOPLEFT", panel, "TOPLEFT", 22, -190 - (i - 1) * 65);
|
||||
slider:SetWidth(240);
|
||||
slider:SetMinMaxValues(i == 1 and 6 or 0, i == 1 and 20 or 30);
|
||||
slider:SetMinMaxValues(sliderMin[i], sliderMax[i]);
|
||||
slider:SetValueStep(1);
|
||||
slider.key = sliderKeys[i];
|
||||
slider.label = sliderLabels[i];
|
||||
getglobal(slider:GetName().."Low"):SetText(i == 1 and "6" or "0");
|
||||
getglobal(slider:GetName().."High"):SetText(i == 1 and "20" or "30");
|
||||
getglobal(slider:GetName().."Low"):SetText(sliderMin[i]);
|
||||
getglobal(slider:GetName().."High"):SetText(sliderMax[i]);
|
||||
slider:SetScript("OnValueChanged", function()
|
||||
local value = math.floor(this:GetValue() + 0.5);
|
||||
TargetFrameBuffDB[this.key] = value;
|
||||
@@ -75,7 +84,7 @@ local function CreateOptions()
|
||||
local testButton = CreateFrame("Button", "TargetFrameBuffTestButton", panel, "UIPanelButtonTemplate");
|
||||
testButton:SetWidth(180);
|
||||
testButton:SetHeight(22);
|
||||
testButton:SetPoint("TOPLEFT", panel, "TOPLEFT", 22, -330);
|
||||
testButton:SetPoint("TOPLEFT", panel, "TOPLEFT", 22, -450);
|
||||
testButton:SetText("Toggle test auras");
|
||||
testButton:SetScript("OnClick", function()
|
||||
TargetFrameBuff_SetTest(not TargetFrameBuff_IsTest());
|
||||
@@ -83,7 +92,7 @@ local function CreateOptions()
|
||||
local saved = {};
|
||||
local function Sync()
|
||||
for i = 1, 3 do checks[i]:SetChecked(TargetFrameBuffDB[checks[i].key]); end
|
||||
for i = 1, 2 do
|
||||
for i = 1, 4 do
|
||||
sliders[i]:SetValue(TargetFrameBuffDB[sliders[i].key]);
|
||||
getglobal(sliders[i]:GetName().."Text"):SetText(sliders[i].label..": "..TargetFrameBuffDB[sliders[i].key]);
|
||||
end
|
||||
@@ -105,6 +114,12 @@ local function CreateOptions()
|
||||
InterfaceOptions_AddCategory(panel);
|
||||
end
|
||||
|
||||
-- command -> saved key, minimum, maximum
|
||||
local NUMBER_OPTIONS = {
|
||||
size = {"timerSize", 6, 20}, warning = {"warning", 0, 30},
|
||||
buffs = {"maxBuffs", 0, 32}, debuffs = {"maxDebuffs", 0, 16}
|
||||
};
|
||||
|
||||
SLASH_TARGETFRAMEBUFF1 = "/tfb";
|
||||
SlashCmdList["TARGETFRAMEBUFF"] = function(message)
|
||||
Validate();
|
||||
@@ -115,14 +130,14 @@ SlashCmdList["TARGETFRAMEBUFF"] = function(message)
|
||||
elseif (value == "") then TargetFrameBuffDB[command] = not TargetFrameBuffDB[command];
|
||||
else Print("Use on or off."); return; end
|
||||
Print(command..": "..(TargetFrameBuffDB[command] and "on" or "off"));
|
||||
elseif (command == "size" or command == "warning") then
|
||||
elseif (NUMBER_OPTIONS[command]) then
|
||||
local number = tonumber(value);
|
||||
local min, max = 0, 30;
|
||||
if (command == "size") then min, max = 6, 20; end
|
||||
local key, min, max = NUMBER_OPTIONS[command][1], NUMBER_OPTIONS[command][2], NUMBER_OPTIONS[command][3];
|
||||
if (not number or number < min or number > max) then
|
||||
Print("Choose a number from "..min.." to "..max.."."); return;
|
||||
end
|
||||
TargetFrameBuffDB[command == "size" and "timerSize" or "warning"] = math.floor(number + 0.5);
|
||||
TargetFrameBuffDB[key] = math.floor(number + 0.5);
|
||||
Print(command..": "..TargetFrameBuffDB[key]);
|
||||
elseif (command == "test") then
|
||||
local _, _, buffs, debuffs = string.find(value, "^(%d+)%s*(%d*)$");
|
||||
local on;
|
||||
@@ -139,7 +154,7 @@ SlashCmdList["TARGETFRAMEBUFF"] = function(message)
|
||||
CreateOptions();
|
||||
InterfaceOptionsFrame_OpenToCategory(panel);
|
||||
else
|
||||
Print("/tfb timers, highlight or sweeps [on or off], /tfb size 6-20, /tfb warning 0-30, /tfb test [buffs debuffs], /tfb reset");
|
||||
Print("/tfb timers, highlight or sweeps [on or off], /tfb size 6-20, /tfb warning 0-30, /tfb buffs 0-32, /tfb debuffs 0-16, /tfb test [buffs debuffs], /tfb reset");
|
||||
return;
|
||||
end
|
||||
RefreshAuras();
|
||||
|
||||
Reference in New Issue
Block a user