From f14a72125e456b1283dca68cad7bae44b1568dc0 Mon Sep 17 00:00:00 2001 From: Aldric Ducreux Date: Fri, 30 Aug 2024 17:45:59 +0200 Subject: [PATCH] Add tuto for command bar settings on first record --- APR-Recorder.toc | 1 + Config.lua | 1 + frames/CommandsBar.lua | 11 +++++++++++ frames/TutoFrame.lua | 11 +++++++++++ 4 files changed, 24 insertions(+) create mode 100644 frames/TutoFrame.lua diff --git a/APR-Recorder.toc b/APR-Recorder.toc index 7b2c80b..00e34dd 100644 --- a/APR-Recorder.toc +++ b/APR-Recorder.toc @@ -29,6 +29,7 @@ helper/spells.lua Commands.lua Event.lua +frames/TutoFrame.lua frames/autocomplete.lua frames/CommandsBar.lua frames/CommandsBarSetting.lua diff --git a/Config.lua b/Config.lua index b3a2bda..65fc8fc 100644 --- a/Config.lua +++ b/Config.lua @@ -47,6 +47,7 @@ function AprRC.settings:InitializeSettings() commandBarFrame = { rotation = "HORIZONTAL", position = {}, + tutorialShown = true }, commandBarSettingFrame = {}, --debug diff --git a/frames/CommandsBar.lua b/frames/CommandsBar.lua index e852694..2ff08a3 100644 --- a/frames/CommandsBar.lua +++ b/frames/CommandsBar.lua @@ -4,6 +4,7 @@ local LibWindow = LibStub("LibWindow-1.1") AprRC.CommandBar = AprRC:NewModule('CommandBar') AprRC.CommandBar.btnList = {} +AprRC.CommandBar.settingTutoFrameID = nil local FRAME_WIDTH = 80 local FRAME_HEIGHT = 35 @@ -56,7 +57,9 @@ function AprRC.CommandBar:UpdateFrame() end AprRC.CommandBar.btnList = {} + -- Check if the commands are still the default commands AprRCData.CommandBarCommands = AprRCData.CommandBarCommands or defaultCommands + for _, commandData in ipairs(AprRCData.CommandBarCommands) do local btn = CreateButton(CommandBarFrame, commandData.texture, commandData.label, function() AprRC.command:SlashCmd(commandData.command) @@ -84,12 +87,19 @@ function AprRC.CommandBar:UpdateFrame() local settingsBtn = CreateButton(CommandBarFrame, "Interface\\AddOns\\APR-Recorder\\assets\\icons\\settings", "Commands Settings", function() AprRC.CommandBarSetting:Show() + AprRC.settings.profile.commandBarFrame.tutorialShown = false + AprRC.TutoFrame:HideCustomTutorialFrame(AprRC.CommandBar.settingTutoFrameID) end) tinsert(AprRC.CommandBar.btnList, zoneDoneSaveBtn) tinsert(AprRC.CommandBar.btnList, rotationBtn) tinsert(AprRC.CommandBar.btnList, settingsBtn) AprRC.CommandBar:AdjustBarRotation(CommandBarFrame) + -- Show the tutorial if we are using the default commands + if AprRC.settings.profile.commandBarFrame.tutorialShown then + AprRC.CommandBar.settingTutoFrameID = AprRC.TutoFrame:ShowCustomTutorialFrame( + "You can add more commands in the Commands Settings panel", TutorialPointerFrame.Direction.UP, settingsBtn) + end end --------------------------------------------------------------------------------------- @@ -110,6 +120,7 @@ end function AprRC.CommandBar:RefreshFrameAnchor() if not AprRC.settings.profile.enableAddon or not AprRC.settings.profile.recordBarFrame.isRecording or C_PetBattles.IsInBattle() then CommandBarFrame:Hide() + AprRC.TutoFrame:HideCustomTutorialFrame(AprRC.CommandBar.settingTutoFrameID) return end CommandBarFrame:Show() diff --git a/frames/TutoFrame.lua b/frames/TutoFrame.lua new file mode 100644 index 0000000..00f4895 --- /dev/null +++ b/frames/TutoFrame.lua @@ -0,0 +1,11 @@ +AprRC.TutoFrame = AprRC:NewModule('TutoFrame') + +function AprRC.TutoFrame:ShowCustomTutorialFrame(message, direction, anchor) + return TutorialPointerFrame:Show(message, direction, anchor, 0, 10) +end + +function AprRC.TutoFrame:HideCustomTutorialFrame(frameID) + if frameID then + TutorialPointerFrame:Hide(frameID) + end +end