Phased out color2hexa and unit32_to_pango_color in favor of their color_t counterparts
This commit is contained in:
parent
fd8e712952
commit
bb5d3078d9
3 changed files with 4 additions and 36 deletions
|
@ -16,39 +16,22 @@
|
|||
#include "formatter.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace font {
|
||||
|
||||
std::string unit32_to_pango_color(uint32_t rgb)
|
||||
{
|
||||
std::ostringstream h;
|
||||
|
||||
// Must match what the pango expects
|
||||
h << "#"
|
||||
<< std::hex << std::setfill('0') << std::setw(2) << ((rgb & 0xFF0000) >> 16)
|
||||
<< std::hex << std::setfill('0') << std::setw(2) << ((rgb & 0x00FF00) >> 8)
|
||||
<< std::hex << std::setfill('0') << std::setw(2) << (rgb & 0x0000FF);
|
||||
|
||||
return h.str();
|
||||
}
|
||||
|
||||
std::string color2hexa(const SDL_Color& color)
|
||||
{
|
||||
return unit32_to_pango_color((color.r << 16 ) + (color.g << 8) + (color.b));
|
||||
}
|
||||
|
||||
std::string span_color(const SDL_Color& color)
|
||||
{
|
||||
return "<span color='" + color2hexa(color) + "'>";
|
||||
return formatter() << "<span color='" << color_t(color).to_hex_string() << "'>";
|
||||
}
|
||||
|
||||
std::string get_pango_color_from_id(const std::string& id)
|
||||
{
|
||||
const auto color = game_config::team_rgb_colors.find(id);
|
||||
if(color != game_config::team_rgb_colors.end()) {
|
||||
return unit32_to_pango_color(color->second[0]);
|
||||
return color_t::from_rgba_bytes(color->second[0]).to_hex_string();
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -23,21 +23,6 @@
|
|||
|
||||
namespace font {
|
||||
|
||||
/**
|
||||
* Converts a color value to Pango markup syntax. The '#' prefix is prepended.
|
||||
*
|
||||
* @param color The 32 byte color to convert to hex format.
|
||||
* For example, 0x00CC00CC becomes "#CC00CC".
|
||||
*/
|
||||
std::string unit32_to_pango_color(uint32_t rgb);
|
||||
|
||||
/**
|
||||
* Returns a hex color string from a SDL_Color object. The '#' prefix is not prepended.
|
||||
*
|
||||
* @param color The SDL_Color object from which to retrieve the color.
|
||||
*/
|
||||
std::string color2hexa(const SDL_Color& color);
|
||||
|
||||
/**
|
||||
* Retuns a Pango formatting string using the provided SDL_Color object.
|
||||
*
|
||||
|
|
|
@ -850,7 +850,7 @@ std::string team::get_side_color_index(int side)
|
|||
|
||||
std::string team::get_side_highlight_pango(int side)
|
||||
{
|
||||
return font::unit32_to_pango_color(get_side_color_range(side+1).mid());
|
||||
return color_t::from_rgba_bytes(get_side_color_range(side + 1).mid()).to_hex_string();
|
||||
}
|
||||
|
||||
void team::log_recruitable() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue