feat: implement automatic skin swapping based on group size and add horizontal grid layout options

This commit is contained in:
Bluewhale1337
2026-07-21 09:02:33 +02:00
parent 85ad55c1cb
commit dd9f9886b4
9 changed files with 385 additions and 15 deletions
+1
View File
@@ -27,3 +27,4 @@ HealBot_Options_CDC.xml
HealBot_Options_Skins.xml
HealBot_Options_Buffs.xml
HealBot_Options_Chat.xml
HealBot_Options_Auto.xml
+10
View File
@@ -181,7 +181,17 @@ HealBot_ConfigDefaults = {
Current_Skin = "Modern Flat",
Skin_ID = 1,
Skins = {"Modern Flat", HEALBOT_SKINS_STD, "HealBot Party", "HealBot Raid", "Alteric Valley"},
AutoSwap_Enabled = 0,
AutoSwap_Profiles = {
[1] = "Modern Flat", -- Solo
[2] = "HealBot Party", -- Party (2-5)
[3] = "HealBot Raid", -- Raid 15 (6-15)
[4] = "HealBot Raid", -- Raid 25 (16-25)
[5] = "HealBot Raid", -- Raid 40 (26-40)
},
numcols = {[HEALBOT_SKINS_STD] = 1, ["HealBot Party"] = 1, ["HealBot Raid"] = 4, ["Alteric Valley"] = 2, ["Modern Flat"] = 1},
bmaxrows = {[HEALBOT_SKINS_STD] = 0, ["HealBot Party"] = 0, ["HealBot Raid"] = 0, ["Alteric Valley"] = 0, ["Modern Flat"] = 0},
GridOrientation = {[HEALBOT_SKINS_STD] = 1, ["HealBot Party"] = 1, ["HealBot Raid"] = 1, ["Alteric Valley"] = 1, ["Modern Flat"] = 1},
btexture = {[HEALBOT_SKINS_STD] = 8,["HealBot Party"] = 6, ["HealBot Raid"] = 7, ["Alteric Valley"] = 9, ["Modern Flat"] = 10},
bcspace = {[HEALBOT_SKINS_STD] = 4, ["HealBot Party"] = 4, ["HealBot Raid"] = 2, ["Alteric Valley"] = 2, ["Modern Flat"] = 4},
brspace = {[HEALBOT_SKINS_STD] = 1, ["HealBot Party"] = 2, ["HealBot Raid"] = 2, ["Alteric Valley"] = 1, ["Modern Flat"] = 2},
+2
View File
@@ -314,6 +314,8 @@ function HealBot_Options_SetSkins()
HealBot_Options_BarHeightS:SetValue(HealBot_Config.bheight[HealBot_Config.Current_Skin])
HealBot_Options_BarWidthS:SetValue(HealBot_Config.bwidth[HealBot_Config.Current_Skin])
HealBot_Options_BarNumColsS:SetValue(HealBot_Config.numcols[HealBot_Config.Current_Skin])
HealBot_Options_BarMaxRowsS:SetValue(HealBot_Config.bmaxrows[HealBot_Config.Current_Skin] or 0)
HealBot_Options_GridOrientation:SetChecked((HealBot_Config.GridOrientation[HealBot_Config.Current_Skin] == 2) and 1 or nil)
HealBot_Options_BarBRSpaceS:SetValue(HealBot_Config.brspace[HealBot_Config.Current_Skin])
HealBot_Options_BarBCSpaceS:SetValue(HealBot_Config.bcspace[HealBot_Config.Current_Skin])
HealBot_Options_FramePaddingS:SetValue((HealBot_Config.bpadding and HealBot_Config.bpadding[HealBot_Config.Current_Skin]) or 10)
+9
View File
@@ -206,6 +206,15 @@
</Anchor>
</Anchors>
</Button>
<Button name="HealBot_OptionsTab8" inherits="HealBot_Options_Tab" id="8" text="Auto">
<Anchors>
<Anchor point="LEFT" relativeTo="HealBot_OptionsTab7" relativePoint="RIGHT">
<Offset>
<AbsDimension x="-14" y="0" />
</Offset>
</Anchor>
</Anchors>
</Button>
<Button name="HealBot_Options_Defaults" inherits="UIPanelButtonTemplate" text="HEALBOT_OPTIONS_DEFAULTS">
<Size>
<AbsDimension x="80" y="22"/>
+79
View File
@@ -0,0 +1,79 @@
function HealBot_Options_AutoSwap_OnClick(this)
if this:GetChecked() then
HealBot_Config.AutoSwap_Enabled = 1
else
HealBot_Config.AutoSwap_Enabled = 0
end
HealBot_Action_PartyChanged()
end
function HealBot_Options_Auto_Initialize()
local dropdownName = UIDROPDOWNMENU_OPEN_MENU
if not dropdownName then return end
local dropdownFrame = getglobal(dropdownName)
if not dropdownFrame then return end
local id = dropdownFrame:GetID()
if not id then return end
for i=1, getn(HealBot_Config.Skins), 1 do
local info = {}
info.text = HealBot_Config.Skins[i]
info.func = HealBot_Options_Auto_OnSelect
info.value = id
if HealBot_Config.AutoSwap_Profiles[id] == HealBot_Config.Skins[i] then
info.checked = 1
else
info.checked = nil
end
UIDropDownMenu_AddButton(info)
end
end
function HealBot_Options_Auto_OnSelect()
local skin = this:GetText()
local id = this.value
if not id or not skin then return end
HealBot_Config.AutoSwap_Profiles[id] = skin
local dropdowns = {
"HealBot_Options_Auto_Solo",
"HealBot_Options_Auto_Party",
"HealBot_Options_Auto_Raid15",
"HealBot_Options_Auto_Raid25",
"HealBot_Options_Auto_Raid40"
}
local dropdownName = dropdowns[id]
local dropdownFrame = getglobal(dropdownName)
UIDropDownMenu_SetSelectedValue(dropdownFrame, skin)
UIDropDownMenu_SetText(skin, dropdownFrame)
HealBot_Action_PartyChanged()
end
function HealBot_Options_Auto_OnShow(this)
if HealBot_Config.AutoSwap_Enabled == 1 then
HealBot_Options_AutoSwap:SetChecked(1)
else
HealBot_Options_AutoSwap:SetChecked(nil)
end
local dropdowns = {
"HealBot_Options_Auto_Solo",
"HealBot_Options_Auto_Party",
"HealBot_Options_Auto_Raid15",
"HealBot_Options_Auto_Raid25",
"HealBot_Options_Auto_Raid40"
}
for id, name in ipairs(dropdowns) do
local dropdownFrame = getglobal(name)
if dropdownFrame then
UIDropDownMenu_SetWidth(150, dropdownFrame)
local skin = HealBot_Config.AutoSwap_Profiles[id]
if skin then
UIDropDownMenu_SetSelectedValue(dropdownFrame, skin)
UIDropDownMenu_SetText(skin, dropdownFrame)
end
end
end
end
+152
View File
@@ -0,0 +1,152 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="HealBot_Options_Auto.lua" />
<Frame name="HealBot_Options_Panel8" parent="HealBot_Options" hidden="true" setAllPoints="true">
<Frames>
<CheckButton name="HealBot_Options_AutoSwap" inherits="OptionsCheckButtonTemplate">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="25" y="-30" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText("Enable Auto-Swap");
</OnLoad>
<OnClick>
HealBot_Options_AutoSwap_OnClick(this);
</OnClick>
</Scripts>
</CheckButton>
<Frame name="HealBot_Options_Auto_Solo" inherits="UIDropDownMenuTemplate" id="1">
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" text="Solo Skin:" inherits="GameFontNormalSmall">
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="-10" y="15" /></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="30" y="-80" /></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, HealBot_Options_Auto_Initialize);
</OnLoad>
</Scripts>
</Frame>
<Frame name="HealBot_Options_Auto_Party" inherits="UIDropDownMenuTemplate" id="2">
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" text="Party Skin:" inherits="GameFontNormalSmall">
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="-10" y="15" /></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="30" y="-130" /></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, HealBot_Options_Auto_Initialize);
</OnLoad>
</Scripts>
</Frame>
<Frame name="HealBot_Options_Auto_Raid15" inherits="UIDropDownMenuTemplate" id="3">
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" text="Raid 15 Skin:" inherits="GameFontNormalSmall">
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="-10" y="15" /></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="30" y="-180" /></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, HealBot_Options_Auto_Initialize);
</OnLoad>
</Scripts>
</Frame>
<Frame name="HealBot_Options_Auto_Raid25" inherits="UIDropDownMenuTemplate" id="4">
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" text="Raid 25 Skin:" inherits="GameFontNormalSmall">
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="-10" y="15" /></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="30" y="-230" /></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, HealBot_Options_Auto_Initialize);
</OnLoad>
</Scripts>
</Frame>
<Frame name="HealBot_Options_Auto_Raid40" inherits="UIDropDownMenuTemplate" id="5">
<Layers>
<Layer level="BACKGROUND">
<FontString name="$parentLabel" text="Raid 40 Skin:" inherits="GameFontNormalSmall">
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="-10" y="15" /></Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Anchors>
<Anchor point="TOPLEFT">
<Offset><AbsDimension x="30" y="-280" /></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, HealBot_Options_Auto_Initialize);
</OnLoad>
</Scripts>
</Frame>
</Frames>
<Scripts>
<OnShow>
HealBot_Options_Auto_OnShow(this);
</OnShow>
</Scripts>
</Frame>
</Ui>
+18
View File
@@ -1,6 +1,20 @@
-- HealBot Options panel file: HealBot_Options_Skins.lua
-- Split from original HealBot_Options.lua
function HealBot_Options_BarMaxRowsS_OnValueChanged(this)
HealBot_Config.bmaxrows[HealBot_Config.Current_Skin] = this:GetValue()
HealBot_Action_PartyChanged()
end
function HealBot_Options_GridOrientation_OnClick(this)
if this:GetChecked() then
HealBot_Config.GridOrientation[HealBot_Config.Current_Skin] = 2 -- Horizontal
else
HealBot_Config.GridOrientation[HealBot_Config.Current_Skin] = 1 -- Vertical
end
HealBot_Action_PartyChanged()
end
function HealBot_Options_NewSkin_OnTextChanged(this)
local text= this:GetText()
if string.len(text)>0 then
@@ -11,6 +25,8 @@ function HealBot_Options_NewSkin_OnTextChanged(this)
end
function HealBot_Options_NewSkinb_OnClick(this)
HealBot_Config.numcols[HealBot_Options_NewSkin:GetText()] = HealBot_Config.numcols[HealBot_Config.Current_Skin]
HealBot_Config.bmaxrows[HealBot_Options_NewSkin:GetText()] = HealBot_Config.bmaxrows[HealBot_Config.Current_Skin]
HealBot_Config.GridOrientation[HealBot_Options_NewSkin:GetText()] = HealBot_Config.GridOrientation[HealBot_Config.Current_Skin]
HealBot_Config.btexture[HealBot_Options_NewSkin:GetText()] = HealBot_Config.btexture[HealBot_Config.Current_Skin]
HealBot_Config.bcspace[HealBot_Options_NewSkin:GetText()] = HealBot_Config.bcspace[HealBot_Config.Current_Skin]
HealBot_Config.brspace[HealBot_Options_NewSkin:GetText()] = HealBot_Config.brspace[HealBot_Config.Current_Skin]
@@ -56,6 +72,8 @@ end
function HealBot_Options_DeleteSkin_OnClick(this)
if HealBot_Config.Current_Skin~=HEALBOT_SKINS_STD then
HealBot_Config.numcols[HealBot_Options_SkinsText:GetText()] = nil
HealBot_Config.bmaxrows[HealBot_Options_SkinsText:GetText()] = nil
HealBot_Config.GridOrientation[HealBot_Options_SkinsText:GetText()] = nil
HealBot_Config.btexture[HealBot_Options_SkinsText:GetText()] = nil
HealBot_Config.bcspace[HealBot_Options_SkinsText:GetText()] = nil
HealBot_Config.brspace[HealBot_Options_SkinsText:GetText()] = nil
+35 -1
View File
@@ -293,12 +293,46 @@
<OnValueChanged>HealBot_Options_BorderThicknessS_OnValueChanged(this)</OnValueChanged>
</Scripts>
</Slider>
<Slider name="HealBot_Options_BarAlpha" inherits="HealBot_Options_SliderTemplate">
<Slider name="HealBot_Options_BarMaxRowsS" inherits="HealBot_Options_SliderTemplate">
<Size>
<AbsDimension x="123" y="17" />
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="HealBot_Options_FramePaddingS" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="-35" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>HealBot_Options_val_OnLoad(this,"Max Rows",0,40)</OnLoad>
<OnValueChanged>HealBot_Options_BarMaxRowsS_OnValueChanged(this)</OnValueChanged>
</Scripts>
</Slider>
<CheckButton name="HealBot_Options_GridOrientation" inherits="OptionsCheckButtonTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="HealBot_Options_BarMaxRowsS" relativePoint="TOPRIGHT">
<Offset>
<AbsDimension x="10" y="5" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName().."Text"):SetText("Horizontal Grid");
</OnLoad>
<OnClick>
HealBot_Options_GridOrientation_OnClick(this);
</OnClick>
</Scripts>
</CheckButton>
<Slider name="HealBot_Options_BarAlpha" inherits="HealBot_Options_SliderTemplate">
<Size>
<AbsDimension x="123" y="17" />
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="HealBot_Options_BarMaxRowsS" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="-35" />
</Offset>
+79 -14
View File
@@ -385,6 +385,30 @@ function HealBot_Action_PartyChanged()
local TempMaxH = 0;
local HeaderPos = {};
if HealBot_Config.AutoSwap_Enabled == 1 then
local totalMembers = GetNumRaidMembers()
if totalMembers == 0 then totalMembers = GetNumPartyMembers() end
local threshold = 1
if totalMembers == 0 then
threshold = 1 -- Solo
elseif totalMembers > 0 and totalMembers <= 5 then
threshold = 2 -- Party
elseif totalMembers > 5 and totalMembers <= 15 then
threshold = 3 -- Raid15
elseif totalMembers > 15 and totalMembers <= 25 then
threshold = 4 -- Raid25
else
threshold = 5 -- Raid40
end
local swapSkin = HealBot_Config.AutoSwap_Profiles[threshold]
if swapSkin and swapSkin ~= HealBot_Config.Current_Skin then
HealBot_Config.Current_Skin = swapSkin
HealBot_Options_SetSkins()
end
end
for j = 1, 15 do
local headerobj = getglobal("HealBot_Action_Header" .. j);
headerobj:SetText(" ")
@@ -743,8 +767,12 @@ function HealBot_Action_PartyChanged()
local OffsetY = bpadding;
local OffsetX = bpadding;
local MaxOffsetY = 0;
local MaxOffsetX = 0;
if cols > (numBars - numHeaders) then
local maxRows = HealBot_Config.bmaxrows[HealBot_Config.Current_Skin] or 0
local orientation = HealBot_Config.GridOrientation[HealBot_Config.Current_Skin] or 1
if cols > (numBars - numHeaders) and maxRows == 0 then
cols = numBars - numHeaders;
end
if cols <= 0 then cols = 1 end
@@ -753,6 +781,13 @@ function HealBot_Action_PartyChanged()
local i = 0;
local z = 1;
local limit = math.ceil((numBars) / cols)
if orientation == 1 and maxRows > 0 then
limit = maxRows
elseif orientation == 2 then
limit = cols
end
for index, button in pairs(HealBot_Action_HealButtons) do
i = i + 1;
local checked = false;
@@ -760,25 +795,48 @@ function HealBot_Action_PartyChanged()
if HeaderPos[i] then
header = HeaderPos[i];
OffsetY = HealBot_Action_PositionButton(nil, OffsetX, OffsetY, bwidth, bheight, checked, header);
if h == math.ceil((numBars) / cols) and z < numBars then
h = 0;
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
OffsetY = bpadding;
OffsetX = OffsetX + bwidth + bcspace;
if orientation == 1 then
OffsetY = HealBot_Action_PositionButton(nil, OffsetX, OffsetY, bwidth, bheight, checked, header);
if h == limit and z < numBars then
h = 0;
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
OffsetY = bpadding;
OffsetX = OffsetX + bwidth + bcspace;
end
else
OffsetY = HealBot_Action_PositionButton(nil, OffsetX, OffsetY, bwidth, bheight, checked, header);
if h == limit and z < numBars then
h = 0;
if MaxOffsetX < OffsetX then MaxOffsetX = OffsetX; end
OffsetX = bpadding;
OffsetY = OffsetY + bheight + bcspace;
end
end
h = h + 1;
z = z + 1;
end
if checked_start <= i and checked_end >= i then checked = true; end
OffsetY = HealBot_Action_PositionButton(button, OffsetX, OffsetY, bwidth, bheight, checked, nil);
if h == math.ceil((numBars) / cols) and z < numBars then
h = 0;
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
OffsetY = bpadding;
OffsetX = OffsetX + bwidth + bcspace;
if orientation == 1 then
OffsetY = HealBot_Action_PositionButton(button, OffsetX, OffsetY, bwidth, bheight, checked, nil);
if h == limit and z < numBars then
h = 0;
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
OffsetY = bpadding;
OffsetX = OffsetX + bwidth + bcspace;
end
else
button:SetPoint("TOPLEFT", "HealBot_Action", "TOPLEFT", OffsetX, -OffsetY);
OffsetX = OffsetX + bwidth + bcspace;
if h == limit and z < numBars then
h = 0;
if MaxOffsetX < OffsetX then MaxOffsetX = OffsetX; end
OffsetX = bpadding;
OffsetY = OffsetY + bheight + bcspace;
end
end
z = z + 1;
h = h + 1;
local bar = HealBot_Action_HealthBar(button);
@@ -794,7 +852,14 @@ function HealBot_Action_PartyChanged()
HealBot_Action_SetTexture(bar2, btexture);
end
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
if orientation == 1 then
if MaxOffsetY < OffsetY then MaxOffsetY = OffsetY; end
else
if MaxOffsetX < OffsetX then MaxOffsetX = OffsetX; end
-- In horizontal mode, OffsetY represents the active row. We need to measure total height.
MaxOffsetY = OffsetY + bheight + bcspace
OffsetX = MaxOffsetX -- For setting the final width
end
if HealBot_Config.HideOptions == 1 then
HealBot_Action_OptionsButton:Hide();