From 3e502955b32bac05af4a28d62ac7815fa55775a3 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 27 Aug 2023 22:34:02 +0400 Subject: [PATCH] Support FilledTexturePlayerColored in configurable interface --- client/gui/InterfaceObjectConfigurable.cpp | 20 +++++++++++++++++++- client/gui/InterfaceObjectConfigurable.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index 37cb233f3..d8ffc8957 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -28,6 +28,7 @@ #include "../windows/GUIClasses.h" #include "../windows/InfoWindows.h" +#include "../../lib//constants/StringConstants.h" #include "../../lib/CGeneralTextHandler.h" #include "../../lib/filesystem/ResourceID.h" @@ -219,8 +220,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"); @@ -510,6 +522,12 @@ std::shared_ptr 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(image, rect); + result->playerColored(playerColor); + } return std::make_shared(image, rect); } diff --git a/client/gui/InterfaceObjectConfigurable.h b/client/gui/InterfaceObjectConfigurable.h index 86a3381c0..b8a155b26 100644 --- a/client/gui/InterfaceObjectConfigurable.h +++ b/client/gui/InterfaceObjectConfigurable.h @@ -80,6 +80,7 @@ protected: std::string readText(const JsonNode &) const; std::pair readHintText(const JsonNode &) const; EShortcut readHotkey(const JsonNode &) const; + PlayerColor readPlayerColor(const JsonNode &) const; void loadToggleButtonCallback(std::shared_ptr button, const JsonNode & config) const; void loadButtonCallback(std::shared_ptr button, const JsonNode & config) const;