porymap/include/core/regionmap.h

114 lines
2.3 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 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;
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;
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);
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;
QMap<QString, QString> sMapNamesMap;
QMap<QString, struct RegionMapEntry> mapSecToMapEntry;
QVector<QString> sMapNames;
int img_index_(int x, int y);
int layout_index_(int x, int y);
QString fix_case(QString);
};
#endif // REGIONMAP_H