100 lines
3.9 KiB
C++
100 lines
3.9 KiB
C++
#ifndef BASEVISUALIZER_H
|
|
#define BASEVISUALIZER_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <cmath>
|
|
#include <iostream>
|
|
|
|
enum Colors {
|
|
BLACK = 0, RED = 1, GREEN = 2, YELLOW = 3, BLUE = 4, MAGENTA = 5, CYAN = 6, WHITE = 7,
|
|
LIGHT_BLACK = 10, LIGHT_RED = 11, LIGHT_GREEN = 12, LIGHT_YELLOW = 13, LIGHT_BLUE = 14,
|
|
LIGHT_MAGENTA = 15, LIGHT_CYAN = 16, LIGHT_WHITE = 17, DEFAULT = 9
|
|
};
|
|
|
|
class BaseVisualizer {
|
|
protected:
|
|
inline static const std::string TOP_LEFT_CORNER = "\u2554";
|
|
inline static const std::string TOP_RIGHT_CORNER = "\u2557";
|
|
inline static const std::string HORIZONTAL_LINE = "\u2550";
|
|
inline static const std::string VERTICAL_LINE = "\u2551";
|
|
inline static const std::string BOTTOM_LEFT_CORNER = "\u255A";
|
|
inline static const std::string BOTTOM_RIGHT_CORNER = "\u255D";
|
|
inline static const std::string RIGHT_CROSS = "\u2560";
|
|
inline static const std::string LEFT_CROSS = "\u2563";
|
|
inline static const std::string CROSS = "\u256C";
|
|
inline static const std::string TOP_CROSS = "\u2566";
|
|
inline static const std::string BOTTOM_CROSS = "\u2569";
|
|
|
|
inline static const std::string TOP_LEFT_CORNER_SINGLE = "\u250C";
|
|
inline static const std::string TOP_RIGHT_CORNER_SINGLE = "\u2510";
|
|
inline static const std::string HORIZONTAL_LINE_SINGLE = "\u2500";
|
|
inline static const std::string VERTICAL_LINE_SINGLE = "\u2502";
|
|
inline static const std::string BOTTOM_LEFT_CORNER_SINGLE = "\u2514";
|
|
inline static const std::string BOTTOM_RIGHT_CORNER_SINGLE = "\u2518";
|
|
inline static const std::string RIGHT_CROSS_SINGLE = "\u251C";
|
|
inline static const std::string LEFT_CROSS_SINGLE = "\u2524";
|
|
inline static const std::string CROSS_SINGLE = "\u253C";
|
|
inline static const std::string TOP_CROSS_SINGLE = "\u252C";
|
|
inline static const std::string BOTTOM_CROSS_SINGLE = "\u2534";
|
|
|
|
const size_t MAX_MENU_WIDTH;
|
|
const size_t PADDING;
|
|
|
|
std::vector<std::vector<std::string>> display_vector;
|
|
|
|
void GenerateEmptyLine(const int lengthOfMenu, const bool single);
|
|
void GenerateBoxMenuLine(const size_t length, const std::string& str, const bool single, const size_t padding);
|
|
void GenerateCenteredString(const size_t widthOfMenu, const std::string& str, const bool single);
|
|
size_t CalculateMaxMenuWidth(const size_t longestStringLength, const size_t padding);
|
|
size_t FindMaxLength(const std::vector<std::string> vec);
|
|
void GenerateTopBottomBorder(const size_t totalLength, const bool top, const bool single);
|
|
void AddEmptyLines(const size_t lines, const size_t length, const bool sinlge);
|
|
void GenerateTableTopBottom(const size_t totalLength, const bool top, const bool single);
|
|
void GenerateTableLine(const float length, const std::vector<std::string>& str, const bool single);
|
|
void GenerateTableSeperator(const float length, const bool single);
|
|
void GenerateBoxSeperator(const float length, const bool single);
|
|
void SetConsoleColor(Colors foreground, Colors background);
|
|
|
|
static size_t GetSumAllCharsFromVector(const std::vector<std::string>& vec);
|
|
static size_t CountVisibleCharacters(const std::string& str);
|
|
|
|
private:
|
|
virtual void GenerateElement() = 0;
|
|
|
|
public:
|
|
virtual ~BaseVisualizer() = default;
|
|
static void ClearTerminal();
|
|
void DisplayElement();
|
|
std::vector<std::vector<std::string>>* GetDisplayVector();
|
|
BaseVisualizer(size_t longestStringLength, size_t padding) : MAX_MENU_WIDTH(BaseVisualizer::CalculateMaxMenuWidth(longestStringLength, padding)), PADDING(padding) {}
|
|
};
|
|
|
|
#endif //BASEVISUALIZER_H
|
|
|
|
/**
|
|
*
|
|
ChessboardVisualizer.cpp
|
|
HistorieVisualizer.cpp
|
|
CommandVisualizer.cpp
|
|
|
|
PlayVisualizer.cpp {
|
|
ChessboardVisualizer.display_vector
|
|
|
|
|
|
HistorieVisualizer.display_vector;
|
|
|
|
CommandVisualizer.display_vector;
|
|
|
|
st::cout << ChessboardVisualizer.display_vector[i] (isEmpty) ? << std:endl : << Padding << Menus.display_vector[i] << std:endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|