mirror of
https://github.com/koloideal/SortLab.git
synced 2026-06-10 10:25:30 +03:00
skelet
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "UI.hpp"
|
||||
#include "OperationsHistory.hpp"
|
||||
#include "ProgressMap.hpp"
|
||||
#include "SortHistory.hpp"
|
||||
|
||||
class App {
|
||||
public:
|
||||
@@ -46,4 +47,8 @@ private:
|
||||
sf::Font bottomPanelFont_;
|
||||
bool bottomPanelFontLoaded_;
|
||||
bool showInfo_;
|
||||
|
||||
SortHistory history_;
|
||||
sf::Clock sortTimer_;
|
||||
bool recordedThisRun_;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
struct SortRecord {
|
||||
std::string algorithmName;
|
||||
int arraySize;
|
||||
int comparisons;
|
||||
int swaps;
|
||||
float normalizedTime;
|
||||
float relativeSpeed;
|
||||
|
||||
SortRecord() : arraySize(0), comparisons(0), swaps(0), normalizedTime(0.0f), relativeSpeed(1.0f) {}
|
||||
};
|
||||
|
||||
class SortHistory {
|
||||
public:
|
||||
SortHistory();
|
||||
|
||||
void add(const SortRecord& record);
|
||||
const std::deque<SortRecord>& getRecords() const;
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::deque<SortRecord> records_;
|
||||
static const size_t MAX_RECORDS = 20;
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "Sorter.hpp"
|
||||
#include "SortHistory.hpp"
|
||||
#include <string>
|
||||
|
||||
class UI {
|
||||
@@ -10,6 +11,10 @@ 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);
|
||||
void drawHistoryOverlay(sf::RenderWindow& window, const SortHistory& history);
|
||||
void toggleHistory();
|
||||
void closeHistory();
|
||||
bool isHistoryOpen() const;
|
||||
|
||||
private:
|
||||
sf::Font font_;
|
||||
@@ -24,4 +29,5 @@ private:
|
||||
sf::RectangleShape leftBackground_;
|
||||
sf::RectangleShape rightBackground_;
|
||||
bool fontLoaded_;
|
||||
bool historyOpen_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user