From e3e117a14ee1cae4f7570f7e0f4a6bfeb9a449b3 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 20 Dec 2023 15:26:45 +0100 Subject: [PATCH] impr: Close tutorial view when a tutorial is started --- .../source/content/tutorials/introduction.cpp | 35 ++++++++++--------- .../source/content/views/view_tutorials.cpp | 1 + 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/plugins/builtin/source/content/tutorials/introduction.cpp b/plugins/builtin/source/content/tutorials/introduction.cpp index 62243d53a..9e3a02cd3 100644 --- a/plugins/builtin/source/content/tutorials/introduction.cpp +++ b/plugins/builtin/source/content/tutorials/introduction.cpp @@ -22,26 +22,27 @@ namespace hex::plugin::builtin { { auto &step = tutorial.addStep(); + static EventManager::EventList::iterator eventHandle; step.setMessage( - "hex.builtin.tutorial.introduction.step2.title", - "hex.builtin.tutorial.introduction.step2.description", - Bottom | Right - ) - .addHighlight("hex.builtin.tutorial.introduction.step2.highlight", - { - "Welcome Screen/Start##SubWindow_69AA6996", - Lang("hex.builtin.welcome.start.create_file") - }) - .onAppear([&step] { - EventProviderOpened::subscribe(&step, [&step](prv::Provider *provider) { - if (dynamic_cast(provider)) - step.complete(); - }); - }) - .onComplete([&step] { - EventProviderOpened::unsubscribe(&step); + "hex.builtin.tutorial.introduction.step2.title", + "hex.builtin.tutorial.introduction.step2.description", + Bottom | Right + ) + .addHighlight("hex.builtin.tutorial.introduction.step2.highlight", + { + "Welcome Screen/Start##SubWindow_69AA6996", + Lang("hex.builtin.welcome.start.create_file") + }) + .onAppear([&step] { + eventHandle = EventProviderOpened::subscribe([&step](prv::Provider *provider) { + if (dynamic_cast(provider)) + step.complete(); }); + }) + .onComplete([] { + EventProviderOpened::unsubscribe(eventHandle); + }); } { diff --git a/plugins/builtin/source/content/views/view_tutorials.cpp b/plugins/builtin/source/content/views/view_tutorials.cpp index 0b1e07de6..cc180aaa9 100644 --- a/plugins/builtin/source/content/views/view_tutorials.cpp +++ b/plugins/builtin/source/content/views/view_tutorials.cpp @@ -53,6 +53,7 @@ namespace hex::plugin::builtin { ImGui::BeginDisabled(currTutorial != tutorials.end()); if (ImGuiExt::DimmedButton("hex.builtin.view.tutorials.start"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) { TutorialManager::startTutorial(m_selectedTutorial->getUnlocalizedName()); + this->getWindowOpenState() = false; } ImGui::EndDisabled(); }