gui1: Drop last instances of GUI1 markup support in menu widgets

This commit is contained in:
Iris Morelle 2021-03-10 17:31:42 -03:00
parent 5ce799ddbd
commit c5e1f77e80
3 changed files with 2 additions and 126 deletions

View file

@ -33,117 +33,6 @@
namespace font {
// NOTE: if you add more markup characters below, you'll need to update
// the list in campaign_server.cpp (illegal_markup_chars) to blacklist
// them for add-on names and titles.
const char LARGE_TEXT='*', SMALL_TEXT='`',
BOLD_TEXT='~', NORMAL_TEXT='{',
NULL_MARKUP='^',
BLACK_TEXT='}', GRAY_TEXT='|',
GOOD_TEXT='@', BAD_TEXT='#',
GREEN_TEXT='@', RED_TEXT='#',
COLOR_TEXT='<', IMAGE='&';
std::string::const_iterator parse_markup(std::string::const_iterator i1,
std::string::const_iterator i2,
int* font_size,
color_t* color, int* /*style*/)
{
while(i1 != i2) {
switch(*i1) {
case '\\':
// This must either be a quoted special character or a
// quoted backslash - either way, remove leading backslash
break;
case BAD_TEXT:
if (color) *color = BAD_COLOR;
break;
case GOOD_TEXT:
if (color) *color = GOOD_COLOR;
break;
case NORMAL_TEXT:
if (color) *color = NORMAL_COLOR;
break;
case BLACK_TEXT:
if (color) *color = BLACK_COLOR;
break;
case GRAY_TEXT:
if (color) *color = GRAY_COLOR;
break;
case LARGE_TEXT:
if (font_size) *font_size += 2;
break;
case SMALL_TEXT:
if (font_size) *font_size -= 2;
break;
//case BOLD_TEXT:
// if (style) *style |= TTF_STYLE_BOLD;
// break;
case NULL_MARKUP:
return i1+1;
case COLOR_TEXT:
{
std::string::const_iterator start = i1;
// Very primitive parsing for rgb value
// should look like <213,14,151>
++i1;
uint8_t red=0, green=0, blue=0, temp=0;
while (i1 != i2 && *i1 >= '0' && *i1<='9') {
temp*=10;
temp += lexical_cast<int, char>(*i1);
++i1;
}
red=temp;
temp=0;
if (i1 != i2 && ',' == (*i1)) {
++i1;
while(i1 != i2 && *i1 >= '0' && *i1<='9'){
temp*=10;
temp += lexical_cast<int, char>(*i1);
++i1;
}
green=temp;
temp=0;
}
if (i1 != i2 && ',' == (*i1)) {
++i1;
while(i1 != i2 && *i1 >= '0' && *i1<='9'){
temp*=10;
temp += lexical_cast<int, char>(*i1);
++i1;
}
}
blue=temp;
if (i1 != i2 && '>' == (*i1)) {
color_t temp_color {red, green, blue, 0};
if (color) *color = temp_color;
} else {
// stop parsing and do not consume any chars
return start;
}
if (i1 == i2) return i1;
break;
}
default:
return i1;
}
++i1;
}
return i1;
}
std::string del_tags(const std::string& text){
std::vector<std::string> lines = utils::split(text, '\n', 0);
std::vector<std::string>::iterator line;
for(line = lines.begin(); line != lines.end(); ++line) {
std::string::const_iterator i1 = line->begin(),
i2 = line->end();
*line = std::string(parse_markup(i1,i2,nullptr,nullptr,nullptr),i2);
}
return utils::join(lines, "\n");
}
bool is_cjk_char(const char32_t ch)
{
/**

View file

@ -25,19 +25,6 @@ class surface;
namespace font {
/** Standard markups for color, size, font, images. */
extern const char LARGE_TEXT, SMALL_TEXT, BOLD_TEXT, NORMAL_TEXT, NULL_MARKUP, BLACK_TEXT, GRAY_TEXT,
GOOD_TEXT, BAD_TEXT, GREEN_TEXT, RED_TEXT, COLOR_TEXT, IMAGE;
/** Parses the markup-tags at the front of a string. */
std::string::const_iterator parse_markup(std::string::const_iterator i1,
std::string::const_iterator i2,
int* font_size,
color_t* color, int* style);
/** Copy string, but without tags at the beginning */
std::string del_tags(const std::string& text);
/**
* Determine if a char32_t is a CJK character
*

View file

@ -106,8 +106,8 @@ bool menu::basic_sorter::less(int column, const item& row1, const item& row2) co
return true;
}
const std::string& item1 = font::del_tags(row1.fields[column]);
const std::string& item2 = font::del_tags(row2.fields[column]);
const std::string& item1 = row1.fields[column];
const std::string& item2 = row2.fields[column];
if(alpha_sort_.count(column) == 1) {
std::string::const_iterator begin1 = item1.begin(), end1 = item1.end(),