diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index f8cf99e33..d84f1293e 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -92,10 +92,10 @@ GameController::GameController(): Client::Ref().AddListener(this); - debugInfo.push_back(new DebugParts(0x1, gameModel->GetSimulation())); - debugInfo.push_back(new ElementPopulationDebug(0x2, gameModel->GetSimulation())); - debugInfo.push_back(new DebugLines(0x4, gameView, this)); - debugInfo.push_back(new ParticleDebug(0x8, gameModel->GetSimulation(), gameModel)); + debugInfo.push_back(std::make_unique(DEBUG_PARTS , gameModel->GetSimulation())); + debugInfo.push_back(std::make_unique(DEBUG_ELEMENTPOP, gameModel->GetSimulation())); + debugInfo.push_back(std::make_unique(DEBUG_LINES , gameView, this)); + debugInfo.push_back(std::make_unique(DEBUG_PARTICLE , gameModel->GetSimulation(), gameModel)); } GameController::~GameController() @@ -132,10 +132,7 @@ GameController::~GameController() { delete options; } - for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) - { - delete *iter; - } + debugInfo.clear(); std::vector quickOptions = gameModel->GetQuickOptions(); for(std::vector::iterator iter = quickOptions.begin(), end = quickOptions.end(); iter != end; ++iter) { @@ -645,11 +642,15 @@ bool GameController::KeyPress(int key, int scan, bool repeat, bool shift, bool c } } - for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) + for (auto &debug : debugInfo) { - if ((*iter)->debugID & debugFlags) - if (!(*iter)->KeyPress(key, scan, shift, ctrl, alt, gameView->GetMousePosition())) + if (debug->debugID & debugFlags) + { + if (!debug->KeyPress(key, scan, shift, ctrl, alt, gameView->GetMousePosition())) + { ret = false; + } + } } } return ret; @@ -715,10 +716,12 @@ void GameController::Tick() gameModel->SetActiveTool(gameModel->SelectNextTool, gameModel->GetToolFromIdentifier(gameModel->SelectNextIdentifier)); gameModel->SelectNextIdentifier.clear(); } - for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) + for (auto &debug : debugInfo) { - if ((*iter)->debugID & debugFlags) - (*iter)->Draw(); + if (debug->debugID & debugFlags) + { + debug->Draw(); + } } commandInterface->OnTick(); } diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index cb64d7a61..d38d7dd8f 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -11,6 +11,11 @@ #include #include +constexpr auto DEBUG_PARTS = 0x0001; +constexpr auto DEBUG_ELEMENTPOP = 0x0002; +constexpr auto DEBUG_LINES = 0x0004; +constexpr auto DEBUG_PARTICLE = 0x0008; + class DebugInfo; class SaveFile; class Notification; @@ -47,7 +52,7 @@ private: TagsController * tagsWindow; LocalBrowserController * localBrowser; OptionsController * options; - std::vector debugInfo; + std::vector> debugInfo; std::unique_ptr beforeRestore; unsigned int debugFlags; diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 597718fad..c9088e1fb 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -512,6 +512,12 @@ tpt.partsdata = nil"); } lua_setfield(l, tptProperties, "eltransition"); + SETCONST(l, DEBUG_PARTS); + SETCONST(l, DEBUG_ELEMENTPOP); + SETCONST(l, DEBUG_LINES); + SETCONST(l, DEBUG_PARTICLE); + SETCONST(l, DEBUG_SURFNORM); + lua_gr_func_v = std::vector(PT_NUM); lua_gr_func = &lua_gr_func_v[0]; lua_el_func_v = std::vector(PT_NUM);