diff --git a/client/adventureMap/AdventureMapWidget.cpp b/client/adventureMap/AdventureMapWidget.cpp index 43cb8dea4..f1777ed1f 100644 --- a/client/adventureMap/AdventureMapWidget.cpp +++ b/client/adventureMap/AdventureMapWidget.cpp @@ -46,18 +46,19 @@ AdventureMapWidget::AdventureMapWidget( std::shared_ptr 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); @@ -328,6 +329,44 @@ std::shared_ptr AdventureMapWidget::buildTexturePlayerColored(const return std::make_shared(area); } +std::shared_ptr AdventureMapWidget::buildResourceAdditional(const JsonNode & input) +{ + OBJECT_CONSTRUCTION; + + logGlobal->debug("Building widget ResourceAdditional"); + Rect area = readTargetArea(input["area"]); + auto obj = std::make_shared(); + + int remainingSpace = area.w; + int resElementSize = 84; + int fitOffset = 2; + for (int i = 0; i < 15; i++) // TODO: Replace with resources amount + { + if(remainingSpace < resElementSize) + break; + + auto resource = GameResID::SULFUR; // TODO: Replace with resource + + auto res = std::make_shared(ImagePath::builtin("ResBarElement"), area.topRight() + Point(remainingSpace - area.w - resElementSize + fitOffset, 0)); + res->setResourcePosition(resource, Point(35, 3)); + addWidget("", res); + obj->addChild(res.get()); + + auto resIcon = std::make_shared(AnimationPath::builtin("SMALRES"), GameResID(resource), 0, res->pos.x + 4, res->pos.y + 2); + addWidget("", resIcon); + obj->addChild(resIcon.get()); + + remainingSpace -= resElementSize; + } + + area.w = remainingSpace + fitOffset; + auto texture = std::make_shared(area); + addWidget("", texture); + obj->addChild(texture.get()); + + return obj; +} + std::shared_ptr AdventureMapWidget::getHeroList() { return heroList; @@ -386,6 +425,8 @@ void AdventureMapWidget::setPlayerChildren(CIntObject * widget, const PlayerColo if (textureIndexed) textureIndexed->setPlayerColor(player); + + setPlayerChildren(entry, player); } redraw(); diff --git a/client/adventureMap/AdventureMapWidget.h b/client/adventureMap/AdventureMapWidget.h index 85111be88..38552d640 100644 --- a/client/adventureMap/AdventureMapWidget.h +++ b/client/adventureMap/AdventureMapWidget.h @@ -55,6 +55,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable std::shared_ptr buildResourceDateBar(const JsonNode & input); std::shared_ptr buildStatusBar(const JsonNode & input); std::shared_ptr buildTexturePlayerColored(const JsonNode &); + std::shared_ptr buildResourceAdditional(const JsonNode &); void setPlayerChildren(CIntObject * widget, const PlayerColor & player); void updateActiveStateChildren(CIntObject * widget); diff --git a/client/adventureMap/CResDataBar.cpp b/client/adventureMap/CResDataBar.cpp index adbc1fb9d..a09ebf5f4 100644 --- a/client/adventureMap/CResDataBar.cpp +++ b/client/adventureMap/CResDataBar.cpp @@ -32,7 +32,7 @@ CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position) { addUsedEvents(SHOW_POPUP); - + pos.x += position.x; pos.y += position.y; @@ -98,9 +98,12 @@ void CResDataBar::setPlayerColor(PlayerColor player) void CResDataBar::showPopupWindow(const Point & cursorPosition) { + if((cursorPosition.x - pos.x) > 600) + return; + std::vector> comp; for (auto & i : LIBRARY->resourceTypeHandler->getAllObjects()) - comp.push_back(std::make_shared(ComponentType::RESOURCE, i, GAME->interface()->cb->getResourceAmount(i))); - + comp.push_back(std::make_shared(ComponentType::RESOURCE, GameResID(i), GAME->interface()->cb->getResourceAmount(i))); + CRClickPopup::createAndPush(LIBRARY->generaltexth->translate("core.genrltxt.270"), comp); } diff --git a/client/render/AssetGenerator.cpp b/client/render/AssetGenerator.cpp index e5d71d864..30c59e5cb 100644 --- a/client/render/AssetGenerator.cpp +++ b/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);}; @@ -334,6 +339,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 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); diff --git a/client/render/AssetGenerator.h b/client/render/AssetGenerator.h index 287d9d76d..54e955253 100644 --- a/client/render/AssetGenerator.h +++ b/client/render/AssetGenerator.h @@ -55,6 +55,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 & animation, int frameIndex, int paletteShiftCounter) const; CanvasPtr createAdventureMapButtonClear(const PlayerColor & player, bool small) const; diff --git a/config/widgets/adventureMap.json b/config/widgets/adventureMap.json index c6ef397e4..2284d4221 100644 --- a/config/widgets/adventureMap.json +++ b/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 } }, {