#pragma once #ifndef REGIONMAP_H #define REGIONMAP_H #include "map.h" #include "project.h" #include "tilemaptileselector.h" #include "history.h" #include #include #include #include #include #include #include enum RegionMapEditorBox { BackgroundImage = 1, CityMapImage = 2, }; class RegionMapHistoryItem { public: int which; int mapWidth = 0; int mapHeight = 0; QVector tiles; QString cityMap; RegionMapHistoryItem(int which, QVector tiles, QString cityMap) { this->which = which; this->tiles = tiles; this->cityMap = cityMap; } RegionMapHistoryItem(int which, QVector tiles, int width, int height) { this->which = which; this->tiles = tiles; this->mapWidth = width; this->mapHeight = height; } ~RegionMapHistoryItem() {} }; class RegionMapEntry { public: 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_; } int x; int y; int width; int height; QString name; void setX(int); void setY(int); void setWidth(int); void setHeight(int); }; class RegionMapSquare { public: int x = -1; int y = -1; uint8_t tile_img_id = 0x00; uint8_t secid = 0x00; bool has_map = false; bool has_city_map = false; bool duplicated = false; QString map_name; QString mapsec; QString city_map_name; }; class RegionMap { public: RegionMap() = default; Project *project = nullptr; QVector map_squares; History history; QMap sMapNamesMap; QMap mapSecToMapEntry; QVector sMapNames; const int padLeft = 1; const int padRight = 3; const int padTop = 2; const int padBottom = 3; bool init(Project*); bool readBkgImgBin(); bool readLayout(); void save(); void saveTileImages(); void saveBkgImgBin(); void saveLayout(); 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(); unsigned getTileId(int x, int y); int getMapSquareIndex(int x, int y); QString pngPath(); void setTemporaryPngPath(QString); QString cityTilesPath(); void setTemporaryCityTilesPath(QString); QVector getTiles(); void setTiles(QVector tileIds); QString fixCase(QString); private: int layout_width_; int layout_height_; int img_width_; int img_height_; 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; bool region_map_png_needs_saving = false; bool city_map_png_needs_saving = false; int img_index_(int x, int y); int layout_index_(int x, int y); }; #endif // REGIONMAP_H