add region map data to config, fix some bugs

This commit is contained in:
garak
2019-01-15 17:06:18 -05:00
parent c75ce5db1d
commit 41f3780c8a
16 changed files with 399 additions and 154 deletions

View File

@@ -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

View File

@@ -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_;

View 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