2020-07-21 11:34:39 +00:00
|
|
|
#ifndef TRIANGLES_STATE_HPP
|
|
|
|
#define TRIANGLES_STATE_HPP
|
|
|
|
|
|
|
|
#include <bitset>
|
2020-07-21 11:44:10 +00:00
|
|
|
#include <vector>
|
2020-07-22 09:19:34 +00:00
|
|
|
#include <array>
|
2020-07-21 11:34:39 +00:00
|
|
|
|
|
|
|
#include <SFML/System.hpp>
|
2020-07-21 11:44:10 +00:00
|
|
|
#include <SFML/Graphics.hpp>
|
2020-07-21 11:34:39 +00:00
|
|
|
|
|
|
|
namespace Tri {
|
2020-07-22 06:19:37 +00:00
|
|
|
class State {
|
|
|
|
public:
|
|
|
|
State(int argc, char **argv);
|
2020-07-22 06:11:10 +00:00
|
|
|
~State();
|
2020-07-22 07:12:21 +00:00
|
|
|
|
|
|
|
enum CurrentState {NONE = 0, FIRST = 1, SECOND = 2};
|
|
|
|
private:
|
2020-07-21 11:34:39 +00:00
|
|
|
/*
|
|
|
|
* 0 - display help
|
2020-07-22 06:19:37 +00:00
|
|
|
* 1 - is running
|
2020-07-22 07:26:57 +00:00
|
|
|
* 2 - display color picker
|
|
|
|
* 3 - color picker color dirty
|
2020-07-22 08:46:20 +00:00
|
|
|
* 4 - bg color picker color dirty
|
|
|
|
* 5 - display bg color picker
|
2020-07-22 09:19:34 +00:00
|
|
|
* 6 - draw save
|
2020-07-21 11:34:39 +00:00
|
|
|
*/
|
2020-07-22 06:19:37 +00:00
|
|
|
typedef std::bitset<64> BitsetType;
|
|
|
|
BitsetType flags;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
2020-07-21 11:34:39 +00:00
|
|
|
const sf::Time dt;
|
2020-07-22 07:12:21 +00:00
|
|
|
float starting_help_alpha;
|
2020-07-21 11:34:39 +00:00
|
|
|
|
2020-07-22 06:11:10 +00:00
|
|
|
sf::RenderWindow window;
|
2020-07-21 11:44:10 +00:00
|
|
|
std::vector<sf::ConvexShape> tris;
|
2020-07-22 06:33:09 +00:00
|
|
|
unsigned int trisIndex;
|
2020-07-22 06:28:36 +00:00
|
|
|
sf::Vector2f currentTri[3];
|
2020-07-22 07:12:21 +00:00
|
|
|
CurrentState currentTri_state;
|
|
|
|
CurrentState currentTri_maxState;
|
2020-07-22 06:28:36 +00:00
|
|
|
sf::CircleShape pointCircle;
|
2020-07-21 11:44:10 +00:00
|
|
|
|
2020-07-22 06:11:10 +00:00
|
|
|
sf::Event event;
|
|
|
|
|
2020-07-22 07:26:57 +00:00
|
|
|
float colorPickerColor[4];
|
2020-07-22 08:46:20 +00:00
|
|
|
float bgColorPickerColor[3];
|
|
|
|
sf::Color bgColor;
|
2020-07-22 07:26:57 +00:00
|
|
|
|
2020-07-22 09:19:34 +00:00
|
|
|
typedef std::array<char, 256> FilenameBufferType;
|
|
|
|
FilenameBufferType saveFilenameBuffer;
|
|
|
|
std::string failedSaveMessage;
|
|
|
|
|
2020-07-22 06:19:37 +00:00
|
|
|
public:
|
2020-07-22 06:11:10 +00:00
|
|
|
void handle_events();
|
2020-07-21 11:34:39 +00:00
|
|
|
void update();
|
|
|
|
void draw();
|
2020-07-22 06:19:37 +00:00
|
|
|
|
2020-07-22 09:19:34 +00:00
|
|
|
private:
|
|
|
|
void draw_to_target(sf::RenderTarget *target, bool draw_points = true);
|
|
|
|
|
|
|
|
public:
|
2020-07-22 07:12:21 +00:00
|
|
|
unsigned int get_width() const;
|
|
|
|
unsigned int get_height() const;
|
2020-07-22 06:19:37 +00:00
|
|
|
|
|
|
|
const BitsetType get_flags() const;
|
2020-07-22 07:12:21 +00:00
|
|
|
|
|
|
|
float get_starting_help_alpha() const;
|
2020-07-22 07:26:57 +00:00
|
|
|
|
|
|
|
float* get_color();
|
2020-07-22 08:46:20 +00:00
|
|
|
float* get_bg_color();
|
2020-07-22 09:19:34 +00:00
|
|
|
|
|
|
|
FilenameBufferType* get_save_filename_buffer();
|
|
|
|
bool do_save();
|
|
|
|
std::string_view failed_save_message() const;
|
|
|
|
void close_save();
|
2020-07-21 11:34:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|