Permalink
Browse files

also add back DebugParts

  • Loading branch information...
jacob1 committed Sep 28, 2014
1 parent 32328ad commit 717408c9d04436e7924d0106d862b9095fc209ff
Showing with 78 additions and 8 deletions.
  1. +4 −4 src/debug/DebugLines.cpp
  2. +3 −3 src/debug/DebugLines.h
  3. +55 −0 src/debug/DebugParts.cpp
  4. +13 −0 src/debug/DebugParts.h
  5. +3 −1 src/gui/game/GameController.cpp
@@ -3,15 +3,15 @@
#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)
{
}
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<drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
@@ -46,7 +46,7 @@ void LineDebug::Draw()
}
}
LineDebug::~LineDebug()
DebugLines::~DebugLines()
{
}
@@ -4,12 +4,12 @@
class GameView;
class GameController;
class LineDebug : public DebugInfo
class DebugLines : public DebugInfo
{
GameView * view;
GameController * controller;
public:
LineDebug(unsigned int id, GameView * view, GameController * controller);
DebugLines(unsigned int id, GameView * view, GameController * controller);
virtual void Draw();
virtual ~LineDebug();
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();
};
@@ -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()

0 comments on commit 717408c

Please sign in to comment.