porymap/include/core/map.h

109 lines
2.4 KiB
C
Raw Normal View History

2020-09-13 23:37:55 +01:00
#pragma once
2018-09-27 00:30:05 +01:00
#ifndef MAP_H
#define MAP_H
#include "blockdata.h"
#include "mapconnection.h"
#include "maplayout.h"
#include "tileset.h"
#include "events.h"
2018-09-27 00:30:05 +01:00
2020-07-29 20:51:04 +01:00
#include <QUndoStack>
2018-09-27 00:30:05 +01:00
#include <QPixmap>
#include <QObject>
#include <QGraphicsPixmapItem>
#include <math.h>
#define DEFAULT_BORDER_WIDTH 2
#define DEFAULT_BORDER_HEIGHT 2
// Maximum based only on data type (u8) of map border width/height
#define MAX_BORDER_WIDTH 255
#define MAX_BORDER_HEIGHT 255
2020-04-05 05:03:36 +01:00
// Number of metatiles to draw out from edge of map. Could allow modification of this in the future.
2020-03-14 07:44:55 +00:00
// porymap will reflect changes to it, but the value is hard-coded in the projects at the moment
2020-04-05 05:03:36 +01:00
#define BORDER_DISTANCE 7
2020-03-14 07:44:55 +00:00
class LayoutPixmapItem;
class CollisionPixmapItem;
2020-07-29 20:51:04 +01:00
class BorderMetatilesPixmapItem;
2018-09-27 00:30:05 +01:00
class Map : public QObject
{
Q_OBJECT
public:
explicit Map(QObject *parent = nullptr);
~Map();
2018-09-27 00:30:05 +01:00
public:
QString name;
QString constantName;
2023-01-23 17:19:21 +00:00
2018-09-27 00:30:05 +01:00
QString song;
2019-02-01 17:43:25 +00:00
QString layoutId;
2018-09-27 00:30:05 +01:00
QString location;
bool requiresFlash;
2018-09-27 00:30:05 +01:00
QString weather;
QString type;
bool show_location;
bool allowRunning;
bool allowBiking;
bool allowEscaping;
2021-02-18 08:51:44 +00:00
int floorNumber = 0;
2018-09-27 00:30:05 +01:00
QString battle_scene;
2023-01-23 17:19:21 +00:00
QString sharedEventsMap = "";
QString sharedScriptsMap = "";
2023-01-23 17:19:21 +00:00
QMap<QString, QJsonValue> customHeaders;
2023-01-23 17:19:21 +00:00
Layout *layout = nullptr;
2023-02-06 20:05:22 +00:00
void setLayout(Layout *layout);
2023-01-23 17:19:21 +00:00
2018-09-27 00:30:05 +01:00
bool isPersistedToFile = true;
bool hasUnsavedDataChanges = false;
2023-01-23 17:19:21 +00:00
bool needsLayoutDir = true;
bool needsHealLocation = false;
2023-01-23 17:19:21 +00:00
QMap<Event::Group, QList<Event *>> events;
QList<Event *> ownedEvents; // for memory management
2018-09-27 00:30:05 +01:00
QList<MapConnection*> connections;
2023-01-23 17:19:21 +00:00
2018-09-27 00:30:05 +01:00
void setName(QString mapName);
static QString mapConstantFromName(QString mapName);
2023-01-23 17:19:21 +00:00
/// !HERE /* layout related stuff */
2018-09-27 00:30:05 +01:00
int getWidth();
int getHeight();
int getBorderWidth();
int getBorderHeight();
2023-01-23 17:19:21 +00:00
QList<Event *> getAllEvents() const;
QStringList eventScriptLabels(Event::Group group = Event::Group::None) const;
void removeEvent(Event *);
void addEvent(Event *);
2023-01-23 17:19:21 +00:00
void openScript(QString label);
QUndoStack editHistory;
void modify();
void clean();
bool hasUnsavedChanges();
2020-07-29 20:51:04 +01:00
QPixmap renderConnection(MapConnection, Layout *);
2020-07-29 20:51:04 +01:00
2018-09-27 00:30:05 +01:00
signals:
void mapChanged(Map *map);
void modified();
2020-10-24 12:45:08 +01:00
void mapDimensionsChanged(const QSize &size);
2018-09-27 00:30:05 +01:00
void mapNeedsRedrawing();
void openScriptRequested(QString label);
2018-09-27 00:30:05 +01:00
};
#endif // MAP_H