Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:simtr/The-Powder-Toy into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonmj committed Sep 28, 2014
2 parents ba31457 + 717408c commit 74dcd40
Show file tree
Hide file tree
Showing 14 changed files with 174 additions and 19 deletions.
12 changes: 8 additions & 4 deletions SConscript
Expand Up @@ -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']})
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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'])
Expand Down
4 changes: 3 additions & 1 deletion src/debug/DebugInfo.h
Expand Up @@ -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() {}
};
52 changes: 52 additions & 0 deletions 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.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()
{

}
15 changes: 15 additions & 0 deletions 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();
};
55 changes: 55 additions & 0 deletions src/debug/DebugParts.cpp
@@ -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()
{

}
13 changes: 13 additions & 0 deletions 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();
};
6 changes: 3 additions & 3 deletions src/debug/ElementPopulation.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/debug/ElementPopulation.h
Expand Up @@ -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();
};
12 changes: 8 additions & 4 deletions src/gui/game/GameController.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/game/GameController.h
Expand Up @@ -46,6 +46,7 @@ class GameController: public ClientListener
OptionsController * options;
CommandInterface * commandInterface;
vector<DebugInfo*> debugInfo;
unsigned int debugFlags;
public:
bool HasDone;
class SearchCallback;
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions src/gui/game/GameView.h
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/options/OptionsView.cpp
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/lua/LegacyLuaAPI.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/PIPE.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 74dcd40

Please sign in to comment.