Refactor + Horfixes: replace UIDropDownMenu calls with wrapper functions and redesign chat option UI to support spell-based configuration.

This commit is contained in:
Bluewhale1337
2026-07-10 15:54:36 +02:00
parent c50bcd54f3
commit f8c6c3493b
13 changed files with 220 additions and 280 deletions
+19 -97
View File
@@ -1,108 +1,30 @@
-- HealBot_Model.lua
-- Centralized Data Store and Observer System for HealBotBlue
-- Fix legacy client UIDropDownMenu crash when setting value/id/refreshing while dropdown is not open
if UIDropDownMenu_Refresh and not HealBot_UIDropDownMenu_Refresh_Fixed then
local orig_UIDropDownMenu_Refresh = UIDropDownMenu_Refresh
UIDropDownMenu_Refresh = function(frame, useValue, group)
local targetFrame = frame or this
if not targetFrame or type(targetFrame) ~= "table" then return end
if not UIDROPDOWNMENU_OPEN_MENU or (targetFrame.GetName and targetFrame:GetName() ~= UIDROPDOWNMENU_OPEN_MENU) then
return
-- Safe local wrappers to prevent native UIDropDownMenu concatenation crashes
-- when setting selected values on closed dropdowns during initialization.
function HealBot_UIDropDownMenu_SetSelectedID(frame, id, useValue)
local wasNil = false
if not UIDROPDOWNMENU_OPEN_MENU then
UIDROPDOWNMENU_OPEN_MENU = "DropDownList1"
wasNil = true
end
UIDropDownMenu_SetSelectedID(frame, id, useValue)
if wasNil then
UIDROPDOWNMENU_OPEN_MENU = nil
end
orig_UIDropDownMenu_Refresh(targetFrame, useValue, group)
end
HealBot_UIDropDownMenu_Refresh_Fixed = true
end
if UIDropDownMenu_Initialize and not HealBot_UIDropDownMenu_Initialize_Fixed then
local orig_UIDropDownMenu_Initialize = UIDropDownMenu_Initialize
UIDropDownMenu_Initialize = function(frame, initFunction, displayMode, level)
local targetFrame = frame or this
if not targetFrame or type(targetFrame) ~= "table" then return end
local name = targetFrame.GetName and targetFrame:GetName()
if UIDROPDOWNMENU_OPEN_MENU and name and name == UIDROPDOWNMENU_OPEN_MENU then
orig_UIDropDownMenu_Initialize(targetFrame, initFunction, displayMode, level)
else
local orig_AddButton = UIDropDownMenu_AddButton
UIDropDownMenu_AddButton = function(info, lvl)
-- Do nothing to prevent button accumulation in DropDownList1
end
orig_UIDropDownMenu_Initialize(targetFrame, initFunction, displayMode, level)
UIDropDownMenu_AddButton = orig_AddButton
function HealBot_UIDropDownMenu_SetSelectedValue(frame, value, useValue)
local wasNil = false
if not UIDROPDOWNMENU_OPEN_MENU then
UIDROPDOWNMENU_OPEN_MENU = "DropDownList1"
wasNil = true
end
end
HealBot_UIDropDownMenu_Initialize_Fixed = true
end
if UIDropDownMenu_SetSelectedID and not HealBot_UIDropDownMenu_SetSelectedID_Fixed then
local orig_UIDropDownMenu_SetSelectedID = UIDropDownMenu_SetSelectedID
UIDropDownMenu_SetSelectedID = function(frame, id, useValue)
local targetFrame = frame or this
if not targetFrame or type(targetFrame) ~= "table" then return end
local name = targetFrame.GetName and targetFrame:GetName()
if UIDROPDOWNMENU_OPEN_MENU and name and name == UIDROPDOWNMENU_OPEN_MENU then
orig_UIDropDownMenu_SetSelectedID(targetFrame, id, useValue)
else
targetFrame.selectedID = id
targetFrame.selectedValue = nil
targetFrame.selectedName = nil
if targetFrame.initialize then
local buttons = {}
local orig_AddButton = UIDropDownMenu_AddButton
UIDropDownMenu_AddButton = function(info, level)
table.insert(buttons, info)
end
local temp_this = this
this = targetFrame
targetFrame.initialize(1)
this = temp_this
UIDropDownMenu_AddButton = orig_AddButton
if buttons[id] then
UIDropDownMenu_SetText(buttons[id].text, targetFrame)
end
end
UIDropDownMenu_SetSelectedValue(frame, value, useValue)
if wasNil then
UIDROPDOWNMENU_OPEN_MENU = nil
end
end
HealBot_UIDropDownMenu_SetSelectedID_Fixed = true
end
if UIDropDownMenu_SetSelectedValue and not HealBot_UIDropDownMenu_SetSelectedValue_Fixed then
local orig_UIDropDownMenu_SetSelectedValue = UIDropDownMenu_SetSelectedValue
UIDropDownMenu_SetSelectedValue = function(frame, value, useValue)
local targetFrame = frame or this
if not targetFrame or type(targetFrame) ~= "table" then return end
local name = targetFrame.GetName and targetFrame:GetName()
if UIDROPDOWNMENU_OPEN_MENU and name and name == UIDROPDOWNMENU_OPEN_MENU then
orig_UIDropDownMenu_SetSelectedValue(targetFrame, value, useValue)
else
targetFrame.selectedID = nil
targetFrame.selectedValue = value
targetFrame.selectedName = nil
if targetFrame.initialize then
local buttons = {}
local orig_AddButton = UIDropDownMenu_AddButton
UIDropDownMenu_AddButton = function(info, level)
table.insert(buttons, info)
end
local temp_this = this
this = targetFrame
targetFrame.initialize(1)
this = temp_this
UIDropDownMenu_AddButton = orig_AddButton
for _, btn in ipairs(buttons) do
if btn.value == value then
UIDropDownMenu_SetText(btn.text, targetFrame)
break
end
end
end
end
end
HealBot_UIDropDownMenu_SetSelectedValue_Fixed = true
end
HealBot_Model = {