2021-05-02 12:14:11 +00:00
|
|
|
#ifndef EDITOR_VISITOR_H
|
|
|
|
#define EDITOR_VISITOR_H
|
|
|
|
|
|
|
|
#include "../sdlpp/sdlpp_visitor.hpp"
|
|
|
|
#include "../sdlpp/sdlpp_geometry.hpp"
|
|
|
|
#include <memory>
|
|
|
|
|
2021-05-08 22:43:53 +00:00
|
|
|
struct VisitorType {
|
|
|
|
enum Value {
|
|
|
|
Terrain = 0xE001,
|
|
|
|
Modifier = 0xE002,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-02 12:14:11 +00:00
|
|
|
class MouseVisitor : public SDLPP::Visitor {
|
|
|
|
public:
|
|
|
|
MouseVisitor() {}
|
|
|
|
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
|
|
|
virtual void setFromId( uint64_t /*UNUSED*/ ) override {}
|
2021-05-08 22:46:10 +00:00
|
|
|
virtual uint64_t getFromId() override {
|
|
|
|
return 0;
|
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
uint64_t getFlags() {
|
|
|
|
return select_flags;
|
|
|
|
}
|
|
|
|
bool foundEditBox() {
|
|
|
|
return edit_box;
|
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
const SDLPP::Vec2D< int > &getEditBoxIndexes() {
|
2021-05-02 12:14:11 +00:00
|
|
|
return edit_box_location;
|
|
|
|
}
|
2021-05-07 07:43:57 +00:00
|
|
|
bool foundToolBox() {
|
|
|
|
return tool_box;
|
|
|
|
}
|
2021-05-08 22:46:10 +00:00
|
|
|
const SDLPP::Vec2D< int > &getToolBoxIndexes() {
|
2021-05-07 07:43:57 +00:00
|
|
|
return tool_box_location;
|
|
|
|
}
|
2021-05-02 12:14:11 +00:00
|
|
|
virtual void setVisitorType( uint64_t type ) override {
|
|
|
|
_type = type;
|
|
|
|
}
|
|
|
|
virtual uint64_t getVisitorType() override {
|
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
|
2021-05-08 22:46:10 +00:00
|
|
|
static bool moveMapLeft( uint64_t flags );
|
|
|
|
static bool moveMapRight( uint64_t flags );
|
|
|
|
static bool moveToolsLeft( uint64_t flags );
|
|
|
|
static bool moveToolsRight( uint64_t flags );
|
2021-05-02 12:14:11 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t select_flags = 0;
|
|
|
|
bool edit_box = false;
|
2021-05-07 07:43:57 +00:00
|
|
|
bool tool_box = false;
|
2021-05-08 22:46:10 +00:00
|
|
|
SDLPP::Vec2D< int > edit_box_location = { -1, -1 };
|
|
|
|
SDLPP::Vec2D< int > tool_box_location = { -1, -1 };
|
2021-05-02 12:14:11 +00:00
|
|
|
uint64_t _type;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ToolVisitor : public SDLPP::Visitor {
|
|
|
|
public:
|
2021-05-08 22:46:10 +00:00
|
|
|
ToolVisitor(){};
|
2021-05-02 12:14:11 +00:00
|
|
|
virtual void visit( const SDLPP::RenderObject &obj ) override;
|
|
|
|
virtual void setFromId( uint64_t id ) override {
|
|
|
|
source_id = id;
|
|
|
|
}
|
|
|
|
virtual uint64_t getFromId() override {
|
|
|
|
return source_id;
|
|
|
|
}
|
|
|
|
virtual void setVisitorType( uint64_t type ) override {
|
|
|
|
_type = type;
|
|
|
|
}
|
|
|
|
virtual uint64_t getVisitorType() override {
|
|
|
|
return _type;
|
|
|
|
}
|
|
|
|
bool addBlock();
|
|
|
|
bool removeBlock();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool remove_block = false;
|
|
|
|
bool add_block = true;
|
|
|
|
uint64_t source_id = 0;
|
|
|
|
uint64_t _type = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|