Bladeren bron

Created campaign_regions.json from campaign_regions.txt.

Frank Zago 14 jaren geleden
bovenliggende
commit
eff17aa850
3 gewijzigde bestanden met toevoegingen van 252 en 149 verwijderingen
  1. 18 18
      client/CPreGame.cpp
  2. 234 0
      config/campaign_regions.json
  3. 0 131
      config/campaign_regions.txt

+ 18 - 18
client/CPreGame.cpp

@@ -19,6 +19,7 @@
 #include "../lib/CObjectHandler.h"
 #include "../lib/CObjectHandler.h"
 #include "../lib/CCampaignHandler.h"
 #include "../lib/CCampaignHandler.h"
 #include "../lib/CCreatureHandler.h"
 #include "../lib/CCreatureHandler.h"
+#include "../lib/JsonNode.h"
 #include "CMusicHandler.h"
 #include "CMusicHandler.h"
 #include "CVideoHandler.h"
 #include "CVideoHandler.h"
 #include <cmath>
 #include <cmath>
@@ -27,6 +28,7 @@
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
 #include <boost/function.hpp>
 #include <boost/ref.hpp>
 #include <boost/ref.hpp>
+#include <boost/foreach.hpp>
 #include <cstdlib>
 #include <cstdlib>
 #include "../lib/Connection.h"
 #include "../lib/Connection.h"
 #include "../lib/VCMIDirs.h"
 #include "../lib/VCMIDirs.h"
@@ -2701,34 +2703,32 @@ void CBonusSelection::showAll( SDL_Surface * to )
 
 
 void CBonusSelection::loadPositionsOfGraphics()
 void CBonusSelection::loadPositionsOfGraphics()
 {
 {
-	std::ifstream is(DATA_DIR "/config/campaign_regions.txt", std::ios_base::binary | std::ios_base::in);
+	const JsonNode config(DATA_DIR "/config/campaign_regions.json");
+	int idx = 0;
 
 
-	assert(is.is_open());
-
-	for (int g=0; g<CGI->generaltexth->campaignMapNames.size(); ++g)
+	BOOST_FOREACH(const JsonNode &campaign, config["campaign_regions"].Vector())
 	{
 	{
 		SCampPositions sc;
 		SCampPositions sc;
-		is >> sc.campPrefix;
-		is >> sc.colorSuffixLength;
-		bool contReading = true;
-		while(contReading)
+
+		sc.campPrefix = campaign["prefix"].String();
+		sc.colorSuffixLength = campaign["color_suffix_length"].Float();
+
+		BOOST_FOREACH(const JsonNode &desc,  campaign["desc"].Vector())
 		{
 		{
 			SCampPositions::SRegionDesc rd;
 			SCampPositions::SRegionDesc rd;
-			is >> rd.infix;
-			if(rd.infix == "END")
-			{
-				contReading = false;
-			}
-			else
-			{
-				is >> rd.xpos >> rd.ypos;
-				sc.regions.push_back(rd);
-			}
+
+			rd.infix = desc["infix"].String();
+			rd.xpos = desc["x"].Float();
+			rd.ypos = desc["y"].Float();
+			sc.regions.push_back(rd);
 		}
 		}
 
 
 		campDescriptions.push_back(sc);
 		campDescriptions.push_back(sc);
+
+		idx++;
 	}
 	}
 
 
+	assert(idx == CGI->generaltexth->campaignMapNames.size());
 }
 }
 
 
 void CBonusSelection::selectMap( int whichOne )
 void CBonusSelection::selectMap( int whichOne )

+ 234 - 0
config/campaign_regions.json

@@ -0,0 +1,234 @@
+{
+	"campaign_regions": [
+		{
+			"prefix": "E1",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 270, "y": 332 },
+				{ "infix": "B", "x": 138, "y": 113 },
+				{ "infix": "C", "x": 26, "y": 70 },
+				{ "infix": "P1", "x": 256, "y": 127 },
+				{ "infix": "P2", "x": 57, "y": 314 },
+				{ "infix": "P3", "x": 137, "y": 310 },
+				{ "infix": "P4", "x": 44, "y": 163 }
+			]
+		},
+
+		{
+			"prefix": "G2",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 56, "y": 90 },
+				{ "infix": "B", "x": 316, "y": 49 },
+				{ "infix": "C", "x": 54, "y": 378 },
+				{ "infix": "D", "x": 151, "y": 126 }
+			]
+		},
+
+		{
+			"prefix": "E2",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 131, "y": 202 },
+				{ "infix": "B", "x": 60, "y": 145 },
+				{ "infix": "C", "x": 92, "y": 261 },
+				{ "infix": "D", "x": 218, "y": 307 }
+			]
+		},
+
+		{
+			"prefix": "G1",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 57, "y": 314 },
+				{ "infix": "B", "x": 137, "y": 309 },
+				{ "infix": "C", "x": 44, "y": 163 }
+			]
+		},
+
+		{
+			"prefix": "G3",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 289, "y": 376 },
+				{ "infix": "B", "x": 60, "y": 147 },
+				{ "infix": "C", "x": 131, "y": 202 }
+			]
+		},
+
+		{
+			"prefix": "N1",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 42, "y": 94 },
+				{ "infix": "B", "x": 309, "y": 290 },
+				{ "infix": "CD", "x": 188, "y": 202 }
+			]
+		},
+
+		{
+			"prefix": "S1",
+			"color_suffix_length": 1,
+			"desc": [
+				{ "infix": "A", "x": 263, "y": 199 },
+				{ "infix": "B", "x": 182, "y": 210 },
+				{ "infix": "C", "x": 82, "y": 152 }
+			]
+		},
+
+		{
+			"prefix": "BR",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 18, "y": 233 },
+				{ "infix": "B", "x": 125, "y": 381 },
+				{ "infix": "C", "x": 224, "y": 357 },
+				{ "infix": "D", "x": 192, "y": 320 }
+			]
+		},
+
+		{
+			"prefix": "IS",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 294, "y": 399 },
+				{ "infix": "B", "x": 183, "y": 293 },
+				{ "infix": "C", "x": 40, "y": 92 },
+				{ "infix": "D", "x": 294, "y": 398 }
+			]
+		},
+
+		{
+			"prefix": "KR",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 148, "y": 323 },
+				{ "infix": "B", "x": 192, "y": 235 },
+				{ "infix": "C", "x": 136, "y": 158 },
+				{ "infix": "D", "x": 87, "y": 107 }
+			]
+		},
+
+		{
+			"prefix": "NI",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 118, "y": 111 },
+				{ "infix": "B", "x": 223, "y": 145 },
+				{ "infix": "C", "x": 320, "y": 213 },
+				{ "infix": "D", "x": 233, "y": 250 }
+			]
+		},
+
+		{
+			"prefix": "TA",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 228, "y": 233 },
+				{ "infix": "B", "x": 147, "y": 194 },
+				{ "infix": "C", "x": 112, "y": 97 }
+			]
+		},
+
+		{
+			"prefix": "AR",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 135, "y": 238 },
+				{ "infix": "B", "x": 135, "y": 121 },
+				{ "infix": "C", "x": 206, "y": 155 },
+				{ "infix": "D", "x": 105, "y": 397 },
+				{ "infix": "E", "x": 109, "y": 275 },
+				{ "infix": "F", "x": 158, "y": 188 },
+				{ "infix": "G", "x": 200, "y": 261 },
+				{ "infix": "H", "x": 232, "y": 197 }
+			]
+		},
+
+		{
+			"prefix": "HS",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 140, "y": 326 },
+				{ "infix": "B", "x": 238, "y": 275 },
+				{ "infix": "C", "x": 22, "y": 161 },
+				{ "infix": "D", "x": 5, "y": 9 }
+			]
+		},
+
+		{
+			"prefix": "BB",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 167, "y": 342 },
+				{ "infix": "B", "x": 217, "y": 263 },
+				{ "infix": "C", "x": 0, "y": 71 },
+				{ "infix": "D", "x": 291, "y": 79 },
+				{ "infix": "E", "x": 316, "y": 199 }
+			]
+		},
+
+		{
+			"prefix": "NB",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 6, "y": 292 },
+				{ "infix": "B", "x": 161, "y": 334 },
+				{ "infix": "C", "x": 63, "y": 195 },
+				{ "infix": "D", "x": 56, "y": 46 }
+			]
+		},
+
+		{
+			"prefix": "EL",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 11, "y": 73 },
+				{ "infix": "B", "x": 0, "y": 241 },
+				{ "infix": "C", "x": 254, "y": 34 },
+				{ "infix": "D", "x": 91, "y": 144 }
+			]
+		},
+
+		{
+			"prefix": "RN",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 84, "y": 319 },
+				{ "infix": "B", "x": 194, "y": 275 },
+				{ "infix": "C", "x": 67, "y": 185 },
+				{ "infix": "D", "x": 77, "y": 30 }
+			]
+		},
+
+		{
+			"prefix": "UA",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 157, "y": 409 },
+				{ "infix": "B", "x": 62, "y": 346 },
+				{ "infix": "C", "x": 8, "y": 8 },
+				{ "infix": "D", "x": 206, "y": 1 },
+				{ "infix": "E", "x": 132, "y": 357 },
+				{ "infix": "F", "x": 184, "y": 83 },
+				{ "infix": "G", "x": 159, "y": 263 },
+				{ "infix": "H", "x": 108, "y": 173 },
+				{ "infix": "I", "x": 55, "y": 127 },
+				{ "infix": "J", "x": 9, "y": 252 },
+				{ "infix": "K", "x": 210, "y": 176 },
+				{ "infix": "L", "x": 260, "y": 210 }
+			]
+		},
+
+		{
+			"prefix": "SP",
+			"color_suffix_length": 2,
+			"desc": [
+				{ "infix": "A", "x": 7, "y": 295 },
+				{ "infix": "B", "x": 44, "y": 141 },
+				{ "infix": "C", "x": 141, "y": 21 },
+				{ "infix": "D", "x": 243, "y": 156 }
+			]
+		}
+	]
+}

+ 0 - 131
config/campaign_regions.txt

@@ -1,131 +0,0 @@
-E1 1
-A 270 332
-B 138 113
-C 26 70
-P1 256 127
-P2 57 314
-P3 137 310
-P4 44 163
-END
-G2 1
-A 56 90
-B 316 49
-C 54 378
-D 151 126
-END
-E2 1
-A 131 202
-B 60 145
-C 92 261
-D 218 307
-END
-G1 1
-A 57 314
-B 137 309
-C 44 163
-END
-G3 1
-A 289 376
-B 60 147
-C 131 202
-END
-N1 1
-A 42 94
-B 309 290
-CD 188 202
-END
-S1 1
-A 263 199
-B 182 210
-C 82 152
-END
-BR 2
-A 18 233
-B 125 381
-C 224 357
-D 192 320
-END
-IS 2
-A 294 399
-B 183 293
-C 40 92
-D 294 398
-END
-KR 2
-A 148 323
-B 192 235
-C 136 158
-D 87 107
-END
-NI 2
-A 118 111
-B 223 145
-C 320 213
-D 233 250
-END
-TA 2
-A 228 233
-B 147 194
-C 112 97
-END
-AR 2
-A 135 238
-B 135 121
-C 206 155
-D 105 397
-E 109 275
-F 158 188
-G 200 261
-H 232 197
-END
-HS 2
-A 140 326
-B 238 275
-C 22 161
-D 5 9
-END
-BB 2
-A 167 342
-B 217 263
-C 0 71
-D 291 79
-E 316 199
-END
-NB 2
-A 6 292
-B 161 334
-C 63 195
-D 56 46
-END
-EL 2
-A 11 73
-B 0 241
-C 254 34
-D 91 144
-END
-RN 2
-A 84 319
-B 194 275
-C 67 185
-D 77 30
-END
-UA 2
-A 157 409
-B 62 346
-C 8 8
-D 206 1
-E 132 357
-F 184 83
-G 159 263
-H 108 173
-I 55 127
-J 9 252
-K 210 176
-L 260 210
-END
-SP 2
-A 7 295
-B 44 141
-C 141 21
-D 243 156
-END