فهرست منبع

allow to position spells in mage guild

Laserlicht 4 ماه پیش
والد
کامیت
fac8fb5952

+ 11 - 8
client/windows/CCastleInterface.cpp

@@ -2141,20 +2141,23 @@ void CMageGuildScreen::updateSpells(ObjectInstanceID tID)
 		return;
 
 	OBJECT_CONSTRUCTION;
-	static const std::vector<std::vector<Point> > positions =
-	{
-		{Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445)},
-		{Point(48,53),   Point(48,147),  Point(48,241),  Point(48,335),  Point(48,429)},
-		{Point(570,82),  Point(672,82),  Point(570,157), Point(672,157)},
-		{Point(183,42),  Point(183,148), Point(183,253)},
-		{Point(491,325), Point(591,325)}//
-	};
 
 	spells.clear();
 	emptyScrolls.clear();
 
 	const CGTownInstance * town = GAME->interface()->cb->getTown(townId);
 
+	auto positions = town->getTown()->clientInfo.guildSpellPositions;
+	if(!positions.size()) // TODO: remove legacy for compatibility
+		positions =
+		{
+			{Point(222,445), Point(312,445), Point(402,445), Point(520,445), Point(610,445), Point(700,445)},
+			{Point(48,53),   Point(48,147),  Point(48,241),  Point(48,335),  Point(48,429)},
+			{Point(570,82),  Point(672,82),  Point(570,157), Point(672,157)},
+			{Point(183,42),  Point(183,148), Point(183,253)},
+			{Point(491,325), Point(591,325)}
+		};
+
 	for(uint32_t i=0; i<town->getTown()->mageLevel; i++)
 	{
 		uint32_t spellCount = town->spellsAtLevel(i+1,false); //spell at level with -1 hmmm?

+ 6 - 0
config/factions/castle.json

@@ -147,6 +147,12 @@
 			],
 			"horde" : [ 2, -1 ],
 			"mageGuild" : 4,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ]
+			],
 			"moatAbility" : "castleMoat",
 			// primaryResource not specified so town get both Wood and Ore for resource bonus
 

+ 9 - 2
config/factions/conflux.json

@@ -127,8 +127,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBELBACK.bmp",
+			"guildWindow": [ "TPMAGEEL.bmp" ],
 			"buildingsIcons": "HALLELEM.DEF",
 			"hallBackground": "TPTHBKFR.BMP",
 			"hallSlots":
@@ -151,6 +151,13 @@
 			],
 			"horde" : [ 0, -1 ],
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"primaryResource" : "mercury",
 			"moatAbility" : "castleMoat",
 

+ 9 - 2
config/factions/dungeon.json

@@ -123,8 +123,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBDNBACK.bmp",
+			"guildWindow": [ "TPMAGEDN.bmp" ],
 			"buildingsIcons": "HALLDUNG.DEF",
 			"hallBackground": "TPTHBKDG.BMP",
 			"hallSlots":
@@ -147,6 +147,13 @@
 			],
 			"horde" : [ 0, -1 ],
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"primaryResource" : "sulfur",
 			"moatAbility" : "dungeonMoat",
 

+ 7 - 2
config/factions/fortress.json

@@ -123,8 +123,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBFRBACK.bmp",
+			"guildWindow": [ "TPMAGEFR.bmp" ],
 			"buildingsIcons": "HALLFORT.DEF",
 			"hallBackground": "TPTHBKFR.BMP",
 			"hallSlots":
@@ -147,6 +147,11 @@
 			],
 			"horde" : [ 0, -1 ],
 			"mageGuild" : 3,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ]
+			],
 			"moatAbility" : "fortressMoat",
 			// primaryResource not specified so town get both Wood and Ore for resource bonus
 

+ 9 - 2
config/factions/inferno.json

@@ -124,8 +124,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBINBACK.bmp",
+			"guildWindow": [ "TPMAGEIN.bmp" ],
 			"buildingsIcons": "HALLINFR.DEF",
 			"hallBackground": "TPTHBKIN.BMP",
 			"hallSlots":
@@ -148,6 +148,13 @@
 			],
 			"horde" : [ 0, 2 ],
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"primaryResource" : "mercury",
 			"moatAbility" : "infernoMoat",
 

+ 9 - 2
config/factions/necropolis.json

@@ -128,8 +128,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBNCBACK.bmp",
+			"guildWindow": [ "TPMAGENC.bmp" ],
 			"buildingsIcons": "HALLNECR.DEF",
 			"hallBackground": "TPTHBKNC.BMP",
 			"hallSlots":
@@ -152,6 +152,13 @@
 			],
 			"horde" : [ 0, -1 ],
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"moatAbility" : "necropolisMoat",
 			// primaryResource not specified so town get both Wood and Ore for resource bonus
 

+ 9 - 2
config/factions/rampart.json

@@ -127,8 +127,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBRMBACK.bmp",
+			"guildWindow": [ "TPMAGERM.bmp" ],
 			"buildingsIcons": "HALLRAMP.DEF",
 			"hallBackground": "TPTHBKRM.BMP",
 			"hallSlots":
@@ -151,6 +151,13 @@
 			],
 			"horde" : [ 1, 4 ],
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"primaryResource" : "crystal",
 			"moatAbility" : "rampartMoat",
 

+ 7 - 2
config/factions/stronghold.json

@@ -121,8 +121,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBSTBACK.bmp",
+			"guildWindow": [ "TPMAGEST.bmp" ],
 			"buildingsIcons": "HALLSTRN.DEF",
 			"hallBackground": "TPTHBKTW.BMP",
 			"hallSlots":
@@ -145,6 +145,11 @@
 			],
 			"horde" : [ 0, -1 ],
 			"mageGuild" : 3,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ]
+			],
 			"moatAbility" : "strongholdMoat",
 			// primaryResource not specified so town get both Wood and Ore for resource bonus
 

+ 9 - 2
config/factions/tower.json

@@ -122,8 +122,8 @@
 			"defaultTavern" : 5,
 			"tavernVideo" : "TAVERN.BIK",
 			"guildBackground" : [ "TPMAGE.bmp" ],
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": [ "TPMAGECS.bmp" ],
+			"townBackground": "TBTWBACK.bmp",
+			"guildWindow": [ "TPMAGETW.bmp" ],
 			"buildingsIcons": "HALLTOWR.DEF",
 			"hallBackground": "TPTHBKTW.BMP",
 			"hallSlots":
@@ -147,6 +147,13 @@
 			"horde" : [ 1, -1 ],
 			"primaryResource" : "gems",
 			"mageGuild" : 5,
+			"guildSpellPositions" : [
+				[ { "x": 222, "y": 445 }, { "x": 312, "y": 445 }, { "x": 402, "y": 445 }, { "x": 520, "y": 445 }, { "x": 610, "y": 445 }, { "x": 700, "y": 445 } ],
+				[ { "x":  48, "y":  53 }, { "x":  48, "y": 147 }, { "x":  48, "y": 241 }, { "x":  48, "y": 335 }, { "x":  48, "y": 429 } ],
+				[ { "x": 570, "y":  82 }, { "x": 672, "y":  82 }, { "x": 570, "y": 157 }, { "x": 672, "y": 157 } ],
+				[ { "x": 183, "y":  42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ],
+				[ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ]
+			],
 			"moatAbility" : "towerMoat",
 
 			"buildings" :

+ 19 - 1
config/schemas/faction.json

@@ -183,6 +183,24 @@
 						"format" : "imageFile"
 					}
 				},
+				"guildSpellPositions" : {
+					"type" : "array",
+					"description" : "Positions of spells in mage guild",
+					"items" : { 
+						"type" : "array",
+						"items" : { 
+							"type" : "array",
+							"items" : {
+								"type" : "object",
+								"additionalProperties" : false,
+								"properties" : {
+									"x" :     { "type" : "number", "description" : "X coordinate on screen" },
+									"y" :     { "type" : "number", "description" : "Y coordinate on screen" }
+								}
+							}
+						}
+					}
+				},
 				"hallBackground" : {
 					"type" : "string",
 					"description" : "background image for town hall",
@@ -268,7 +286,7 @@
 						"properties" : {
 							"index" : { "type" : "number", "description" : "Order in which images will be opened" },
 							"x" :     { "type" : "number", "description" : "X coordinate on screen" },
-							"y" :     { "type" : "number", "description" : "X coordinate on screen" }
+							"y" :     { "type" : "number", "description" : "Y coordinate on screen" }
 						}
 					}
 				},

+ 1 - 0
lib/entities/faction/CTown.h

@@ -90,6 +90,7 @@ public:
 		ImagePath townBackground;
 		std::vector<ImagePath> guildBackground;
 		std::vector<ImagePath> guildWindow;
+		std::vector<std::vector<Point>> guildSpellPositions;
 		AnimationPath buildingsIcons;
 		ImagePath hallBackground;
 		/// vector[row][column] = list of buildings in this slot

+ 15 - 17
lib/entities/faction/CTownHandler.cpp

@@ -561,35 +561,33 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source) const
 	readIcon(source["icons"]["fort"]["normal"], info.iconSmall[1][0], info.iconLarge[1][0]);
 	readIcon(source["icons"]["fort"]["built"], info.iconSmall[1][1], info.iconLarge[1][1]);
 
-	if (source["musicTheme"].isVector())
-	{
-		for (auto const & entry : source["musicTheme"].Vector())
-			info.musicTheme.push_back(AudioPath::fromJson(entry));
-	}
-	else
-	{
-		info.musicTheme.push_back(AudioPath::fromJson(source["musicTheme"]));
-	}
-
 	info.hallBackground = ImagePath::fromJson(source["hallBackground"]);
 	info.townBackground = ImagePath::fromJson(source["townBackground"]);
 	info.buildingsIcons = AnimationPath::fromJson(source["buildingsIcons"]);
 	info.tavernVideo = VideoPath::fromJson(source["tavernVideo"]);
 
-	auto loadStringOrVector = [](auto & target, auto & node){
+	info.guildSpellPositions.clear();
+	for(auto & level : source["guildSpellPositions"].Vector())
+	{
+		std::vector<Point> points;
+		for(auto & item : level.Vector())
+			points.push_back(Point(item["x"].Integer(), item["y"].Integer()));
+		info.guildSpellPositions.push_back(points);
+	}
+
+	auto loadStringOrVector = [](auto & target, auto & node, auto fromJsonFunc){
 		if(node.isVector())
 		{
 			target.clear();
 			for(auto & background : node.Vector())
-			{
-				target.push_back(ImagePath::fromJson(background));
-			}
+				target.push_back(fromJsonFunc(background));
 		}
 		else
-			target = {ImagePath::fromJson(node)};
+			target = {fromJsonFunc(node)};
 	};
-	loadStringOrVector(info.guildBackground, source["guildBackground"]);
-	loadStringOrVector(info.guildWindow, source["guildWindow"]);
+	loadStringOrVector(info.musicTheme, source["musicTheme"], AudioPath::fromJson);
+	loadStringOrVector(info.guildBackground, source["guildBackground"], ImagePath::fromJson);
+	loadStringOrVector(info.guildWindow, source["guildWindow"], ImagePath::fromJson);
 
 	loadTownHall(town,   source["hallSlots"]);
 	loadStructures(town, source["structures"]);