2018-12-28 18:26:18 +00:00
|
|
|
#ifndef REGIONMAP_H
|
|
|
|
#define REGIONMAP_H
|
|
|
|
|
|
|
|
#include "project.h"
|
|
|
|
#include "map.h"
|
|
|
|
#include "tilemaptileselector.h"
|
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
// rename this struct?
|
2018-12-28 18:26:18 +00:00
|
|
|
struct CityMapPosition
|
|
|
|
{
|
|
|
|
//
|
2019-01-05 04:04:14 +00:00
|
|
|
//QString filename; // eg. dewford_0 ?
|
2018-12-28 18:26:18 +00:00
|
|
|
QString tilemap;// eg. "dewford_0"
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
struct RegionMapEntry
|
|
|
|
{
|
|
|
|
//
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
QString name;// mapsection
|
|
|
|
};
|
|
|
|
|
2018-12-28 18:26:18 +00:00
|
|
|
// class that holds data for each square in this project
|
|
|
|
// struct?
|
|
|
|
// TODO: change char / uint8_t to unsigned
|
|
|
|
class RegionMapSquare
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//
|
|
|
|
int x = -1;// x position, 0-indexed from top left
|
|
|
|
int y = -1;// y position, 0-indexed from top left
|
|
|
|
uint8_t tile_img_id;// tilemap ids for the background image
|
|
|
|
bool has_map = false;// whether this square is linked to a map or is empty
|
2019-01-05 04:04:14 +00:00
|
|
|
QString map_name;// name of the map associated with this square (if has_map is true): eg. "MAUVILLE_CITY" (TODO: REMOVE)
|
|
|
|
QString mapsec;
|
|
|
|
uint8_t secid;
|
|
|
|
bool has_city_map = false;// whether there is a city map on this grid
|
2018-12-28 18:26:18 +00:00
|
|
|
QString city_map_name;// filename of the city_map tilemap
|
|
|
|
//bool is_flyable;//? needed ?
|
|
|
|
friend class RegionMap;// not necessary if instance? what
|
|
|
|
};
|
|
|
|
|
|
|
|
class RegionMap : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
//public:
|
|
|
|
// explicit Map(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
public:
|
|
|
|
RegionMap() = default;
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
~RegionMap() {};
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
static QMap<QString, QList<struct CityMapPosition>> ruby_city_maps_;
|
|
|
|
static QString mapSecToMapConstant(QString);
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
Project *project;
|
|
|
|
|
2018-12-28 18:26:18 +00:00
|
|
|
//RegionMapSquare *map_squares = nullptr;// array of RegionMapSquares
|
|
|
|
QList<RegionMapSquare> map_squares;
|
|
|
|
|
|
|
|
QString temp_path;// delete this
|
|
|
|
QString city_map_squares_path;
|
|
|
|
QString region_map_png_path;
|
|
|
|
QString region_map_bin_path;// = QString::null;
|
|
|
|
QString city_map_header_path;//dafuq is this?
|
|
|
|
QString region_map_layout_path;
|
2019-01-05 04:04:14 +00:00
|
|
|
QString region_map_entries_path;
|
|
|
|
QString region_map_layout_bin_path;
|
|
|
|
QString region_map_city_map_tiles_path;
|
|
|
|
|
|
|
|
QByteArray mapBinData;
|
2018-12-28 18:26:18 +00:00
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
QMap<QString, QString> sMapNames;// {"{/sMapName_/}LittlerootTown" : "LITTLEROOT{NAME_END} TOWN"}
|
|
|
|
QMap<QString, QString> mapSecToMapName;// {"MAPSEC_LITTLEROOT_TOWN" : "LITTLEROOT{NAME_END} TOWN"}
|
|
|
|
//QList<QPair<QString, struct RegionMapEntry>> mapSecToMapEntry;
|
|
|
|
QMap<QString, struct RegionMapEntry> mapSecToMapEntry;// TODO: add to this on creation of new map
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
bool hasUnsavedChanges();
|
|
|
|
|
|
|
|
void init(Project*);//QString);
|
|
|
|
|
|
|
|
// parseutil.cpp ?
|
|
|
|
void readBkgImgBin();
|
|
|
|
void readCityMaps();// more complicated
|
2019-01-05 04:04:14 +00:00
|
|
|
void readLayout();
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
QString newAbbr(QString);// makes a *unique* 5 character abbreviation from mapname to add to mapname_abbr
|
|
|
|
|
|
|
|
// 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);
|
2018-12-28 18:26:18 +00:00
|
|
|
void saveCityMaps();
|
|
|
|
|
|
|
|
void update();// update the view in case something is broken?
|
|
|
|
void resize(int, int);
|
|
|
|
void setWidth(int);
|
|
|
|
void setHeight(int);
|
|
|
|
int width();
|
|
|
|
int height();
|
|
|
|
QSize imgSize();
|
|
|
|
unsigned getTileId(int, int);
|
2019-01-05 04:04:14 +00:00
|
|
|
int getMapSquareIndex(int, int);
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
// implement these here?
|
|
|
|
void undo();
|
|
|
|
void redo();
|
|
|
|
|
2019-01-05 04:04:14 +00:00
|
|
|
void test();// remove when done testing obvi
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
// 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
|
2018-12-28 18:26:18 +00:00
|
|
|
|
|
|
|
//protected:
|
|
|
|
//
|
|
|
|
|
|
|
|
//signals:
|
|
|
|
//
|
|
|
|
};
|
|
|
|
|
|
|
|
//TilemapTileSelector *city_map_metatile_selector_item = nullptr;
|
|
|
|
|
|
|
|
#endif // REGIONMAP_H
|