feat: added debug information toggle to UI
This commit is contained in:
parent
847c0bded5
commit
34a289d36b
|
|
@ -69,6 +69,7 @@ static void PrimaryControls() {
|
|||
if (!isSimulating) {
|
||||
elements::TextButton(CLAY_STRING("Randomize"), style::actionButton, &RandomizeFieldButton);
|
||||
}
|
||||
elements::Toggle(CLAY_STRING("Debug Info"), style::actionButton, simulation::drawDebugInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#include <vector>
|
||||
|
||||
namespace simulation {
|
||||
bool drawDebugInfo{ true };
|
||||
|
||||
static std::set<Cell> living{};
|
||||
static std::vector<Cell> overpopulated{};
|
||||
static std::vector<Cell> underpopulated{};
|
||||
|
|
@ -145,6 +147,9 @@ void Draw(SDL_Renderer *renderer, double cellSizePercent) {
|
|||
cellRect.y = (viewOffset.y + cell.y) * cellRect.h;
|
||||
SDL_RenderFillRect(renderer, &cellRect);
|
||||
}
|
||||
if (!drawDebugInfo) {
|
||||
return;
|
||||
}
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
for (Cell const &cell : overpopulated) {
|
||||
cellRect.x = (viewOffset.x + cell.x) * cellRect.w;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ public: CellRange(Cell begin, Cell end) : beginCell{ begin }, endCell{ end } {}
|
|||
CellIterator end() { return CellIterator{ beginCell, endCell, endCell }; }
|
||||
};
|
||||
|
||||
extern bool drawDebugInfo;
|
||||
|
||||
void InitializeRandom(size_t livingChance, int64_t fillArea);
|
||||
void Step();
|
||||
void Draw(SDL_Renderer *renderer, double cellSizePercent);
|
||||
|
|
|
|||
Loading…
Reference in a new issue