mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Completely remove Graphics::bprint
Only three deprecated functions remain: - Graphics::Print - Graphics::PrintWrap - Graphics::bigprint I also fixed multiline transparent textboxes having their outlines overlap the text itself, and fixed textboxclass::padtowidth assuming glyph widths of 8 (it made the hints at the start of intermission 1 run offscreen for example)
This commit is contained in:
parent
d784f7f61a
commit
ddaabb3efe
8 changed files with 75 additions and 64 deletions
|
@ -732,12 +732,12 @@ void editorrender(void)
|
|||
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(255, 164, 164));
|
||||
if (i == edent_under_cursor)
|
||||
{
|
||||
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,
|
||||
font::print(PR_BOR | PR_CJK_HIGH, (customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,
|
||||
"("+help.String(customentities[i].p1/40 + 1)+","+help.String(customentities[i].p2/30 + 1)+")",210,210,255);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255);
|
||||
font::print(PR_BOR | PR_CJK_HIGH, (customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255);
|
||||
}
|
||||
break;
|
||||
case 15: //Crewmates
|
||||
|
@ -794,7 +794,7 @@ void editorrender(void)
|
|||
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164));
|
||||
if (i == edent_under_cursor)
|
||||
{
|
||||
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
||||
font::print(PR_FONT_LEVEL | PR_BOR | PR_CJK_HIGH, (customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ void editorrender(void)
|
|||
fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,255));
|
||||
if (i == edent_under_cursor)
|
||||
{
|
||||
graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
||||
font::print(PR_FONT_LEVEL | PR_BOR | PR_CJK_HIGH, (customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255);
|
||||
}
|
||||
break;
|
||||
case 50: //Warp lines
|
||||
|
@ -866,12 +866,12 @@ void editorrender(void)
|
|||
fillboxabs((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),16,16,graphics.getRGB(96, 64, 64));
|
||||
if(ed.tilex+(ed.levx*40)==customentities[i].p1 && ed.tiley+(ed.levy*30)==customentities[i].p2)
|
||||
{
|
||||
graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,
|
||||
font::print(PR_BOR | PR_CJK_HIGH, (customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,
|
||||
"("+help.String(customentities[i].x/40 + 1)+","+help.String(customentities[i].y/30 + 1)+")",190,190,225);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225);
|
||||
font::print(PR_BOR | PR_CJK_HIGH, (customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1543,55 +1543,55 @@ void editorrender(void)
|
|||
switch(ed.drawmode)
|
||||
{
|
||||
case 0:
|
||||
graphics.bprint(2,2, loc::gettext("1: Walls"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("1: Walls"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 1:
|
||||
graphics.bprint(2,2, loc::gettext("2: Backing"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("2: Backing"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 2:
|
||||
graphics.bprint(2,2, loc::gettext("3: Spikes"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("3: Spikes"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 3:
|
||||
graphics.bprint(2,2, loc::gettext("4: Trinkets"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("4: Trinkets"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 4:
|
||||
graphics.bprint(2,2, loc::gettext("5: Checkpoint"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("5: Checkpoint"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 5:
|
||||
graphics.bprint(2,2, loc::gettext("6: Disappear"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("6: Disappear"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 6:
|
||||
graphics.bprint(2,2, loc::gettext("7: Conveyors"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("7: Conveyors"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 7:
|
||||
graphics.bprint(2,2, loc::gettext("8: Moving"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("8: Moving"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 8:
|
||||
graphics.bprint(2,2, loc::gettext("9: Enemies"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("9: Enemies"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 9:
|
||||
graphics.bprint(2,2, loc::gettext("0: Grav Line"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("0: Grav Line"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 10:
|
||||
graphics.bprint(2,2, loc::gettext("R: Roomtext"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("R: Roomtext"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 11:
|
||||
graphics.bprint(2,2, loc::gettext("T: Terminal"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("T: Terminal"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 12:
|
||||
graphics.bprint(2,2, loc::gettext("Y: Script Box"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("Y: Script Box"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 13:
|
||||
graphics.bprint(2,2, loc::gettext("U: Warp Token"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("U: Warp Token"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 14:
|
||||
graphics.bprint(2,2, loc::gettext("I: Warp Lines"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("I: Warp Lines"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 15:
|
||||
graphics.bprint(2,2, loc::gettext("O: Crewmate"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("O: Crewmate"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
case 16:
|
||||
graphics.bprint(2,2, loc::gettext("P: Start Point"),196, 196, 255 - help.glow);
|
||||
font::print(PR_BOR, 2,2, loc::gettext("P: Start Point"),196, 196, 255 - help.glow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -738,27 +738,6 @@ static Font* container_get(FontContainer* container, uint8_t idx)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool glyph_dimensions_main(uint8_t idx, uint8_t* glyph_w, uint8_t* glyph_h)
|
||||
{
|
||||
/* Gets the dimensions (glyph_w and glyph_h) of fonts_main[idx].
|
||||
* Returns true if the font is valid (glyph_w and/or glyph_h were written to if not NULL), false if not. */
|
||||
|
||||
Font* f = container_get(&fonts_main, idx);
|
||||
if (f == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (glyph_w != NULL)
|
||||
{
|
||||
*glyph_w = f->glyph_w;
|
||||
}
|
||||
if (glyph_h != NULL)
|
||||
{
|
||||
*glyph_h = f->glyph_h;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* get_main_font_name(uint8_t idx)
|
||||
{
|
||||
Font* f = container_get(&fonts_main, idx);
|
||||
|
@ -831,6 +810,28 @@ static PrintFlags decode_print_flags(uint32_t flags)
|
|||
}
|
||||
#undef FLAG_PART
|
||||
|
||||
bool glyph_dimensions(uint32_t flags, uint8_t* glyph_w, uint8_t* glyph_h)
|
||||
{
|
||||
/* Gets the dimensions (glyph_w and glyph_h) of a certain font.
|
||||
* Returns true if the font is valid (glyph_w and/or glyph_h were written to if not NULL), false if not. */
|
||||
|
||||
PrintFlags pf = decode_print_flags(flags);
|
||||
|
||||
if (pf.font_sel == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (glyph_w != NULL)
|
||||
{
|
||||
*glyph_w = pf.font_sel->glyph_w;
|
||||
}
|
||||
if (glyph_h != NULL)
|
||||
{
|
||||
*glyph_h = pf.font_sel->glyph_h;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int len(const uint32_t flags, const std::string& t)
|
||||
{
|
||||
PrintFlags pf = decode_print_flags(flags);
|
||||
|
|
|
@ -119,7 +119,7 @@ std::string string_wordwrap(const std::string& s, int maxwidth, short *lines = N
|
|||
std::string string_wordwrap_balanced(const std::string& s, int maxwidth);
|
||||
std::string string_unwordwrap(const std::string& s);
|
||||
|
||||
bool glyph_dimensions_main(uint8_t idx, uint8_t* glyph_w, uint8_t* glyph_h);
|
||||
bool glyph_dimensions(uint32_t flags, uint8_t* glyph_w, uint8_t* glyph_h);
|
||||
|
||||
int len(uint32_t flags, const std::string& t);
|
||||
int height(const uint32_t flags);
|
||||
|
|
|
@ -374,14 +374,6 @@ void Graphics::bigprint( int x, int y, const std::string& text, int r, int g, i
|
|||
font::print(PR_scX, x, y, text, r, g, b);
|
||||
}
|
||||
|
||||
void Graphics::bprint( int x, int y, const std::string& text, int r, int g, int b, bool cen /*= false*/ ) {
|
||||
// DEPRECATED
|
||||
if (cen)
|
||||
font::print(PR_CEN | PR_BOR, -1, y, text, r, g, b);
|
||||
else
|
||||
font::print(PR_BOR, x, y, text, r, g, b);
|
||||
}
|
||||
|
||||
void Graphics::printcrewname( int x, int y, int t )
|
||||
{
|
||||
//Print the name of crew member t in the right colour
|
||||
|
@ -826,10 +818,28 @@ void Graphics::drawgui(void)
|
|||
|
||||
if (textboxes[i].r == 0 && textboxes[i].g == 0 && textboxes[i].b == 0)
|
||||
{
|
||||
/* To avoid the outlines for different lines overlapping the text itself,
|
||||
* first draw all the outlines and then draw the text. */
|
||||
size_t j;
|
||||
for (j = 0; j < textboxes[i].lines.size(); j++)
|
||||
{
|
||||
bprint(textboxes[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textboxes[i].lines[j], 196, 196, 255 - help.glow);
|
||||
font::print(
|
||||
textboxes[i].print_flags | PR_CJK_LOW | PR_BOR,
|
||||
textboxes[i].xp + 8,
|
||||
yp + text_yoff + text_sign * (j * font_height),
|
||||
textboxes[i].lines[j],
|
||||
0, 0, 0
|
||||
);
|
||||
}
|
||||
for (j = 0; j < textboxes[i].lines.size(); j++)
|
||||
{
|
||||
font::print(
|
||||
textboxes[i].print_flags | PR_CJK_LOW,
|
||||
textboxes[i].xp + 8,
|
||||
yp + text_yoff + text_sign * (j * font_height),
|
||||
textboxes[i].lines[j],
|
||||
196, 196, 255 - help.glow
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -206,8 +206,6 @@ public:
|
|||
|
||||
int PrintWrap(int x, int y, const std::string& s, int r, int g, int b, bool cen = false, int linespacing = -1, int maxwidth = -1);
|
||||
|
||||
void bprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false);
|
||||
|
||||
void bigprint( int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false, int sc = 2 );
|
||||
void drawspritesetcol(int x, int y, int t, int c);
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ static bool max_check_string(const char* str, const char* max)
|
|||
uint32_t print_flags = PR_FONT_IDX(font_idx) | PR_CJK_LOW;
|
||||
uint8_t font_w = 8;
|
||||
uint8_t font_h = 8;
|
||||
font::glyph_dimensions_main(font_idx, &font_w, &font_h);
|
||||
font::glyph_dimensions(print_flags, &font_w, &font_h);
|
||||
|
||||
unsigned short max_w_px = max_w * 8;
|
||||
unsigned short max_h_px = max_h * 10;
|
||||
|
|
|
@ -1038,7 +1038,7 @@ static void menurender(void)
|
|||
text = loc::gettext("Text outlines are OFF.");
|
||||
}
|
||||
|
||||
graphics.bprint(-1, next_y, text, 255, 255, 255, true);
|
||||
font::print(PR_BOR | PR_CEN, -1, next_y, text, 255, 255, 255);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1973,11 +1973,11 @@ void gamerender(void)
|
|||
graphics.drawgui();
|
||||
if (graphics.flipmode)
|
||||
{
|
||||
if (game.advancetext) graphics.bprint(5, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
||||
if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game.advancetext) graphics.bprint(5, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
||||
if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||
}
|
||||
|
||||
if (game.readytotele > 100 || game.oldreadytotele > 100)
|
||||
|
@ -2500,7 +2500,7 @@ void maprender(void)
|
|||
graphics.drawimage(IMAGE_COVERED, 40 + (i * 12), 21 + (j * 9), false);
|
||||
}
|
||||
}
|
||||
graphics.bprint(-1, 105, loc::gettext("NO SIGNAL"), 245, 245, 245, true);
|
||||
font::print(PR_CEN | PR_BOR, -1, 105, loc::gettext("NO SIGNAL"), 245, 245, 245);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2980,11 +2980,11 @@ void teleporterrender(void)
|
|||
|
||||
if (graphics.flipmode)
|
||||
{
|
||||
if (game.advancetext) graphics.bprint(5, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
||||
if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 228, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game.advancetext) graphics.bprint(5, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
|
||||
if (game.advancetext) font::print(PR_CEN | PR_BOR, -1, 5, loc::gettext("- Press ACTION to advance text -"), 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2));
|
||||
}
|
||||
|
||||
graphics.set_render_target(graphics.gameTexture);
|
||||
|
|
|
@ -135,7 +135,9 @@ void textboxclass::padtowidth(size_t new_w)
|
|||
/* Pad the current text so that each line is new_w pixels wide.
|
||||
* Each existing line is centered in that width. */
|
||||
resize();
|
||||
size_t chars_w = SDL_max(w-16, new_w) / 8;
|
||||
uint8_t glyph_w = 8;
|
||||
font::glyph_dimensions(print_flags, &glyph_w, NULL);
|
||||
size_t chars_w = SDL_max(w-16, new_w) / glyph_w;
|
||||
for (size_t iter = 0; iter < lines.size(); iter++)
|
||||
{
|
||||
size_t n_glyphs = utf8::unchecked::distance(lines[iter].begin(), lines[iter].end());
|
||||
|
|
Loading…
Reference in a new issue