diff --git a/HealBotBlue.toc b/HealBotBlue.toc index eafa611..94b7783 100644 --- a/HealBotBlue.toc +++ b/HealBotBlue.toc @@ -1,6 +1,6 @@ ## Interface: 11200 ## Title: HealBotBlue -## Version: 1.3.1 +## Version: 1.3.2 ## Author: Bluewhale ## Notes: Adds panel with skinable bars for healing and decursive ## SavedVariables: HealBot_Config diff --git a/HealBot_Localization.en.lua b/HealBot_Localization.en.lua index 6d81d92..53f8071 100644 --- a/HealBot_Localization.en.lua +++ b/HealBot_Localization.en.lua @@ -1,4 +1,4 @@ -HEALBOT_VERSION = "1.3.1"; +HEALBOT_VERSION = "1.3.2"; ------------- -- ENGLISH -- diff --git a/HealBot_Model.lua b/HealBot_Model.lua index 0154eb1..0a1fc38 100644 --- a/HealBot_Model.lua +++ b/HealBot_Model.lua @@ -1,6 +1,110 @@ -- 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 + 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 + 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 + 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 = { observers = {}, units = {}, diff --git a/README.md b/README.md index 904faff..0b7412c 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ Default installation path: `C:\Program Files\World of Warcraft\Interface\AddOns\ ### Change Log +**1.3.2** +* **UIDropDownMenu Fixes:** Fixed client crash and button accumulation error on unopened dropdown menus in options. + **1.3.1** * **Hotfix: missing helper function restored** Fixed issue with lua error for druids.