porymap/include/core/regionmap.h

128 lines
2.6 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-04-13 02:25:43 +01:00
class RegionMapEntry
2019-01-05 04:04:14 +00:00
{
2019-04-13 02:25:43 +01:00
public:
2019-04-13 04:07:00 +01:00
RegionMapEntry()=default;
RegionMapEntry(int x_, int y_, int width_, int height_, QString name_) {
this-> x = x_;
this-> y = y_;
this-> width = width_;
this-> height = height_;
this-> name = name_;
}
2019-01-05 04:04:14 +00:00
int x;
int y;
int width;
int height;
2019-01-14 00:27:28 +00:00
QString name;
2019-04-13 02:25:43 +01:00
void setX(int);
void setY(int);
void setWidth(int);
void setHeight(int);
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;
2019-01-28 18:47:20 +00:00
uint8_t tile_img_id = 0x00;
uint8_t secid = 0x00;
2019-01-14 00:27:28 +00:00
bool has_map = false;
2019-01-28 18:47:20 +00:00
bool has_city_map = false;
bool duplicated = false;
2019-01-14 00:27:28 +00:00
QString map_name;
2019-01-05 04:04:14 +00:00
QString mapsec;
2019-01-14 00:27:28 +00:00
QString city_map_name;
};
class RegionMap : public QObject
{
Q_OBJECT
public:
RegionMap() = default;
2019-01-05 04:04:14 +00:00
~RegionMap() {};
Project *project = nullptr;
2019-01-05 04:04:14 +00:00
2019-01-14 00:27:28 +00:00
QVector<RegionMapSquare> map_squares;
2019-01-28 18:47:20 +00:00
History<RegionMapHistoryItem*> history;
2019-04-13 02:25:43 +01:00
QMap<QString, QString> sMapNamesMap;
QMap<QString, RegionMapEntry> mapSecToMapEntry;
QVector<QString> sMapNames;
const int padLeft = 1;
const int padRight = 3;
const int padTop = 2;
const int padBottom = 3;
2019-01-14 00:27:28 +00:00
void init(Project*);
void readBkgImgBin();
2019-01-05 04:04:14 +00:00
void readLayout();
void save();
2019-03-25 04:10:57 +00:00
void saveTileImages();
void saveBkgImgBin();
void saveLayout();
2019-01-28 18:47:20 +00:00
void saveOptions(int id, QString sec, QString name, int x, int y);
void resize(int width, int height);
void resetSquare(int index);
void clearLayout();
void clearImage();
void replaceSectionId(unsigned oldId, unsigned newId);
int width();
int height();
QSize imgSize();
2019-01-28 18:47:20 +00:00
unsigned getTileId(int x, int y);
int getMapSquareIndex(int x, int y);
QString pngPath();
2019-03-25 04:10:57 +00:00
void setTemporaryPngPath(QString);
2019-01-28 18:47:20 +00:00
QString cityTilesPath();
2019-03-25 04:10:57 +00:00
void setTemporaryCityTilesPath(QString);
2019-01-22 20:06:49 +00:00
QVector<uint8_t> getTiles();
2019-01-28 18:47:20 +00:00
void setTiles(QVector<uint8_t> tileIds);
2019-04-13 04:07:00 +01:00
QString fixCase(QString);
private:
int layout_width_;
int layout_height_;
int img_width_;
int img_height_;
2019-01-28 18:47:20 +00:00
QString region_map_png_path;
QString region_map_bin_path;
QString region_map_entries_path;
QString region_map_layout_bin_path;
QString city_map_tiles_path;
int img_index_(int x, int y);
int layout_index_(int x, int y);
};
#endif // REGIONMAP_H