From 154140f18524b5b1155952340125fedaf5bf2780 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 21 Mar 2026 02:36:06 -0700 Subject: [PATCH] feat: add UIDropDownMenu framework, font objects, and UI global stubs Add the UIDropDownMenu compatibility framework used by virtually every addon with settings or selection menus: UIDropDownMenu_Initialize, CreateInfo, AddButton, SetWidth, SetText, GetText, SetSelectedID, etc. Add global font object stubs (GameFontNormal, GameFontHighlight, etc.) referenced by CreateFontString template arguments. Add UISpecialFrames table, InterfaceOptionsFrame for addon panels, InterfaceOptions_AddCategory, and common font color constants (GRAY_FONT_COLOR, NORMAL_FONT_COLOR, etc.). These globals prevent nil-reference errors in most popular addons. --- src/addons/lua_engine.cpp | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index ee8b3f34..d86103c5 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -2928,6 +2928,69 @@ void LuaEngine::registerCoreAPI() { "end\n" "GetCoinText = GetCoinTextureString\n" ); + + // UIDropDownMenu framework — minimal compat for addons using dropdown menus + luaL_dostring(L_, + "UIDROPDOWNMENU_MENU_LEVEL = 1\n" + "UIDROPDOWNMENU_MENU_VALUE = nil\n" + "UIDROPDOWNMENU_OPEN_MENU = nil\n" + "local _ddMenuList = {}\n" + "function UIDropDownMenu_Initialize(frame, initFunc, displayMode, level, menuList)\n" + " if frame then frame.__initFunc = initFunc end\n" + "end\n" + "function UIDropDownMenu_CreateInfo() return {} end\n" + "function UIDropDownMenu_AddButton(info, level) table.insert(_ddMenuList, info) end\n" + "function UIDropDownMenu_SetWidth(frame, width) end\n" + "function UIDropDownMenu_SetButtonWidth(frame, width) end\n" + "function UIDropDownMenu_SetText(frame, text)\n" + " if frame then frame.__text = text end\n" + "end\n" + "function UIDropDownMenu_GetText(frame)\n" + " return frame and frame.__text or ''\n" + "end\n" + "function UIDropDownMenu_SetSelectedID(frame, id) end\n" + "function UIDropDownMenu_SetSelectedValue(frame, value) end\n" + "function UIDropDownMenu_GetSelectedID(frame) return 1 end\n" + "function UIDropDownMenu_GetSelectedValue(frame) return nil end\n" + "function UIDropDownMenu_JustifyText(frame, justify) end\n" + "function UIDropDownMenu_EnableDropDown(frame) end\n" + "function UIDropDownMenu_DisableDropDown(frame) end\n" + "function CloseDropDownMenus() end\n" + "function ToggleDropDownMenu(level, value, frame, anchor, xOfs, yOfs) end\n" + ); + + // UISpecialFrames: frames in this list close on Escape key + luaL_dostring(L_, + "UISpecialFrames = {}\n" + // Font object stubs — addons reference these for CreateFontString templates + "GameFontNormal = {}\n" + "GameFontNormalSmall = {}\n" + "GameFontNormalLarge = {}\n" + "GameFontHighlight = {}\n" + "GameFontHighlightSmall = {}\n" + "GameFontHighlightLarge = {}\n" + "GameFontDisable = {}\n" + "GameFontDisableSmall = {}\n" + "GameFontWhite = {}\n" + "GameFontRed = {}\n" + "GameFontGreen = {}\n" + "NumberFontNormal = {}\n" + "ChatFontNormal = {}\n" + "SystemFont = {}\n" + // InterfaceOptionsFrame: addons register settings panels here + "InterfaceOptionsFrame = CreateFrame('Frame', 'InterfaceOptionsFrame')\n" + "InterfaceOptionsFramePanelContainer = CreateFrame('Frame', 'InterfaceOptionsFramePanelContainer')\n" + "function InterfaceOptions_AddCategory(panel) end\n" + "function InterfaceOptionsFrame_OpenToCategory(panel) end\n" + // Commonly expected global tables + "SLASH_RELOAD1 = '/reload'\n" + "SLASH_RELOADUI1 = '/reloadui'\n" + "GRAY_FONT_COLOR = {r=0.5,g=0.5,b=0.5}\n" + "NORMAL_FONT_COLOR = {r=1.0,g=0.82,b=0.0}\n" + "HIGHLIGHT_FONT_COLOR = {r=1.0,g=1.0,b=1.0}\n" + "GREEN_FONT_COLOR = {r=0.1,g=1.0,b=0.1}\n" + "RED_FONT_COLOR = {r=1.0,g=0.1,b=0.1}\n" + ); } // ---- Event System ----