diff --git a/Core/MultiBotConfig.lua b/Core/MultiBotConfig.lua index 0992846..4b42085 100644 --- a/Core/MultiBotConfig.lua +++ b/Core/MultiBotConfig.lua @@ -21,6 +21,8 @@ local UI_DEFAULTS = { mainBar = { moveLocked = true, disableAutoCollapse = false, + autoHideEnabled = false, + autoHideDelay = 60, }, } @@ -83,6 +85,12 @@ local function migrateLegacyConfigIntoProfile(profile) if type(profile.ui.mainBar.disableAutoCollapse) ~= "boolean" then profile.ui.mainBar.disableAutoCollapse = UI_DEFAULTS.mainBar.disableAutoCollapse end + if type(profile.ui.mainBar.autoHideEnabled) ~= "boolean" then + profile.ui.mainBar.autoHideEnabled = UI_DEFAULTS.mainBar.autoHideEnabled + end + if type(profile.ui.mainBar.autoHideDelay) ~= "number" or profile.ui.mainBar.autoHideDelay <= 0 then + profile.ui.mainBar.autoHideDelay = UI_DEFAULTS.mainBar.autoHideDelay + end end local function getConfigStore(createIfMissing) @@ -147,6 +155,12 @@ function MultiBot.Config_Ensure() if type(config.ui.mainBar.disableAutoCollapse) ~= "boolean" then config.ui.mainBar.disableAutoCollapse = UI_DEFAULTS.mainBar.disableAutoCollapse end + if type(config.ui.mainBar.autoHideEnabled) ~= "boolean" then + config.ui.mainBar.autoHideEnabled = UI_DEFAULTS.mainBar.autoHideEnabled + end + if type(config.ui.mainBar.autoHideDelay) ~= "number" or config.ui.mainBar.autoHideDelay <= 0 then + config.ui.mainBar.autoHideDelay = UI_DEFAULTS.mainBar.autoHideDelay + end end -- Copy saved values into runtime timers. @@ -280,4 +294,59 @@ function MultiBot.SetDisableAutoCollapse(value) config.ui.mainBar = config.ui.mainBar or {} config.ui.mainBar.disableAutoCollapse = value and true or false return config.ui.mainBar.disableAutoCollapse +end + +local function normalizeMainBarAutoHideDelay(value) + if type(value) ~= "number" then + return UI_DEFAULTS.mainBar.autoHideDelay + end + if value < 5 then + return 5 + end + if value > 600 then + return 600 + end + return value +end + +function MultiBot.GetMainBarAutoHideEnabled() + local config = getConfigStore(false) + local value = config and config.ui and config.ui.mainBar and config.ui.mainBar.autoHideEnabled + if type(value) == "boolean" then + return value + end + + return UI_DEFAULTS.mainBar.autoHideEnabled +end + +function MultiBot.SetMainBarAutoHideEnabled(value) + local config = getConfigStore(true) + config.ui = config.ui or {} + config.ui.mainBar = config.ui.mainBar or {} + config.ui.mainBar.autoHideEnabled = value and true or false + if MultiBot.RefreshMainBarAutoHideState then + MultiBot.RefreshMainBarAutoHideState() + end + return config.ui.mainBar.autoHideEnabled +end + +function MultiBot.GetMainBarAutoHideDelay() + local config = getConfigStore(false) + local value = config and config.ui and config.ui.mainBar and config.ui.mainBar.autoHideDelay + if type(value) == "number" and value > 0 then + return normalizeMainBarAutoHideDelay(value) + end + + return UI_DEFAULTS.mainBar.autoHideDelay +end + +function MultiBot.SetMainBarAutoHideDelay(value) + local config = getConfigStore(true) + config.ui = config.ui or {} + config.ui.mainBar = config.ui.mainBar or {} + config.ui.mainBar.autoHideDelay = normalizeMainBarAutoHideDelay(value) + if MultiBot.RefreshMainBarAutoHideState then + MultiBot.RefreshMainBarAutoHideState() + end + return config.ui.mainBar.autoHideDelay end \ No newline at end of file diff --git a/Core/MultiBotEngine.lua b/Core/MultiBotEngine.lua index 2262618..38b1937 100644 --- a/Core/MultiBotEngine.lua +++ b/Core/MultiBotEngine.lua @@ -1154,6 +1154,9 @@ MultiBot.newButton = function(pParent, pX, pY, pSize, pTexture, pTip, oTemplate) if(pEvent == "RightButton" and button.doRight ~= nil) then button.doRight(button) end if(pEvent == "LeftButton" and button.doLeft ~= nil) then button.doLeft(button) end + if MultiBot.MainBarAutoHide_NotifyInteraction then + MultiBot.MainBarAutoHide_NotifyInteraction() + end if button.parent and button.parent._mbDropdownManaged then if MultiBot.RestoreCollapsedUnitBarsFromDropdown then diff --git a/Core/MultiBotHandler.lua b/Core/MultiBotHandler.lua index 82cc001..2349a8a 100644 --- a/Core/MultiBotHandler.lua +++ b/Core/MultiBotHandler.lua @@ -466,6 +466,9 @@ function MultiBot.ResetMainBarLayoutState() if multiBar and multiBar.setPoint then multiBar.setPoint(-262, 144) end + if MultiBot.RefreshMainBarAutoHideState then + MultiBot.RefreshMainBarAutoHideState() + end return true, removed end @@ -489,6 +492,9 @@ local function applyImportedLayoutEntry(key, value) local split = MultiBot.doSplit(value, ", ") multibar.setPoint(tonumber(split[1]), tonumber(split[2])) end + if MultiBot.RefreshMainBarAutoHideState then + MultiBot.RefreshMainBarAutoHideState() + end return true end diff --git a/Locales/MultiBotAceLocale-deDE.lua b/Locales/MultiBotAceLocale-deDE.lua index 503b9dd..7d574c3 100644 --- a/Locales/MultiBotAceLocale-deDE.lua +++ b/Locales/MultiBotAceLocale-deDE.lua @@ -200,6 +200,9 @@ local deDEValues = { ["options.layout.lock_mainbar_desc"] = "Aktiviert: Strg + Rechtsklick zum Verschieben der Leiste. Deaktiviert: Rechtsklick genügt.", ["options.layout.disable_autocollapse"] = "Automatisches Einklappen für Bot-Leisten deaktivieren", ["options.layout.disable_autocollapse_desc"] = "Aktiviert: Das Öffnen von Bot-Untermenüs klappt andere Bot-Leisten nicht ein.", + ["options.layout.mainbar_autohide"] = "Automatisches Ausblenden der Hauptleiste aktivieren", + ["options.layout.mainbar_autohide_desc"] = "Aktiviert: Blendet die Hauptleiste nach Inaktivität aus und zeigt sie wieder an, wenn der Mauszeiger über den Hotspot bewegt wird.", + ["options.layout.mainbar_autohide_delay"] = "Verzögerung für automatisches Ausblenden der Hauptleiste", ["options.layout.owner_import"] = "Spieler-Layout zum Importieren", ["options.layout.export"] = "Layout exportieren", ["options.layout.import"] = "Layout importieren", diff --git a/Locales/MultiBotAceLocale-enGB.lua b/Locales/MultiBotAceLocale-enGB.lua index af1a002..a589ae5 100644 --- a/Locales/MultiBotAceLocale-enGB.lua +++ b/Locales/MultiBotAceLocale-enGB.lua @@ -202,6 +202,9 @@ local enGBValues = { ["options.layout.lock_mainbar_desc"] = "Checked: Ctrl + right-click to move the bar. Unchecked: right-click is enough.", ["options.layout.disable_autocollapse"] = "Disable auto-collapse for bot bars", ["options.layout.disable_autocollapse_desc"] = "Checked: opening bot submenus will not collapse other bot bars.", + ["options.layout.mainbar_autohide"] = "Enable main bar auto-hide", + ["options.layout.mainbar_autohide_desc"] = "Checked: hide the main bar after inactivity and show it again when hovering its hotspot.", + ["options.layout.mainbar_autohide_delay"] = "Main bar auto-hide delay", ["options.layout.owner_import"] = "Player layout to import", ["options.layout.export"] = "Export layout", ["options.layout.import"] = "Import layout", diff --git a/Locales/MultiBotAceLocale-enUS.lua b/Locales/MultiBotAceLocale-enUS.lua index 878936f..60aba35 100644 --- a/Locales/MultiBotAceLocale-enUS.lua +++ b/Locales/MultiBotAceLocale-enUS.lua @@ -202,6 +202,9 @@ local enUSValues = { ["options.layout.lock_mainbar_desc"] = "Checked: Ctrl + right-click to move the bar. Unchecked: right-click is enough.", ["options.layout.disable_autocollapse"] = "Disable auto-collapse for bot bars", ["options.layout.disable_autocollapse_desc"] = "Checked: opening bot submenus will not collapse other bot bars.", + ["options.layout.mainbar_autohide"] = "Enable main bar auto-hide", + ["options.layout.mainbar_autohide_desc"] = "Checked: hide the main bar after inactivity and show it again when hovering its hotspot.", + ["options.layout.mainbar_autohide_delay"] = "Main bar auto-hide delay", ["options.layout.owner_import"] = "Player layout to import", ["options.layout.export"] = "Export layout", ["options.layout.import"] = "Import layout", diff --git a/Locales/MultiBotAceLocale-esES.lua b/Locales/MultiBotAceLocale-esES.lua index 71bd8fe..0b22e2f 100644 --- a/Locales/MultiBotAceLocale-esES.lua +++ b/Locales/MultiBotAceLocale-esES.lua @@ -200,6 +200,9 @@ local esESValues = { ["options.layout.lock_mainbar_desc"] = "Marcado: Ctrl + clic derecho para mover la barra. Desmarcado: clic derecho suficiente.", ["options.layout.disable_autocollapse"] = "Desactivar el auto-colapso de las barras de bots", ["options.layout.disable_autocollapse_desc"] = "Marcado: al abrir submenús de bots no se colapsarán otras barras de bots.", + ["options.layout.mainbar_autohide"] = "Activar el auto-ocultado de la barra principal", + ["options.layout.mainbar_autohide_desc"] = "Marcado: la barra principal se ocultará tras inactividad y volverá a mostrarse al pasar el cursor por su zona activa.", + ["options.layout.mainbar_autohide_delay"] = "Retraso del auto-ocultado de la barra principal", ["options.layout.owner_import"] = "Layout de jugador para importar", ["options.layout.export"] = "Exportar diseño", ["options.layout.import"] = "Importar diseño", diff --git a/Locales/MultiBotAceLocale-frFR.lua b/Locales/MultiBotAceLocale-frFR.lua index 1a5a86a..1f49724 100644 --- a/Locales/MultiBotAceLocale-frFR.lua +++ b/Locales/MultiBotAceLocale-frFR.lua @@ -200,6 +200,9 @@ local frFRValues = { ["options.layout.lock_mainbar_desc"] = "Coché : Ctrl + clic droit pour déplacer la barre. Décoché : clic droit suffit.", ["options.layout.disable_autocollapse"] = "Désactiver l'auto-repli des barres bots", ["options.layout.disable_autocollapse_desc"] = "Coché : l'ouverture d'un sous-menu bot ne replie plus les autres barres bots.", + ["options.layout.mainbar_autohide"] = "Activer l'auto-masquage de la barre principale", + ["options.layout.mainbar_autohide_desc"] = "Coché : masque la barre principale après inactivité et la réaffiche au survol de sa zone.", + ["options.layout.mainbar_autohide_delay"] = "Délai avant auto-masquage de la barre principale", ["options.layout.owner_import"] = "Layout joueur à importer", ["options.layout.export"] = "Exporter le layout", ["options.layout.import"] = "Importer le layout", diff --git a/Locales/MultiBotAceLocale-koKR.lua b/Locales/MultiBotAceLocale-koKR.lua index cab522a..fe96061 100644 --- a/Locales/MultiBotAceLocale-koKR.lua +++ b/Locales/MultiBotAceLocale-koKR.lua @@ -199,6 +199,9 @@ local koKRValues = { ["options.layout.lock_mainbar_desc"] = "체크: Ctrl + 우클릭으로 바 이동. 해제: 우클릭만으로 이동.", ["options.layout.disable_autocollapse"] = "봇 바 자동 접기 비활성화", ["options.layout.disable_autocollapse_desc"] = "선택 시: 봇 하위 메뉴를 열어도 다른 봇 바가 접히지 않습니다.", + ["options.layout.mainbar_autohide"] = "메인 바 자동 숨기기 활성화", + ["options.layout.mainbar_autohide_desc"] = "선택 시: 비활성 상태 후 메인 바가 숨겨지며, 핫스팟에 마우스를 올리면 다시 표시됩니다.", + ["options.layout.mainbar_autohide_delay"] = "메인 바 자동 숨기기 지연 시간", ["options.layout.owner_import"] = "가져올 플레이어 레이아웃", ["options.layout.export"] = "레이아웃 내보내기", ["options.layout.import"] = "레이아웃 가져오기", diff --git a/Locales/MultiBotAceLocale-ruRU.lua b/Locales/MultiBotAceLocale-ruRU.lua index 7fe9234..96ef53c 100644 --- a/Locales/MultiBotAceLocale-ruRU.lua +++ b/Locales/MultiBotAceLocale-ruRU.lua @@ -200,6 +200,9 @@ local ruRUValues = { ["options.layout.lock_mainbar_desc"] = "Включено: Ctrl + ПКМ для перемещения панели. Выключено: достаточно ПКМ.", ["options.layout.disable_autocollapse"] = "Отключить авто-сворачивание панелей ботов", ["options.layout.disable_autocollapse_desc"] = "Включено: при открытии подменю ботов другие панели ботов не будут сворачиваться.", + ["options.layout.mainbar_autohide"] = "Включить авто‑скрытие главной панели", + ["options.layout.mainbar_autohide_desc"] = "Включено: главная панель будет скрываться после бездействия и появляться при наведении на её область.", + ["options.layout.mainbar_autohide_delay"] = "Задержка авто‑скрытия главной панели", ["options.layout.owner_import"] = "Макет игрока для импорта", ["options.layout.export"] = "Экспорт макета", ["options.layout.import"] = "Импорт макета", diff --git a/Locales/MultiBotAceLocale-zhCN.lua b/Locales/MultiBotAceLocale-zhCN.lua index 7b453cb..24bd370 100644 --- a/Locales/MultiBotAceLocale-zhCN.lua +++ b/Locales/MultiBotAceLocale-zhCN.lua @@ -200,6 +200,9 @@ local zhCNValues = { ["options.layout.lock_mainbar_desc"] = "勾选:Ctrl + 右键拖动动作条。取消勾选:仅右键即可。", ["options.layout.disable_autocollapse"] = "禁用机器人栏的自动折叠", ["options.layout.disable_autocollapse_desc"] = "勾选:打开机器人子菜单时不会折叠其他机器人栏。", + ["options.layout.mainbar_autohide"] = "启用主栏自动隐藏", + ["options.layout.mainbar_autohide_desc"] = "勾选:主栏在无操作后会自动隐藏,鼠标悬停在热点区域时重新显示。", + ["options.layout.mainbar_autohide_delay"] = "主栏自动隐藏延迟", ["options.layout.owner_import"] = "要导入的玩家布局", ["options.layout.export"] = "导出布局", ["options.layout.import"] = "导入布局", diff --git a/UI/MultiBotMainUI.lua b/UI/MultiBotMainUI.lua index cf811ae..3ec3cf6 100644 --- a/UI/MultiBotMainUI.lua +++ b/UI/MultiBotMainUI.lua @@ -9,6 +9,8 @@ local MULTIBAR_LAYOUT_KEY = "MultiBarPoint" local MAINBAR_BUTTON_ORDER_LAYOUT_KEY = "MainBarButtonsOrder" local MAINBAR_BUTTON_STEP_Y = 34 local LEFT_LAYOUT_SHIFT = 34 +local MAINBAR_AUTOHIDE_HOTSPOT_SIZE = 42 +local MAINBAR_AUTOHIDE_UPDATE_INTERVAL = 0.2 local LEFT_LAYOUT_NAMES = { "Tanker", @@ -323,6 +325,88 @@ local function saveMultiBarPosition() local offsetX, offsetY = MultiBot.toPoint(multiBar) MultiBot.SetSavedLayoutValue(MULTIBAR_LAYOUT_KEY, offsetX .. ", " .. offsetY) + if MultiBot.RefreshMainBarAutoHideState then + MultiBot.RefreshMainBarAutoHideState() + end +end + +local function isMouseOverFrameNode(node) + if not node or (node.IsShown and not node:IsShown()) then + return false + end + + if node.IsMouseOver and node:IsMouseOver() then + return true + end + + local buttons = node.buttons + if type(buttons) == "table" then + for _, button in pairs(buttons) do + if button and button.IsShown and button:IsShown() and button.IsMouseOver and button:IsMouseOver() then + return true + end + end + end + + local children = node.frames + if type(children) == "table" then + for _, child in pairs(children) do + if isMouseOverFrameNode(child) then + return true + end + end + end + + return false +end + +local function hideMainBarForAutoHide(state) + if state.hidden then + return + end + + local multiBar = state.multiBar + if not multiBar then + return + end + + multiBar:Hide() + state.hidden = true + if state.detector then + state.detector:Show() + end +end + +local function showMainBarFromAutoHide(state) + local multiBar = state.multiBar + if not multiBar then + return + end + + if state.hidden then + multiBar:Show() + state.hidden = false + end + + if state.detector then + state.detector:Hide() + end +end + +local function markMainBarInteraction(state) + state.lastInteraction = GetTime() + showMainBarFromAutoHide(state) +end + +local function syncMainBarDetectorPosition(state) + local detector = state and state.detector + local multiBar = state and state.multiBar + if not detector or not multiBar then + return + end + + detector:ClearAllPoints() + detector:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", multiBar.x or 0, multiBar.y or 0) end local function splitCsv(value) @@ -397,6 +481,25 @@ function MultiBot.InitializeMainUI(tMultiBar) local mainButton = tMultiBar.addButton(MAIN_BUTTON_NAME, 0, 0, MAIN_BUTTON_ICON, MultiBot.L("tips.main.master")) mainButton:RegisterForDrag("RightButton") + local autoHideState = { + multiBar = MultiBot.frames and MultiBot.frames["MultiBar"], + hidden = false, + enabled = false, + delay = 60, + elapsed = 0, + lastInteraction = GetTime(), + } + + local detector = CreateFrame("Frame", "MultiBotMainBarAutoHideDetector", UIParent) + detector:SetFrameStrata("TOOLTIP") + detector:SetSize(MAINBAR_AUTOHIDE_HOTSPOT_SIZE, MAINBAR_AUTOHIDE_HOTSPOT_SIZE) + detector:EnableMouse(true) + detector:Hide() + autoHideState.detector = detector + + detector:SetScript("OnEnter", function() + markMainBarInteraction(autoHideState) + end) local function applyMoveLockState(moveLocked) local locked = moveLocked @@ -413,6 +516,7 @@ function MultiBot.InitializeMainUI(tMultiBar) applyMoveLockState() mainButton:SetScript("OnDragStart", function() + markMainBarInteraction(autoHideState) local moveLocked = mainButton.__mbMoveLocked if moveLocked and not IsControlKeyDown() then if UIErrorsFrame then @@ -426,13 +530,77 @@ function MultiBot.InitializeMainUI(tMultiBar) mainButton:SetScript("OnDragStop", function() MultiBot.frames["MultiBar"]:StopMovingOrSizing() saveMultiBarPosition() + syncMainBarDetectorPosition(autoHideState) + markMainBarInteraction(autoHideState) end) mainButton.doLeft = function(button) + markMainBarInteraction(autoHideState) MultiBot.ShowHideSwitch(button.parent.frames[MAIN_FRAME_NAME]) end local mainFrame = tMultiBar.addFrame(MAIN_FRAME_NAME, MAIN_FRAME_X, MAIN_FRAME_Y) mainFrame:Hide() + mainFrame:HookScript("OnShow", function() + markMainBarInteraction(autoHideState) + end) + mainFrame:HookScript("OnHide", function() + markMainBarInteraction(autoHideState) + end) + + function MultiBot.MainBarAutoHide_NotifyInteraction() + markMainBarInteraction(autoHideState) + end + + function MultiBot.RefreshMainBarAutoHideState() + autoHideState.enabled = MultiBot.GetMainBarAutoHideEnabled and MultiBot.GetMainBarAutoHideEnabled() or false + autoHideState.delay = MultiBot.GetMainBarAutoHideDelay and MultiBot.GetMainBarAutoHideDelay() or 60 + syncMainBarDetectorPosition(autoHideState) + if not autoHideState.enabled then + showMainBarFromAutoHide(autoHideState) + autoHideState.lastInteraction = GetTime() + end + end + + if autoHideState.multiBar and autoHideState.multiBar.HookScript then + autoHideState.multiBar:HookScript("OnShow", function() + if autoHideState.enabled and autoHideState.hidden then + return + end + autoHideState.hidden = false + if autoHideState.detector then + autoHideState.detector:Hide() + end + end) + end + + mainButton:HookScript("PostClick", function() + markMainBarInteraction(autoHideState) + end) + + if autoHideState.multiBar and autoHideState.multiBar.HookScript then + autoHideState.multiBar:HookScript("OnUpdate", function(_, elapsed) + autoHideState.elapsed = autoHideState.elapsed + elapsed + if autoHideState.elapsed < MAINBAR_AUTOHIDE_UPDATE_INTERVAL then + return + end + autoHideState.elapsed = 0 + + if not autoHideState.enabled or autoHideState.hidden then + return + end + + if isMouseOverFrameNode(autoHideState.multiBar) then + autoHideState.lastInteraction = GetTime() + return + end + + if (GetTime() - autoHideState.lastInteraction) >= autoHideState.delay then + hideMainBarForAutoHide(autoHideState) + end + end) + end + + MultiBot.RefreshMainBarAutoHideState() local defaultMainButtonOrder = { "Coords", diff --git a/UI/MultiBotOptions.lua b/UI/MultiBotOptions.lua index 4809434..ebabe0a 100644 --- a/UI/MultiBotOptions.lua +++ b/UI/MultiBotOptions.lua @@ -14,6 +14,10 @@ local function secondsLabel(value) return string.format("%.1f %s", value, suffix) end +local function mainBarAutoHideDelayLabel(value) + return string.format("%d %s", round(value, 1), MultiBot.L("options.seconds_suffix")) +end + local function getAceGUI() if type(LibStub) ~= "table" then return nil end return LibStub("AceGUI-3.0", true) @@ -154,7 +158,9 @@ local function buildLegacyOptionsContent(panel) local minimapConfig = MultiBot.GetMinimapConfig and MultiBot.GetMinimapConfig() or { hide = false } local mainBarMoveLocked = MultiBot.GetMainBarMoveLocked and MultiBot.GetMainBarMoveLocked() or true local disableAutoCollapse = MultiBot.GetDisableAutoCollapse and MultiBot.GetDisableAutoCollapse() or false - + local mainBarAutoHideEnabled = MultiBot.GetMainBarAutoHideEnabled and MultiBot.GetMainBarAutoHideEnabled() or false + local mainBarAutoHideDelay = MultiBot.GetMainBarAutoHideDelay and MultiBot.GetMainBarAutoHideDelay() or 60 + local strataDropDown = CreateFrame("Frame", "MultiBotStrataDropDown", scrollChild, "UIDropDownMenuTemplate") local chkMinimapHide = CreateFrame("CheckButton", "MultiBot_MinimapHideCheck", scrollChild, "InterfaceOptionsCheckButtonTemplate") @@ -199,16 +205,72 @@ local function buildLegacyOptionsContent(panel) end end) + local chkMainBarAutoHide = CreateFrame("CheckButton", "MultiBot_MainBarAutoHideCheck", scrollChild, "InterfaceOptionsCheckButtonTemplate") + chkMainBarAutoHide:SetPoint("TOPLEFT", chkDisableAutoCollapse, "BOTTOMLEFT", 0, -8) + _G[chkMainBarAutoHide:GetName() .. "Text"]:SetText(optL("options.layout.mainbar_autohide")) + chkMainBarAutoHide.tooltipText = optL("options.layout.mainbar_autohide_desc") + chkMainBarAutoHide:SetChecked(mainBarAutoHideEnabled and true or false) + + local mainBarAutoHideDelaySlider = CreateFrame("Slider", PANEL_NAME .. "_mainbar_autohide_delay_slider", scrollChild, "OptionsSliderTemplate") + mainBarAutoHideDelaySlider:SetPoint("TOPLEFT", chkMainBarAutoHide, "BOTTOMLEFT", 8, -18) + mainBarAutoHideDelaySlider:SetWidth(300) + mainBarAutoHideDelaySlider:SetMinMaxValues(5, 600) + mainBarAutoHideDelaySlider:SetValueStep(1) + if mainBarAutoHideDelaySlider.SetObeyStepOnDrag then + mainBarAutoHideDelaySlider:SetObeyStepOnDrag(true) + end + mainBarAutoHideDelaySlider:SetValue(mainBarAutoHideDelay) + + _G[mainBarAutoHideDelaySlider:GetName() .. "Text"]:SetText(optL("options.layout.mainbar_autohide_delay")) + _G[mainBarAutoHideDelaySlider:GetName() .. "Low"]:SetText(mainBarAutoHideDelayLabel(5)) + _G[mainBarAutoHideDelaySlider:GetName() .. "High"]:SetText(mainBarAutoHideDelayLabel(600)) + + local autoHideDelayValueLabel = scrollChild:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") + autoHideDelayValueLabel:SetPoint("TOP", mainBarAutoHideDelaySlider, "BOTTOM", 0, 0) + autoHideDelayValueLabel:SetText(mainBarAutoHideDelayLabel(mainBarAutoHideDelay)) + + local function updateMainBarAutoHideDelaySliderState() + local enabled = chkMainBarAutoHide:GetChecked() and true or false + if enabled then + mainBarAutoHideDelaySlider:Enable() + autoHideDelayValueLabel:SetTextColor(0.82, 0.82, 0.82) + else + mainBarAutoHideDelaySlider:Disable() + autoHideDelayValueLabel:SetTextColor(0.5, 0.5, 0.5) + end + end + + chkMainBarAutoHide:SetScript("OnClick", function(btn) + local enabled = btn:GetChecked() and true or false + if MultiBot.SetMainBarAutoHideEnabled then + MultiBot.SetMainBarAutoHideEnabled(enabled) + end + updateMainBarAutoHideDelaySliderState() + end) + + mainBarAutoHideDelaySlider:SetScript("OnValueChanged", function(self, value) + value = round(value, 1) + self:SetValue(value) + autoHideDelayValueLabel:SetText(mainBarAutoHideDelayLabel(value)) + if MultiBot.SetMainBarAutoHideDelay then + MultiBot.SetMainBarAutoHideDelay(value) + end + end) + + updateMainBarAutoHideDelaySliderState() + panel.chkMinimapHide = chkMinimapHide panel.chkMainBarMoveLocked = chkMainBarMoveLocked panel.chkDisableAutoCollapse = chkDisableAutoCollapse + panel.chkMainBarAutoHide = chkMainBarAutoHide + panel.mainBarAutoHideDelaySlider = mainBarAutoHideDelaySlider local selectedOwnerKey = nil local refreshOwnerDropdown local exportBtn = CreateFrame("Button", nil, scrollChild, "UIPanelButtonTemplate") exportBtn:SetSize(110, 22) - exportBtn:SetPoint("TOPLEFT", chkDisableAutoCollapse, "BOTTOMLEFT", 0, -14) + exportBtn:SetPoint("TOPLEFT", mainBarAutoHideDelaySlider, "BOTTOMLEFT", -8, -24) exportBtn:SetText(optL("options.layout.export")) exportBtn:SetScript("OnClick", function() if MultiBot.SaveMainBarLayoutForCurrentPlayer then @@ -530,6 +592,8 @@ function MultiBot.BuildOptionsPanel() local scroll = addTabScroll(tabGroup) local mainBarMoveLocked = MultiBot.GetMainBarMoveLocked and MultiBot.GetMainBarMoveLocked() or true local disableAutoCollapse = MultiBot.GetDisableAutoCollapse and MultiBot.GetDisableAutoCollapse() or false + local mainBarAutoHideEnabled = MultiBot.GetMainBarAutoHideEnabled and MultiBot.GetMainBarAutoHideEnabled() or false + local mainBarAutoHideDelay = MultiBot.GetMainBarAutoHideDelay and MultiBot.GetMainBarAutoHideDelay() or 60 local chkMainBarMoveLocked = AceGUI:Create("CheckBox") chkMainBarMoveLocked:SetLabel(mainBarMoveLockLabel) @@ -561,6 +625,50 @@ function MultiBot.BuildOptionsPanel() scroll:AddChild(chkDisableAutoCollapse) panel.chkDisableAutoCollapse = chkDisableAutoCollapse + local autoHideDelaySlider = AceGUI:Create("Slider") + autoHideDelaySlider:SetLabel(optL("options.layout.mainbar_autohide_delay")) + autoHideDelaySlider:SetSliderValues(5, 600, 1) + autoHideDelaySlider:SetValue(mainBarAutoHideDelay) + autoHideDelaySlider:SetFullWidth(true) + autoHideDelaySlider:SetCallback("OnValueChanged", function(widget, _, value) + value = round(value, 1) + widget:SetValue(value) + widget:SetLabel(formatSliderLabel(optL("options.layout.mainbar_autohide_delay"), mainBarAutoHideDelayLabel(value))) + if MultiBot.SetMainBarAutoHideDelay then + MultiBot.SetMainBarAutoHideDelay(value) + end + end) + + local function refreshAutoHideDelaySliderState(enabled) + local delayValue = MultiBot.GetMainBarAutoHideDelay and MultiBot.GetMainBarAutoHideDelay() or mainBarAutoHideDelay + autoHideDelaySlider:SetValue(delayValue) + autoHideDelaySlider:SetLabel(formatSliderLabel(optL("options.layout.mainbar_autohide_delay"), mainBarAutoHideDelayLabel(delayValue))) + if autoHideDelaySlider.SetDisabled then + autoHideDelaySlider:SetDisabled(not enabled) + end + end + + local chkMainBarAutoHide = AceGUI:Create("CheckBox") + chkMainBarAutoHide:SetLabel(optL("options.layout.mainbar_autohide")) + if chkMainBarAutoHide.SetDescription then + chkMainBarAutoHide:SetDescription(optL("options.layout.mainbar_autohide_desc")) + end + chkMainBarAutoHide:SetValue(mainBarAutoHideEnabled and true or false) + chkMainBarAutoHide:SetFullWidth(true) + chkMainBarAutoHide:SetCallback("OnValueChanged", function(_, _, value) + local enabled = value and true or false + if MultiBot.SetMainBarAutoHideEnabled then + MultiBot.SetMainBarAutoHideEnabled(enabled) + end + refreshAutoHideDelaySliderState(enabled) + end) + scroll:AddChild(chkMainBarAutoHide) + panel.chkMainBarAutoHide = chkMainBarAutoHide + + refreshAutoHideDelaySliderState(mainBarAutoHideEnabled and true or false) + scroll:AddChild(autoHideDelaySlider) + panel.autoHideDelaySlider = autoHideDelaySlider + local ownerTitle = AceGUI:Create("Label") ownerTitle:SetFullWidth(true) ownerTitle:SetText(layoutOwnerLabel)