From b9baa05f2735b5c45c0bf7bccd2caef670569ae9 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Wed, 29 May 2024 20:31:45 +0300 Subject: [PATCH] working exit button --- exitButton.cpp | 6 ++---- exitButton.h | 1 - gameManager.cpp | 1 + gameManager.h | 4 +++- main.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exitButton.cpp b/exitButton.cpp index 884f3fa..b1b895c 100755 --- a/exitButton.cpp +++ b/exitButton.cpp @@ -1,7 +1,5 @@ #include "exitButton.h" -#include "defConfigs.h" - -#include +#include "gameManager.h" using namespace std; using namespace vb01; @@ -10,6 +8,6 @@ namespace battleship{ ExitButton::ExitButton(Vector3 pos, Vector2 size) : Button(pos, size, "Exit", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {} void ExitButton::onClick() { - //Root::getSingleton()->set + GameManager::getSingleton()->setRunning(false); } } diff --git a/exitButton.h b/exitButton.h index d43e9e3..c845342 100755 --- a/exitButton.h +++ b/exitButton.h @@ -1,4 +1,3 @@ -#pragma once #ifndef EXIT_BUTTON_H #define EXIT_BUTTON_H diff --git a/gameManager.cpp b/gameManager.cpp index 51cbe10..74fcb1e 100755 --- a/gameManager.cpp +++ b/gameManager.cpp @@ -145,6 +145,7 @@ namespace battleship{ } void GameManager::start(string gameDir) { + running = true; registerMembers(); initLua(gameDir); diff --git a/gameManager.h b/gameManager.h index 6bd5b19..99e93cb 100755 --- a/gameManager.h +++ b/gameManager.h @@ -25,6 +25,8 @@ namespace battleship{ inline std::string getPath(){return path;} inline gameBase::InputManager* getInputManager(){return inputManager;} inline bool isServerSide(){return serverSide;} + inline bool isRunning(){return running;} + inline void setRunning(bool r){this->running = r;} inline gameBase::StateManager* getStateManager(){return stateManager;} private: GameManager(){} @@ -36,7 +38,7 @@ namespace battleship{ gameBase::InputManager *inputManager = nullptr; int width, height; std::string path = ""; - bool serverSide; + bool serverSide, running = false; }; } diff --git a/main.cpp b/main.cpp index cbe1b10..466a279 100755 --- a/main.cpp +++ b/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char **argv) { ConcreteGuiManager::getSingleton()->readLuaScreenScript("mainMenu.lua"); - while(true){ + while(gm->isRunning()){ gm->update(); }