-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:simtr/The-Powder-Toy into develop
- Loading branch information
Showing
14 changed files
with
174 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters