diff --git a/client/CAdvmapInterface.cpp b/client/CAdvmapInterface.cpp index 057d1b3e7..47123bc16 100644 --- a/client/CAdvmapInterface.cpp +++ b/client/CAdvmapInterface.cpp @@ -19,6 +19,7 @@ #include "../lib/CObjectHandler.h" #include "../lib/CTownHandler.h" #include "../lib/map.h" +#include "../lib/JsonNode.h" #include "mapHandler.h" #include "../stdafx.h" #include @@ -60,42 +61,40 @@ CMinimap::CMinimap(bool draw) int3 mapSizes = LOCPLINT->cb->getMapSize(); statusbarTxt = CGI->generaltexth->zelp[291].first; rcText = CGI->generaltexth->zelp[291].second; - pos.x=ADVOPT.minimapX;//630 - pos.y=ADVOPT.minimapY;//26 - pos.h=ADVOPT.minimapW;//144 - pos.w=ADVOPT.minimapH;//144 + pos.x=ADVOPT.minimapX; + pos.y=ADVOPT.minimapY; + pos.h=ADVOPT.minimapW; + pos.w=ADVOPT.minimapH; temps = newSurface(pos.w,pos.h); - std::ifstream is(DATA_DIR "/config/minimap.txt",std::ifstream::in); - for (int i=0;i vinya; - std::pair vinya2; - int pom; - is >> pom; - vinya2.first=vinya.first=pom; - is >> pom; - vinya.second.r=pom; - is >> pom; - vinya.second.g=pom; - is >> pom; - vinya.second.b=pom; - is >> pom; - vinya2.second.r=pom; - is >> pom; - vinya2.second.g=pom; - is >> pom; - vinya2.second.b=pom; - vinya.second.unused=vinya2.second.unused=255; + + vinya.first = m["terrain_id"].Float(); + + const JsonVector &unblocked_vec = m["unblocked"].Vector(); + vinya.second.r = unblocked_vec[0].Float(); + vinya.second.g = unblocked_vec[1].Float(); + vinya.second.b = unblocked_vec[2].Float(); + vinya.second.unused = 255; colors.insert(vinya); - colorsBlocked.insert(vinya2); + + const JsonVector &blocked_vec = m["blocked"].Vector(); + vinya.second.r = blocked_vec[0].Float(); + vinya.second.g = blocked_vec[1].Float(); + vinya.second.b = blocked_vec[2].Float(); + vinya.second.unused = 255; + colorsBlocked.insert(vinya); } - is.close(); if (draw) redraw(); } + CMinimap::~CMinimap() { SDL_FreeSurface(temps); diff --git a/config/minimap.json b/config/minimap.json new file mode 100644 index 000000000..e5575bb23 --- /dev/null +++ b/config/minimap.json @@ -0,0 +1,16 @@ +{ + "MinimapColors": + // Colors of terrain in minimap, in RGB format + [ + { "name": "Dirt", "terrain_id": 0, "unblocked": [ 82, 56, 8 ], "blocked": [ 57, 40, 8 ] }, + { "name": "Sand", "terrain_id": 1, "unblocked": [ 222, 207, 140 ], "blocked": [ 165, 158, 107 ] }, + { "name": "Grass", "terrain_id": 2, "unblocked": [ 0, 65, 0 ], "blocked": [ 0, 48, 0 ] }, + { "name": "Snow", "terrain_id": 3, "unblocked": [ 181, 199, 198 ], "blocked": [ 140, 158, 156 ] }, + { "name": "Swamp", "terrain_id": 4, "unblocked": [ 74, 134, 107 ], "blocked": [ 33, 89, 66 ] }, + { "name": "Rough", "terrain_id": 5, "unblocked": [ 132, 113, 49 ], "blocked": [ 99, 81, 33 ] }, + { "name": "Subterranean", "terrain_id": 6, "unblocked": [ 132, 48, 0 ], "blocked": [ 90, 8, 0 ] }, + { "name": "Lava", "terrain_id": 7, "unblocked": [ 74, 73, 74 ], "blocked": [ 41, 40, 41 ] }, + { "name": "Water", "terrain_id": 8, "unblocked": [ 8, 81, 148 ], "blocked": [ 8, 81, 148 ] }, + { "name": "Rock", "terrain_id": 9, "unblocked": [ 0, 0, 0 ], "blocked": [ 0, 0, 0 ] } + ] +} diff --git a/config/minimap.txt b/config/minimap.txt deleted file mode 100644 index 895ffbe65..000000000 --- a/config/minimap.txt +++ /dev/null @@ -1,26 +0,0 @@ -0 82 56 8 57 40 8 -1 222 207 140 165 158 107 -2 0 65 0 0 48 0 -3 181 199 198 140 158 156 -4 74 134 107 33 89 66 -5 132 113 49 99 81 33 -6 132 48 0 90 8 0 -7 74 73 74 41 40 41 -8 8 81 148 8 81 148 -9 0 0 0 0 0 0 - -//end of data -Colors of terrain in minimap -Terrain_ID Unblocked_R Unblocked_G Unblocked_B Blocked_R Blocked_G Blocked_B -(all values are decimal) -Terrain types: -00 Dirt -01 Sand -02 Grass -03 Snow -04 Swamp -05 Rough -06 Subterranean -07 Lava -08 Water -09 Rock \ No newline at end of file