Remove exit confirmation modal

This commit is contained in:
blankie 2023-01-05 20:55:54 +07:00
parent 8a0d2b428e
commit 417addab36
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 3 additions and 26 deletions

View File

@ -53,8 +53,8 @@ static inline void logs_window(bool* show_logs_window) {
ImGui::End();
}
static inline void main_window(Config& active_config, bool* show_settings_window, bool* show_logs_window, bool* exit_requested_rev) {
if (!ImGui::Begin("LogMeow", exit_requested_rev)) {
static inline void main_window(Config& active_config, bool* show_settings_window, bool* show_logs_window, bool* run_event_loop) {
if (!ImGui::Begin("LogMeow", run_event_loop)) {
ImGui::End();
return;
}
@ -107,27 +107,9 @@ static inline void debug_window() {
ImGui::End();
}
static inline void exit_modal_if_necessary(bool* run_event_loop) {
if (!ImGui::BeginPopupModal("Exit?", nullptr, ImGuiWindowFlags_NoResize)) {
return;
}
ImGui::Text("Are you sure you want to exit?");
if (ImGui::Button("Yes", ImVec2(120, 0))) {
*run_event_loop = false;
}
ImGui::SameLine();
if (ImGui::Button("No", ImVec2(120, 0))) {
ImGui::CloseCurrentPopup();
}
ImGui::SetItemDefaultFocus();
ImGui::EndPopup();
}
void event_loop(Config& config, float* config_write_timer, bool* run_event_loop) {
static bool show_settings_window = false;
static bool show_logs_window = false;
static bool exit_requested_rev = true;
debug_window();
@ -145,10 +127,5 @@ void event_loop(Config& config, float* config_write_timer, bool* run_event_loop)
logs_window(&show_logs_window);
}
if (!exit_requested_rev) {
ImGui::OpenPopup("Exit?");
exit_requested_rev = true;
}
exit_modal_if_necessary(run_event_loop);
main_window(config, &show_settings_window, &show_logs_window, &exit_requested_rev);
main_window(config, &show_settings_window, &show_logs_window, run_event_loop);
}