mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
resbar
This commit is contained in:
@@ -55,6 +55,7 @@ AdventureMapWidget::AdventureMapWidget( std::shared_ptr<AdventureMapShortcuts> s
|
|||||||
REGISTER_BUILDER("adventureResourceDateBar", &AdventureMapWidget::buildResourceDateBar );
|
REGISTER_BUILDER("adventureResourceDateBar", &AdventureMapWidget::buildResourceDateBar );
|
||||||
REGISTER_BUILDER("adventureStatusBar", &AdventureMapWidget::buildStatusBar );
|
REGISTER_BUILDER("adventureStatusBar", &AdventureMapWidget::buildStatusBar );
|
||||||
REGISTER_BUILDER("adventurePlayerTexture", &AdventureMapWidget::buildTexturePlayerColored);
|
REGISTER_BUILDER("adventurePlayerTexture", &AdventureMapWidget::buildTexturePlayerColored);
|
||||||
|
REGISTER_BUILDER("adventureResourceAdditional", &AdventureMapWidget::buildResourceAdditional );
|
||||||
|
|
||||||
for (const auto & entry : shortcuts->getShortcuts())
|
for (const auto & entry : shortcuts->getShortcuts())
|
||||||
addShortcut(entry.shortcut, entry.callback);
|
addShortcut(entry.shortcut, entry.callback);
|
||||||
@@ -316,6 +317,20 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildTexturePlayerColored(const
|
|||||||
return std::make_shared<FilledTexturePlayerColored>(area);
|
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()
|
std::shared_ptr<CHeroList> AdventureMapWidget::getHeroList()
|
||||||
{
|
{
|
||||||
return heroList;
|
return heroList;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
|
|||||||
std::shared_ptr<CIntObject> buildResourceDateBar(const JsonNode & input);
|
std::shared_ptr<CIntObject> buildResourceDateBar(const JsonNode & input);
|
||||||
std::shared_ptr<CIntObject> buildStatusBar(const JsonNode & input);
|
std::shared_ptr<CIntObject> buildStatusBar(const JsonNode & input);
|
||||||
std::shared_ptr<CIntObject> buildTexturePlayerColored(const JsonNode &);
|
std::shared_ptr<CIntObject> buildTexturePlayerColored(const JsonNode &);
|
||||||
|
std::shared_ptr<CIntObject> buildResourceAdditional(const JsonNode &);
|
||||||
|
|
||||||
void setPlayerChildren(CIntObject * widget, const PlayerColor & player);
|
void setPlayerChildren(CIntObject * widget, const PlayerColor & player);
|
||||||
void updateActiveStateChildden(CIntObject * widget);
|
void updateActiveStateChildden(CIntObject * widget);
|
||||||
|
|||||||
@@ -18,15 +18,19 @@
|
|||||||
#include "../GameInstance.h"
|
#include "../GameInstance.h"
|
||||||
#include "../gui/TextAlignment.h"
|
#include "../gui/TextAlignment.h"
|
||||||
#include "../widgets/Images.h"
|
#include "../widgets/Images.h"
|
||||||
|
#include "../widgets/CComponent.h"
|
||||||
|
#include "../windows/InfoWindows.h"
|
||||||
|
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../../lib/callback/CCallback.h"
|
#include "../../lib/callback/CCallback.h"
|
||||||
#include "../../lib/texts/CGeneralTextHandler.h"
|
#include "../../lib/texts/CGeneralTextHandler.h"
|
||||||
#include "../../lib/ResourceSet.h"
|
#include "../../lib/ResourceSet.h"
|
||||||
#include "../../lib/GameLibrary.h"
|
#include "../../lib/GameLibrary.h"
|
||||||
|
#include "../../lib/networkPacks/Component.h"
|
||||||
|
|
||||||
CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position)
|
CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position)
|
||||||
{
|
{
|
||||||
|
addUsedEvents(SHOW_POPUP);
|
||||||
pos.x += position.x;
|
pos.x += position.x;
|
||||||
pos.y += position.y;
|
pos.y += position.y;
|
||||||
|
|
||||||
@@ -89,3 +93,15 @@ void CResDataBar::setPlayerColor(PlayerColor player)
|
|||||||
{
|
{
|
||||||
background->setPlayerColor(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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public:
|
|||||||
void setResourcePosition(const GameResID & resource, const Point & position);
|
void setResourcePosition(const GameResID & resource, const Point & position);
|
||||||
|
|
||||||
void setPlayerColor(PlayerColor player);
|
void setPlayerColor(PlayerColor player);
|
||||||
|
void showPopupWindow(const Point & cursorPosition) override;
|
||||||
void showAll(Canvas & to) override;
|
void showAll(Canvas & to) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ void AssetGenerator::initialize()
|
|||||||
imageFiles[ImagePath::builtin("CampaignBackground8.png")] = [this]() { return createCampaignBackground(8); };
|
imageFiles[ImagePath::builtin("CampaignBackground8.png")] = [this]() { return createCampaignBackground(8); };
|
||||||
|
|
||||||
imageFiles[ImagePath::builtin("SpelTabNone.png")] = [this](){ return createSpellTabNone();};
|
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-0.png")] = [this](){ return createCreatureInfoPanel(2);};
|
||||||
imageFiles[ImagePath::builtin("stackWindow/info-panel-1.png")] = [this](){ return createCreatureInfoPanel(3);};
|
imageFiles[ImagePath::builtin("stackWindow/info-panel-1.png")] = [this](){ return createCreatureInfoPanel(3);};
|
||||||
@@ -322,6 +327,20 @@ AssetGenerator::CanvasPtr AssetGenerator::createCampaignBackground(int selection
|
|||||||
return image;
|
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
|
AssetGenerator::CanvasPtr AssetGenerator::createSpellTabNone() const
|
||||||
{
|
{
|
||||||
auto img1 = ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("SPELTAB"), EImageBlitMode::COLORKEY)->getImage(0);
|
auto img1 = ENGINE->renderHandler().loadAnimation(AnimationPath::builtin("SPELTAB"), EImageBlitMode::COLORKEY)->getImage(0);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ private:
|
|||||||
CanvasPtr createCombatUnitNumberWindow(float multR, float multG, float multB) const;
|
CanvasPtr createCombatUnitNumberWindow(float multR, float multG, float multB) const;
|
||||||
CanvasPtr createCampaignBackground(int selection) const;
|
CanvasPtr createCampaignBackground(int selection) const;
|
||||||
CanvasPtr createSpellTabNone() const;
|
CanvasPtr createSpellTabNone() const;
|
||||||
|
CanvasPtr createResBarElement(const PlayerColor & player) const;
|
||||||
CanvasPtr createChroniclesCampaignImages(int chronicle) const;
|
CanvasPtr createChroniclesCampaignImages(int chronicle) const;
|
||||||
CanvasPtr createPaletteShiftedImage(const AnimationPath & source, const std::vector<PaletteAnimation> & animation, int frameIndex, int paletteShiftCounter) const;
|
CanvasPtr createPaletteShiftedImage(const AnimationPath & source, const std::vector<PaletteAnimation> & animation, int frameIndex, int paletteShiftCounter) const;
|
||||||
CanvasPtr createAdventureMapButtonClear(const PlayerColor & player) const;
|
CanvasPtr createAdventureMapButtonClear(const PlayerColor & player) const;
|
||||||
|
|||||||
@@ -467,9 +467,8 @@
|
|||||||
},
|
},
|
||||||
// Resource & Data bar
|
// Resource & Data bar
|
||||||
{
|
{
|
||||||
"type": "adventurePlayerTexture",
|
"type": "adventureResourceAdditional",
|
||||||
"name" : "backgroundLeftOfResourceDateBar",
|
"name" : "resourceAdditional",
|
||||||
"image" : "DiBoxBck.pcx",
|
|
||||||
"area" : { "left": 3, "bottom" : 4, "right" : 797, "height" : 21 }
|
"area" : { "left": 3, "bottom" : 4, "right" : 797, "height" : 21 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user