Files
moon-well-ui/vanilla/Interface/FrameXML/MoonWellUI/Chooser.lua
T
sindoring fc364f4693 Add the MoonWell UI style chooser for the 1.12 client
A patch-F.MPQ source for benilla: the player's stock FrameXML.toc with one
row appended, the chooser shown at the first world entry while the
moonwellUIStyle CVar is unset, and an Interface Style rung in the game menu
that reopens it. Forever UI is a stub that announces itself.

Verified with benilla's addon harness (clean load, choose/finish/reopen
flow), capture renders of the chooser and the game menu, and a live client:
the forever style reloads the UI, persists across a restart and switches
back to classic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 16:27:03 +04:00

128 lines
4.0 KiB
Lua

-- The interface style chooser: up at the first world entry while no style is chosen, then from
-- the game menu's "Interface Style" rung. The first time it has no Cancel and Escape does not
-- close it, so the player leaves it with a style.
local MOONWELLUI_CARDS = {
{ style = "classic", frame = "MoonWellUIChoiceFrameClassic",
texture = "Interface\\MoonWellUI\\Choice\\Classic", title = "CLASSIC", desc = "CLASSIC_DESC" },
{ style = "forever", frame = "MoonWellUIChoiceFrameForever",
texture = "Interface\\MoonWellUI\\Choice\\Forever", title = "FOREVER", desc = "FOREVER_DESC" },
}
local selectedStyle = "classic"
local firstRun = nil
local askedThisSession = nil
local function MoonWellUIChoice_Paint()
for i = 1, table.getn(MOONWELLUI_CARDS) do
local card = getglobal(MOONWELLUI_CARDS[i].frame)
local radio = getglobal(card:GetName() .. "Radio")
local preview = getglobal(card:GetName() .. "Preview")
if MOONWELLUI_CARDS[i].style == selectedStyle then
radio:SetChecked(1)
card:SetBackdropBorderColor(1, 0.82, 0)
preview:SetVertexColor(1, 1, 1)
elseif card.hovered then
radio:SetChecked(nil)
card:SetBackdropBorderColor(0.9, 0.9, 0.9)
preview:SetVertexColor(0.9, 0.9, 0.9)
else
radio:SetChecked(nil)
card:SetBackdropBorderColor(0.45, 0.45, 0.45)
preview:SetVertexColor(0.6, 0.6, 0.6)
end
end
end
-- The radio and its label centred together under the card.
local function MoonWellUIChoice_CentreRadio(card)
local radio = getglobal(card:GetName() .. "Radio")
local label = getglobal(radio:GetName() .. "Text")
local width = radio:GetWidth() + 5 + label:GetStringWidth()
radio:ClearAllPoints()
radio:SetPoint("TOPLEFT", card, "BOTTOM", -width / 2, -12)
end
function MoonWellUIChoice_OnLoad()
local text = MOONWELLUI_TEXT
local font, _, flags = GameFontNormalHuge:GetFont()
MoonWellUIChoiceFrameTitle:SetFont(font, 30, flags)
MoonWellUIChoiceFrameTitle:SetText(text.CHOOSE_TITLE)
MoonWellUIChoiceFrameHint:SetText(text.HINT)
MoonWellUIChoiceFrameFinish:SetText(text.FINISH)
MoonWellUIChoiceFrameCancel:SetText(text.CANCEL)
for i = 1, table.getn(MOONWELLUI_CARDS) do
local entry = MOONWELLUI_CARDS[i]
local card = getglobal(entry.frame)
local label = getglobal(card:GetName() .. "RadioText")
card:SetID(i)
card:SetBackdropColor(0, 0, 0, 1)
getglobal(card:GetName() .. "Preview"):SetTexture(entry.texture)
label:SetFontObject(GameFontHighlight)
label:SetText(text[entry.title])
getglobal(card:GetName() .. "Desc"):SetText(text[entry.desc])
end
this:RegisterEvent("PLAYER_ENTERING_WORLD")
end
function MoonWellUIChoice_OnEvent()
if event == "PLAYER_ENTERING_WORLD" and not askedThisSession and not MoonWellUI_GetStyle() then
askedThisSession = 1
firstRun = 1
MoonWellUIChoice_Open()
end
end
-- Open on the chosen style, else on classic.
function MoonWellUIChoice_Open()
selectedStyle = MoonWellUI_GetStyle() or "classic"
if firstRun then
MoonWellUIChoiceFrameCancel:Hide()
else
MoonWellUIChoiceFrameCancel:Show()
end
MoonWellUIChoiceFrame:Show()
end
function MoonWellUIChoice_OnShow()
for i = 1, table.getn(MOONWELLUI_CARDS) do
MoonWellUIChoice_CentreRadio(getglobal(MOONWELLUI_CARDS[i].frame))
end
MoonWellUIChoice_Paint()
end
function MoonWellUIChoice_Select(id)
local entry = MOONWELLUI_CARDS[id]
if entry and entry.style ~= selectedStyle then
PlaySound("igMainMenuOptionCheckBoxOn")
selectedStyle = entry.style
end
MoonWellUIChoice_Paint()
end
function MoonWellUIChoice_Hover(card, hovered)
card.hovered = hovered
MoonWellUIChoice_Paint()
end
function MoonWellUIChoice_Finish()
PlaySound("igMainMenuOption")
firstRun = nil
MoonWellUIChoiceFrame:Hide()
MoonWellUI_SetStyle(selectedStyle)
end
function MoonWellUIChoice_Cancel()
PlaySound("igMainMenuClose")
MoonWellUIChoiceFrame:Hide()
end
-- The frame holds the keyboard while it is up: Enter finishes, Escape cancels when it may.
function MoonWellUIChoice_OnKeyDown()
if arg1 == "ENTER" then
MoonWellUIChoice_Finish()
elseif arg1 == "ESCAPE" and not firstRun then
MoonWellUIChoice_Cancel()
end
end