mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-03 14:52:11 +02:00
Fixed player-coloring on adventure map
This commit is contained in:
parent
920a39844b
commit
0e407540ec
@ -59,7 +59,7 @@ AdventureMapWidget::AdventureMapWidget( std::shared_ptr<AdventureMapShortcuts> s
|
||||
const JsonNode config(JsonPath::builtin("config/widgets/adventureMap.json"));
|
||||
|
||||
for(const auto & entry : config["options"]["imagesPlayerColored"].Vector())
|
||||
playerColorerImages.push_back(ImagePath::fromJson(entry));
|
||||
playerColoredImages.push_back(ImagePath::fromJson(entry));
|
||||
|
||||
build(config);
|
||||
addUsedEvents(KEYBOARD);
|
||||
@ -135,8 +135,12 @@ std::shared_ptr<CIntObject> AdventureMapWidget::buildMapImage(const JsonNode & i
|
||||
{
|
||||
Rect targetArea = readTargetArea(input["area"]);
|
||||
Rect sourceArea = readSourceArea(input["sourceArea"], input["area"]);
|
||||
ImagePath path = ImagePath::fromJson(input["image"]);
|
||||
|
||||
return std::make_shared<CFilledTexture>(ImagePath::fromJson(input["image"]), targetArea, sourceArea);
|
||||
if (vstd::contains(playerColoredImages, path))
|
||||
return std::make_shared<FilledTexturePlayerIndexed>(path, targetArea, sourceArea);
|
||||
else
|
||||
return std::make_shared<CFilledTexture>(path, targetArea, sourceArea);
|
||||
}
|
||||
|
||||
std::shared_ptr<CIntObject> AdventureMapWidget::buildMapButton(const JsonNode & input)
|
||||
@ -348,7 +352,8 @@ void AdventureMapWidget::setPlayerChildren(CIntObject * widget, const PlayerColo
|
||||
auto icon = dynamic_cast<CAdventureMapIcon *>(entry);
|
||||
auto button = dynamic_cast<CButton *>(entry);
|
||||
auto resDataBar = dynamic_cast<CResDataBar *>(entry);
|
||||
auto texture = dynamic_cast<FilledTexturePlayerColored *>(entry);
|
||||
auto textureColored = dynamic_cast<FilledTexturePlayerColored *>(entry);
|
||||
auto textureIndexed = dynamic_cast<FilledTexturePlayerIndexed *>(entry);
|
||||
|
||||
if(button)
|
||||
button->setPlayerColor(player);
|
||||
@ -362,8 +367,11 @@ void AdventureMapWidget::setPlayerChildren(CIntObject * widget, const PlayerColo
|
||||
if(container)
|
||||
setPlayerChildren(container, player);
|
||||
|
||||
if (texture)
|
||||
texture->setPlayerColor(player);
|
||||
if (textureColored)
|
||||
textureColored->setPlayerColor(player);
|
||||
|
||||
if (textureIndexed)
|
||||
textureIndexed->setPlayerColor(player);
|
||||
}
|
||||
|
||||
redraw();
|
||||
|
@ -28,7 +28,7 @@ class AdventureMapWidget : public InterfaceObjectConfigurable
|
||||
std::vector<Rect> subwidgetSizes;
|
||||
|
||||
/// list of images on which player-colored palette will be applied
|
||||
std::vector<ImagePath> playerColorerImages;
|
||||
std::vector<ImagePath> playerColoredImages;
|
||||
|
||||
/// Widgets that require access from adventure map
|
||||
std::shared_ptr<CHeroList> heroList;
|
||||
|
@ -140,9 +140,9 @@ void CFilledTexture::showAll(Canvas & to)
|
||||
}
|
||||
}
|
||||
|
||||
FilledTexturePlayerColored::FilledTexturePlayerColored(const ImagePath & imageName, Rect position)
|
||||
: CFilledTexture(imageName, position)
|
||||
void FilledTexturePlayerIndexed::setPlayerColor(PlayerColor player)
|
||||
{
|
||||
texture->playerColored(player);
|
||||
}
|
||||
|
||||
void FilledTexturePlayerColored::setPlayerColor(PlayerColor player)
|
||||
|
@ -74,10 +74,20 @@ public:
|
||||
void showAll(Canvas & to) override;
|
||||
};
|
||||
|
||||
/// area filled with specific texture, colorized to player color if image is indexed
|
||||
class FilledTexturePlayerIndexed : public CFilledTexture
|
||||
{
|
||||
public:
|
||||
using CFilledTexture::CFilledTexture;
|
||||
|
||||
void setPlayerColor(PlayerColor player);
|
||||
};
|
||||
|
||||
/// area filled with specific texture, with applied color filter to colorize it to specific player
|
||||
class FilledTexturePlayerColored : public CFilledTexture
|
||||
{
|
||||
public:
|
||||
FilledTexturePlayerColored(const ImagePath & imageName, Rect position);
|
||||
using CFilledTexture::CFilledTexture;
|
||||
|
||||
void setPlayerColor(PlayerColor player);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user