porymap/map.h

121 lines
3.4 KiB
C
Raw Normal View History

2016-09-07 04:50:47 +01:00
#ifndef MAP_H
#define MAP_H
2018-09-25 01:12:29 +01:00
#include "blockdata.h"
#include "history.h"
#include "historyitem.h"
#include "mapconnection.h"
#include "maplayout.h"
#include "tileset.h"
2016-09-07 04:50:47 +01:00
#include "event.h"
#include <QPixmap>
#include <QObject>
#include <QDebug>
#include <QGraphicsPixmapItem>
#include <math.h>
2016-09-07 04:50:47 +01:00
class Map : public QObject
{
Q_OBJECT
public:
2018-09-15 00:37:44 +01:00
explicit Map(QObject *parent = nullptr);
2016-09-07 04:50:47 +01:00
public:
QString name;
QString constantName;
QString group_num;
2018-06-20 23:43:20 +01:00
QString layout_label;
2016-09-07 04:50:47 +01:00
QString events_label;
QString scripts_label;
QString connections_label;
QString song;
2018-06-20 23:43:20 +01:00
QString layout_id;
2016-09-07 04:50:47 +01:00
QString location;
QString requiresFlash;
2018-09-12 01:37:36 +01:00
QString isFlyable; // TODO: implement this
2016-09-07 04:50:47 +01:00
QString weather;
QString type;
QString unknown;
QString show_location;
QString battle_scene;
2018-06-20 23:43:20 +01:00
MapLayout *layout;
int scale_exp = 0;
double scale_base = sqrt(2); // adjust scale factor with this
2016-09-07 04:50:47 +01:00
bool isPersistedToFile = true;
2016-09-07 04:50:47 +01:00
public:
void setName(QString mapName);
static QString mapConstantFromName(QString mapName);
2018-07-07 17:57:44 +01:00
static QString objectEventsLabelFromName(QString mapName);
static QString warpEventsLabelFromName(QString mapName);
static QString coordEventsLabelFromName(QString mapName);
static QString bgEventsLabelFromName(QString mapName);
2016-09-07 04:50:47 +01:00
int getWidth();
int getHeight();
2018-09-15 00:37:36 +01:00
uint16_t getSelectedBlockIndex(int);
2018-07-07 17:57:44 +01:00
int getDisplayedBlockIndex(int);
2018-06-20 23:43:20 +01:00
QPixmap render(bool ignoreCache);
2016-09-07 04:50:47 +01:00
2018-06-20 23:43:20 +01:00
QPixmap renderCollision(bool ignoreCache);
2016-09-07 04:50:47 +01:00
QImage collision_image;
QPixmap collision_pixmap;
QImage getCollisionMetatileImage(Block);
2018-07-20 04:27:40 +01:00
QImage getCollisionMetatileImage(int, int);
void drawSelection(int i, int w, int selectionWidth, int selectionHeight, QPainter *painter, int gridWidth);
2016-09-07 04:50:47 +01:00
bool blockChanged(int, Blockdata*);
void cacheBlockdata();
void cacheCollision();
QImage image;
QPixmap pixmap;
QList<QImage> metatile_images;
2018-03-06 00:47:00 +00:00
bool smart_paths_enabled = false;
2018-03-05 22:47:46 +00:00
int paint_tile_initial_x;
int paint_tile_initial_y;
2016-09-07 04:50:47 +01:00
Block *getBlock(int x, int y);
void setBlock(int x, int y, Block block);
void _setBlock(int x, int y, Block block);
2018-09-15 00:37:36 +01:00
void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
2016-09-07 04:50:47 +01:00
History<HistoryItem*> history;
2016-09-07 04:50:47 +01:00
void undo();
void redo();
void commit();
2017-11-28 04:46:27 +00:00
QList<Event*> getAllEvents();
void removeEvent(Event *event);
void addEvent(Event *event);
QMap<QString, QList<Event*>> events;
2016-09-07 04:50:47 +01:00
QList<MapConnection*> connections;
QPixmap renderConnection(MapConnection);
void setNewDimensionsBlockdata(int newWidth, int newHeight);
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
2016-09-07 04:50:47 +01:00
QPixmap renderBorder();
void cacheBorder();
2017-11-28 04:46:27 +00:00
bool hasUnsavedChanges();
void hoveredTileChanged(int x, int y, int block);
void clearHoveredTile();
void hoveredMetatileSelectionChanged(uint16_t);
void clearHoveredMetatileSelection();
2018-07-20 04:27:40 +01:00
void clearHoveredMovementPermissionTile();
2017-11-28 04:46:27 +00:00
2016-09-07 04:50:47 +01:00
signals:
2017-11-28 04:46:27 +00:00
void mapChanged(Map *map);
2018-09-15 00:37:36 +01:00
void mapNeedsRedrawing();
void statusBarMessage(QString);
2016-09-07 04:50:47 +01:00
public slots:
void hoveredMovementPermissionTileChanged(int collision, int elevation);
2016-09-07 04:50:47 +01:00
};
#endif // MAP_H