Laserlicht 2 months ago
parent
commit
a833b53432

+ 27 - 12
client/adventureMap/AdventureMapWidget.cpp

@@ -43,18 +43,19 @@ AdventureMapWidget::AdventureMapWidget( std::shared_ptr<AdventureMapShortcuts> s
 	pos.w = ENGINE->screenDimensions().x;
 	pos.h = ENGINE->screenDimensions().y;
 
-	REGISTER_BUILDER("adventureInfobar",         &AdventureMapWidget::buildInfobox         );
-	REGISTER_BUILDER("adventureMapImage",        &AdventureMapWidget::buildMapImage        );
-	REGISTER_BUILDER("adventureMapButton",       &AdventureMapWidget::buildMapButton       );
-	REGISTER_BUILDER("adventureMapContainer",    &AdventureMapWidget::buildMapContainer    );
-	REGISTER_BUILDER("adventureMapGameArea",     &AdventureMapWidget::buildMapGameArea     );
-	REGISTER_BUILDER("adventureMapHeroList",     &AdventureMapWidget::buildMapHeroList     );
-	REGISTER_BUILDER("adventureMapIcon",         &AdventureMapWidget::buildMapIcon         );
-	REGISTER_BUILDER("adventureMapTownList",     &AdventureMapWidget::buildMapTownList     );
-	REGISTER_BUILDER("adventureMinimap",         &AdventureMapWidget::buildMinimap         );
-	REGISTER_BUILDER("adventureResourceDateBar", &AdventureMapWidget::buildResourceDateBar );
-	REGISTER_BUILDER("adventureStatusBar",       &AdventureMapWidget::buildStatusBar       );
-	REGISTER_BUILDER("adventurePlayerTexture",   &AdventureMapWidget::buildTexturePlayerColored);
+	REGISTER_BUILDER("adventureInfobar",            &AdventureMapWidget::buildInfobox             );
+	REGISTER_BUILDER("adventureMapImage",           &AdventureMapWidget::buildMapImage            );
+	REGISTER_BUILDER("adventureMapButton",          &AdventureMapWidget::buildMapButton           );
+	REGISTER_BUILDER("adventureMapContainer",       &AdventureMapWidget::buildMapContainer        );
+	REGISTER_BUILDER("adventureMapGameArea",        &AdventureMapWidget::buildMapGameArea         );
+	REGISTER_BUILDER("adventureMapHeroList",        &AdventureMapWidget::buildMapHeroList         );
+	REGISTER_BUILDER("adventureMapIcon",            &AdventureMapWidget::buildMapIcon             );
+	REGISTER_BUILDER("adventureMapTownList",        &AdventureMapWidget::buildMapTownList         );
+	REGISTER_BUILDER("adventureMinimap",            &AdventureMapWidget::buildMinimap             );
+	REGISTER_BUILDER("adventureResourceDateBar",    &AdventureMapWidget::buildResourceDateBar     );
+	REGISTER_BUILDER("adventureStatusBar",          &AdventureMapWidget::buildStatusBar           );
+	REGISTER_BUILDER("adventurePlayerTexture",      &AdventureMapWidget::buildTexturePlayerColored);
+	REGISTER_BUILDER("adventureResourceAdditional", &AdventureMapWidget::buildResourceAdditional  );
 
 	for (const auto & entry : shortcuts->getShortcuts())
 		addShortcut(entry.shortcut, entry.callback);
@@ -316,6 +317,20 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildTexturePlayerColored(const
 	return std::make_shared<FilledTexturePlayerColored>(area);
 }
 
+std::shared_ptr<CIntObject> AdventureMapWidget::buildResourceAdditional(const JsonNode & input)
+{
+	OBJECT_CONSTRUCTION;
+	logGlobal->debug("Building widget ResourceAdditional");
+	Rect area = readTargetArea(input["area"]);
+	auto obj = std::make_shared<CIntObject>();
+	auto result = std::make_shared<CResDataBar>(ImagePath::builtin("ResBarElement"), area.topLeft());
+	result->setResourcePosition(GameResID::CRYSTAL, Point(35, 3));
+	addWidget("", result);
+	obj->addChild(result.get());
+	//auto area = std::make_shared<FilledTexturePlayerColored>(area)
+	return obj;
+}
+
 std::shared_ptr<CHeroList> AdventureMapWidget::getHeroList()
 {
 	return heroList;

+ 1 - 0
client/adventureMap/AdventureMapWidget.h

@@ -55,6 +55,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
 	std::shared_ptr<CIntObject> buildResourceDateBar(const JsonNode & input);
 	std::shared_ptr<CIntObject> buildStatusBar(const JsonNode & input);
 	std::shared_ptr<CIntObject> buildTexturePlayerColored(const JsonNode &);
+	std::shared_ptr<CIntObject> buildResourceAdditional(const JsonNode &);
 
 	void setPlayerChildren(CIntObject * widget, const PlayerColor & player);
 	void updateActiveStateChildden(CIntObject * widget);

+ 16 - 0
client/adventureMap/CResDataBar.cpp

@@ -18,15 +18,19 @@
 #include "../GameInstance.h"
 #include "../gui/TextAlignment.h"
 #include "../widgets/Images.h"
+#include "../widgets/CComponent.h"
+#include "../windows/InfoWindows.h"
 
 #include "../../lib/CConfigHandler.h"
 #include "../../lib/callback/CCallback.h"
 #include "../../lib/texts/CGeneralTextHandler.h"
 #include "../../lib/ResourceSet.h"
 #include "../../lib/GameLibrary.h"
+#include "../../lib/networkPacks/Component.h"
 
 CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position)
 {
+	addUsedEvents(SHOW_POPUP);
 	pos.x += position.x;
 	pos.y += position.y;
 
@@ -89,3 +93,15 @@ void CResDataBar::setPlayerColor(PlayerColor player)
 {
 	background->setPlayerColor(player);
 }
+
+void CResDataBar::showPopupWindow(const Point & cursorPosition)
+{
+	if((cursorPosition.x - pos.x) > 600)
+		return;
+
+	std::vector<std::shared_ptr<CComponent>> comp;
+	for(auto i = 0; i < GameConstants::RESOURCE_QUANTITY - 1; i++)
+		comp.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, GameResID(i), GAME->interface()->cb->getResourceAmount(i)));
+
+	CRClickPopup::createAndPush(LIBRARY->generaltexth->translate("core.genrltxt.270"), comp);
+}

+ 1 - 0
client/adventureMap/CResDataBar.h

@@ -35,6 +35,7 @@ public:
 	void setResourcePosition(const GameResID & resource, const Point & position);
 
 	void setPlayerColor(PlayerColor player);
+	void showPopupWindow(const Point & cursorPosition) override;
 	void showAll(Canvas & to) override;
 };
 

+ 19 - 0
client/render/AssetGenerator.cpp

@@ -51,6 +51,11 @@ void AssetGenerator::initialize()
 	imageFiles[ImagePath::builtin("CampaignBackground8.png")] = [this]() { return createCampaignBackground(8); };
 
 	imageFiles[ImagePath::builtin("SpelTabNone.png")] = [this](){ return createSpellTabNone();};
+	for (PlayerColor color(-1); color < PlayerColor::PLAYER_LIMIT; ++color)
+	{
+		std::string name = "ResBarElement" + (color == -1 ? "" : "-" + color.toString());
+		imageFiles[ImagePath::builtin(name)] = [this, color](){ return createResBarElement(std::max(PlayerColor(0), color));};
+	}
 
 	imageFiles[ImagePath::builtin("stackWindow/info-panel-0.png")] = [this](){ return createCreatureInfoPanel(2);};
 	imageFiles[ImagePath::builtin("stackWindow/info-panel-1.png")] = [this](){ return createCreatureInfoPanel(3);};
@@ -322,6 +327,20 @@ AssetGenerator::CanvasPtr AssetGenerator::createCampaignBackground(int selection
 	return image;
 }
 
+AssetGenerator::CanvasPtr AssetGenerator::createResBarElement(const PlayerColor & player) const
+{
+	auto locator = ImageLocator(ImagePath::builtin("ARESBAR"), EImageBlitMode::COLORKEY);
+	std::shared_ptr<IImage> img = ENGINE->renderHandler().loadImage(locator);
+	img->playerColored(player);
+
+	auto image = ENGINE->renderHandler().createImage(Point(84, 22), CanvasScalingPolicy::IGNORE);
+	Canvas canvas = image->getCanvas();
+	canvas.draw(img, Point(0, 0), Rect(2, 0, 84, 22));
+	canvas.draw(img, Point(4, 0), Rect(29, 0, 22, 22));
+
+	return image;
+}
+
 AssetGenerator::CanvasPtr AssetGenerator::createSpellTabNone() const
 {
 	auto img1 = ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("SPELTAB"), EImageBlitMode::COLORKEY)->getImage(0);

+ 1 - 0
client/render/AssetGenerator.h

@@ -51,6 +51,7 @@ private:
 	CanvasPtr createCombatUnitNumberWindow(float multR, float multG, float multB) const;
 	CanvasPtr createCampaignBackground(int selection) const;
 	CanvasPtr createSpellTabNone() const;
+	CanvasPtr createResBarElement(const PlayerColor & player) const;
 	CanvasPtr createChroniclesCampaignImages(int chronicle) const;
 	CanvasPtr createPaletteShiftedImage(const AnimationPath & source, const std::vector<PaletteAnimation> & animation, int frameIndex, int paletteShiftCounter) const;
 	CanvasPtr createAdventureMapButtonClear(const PlayerColor & player) const;

+ 2 - 3
config/widgets/adventureMap.json

@@ -467,9 +467,8 @@
 		},
 		// Resource & Data bar
 		{
-			"type": "adventurePlayerTexture",
-			"name" : "backgroundLeftOfResourceDateBar",
-			"image" : "DiBoxBck.pcx",
+			"type": "adventureResourceAdditional",
+			"name" : "resourceAdditional",
 			"area" : { "left": 3, "bottom" : 4, "right" : 797, "height" : 21 }
 		},
 		{