game/mario/editor_visitor.cpp
2021-05-02 14:14:11 +02:00

57 lines
1.4 KiB
C++

#include "editor_visitor.hpp"
#include "../sdlpp/sdlpp_renderobject.hpp"
#include "objectids.hpp"
#include "edit_box.hpp"
#define SELECTED_LEFT_MAP 0x00000001
#define SELECTED_RIGHT_MAP 0x00000002
#define SELECTED_LEFT_SELECT 0x00000004
#define SELECTED_RIGHT_SELECT 0x00000004
#define SELECTED_REMOVE_BLOCK 0x00000008
#define SELECTED_REMOVE_MODIFIER 0x00000010
void MouseVisitor::visit( const SDLPP::RenderObject &obj ) {
auto id = obj.getId();
switch ( id ) {
case EDITOR_LEFT_MAP_ID:
select_flags |= SELECTED_LEFT_MAP;
break;
case EDITOR_RIGHT_MAP_ID:
select_flags |= SELECTED_RIGHT_MAP;
break;
case EDITOR_EDIT_SQUARE:
edit_box = true;
edit_box_location = dynamic_cast<const EditBox&>(obj).getIndexes();
break;
default:
break;
}
}
bool MouseVisitor::moveMapLeft(uint64_t flags) {
return flags & SELECTED_LEFT_MAP;
}
bool MouseVisitor::moveMapRight(uint64_t flags) {
return flags & SELECTED_RIGHT_MAP;
}
void ToolVisitor::visit( const SDLPP::RenderObject &obj ) {
auto id = obj.getCollisions()[0]->getId();
switch ( id ) {
case EDITOR_TERRAIN_ID:
remove_block = true;
if(obj.getId() == source_id) {
add_block = false;
}
default:
break;
}
}
bool ToolVisitor::addBlock() {
return add_block;
}
bool ToolVisitor::removeBlock() {
return remove_block;
}