also add back DebugParts

This commit is contained in:
jacob1 2014-09-27 23:27:41 -04:00
parent 32328ad4fe
commit 717408c9d0
5 changed files with 78 additions and 8 deletions

View File

@ -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<drawPoint1.Y?-10:3), info.str().c_str(), 255, 255, 255, 200);
@ -46,7 +46,7 @@ void LineDebug::Draw()
}
}
LineDebug::~LineDebug()
DebugLines::~DebugLines()
{
}

View File

@ -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();
};

55
src/debug/DebugParts.cpp Normal file
View File

@ -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
src/debug/DebugParts.h Normal file
View File

@ -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();
};

View File

@ -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()