2018-12-28 18:26:18 +00:00
|
|
|
#ifndef REGIONMAP_H
|
|
|
|
#define REGIONMAP_H
|
|
|
|
|
|
|
|
#include "map.h"
|
2019-01-22 20:06:49 +00:00
|
|
|
#include "project.h"
|
2018-12-28 18:26:18 +00:00
|
|
|
#include "tilemaptileselector.h"
|
2019-01-09 02:03:54 +00:00
|
|
|
#include "history.h"
|
|
|
|
#include "historyitem.h"
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
2019-01-14 00:27:28 +00:00
|
|
|
#include <QVector>
|
2018-12-28 18:26:18 +00:00
|
|
|
#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
|
|
|
};
|
|
|
|
|
2018-12-28 18:26:18 +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;
|
2018-12-28 18:26:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RegionMap : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
RegionMap() = default;
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
~RegionMap() {};
|
2018-12-28 18:26:18 +00:00
|
|
|
|
2019-02-16 22:56:44 +00:00
|
|
|
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;
|
2018-12-28 18:26:18 +00:00
|
|
|
|
2019-01-15 22:06:18 +00:00
|
|
|
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*);
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
void readBkgImgBin();
|
2019-01-05 04:04:14 +00:00
|
|
|
void readLayout();
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
void save();
|
2019-03-25 04:10:57 +00:00
|
|
|
void saveTileImages();
|
2018-12-28 18:26:18 +00:00
|
|
|
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);
|
2019-03-17 16:37:13 +00:00
|
|
|
void clearLayout();
|
|
|
|
void clearImage();
|
2019-02-16 22:56:44 +00:00
|
|
|
void replaceSectionId(unsigned oldId, unsigned newId);
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
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);
|
2018-12-28 18:26:18 +00:00
|
|
|
|
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);
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
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);
|
2018-12-28 18:26:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // REGIONMAP_H
|