1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #2687 from Nordsoft91/filledTexturePlayerColored

Support FilledTexturePlayerColored in configurable interface
This commit is contained in:
Ivan Savenko 2023-08-31 15:43:40 +03:00 committed by GitHub
commit a59d7b5fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include "../windows/GUIClasses.h"
#include "../windows/InfoWindows.h"
#include "../../lib//constants/StringConstants.h"
#include "../../lib/CGeneralTextHandler.h"
#include "../../lib/filesystem/ResourceID.h"
@ -228,8 +229,19 @@ ColorRGBA InterfaceObjectConfigurable::readColor(const JsonNode & config) const
}
logGlobal->debug("Uknown color attribute");
return Colors::DEFAULT_KEY_COLOR;
}
PlayerColor InterfaceObjectConfigurable::readPlayerColor(const JsonNode & config) const
{
logGlobal->debug("Reading PlayerColor");
if(!config.isNull() && config.isString())
return PlayerColor(vstd::find_pos(GameConstants::PLAYER_COLOR_NAMES, config.String()));
logGlobal->debug("Unknown PlayerColor attribute");
return PlayerColor::CANNOT_DETERMINE;
}
EFonts InterfaceObjectConfigurable::readFont(const JsonNode & config) const
{
logGlobal->debug("Reading font");
@ -519,6 +531,12 @@ std::shared_ptr<CFilledTexture> InterfaceObjectConfigurable::buildTexture(const
logGlobal->debug("Building widget CFilledTexture");
auto image = config["image"].String();
auto rect = readRect(config["rect"]);
auto playerColor = readPlayerColor(config["color"]);
if(playerColor.isValidPlayer())
{
auto result = std::make_shared<FilledTexturePlayerColored>(image, rect);
result->playerColored(playerColor);
}
return std::make_shared<CFilledTexture>(image, rect);
}

View File

@ -83,6 +83,7 @@ protected:
std::string readText(const JsonNode &) const;
std::pair<std::string, std::string> readHintText(const JsonNode &) const;
EShortcut readHotkey(const JsonNode &) const;
PlayerColor readPlayerColor(const JsonNode &) const;
void loadToggleButtonCallback(std::shared_ptr<CToggleButton> button, const JsonNode & config) const;
void loadButtonCallback(std::shared_ptr<CButton> button, const JsonNode & config) const;