diff --git a/SConscript b/SConscript index fd08935c2b..c44cb4f274 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']) diff --git a/src/debug/DebugInfo.h b/src/debug/DebugInfo.h index 4cdfedc38f..9266b87fe7 100644 --- a/src/debug/DebugInfo.h +++ b/src/debug/DebugInfo.h @@ -5,5 +5,7 @@ class DebugInfo { public: - virtual void Draw(ui::Point position) {} + DebugInfo(unsigned int id):ID(id) { } + unsigned int ID; + virtual void Draw() {} }; diff --git a/src/debug/DebugLines.cpp b/src/debug/DebugLines.cpp new file mode 100644 index 0000000000..760c626c63 --- /dev/null +++ b/src/debug/DebugLines.cpp @@ -0,0 +1,52 @@ +#include "DebugLines.h" +#include "gui/interface/Engine.h" +#include "gui/game/GameView.h" +#include "gui/game/GameController.h" + +DebugLines::DebugLines(unsigned int id, GameView * view, GameController * controller): + DebugInfo(id), + view(view), + controller(controller) +{ + +} + +void DebugLines::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); + + 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.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); + } +} + +DebugLines::~DebugLines() +{ + +} diff --git a/src/debug/DebugLines.h b/src/debug/DebugLines.h new file mode 100644 index 0000000000..c835aa36d4 --- /dev/null +++ b/src/debug/DebugLines.h @@ -0,0 +1,15 @@ +#pragma once + +#include "DebugInfo.h" + +class GameView; +class GameController; +class DebugLines : public DebugInfo +{ + GameView * view; + GameController * controller; +public: + DebugLines(unsigned int id, GameView * view, GameController * controller); + virtual void Draw(); + virtual ~DebugLines(); +}; diff --git a/src/debug/DebugParts.cpp b/src/debug/DebugParts.cpp new file mode 100644 index 0000000000..c94efb17f8 --- /dev/null +++ b/src/debug/DebugParts.cpp @@ -0,0 +1,55 @@ +#include "DebugParts.h" +#include "gui/interface/Engine.h" +#include "simulation/Simulation.h" +#include + +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 0000000000..77cd6d8df4 --- /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/debug/ElementPopulation.cpp b/src/debug/ElementPopulation.cpp index 33994a7452..1cfd9c5d83 100644 --- a/src/debug/ElementPopulation.cpp +++ b/src/debug/ElementPopulation.cpp @@ -3,17 +3,17 @@ #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) { } -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 a1a2093171..64de0674f1 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); - virtual void Draw(ui::Point position); + 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 43f0396644..f4b37e3c29 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -26,12 +26,14 @@ #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 #include "lua/LuaScriptInterface.h" #else #include "lua/TPTScriptInterface.h" #endif -//#include "debug/ElementPopulation.h" using namespace std; @@ -152,10 +154,11 @@ 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 DebugParts(0x1, gameModel->GetSimulation())); + debugInfo.push_back(new ElementPopulationDebug(0x2, gameModel->GetSimulation())); + debugInfo.push_back(new DebugLines(0x4, gameView, this)); } GameController::~GameController() @@ -741,7 +744,8 @@ void GameController::Tick() } for(std::vector::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++) { - (*iter)->Draw(ui::Point(10, 10)); + if ((*iter)->ID & debugFlags) + (*iter)->Draw(); } commandInterface->OnTick(); } diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index a7cdfc94b0..c436c9dadc 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -46,6 +46,7 @@ class GameController: public ClientListener OptionsController * options; CommandInterface * commandInterface; vector debugInfo; + unsigned int debugFlags; public: bool HasDone; class SearchCallback; @@ -101,6 +102,7 @@ class GameController: public ClientListener 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/gui/game/GameView.h b/src/gui/game/GameView.h index 90fae7db25..acbe0e03e0 100644 --- a/src/gui/game/GameView.h +++ b/src/gui/game/GameView.h @@ -113,8 +113,6 @@ class GameView: public ui::Window 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 @@ class GameView: public ui::Window 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); diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index dd2bf5a326..46684a696f 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 diff --git a/src/lua/LegacyLuaAPI.cpp b/src/lua/LegacyLuaAPI.cpp index ca67c89192..17fd59453a 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) diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index daf354b17a..3e24c1b767 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;