porymap/include/core/regionmap.h

141 lines
3.2 KiB
C
Raw Normal View History

#ifndef REGIONMAP_H
#define REGIONMAP_H
#include "map.h"
2019-01-22 20:06:49 +00:00
#include "project.h"
#include "tilemaptileselector.h"
#include "history.h"
#include "historyitem.h"
#include <QStringList>
#include <QString>
2019-01-14 00:27:28 +00:00
#include <QVector>
#include <QList>
#include <QMap>
#include <QGraphicsScene>
#include <QGraphicsView>
2019-01-05 04:04:14 +00:00
struct CityMapPosition
{
2019-01-14 00:27:28 +00:00
QString tilemap;
int x;
int y;
};
2019-01-05 04:04:14 +00:00
struct RegionMapEntry
{
int x;
int y;
int width;
int height;
2019-01-14 00:27:28 +00:00
QString name;
2019-01-05 04:04:14 +00:00
};
class RegionMapSquare
{
public:
2019-01-14 00:27:28 +00:00
int x = -1;
int y = -1;
uint8_t tile_img_id;
bool has_map = false;
QString map_name;
2019-01-05 04:04:14 +00:00
QString mapsec;
uint8_t secid;
2019-01-14 00:27:28 +00:00
bool has_city_map = false;
QString city_map_name;
bool duplicated = false;
};
class RegionMap : public QObject
{
Q_OBJECT
public:
RegionMap() = default;
2019-01-05 04:04:14 +00:00
~RegionMap() {};
static QString mapSecToMapConstant(QString);
2019-01-05 04:04:14 +00:00
Project *project;
2019-01-14 00:27:28 +00:00
QVector<RegionMapSquare> map_squares;
const int padLeft = 1;
const int padRight = 3;
const int padTop = 2;
const int padBottom = 3;
History<RegionMapHistoryItem*> history;
QString region_map_png_path;
2019-01-14 00:27:28 +00:00
QString region_map_bin_path;
2019-01-05 04:04:14 +00:00
QString region_map_entries_path;
QString region_map_layout_bin_path;
2019-01-14 00:27:28 +00:00
QString city_map_tiles_path;
2019-01-05 04:04:14 +00:00
QByteArray mapBinData;
2019-01-14 00:27:28 +00:00
QMap<QString, QString> sMapNamesMap;// {"{/sMapName_/}LittlerootTown" : "LITTLEROOT{NAME_END} TOWN"}
2019-01-05 04:04:14 +00:00
QMap<QString, QString> mapSecToMapName;// {"MAPSEC_LITTLEROOT_TOWN" : "LITTLEROOT{NAME_END} TOWN"}
QMap<QString, struct RegionMapEntry> mapSecToMapEntry;// TODO: add to this on creation of new map
2019-01-14 00:27:28 +00:00
QVector<QString> sMapNames;
bool hasUnsavedChanges();
2019-01-14 00:27:28 +00:00
void init(Project*);
void readBkgImgBin();
2019-01-14 00:27:28 +00:00
void readCityMaps();
2019-01-05 04:04:14 +00:00
void readLayout();
QString newAbbr(QString);// makes a *unique* 5 character abbreviation from mapname to add to mapname_abbr
2019-01-22 20:06:49 +00:00
// TODO: did I use these like, at all?
// editing functions
// if they are booleans, returns true if successful?
bool placeTile(char, int, int);// place tile at x, y
bool removeTile(char, int, int);// replaces with 0x00 byte at x,y
bool placeMap(QString, int, int);
bool removeMap(QString, int, int);
bool removeMap(QString);// remove all instances of map
void save();
void saveBkgImgBin();
void saveLayout();
2019-01-05 04:04:14 +00:00
void saveOptions(int, QString, QString, int, int);
void saveCityMaps();
void resize(int, int);
void setWidth(int);
void setHeight(int);
2019-01-22 20:06:49 +00:00
void setBackgroundImageData(QVector<uint8_t> *);
int width();
int height();
QSize imgSize();
unsigned getTileId(int, int);
2019-01-05 04:04:14 +00:00
int getMapSquareIndex(int, int);
2019-01-22 20:06:49 +00:00
QVector<uint8_t> getTiles();
void setTiles(QVector<uint8_t>);
2019-01-14 00:27:28 +00:00
void resetSquare(int);
// TODO: move read / write functions to private (and others)
private:
int layout_width_;
int layout_height_;
int img_width_;
int img_height_;
int img_index_(int, int);// returns index int at x,y args (x + y * width_ * 2) // 2 because
int layout_index_(int, int);
2019-01-05 04:04:14 +00:00
void fillMapSquaresFromLayout();
QString fix_case(QString);// CAPS_WITH_UNDERSCORE to CamelCase
};
#endif // REGIONMAP_H