浏览代码

Added larger town list for higher resolutions

Ivan Savenko 2 年之前
父节点
当前提交
d96edd9f56
共有 3 个文件被更改,包括 212 次插入73 次删除
  1. 32 15
      client/adventureMap/CAdventureMapWidget.cpp
  2. 7 0
      client/adventureMap/CAdventureMapWidget.h
  3. 173 58
      config/widgets/adventureMap.json

+ 32 - 15
client/adventureMap/CAdventureMapWidget.cpp

@@ -133,7 +133,8 @@ std::shared_ptr<CAnimation> CAdventureMapWidget::loadAnimation(const std::string
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildInfobox(const JsonNode & input)
 {
 	Rect area = readTargetArea(input["area"]);
-	return std::make_shared<CInfoBar>(area);
+	infoBar = std::make_shared<CInfoBar>(area);
+	return infoBar;
 }
 
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapImage(const JsonNode & input)
@@ -158,6 +159,18 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapContainer(const JsonNod
 	auto position = readTargetArea(input["area"]);
 	std::shared_ptr<CAdventureMapContainerWidget> result;
 
+	if (!input["exists"].isNull())
+	{
+		if (!input["exists"]["heightMin"].isNull() && input["exists"]["heightMin"].Integer() >= pos.h)
+			return nullptr;
+		if (!input["exists"]["heightMax"].isNull() && input["exists"]["heightMax"].Integer() < pos.h)
+			return nullptr;
+		if (!input["exists"]["widthMin"].isNull() && input["exists"]["widthMin"].Integer() >= pos.w)
+			return nullptr;
+		if (!input["exists"]["widthMax"].isNull() && input["exists"]["widthMax"].Integer() < pos.w)
+			return nullptr;
+	}
+
 	if (input["overlay"].Bool())
 		result = std::make_shared<CAdventureMapOverlayWidget>();
 	else
@@ -168,7 +181,7 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapContainer(const JsonNod
 	for(const auto & entry : input["items"].Vector())
 	{
 		result->ownedChildren.push_back(buildWidget(entry));
-		result->addChild(result->ownedChildren.back().get(), true);
+		result->addChild(result->ownedChildren.back().get(), false);
 	}
 	subwidgetSizes.pop_back();
 
@@ -178,20 +191,22 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapContainer(const JsonNod
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapGameArea(const JsonNode & input)
 {
 	Rect area = readTargetArea(input["area"]);
-	return std::make_shared<MapView>(area.topLeft(), area.dimensions());
+	mapView = std::make_shared<MapView>(area.topLeft(), area.dimensions());
+	return mapView;
 }
 
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapHeroList(const JsonNode & input)
 {
 	Rect area = readTargetArea(input["area"]);
+	subwidgetSizes.push_back(area);
+
 	Rect item = readTargetArea(input["item"]);
 
 	Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer());
 	int itemsCount = input["itemsCount"].Integer();
 
-	auto result = std::make_shared<CHeroList>(itemsCount, area.topLeft() + item.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size());
+	auto result = std::make_shared<CHeroList>(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size());
 
-	subwidgetSizes.push_back(area);
 
 	if(!input["scrollUp"].isNull())
 		result->setScrollUpButton(std::dynamic_pointer_cast<CButton>(buildMapButton(input["scrollUp"])));
@@ -201,6 +216,7 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapHeroList(const JsonNode
 
 	subwidgetSizes.pop_back();
 
+	heroList = result;
 	return result;
 }
 
@@ -217,14 +233,13 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapIcon(const JsonNode & i
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapTownList(const JsonNode & input)
 {
 	Rect area = readTargetArea(input["area"]);
-	Rect item = readTargetArea(input["item"]);
+	subwidgetSizes.push_back(area);
 
+	Rect item = readTargetArea(input["item"]);
 	Point itemOffset(input["itemsOffset"]["x"].Integer(), input["itemsOffset"]["y"].Integer());
 	int itemsCount = input["itemsCount"].Integer();
 
-	auto result = std::make_shared<CTownList>(itemsCount, area.topLeft() + item.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size());
-
-	subwidgetSizes.push_back(area);
+	auto result = std::make_shared<CTownList>(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size());
 
 	if(!input["scrollUp"].isNull())
 		result->setScrollUpButton(std::dynamic_pointer_cast<CButton>(buildMapButton(input["scrollUp"])));
@@ -234,13 +249,15 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapTownList(const JsonNode
 
 	subwidgetSizes.pop_back();
 
+	townList = result;
 	return result;
 }
 
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMinimap(const JsonNode & input)
 {
 	Rect area = readTargetArea(input["area"]);
-	return std::make_shared<CMinimap>(area);
+	minimap = std::make_shared<CMinimap>(area);
+	return minimap;
 }
 
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildResourceDateBar(const JsonNode & input)
@@ -277,27 +294,27 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildStatusBar(const JsonNode &
 
 std::shared_ptr<CHeroList> CAdventureMapWidget::getHeroList()
 {
-	return widget<CHeroList>("heroList");
+	return heroList;
 }
 
 std::shared_ptr<CTownList> CAdventureMapWidget::getTownList()
 {
-	return widget<CTownList>("townList");
+	return townList;
 }
 
 std::shared_ptr<CMinimap> CAdventureMapWidget::getMinimap()
 {
-	return widget<CMinimap>("minimap");
+	return minimap;
 }
 
 std::shared_ptr<MapView> CAdventureMapWidget::getMapView()
 {
-	return widget<MapView>("mapView");
+	return mapView;
 }
 
 std::shared_ptr<CInfoBar> CAdventureMapWidget::getInfoBar()
 {
-	return widget<CInfoBar>("infoBar");
+	return infoBar;
 }
 
 void CAdventureMapWidget::setPlayer(const PlayerColor & player)

+ 7 - 0
client/adventureMap/CAdventureMapWidget.h

@@ -42,6 +42,13 @@ class CAdventureMapWidget : public InterfaceObjectConfigurable
 	std::map<std::string, std::shared_ptr<IImage>> images;
 	std::map<std::string, std::shared_ptr<CAnimation>> animations;
 
+	/// Widgets that require access from adventure map
+	std::shared_ptr<CHeroList> heroList;
+	std::shared_ptr<CTownList> townList;
+	std::shared_ptr<CMinimap> minimap;
+	std::shared_ptr<MapView> mapView;
+	std::shared_ptr<CInfoBar> infoBar;
+
 	Rect readTargetArea(const JsonNode & source);
 	Rect readSourceArea(const JsonNode & source, const JsonNode & sourceCommon);
 	Rect readArea(const JsonNode & source, const Rect & boundingBox);

+ 173 - 58
config/widgets/adventureMap.json

@@ -89,25 +89,12 @@
 			"image" : "AdvMap.pcx",
 			"area": { "top": 196, "bottom" : 211, "right" : 191, "width" : 8 }
 		},
-		{
-			"type": "adventureMapImage",
-			"name": "backgroundHeroListBorderRight",
-			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 211, "right" : 121, "width" : 6 }
-		},
-		{
-			"type": "adventureMapImage",
-			"name": "backgroundTownListBorderLeft",
-			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 211, "right" : 53, "width" : 4 }
-		},
 		{
 			"type": "adventureMapImage",
 			"name": "backgroundTownListBorderRight",
 			"image" : "AdvMap.pcx",
 			"area": { "top": 196, "bottom" : 211, "right" : 0, "width" : 5 }
 		},
-		
 		// Game area
 		{
 			"type": "adventureMapGameArea",
@@ -214,54 +201,182 @@
 				}
 			]
 		},
-		// Hero List
+		// Town / Hero lists for small (600-664) vertical resolution
 		{
-			"type": "adventureMapHeroList",
-			"name" : "heroList",
-			"area": { "top": 196, "right" : 127, "width" : 64, "height" : 192 },
-			"scrollUp" : {
-				"type": "adventureMapButton",
-				"name": "heroListScrollUp",
-				"image" : "IAM012.DEF",
-				"help" : "core.help.303",
-				"area": { "top" : 0, "left": 0, "width" : 64, "height" : 16 }
-			},
-			"scrollDown" : {
-				"type": "adventureMapButton",
-				"name": "heroListScrollDown",
-				"image" : "IAM013.DEF",
-				"help" : "core.help.304",
-				"area": { "top" : 176, "left": 0, "width" : 64, "height" : 16 }
-			},
-			"item" : { "top" :  16, "left": 1, "width" : 62, "height" : 32 },
-			"itemsOffset" : { "x" : 0, "y" : 32 },
-			"itemsCount" : 5
+			"type": "adventureMapContainer",
+			"name" : "listContainerSmall",
+			"area": { "top": 196, "right" : 0, "width" : 193, "height" : 196 },
+			"exists" : { "heightMax" : 664 },
+			"items" : [
+				{
+					"type": "adventureMapImage",
+					"name": "backgroundHeroListBorderRight",
+					"image" : "AdvMap.pcx",
+					"area": { "top": 0, "bottom" : 0, "right" : 121, "width" : 6 },
+					"sourceArea": { "top": 196, "bottom" : 211, "right" : 121, "width" : 6 }
+				},
+				{
+					"type": "adventureMapImage",
+					"name": "backgroundTownListBorderLeft",
+					"image" : "AdvMap.pcx",
+					"area": { "top": 0, "bottom" : 0, "right" : 53, "width" : 4 },
+					"sourceArea": { "top": 196, "bottom" : 211, "right" : 53, "width" : 4 }
+				},
+				{
+					"type": "adventureMapImage",
+					"name" : "backgroundBelowHeroTownList",
+					"image" : "AdvMap.pcx",
+					"area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 3 },
+					"sourceArea": { "bottom" : 208, "height" : 3, "right" : 0, "width" : 193 }
+				},
+				// Hero List
+				{
+					"type": "adventureMapHeroList",
+					"name" : "heroList",
+					"area": { "top": 0, "right" : 127, "width" : 64, "height" : 192 },
+					"scrollUp" : {
+						"type": "adventureMapButton",
+						"name": "heroListScrollUp",
+						"image" : "IAM012.DEF",
+						"help" : "core.help.303",
+						"area": { "top" : 0, "left": 0, "width" : 64, "height" : 16 }
+					},
+					"scrollDown" : {
+						"type": "adventureMapButton",
+						"name": "heroListScrollDown",
+						"image" : "IAM013.DEF",
+						"help" : "core.help.304",
+						"area": { "bottom" : 0, "left": 0, "width" : 64, "height" : 16 }
+					},
+					"item" : { "top" :  16, "left": 1, "width" : 62, "height" : 32 },
+					"itemsOffset" : { "x" : 0, "y" : 32 },
+					"itemsCount" : 5
+				},
+				// Town List
+				{
+					"type": "adventureMapTownList",
+					"name" : "townList",
+					"area": { "top": 0, "right" : 5, "width" : 48, "height" : 192 },
+					"scrollUp" : {
+						"type": "adventureMapButton",
+						"name": "townListScrollUp",
+						"image" : "IAM014.DEF",
+						"help" : "core.help.306",
+						"area": { "top" : 0, "left": 0, "width" : 48, "height" : 16 }
+					},
+					"scrollDown" : {
+						"type": "adventureMapButton",
+						"name": "townListScrollDown",
+						"image" : "IAM015.DEF",
+						"help" : "core.help.307",
+						"area": { "bottom" : 0, "left": 0, "width" : 48, "height" : 16 }
+					},
+					"item" : { "top" :  16, "left": 0, "width" : 48, "height" : 32 },
+					"itemsOffset" : { "x" : 0, "y" : 32 },
+					"itemsCount" : 5
+				},
+			]
 		},
-		
-		// Town List
 		{
-			"type": "adventureMapTownList",
-			"name" : "townList",
-			"area": { "top": 196, "right" : 5, "width" : 48, "height" : 192 },
-			"scrollUp" : {
-				"type": "adventureMapButton",
-				"name": "townListScrollUp",
-				"image" : "IAM014.DEF",
-				"help" : "core.help.306",
-				"area": { "top" : 0, "left": 0, "width" : 48, "height" : 16 }
-			},
-			"scrollDown" : {
-				"type": "adventureMapButton",
-				"name": "townListScrollDown",
-				"image" : "IAM015.DEF",
-				"help" : "core.help.307",
-				"area": { "top" : 176, "left": 0, "width" : 48, "height" : 16 }
-			},
-			"item" : { "top" :  16, "left": 0, "width" : 48, "height" : 32 },
-			"itemsOffset" : { "x" : 0, "y" : 32 },
-			"itemsCount" : 5
+			"type": "adventureMapContainer",
+			"name" : "emptyAreaFillSmall",
+			"area": { "top": 392, "right" : 3, "width" : 190, "bottom" : 211 },
+			"exists" : { "heightMax" : 664 },
+			"items" : [
+				{
+					"type": "adventureMapImage",
+					"name": "emptyAreaFillSmallImage",
+					"image" : "DiBoxBck.pcx",
+					"area": { "top": 0, "bottom" : 0, "left" : 0, "right" : 0 }
+					"sourceArea": { "left" : 0, "top" : 0, "width" : 256, "height" : 256 }
+				},
+			]
+		},
+		// Town / Hero lists for large (664+) vertical resolution
+		{
+			"type": "adventureMapContainer",
+			"name" : "listContainerLarge",
+			"area": { "top": 196, "right" : 0, "width" : 193, "height" : 260 },
+			"exists" : { "heightMin" : 664 },
+			"items" : [
+				{
+					"type": "adventureMapImage",
+					"name": "backgroundHeroListBorderRight",
+					"image" : "AdvMap.pcx",
+					"area": { "top": 0, "bottom" : 0, "right" : 121, "width" : 6 }
+					"sourceArea": { "top": 196, "bottom" : 211, "right" : 121, "width" : 6 }
+				},
+				{
+					"type": "adventureMapImage",
+					"name": "backgroundTownListBorderLeft",
+					"image" : "AdvMap.pcx",
+					"area": { "top": 0, "bottom" : 0, "right" : 53, "width" : 4 }
+					"sourceArea": { "top": 196, "bottom" : 211, "right" : 53, "width" : 4 }
+				},
+				{
+					"type": "adventureMapImage",
+					"name" : "backgroundBelowHeroTownList",
+					"image" : "AdvMap.pcx",
+					"area" : { "right": 0, "left" : 0, "bottom" : 0, "height" : 3 }
+					"sourceArea": { "bottom" : 208, "height" : 3, "right" : 0, "width" : 193 }
+				},
+				// Hero List
+				{
+					"type": "adventureMapHeroList",
+					"name" : "heroList",
+					"area": { "top": 0, "right" : 127, "width" : 64, "height" : 256 },
+					"item" : { "top" :  0, "left": 1, "width" : 62, "height" : 32 },
+					"itemsOffset" : { "x" : 0, "y" : 32 },
+					"itemsCount" : 8
+				},
+				// Town List
+				{
+					"type": "adventureMapTownList",
+					"name" : "townList",
+					"area": { "top": 0, "right" : 5, "width" : 48, "height" : 256 },
+					"scrollUp" : {
+						"type": "adventureMapButton",
+						"name": "townListScrollUp",
+						"image" : "IAM014.DEF",
+						"help" : "core.help.306",
+						"area": { "top" : 0, "left": 0, "width" : 48, "height" : 16 }
+					},
+					"scrollDown" : {
+						"type": "adventureMapButton",
+						"name": "townListScrollDown",
+						"image" : "IAM015.DEF",
+						"help" : "core.help.307",
+						"area": { "bottom" : 0, "left": 0, "width" : 48, "height" : 16 }
+					},
+					"item" : { "top" :  16, "left": 0, "width" : 48, "height" : 32 },
+					"itemsOffset" : { "x" : 0, "y" : 32 },
+					"itemsCount" : 7
+				}
+				// Fill empty area below buttons
+				{
+					"type": "adventureMapImage",
+					"name" : "backgroundBelowButtons",
+					"image" : "DiBoxBck.pcx",
+					"area": { "top": 192, "bottom" : 3, "right" : 57, "width" : 64 }
+					"sourceArea": { "left" : 0, "top" : 0, "width" : 256, "height" : 256 }
+				},
+			]
+		},
+		{
+			"type": "adventureMapContainer",
+			"name" : "emptyAreaFillLarge",
+			"area": { "top": 456, "right" : 3, "width" : 190, "bottom" : 211 },
+			"exists" : { "heightMin" : 664 },
+			"items" : [
+				{
+					"type": "adventureMapImage",
+					"name": "emptyAreaFillLargeImage",
+					"image" : "DiBoxBck.pcx",
+					"area": { "top": 0, "bottom" : 0, "left" : 0, "right" : 0 }
+					"sourceArea": { "left" : 0, "top" : 0, "width" : 256, "height" : 256 }
+				},
+			]
 		},
-		
 		// Infobar
 		{
 			"type": "adventureInfobar",
@@ -302,7 +417,7 @@
 					"name": "worldViewBackground",
 					"image" : "VWorld.pcx",
 					"area": { "top" : 0, "left": 0, "width" : 48, "height" : 192 },
-					"areaSource": { "left" : 0, "right" : 0, "top" : 0, "bottom" : 0 }
+					"sourceArea": { "left" : 0, "right" : 0, "top" : 0, "bottom" : 0 }
 				},
 				{
 					"type": "adventureMapButton",