mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Reduce direct access to CAnimation, removed various caching schemes
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../gui/Shortcut.h"
|
||||
#include "../mapView/MapView.h"
|
||||
#include "../render/CAnimation.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "../render/IRenderHandler.h"
|
||||
#include "../widgets/Buttons.h"
|
||||
@@ -125,26 +124,6 @@ Rect AdventureMapWidget::readArea(const JsonNode & source, const Rect & bounding
|
||||
return Rect(topLeft + boundingBox.topLeft(), dimensions);
|
||||
}
|
||||
|
||||
std::shared_ptr<IImage> AdventureMapWidget::loadImage(const JsonNode & name)
|
||||
{
|
||||
ImagePath resource = ImagePath::fromJson(name);
|
||||
|
||||
if(images.count(resource) == 0)
|
||||
images[resource] = GH.renderHandler().loadImage(resource);
|
||||
|
||||
return images[resource];
|
||||
}
|
||||
|
||||
std::shared_ptr<CAnimation> AdventureMapWidget::loadAnimation(const JsonNode & name)
|
||||
{
|
||||
AnimationPath resource = AnimationPath::fromJson(name);
|
||||
|
||||
if(animations.count(resource) == 0)
|
||||
animations[resource] = GH.renderHandler().loadAnimation(resource);
|
||||
|
||||
return animations[resource];
|
||||
}
|
||||
|
||||
std::shared_ptr<CIntObject> AdventureMapWidget::buildInfobox(const JsonNode & input)
|
||||
{
|
||||
Rect area = readTargetArea(input["area"]);
|
||||
@@ -157,7 +136,7 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapImage(const JsonNode & i
|
||||
Rect targetArea = readTargetArea(input["area"]);
|
||||
Rect sourceArea = readSourceArea(input["sourceArea"], input["area"]);
|
||||
|
||||
return std::make_shared<CFilledTexture>(loadImage(input["image"]), targetArea, sourceArea);
|
||||
return std::make_shared<CFilledTexture>(ImagePath::fromJson(input["image"]), targetArea, sourceArea);
|
||||
}
|
||||
|
||||
std::shared_ptr<CIntObject> AdventureMapWidget::buildMapButton(const JsonNode & input)
|
||||
@@ -257,7 +236,7 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapIcon(const JsonNode & in
|
||||
size_t index = input["index"].Integer();
|
||||
size_t perPlayer = input["perPlayer"].Integer();
|
||||
|
||||
return std::make_shared<CAdventureMapIcon>(area.topLeft(), loadAnimation(input["image"]), index, perPlayer);
|
||||
return std::make_shared<CAdventureMapIcon>(area.topLeft(), AnimationPath::fromJson(input["image"]), index, perPlayer);
|
||||
}
|
||||
|
||||
std::shared_ptr<CIntObject> AdventureMapWidget::buildMapTownList(const JsonNode & input)
|
||||
@@ -387,16 +366,10 @@ void AdventureMapWidget::setPlayerChildren(CIntObject * widget, const PlayerColo
|
||||
texture->playerColored(player);
|
||||
}
|
||||
|
||||
for(const auto & entry : playerColorerImages)
|
||||
{
|
||||
if(images.count(entry))
|
||||
images[entry]->playerColored(player);
|
||||
}
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
CAdventureMapIcon::CAdventureMapIcon(const Point & position, std::shared_ptr<CAnimation> animation, size_t index, size_t iconsPerPlayer)
|
||||
CAdventureMapIcon::CAdventureMapIcon(const Point & position, const AnimationPath & animation, size_t index, size_t iconsPerPlayer)
|
||||
: index(index)
|
||||
, iconsPerPlayer(iconsPerPlayer)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user