mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-30 20:06:56 -05:00
resize region map, move map squares
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QGraphicsScene>
|
||||
@@ -16,91 +17,75 @@
|
||||
|
||||
|
||||
|
||||
// rename this struct?
|
||||
struct CityMapPosition
|
||||
{
|
||||
//
|
||||
//QString filename; // eg. dewford_0 ?
|
||||
QString tilemap;// eg. "dewford_0"
|
||||
QString tilemap;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct RegionMapEntry
|
||||
{
|
||||
//
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
QString name;// mapsection
|
||||
QString name;
|
||||
};
|
||||
|
||||
// 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
|
||||
QString map_name;// name of the map associated with this square (if has_map is true): eg. "MAUVILLE_CITY" (TODO: REMOVE)
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
uint8_t tile_img_id;
|
||||
bool has_map = false;
|
||||
QString map_name;
|
||||
QString mapsec;
|
||||
uint8_t secid;
|
||||
bool has_city_map = false;// whether there is a city map on this grid
|
||||
QString city_map_name;// filename of the city_map tilemap
|
||||
//bool is_flyable;//? needed ?
|
||||
friend class RegionMap;// not necessary if instance? what
|
||||
bool has_city_map = false;
|
||||
QString city_map_name;
|
||||
bool duplicated = false;
|
||||
};
|
||||
|
||||
class RegionMap : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
//public:
|
||||
// explicit Map(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
RegionMap() = default;
|
||||
|
||||
~RegionMap() {};
|
||||
|
||||
static QMap<QString, QList<struct CityMapPosition>> ruby_city_maps_;
|
||||
static QString mapSecToMapConstant(QString);
|
||||
|
||||
Project *project;
|
||||
|
||||
//RegionMapSquare *map_squares = nullptr;// array of RegionMapSquares
|
||||
QList<RegionMapSquare> map_squares;
|
||||
//QList<RegionMapSquare> map_squares;
|
||||
QVector<RegionMapSquare> map_squares;
|
||||
|
||||
History<RegionMapHistoryItem*> history;
|
||||
|
||||
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;
|
||||
QString region_map_bin_path;
|
||||
QString region_map_entries_path;
|
||||
QString region_map_layout_bin_path;
|
||||
QString region_map_city_map_tiles_path;
|
||||
QString city_map_tiles_path;
|
||||
|
||||
QByteArray mapBinData;
|
||||
|
||||
QMap<QString, QString> sMapNames;// {"{/sMapName_/}LittlerootTown" : "LITTLEROOT{NAME_END} TOWN"}
|
||||
QMap<QString, QString> sMapNamesMap;// {"{/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
|
||||
|
||||
QVector<QString> sMapNames;
|
||||
|
||||
bool hasUnsavedChanges();
|
||||
|
||||
void init(Project*);//QString);
|
||||
void init(Project*);
|
||||
|
||||
// parseutil.cpp ?
|
||||
void readBkgImgBin();
|
||||
void readCityMaps();// more complicated
|
||||
void readCityMaps();
|
||||
void readLayout();
|
||||
|
||||
QString newAbbr(QString);// makes a *unique* 5 character abbreviation from mapname to add to mapname_abbr
|
||||
@@ -119,7 +104,6 @@ public:
|
||||
void saveOptions(int, QString, QString, int, int);
|
||||
void saveCityMaps();
|
||||
|
||||
void update();// update the view in case something is broken?
|
||||
void resize(int, int);
|
||||
void setWidth(int);
|
||||
void setHeight(int);
|
||||
@@ -129,18 +113,12 @@ public:
|
||||
unsigned getTileId(int, int);
|
||||
int getMapSquareIndex(int, int);
|
||||
|
||||
void deleteLayoutSquare(int);
|
||||
void resetSquare(int);
|
||||
|
||||
// implement these here?
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void test();// remove when done testing obvi
|
||||
void test();// remove
|
||||
|
||||
// TODO: move read / write functions to private (and others)
|
||||
private:
|
||||
//
|
||||
//History<QPair<int, uint8_t>> *history;// (index, tile)
|
||||
int layout_width_;
|
||||
int layout_height_;
|
||||
int img_width_;
|
||||
@@ -150,13 +128,6 @@ private:
|
||||
void fillMapSquaresFromLayout();
|
||||
QString fix_case(QString);// CAPS_WITH_UNDERSCORE to CamelCase
|
||||
|
||||
//protected:
|
||||
//
|
||||
|
||||
//signals:
|
||||
//
|
||||
};
|
||||
|
||||
//TilemapTileSelector *city_map_metatile_selector_item = nullptr;
|
||||
|
||||
#endif // REGIONMAP_H
|
||||
|
||||
@@ -24,32 +24,11 @@ public:
|
||||
explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr);
|
||||
~RegionMapEditor();
|
||||
|
||||
// TODO: make members that are not called outside of this private
|
||||
RegionMap *region_map;
|
||||
|
||||
QGraphicsScene *scene_region_map_image = nullptr;
|
||||
QGraphicsScene *scene_city_map_image = nullptr;
|
||||
QGraphicsScene *scene_region_map_layout = nullptr;
|
||||
QGraphicsScene *scene_region_map_tiles = nullptr;
|
||||
QGraphicsScene *scene_city_map_tiles = nullptr;
|
||||
TilemapTileSelector *mapsquare_selector_item = nullptr;
|
||||
TilemapTileSelector *city_map_selector_item = nullptr;
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
CityMapPixmapItem *city_map_item = nullptr;
|
||||
RegionMapLayoutPixmapItem *region_map_layout_item = nullptr;
|
||||
|
||||
void loadRegionMapData();
|
||||
void displayRegionMap();
|
||||
void displayRegionMapImage();
|
||||
void displayRegionMapLayout();
|
||||
void displayRegionMapLayoutOptions();
|
||||
void updateRegionMapLayoutOptions(int);
|
||||
void displayRegionMapTileSelector();
|
||||
void displayCityMapTileSelector();
|
||||
void displayCityMap(QString);
|
||||
void loadCityMaps();
|
||||
|
||||
void onRegionMapTileSelectorSelectedTileChanged();
|
||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned);
|
||||
void onRegionMapTileSelectorHoveredTileCleared();
|
||||
|
||||
@@ -60,14 +39,17 @@ public:
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void resize(int, int);
|
||||
|
||||
private:
|
||||
Ui::RegionMapEditor *ui;
|
||||
Project *project;
|
||||
|
||||
QString rmStatusbarMessage;
|
||||
History<RegionMapHistoryItem*> history;
|
||||
|
||||
double scaleUpFactor = 2.0;
|
||||
int currIndex = 65;// TODO: automatic this from width * 2 + 1
|
||||
|
||||
double scaleUpFactor = 2.0;// TODO
|
||||
double scaleDownFactor = 1.0 / scaleUpFactor;
|
||||
|
||||
double scaleRegionMapTiles = 1.0;
|
||||
@@ -75,7 +57,27 @@ private:
|
||||
double scaleCityMapTiles = 1.0;
|
||||
double scaleCityMapImage = 1.0;
|
||||
|
||||
void scaleUp(QGraphicsView *, qreal factor, qreal width, qreal height);
|
||||
QGraphicsScene *scene_region_map_image = nullptr;
|
||||
QGraphicsScene *scene_city_map_image = nullptr;
|
||||
QGraphicsScene *scene_region_map_layout = nullptr;
|
||||
QGraphicsScene *scene_region_map_tiles = nullptr;
|
||||
QGraphicsScene *scene_city_map_tiles = nullptr;
|
||||
|
||||
TilemapTileSelector *mapsquare_selector_item = nullptr;
|
||||
TilemapTileSelector *city_map_selector_item = nullptr;
|
||||
|
||||
RegionMapLayoutPixmapItem *region_map_layout_item = nullptr;
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
CityMapPixmapItem *city_map_item = nullptr;
|
||||
|
||||
void displayRegionMap();
|
||||
void displayRegionMapImage();
|
||||
void displayRegionMapLayout();
|
||||
void displayRegionMapLayoutOptions();
|
||||
void updateRegionMapLayoutOptions(int);
|
||||
void displayRegionMapTileSelector();
|
||||
void displayCityMapTileSelector();
|
||||
void displayCityMap(QString);
|
||||
|
||||
bool createCityMap(QString);
|
||||
|
||||
@@ -83,20 +85,23 @@ private slots:
|
||||
void on_action_RegionMap_Save_triggered();
|
||||
void on_action_RegionMap_Undo_triggered();
|
||||
void on_action_RegionMap_Redo_triggered();
|
||||
void on_action_RegionMap_Resize_triggered();
|
||||
void on_tabWidget_Region_Map_currentChanged(int);
|
||||
void on_pushButton_RM_Options_save_clicked();
|
||||
void on_pushButton_RM_Options_delete_clicked();
|
||||
void on_pushButton_CityMap_save_clicked();
|
||||
void on_pushButton_CityMap_add_clicked();//
|
||||
void on_pushButton_CityMap_add_clicked();
|
||||
void on_pushButton_Zoom_In_Image_Tiles_clicked();
|
||||
void on_pushButton_Zoom_Out_Image_Tiles_clicked();
|
||||
void on_pushButton_Zoom_In_City_Tiles_clicked();
|
||||
void on_pushButton_Zoom_Out_City_Tiles_clicked();
|
||||
void on_pushButton_Zoom_In_City_Map_clicked();//
|
||||
void on_pushButton_Zoom_In_City_Map_clicked();
|
||||
void on_pushButton_Zoom_Out_City_Map_clicked();
|
||||
void on_pushButton_Zoom_In_Map_Image_clicked();
|
||||
void on_pushButton_Zoom_Out_Map_Image_clicked();//
|
||||
void on_pushButton_Zoom_Out_Map_Image_clicked();
|
||||
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
||||
void on_spinBox_RM_Options_x_valueChanged(int);
|
||||
void on_spinBox_RM_Options_y_valueChanged(int);
|
||||
void onHoveredRegionMapTileChanged(int, int);
|
||||
void onHoveredRegionMapTileCleared();
|
||||
void mouseEvent_region_map(QGraphicsSceneMouseEvent *, RegionMapPixmapItem *);
|
||||
|
||||
@@ -8,22 +8,22 @@ class RegionMapLayoutPixmapItem : public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RegionMapLayoutPixmapItem(RegionMap *rmap, TilemapTileSelector *ts) : SelectablePixmapItem(8, 8, 1, 1) {
|
||||
//
|
||||
this->region_map = rmap;
|
||||
this->tile_selector = ts;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
RegionMap *region_map;// inherited from RegionMapPixmapItem?
|
||||
RegionMap *region_map;
|
||||
TilemapTileSelector *tile_selector;
|
||||
int selectedTile;// index in map_squares
|
||||
int selectedTile;
|
||||
int highlightedTile;
|
||||
void draw();
|
||||
void select(int, int);
|
||||
void setDefaultSelection();
|
||||
void select(int);
|
||||
void highlight(int, int, int);
|
||||
|
||||
private:
|
||||
void updateSelectedTile();
|
||||
|
||||
// can I implement these if they are virtual?
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, RegionMapLayoutPixmapItem *);
|
||||
void hoveredTileChanged(int);
|
||||
|
||||
Reference in New Issue
Block a user