diff --git a/client/adventureMap/CAdventureMapWidget.cpp b/client/adventureMap/CAdventureMapWidget.cpp index c6d0cc021..6d12b48ec 100644 --- a/client/adventureMap/CAdventureMapWidget.cpp +++ b/client/adventureMap/CAdventureMapWidget.cpp @@ -133,7 +133,8 @@ std::shared_ptr CAdventureMapWidget::loadAnimation(const std::string std::shared_ptr CAdventureMapWidget::buildInfobox(const JsonNode & input) { Rect area = readTargetArea(input["area"]); - return std::make_shared(area); + infoBar = std::make_shared(area); + return infoBar; } std::shared_ptr CAdventureMapWidget::buildMapImage(const JsonNode & input) @@ -158,6 +159,18 @@ std::shared_ptr CAdventureMapWidget::buildMapContainer(const JsonNod auto position = readTargetArea(input["area"]); std::shared_ptr 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(); else @@ -168,7 +181,7 @@ std::shared_ptr 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 CAdventureMapWidget::buildMapContainer(const JsonNod std::shared_ptr CAdventureMapWidget::buildMapGameArea(const JsonNode & input) { Rect area = readTargetArea(input["area"]); - return std::make_shared(area.topLeft(), area.dimensions()); + mapView = std::make_shared(area.topLeft(), area.dimensions()); + return mapView; } std::shared_ptr 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(itemsCount, area.topLeft() + item.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size()); + auto result = std::make_shared(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getWanderingHeroes().size()); - subwidgetSizes.push_back(area); if(!input["scrollUp"].isNull()) result->setScrollUpButton(std::dynamic_pointer_cast(buildMapButton(input["scrollUp"]))); @@ -201,6 +216,7 @@ std::shared_ptr CAdventureMapWidget::buildMapHeroList(const JsonNode subwidgetSizes.pop_back(); + heroList = result; return result; } @@ -217,14 +233,13 @@ std::shared_ptr CAdventureMapWidget::buildMapIcon(const JsonNode & i std::shared_ptr 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(itemsCount, area.topLeft() + item.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size()); - - subwidgetSizes.push_back(area); + auto result = std::make_shared(itemsCount, item.topLeft(), itemOffset, LOCPLINT->localState->getOwnedTowns().size()); if(!input["scrollUp"].isNull()) result->setScrollUpButton(std::dynamic_pointer_cast(buildMapButton(input["scrollUp"]))); @@ -234,13 +249,15 @@ std::shared_ptr CAdventureMapWidget::buildMapTownList(const JsonNode subwidgetSizes.pop_back(); + townList = result; return result; } std::shared_ptr CAdventureMapWidget::buildMinimap(const JsonNode & input) { Rect area = readTargetArea(input["area"]); - return std::make_shared(area); + minimap = std::make_shared(area); + return minimap; } std::shared_ptr CAdventureMapWidget::buildResourceDateBar(const JsonNode & input) @@ -277,27 +294,27 @@ std::shared_ptr CAdventureMapWidget::buildStatusBar(const JsonNode & std::shared_ptr CAdventureMapWidget::getHeroList() { - return widget("heroList"); + return heroList; } std::shared_ptr CAdventureMapWidget::getTownList() { - return widget("townList"); + return townList; } std::shared_ptr CAdventureMapWidget::getMinimap() { - return widget("minimap"); + return minimap; } std::shared_ptr CAdventureMapWidget::getMapView() { - return widget("mapView"); + return mapView; } std::shared_ptr CAdventureMapWidget::getInfoBar() { - return widget("infoBar"); + return infoBar; } void CAdventureMapWidget::setPlayer(const PlayerColor & player) diff --git a/client/adventureMap/CAdventureMapWidget.h b/client/adventureMap/CAdventureMapWidget.h index 0d462d0ed..c13bd9d8b 100644 --- a/client/adventureMap/CAdventureMapWidget.h +++ b/client/adventureMap/CAdventureMapWidget.h @@ -42,6 +42,13 @@ class CAdventureMapWidget : public InterfaceObjectConfigurable std::map> images; std::map> animations; + /// Widgets that require access from adventure map + std::shared_ptr heroList; + std::shared_ptr townList; + std::shared_ptr minimap; + std::shared_ptr mapView; + std::shared_ptr infoBar; + Rect readTargetArea(const JsonNode & source); Rect readSourceArea(const JsonNode & source, const JsonNode & sourceCommon); Rect readArea(const JsonNode & source, const Rect & boundingBox); diff --git a/config/widgets/adventureMap.json b/config/widgets/adventureMap.json index 7cb3030f0..72d061ab7 100644 --- a/config/widgets/adventureMap.json +++ b/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",