瀏覽代碼

Fixed visibility of corner gems

Ivan Savenko 2 年之前
父節點
當前提交
4958190e82

+ 1 - 1
client/CMT.cpp

@@ -659,7 +659,7 @@ static bool recreateWindow(int w, int h, int bpp, bool fullscreen, int displayIn
 
 	// TODO: CONFIGURABLE ADVMAP
 	static const std::vector<Point> supportedResolutions = {
-		{ 800, 600 }
+		{ 1280, 720 }
 	};
 
 

+ 15 - 3
client/adventureMap/CAdventureMapWidget.cpp

@@ -32,8 +32,10 @@
 CAdventureMapWidget::CAdventureMapWidget()
 	: state(EGameState::NOT_INITIALIZED)
 {
-	pos.w = 800;
-	pos.h = 600;
+	pos.x = pos.y = 0;
+	pos.w = GH.screenDimensions().x;
+	pos.h = GH.screenDimensions().y;
+
 	REGISTER_BUILDER("adventureInfobar",         &CAdventureMapWidget::buildInfobox         );
 	REGISTER_BUILDER("adventureMapImage",        &CAdventureMapWidget::buildMapImage        );
 	REGISTER_BUILDER("adventureMapButton",       &CAdventureMapWidget::buildMapButton       );
@@ -154,7 +156,12 @@ std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapButton(const JsonNode &
 std::shared_ptr<CIntObject> CAdventureMapWidget::buildMapContainer(const JsonNode & input)
 {
 	auto position = readTargetArea(input["area"]);
-	auto result = std::make_shared<CAdventureMapContainerWidget>();
+	std::shared_ptr<CAdventureMapContainerWidget> result;
+
+	if (input["overlay"].Bool())
+		result = std::make_shared<CAdventureMapOverlayWidget>();
+	else
+		result = std::make_shared<CAdventureMapContainerWidget>();
 
 	result->moveBy(position.topLeft());
 	subwidgetSizes.push_back(position);
@@ -388,3 +395,8 @@ void CAdventureMapIcon::setPlayer(const PlayerColor & player)
 {
 	image->setFrame(index + player.getNum() * iconsPerPlayer);
 }
+
+void CAdventureMapOverlayWidget::show(SDL_Surface * to)
+{
+	CIntObject::showAll(to);
+}

+ 6 - 0
client/adventureMap/CAdventureMapWidget.h

@@ -91,6 +91,12 @@ class CAdventureMapContainerWidget : public CIntObject
 	std::vector<std::shared_ptr<CIntObject>> ownedChildren;
 };
 
+class CAdventureMapOverlayWidget : public CAdventureMapContainerWidget
+{
+public:
+	void show(SDL_Surface * to) override;
+};
+
 /// Small helper class that provides player-colorable icon using animation file
 class CAdventureMapIcon : public CIntObject
 {

+ 2 - 0
client/adventureMap/CResDataBar.h

@@ -11,8 +11,10 @@
 
 #include "../gui/CIntObject.h"
 
+VCMI_LIB_NAMESPACE_BEGIN
 enum class EGameResID : int8_t;
 using GameResID = Identifier<EGameResID>;
+VCMI_LIB_NAMESPACE_END
 
 /// Resources bar which shows information about how many gold, crystals,... you have
 /// Current date is displayed too

+ 2 - 2
client/widgets/Images.cpp

@@ -128,9 +128,9 @@ void CFilledTexture::showAll(SDL_Surface *to)
 {
 	CSDL_Ext::CClipRectGuard guard(to, pos);
 
-	for (int y=pos.top(); y < pos.bottom(); y+= texture->height())
+	for (int y=pos.top(); y < pos.bottom(); y+= imageArea.h)
 	{
-		for (int x=pos.left(); x < pos.right(); x+=texture->width())
+		for (int x=pos.left(); x < pos.right(); x+= imageArea.w)
 			texture->draw(to, x, y, &imageArea);
 	}
 }

+ 107 - 53
config/widgets/adventureMap.json

@@ -9,114 +9,103 @@
 		
 		// widgets that are only visible in game view mode
 		"gameViewWidgets" : [ "townListContainer", "heroListContainer", "buttonsContainer", "infobox" ],
-		
-		// widgets that should be drawn on top of game area
-		// NOTE: semi-transparency is not supported, only fully transparent/fully opaque
-		"overlayWidgets" : [ "gemTopLeft", "gemTopRight", "gemBottomLeft", "gemBottomRight" ]
 	},
 
 	"items":
 	[
-		// GEMS - set of images with different image for each player
-		{
-			"type": "adventureMapIcon",
-			"name" : "gemTopLeft",
-			"image" : "agemUL.def",
-			"index" : 0,
-			"perPlayer" : 1,
-			"area" : { "left": 7, "top" : 7, "width" : 46, "height" : 46 }
-		},
+		// Background sections - left side
 		{
-			"type": "adventureMapIcon",
-			"name" : "gemTopRight",
-			"image" : "agemUR.def",
-			"index" : 0,
-			"perPlayer" : 1,
-			"area" : { "right": 198, "top" : 7, "width" : 46, "height" : 46 }
+			"type": "adventureMapImage",
+			"name" : "backgroundLeftTop",
+			"image" : "AdvMap.pcx",
+			"area" : { "left": 0, "top" : 0, "width" : 7, "height" : 52 }
 		},
 		{
-			"type": "adventureMapIcon",
-			"name" : "gemBottomLeft",
-			"image" : "agemLL.def",
-			"index" : 0,
-			"perPlayer" : 1,
-			"area" : { "left": 7, "bottom" : 46, "width" : 46, "height" : 46 }
+			"type": "adventureMapImage",
+			"name" : "backgroundLeftCenter",
+			"image" : "AdvMap.pcx",
+			"area" : { "left": 0, "top" : 52, "width" : 7, "bottom" : 91 }
 		},
 		{
-			"type": "adventureMapIcon",
-			"name" : "gemBottomRight",
-			"image" : "agemLR.def",
-			"index" : 0,
-			"perPlayer" : 1,
-			"area" : { "right": 198, "bottom" : 46, "width" : 46, "height" : 46 }
+			"type": "adventureMapImage",
+			"name" : "backgroundLeftBottom",
+			"image" : "AdvMap.pcx",
+			"area" : { "left": 0, "bottom" : 0, "width" : 7, "height" : 91 }
 		},
-
-		// Background sections
+		// Background sections - top side
 		{
 			"type": "adventureMapImage",
 			"name" : "backgroundTopLeft",
 			"image" : "AdvMap.pcx",
-			"area" : { "left": 0, "top" : 0, "width" : 7, "height" : 7 }
+			"area" : { "left": 7, "top" : 0, "width" : 193, "height" : 7 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name" : "backgroundBottomLeft",
+			"name" : "backgroundTopCenter",
 			"image" : "AdvMap.pcx",
-			"area" : { "left": 0, "bottom" : 0, "width" : 7, "height" : 46 }
+			"area" : { "left": 200, "top" : 0, "right" : 244, "height" : 7 }
 		},
 		{
 			"type": "adventureMapImage",
 			"name" : "backgroundTopRight",
 			"image" : "AdvMap.pcx",
-			"area" : { "right": 0, "top" : 0, "width" : 199, "height" : 196 }
+			"area" : { "width": 45, "top" : 0, "right" : 199, "height" : 7 }
 		},
+		// Background sections - bottom side
 		{
 			"type": "adventureMapImage",
-			"name" : "backgroundBottomRight",
+			"name" : "backgroundBottomLeft",
 			"image" : "AdvMap.pcx",
-			"area" : { "bottom": 0, "right" : 0, "width" : 199, "height" : 211 }
+			"area" : { "left": 7, "bottom" : 0, "width" : 44, "height" : 47 }
+		},
+		{
+			"type": "adventureMapImage",
+			"name" : "backgroundBottomCenter",
+			"image" : "AdvMap.pcx",
+			"area" : { "left": 51, "bottom" : 0, "right" : 244, "height" : 47 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "sideBorderLeft",
+			"name" : "backgroundBottomRight",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 7, "left" : 0, "bottom" : 46, "width" : 7 }
+			"area" : { "width": 45, "bottom" : 0, "right" : 199, "height" : 47 }
 		},
+		// Background sections - side panel
 		{
 			"type": "adventureMapImage",
-			"name": "sideBorderTop",
+			"name" : "backgroundRightMinimap",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 0, "left" : 7, "right" : 199, "height" : 7 }
+			"area" : { "right": 0, "top" : 0, "width" : 199, "height" : 196 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "sideBorderBottom",
+			"name" : "backgroundRightInfobar",
 			"image" : "AdvMap.pcx",
-			"area": { "bottom": 0, "right" : 199, "left" : 0, "height" : 47 }
+			"area" : { "bottom": 0, "right" : 0, "width" : 199, "height" : 211 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "heroListBorderLeft",
+			"name": "backgroundHeroListBorderLeft",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 210, "right" : 192, "width" : 7 }
+			"area": { "top": 196, "bottom" : 211, "right" : 191, "width" : 8 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "heroListBorderRight",
+			"name": "backgroundHeroListBorderRight",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 210, "right" : 122, "width" : 3 }
+			"area": { "top": 196, "bottom" : 211, "right" : 121, "width" : 6 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "townListBorderLeft",
+			"name": "backgroundTownListBorderLeft",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 210, "right" : 54, "width" : 3 }
+			"area": { "top": 196, "bottom" : 211, "right" : 53, "width" : 4 }
 		},
 		{
 			"type": "adventureMapImage",
-			"name": "townListBorderRight",
+			"name": "backgroundTownListBorderRight",
 			"image" : "AdvMap.pcx",
-			"area": { "top": 196, "bottom" : 210, "right" : 0, "width" : 3 }
+			"area": { "top": 196, "bottom" : 211, "right" : 0, "width" : 5 }
 		},
 		
 		// Game area
@@ -607,6 +596,71 @@
 					]
 				},
 			]
+		},
+		// GEMS - set of images with different image for each player
+		{
+			"type": "adventureMapContainer",
+			"name" : "overlayGemTopLeft",
+			"overlay" : true,
+			"area": { "left": 6, "top" : 6, "width" : 46, "height" : 46 },
+			"items" : [
+				{
+					"type": "adventureMapIcon",
+					"name" : "gemTopLeft",
+					"image" : "agemUL.def",
+					"index" : 0,
+					"perPlayer" : 1,
+					"area" : { "left": 0, "top" : 0, "right" : 0, "bottom" : 0 }
+				}
+			]
+		},
+		{
+			"type": "adventureMapContainer",
+			"name" : "overlayGemTopRight",
+			"overlay" : true,
+			"area": { "right": 198, "top" : 6, "width" : 46, "height" : 46 },
+			"items" : [
+				{
+					"type": "adventureMapIcon",
+					"name" : "gemTopRight",
+					"image" : "agemUR.def",
+					"index" : 0,
+					"perPlayer" : 1,
+					"area" : { "left": 0, "top" : 0, "right" : 0, "bottom" : 0 }
+				}
+			]
+		},
+		{
+			"type": "adventureMapContainer",
+			"name" : "overlayGemBottomLeft",
+			"overlay" : true,
+			"area": { "left": 6, "bottom" : 46, "width" : 46, "height" : 46 },
+			"items" : [
+				{
+					"type": "adventureMapIcon",
+					"name" : "gemBottomLeft",
+					"image" : "agemLL.def",
+					"index" : 0,
+					"perPlayer" : 1,
+					"area" : { "left": 0, "top" : 0, "right" : 0, "bottom" : 0 }
+				}
+			]
+		},
+		{
+			"type": "adventureMapContainer",
+			"name" : "overlayGemBottomRight",
+			"overlay" : true,
+			"area": { "right": 198, "bottom" : 46, "width" : 46, "height" : 46 },
+			"items" : [
+				{
+					"type": "adventureMapIcon",
+					"name" : "gemBottomRight",
+					"image" : "agemLR.def",
+					"index" : 0,
+					"perPlayer" : 1,
+					"area" : { "left": 0, "top" : 0, "right" : 0, "bottom" : 0 }
+				}
+			]
 		}
 	]
 }