This commit is contained in:
2026-03-03 21:14:39 +03:00
parent bf8e3bad6f
commit ff28dbb2f5
9 changed files with 376 additions and 58 deletions
+6 -3
View File
@@ -6,6 +6,7 @@
#include "Sorter.hpp"
#include "UI.hpp"
#include "OperationsHistory.hpp"
#include "ProgressMap.hpp"
class App {
public:
@@ -16,7 +17,7 @@ private:
void handleEvents();
void update(float dt);
void render();
void renderHistogram();
void renderDeltaHistogram();
void switchSorter(std::unique_ptr<Sorter> newSorter);
void generateBeepSound();
void playBeep(float pitch);
@@ -26,6 +27,7 @@ private:
std::unique_ptr<Sorter> currentSorter_;
UI ui_;
OperationsHistory opsHistory_;
ProgressMap progressMap_;
bool isPlaying_;
float timeSinceLastStep_;
int stepsPerFrame_;
@@ -41,6 +43,7 @@ private:
size_t lastComparisons_;
size_t lastSwaps_;
sf::Font histogramFont_;
bool histogramFontLoaded_;
sf::Font bottomPanelFont_;
bool bottomPanelFontLoaded_;
bool showInfo_;
};
+6 -5
View File
@@ -4,14 +4,15 @@
class OperationsHistory {
public:
OperationsHistory(size_t maxSamples = 300);
OperationsHistory(size_t maxSamples = 400);
void record(size_t comparisons);
void record(size_t currentComparisons);
void reset();
const std::deque<size_t>& getHistory() const;
size_t getMaxValue() const;
const std::deque<size_t>& getDeltaHistory() const;
size_t getMaxDelta() const;
private:
std::deque<size_t> compareHistory_;
std::deque<size_t> deltaHistory_;
size_t maxSamples_;
size_t lastComparisons_;
};
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include <SFML/Graphics.hpp>
#include "Array.hpp"
class ProgressMap {
public:
ProgressMap();
void draw(sf::RenderWindow& window, const Array& array, sf::Font& font, bool fontLoaded);
private:
sf::Color getColorForState(Array::State state) const;
};
+1
View File
@@ -9,6 +9,7 @@ public:
void update(const Sorter& sorter, bool isPlaying, bool isFinished, int stepsPerFrame, const Array& array);
void draw(sf::RenderWindow& window);
void drawInfoOverlay(sf::RenderWindow& window);
private:
sf::Font font_;