Permalink
Browse files

Merge branch 'develop' of github.com:simtr/The-Powder-Toy into develop

  • Loading branch information...
jacksonmj committed Sep 28, 2014
2 parents ba31457 + 717408c commit 74dcd4074edb67e16cc293b788d9f2815038a256
@@ -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'])
@@ -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() {}
};
@@ -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.Y<drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
info.str("");
info << drawPoint1.X << " x " << drawPoint1.Y;
g->drawtext_outline(drawPoint1.X+(drawPoint2.X<drawPoint1.X?3:-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.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.X<drawPoint1.X?3:-g->textwidth(info.str().c_str())-2), (drawPoint1.Y+drawPoint2.Y)/2-3, info.str().c_str(), 255, 255, 255, 200);
}
}
DebugLines::~DebugLines()
{
}
@@ -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();
};
@@ -0,0 +1,55 @@
#include "DebugParts.h"
#include "gui/interface/Engine.h"
#include "simulation/Simulation.h"
#include <iomanip>
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()
{
}
@@ -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();
};
@@ -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;
@@ -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();
};
@@ -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<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
{
(*iter)->Draw(ui::Point(10, 10));
if ((*iter)->ID & debugFlags)
(*iter)->Draw();
}
commandInterface->OnTick();
}
@@ -46,6 +46,7 @@ class GameController: public ClientListener
OptionsController * options;
CommandInterface * commandInterface;
vector<DebugInfo*> 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<Menu*> GetMenuList();
Tool * GetActiveTool(int selection);
@@ -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);
@@ -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
@@ -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)
@@ -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;

0 comments on commit 74dcd40

Please sign in to comment.