Explorar el Código

Created battles_graphics.json from battleBack.txt and battleHeroes.txt.

Frank Zago hace 14 años
padre
commit
68090a4ec6
Se han modificado 4 ficheros con 77 adiciones y 64 borrados
  1. 24 18
      client/Graphics.cpp
  2. 0 25
      config/battleBack.txt
  3. 0 21
      config/battleHeroes.txt
  4. 53 0
      config/battles_graphics.json

+ 24 - 18
client/Graphics.cpp

@@ -212,27 +212,33 @@ void Graphics::loadPaletteAndColors()
 
 void Graphics::initializeBattleGraphics()
 {
-	std::ifstream bback(DATA_DIR "/config/battleBack.txt");
-	battleBacks.resize(26);
-	for(int i=1; i<26; ++i) //25 - number of terrains battle can be fought on
-	{
-		int am;
-		bback>>am;
-		battleBacks[i].resize(am);
-		for(int f=0; f<am; ++f)
-		{
-			bback>>battleBacks[i][f];
-		}
+	const JsonNode config(DATA_DIR "/config/battles_graphics.json");
+	
+	// Reserve enough space for the terrains
+	// TODO: there should be a method to count the number of elements
+	int idx = 0;
+	BOOST_FOREACH(const JsonNode &t, config["backgrounds"].Vector()) {
+		idx++;
+	}
+	battleBacks.resize(idx);
+
+	idx = 0;
+	BOOST_FOREACH(const JsonNode &t, config["backgrounds"].Vector()) {
+		battleBacks[idx].push_back(t.String());
+		idx++;
 	}
 
 	//initializing battle hero animation
-	std::ifstream bher(DATA_DIR "/config/battleHeroes.txt");
-	int numberofh;
-	bher>>numberofh;
-	battleHeroes.resize(numberofh);
-	for(int i=0; i<numberofh; ++i) //9 - number of terrains battle can be fought on
-	{
-		bher>>battleHeroes[i];
+	idx = 0;
+	BOOST_FOREACH(const JsonNode &h, config["heroes"].Vector()) {
+		idx++;
+	}
+	battleHeroes.resize(idx);
+
+	idx = 0;
+	BOOST_FOREACH(const JsonNode &h, config["heroes"].Vector()) {
+		battleHeroes[idx] = h.String();
+		idx ++;
 	}
 
 	//initialization of AC->def name mapping

+ 0 - 25
config/battleBack.txt

@@ -1,25 +0,0 @@
-1 CMBKBCH.BMP
-1 CMBKDES.BMP
-1 CMBKDRTR.BMP
-1 CMBKDRMT.BMP
-1 CMBKDRDD.BMP
-1 CMBKGRMT.BMP
-1 CMBKGRTR.BMP
-1 CMBKLAVA.BMP
-1 CMBKMAG.BMP
-1 CMBKSNMT.BMP
-1 CMBKSNTR.BMP
-1 CMBKSUB.BMP
-1 CMBKSWMP.BMP
-1 CMBKFF.BMP
-1 CMBKRK.BMP
-1 CMBKMC.BMP
-1 CMBKLP.BMP
-1 CMBKHG.BMP
-1 CMBKCF.BMP
-1 CMBKEF.BMP
-1 CMBKFW.BMP
-1 CMBKCUR.BMP
-1 CMBKRGH.BMP
-1 CMBKBOAT.BMP
-1 CMBKDECK.BMP

+ 0 - 21
config/battleHeroes.txt

@@ -1,21 +0,0 @@
-18
-CH00.DEF
-CH01.DEF
-CH02.DEF
-CH03.DEF
-CH05.DEF
-CH04.DEF
-CH06.DEF
-CH07.DEF
-CH08.DEF
-CH09.DEF
-CH010.DEF
-CH11.DEF
-CH013.DEF
-CH012.DEF
-CH014.DEF
-CH015.DEF
-CH16.DEF
-CH17.DEF
-
-hero animation used in battles, each 2 def represent male and female heroes for each race

+ 53 - 0
config/battles_graphics.json

@@ -0,0 +1,53 @@
+{
+	// backgrounds of terrains battles can be fought on
+	"backgrounds": [
+		"CMBKBCH.BMP",
+		"CMBKDES.BMP",
+		"CMBKDRTR.BMP",
+		"CMBKDRMT.BMP",
+		"CMBKDRDD.BMP",
+		"CMBKGRMT.BMP",
+		"CMBKGRTR.BMP",
+		"CMBKLAVA.BMP",
+		"CMBKMAG.BMP",
+		"CMBKSNMT.BMP",
+		"CMBKSNTR.BMP",
+		"CMBKSUB.BMP",
+		"CMBKSWMP.BMP",
+		"CMBKFF.BMP",
+		"CMBKRK.BMP",
+		"CMBKMC.BMP",
+		"CMBKLP.BMP",
+		"CMBKHG.BMP",
+		"CMBKCF.BMP",
+		"CMBKEF.BMP",
+		"CMBKFW.BMP",
+		"CMBKCUR.BMP",
+		"CMBKRGH.BMP",
+		"CMBKBOAT.BMP",
+		"CMBKDECK.BMP"
+	]
+
+	// Hero animation used in battles.
+	// Each 2 def represent male and female heroes for each race
+	"heroes": [
+		"CH00.DEF",
+		"CH01.DEF",
+		"CH02.DEF",
+		"CH03.DEF",
+		"CH05.DEF",
+		"CH04.DEF",
+		"CH06.DEF",
+		"CH07.DEF",
+		"CH08.DEF",
+		"CH09.DEF",
+		"CH010.DEF",
+		"CH11.DEF",
+		"CH013.DEF",
+		"CH012.DEF",
+		"CH014.DEF",
+		"CH015.DEF",
+		"CH16.DEF",
+		"CH17.DEF"
+	]
+}