Permalink
Browse files

new DebugInfo thing: the old debug lines

  • Loading branch information...
jacob1 committed Sep 28, 2014
1 parent 6beafc3 commit 507ba35ce089da17d75549c3907e0512f6b8fc29
@@ -5,5 +5,5 @@
class DebugInfo
{
public:
virtual void Draw(ui::Point position) {}
virtual void Draw() {}
};
@@ -0,0 +1,110 @@
#include "DebugLines.h"
#include "gui/interface/Engine.h"
#include "gui/game/GameView.h"
#include "gui/game/GameController.h"
LineDebug::LineDebug(GameView * view, GameController * controller):
view(view),
controller(controller)
{
}
void LineDebug::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);
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);
}
/*int yBottom = YRES-10;
int xStart = 10;
std::string maxValString;
std::string halfValString;
float maxVal = 255;
float scale = 1.0f;
int bars = 0;
for(int i = 0; i < PT_NUM; i++)
{
if(sim->elements[i].Enabled)
{
if(maxVal < sim->elementCount[i])
maxVal = sim->elementCount[i];
bars++;
}
}
maxAverage = (maxAverage*(1.0f-0.015f)) + (0.015f*maxVal);
scale = 255.0f/maxAverage;
maxValString = format::NumberToString<int>(maxAverage);
halfValString = format::NumberToString<int>(maxAverage/2);
g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180);
bars = 0;
for(int i = 0; i < PT_NUM; i++)
{
if(sim->elements[i].Enabled)
{
float count = sim->elementCount[i];
int barSize = (count * scale - 0.5f);
int barX = bars;//*2;
g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
if(sim->elementCount[i])
{
if(barSize > 256)
{
barSize = 256;
g->blendpixel(xStart+barX, yBottom-barSize-3, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
g->blendpixel(xStart+barX, yBottom-barSize-5, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
g->blendpixel(xStart+barX, yBottom-barSize-7, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
} else {
g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180);
}
g->draw_line(xStart+barX, yBottom-barSize, xStart+barX, yBottom, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255);
}
bars++;
}
}
g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255);
g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255);
g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255);*/
}
LineDebug::~LineDebug()
{
}
@@ -0,0 +1,15 @@
#pragma once
#include "DebugInfo.h"
class GameView;
class GameController;
class LineDebug : public DebugInfo
{
GameView * view;
GameController * controller;
public:
LineDebug(GameView * view, GameController * controller);
virtual void Draw();
virtual ~LineDebug();
};
@@ -10,10 +10,9 @@ ElementPopulationDebug::ElementPopulationDebug(Simulation * sim):
}
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;
@@ -9,6 +9,6 @@ class ElementPopulationDebug : public DebugInfo
float maxAverage;
public:
ElementPopulationDebug(Simulation * sim);
virtual void Draw(ui::Point position);
virtual void Draw();
virtual ~ElementPopulationDebug();
};
@@ -26,12 +26,13 @@
#include "gui/interface/Keys.h"
#include "simulation/Snapshot.h"
#include "debug/DebugInfo.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;
@@ -156,6 +157,7 @@ GameController::GameController():
Client::Ref().AddListener(this);
//debugInfo.push_back(new ElementPopulationDebug(gameModel->GetSimulation()));
//debugInfo.push_back(new LineDebug(gameView, this));
}
GameController::~GameController()
@@ -741,7 +743,7 @@ void GameController::Tick()
}
for(std::vector<DebugInfo*>::iterator iter = debugInfo.begin(), end = debugInfo.end(); iter != end; iter++)
{
(*iter)->Draw(ui::Point(10, 10));
(*iter)->Draw();
}
commandInterface->OnTick();
}
@@ -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);

0 comments on commit 507ba35

Please sign in to comment.