From ee66907504b8d34481f0ca229e3f0506bde86318 Mon Sep 17 00:00:00 2001 From: Wishmaster117 <140754794+Wishmaster117@users.noreply.github.com> Date: Thu, 2 Apr 2026 23:24:32 +0100 Subject: [PATCH 1/2] Add unequip right click to inspect windows --- Core/MultiBotHandler.lua | 4 +- MultiBot.toc | 1 + UI/MultiBotInspectUI.lua | 157 +++++++++++++++++++++++++++++++++++++++ UI/MultiBotOptions.lua | 2 +- 4 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 UI/MultiBotInspectUI.lua diff --git a/Core/MultiBotHandler.lua b/Core/MultiBotHandler.lua index 293f94f..82cc001 100644 --- a/Core/MultiBotHandler.lua +++ b/Core/MultiBotHandler.lua @@ -1843,13 +1843,13 @@ function MultiBot.HandleMultiBotEvent(event, ...) -- EQUIPPING -- if(MultiBot.inventory:IsVisible()) then - if(MultiBot.isInside(arg1, "装备", "使用", "吃", "喝", "盛宴", "摧毁")) then + if(MultiBot.isInside(arg1, "装备", "卸下", "使用", "吃", "喝", "盛宴", "摧毁")) then tButton.waitFor = "INVENTORY" SendChatMessage("items", "WHISPER", nil, tButton.name) return end - if(MultiBot.isInside(string.lower(arg1), "equipping", "using", "eating", "drinking", "feasting", "destroyed")) then + if(MultiBot.isInside(string.lower(arg1), "equipping", "unequipping", "using", "eating", "drinking", "feasting", "destroyed", "removed", "taking off")) then tButton.waitFor = "INVENTORY" SendChatMessage("items", "WHISPER", nil, tButton.name) return diff --git a/MultiBot.toc b/MultiBot.toc index fda5733..542f4c2 100644 --- a/MultiBot.toc +++ b/MultiBot.toc @@ -65,6 +65,7 @@ UI\MultiBotSpellBookFrame.lua UI\MultiBotRewardFrame.lua UI\MultiBotInventoryFrame.lua UI\MultiBotInventoryItem.lua +UI\MultiBotInspectUI.lua UI\MultiBotItemusFrame.lua UI\MultiBotIconosFrame.lua UI\MultiBotItem.lua diff --git a/UI/MultiBotInspectUI.lua b/UI/MultiBotInspectUI.lua new file mode 100644 index 0000000..e84b65c --- /dev/null +++ b/UI/MultiBotInspectUI.lua @@ -0,0 +1,157 @@ +if not MultiBot then + return +end + +local EQUIPMENT_SLOT_BY_NAME = { + HeadSlot = 1, + NeckSlot = 2, + ShoulderSlot = 3, + ShirtSlot = 4, + ChestSlot = 5, + WaistSlot = 6, + LegsSlot = 7, + FeetSlot = 8, + WristSlot = 9, + HandsSlot = 10, + Finger0Slot = 11, + Finger1Slot = 12, + Trinket0Slot = 13, + Trinket1Slot = 14, + BackSlot = 15, + MainHandSlot = 16, + SecondaryHandSlot = 17, + RangedSlot = 18, + TabardSlot = 19, +} + +local INSPECT_SLOT_SUFFIXES = { + "HeadSlot", + "NeckSlot", + "ShoulderSlot", + "ShirtSlot", + "ChestSlot", + "WaistSlot", + "LegsSlot", + "FeetSlot", + "WristSlot", + "HandsSlot", + "Finger0Slot", + "Finger1Slot", + "Trinket0Slot", + "Trinket1Slot", + "BackSlot", + "MainHandSlot", + "SecondaryHandSlot", + "RangedSlot", + "TabardSlot", +} + +local function getInspectedBotName() + local inspectUnit = InspectFrame and InspectFrame.unit + if inspectUnit and UnitExists(inspectUnit) then + return UnitName(inspectUnit) + end + + return UnitName("target") +end + +local function canUnequipInspectedBot(botName) + if not botName or botName == "" then + return false + end + + if MultiBot.isActive then + return MultiBot.isActive(botName) + end + + return UnitIsPlayer("target") and not UnitIsUnit("target", "player") +end + +local function requestInventorySync(botName) + if MultiBot.RequestBotInventory then + MultiBot.RequestBotInventory(botName) + return + end + + if MultiBot.RefreshInventory then + MultiBot.RefreshInventory(0.15) + end +end + +local function getSlotItemLink(inspectButton) + if not inspectButton then + return nil + end + + local slotId = inspectButton.GetID and inspectButton:GetID() or nil + if not slotId or slotId <= 0 then + slotId = EQUIPMENT_SLOT_BY_NAME[inspectButton.mbSlotName or ""] + end + + local inspectUnit = InspectFrame and InspectFrame.unit + if inspectUnit and UnitExists(inspectUnit) and slotId then + return GetInventoryItemLink(inspectUnit, slotId) + end + + return nil +end + +local function showRightClickHint(self) + if not GameTooltip or not GameTooltip:IsShown() then + return + end + + local botName = getInspectedBotName() + if canUnequipInspectedBot(botName) then + GameTooltip:AddLine(" ") + GameTooltip:AddLine("Clic droit : déséquiper (ue)", 1, 0.82, 0) + GameTooltip:Show() + end +end + +local function onInspectSlotClick(self, mouseButton) + if mouseButton ~= "RightButton" then + return + end + + local botName = getInspectedBotName() + if not canUnequipInspectedBot(botName) then + return + end + + local itemLink = getSlotItemLink(self) + if not itemLink or itemLink == "" then + return + end + + SendChatMessage("ue " .. itemLink, "WHISPER", nil, botName) + requestInventorySync(botName) +end + +local function hookInspectSlot(slotSuffix) + local buttonName = "Inspect" .. slotSuffix + local button = _G[buttonName] + if not button or button.__mbUnequipHooked then + return + end + + button.__mbUnequipHooked = true + button.mbSlotName = slotSuffix + button:RegisterForClicks("LeftButtonUp", "RightButtonUp") + button:HookScript("OnClick", onInspectSlotClick) + button:HookScript("OnEnter", showRightClickHint) +end + +local function hookInspectSlots() + for _, suffix in ipairs(INSPECT_SLOT_SUFFIXES) do + hookInspectSlot(suffix) + end +end + +local loader = CreateFrame("Frame") +loader:RegisterEvent("ADDON_LOADED") +loader:RegisterEvent("PLAYER_ENTERING_WORLD") +loader:RegisterEvent("INSPECT_READY") +loader:SetScript("OnEvent", function() + hookInspectSlots() +end) \ No newline at end of file diff --git a/UI/MultiBotOptions.lua b/UI/MultiBotOptions.lua index ac191a9..ee671a1 100644 --- a/UI/MultiBotOptions.lua +++ b/UI/MultiBotOptions.lua @@ -626,7 +626,7 @@ function MultiBot.BuildOptionsPanel() if UIErrorsFrame then UIErrorsFrame:AddMessage(optL("options.layout.error_no_layout_to_delete"), 1, 0.25, 0.25, 1) end - return + return end if not MultiBot.DeleteSavedMainBarLayout then if UIErrorsFrame then From 831316f34c79385638fcdd11d41821f7d37f9eba Mon Sep 17 00:00:00 2001 From: Wishmaster117 <140754794+Wishmaster117@users.noreply.github.com> Date: Thu, 2 Apr 2026 23:26:04 +0100 Subject: [PATCH 2/2] Update .luacheckrc --- .luacheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index c3ff305..160778e 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -36,7 +36,7 @@ globals = { "TooltipBackdropTemplateMixin", "NORMAL_FONT_COLOR", "HIGHLIGHT_FONT_COLOR", "GameTooltip_SetDefaultAnchor", "ChatFrame1", "UISpecialFrames", "GetMouseFocus", "ShowUIPanel", "tremove", "min", "max", "GetMinimapShape", "GetMinimapShape", "PanelTemplates_TabResize", "GetGuildRosterShowOffline", "SetGuildRosterShowOffline", "IsInGuild", "GetGuildInfo", "SetGuildRosterShowOffline", "PLAYER", "INVENTORY_TOOLTIP", "BAGSLOT", "UNKNOWN", "UnitIsDead", "ShowPrompt", "_MB_GetOrCreateShamanPos", "ensureHiddenTooltip", "MB_TAB_TITLE_DEFAULT", "SPELLBOOK", "MB_PAGE_DEFAULT", "SPELLBOOK_END_NON_SPELL_STREAK", "sendInventoryItemCommand", - "RAID_CLASS_COLORS", "INSPECT", "MB_INVENTORY_LABEL", "LOADING", "ITEM", "ITEMS", "SEARCH", "NO_QUESTS_LABEL", "QUESTS_LABEL", "QUEST_LOG" + "RAID_CLASS_COLORS", "INSPECT", "MB_INVENTORY_LABEL", "LOADING", "ITEM", "ITEMS", "SEARCH", "NO_QUESTS_LABEL", "QUESTS_LABEL", "QUEST_LOG", "UnitIsUnit" } read_globals = {