mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-13 20:36:19 -05:00
add region map data to config, fix some bugs
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
#include <QByteArrayList>
|
||||
#include <QSize>
|
||||
|
||||
enum MapSortOrder {
|
||||
Group = 0,
|
||||
@@ -36,6 +37,7 @@ public:
|
||||
this->metatilesZoom = 30;
|
||||
this->showPlayerView = false;
|
||||
this->showCursorTile = true;
|
||||
this->regionMapDimensions = QSize(32, 20);
|
||||
}
|
||||
void setRecentProject(QString project);
|
||||
void setRecentMap(QString map);
|
||||
@@ -46,6 +48,7 @@ public:
|
||||
void setMetatilesZoom(int zoom);
|
||||
void setShowPlayerView(bool enabled);
|
||||
void setShowCursorTile(bool enabled);
|
||||
void setRegionMapDimensions(int width, int height);
|
||||
QString getRecentProject();
|
||||
QString getRecentMap();
|
||||
MapSortOrder getMapSortOrder();
|
||||
@@ -55,6 +58,7 @@ public:
|
||||
int getMetatilesZoom();
|
||||
bool getShowPlayerView();
|
||||
bool getShowCursorTile();
|
||||
QSize getRegionMapDimensions();
|
||||
protected:
|
||||
QString getConfigFilepath();
|
||||
void parseConfigKeyValue(QString key, QString value);
|
||||
@@ -76,6 +80,7 @@ private:
|
||||
int metatilesZoom;
|
||||
bool showPlayerView;
|
||||
bool showCursorTile;
|
||||
QSize regionMapDimensions;
|
||||
};
|
||||
|
||||
extern PorymapConfig porymapConfig;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define MAPCONNECTION_H
|
||||
|
||||
#include <QString>
|
||||
#include <QHash>
|
||||
|
||||
class MapConnection {
|
||||
public:
|
||||
@@ -10,4 +11,12 @@ public:
|
||||
QString map_name;
|
||||
};
|
||||
|
||||
inline bool operator==(const MapConnection &c1, const MapConnection &c2) {
|
||||
return c1.map_name == c2.map_name;
|
||||
}
|
||||
|
||||
inline uint qHash(const MapConnection &key) {
|
||||
return qHash(key.map_name);
|
||||
}
|
||||
|
||||
#endif // MAPCONNECTION_H
|
||||
|
||||
@@ -61,9 +61,13 @@ public:
|
||||
|
||||
Project *project;
|
||||
|
||||
//QList<RegionMapSquare> map_squares;
|
||||
QVector<RegionMapSquare> map_squares;
|
||||
|
||||
const int padLeft = 1;
|
||||
const int padRight = 3;
|
||||
const int padTop = 2;
|
||||
const int padBottom = 3;
|
||||
|
||||
History<RegionMapHistoryItem*> history;
|
||||
|
||||
QString region_map_png_path;
|
||||
@@ -115,8 +119,6 @@ public:
|
||||
|
||||
void resetSquare(int);
|
||||
|
||||
void test();// remove
|
||||
|
||||
// TODO: move read / write functions to private (and others)
|
||||
private:
|
||||
int layout_width_;
|
||||
|
||||
77
include/core/regionmapgenerator.h
Normal file
77
include/core/regionmapgenerator.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef GUARD_REGIONMAPGENERATOR_H
|
||||
#define GUARD_REGIONMAPGENERATOR_H
|
||||
|
||||
#include "project.h"
|
||||
#include "regionmap.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QStack>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
|
||||
class GeneratorEntry
|
||||
{
|
||||
GeneratorEntry(QString name_, int x_, int y_, int width_, int height_) {
|
||||
this->name = name_;
|
||||
this->x = x_;
|
||||
this->y = y_;
|
||||
this->width = width_;
|
||||
this->height = height_;
|
||||
}
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
QString name;
|
||||
friend class RegionMapGenerator;
|
||||
public:
|
||||
friend QDebug operator<<(QDebug, const GeneratorEntry &);
|
||||
};
|
||||
|
||||
class RegionMapGenerator
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
RegionMapGenerator() = default;
|
||||
RegionMapGenerator(Project *);
|
||||
~RegionMapGenerator() {};
|
||||
|
||||
Project *project = nullptr;
|
||||
|
||||
QVector<RegionMapSquare> map_squares;
|
||||
|
||||
QStack<QPair<QString, int>> forks;//?
|
||||
QSet<MapConnection> connections;//
|
||||
// <MapConnection>
|
||||
|
||||
void generate(QString);
|
||||
|
||||
void center();// center the map squares so they arent hanging over
|
||||
|
||||
private:
|
||||
//
|
||||
int square_block_width_ = 20;
|
||||
int square_block_height_ = 20;
|
||||
|
||||
int width_;
|
||||
int height_;
|
||||
|
||||
//QPoint
|
||||
|
||||
QList<struct RegionMapEntry> entries_;
|
||||
QMap<QString, GeneratorEntry> entries;
|
||||
|
||||
void bfs(int);// breadth first search of a graph
|
||||
void search(int);
|
||||
void dfs(int, QVector<bool> &);// depth first search
|
||||
void sort();
|
||||
void ts();// topological sort
|
||||
void populateSquares();
|
||||
|
||||
};
|
||||
|
||||
#endif // GUARD_REGIONMAPGENERATOR_H
|
||||
@@ -47,8 +47,7 @@ public:
|
||||
Map* loadMap(QString);
|
||||
Map* getMap(QString);
|
||||
|
||||
// other options include: InGameName, PopUpName, ????
|
||||
QMap<QString, QString> *mapSecToMapHoverName;// {"MAPSEC_LITTLEROOT_TOWN" : "LITTLEROOT{NAME_END} TOWN"}
|
||||
QMap<QString, QString> *mapSecToMapHoverName;
|
||||
|
||||
QMap<QString, Tileset*> *tileset_cache = nullptr;
|
||||
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CITYMAPPIXMAPITEM_H
|
||||
|
||||
#include "tilemaptileselector.h"
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QByteArray>
|
||||
|
||||
@@ -18,10 +19,6 @@ public:
|
||||
|
||||
QString file;
|
||||
|
||||
// TODO: make private and use access functions
|
||||
int width;
|
||||
int height;
|
||||
|
||||
QByteArray data;
|
||||
|
||||
void init();
|
||||
@@ -30,10 +27,12 @@ public:
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void draw();
|
||||
int getIndexAt(int, int);
|
||||
int width();
|
||||
int height();
|
||||
|
||||
//private:
|
||||
// int width;
|
||||
// int height;
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, CityMapPixmapItem *);
|
||||
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
void loadRegionMapData();
|
||||
void loadCityMaps();
|
||||
|
||||
void onRegionMapTileSelectorSelectedTileChanged(unsigned);
|
||||
void onCityMapTileSelectorSelectedTileChanged(unsigned);
|
||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned);
|
||||
void onRegionMapTileSelectorHoveredTileCleared();
|
||||
|
||||
@@ -47,9 +49,11 @@ private:
|
||||
|
||||
History<RegionMapHistoryItem*> history;
|
||||
|
||||
int currIndex = 65;// TODO: automatic this from width * 2 + 1
|
||||
int currIndex;
|
||||
unsigned selectedCityTile;
|
||||
unsigned selectedImageTile;
|
||||
|
||||
double scaleUpFactor = 2.0;// TODO
|
||||
double scaleUpFactor = 2.0;
|
||||
double scaleDownFactor = 1.0 / scaleUpFactor;
|
||||
|
||||
double scaleRegionMapTiles = 1.0;
|
||||
@@ -86,6 +90,7 @@ private slots:
|
||||
void on_action_RegionMap_Undo_triggered();
|
||||
void on_action_RegionMap_Redo_triggered();
|
||||
void on_action_RegionMap_Resize_triggered();
|
||||
void on_action_RegionMap_Generate_triggered();
|
||||
void on_tabWidget_Region_Map_currentChanged(int);
|
||||
void on_pushButton_RM_Options_save_clicked();
|
||||
void on_pushButton_RM_Options_delete_clicked();
|
||||
|
||||
Reference in New Issue
Block a user