From f732cdaf7374fde737b503ec6966fb8cd8f4c32b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 17 Mar 2015 23:53:55 -0400 Subject: Map editor can now define actions to occur when the player goes off a specified edge of the map --- tools/mapedit/src/map.cpp | 216 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 180 insertions(+), 36 deletions(-) (limited to 'tools/mapedit/src/map.cpp') diff --git a/tools/mapedit/src/map.cpp b/tools/mapedit/src/map.cpp index 0db7031..fb675e8 100644 --- a/tools/mapedit/src/map.cpp +++ b/tools/mapedit/src/map.cpp @@ -1,5 +1,8 @@ #include "map.h" #include "frame.h" +#include "object.h" +#include "world.h" +#include "consts.h" Map::Map(int id, World* world) : id(id), world(world) { @@ -13,13 +16,19 @@ Map::Map(const Map& map) id = map.id; title = map.title; - leftmap = map.leftmap; - rightmap = map.rightmap; objects = map.objects; world = map.world; treeItemId = map.treeItemId; children = map.children; hidden = map.hidden; + leftType = map.leftType; + rightType = map.rightType; + upType = map.upType; + downType = map.downType; + leftMap = map.leftMap; + rightMap = map.rightMap; + downMap = map.downMap; + upMap = map.upMap; } Map::Map(Map&& map) : Map(-1, map.world) @@ -43,14 +52,67 @@ void swap(Map& first, Map& second) { std::swap(first.mapdata, second.mapdata); std::swap(first.title, second.title); - std::swap(first.leftmap, second.leftmap); - std::swap(first.rightmap, second.rightmap); std::swap(first.objects, second.objects); std::swap(first.id, second.id); std::swap(first.world, second.world); std::swap(first.treeItemId, second.treeItemId); std::swap(first.children, second.children); std::swap(first.hidden, second.hidden); + std::swap(first.leftType, second.leftType); + std::swap(first.rightType, second.rightType); + std::swap(first.upType, second.upType); + std::swap(first.downType, second.downType); + std::swap(first.leftMap, second.leftMap); + std::swap(first.rightMap, second.rightMap); + std::swap(first.downMap, second.downMap); + std::swap(first.upMap, second.upMap); +} + +std::list Map::listMoveTypes() +{ + return {MoveType::Wall, MoveType::Wrap, MoveType::Warp, MoveType::ReverseWarp}; +} + +std::string Map::stringForMoveType(MoveType type) +{ + switch (type) + { + case MoveType::Wall: return "Wall"; + case MoveType::Warp: return "Warp"; + case MoveType::Wrap: return "Wrap"; + case MoveType::ReverseWarp: return "Reverse Warp"; + } +} + +bool Map::moveTypeTakesMap(MoveType type) +{ + switch (type) + { + case MoveType::Wall: return false; + case MoveType::Wrap: return false; + case MoveType::Warp: return true; + case MoveType::ReverseWarp: return true; + } +} + +std::string Map::shortForMoveType(MoveType type) +{ + switch (type) + { + case MoveType::Wall: return "wall"; + case MoveType::Wrap: return "wrap"; + case MoveType::Warp: return "warp"; + case MoveType::ReverseWarp: return "reverseWarp"; + } +} + +Map::MoveType Map::moveTypeForShort(std::string str) +{ + if (str == "wrap") return MoveType::Wrap; + if (str == "warp") return MoveType::Warp; + if (str == "reverseWarp") return MoveType::ReverseWarp; + + return MoveType::Wall; } int Map::getID() const @@ -73,26 +135,6 @@ const std::list>& Map::getObjects() const return objects; } -std::shared_ptr Map::getLeftmap() const -{ - if (leftmap == -1) - { - return std::shared_ptr(); - } else { - return world->getMap(leftmap); - } -} - -std::shared_ptr Map::getRightmap() const -{ - if (rightmap == -1) - { - return std::shared_ptr(); - } else { - return world->getMap(rightmap); - } -} - wxTreeItemId Map::getTreeItemId() const { return treeItemId; @@ -125,6 +167,47 @@ bool Map::getHidden() const return hidden; } +Map::MoveType Map::getLeftMoveType() const +{ + return leftType; +} + +Map::MoveType Map::getRightMoveType() const +{ + return rightType; +} + +Map::MoveType Map::getUpMoveType() const +{ + return upType; +} + +Map::MoveType Map::getDownMoveType() const +{ + return downType; +} + +int Map::getLeftMoveMapID() const +{ + return leftMap; +} + +int Map::getRightMoveMapID() const +{ + return rightMap; +} + +int Map::getUpMoveMapID() const +{ + return upMap; +} + +int Map::getDownMoveMapID() const +{ + return downMap; +} + + void Map::setTitle(std::string title, bool dirty) { this->title = title; @@ -176,9 +259,39 @@ void Map::removeObject(std::shared_ptr obj, bool dirty) } } -void Map::setLeftmap(int id, bool dirty) +void Map::setTreeItemId(wxTreeItemId id) +{ + this->treeItemId = id; +} + +void Map::addChild(int id) +{ + children.push_back(id); +} + +void Map::setExpanded(bool exp) +{ + expanded = exp; +} + +void Map::setHidden(bool hid) +{ + hidden = hid; +} + +void Map::setLeftMoveType(Map::MoveType move, bool dirty) +{ + leftType = move; + + if (dirty) + { + world->setDirty(true); + } +} + +void Map::setRightMoveType(Map::MoveType move, bool dirty) { - leftmap = id; + rightType = move; if (dirty) { @@ -186,9 +299,9 @@ void Map::setLeftmap(int id, bool dirty) } } -void Map::setRightmap(int id, bool dirty) +void Map::setUpMoveType(Map::MoveType move, bool dirty) { - rightmap = id; + upType = move; if (dirty) { @@ -196,22 +309,53 @@ void Map::setRightmap(int id, bool dirty) } } -void Map::setTreeItemId(wxTreeItemId id) +void Map::setDownMoveType(Map::MoveType move, bool dirty) { - this->treeItemId = id; + downType = move; + + if (dirty) + { + world->setDirty(true); + } } -void Map::addChild(int id) +void Map::setLeftMoveMapID(int id, bool dirty) { - children.push_back(id); + leftMap = id; + + if (dirty) + { + world->setDirty(true); + } } -void Map::setExpanded(bool exp) +void Map::setRightMoveMapID(int id, bool dirty) { - expanded = exp; + rightMap = id; + + if (dirty) + { + world->setDirty(true); + } } -void Map::setHidden(bool hid) +void Map::setUpMoveMapID(int id, bool dirty) { - hidden = hid; + upMap = id; + + if (dirty) + { + world->setDirty(true); + } } + +void Map::setDownMoveMapID(int id, bool dirty) +{ + downMap = id; + + if (dirty) + { + world->setDirty(true); + } +} + -- cgit 1.4.1