mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
impr: Added proper cancel buttons to tutorial popups and tutorial selector
Closes #2571
This commit is contained in:
@@ -149,6 +149,7 @@ EXPORT_MODULE namespace hex {
|
||||
* @param unlocalizedName Name of tutorial to start
|
||||
*/
|
||||
static void startTutorial(const UnlocalizedString &unlocalizedName);
|
||||
static void stopCurrentTutorial();
|
||||
|
||||
static void startHelpHover();
|
||||
static void addInteractiveHelpText(std::initializer_list<std::variant<Lang, std::string, int>> &&ids, UnlocalizedString unlocalizedString);
|
||||
|
||||
@@ -217,6 +217,10 @@ namespace hex {
|
||||
s_currentTutorial->second.start();
|
||||
}
|
||||
|
||||
void TutorialManager::stopCurrentTutorial() {
|
||||
s_currentTutorial = s_tutorials->end();
|
||||
}
|
||||
|
||||
void TutorialManager::drawHighlights() {
|
||||
if (s_helpHoverActive) {
|
||||
const auto &drawList = ImGui::GetForegroundDrawList(ImGui::GetMainViewport());
|
||||
@@ -347,7 +351,9 @@ namespace hex {
|
||||
ImGui::SetNextWindowPos(position, ImGuiCond_Always, pivot);
|
||||
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
|
||||
ImGui::SetNextWindowSize(ImVec2(300_scaled, 0));
|
||||
if (ImGui::Begin(message->unlocalizedTitle.empty() ? "##TutorialMessage" : Lang(message->unlocalizedTitle), nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoFocusOnAppearing)) {
|
||||
|
||||
bool open = true;
|
||||
if (ImGui::Begin(message->unlocalizedTitle.empty() ? "##TutorialMessage" : Lang(message->unlocalizedTitle), &open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoFocusOnAppearing)) {
|
||||
ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindowRead());
|
||||
|
||||
auto &step = s_currentTutorial->second.m_currentStep;
|
||||
@@ -373,6 +379,10 @@ namespace hex {
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
if (!open) {
|
||||
stopCurrentTutorial();
|
||||
}
|
||||
}
|
||||
|
||||
void TutorialManager::drawTutorial() {
|
||||
|
||||
@@ -1162,6 +1162,7 @@
|
||||
"hex.builtin.view.tutorials.name": "Interactive Tutorials",
|
||||
"hex.builtin.view.tutorials.description": "Description",
|
||||
"hex.builtin.view.tutorials.start": "Start Tutorial",
|
||||
"hex.builtin.view.tutorials.stop": "Cancel current Tutorial",
|
||||
"hex.builtin.visualizer.binary": "Binary",
|
||||
"hex.builtin.visualizer.decimal.signed.16bit": "Decimal Signed (16 bits)",
|
||||
"hex.builtin.visualizer.decimal.signed.32bit": "Decimal Signed (32 bits)",
|
||||
|
||||
@@ -61,12 +61,16 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
ImGuiExt::EndSubWindow();
|
||||
|
||||
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;
|
||||
if (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;
|
||||
}
|
||||
} else {
|
||||
if (ImGuiExt::DimmedButton("hex.builtin.view.tutorials.stop"_lang, ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
|
||||
TutorialManager::stopCurrentTutorial();
|
||||
}
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
Reference in New Issue
Block a user