Make more public an utility function generating pango color markup.
This commit is contained in:
parent
8c731f62e4
commit
8934cebdf1
4 changed files with 19 additions and 9 deletions
|
@ -26,6 +26,8 @@
|
|||
#include "../gettext.hpp"
|
||||
#include "../serialization/string_utils.hpp"
|
||||
#include "../tooltips.hpp"
|
||||
#include "../marked-up_text.hpp"
|
||||
|
||||
|
||||
namespace editor {
|
||||
|
||||
|
@ -498,10 +500,11 @@ void terrain_palette::draw(bool force) {
|
|||
tooltip_text << " - " << terrain;
|
||||
}
|
||||
if (!is_core) {
|
||||
tooltip_text << " <span foreground=\"red\">";
|
||||
tooltip_text << _("(non-core)") << "\n";
|
||||
tooltip_text << _("Will not work in game without extra care.");
|
||||
tooltip_text << "</span>";
|
||||
tooltip_text << " "
|
||||
<< font::span_color(font::BAD_COLOUR)
|
||||
<< _("(non-core)") << "\n"
|
||||
<< _("Will not work in game without extra care.")
|
||||
<< "</span>";
|
||||
}
|
||||
tooltips::add_tooltip(dstrect, tooltip_text.str());
|
||||
if (counter_from_zero % size_specs_.terrain_width == size_specs_.terrain_width - 1)
|
||||
|
|
|
@ -53,11 +53,6 @@ static std::string flush(std::ostringstream &s)
|
|||
return r;
|
||||
}
|
||||
|
||||
static std::string span_color(SDL_Color const &c)
|
||||
{
|
||||
return "<span foreground=\"#" + font::color2hexa(c) + "\">";
|
||||
}
|
||||
|
||||
static char const *naps = "</span>";
|
||||
|
||||
report generate_report(TYPE type,
|
||||
|
@ -83,6 +78,7 @@ report generate_report(TYPE type,
|
|||
std::ostringstream str;
|
||||
std::ostringstream tooltip;
|
||||
using utils::signed_percent;
|
||||
using font::span_color;
|
||||
|
||||
switch(type) {
|
||||
case UNIT_NAME:
|
||||
|
|
|
@ -171,6 +171,11 @@ std::string color2hexa(const SDL_Color &color)
|
|||
return buf;
|
||||
}
|
||||
|
||||
std::string span_color(const SDL_Color &color)
|
||||
{
|
||||
return "<span foreground=\"#" + font::color2hexa(color) + "\">";
|
||||
}
|
||||
|
||||
SDL_Rect text_area(const std::string& text, int size, int style)
|
||||
{
|
||||
const SDL_Rect area = {0,0,10000,10000};
|
||||
|
|
|
@ -97,6 +97,12 @@ std::string color2markup(const SDL_Color &color);
|
|||
/** Creates the hexadecimal string of a color, such as "#ffff00" for yellow. */
|
||||
std::string color2hexa(const SDL_Color &color);
|
||||
|
||||
/**
|
||||
* Creates pango markup of a color.
|
||||
* Don't forget to close it with a </span>
|
||||
*/
|
||||
std::string span_color(const SDL_Color &color);
|
||||
|
||||
/**
|
||||
* Wrap text.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue