mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-13 04:15:45 -05:00
MapConnection to QObject
This commit is contained in:
@@ -98,7 +98,7 @@ public:
|
||||
QStringList getScriptLabels(Event::Group group = Event::Group::None);
|
||||
void removeEvent(Event *);
|
||||
void addEvent(Event *);
|
||||
QPixmap renderConnection(const MapConnection&, MapLayout *);
|
||||
QPixmap renderConnection(const QString &, MapLayout *);
|
||||
QPixmap renderBorder(bool ignoreCache = false);
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
|
||||
@@ -3,32 +3,45 @@
|
||||
#define MAPCONNECTION_H
|
||||
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
class Map;
|
||||
|
||||
class MapConnection {
|
||||
class MapConnection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QString direction;
|
||||
int offset;
|
||||
QString map_name;
|
||||
MapConnection(const QString &direction, const QString &hostMapName, const QString &targetMapName, int offset = 0);
|
||||
|
||||
QString direction() const { return m_direction; }
|
||||
void setDirection(const QString &direction);
|
||||
|
||||
QString hostMapName() const { return m_hostMapName; }
|
||||
void setHostMapName(const QString &hostMapName);
|
||||
|
||||
QString targetMapName() const { return m_targetMapName; }
|
||||
void setTargetMapName(const QString &targetMapName);
|
||||
|
||||
int offset() const { return m_offset; }
|
||||
void setOffset(int offset);
|
||||
|
||||
MapConnection * createMirror();
|
||||
bool isMirror(const MapConnection*);
|
||||
|
||||
static const QStringList cardinalDirections;
|
||||
static bool isCardinal(const QString &direction);
|
||||
static bool isHorizontal(const QString &direction);
|
||||
static bool isVertical(const QString &direction);
|
||||
static MapConnection mirror(const MapConnection &source, const QString &mapName);
|
||||
};
|
||||
|
||||
struct MapConnectionMirror {
|
||||
MapConnection * connection = nullptr;
|
||||
Map * map = nullptr;
|
||||
};
|
||||
private:
|
||||
QString m_direction;
|
||||
QString m_hostMapName;
|
||||
QString m_targetMapName;
|
||||
int m_offset;
|
||||
|
||||
inline bool operator==(const MapConnection &c1, const MapConnection &c2) {
|
||||
return c1.direction == c2.direction &&
|
||||
c1.offset == c2.offset &&
|
||||
c1.map_name == c2.map_name;
|
||||
}
|
||||
signals:
|
||||
void directionChanged(const QString &before, const QString &after);
|
||||
void targetMapNameChanged(const QString &before, const QString &after);
|
||||
void hostMapNameChanged(const QString &before, const QString &after);
|
||||
void offsetChanged(int before, int after);
|
||||
};
|
||||
|
||||
#endif // MAPCONNECTION_H
|
||||
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
void setConnectionsVisibility(bool visible);
|
||||
void updateDiveEmergeVisibility();
|
||||
void addNewConnection();
|
||||
void addConnection(Map* map, MapConnection* connection, bool addMirror = true);
|
||||
void removeConnection(Map* map, MapConnection* connection, bool removeMirror = true);
|
||||
void addConnection(MapConnection* connection, bool addMirror = true);
|
||||
void removeConnection(MapConnection* connection, bool removeMirror = true);
|
||||
void removeConnectionItem(ConnectionPixmapItem* connectionItem);
|
||||
void removeSelectedConnection();
|
||||
void addNewWildMonGroup(QWidget *window);
|
||||
@@ -185,14 +185,14 @@ private:
|
||||
void clearMapGrid();
|
||||
void clearWildMonTables();
|
||||
void updateBorderVisibility();
|
||||
QPoint calculateConnectionPosition(const MapConnection &connection, const QPixmap &pixmap);
|
||||
QPixmap getConnectionPixmap(const MapConnection &connection);
|
||||
QPoint calculateConnectionPosition(MapConnection *connection, const QPixmap &pixmap);
|
||||
QPixmap getConnectionPixmap(MapConnection *connection);
|
||||
void updateConnectionItem(ConnectionPixmapItem* connectionItem);
|
||||
void updateConnectionItemPos(ConnectionPixmapItem* connectionItem);
|
||||
void createConnectionItem(MapConnection* connection);
|
||||
void createDiveEmergeConnection(MapConnection* connection);
|
||||
void setDiveEmergeMapName(QString mapName, QString direction);
|
||||
MapConnectionMirror getMirroredConnection(MapConnection*);
|
||||
MapConnection* getMirroredConnection(MapConnection*);
|
||||
void addMirroredConnection(MapConnection*);
|
||||
void removeMirroredConnection(MapConnection*);
|
||||
void updateEncounterFields(EncounterFields newFields);
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
this->initialX = x;
|
||||
this->initialY = y;
|
||||
this->initialOffset = connection->offset;
|
||||
this->initialOffset = connection->offset();
|
||||
this->setX(x);
|
||||
this->setY(y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user