Redesigned radio buttons
This commit is contained in:
parent
cfdef3cc26
commit
26f25d969c
1 changed files with 91 additions and 32 deletions
123
UI.lua
123
UI.lua
|
|
@ -84,27 +84,46 @@ local function CreateDropdown(parent, name, labelText, options, defaultIndex, on
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper: Create a radio button (CheckButton with radio texture)
|
-- Helper: Create a custom flat radio button (gold circle when selected, grey when not)
|
||||||
local function CreateRadioButton(parent, name, text, x, y, isChecked, onClick)
|
local function CreateRadioButton(parent, name, text, x, y, isChecked, onClick)
|
||||||
local radio = CreateFrame("CheckButton", name, parent, "UIRadioButtonTemplate")
|
local size = 20
|
||||||
radio:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
|
local btn = CreateFrame("CheckButton", name, parent)
|
||||||
radio:SetChecked(isChecked)
|
btn:SetSize(size, size)
|
||||||
|
btn:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
|
||||||
|
|
||||||
local radioText = radio:GetFontString()
|
-- Background (grey when unselected, yellow when selected) — circular via mask
|
||||||
if radioText then
|
local bg = btn:CreateTexture(nil, "BACKGROUND")
|
||||||
radioText:SetText(text)
|
bg:SetAllPoints()
|
||||||
radioText:SetFontObject("GameFontHighlight")
|
bg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
else
|
local mask = btn:CreateMaskTexture()
|
||||||
local t = radio:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
mask:SetAllPoints()
|
||||||
t:SetPoint("LEFT", radio, "RIGHT", 4, 0)
|
mask:SetTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
|
||||||
t:SetText(text)
|
bg:AddMaskTexture(mask)
|
||||||
|
|
||||||
|
btn.checkTex = nil -- unused, kept for compatibility
|
||||||
|
|
||||||
|
local function UpdateVisual()
|
||||||
|
if btn:GetChecked() then
|
||||||
|
bg:SetColorTexture(0.9, 0.75, 0.2, 1)
|
||||||
|
else
|
||||||
|
bg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
radio:SetScript("OnClick", function(self)
|
btn:SetChecked(isChecked)
|
||||||
|
UpdateVisual()
|
||||||
|
|
||||||
|
local label = btn:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||||
|
label:SetPoint("LEFT", btn, "RIGHT", 6, 0)
|
||||||
|
label:SetText(text)
|
||||||
|
|
||||||
|
btn:SetScript("OnClick", function(self)
|
||||||
onClick(self)
|
onClick(self)
|
||||||
|
UpdateVisual()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return radio
|
btn.UpdateVisual = UpdateVisual
|
||||||
|
return btn
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper: Create a section header (golden text)
|
-- Helper: Create a section header (golden text)
|
||||||
|
|
@ -242,6 +261,8 @@ function AltSystem:CreateMainFrame()
|
||||||
AltSystem.State.rollType = rollType
|
AltSystem.State.rollType = rollType
|
||||||
attackRadio:SetChecked(rollType == "attack")
|
attackRadio:SetChecked(rollType == "attack")
|
||||||
defenseRadio:SetChecked(rollType == "defense")
|
defenseRadio:SetChecked(rollType == "defense")
|
||||||
|
attackRadio.UpdateVisual()
|
||||||
|
defenseRadio.UpdateVisual()
|
||||||
-- Update roll button text
|
-- Update roll button text
|
||||||
if AltSystem.RollButton then
|
if AltSystem.RollButton then
|
||||||
local label = rollType == "attack" and "Roll Attack" or "Roll Defense"
|
local label = rollType == "attack" and "Roll Attack" or "Roll Defense"
|
||||||
|
|
@ -330,6 +351,7 @@ function AltSystem:CreateMainFrame()
|
||||||
AltSystem.State.selectedDefenseIndex = index
|
AltSystem.State.selectedDefenseIndex = index
|
||||||
for i, radio in ipairs(armorRadios) do
|
for i, radio in ipairs(armorRadios) do
|
||||||
radio:SetChecked(i == index)
|
radio:SetChecked(i == index)
|
||||||
|
radio.UpdateVisual()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -361,6 +383,7 @@ function AltSystem:CreateMainFrame()
|
||||||
AltSystem.State.selectedItemIndex = index
|
AltSystem.State.selectedItemIndex = index
|
||||||
for i, radio in ipairs(itemRadios) do
|
for i, radio in ipairs(itemRadios) do
|
||||||
radio:SetChecked(i == index)
|
radio:SetChecked(i == index)
|
||||||
|
radio.UpdateVisual()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -387,40 +410,76 @@ function AltSystem:CreateMainFrame()
|
||||||
--CreateSubLabel(content, "Label", PADDING, yPos)
|
--CreateSubLabel(content, "Label", PADDING, yPos)
|
||||||
--yPos = yPos - 22
|
--yPos = yPos - 22
|
||||||
|
|
||||||
-- Shield checkbox
|
-- Shield checkbox (flat square toggle)
|
||||||
local shieldCheck = CreateFrame("CheckButton", "AltSystemShieldCheck", content, "UICheckButtonTemplate")
|
local shieldCheck = CreateFrame("CheckButton", "AltSystemShieldCheck", content)
|
||||||
|
shieldCheck:SetSize(20, 20)
|
||||||
shieldCheck:SetPoint("TOPLEFT", content, "TOPLEFT", PADDING, yPos)
|
shieldCheck:SetPoint("TOPLEFT", content, "TOPLEFT", PADDING, yPos)
|
||||||
shieldCheck:SetChecked(AltSystem.State.shieldEnabled)
|
shieldCheck:SetChecked(AltSystem.State.shieldEnabled)
|
||||||
|
|
||||||
local shieldText = shieldCheck:GetFontString()
|
local shieldBg = shieldCheck:CreateTexture(nil, "BACKGROUND")
|
||||||
if shieldText then
|
shieldBg:SetAllPoints()
|
||||||
shieldText:SetText("Shield (+ 1)")
|
shieldBg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
else
|
|
||||||
shieldText = shieldCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
local shieldCheckMark = shieldCheck:CreateTexture(nil, "ARTWORK")
|
||||||
shieldText:SetPoint("LEFT", shieldCheck, "RIGHT", 2, 0)
|
shieldCheckMark:SetSize(14, 14)
|
||||||
shieldText:SetText("Shield (+ 1)")
|
shieldCheckMark:SetPoint("CENTER")
|
||||||
|
shieldCheckMark:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
|
||||||
|
shieldCheckMark:SetVertexColor(0.9, 0.75, 0.2, 1)
|
||||||
|
|
||||||
|
local function UpdateShieldVisual()
|
||||||
|
if shieldCheck:GetChecked() then
|
||||||
|
shieldCheckMark:Show()
|
||||||
|
shieldBg:SetColorTexture(0.25, 0.25, 0.25, 1)
|
||||||
|
else
|
||||||
|
shieldCheckMark:Hide()
|
||||||
|
shieldBg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
UpdateShieldVisual()
|
||||||
|
|
||||||
|
local shieldLabel = shieldCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||||
|
shieldLabel:SetPoint("LEFT", shieldCheck, "RIGHT", 6, 0)
|
||||||
|
shieldLabel:SetText("Shield (+ 1)")
|
||||||
|
|
||||||
shieldCheck:SetScript("OnClick", function(self)
|
shieldCheck:SetScript("OnClick", function(self)
|
||||||
AltSystem.State.shieldEnabled = self:GetChecked()
|
AltSystem.State.shieldEnabled = self:GetChecked()
|
||||||
|
UpdateShieldVisual()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Pet checkbox
|
-- Pet checkbox (flat square toggle)
|
||||||
local petCheck = CreateFrame("CheckButton", "AltSystemPetSummonCheck", content, "UICheckButtonTemplate")
|
local petCheck = CreateFrame("CheckButton", "AltSystemPetSummonCheck", content)
|
||||||
|
petCheck:SetSize(20, 20)
|
||||||
petCheck:SetPoint("LEFT", shieldCheck, "RIGHT", 80, 0)
|
petCheck:SetPoint("LEFT", shieldCheck, "RIGHT", 80, 0)
|
||||||
petCheck:SetChecked(AltSystem.State.petSummonEnabled)
|
petCheck:SetChecked(AltSystem.State.petSummonEnabled)
|
||||||
|
|
||||||
local petText = petCheck:GetFontString()
|
local petBg = petCheck:CreateTexture(nil, "BACKGROUND")
|
||||||
if petText then
|
petBg:SetAllPoints()
|
||||||
petText:SetText("Pet (+d5)")
|
petBg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
else
|
|
||||||
petText = petCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
local petCheckMark = petCheck:CreateTexture(nil, "ARTWORK")
|
||||||
petText:SetPoint("LEFT", petCheck, "RIGHT", 2, 0)
|
petCheckMark:SetSize(14, 14)
|
||||||
petText:SetText("Pet (+d5)")
|
petCheckMark:SetPoint("CENTER")
|
||||||
|
petCheckMark:SetTexture("Interface\\RAIDFRAME\\ReadyCheck-Ready")
|
||||||
|
petCheckMark:SetVertexColor(0.9, 0.75, 0.2, 1)
|
||||||
|
|
||||||
|
local function UpdatePetVisual()
|
||||||
|
if petCheck:GetChecked() then
|
||||||
|
petCheckMark:Show()
|
||||||
|
petBg:SetColorTexture(0.25, 0.25, 0.25, 1)
|
||||||
|
else
|
||||||
|
petCheckMark:Hide()
|
||||||
|
petBg:SetColorTexture(0.3, 0.3, 0.3, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
UpdatePetVisual()
|
||||||
|
|
||||||
|
local petLabel = petCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
|
||||||
|
petLabel:SetPoint("LEFT", petCheck, "RIGHT", 6, 0)
|
||||||
|
petLabel:SetText("Pet (+d5)")
|
||||||
|
|
||||||
petCheck:SetScript("OnClick", function(self)
|
petCheck:SetScript("OnClick", function(self)
|
||||||
AltSystem.State.petSummonEnabled = self:GetChecked()
|
AltSystem.State.petSummonEnabled = self:GetChecked()
|
||||||
|
UpdatePetVisual()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
yPos = yPos - ROW_HEIGHT - SECTION_GAP
|
yPos = yPos - ROW_HEIGHT - SECTION_GAP
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue