1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Change font::len text argument from std::string to const char*

See the previous two commits, a lot of the time we don't need
std::string objects to be passed to these functions because we already
have C strings.

   Commit 1/3: font::print_wrap
   Commit 2/3: font::print
-> Commit 3/3: font::len
This commit is contained in:
Dav999-v 2023-03-05 00:32:58 +01:00 committed by Misa Elizabeth Kai
parent 5e3a4e69ce
commit d112dee72c
7 changed files with 11 additions and 12 deletions

View file

@ -790,7 +790,7 @@ void editorrender(void)
}
else
{
fillboxabs((customentities[i].x*8)-(ed.levx*40*8), (customentities[i].y*8)-(ed.levy*30*8), font::len(PR_FONT_LEVEL, customentities[i].scriptname), font::height(PR_FONT_LEVEL), graphics.getRGB(96,96,96));
fillboxabs((customentities[i].x*8)-(ed.levx*40*8), (customentities[i].y*8)-(ed.levy*30*8), font::len(PR_FONT_LEVEL, customentities[i].scriptname.c_str()), font::height(PR_FONT_LEVEL), graphics.getRGB(96,96,96));
}
font::print(PR_FONT_LEVEL | PR_CJK_LOW, (customentities[i].x*8)-(ed.levx*40*8), (customentities[i].y*8)-(ed.levy*30*8), customentities[i].scriptname, 196, 196, 255 - help.glow);
break;
@ -1245,7 +1245,7 @@ void editorrender(void)
//Draw cursor
if(ed.entframe<2)
{
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16+font::len(PR_FONT_LEVEL, ed.sb[ed.pagey+ed.sby]),20+(ed.sby*font_height),"_",123, 111, 218);
font::print(PR_FONT_LEVEL | PR_CJK_LOW, 16+font::len(PR_FONT_LEVEL, ed.sb[ed.pagey+ed.sby].c_str()),20+(ed.sby*font_height),"_",123, 111, 218);
}
break;
}

View file

@ -1147,13 +1147,12 @@ bool glyph_dimensions(uint32_t flags, uint8_t* glyph_w, uint8_t* glyph_h)
return true;
}
int len(const uint32_t flags, const std::string& t)
int len(const uint32_t flags, const char* text)
{
PrintFlags pf = decode_print_flags(flags);
int text_len = 0;
uint32_t codepoint;
const char* text = t.c_str(); // TODO no std::string
while ((codepoint = UTF8_next(&text)))
{
text_len += get_advance(pf.font_sel, codepoint);

View file

@ -81,7 +81,7 @@ std::string string_unwordwrap(const std::string& s);
bool glyph_dimensions(uint32_t flags, uint8_t* glyph_w, uint8_t* glyph_h);
int len(uint32_t flags, const std::string& t);
int len(uint32_t flags, const char* text);
int height(const uint32_t flags);
void print(

View file

@ -468,7 +468,7 @@ void Graphics::print_level_creator(
* - it makes sense to make it a face
* - if anyone is sad about this decision, the happy face will cheer them up anyway :D */
int width_for_face = 17;
int total_width = width_for_face + font::len(print_flags, creator);
int total_width = width_for_face + font::len(print_flags, creator.c_str());
int face_x = (SCREEN_WIDTH_PIXELS-total_width)/2;
set_texture_color_mod(grphx.im_sprites, r, g, b);
draw_texture_part(grphx.im_sprites, face_x, y-1, 7, 2, 10, 10, 1, 1);
@ -1366,7 +1366,7 @@ void Graphics::createtextboxreal(
textboxclass text;
text.lines.push_back(t);
text.xp = xp;
if (xp == -1) text.xp = 160 - ((font::len(PR_FONT_LEVEL, t) / 2) + 8);
if (xp == -1) text.xp = 160 - ((font::len(PR_FONT_LEVEL, t.c_str()) / 2) + 8);
text.yp = yp;
text.initcol(r, g, b);
text.flipme = flipme;
@ -1567,7 +1567,7 @@ void Graphics::drawmenu(int cr, int cg, int cb, enum Menu::MenuName menu)
vformat_buf(buffer, sizeof(buffer), loc::get_langmeta()->menu_select.c_str(), "label:str", opt_text.c_str());
// Account for brackets
x -= (font::len(opt.print_flags, buffer)-font::len(opt.print_flags, opt_text))/2;
x -= (font::len(opt.print_flags, buffer)-font::len(opt.print_flags, opt_text.c_str()))/2;
}
else
{

View file

@ -1497,7 +1497,7 @@ static void menurender(void)
int w[4] = {
font::len(0, str_par_time),
font::len(0, par_time),
font::len(0, par_time.c_str()),
font::len(0, str_best_rank),
font::len(PR_2X, rank)
};
@ -2189,7 +2189,7 @@ void gamerender(void)
}
std::string time = game.timetstring(game.timetrialpar);
label_len = font::len(0, time);
label_len = font::len(0, time.c_str());
if(game.timetrialparlost)
{
font::print(PR_BOR | PR_RIGHT, 307-label_len-8, 214, loc::gettext("PAR TIME:"), 80, 80, 80);

View file

@ -186,7 +186,7 @@ namespace roomname_translator
{
*force_roomname_hidden = true;
graphics.render_roomname(PR_FONT_LEVEL, key.keybuffer.c_str(), 255,255,255);
int name_w = font::len(PR_FONT_LEVEL, key.keybuffer);
int name_w = font::len(PR_FONT_LEVEL, key.keybuffer.c_str());
font::print(PR_BOR | PR_FONT_LEVEL, (320-name_w)/2+name_w, 231, "_", 255,255,255);
}
else if (!roomname_is_translated)

View file

@ -106,7 +106,7 @@ void textboxclass::resize(void)
int max = 0;
for (size_t iter = 0; iter < lines.size(); iter++)
{
int len = font::len(print_flags, lines[iter]);
int len = font::len(print_flags, lines[iter].c_str());
if (len > max) max = len;
}