From 28516c24e99e9eedb541c2262cfd483f5966db89 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 4 Sep 2014 17:21:39 -0400 Subject: [PATCH 1/6] msvc compiling fixes --- SConscript | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SConscript b/SConscript index fd08935c2..c44cb4f27 100644 --- a/SConscript +++ b/SConscript @@ -92,7 +92,9 @@ if msvc and platform != "Windows": FatalError("Error: --msvc only works on windows") #Create SCons Environment -if platform == "Windows" and not GetOption('msvc'): +if GetOption('msvc'): + env = Environment(tools = ['default'], ENV = {'PATH' : os.environ['PATH'], 'TMP' : os.environ['TMP']}, TARGET_ARCH = 'x86') +elif platform == "Windows" and not GetOption('msvc'): env = Environment(tools = ['mingw'], ENV = {'PATH' : os.environ['PATH']}) else: env = Environment(tools = ['default'], ENV = {'PATH' : os.environ['PATH']}) @@ -168,6 +170,7 @@ if GetOption("msvc"): env.Append(LIBPATH=['StaticLibs/']) else: env.Append(LIBPATH=['Libraries/']) + env.Append(CPPPATH=['includes/']) #Check 32/64 bit def CheckBit(context): @@ -282,7 +285,7 @@ def findLibs(env, conf): FatalError("bzip2 headers not found") #Look for libz - if not conf.CheckLib('z'): + if not conf.CheckLib(['z', 'zlib']): FatalError("libz not found or not installed") #Look for pthreads @@ -342,7 +345,7 @@ elif not GetOption('help'): conf.AddTest('CheckBit', CheckBit) if not conf.CheckCC() or not conf.CheckCXX(): FatalError("compiler not correctly configured") - if platform == compilePlatform and isX86 and not GetOption('32bit') and not GetOption('64bit'): + if platform == compilePlatform and isX86 and not GetOption('32bit') and not GetOption('64bit') and not GetOption('msvc'): conf.CheckBit() findLibs(env, conf) env = conf.Finish() @@ -381,7 +384,8 @@ if isX86: if not GetOption('no-sse'): if GetOption('sse'): if msvc: - env.Append(CCFLAGS=['/arch:SSE']) + if not GetOption('sse2'): + env.Append(CCFLAGS=['/arch:SSE']) else: env.Append(CCFLAGS=['-msse']) env.Append(CPPDEFINES=['X86_SSE']) From a78129adb99e083bba5f3ef4a0fb553714d0315d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 8 Sep 2014 16:06:12 -0400 Subject: [PATCH 2/6] Fix spelling mistake --- src/simulation/elements/PIPE.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index daf354b17..3e24c1b76 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -28,7 +28,7 @@ Element_PIPE::Element_PIPE() Temperature = 273.15f; HeatConduct = 0; - Description = "PIPE, moves particles around. Once the BRCK generates, erase some for the exit. Then the PIPE generates and is useable."; + Description = "PIPE, moves particles around. Once the BRCK generates, erase some for the exit. Then the PIPE generates and is usable."; State = ST_SOLID; Properties = TYPE_SOLID|PROP_LIFE_DEC; From 6beafc354d1083fc0e6fe831d33533e5c7721f03 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 23 Sep 2014 17:06:52 -0400 Subject: [PATCH 3/6] fix "open data folder" on windows --- src/gui/options/OptionsView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index dd2bf5a32..46684a696 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -215,7 +215,7 @@ OptionsView::OptionsView(): { //one of these should always be defined #ifdef WIN - const char* openCommand = "start "; + const char* openCommand = "explorer "; #elif MACOSX const char* openCommand = "open "; //#elif LIN From 507ba35ce089da17d75549c3907e0512f6b8fc29 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 27 Sep 2014 21:40:16 -0400 Subject: [PATCH 4/6] new DebugInfo thing: the old debug lines --- src/debug/DebugInfo.h | 2 +- src/debug/DebugLines.cpp | 110 ++++++++++++++++++++++++++++++++ src/debug/DebugLines.h | 15 +++++ src/debug/ElementPopulation.cpp | 3 +- src/debug/ElementPopulation.h | 2 +- src/gui/game/GameController.cpp | 6 +- src/gui/game/GameView.h | 10 ++- 7 files changed, 140 insertions(+), 8 deletions(-) create mode 100644 src/debug/DebugLines.cpp create mode 100644 src/debug/DebugLines.h diff --git a/src/debug/DebugInfo.h b/src/debug/DebugInfo.h index 4cdfedc38..5a7f00500 100644 --- a/src/debug/DebugInfo.h +++ b/src/debug/DebugInfo.h @@ -5,5 +5,5 @@ class DebugInfo { public: - virtual void Draw(ui::Point position) {} + virtual void Draw() {} }; diff --git a/src/debug/DebugLines.cpp b/src/debug/DebugLines.cpp new file mode 100644 index 000000000..3f2da8491 --- /dev/null +++ b/src/debug/DebugLines.cpp @@ -0,0 +1,110 @@ +#include "DebugLines.h" +#include "gui/interface/Engine.h" +#include "gui/game/GameView.h" +#include "gui/game/GameController.h" + +LineDebug::LineDebug(GameView * view, GameController * controller): + view(view), + controller(controller) +{ + +} + +void LineDebug::Draw() +{ + Graphics * g = ui::Engine::Ref().g; + + if (view->GetDrawingLine()) + { + ui::Point drawPoint1 = controller->PointTranslate(view->GetLineStartCoords()), drawPoint2 = controller->PointTranslate(view->GetLineFinishCoords()); + if (view->GetDrawSnap()) + drawPoint2 = view->lineSnapCoords(drawPoint1, drawPoint2); + //g->draw_line(drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y, 255, 0, 255, 255); + + g->draw_line(0, drawPoint1.Y, XRES, drawPoint1.Y, 255, 255, 255, 120); + g->draw_line(drawPoint1.X, 0, drawPoint1.X, YRES, 255, 255, 255, 120); + + g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120); + g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120); + + stringstream info; + info << drawPoint2.X << " x " << drawPoint2.Y; + g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info.str().c_str())-3), drawPoint2.Y+(drawPoint2.Ydrawtext_outline(drawPoint1.X+(drawPoint2.Xtextwidth(info.str().c_str())-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200); + + info.str(""); + info << std::abs(drawPoint2.X-drawPoint1.X); + g->drawtext_outline((drawPoint1.X+drawPoint2.X)/2-g->textwidth(info.str().c_str())/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200); + + info.str(""); + info << std::abs(drawPoint2.Y-drawPoint1.Y); + g->drawtext_outline(drawPoint1.X+(drawPoint2.Xtextwidth(info.str().c_str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str().c_str(), 255, 255, 255, 200); + } + /*int yBottom = YRES-10; + int xStart = 10; + + std::string maxValString; + std::string halfValString; + + + float maxVal = 255; + float scale = 1.0f; + int bars = 0; + for(int i = 0; i < PT_NUM; i++) + { + if(sim->elements[i].Enabled) + { + if(maxVal < sim->elementCount[i]) + maxVal = sim->elementCount[i]; + bars++; + } + } + maxAverage = (maxAverage*(1.0f-0.015f)) + (0.015f*maxVal); + scale = 255.0f/maxAverage; + + maxValString = format::NumberToString(maxAverage); + halfValString = format::NumberToString(maxAverage/2); + + + g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180); + + bars = 0; + for(int i = 0; i < PT_NUM; i++) + { + if(sim->elements[i].Enabled) + { + float count = sim->elementCount[i]; + int barSize = (count * scale - 0.5f); + int barX = bars;//*2; + + g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); + if(sim->elementCount[i]) + { + if(barSize > 256) + { + barSize = 256; + g->blendpixel(xStart+barX, yBottom-barSize-3, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); + g->blendpixel(xStart+barX, yBottom-barSize-5, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); + g->blendpixel(xStart+barX, yBottom-barSize-7, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); + } else { + + g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180); + } + g->draw_line(xStart+barX, yBottom-barSize, xStart+barX, yBottom, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); + } + bars++; + } + } + + g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255); + g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255); + g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255);*/ +} + +LineDebug::~LineDebug() +{ + +} diff --git a/src/debug/DebugLines.h b/src/debug/DebugLines.h new file mode 100644 index 000000000..302408921 --- /dev/null +++ b/src/debug/DebugLines.h @@ -0,0 +1,15 @@ +#pragma once + +#include "DebugInfo.h" + +class GameView; +class GameController; +class LineDebug : public DebugInfo +{ + GameView * view; + GameController * controller; +public: + LineDebug(GameView * view, GameController * controller); + virtual void Draw(); + virtual ~LineDebug(); +}; diff --git a/src/debug/ElementPopulation.cpp b/src/debug/ElementPopulation.cpp index 33994a745..e01de6e20 100644 --- a/src/debug/ElementPopulation.cpp +++ b/src/debug/ElementPopulation.cpp @@ -10,10 +10,9 @@ ElementPopulationDebug::ElementPopulationDebug(Simulation * sim): } -void ElementPopulationDebug::Draw(ui::Point position) +void ElementPopulationDebug::Draw() { Graphics * g = ui::Engine::Ref().g; - //g->drawtext(10, 10, "Arse", 255, 255, 255, 255); int yBottom = YRES-10; int xStart = 10; diff --git a/src/debug/ElementPopulation.h b/src/debug/ElementPopulation.h index a1a209317..dfd679e62 100644 --- a/src/debug/ElementPopulation.h +++ b/src/debug/ElementPopulation.h @@ -9,6 +9,6 @@ class ElementPopulationDebug : public DebugInfo float maxAverage; public: ElementPopulationDebug(Simulation * sim); - virtual void Draw(ui::Point position); + virtual void Draw(); virtual ~ElementPopulationDebug(); }; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 43f039664..8f7cbe988 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -26,12 +26,13 @@ #include "gui/interface/Keys.h" #include "simulation/Snapshot.h" #include "debug/DebugInfo.h" +#include "debug/ElementPopulation.h" +#include "debug/DebugLines.h" #ifdef LUACONSOLE #include "lua/LuaScriptInterface.h" #else #include "lua/TPTScriptInterface.h" #endif -//#include "debug/ElementPopulation.h" using namespace std; @@ -156,6 +157,7 @@ GameController::GameController(): Client::Ref().AddListener(this); //debugInfo.push_back(new ElementPopulationDebug(gameModel->GetSimulation())); + //debugInfo.push_back(new LineDebug(gameView, this)); } GameController::~GameController() @@ -741,7 +743,7 @@ void GameController::Tick() } for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) { - (*iter)->Draw(ui::Point(10, 10)); + (*iter)->Draw(); } commandInterface->OnTick(); } diff --git a/src/gui/game/GameView.h b/src/gui/game/GameView.h index 90fae7db2..acbe0e03e 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -113,8 +113,6 @@ private: int lastOffset; void setToolButtonOffset(int offset); - virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2); - virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2); void screenshot(); void record(); @@ -145,6 +143,14 @@ public: SelectMode GetSelectMode() { return selectMode; } void BeginStampSelection(); + //all of these are only here for one debug lines + bool GetDrawingLine() { return drawMode == DrawLine && isMouseDown; } + bool GetDrawSnap() { return drawSnap; } + ui::Point GetLineStartCoords() { return drawPoint1; } + ui::Point GetLineFinishCoords() { return currentMouse; } + ui::Point lineSnapCoords(ui::Point point1, ui::Point point2); + ui::Point rectSnapCoords(ui::Point point1, ui::Point point2); + void AttachController(GameController * _c){ c = _c; } void NotifyRendererChanged(GameModel * sender); void NotifySimulationChanged(GameModel * sender); From 32328ad4fe07048e5b2b39db759a45f51af53510 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 27 Sep 2014 22:25:15 -0400 Subject: [PATCH 5/6] re-implement tpt.setdebug --- src/debug/DebugInfo.h | 2 ++ src/debug/DebugLines.cpp | 62 ++------------------------------- src/debug/DebugLines.h | 2 +- src/debug/ElementPopulation.cpp | 3 +- src/debug/ElementPopulation.h | 2 +- src/gui/game/GameController.cpp | 8 ++--- src/gui/game/GameController.h | 2 ++ src/lua/LegacyLuaAPI.cpp | 4 ++- 8 files changed, 17 insertions(+), 68 deletions(-) diff --git a/src/debug/DebugInfo.h b/src/debug/DebugInfo.h index 5a7f00500..9266b87fe 100644 --- a/src/debug/DebugInfo.h +++ b/src/debug/DebugInfo.h @@ -5,5 +5,7 @@ class DebugInfo { public: + DebugInfo(unsigned int id):ID(id) { } + unsigned int ID; virtual void Draw() {} }; diff --git a/src/debug/DebugLines.cpp b/src/debug/DebugLines.cpp index 3f2da8491..5174e8868 100644 --- a/src/debug/DebugLines.cpp +++ b/src/debug/DebugLines.cpp @@ -3,7 +3,8 @@ #include "gui/game/GameView.h" #include "gui/game/GameController.h" -LineDebug::LineDebug(GameView * view, GameController * controller): +LineDebug::LineDebug(unsigned int id, GameView * view, GameController * controller): + DebugInfo(id), view(view), controller(controller) { @@ -43,65 +44,6 @@ void LineDebug::Draw() info << std::abs(drawPoint2.Y-drawPoint1.Y); g->drawtext_outline(drawPoint1.X+(drawPoint2.Xtextwidth(info.str().c_str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str().c_str(), 255, 255, 255, 200); } - /*int yBottom = YRES-10; - int xStart = 10; - - std::string maxValString; - std::string halfValString; - - - float maxVal = 255; - float scale = 1.0f; - int bars = 0; - for(int i = 0; i < PT_NUM; i++) - { - if(sim->elements[i].Enabled) - { - if(maxVal < sim->elementCount[i]) - maxVal = sim->elementCount[i]; - bars++; - } - } - maxAverage = (maxAverage*(1.0f-0.015f)) + (0.015f*maxVal); - scale = 255.0f/maxAverage; - - maxValString = format::NumberToString(maxAverage); - halfValString = format::NumberToString(maxAverage/2); - - - g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180); - - bars = 0; - for(int i = 0; i < PT_NUM; i++) - { - if(sim->elements[i].Enabled) - { - float count = sim->elementCount[i]; - int barSize = (count * scale - 0.5f); - int barX = bars;//*2; - - g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); - if(sim->elementCount[i]) - { - if(barSize > 256) - { - barSize = 256; - g->blendpixel(xStart+barX, yBottom-barSize-3, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); - g->blendpixel(xStart+barX, yBottom-barSize-5, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); - g->blendpixel(xStart+barX, yBottom-barSize-7, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); - } else { - - g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180); - } - g->draw_line(xStart+barX, yBottom-barSize, xStart+barX, yBottom, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); - } - bars++; - } - } - - g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255); - g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255); - g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255);*/ } LineDebug::~LineDebug() diff --git a/src/debug/DebugLines.h b/src/debug/DebugLines.h index 302408921..007689998 100644 --- a/src/debug/DebugLines.h +++ b/src/debug/DebugLines.h @@ -9,7 +9,7 @@ class LineDebug : public DebugInfo GameView * view; GameController * controller; public: - LineDebug(GameView * view, GameController * controller); + LineDebug(unsigned int id, GameView * view, GameController * controller); virtual void Draw(); virtual ~LineDebug(); }; diff --git a/src/debug/ElementPopulation.cpp b/src/debug/ElementPopulation.cpp index e01de6e20..1cfd9c5d8 100644 --- a/src/debug/ElementPopulation.cpp +++ b/src/debug/ElementPopulation.cpp @@ -3,7 +3,8 @@ #include "simulation/Simulation.h" #include "Format.h" -ElementPopulationDebug::ElementPopulationDebug(Simulation * sim): +ElementPopulationDebug::ElementPopulationDebug(unsigned int id, Simulation * sim): + DebugInfo(id), sim(sim), maxAverage(255.0f) { diff --git a/src/debug/ElementPopulation.h b/src/debug/ElementPopulation.h index dfd679e62..64de0674f 100644 --- a/src/debug/ElementPopulation.h +++ b/src/debug/ElementPopulation.h @@ -8,7 +8,7 @@ class ElementPopulationDebug : public DebugInfo Simulation * sim; float maxAverage; public: - ElementPopulationDebug(Simulation * sim); + ElementPopulationDebug(unsigned int id, Simulation * sim); virtual void Draw(); virtual ~ElementPopulationDebug(); }; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 8f7cbe988..9cc750370 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -153,11 +153,10 @@ GameController::GameController(): ActiveToolChanged(2, gameModel->GetActiveTool(2)); ActiveToolChanged(3, gameModel->GetActiveTool(3)); - //sim = new Simulation(); Client::Ref().AddListener(this); - //debugInfo.push_back(new ElementPopulationDebug(gameModel->GetSimulation())); - //debugInfo.push_back(new LineDebug(gameView, this)); + debugInfo.push_back(new ElementPopulationDebug(0x2, gameModel->GetSimulation())); + debugInfo.push_back(new LineDebug(0x4, gameView, this)); } GameController::~GameController() @@ -743,7 +742,8 @@ void GameController::Tick() } for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) { - (*iter)->Draw(); + if ((*iter)->ID & debugFlags) + (*iter)->Draw(); } commandInterface->OnTick(); } diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index a7cdfc94b..c436c9dad 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -46,6 +46,7 @@ private: OptionsController * options; CommandInterface * commandInterface; vector debugInfo; + unsigned int debugFlags; public: bool HasDone; class SearchCallback; @@ -101,6 +102,7 @@ public: bool GetHudEnable(); void SetDebugHUD(bool hudState); bool GetDebugHUD(); + void SetDebugFlags(unsigned int flags) { debugFlags = flags; } void SetActiveMenu(int menuID); std::vector GetMenuList(); Tool * GetActiveTool(int selection); diff --git a/src/lua/LegacyLuaAPI.cpp b/src/lua/LegacyLuaAPI.cpp index ca67c8919..17fd59453 100644 --- a/src/lua/LegacyLuaAPI.cpp +++ b/src/lua/LegacyLuaAPI.cpp @@ -1885,7 +1885,9 @@ int luatpt_setfire(lua_State* l) int luatpt_setdebug(lua_State* l) { - return luaL_error(l, "setdebug: Deprecated"); //TODO: maybe use the debugInfo thing in GameController to implement this + int debugFlags = luaL_optint(l, 1, 0); + luacon_controller->SetDebugFlags(debugFlags); + return 0; } int luatpt_setfpscap(lua_State* l) From 717408c9d04436e7924d0106d862b9095fc209ff Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 27 Sep 2014 23:27:41 -0400 Subject: [PATCH 6/6] also add back DebugParts --- src/debug/DebugLines.cpp | 8 ++--- src/debug/DebugLines.h | 6 ++-- src/debug/DebugParts.cpp | 55 +++++++++++++++++++++++++++++++++ src/debug/DebugParts.h | 13 ++++++++ src/gui/game/GameController.cpp | 4 ++- 5 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 src/debug/DebugParts.cpp create mode 100644 src/debug/DebugParts.h diff --git a/src/debug/DebugLines.cpp b/src/debug/DebugLines.cpp index 5174e8868..760c626c6 100644 --- a/src/debug/DebugLines.cpp +++ b/src/debug/DebugLines.cpp @@ -3,7 +3,7 @@ #include "gui/game/GameView.h" #include "gui/game/GameController.h" -LineDebug::LineDebug(unsigned int id, GameView * view, GameController * controller): +DebugLines::DebugLines(unsigned int id, GameView * view, GameController * controller): DebugInfo(id), view(view), controller(controller) @@ -11,7 +11,7 @@ LineDebug::LineDebug(unsigned int id, GameView * view, GameController * controll } -void LineDebug::Draw() +void DebugLines::Draw() { Graphics * g = ui::Engine::Ref().g; @@ -28,7 +28,7 @@ void LineDebug::Draw() g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120); g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120); - stringstream info; + std::stringstream info; info << drawPoint2.X << " x " << drawPoint2.Y; g->drawtext_outline(drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-g->textwidth(info.str().c_str())-3), drawPoint2.Y+(drawPoint2.Y + +DebugParts::DebugParts(unsigned int id, Simulation * sim): + DebugInfo(id), + sim(sim) +{ + +} + +void DebugParts::Draw() +{ + Graphics * g = ui::Engine::Ref().g; + + int x = 0, y = 0, lpx = 0, lpy = 0; + std::stringstream info; + info << sim->parts_lastActiveIndex << "/" << NPART << " (" << std::fixed << std::setprecision(2) << (float)sim->parts_lastActiveIndex/(NPART)*100.0f << "%)"; + for (int i = 0; i < NPART; i++) + { + if (sim->parts[i].type) + g->addpixel(x, y, 255, 255, 255, 180); + else + g->addpixel(x, y, 0, 0, 0, 180); + + if (i == sim->parts_lastActiveIndex) + { + lpx = x; + lpy = y; + } + x++; + if(x >= XRES) + { + y++; + x = 0; + } + } + g->draw_line(0, lpy, XRES, lpy, 0, 255, 120, 255); + g->draw_line(lpx, 0, lpx, YRES, 0, 255, 120, 255); + g->addpixel(lpx, lpy, 255, 50, 50, 220); + + g->addpixel(lpx+1, lpy, 255, 50, 50, 120); + g->addpixel(lpx-1, lpy, 255, 50, 50, 120); + g->addpixel(lpx, lpy+1, 255, 50, 50, 120); + g->addpixel(lpx, lpy-1, 255, 50, 50, 120); + + g->fillrect(7, YRES-26, g->textwidth(info.str().c_str())+5, 14, 0, 0, 0, 180); + g->drawtext(10, YRES-22, info.str().c_str(), 255, 255, 255, 255); +} + +DebugParts::~DebugParts() +{ + +} diff --git a/src/debug/DebugParts.h b/src/debug/DebugParts.h new file mode 100644 index 000000000..77cd6d8df --- /dev/null +++ b/src/debug/DebugParts.h @@ -0,0 +1,13 @@ +#pragma once + +#include "DebugInfo.h" + +class Simulation; +class DebugParts : public DebugInfo +{ + Simulation * sim; +public: + DebugParts(unsigned int id, Simulation * sim); + virtual void Draw(); + virtual ~DebugParts(); +}; diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 9cc750370..f4b37e3c2 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -26,6 +26,7 @@ #include "gui/interface/Keys.h" #include "simulation/Snapshot.h" #include "debug/DebugInfo.h" +#include "debug/DebugParts.h" #include "debug/ElementPopulation.h" #include "debug/DebugLines.h" #ifdef LUACONSOLE @@ -155,8 +156,9 @@ 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 LineDebug(0x4, gameView, this)); + debugInfo.push_back(new DebugLines(0x4, gameView, this)); } GameController::~GameController()