From f07ad0c1175cfe6ac2a3246d028b201d03b32c38 Mon Sep 17 00:00:00 2001 From: briaguya Date: Fri, 3 Jun 2022 02:55:45 -0400 Subject: [PATCH] move it to a thread --- soh/soh/Enhancements/randomizer/randomizer.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index eca1b61f9..401f38253 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -2071,6 +2071,11 @@ void GenerateRandomizerImgui() { } void DrawRandoEditor(bool& open) { + if (generated) { + generated = 0; + randoThread.join(); + } + if (!open) { return; } @@ -2088,14 +2093,12 @@ void DrawRandoEditor(bool& open) { } if (ImGui::Button("Generate")) { - GenerateRandomizerImgui(); + if (CVar_GetS32("gRandoGenerating", 0) == 0) { + randoThread = std::thread(&GenerateRandomizerImgui); + } + // GenerateRandomizerImgui(); } - // if (generated) { - // generated = 0; - // randoThread.join(); - // } - ImGui::End(); }