game/mario/editor_visitor.hpp

110 lines
2.8 KiB
C++
Raw Normal View History

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"
2021-05-31 12:03:11 +00:00
#include "blocks.hpp"
2022-06-21 12:52:36 +00:00
#include "gui/gui.hpp"
2021-05-02 12:14:11 +00:00
#include <memory>
2021-05-08 22:43:53 +00:00
struct VisitorType {
enum Value {
Terrain = 0xE001,
Modifier = 0xE002,
2021-08-08 19:22:00 +00:00
Character = 0xE003,
2021-05-08 22:43:53 +00:00
};
};
2021-05-02 12:14:11 +00:00
class MouseVisitor : public SDLPP::Visitor {
public:
2021-08-07 10:13:23 +00:00
MouseVisitor() = default;
2021-10-18 07:08:35 +00:00
void visit(const SDLPP::RenderObject &obj) override;
void setFromId(uint64_t /*UNUSED*/) override {}
2021-08-07 10:13:23 +00:00
uint64_t getFromId() const override {
2021-05-08 22:46:10 +00:00
return 0;
}
2021-08-07 10:13:23 +00:00
uint64_t getFlags() const {
2021-05-02 12:14:11 +00:00
return select_flags;
}
2021-08-07 10:13:23 +00:00
bool foundEditBox() const {
2021-05-02 12:14:11 +00:00
return edit_box;
}
2021-10-18 07:08:35 +00:00
const SDLPP::Vec2D<int> &getEditBoxIndexes() const {
2021-05-02 12:14:11 +00:00
return edit_box_location;
}
2021-08-07 10:13:23 +00:00
bool foundToolBox() const {
2021-05-07 07:43:57 +00:00
return tool_box;
}
2021-10-18 07:08:35 +00:00
const SDLPP::Vec2D<int> &getToolBoxIndexes() const {
2021-05-07 07:43:57 +00:00
return tool_box_location;
}
2021-10-18 07:08:35 +00:00
void setVisitorType(uint64_t type) override {
2021-05-02 12:14:11 +00:00
_type = type;
}
2021-08-07 10:13:23 +00:00
uint64_t getVisitorType() const override {
2021-05-02 12:14:11 +00:00
return _type;
}
2021-08-07 10:13:23 +00:00
uint64_t getToolType() const {
2021-05-28 17:51:02 +00:00
return tool_box_type;
}
2022-06-22 19:42:57 +00:00
uint64_t getCurButton() const {
2022-06-21 12:52:36 +00:00
return cur_button;
}
2021-05-02 12:14:11 +00:00
2021-10-18 07:08:35 +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);
static bool moveModsLeft(uint64_t flags);
static bool moveModsRight(uint64_t flags);
static bool moveCharactersLeft(uint64_t flags);
static bool moveCharactersRight(uint64_t flags);
2022-06-21 12:52:36 +00:00
static bool button(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-10-18 07:08:35 +00:00
SDLPP::Vec2D<int> edit_box_location = { -1, -1 };
SDLPP::Vec2D<int> tool_box_location = { -1, -1 };
2021-08-07 10:13:23 +00:00
uint64_t _type{};
2021-05-28 17:51:02 +00:00
uint64_t tool_box_type = 0;
2022-06-22 19:42:57 +00:00
uint64_t cur_button = -1;
2021-05-02 12:14:11 +00:00
};
class ToolVisitor : public SDLPP::Visitor {
public:
2021-08-07 10:13:23 +00:00
ToolVisitor() = default;
2021-10-18 07:08:35 +00:00
void visit(const SDLPP::RenderObject &obj) override;
void setFromId(uint64_t id) override {
2021-05-02 12:14:11 +00:00
source_id = id;
}
2021-08-07 10:13:23 +00:00
uint64_t getFromId() const override {
2021-05-02 12:14:11 +00:00
return source_id;
}
2021-10-18 07:08:35 +00:00
void setVisitorType(uint64_t type) override {
2021-05-02 12:14:11 +00:00
_type = type;
}
2021-08-07 10:13:23 +00:00
uint64_t getVisitorType() const override {
2021-05-02 12:14:11 +00:00
return _type;
}
2021-05-31 12:03:11 +00:00
void setSourceType(LandType::Value type) {
source_type = type;
}
2021-08-07 10:13:23 +00:00
void setSourceData(const uint64_t &data) {
_data = data;
}
bool addBlock() const;
bool removeBlock() const;
2021-05-02 12:14:11 +00:00
private:
bool remove_block = false;
bool add_block = true;
uint64_t source_id = 0;
uint64_t _type = 0;
2021-08-07 10:13:23 +00:00
uint64_t _data = 0;
LandType::Value source_type{};
2021-05-02 12:14:11 +00:00
};
#endif