mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-26 09:56:32 -05:00
Performance & bug clean up
This commit is contained in:
@@ -1,43 +1,35 @@
|
||||
#include "mapconnection.h"
|
||||
#include "map.h"
|
||||
|
||||
void MapConnection::setDirection(const QString & direction) {
|
||||
if (direction == m_direction)
|
||||
return;
|
||||
auto before = m_direction;
|
||||
m_direction = direction;
|
||||
emit directionChanged(before, m_direction);
|
||||
}
|
||||
const QStringList MapConnection::cardinalDirections = {
|
||||
"up", "down", "left", "right"
|
||||
};
|
||||
|
||||
void MapConnection::setOffset(int offset) {
|
||||
if (offset == m_offset)
|
||||
return;
|
||||
auto before = m_offset;
|
||||
m_offset = offset;
|
||||
emit offsetChanged(before, m_offset);
|
||||
}
|
||||
|
||||
void MapConnection::setMapName(const QString &mapName) {
|
||||
if (mapName == m_mapName)
|
||||
return;
|
||||
auto before = m_mapName;
|
||||
m_mapName = mapName;
|
||||
emit mapNameChanged(before, m_mapName);
|
||||
}
|
||||
/*
|
||||
static QString MapConnection::oppositeDirection(const QString &direction) {
|
||||
MapConnection MapConnection::mirror(const MapConnection &source, const QString &mapName) {
|
||||
static const QMap<QString, QString> oppositeDirections = {
|
||||
{"up", "down"}, {"down", "up"},
|
||||
{"right", "left"}, {"left", "right"},
|
||||
{"dive", "emerge"}, {"emerge", "dive"}
|
||||
};
|
||||
return oppositeDirections.value(direction);
|
||||
|
||||
// TODO: Allowing editing unknown directions is a can of worms.
|
||||
// Specifically a self-connection with an empty direction and an offset of 0 can be identified as its own mirror
|
||||
MapConnection mirror;
|
||||
mirror.direction = oppositeDirections.value(source.direction/*, source.direction*/);
|
||||
mirror.map_name = mapName;
|
||||
mirror.offset = -source.offset;
|
||||
|
||||
return mirror;
|
||||
}
|
||||
|
||||
static MapConnection* MapConnection::getMirror(const MapConnection*, const Map*) {
|
||||
|
||||
bool MapConnection::isHorizontal(const QString &direction) {
|
||||
return direction == "left" || direction == "right";
|
||||
}
|
||||
|
||||
static MapConnection* MapConnection::newMirror(const MapConnection*) {
|
||||
bool MapConnection::isVertical(const QString &direction) {
|
||||
return direction == "up" || direction == "down";
|
||||
}
|
||||
|
||||
}*/
|
||||
bool MapConnection::isCardinal(const QString &direction) {
|
||||
return cardinalDirections.contains(direction);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user