|
| 1 | +#include "DebugLines.h" |
| 2 | +#include "gui/interface/Engine.h" |
| 3 | +#include "gui/game/GameView.h" |
| 4 | +#include "gui/game/GameController.h" |
| 5 | + |
| 6 | +LineDebug::LineDebug(GameView * view, GameController * controller): |
| 7 | + view(view), |
| 8 | + controller(controller) |
| 9 | +{ |
| 10 | + |
| 11 | +} |
| 12 | + |
| 13 | +void LineDebug::Draw() |
| 14 | +{ |
| 15 | + Graphics * g = ui::Engine::Ref().g; |
| 16 | + |
| 17 | + if (view->GetDrawingLine()) |
| 18 | + { |
| 19 | + ui::Point drawPoint1 = controller->PointTranslate(view->GetLineStartCoords()), drawPoint2 = controller->PointTranslate(view->GetLineFinishCoords()); |
| 20 | + if (view->GetDrawSnap()) |
| 21 | + drawPoint2 = view->lineSnapCoords(drawPoint1, drawPoint2); |
| 22 | + //g->draw_line(drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y, 255, 0, 255, 255); |
| 23 | + |
| 24 | + g->draw_line(0, drawPoint1.Y, XRES, drawPoint1.Y, 255, 255, 255, 120); |
| 25 | + g->draw_line(drawPoint1.X, 0, drawPoint1.X, YRES, 255, 255, 255, 120); |
| 26 | + |
| 27 | + g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120); |
| 28 | + g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120); |
| 29 | + |
| 30 | + stringstream info; |
| 31 | + info << drawPoint2.X << " x " << drawPoint2.Y; |
| 32 | + 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); |
| 33 | + |
| 34 | + info.str(""); |
| 35 | + info << drawPoint1.X << " x " << drawPoint1.Y; |
| 36 | + 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); |
| 37 | + |
| 38 | + info.str(""); |
| 39 | + info << std::abs(drawPoint2.X-drawPoint1.X); |
| 40 | + 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); |
| 41 | + |
| 42 | + info.str(""); |
| 43 | + info << std::abs(drawPoint2.Y-drawPoint1.Y); |
| 44 | + 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); |
| 45 | + } |
| 46 | + /*int yBottom = YRES-10; |
| 47 | + int xStart = 10; |
| 48 | +
|
| 49 | + std::string maxValString; |
| 50 | + std::string halfValString; |
| 51 | +
|
| 52 | +
|
| 53 | + float maxVal = 255; |
| 54 | + float scale = 1.0f; |
| 55 | + int bars = 0; |
| 56 | + for(int i = 0; i < PT_NUM; i++) |
| 57 | + { |
| 58 | + if(sim->elements[i].Enabled) |
| 59 | + { |
| 60 | + if(maxVal < sim->elementCount[i]) |
| 61 | + maxVal = sim->elementCount[i]; |
| 62 | + bars++; |
| 63 | + } |
| 64 | + } |
| 65 | + maxAverage = (maxAverage*(1.0f-0.015f)) + (0.015f*maxVal); |
| 66 | + scale = 255.0f/maxAverage; |
| 67 | +
|
| 68 | + maxValString = format::NumberToString<int>(maxAverage); |
| 69 | + halfValString = format::NumberToString<int>(maxAverage/2); |
| 70 | + |
| 71 | +
|
| 72 | + g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::textwidth(maxValString.c_str())+10, 255 + 13, 0, 0, 0, 180); |
| 73 | +
|
| 74 | + bars = 0; |
| 75 | + for(int i = 0; i < PT_NUM; i++) |
| 76 | + { |
| 77 | + if(sim->elements[i].Enabled) |
| 78 | + { |
| 79 | + float count = sim->elementCount[i]; |
| 80 | + int barSize = (count * scale - 0.5f); |
| 81 | + int barX = bars;//*2; |
| 82 | +
|
| 83 | + 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); |
| 84 | + if(sim->elementCount[i]) |
| 85 | + { |
| 86 | + if(barSize > 256) |
| 87 | + { |
| 88 | + barSize = 256; |
| 89 | + g->blendpixel(xStart+barX, yBottom-barSize-3, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); |
| 90 | + g->blendpixel(xStart+barX, yBottom-barSize-5, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); |
| 91 | + g->blendpixel(xStart+barX, yBottom-barSize-7, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), 255); |
| 92 | + } else { |
| 93 | +
|
| 94 | + g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180); |
| 95 | + } |
| 96 | + 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); |
| 97 | + } |
| 98 | + bars++; |
| 99 | + } |
| 100 | + } |
| 101 | +
|
| 102 | + g->drawtext(xStart + bars + 5, yBottom-5, "0", 255, 255, 255, 255); |
| 103 | + g->drawtext(xStart + bars + 5, yBottom-132, halfValString, 255, 255, 255, 255); |
| 104 | + g->drawtext(xStart + bars + 5, yBottom-260, maxValString, 255, 255, 255, 255);*/ |
| 105 | +} |
| 106 | + |
| 107 | +LineDebug::~LineDebug() |
| 108 | +{ |
| 109 | + |
| 110 | +} |
0 commit comments