From 14f0b82f17bb24fb945e45440ab4e4cf7db97068 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Thu, 19 Jun 2025 19:48:02 +0200 Subject: [PATCH] configurable window position --- client/windows/CCastleInterface.cpp | 5 ++++- config/factions/castle.json | 1 + config/factions/conflux.json | 1 + config/factions/dungeon.json | 1 + config/factions/fortress.json | 1 + config/factions/inferno.json | 1 + config/factions/necropolis.json | 1 + config/factions/rampart.json | 1 + config/factions/stronghold.json | 1 + config/factions/tower.json | 1 + config/schemas/faction.json | 11 +++++++++++ lib/entities/faction/CTown.h | 1 + lib/entities/faction/CTownHandler.cpp | 1 + 13 files changed, 26 insertions(+), 1 deletion(-) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 1dfdc7932..4e53c322a 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -2120,7 +2120,10 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner, const ImagePath & i assert(guildWindow.size() == 1 || guildWindow.size() == GAME->interface()->castleInt->town->getTown()->mageLevel); auto selectedGuildWindow = guildWindow.size() == 1 ? guildWindow[0] : guildWindow[owner->town->mageGuildLevel() - 1]; - window = std::make_shared(selectedGuildWindow, 332, 76); + auto windowPosition = owner->town->getTown()->clientInfo.guildWindowPosition; + if(windowPosition == Point(0, 0)) // TODO: remove legacy for compatibility + windowPosition = Point(332, 76); + window = std::make_shared(selectedGuildWindow, windowPosition.x, windowPosition.y); resdatabar = std::make_shared(); resdatabar->moveBy(pos.topLeft(), true); diff --git a/config/factions/castle.json b/config/factions/castle.json index 35b94e04b..1c09793d5 100644 --- a/config/factions/castle.json +++ b/config/factions/castle.json @@ -153,6 +153,7 @@ [ { "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 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "moatAbility" : "castleMoat", // primaryResource not specified so town get both Wood and Ore for resource bonus diff --git a/config/factions/conflux.json b/config/factions/conflux.json index a6c7f7568..24d8c1b2f 100644 --- a/config/factions/conflux.json +++ b/config/factions/conflux.json @@ -158,6 +158,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "primaryResource" : "mercury", "moatAbility" : "castleMoat", diff --git a/config/factions/dungeon.json b/config/factions/dungeon.json index 037b79790..ec860b248 100644 --- a/config/factions/dungeon.json +++ b/config/factions/dungeon.json @@ -154,6 +154,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "primaryResource" : "sulfur", "moatAbility" : "dungeonMoat", diff --git a/config/factions/fortress.json b/config/factions/fortress.json index 37485b94f..dcd5f19fd 100644 --- a/config/factions/fortress.json +++ b/config/factions/fortress.json @@ -152,6 +152,7 @@ [ { "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 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "moatAbility" : "fortressMoat", // primaryResource not specified so town get both Wood and Ore for resource bonus diff --git a/config/factions/inferno.json b/config/factions/inferno.json index 79f4b6649..d4da7481d 100644 --- a/config/factions/inferno.json +++ b/config/factions/inferno.json @@ -155,6 +155,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "primaryResource" : "mercury", "moatAbility" : "infernoMoat", diff --git a/config/factions/necropolis.json b/config/factions/necropolis.json index 724b50b64..445b64231 100644 --- a/config/factions/necropolis.json +++ b/config/factions/necropolis.json @@ -159,6 +159,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "moatAbility" : "necropolisMoat", // primaryResource not specified so town get both Wood and Ore for resource bonus diff --git a/config/factions/rampart.json b/config/factions/rampart.json index 753254f6e..dfb661188 100644 --- a/config/factions/rampart.json +++ b/config/factions/rampart.json @@ -158,6 +158,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "primaryResource" : "crystal", "moatAbility" : "rampartMoat", diff --git a/config/factions/stronghold.json b/config/factions/stronghold.json index d34b6e2d8..8ff08f5b0 100644 --- a/config/factions/stronghold.json +++ b/config/factions/stronghold.json @@ -150,6 +150,7 @@ [ { "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 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "moatAbility" : "strongholdMoat", // primaryResource not specified so town get both Wood and Ore for resource bonus diff --git a/config/factions/tower.json b/config/factions/tower.json index 588b40722..9fbf48421 100644 --- a/config/factions/tower.json +++ b/config/factions/tower.json @@ -154,6 +154,7 @@ [ { "x": 183, "y": 42 }, { "x": 183, "y": 148 }, { "x": 183, "y": 253 } ], [ { "x": 491, "y": 325 }, { "x": 591, "y": 325 } ] ], + "guildWindowPosition": { "x": 332, "y": 76 }, "moatAbility" : "towerMoat", "buildings" : diff --git a/config/schemas/faction.json b/config/schemas/faction.json index 09c99a5a5..55217a336 100644 --- a/config/schemas/faction.json +++ b/config/schemas/faction.json @@ -183,6 +183,17 @@ "format" : "imageFile" } }, + "guildWindowPosition" : { + "type" : "array", + "items" : { + "type" : "object", + "additionalProperties" : false, + "properties" : { + "x" : { "type" : "number", "description" : "X coordinate on screen" }, + "y" : { "type" : "number", "description" : "Y coordinate on screen" } + } + } + }, "guildSpellPositions" : { "type" : "array", "description" : "Positions of spells in mage guild", diff --git a/lib/entities/faction/CTown.h b/lib/entities/faction/CTown.h index 67f19367d..1d9b77842 100644 --- a/lib/entities/faction/CTown.h +++ b/lib/entities/faction/CTown.h @@ -90,6 +90,7 @@ public: ImagePath townBackground; std::vector guildBackground; std::vector guildWindow; + Point guildWindowPosition; std::vector> guildSpellPositions; AnimationPath buildingsIcons; ImagePath hallBackground; diff --git a/lib/entities/faction/CTownHandler.cpp b/lib/entities/faction/CTownHandler.cpp index 085af5ad2..8376d47a6 100644 --- a/lib/entities/faction/CTownHandler.cpp +++ b/lib/entities/faction/CTownHandler.cpp @@ -565,6 +565,7 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source) const info.townBackground = ImagePath::fromJson(source["townBackground"]); info.buildingsIcons = AnimationPath::fromJson(source["buildingsIcons"]); info.tavernVideo = VideoPath::fromJson(source["tavernVideo"]); + info.guildWindowPosition = Point(source["guildWindowPosition"]["x"].Integer(), source["guildWindowPosition"]["y"].Integer()); info.guildSpellPositions.clear(); for(auto & level : source["guildSpellPositions"].Vector())