From 0af00a1f7c2ee8bdfb774b53d765b07b40613f47 Mon Sep 17 00:00:00 2001 From: Aldric Ducreux Date: Fri, 3 May 2024 23:31:47 +0200 Subject: [PATCH] Add route selection on record --- APR-Recorder.toc | 1 + frames/RecorderBar.lua | 15 ++++++------ frames/routeSelector.lua | 51 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 frames/routeSelector.lua diff --git a/APR-Recorder.toc b/APR-Recorder.toc index b855f8a..ec1a8a9 100644 --- a/APR-Recorder.toc +++ b/APR-Recorder.toc @@ -36,4 +36,5 @@ frames/exportRoute.lua frames/fillersSelection.lua frames/QuestionPopUp.lua frames/RecorderBar.lua +frames/routeSelector.lua frames/selectButton.lua diff --git a/frames/RecorderBar.lua b/frames/RecorderBar.lua index 0800e5d..cd4059c 100644 --- a/frames/RecorderBar.lua +++ b/frames/RecorderBar.lua @@ -53,17 +53,14 @@ local recordBtn = CreateButton(RecordBarFrame, "interface/timemanager/resetbutto recordBtn:SetScript("OnClick", function() AprRC.settings.profile.recordBarFrame.isRecording = not AprRC.settings.profile.recordBarFrame.isRecording if AprRC.settings.profile.recordBarFrame.isRecording then - if AprRCData.CurrentRoute.name ~= "" then + if not AprRC:IsTableEmpty(AprRCData.Routes) then APR.questionDialog:CreateQuestionPopup( - "New Route?", + "Continue route " .. AprRCData.CurrentRoute.name .. "?", function() - AprRC.questionDialog:CreateEditBoxPopupWithCallback("Route Name", function(text) - AprRC:InitRoute(text) - UpdateRecordButton(recordBtn) - end) + UpdateRecordButton(recordBtn) end, function() - UpdateRecordButton(recordBtn) + AprRC.SelectRoute:Show() end, YES, NO, @@ -145,3 +142,7 @@ function AprRC.record:StopRecord() UpdateRecordButton(recordBtn) AprRC:UpdateRoute() end + +function AprRC.record:UpdateRecordButton() + UpdateRecordButton(recordBtn) +end diff --git a/frames/routeSelector.lua b/frames/routeSelector.lua new file mode 100644 index 0000000..345772a --- /dev/null +++ b/frames/routeSelector.lua @@ -0,0 +1,51 @@ +local AceGUI = LibStub("AceGUI-3.0") + +AprRC.SelectRoute = AprRC:NewModule('SelectRoute') + +function AprRC.SelectRoute:Show() + local frame = AceGUI:Create("Frame") + frame:SetTitle("Select Route") + frame.statustext:GetParent():Hide() + frame:SetCallback("OnClose", function(widget) AceGUI:Release(widget) end) + frame:SetWidth(600) + frame:SetHeight(100) + frame:SetLayout("Flow") + + local dropdown = AceGUI:Create("Dropdown") + dropdown:SetFullWidth(true) + local routeList = {} + for index, route in ipairs(AprRCData.Routes) do + routeList[index] = route.name + end + local selectedRouteName = routeList[1] + dropdown:SetList(routeList) + dropdown:SetValue(1) + frame:AddChild(dropdown) + + dropdown:SetCallback("OnValueChanged", function(widget, event, index) + selectedRouteName = routeList[index] + end) + + local confirmBtn = AceGUI:Create("Button") + confirmBtn:SetText(CONTINUE) + confirmBtn:SetWidth(200) + confirmBtn:SetCallback("OnClick", function() + local route = AprRC:FindRouteByName(selectedRouteName) + AprRCData.CurrentRoute = { name = selectedRouteName, steps = route.steps } + AceGUI:Release(frame) + AprRC.record:UpdateRecordButton() + end) + frame:AddChild(confirmBtn) + + local newRouteBtn = AceGUI:Create("Button") + newRouteBtn:SetText(NEW) + newRouteBtn:SetWidth(200) + newRouteBtn:SetCallback("OnClick", function() + AceGUI:Release(frame) + AprRC.questionDialog:CreateEditBoxPopupWithCallback("Route Name", function(text) + AprRC:InitRoute(text) + AprRC.record:UpdateRecordButton() + end) + end) + frame:AddChild(newRouteBtn) +end