mirror of
https://github.com/koloideal/SortLab.git
synced 2026-06-10 10:25:30 +03:00
skelet
This commit is contained in:
+6
-3
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -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_;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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_;
|
||||
|
||||
Reference in New Issue
Block a user