porymap/include/core/mapconnection.h

64 lines
1.9 KiB
C
Raw Normal View History

2020-09-13 23:37:55 +01:00
#pragma once
#ifndef MAPCONNECTION_H
#define MAPCONNECTION_H
#include <QString>
2024-08-04 21:08:16 +01:00
#include <QObject>
#include <QMap>
class Project;
2024-08-09 06:29:28 +01:00
class Map;
2024-08-04 21:08:16 +01:00
class MapConnection : public QObject
{
Q_OBJECT
public:
2024-08-09 06:29:28 +01:00
MapConnection(const QString &targetMapName, const QString &direction, int offset = 0);
2024-08-04 21:08:16 +01:00
2024-08-09 06:29:28 +01:00
Map* parentMap() const { return m_parentMap; }
QString parentMapName() const;
void setParentMap(Map* map, bool mirror = true);
2024-08-04 21:08:16 +01:00
2024-08-09 06:29:28 +01:00
Map* targetMap() const;
2024-08-04 21:08:16 +01:00
QString targetMapName() const { return m_targetMapName; }
2024-08-09 06:29:28 +01:00
void setTargetMapName(const QString &targetMapName, bool mirror = true);
QString direction() const { return m_direction; }
void setDirection(const QString &direction, bool mirror = true);
2024-08-04 21:08:16 +01:00
int offset() const { return m_offset; }
2024-08-09 06:29:28 +01:00
void setOffset(int offset, bool mirror = true);
2024-08-04 21:08:16 +01:00
MapConnection* findMirror();
MapConnection* createMirror();
QPixmap getPixmap();
2024-07-12 19:05:37 +01:00
static QPointer<Project> project;
static const QMap<QString, QString> oppositeDirections;
2024-07-12 19:05:37 +01:00
static const QStringList cardinalDirections;
static bool isCardinal(const QString &direction);
static bool isHorizontal(const QString &direction);
static bool isVertical(const QString &direction);
2024-08-09 06:29:28 +01:00
static bool isDiving(const QString &direction);
static QString oppositeDirection(const QString &direction) { return oppositeDirections.value(direction, direction); }
2024-08-15 03:22:54 +01:00
static bool areMirrored(const MapConnection*, const MapConnection*);
2024-08-04 21:08:16 +01:00
private:
2024-08-09 06:29:28 +01:00
Map* m_parentMap;
2024-08-04 21:08:16 +01:00
QString m_targetMapName;
2024-08-09 06:29:28 +01:00
QString m_direction;
2024-08-04 21:08:16 +01:00
int m_offset;
void markMapEdited();
2024-08-09 06:29:28 +01:00
Map* getMap(const QString& mapName) const;
2024-08-04 21:08:16 +01:00
signals:
2024-08-09 06:29:28 +01:00
void parentMapChanged(Map* before, Map* after);
2024-08-20 02:31:36 +01:00
void targetMapNameChanged(QString before, QString after);
void directionChanged(QString before, QString after);
2024-08-04 21:08:16 +01:00
void offsetChanged(int before, int after);
};
#endif // MAPCONNECTION_H