1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Convert minimap.txt to a json file.

This commit is contained in:
Frank Zago 2011-08-26 00:29:37 +00:00
parent 4725cfbf68
commit 06ca4a7c76
3 changed files with 41 additions and 52 deletions

View File

@ -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 <boost/algorithm/string.hpp>
@ -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<TERRAIN_TYPES;i++)
{
const JsonNode config(DATA_DIR "/config/minimap.json");
const JsonVector &minimap_vec = config["MinimapColors"].Vector();
BOOST_FOREACH(const JsonNode &m, minimap_vec) {
std::pair<int,SDL_Color> vinya;
std::pair<int,SDL_Color> 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);

16
config/minimap.json Normal file
View File

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

View File

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