diff --git a/forms/regionmappropertiesdialog.ui b/forms/regionmappropertiesdialog.ui
index 85f54f9c..80e7020a 100644
--- a/forms/regionmappropertiesdialog.ui
+++ b/forms/regionmappropertiesdialog.ui
@@ -31,7 +31,11 @@
-
-
+
+
+ A nickname for this region map that will differentiate it from others (should be unique).
+
+
-
@@ -58,6 +62,9 @@
-
+
+ <html><head/><body><p>The tilemap format can be either:</p><p>1) Plain (tilemap is a list of 8-bit tile indexes into the tileset)</p><p>2) 4BPP (tilemap entries are 16 bits, with x/y-flip, and palette index for 16 16-color palettes)</p><p>3) 8BPP (tilemap entries are 16 bits, with x/y-flip, single 256-color palette)</p></body></html>
+
-
plain
@@ -123,6 +130,9 @@
0
+
+ The height of the tilemap
+
255
@@ -170,6 +180,9 @@
0
+
+ <html><head/><body><p>Path to the tileset image (.png) relative to the project root.</p></body></html>
+
-
@@ -201,6 +214,9 @@
-
+
+ <html><head/><body><p>Path to the tilemap binary relative to the project root.</p></body></html>
+
QFrame::NoFrame
@@ -272,7 +288,11 @@
0
-
-
+
+
+ <html><head/><body><p>(optional) Path to the .pal JASC palette file</p></body></html>
+
+
-
@@ -308,6 +328,9 @@
0
+
+ <html><head/><body><p>The width of the tilemap</p></body></html>
+
255
@@ -334,6 +357,9 @@
-
+
+ <html><head/><body><p>The format of the layout file, can be a C array in a text file with "MAPSEC_"-prefixed constants, or a binary file where each byte is a value of some "MAPSEC_"-prefixed constant.</p></body></html>
+
-
C array
@@ -385,7 +411,11 @@
0
-
-
+
+
+ <html><head/><body><p>The path to the layout file, relative to the project root.</p></body></html>
+
+
-
@@ -443,6 +473,9 @@
0
+
+ <html><head/><body><p>The layout width.</p></body></html>
+
0
@@ -473,6 +506,9 @@
-
+
+ <html><head/><body><p>The offset from the left of the tilemap where the layout starts.</p><p>(ie, coordinate (0,0) in the layout would be (offset left, offset top) in the tilemap).</p></body></html>
+
255
@@ -540,6 +576,9 @@
0
+
+ <html><head/><body><p>The layout height.</p></body></html>
+
0
@@ -569,7 +608,11 @@
-
-
+
+
+ <html><head/><body><p>The offset from the top of the tilemap where the layout starts.</p><p>(ie, coordinate (0,0) in the layout would be (offset left, offset top) in the tilemap).</p></body></html>
+
+
-
diff --git a/include/core/regionmap.h b/include/core/regionmap.h
index 7a29c2a8..d5535138 100644
--- a/include/core/regionmap.h
+++ b/include/core/regionmap.h
@@ -181,6 +181,7 @@ private:
bool layout_uses_layers = false;
QStringList layout_constants;
QString layout_qualifiers;
+ QString layout_type;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QVector> tilemap;
diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h
index 84f16f0f..047edad7 100644
--- a/include/ui/regionmapeditor.h
+++ b/include/ui/regionmapeditor.h
@@ -93,11 +93,11 @@ private:
bool saveRegionMapEntries();
tsl::ordered_map region_map_entries;
- void buildConfigDialog();
+ bool buildConfigDialog();
poryjson::Json configRegionMapDialog();
void buildUpdateConfigDialog();
poryjson::Json buildDefaultJson();
- poryjson::Json getJsonFromAlias(QString alias);
+ bool verifyConfig(poryjson::Json cfg);
bool modified();
@@ -117,7 +117,6 @@ private:
void setRegionMap(RegionMap *map);
bool createCityMap(QString name);
- bool tryInsertNewMapEntry(QString);
void restoreWindowState();
void closeEvent(QCloseEvent* event);
diff --git a/resources/text/region_map_default_ruby.json b/resources/text/region_map_default_ruby.json
index e69de29b..4fcaa555 100644
--- a/resources/text/region_map_default_ruby.json
+++ b/resources/text/region_map_default_ruby.json
@@ -0,0 +1,22 @@
+{
+ "region_maps": [
+ {
+ "alias": "hoenn",
+ "tilemap": {
+ "width": 64,
+ "height": 64,
+ "format": "plain",
+ "tileset_path": "graphics/pokenav/region_map.png",
+ "tilemap_path": "graphics/pokenav/region_map_map.bin"
+ },
+ "layout": {
+ "width": 28,
+ "height": 15,
+ "offset_left": 1,
+ "offset_top": 2,
+ "format": "C array",
+ "path": "src/data/region_map/region_map_layout.h"
+ }
+ }
+ ]
+}
diff --git a/src/core/regionmap.cpp b/src/core/regionmap.cpp
index 6297b63e..509c46ee 100644
--- a/src/core/regionmap.cpp
+++ b/src/core/regionmap.cpp
@@ -15,13 +15,7 @@
using std::make_shared;
-static bool ensureRegionMapFileExists(QString filepath) {
- if (!QFile::exists(filepath)) {
- logError(QString("Region map file does not exist: %1").arg(filepath));
- return false;
- }
- return true;
-}
+
RegionMap::RegionMap(Project *project) {
this->project = project;
@@ -39,8 +33,7 @@ bool RegionMap::loadMapData(poryjson::Json data) {
this->layout_layers.clear();
this->layouts.clear();
- loadTilemap(tilemapJson);
- loadLayout(layoutJson);
+ return loadTilemap(tilemapJson) && loadLayout(layoutJson);
}
int RegionMap::tilemapBytes() {
@@ -166,8 +159,6 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
}
case LayoutFormat::CArray:
{
- // TODO: pokeruby / non-layered style C array or just an array of mapsections
-
ParseUtil parser;
QString text = parser.readTextFile(fullPath(this->layout_path));
@@ -228,8 +219,46 @@ bool RegionMap::loadLayout(poryjson::Json layoutJson) {
}
} else {
- logError("Region map layout is not readable.");
- return false;
+ // try single-layered
+ QRegularExpression reAlt("(?static)?\\s?(?const)?\\s?(?[A-Za-z0-9_]+)?\\s+(?