From 26f25d969cc3e71b72f259020846bfd17224b6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Correia?= Date: Fri, 15 May 2026 13:27:31 +0100 Subject: [PATCH] Redesigned radio buttons --- UI.lua | 123 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 32 deletions(-) diff --git a/UI.lua b/UI.lua index 09e0cab..c838c90 100755 --- a/UI.lua +++ b/UI.lua @@ -84,27 +84,46 @@ local function CreateDropdown(parent, name, labelText, options, defaultIndex, on 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 radio = CreateFrame("CheckButton", name, parent, "UIRadioButtonTemplate") - radio:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y) - radio:SetChecked(isChecked) + local size = 20 + local btn = CreateFrame("CheckButton", name, parent) + btn:SetSize(size, size) + btn:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y) - local radioText = radio:GetFontString() - if radioText then - radioText:SetText(text) - radioText:SetFontObject("GameFontHighlight") - else - local t = radio:CreateFontString(nil, "OVERLAY", "GameFontHighlight") - t:SetPoint("LEFT", radio, "RIGHT", 4, 0) - t:SetText(text) + -- Background (grey when unselected, yellow when selected) — circular via mask + local bg = btn:CreateTexture(nil, "BACKGROUND") + bg:SetAllPoints() + bg:SetColorTexture(0.3, 0.3, 0.3, 1) + local mask = btn:CreateMaskTexture() + mask:SetAllPoints() + mask:SetTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE") + 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 - 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) + UpdateVisual() end) - return radio + btn.UpdateVisual = UpdateVisual + return btn end -- Helper: Create a section header (golden text) @@ -242,6 +261,8 @@ function AltSystem:CreateMainFrame() AltSystem.State.rollType = rollType attackRadio:SetChecked(rollType == "attack") defenseRadio:SetChecked(rollType == "defense") + attackRadio.UpdateVisual() + defenseRadio.UpdateVisual() -- Update roll button text if AltSystem.RollButton then local label = rollType == "attack" and "Roll Attack" or "Roll Defense" @@ -330,6 +351,7 @@ function AltSystem:CreateMainFrame() AltSystem.State.selectedDefenseIndex = index for i, radio in ipairs(armorRadios) do radio:SetChecked(i == index) + radio.UpdateVisual() end end @@ -361,6 +383,7 @@ function AltSystem:CreateMainFrame() AltSystem.State.selectedItemIndex = index for i, radio in ipairs(itemRadios) do radio:SetChecked(i == index) + radio.UpdateVisual() end end @@ -387,40 +410,76 @@ function AltSystem:CreateMainFrame() --CreateSubLabel(content, "Label", PADDING, yPos) --yPos = yPos - 22 - -- Shield checkbox - local shieldCheck = CreateFrame("CheckButton", "AltSystemShieldCheck", content, "UICheckButtonTemplate") + -- Shield checkbox (flat square toggle) + local shieldCheck = CreateFrame("CheckButton", "AltSystemShieldCheck", content) + shieldCheck:SetSize(20, 20) shieldCheck:SetPoint("TOPLEFT", content, "TOPLEFT", PADDING, yPos) shieldCheck:SetChecked(AltSystem.State.shieldEnabled) - local shieldText = shieldCheck:GetFontString() - if shieldText then - shieldText:SetText("Shield (+ 1)") - else - shieldText = shieldCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight") - shieldText:SetPoint("LEFT", shieldCheck, "RIGHT", 2, 0) - shieldText:SetText("Shield (+ 1)") + local shieldBg = shieldCheck:CreateTexture(nil, "BACKGROUND") + shieldBg:SetAllPoints() + shieldBg:SetColorTexture(0.3, 0.3, 0.3, 1) + + local shieldCheckMark = shieldCheck:CreateTexture(nil, "ARTWORK") + shieldCheckMark:SetSize(14, 14) + 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 + UpdateShieldVisual() + + local shieldLabel = shieldCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight") + shieldLabel:SetPoint("LEFT", shieldCheck, "RIGHT", 6, 0) + shieldLabel:SetText("Shield (+ 1)") shieldCheck:SetScript("OnClick", function(self) AltSystem.State.shieldEnabled = self:GetChecked() + UpdateShieldVisual() end) - -- Pet checkbox - local petCheck = CreateFrame("CheckButton", "AltSystemPetSummonCheck", content, "UICheckButtonTemplate") + -- Pet checkbox (flat square toggle) + local petCheck = CreateFrame("CheckButton", "AltSystemPetSummonCheck", content) + petCheck:SetSize(20, 20) petCheck:SetPoint("LEFT", shieldCheck, "RIGHT", 80, 0) petCheck:SetChecked(AltSystem.State.petSummonEnabled) - local petText = petCheck:GetFontString() - if petText then - petText:SetText("Pet (+d5)") - else - petText = petCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight") - petText:SetPoint("LEFT", petCheck, "RIGHT", 2, 0) - petText:SetText("Pet (+d5)") + local petBg = petCheck:CreateTexture(nil, "BACKGROUND") + petBg:SetAllPoints() + petBg:SetColorTexture(0.3, 0.3, 0.3, 1) + + local petCheckMark = petCheck:CreateTexture(nil, "ARTWORK") + petCheckMark:SetSize(14, 14) + 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 + UpdatePetVisual() + + local petLabel = petCheck:CreateFontString(nil, "OVERLAY", "GameFontHighlight") + petLabel:SetPoint("LEFT", petCheck, "RIGHT", 6, 0) + petLabel:SetText("Pet (+d5)") petCheck:SetScript("OnClick", function(self) AltSystem.State.petSummonEnabled = self:GetChecked() + UpdatePetVisual() end) yPos = yPos - ROW_HEIGHT - SECTION_GAP