From d3a4459071b561d2ee50fa1dfcbdf62590c5758e Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 23 Dec 2022 01:19:56 +0100 Subject: Added a method to quit game naturally through Session --- kurator/src/Session.cpp | 9 ++++++++- kurator/src/Session.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kurator/src/Session.cpp b/kurator/src/Session.cpp index 4f8e8e2..0d55eb3 100644 --- a/kurator/src/Session.cpp +++ b/kurator/src/Session.cpp @@ -22,7 +22,7 @@ Session::set(std::shared_ptr _scene) void Session::run() { - while (!window.should_close()) { + while (!window.should_close() && keep_going) { if (!scene) return; rlImGuiBegin(); @@ -35,4 +35,11 @@ Session::run() } +void +Session::quit() +{ + keep_going = false; +} + + } // namespace kurator diff --git a/kurator/src/Session.h b/kurator/src/Session.h index 43f5747..4bb55cf 100644 --- a/kurator/src/Session.h +++ b/kurator/src/Session.h @@ -15,7 +15,9 @@ class Session public: void set(std::shared_ptr _scene); void run(); + void quit(); private: + bool keep_going = true; Window window; std::shared_ptr scene; }; -- cgit v1.1