1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 10:09:43 +01:00

Graphics.cpp: make whole file translatable

This mainly adds loc::gettext calls.

This commit is part of rewritten history of the localization branch.
The original (unsquashed) commit history can be found here:
https://github.com/Dav999-v/VVVVVV/tree/localization-orig
This commit is contained in:
Dav999-v 2022-12-30 23:39:12 +01:00 committed by Misa Elizabeth Kai
parent e90cc86a3c
commit 45b564b4fb

View file

@ -476,16 +476,15 @@ void Graphics::map_option(int opt, int num_opts, const std::string& text, bool s
if (selected) if (selected)
{ {
std::string text_upper(text); std::string text_upper(loc::toupper(text));
for (size_t i = 0; i < text_upper.length(); i++)
{ char buffer[SCREEN_WIDTH_CHARS + 1];
text_upper[i] = SDL_toupper(text_upper[i]); vformat_buf(buffer, sizeof(buffer), loc::get_langmeta()->menu_select.c_str(), "label:str", text_upper.c_str());
} Print(x - 16, y, buffer, 196, 196, 255 - help.glow);
Print(x - 16, y, "[ " + text_upper + " ]", 196, 196, 255 - help.glow);
} }
else else
{ {
Print(x, y, text, 96, 96, 96); Print(x, y, loc::remove_toupper_escape_chars(text), 96, 96, 96);
} }
} }
@ -919,22 +918,22 @@ void Graphics::printcrewname( int x, int y, int t )
switch(t) switch(t)
{ {
case 0: case 0:
Print(x, y, "Viridian", 16, 240, 240,false ); Print(x, y, loc::gettext("Viridian"), 16, 240, 240,false);
break; break;
case 1: case 1:
Print(x, y, "Violet", 240, 16, 240,false); Print(x, y, loc::gettext("Violet"), 240, 16, 240,false);
break; break;
case 2: case 2:
Print(x, y, "Vitellary", 240, 240, 16,false); Print(x, y, loc::gettext("Vitellary"), 240, 240, 16,false);
break; break;
case 3: case 3:
Print(x, y, "Vermilion", 240, 16, 16,false); Print(x, y, loc::gettext("Vermilion"), 240, 16, 16,false);
break; break;
case 4: case 4:
Print(x, y, "Verdigris", 16, 240, 16,false); Print(x, y, loc::gettext("Verdigris"), 16, 240, 16,false);
break; break;
case 5: case 5:
Print(x, y, "Victoria", 16, 16, 240,false); Print(x, y, loc::gettext("Victoria"), 16, 16, 240,false);
break; break;
} }
} }
@ -945,22 +944,22 @@ void Graphics::printcrewnamedark( int x, int y, int t )
switch(t) switch(t)
{ {
case 0: case 0:
Print(x, y, "Viridian", 128,128,128,false); Print(x, y, loc::gettext("Viridian"), 128,128,128,false);
break; break;
case 1: case 1:
Print(x, y, "Violet", 128,128,128,false); Print(x, y, loc::gettext("Violet"), 128,128,128,false);
break; break;
case 2: case 2:
Print(x, y, "Vitellary", 128,128,128,false); Print(x, y, loc::gettext("Vitellary"), 128,128,128,false);
break; break;
case 3: case 3:
Print(x, y, "Vermilion", 128,128,128,false); Print(x, y, loc::gettext("Vermilion"), 128,128,128,false);
break; break;
case 4: case 4:
Print(x, y, "Verdigris", 128,128,128,false); Print(x, y, loc::gettext("Verdigris"), 128,128,128,false);
break; break;
case 5: case 5:
Print(x, y, "Victoria", 128,128,128,false); Print(x, y, loc::gettext("Victoria"), 128,128,128,false);
break; break;
} }
} }
@ -971,22 +970,22 @@ void Graphics::printcrewnamestatus( int x, int y, int t )
switch(t) switch(t)
{ {
case 0: case 0:
Print(x, y, "(that's you!)", 12, 140, 140,false); Print(x, y, loc::gettext("(that's you!)"), 12, 140, 140,false);
break; break;
case 1: case 1:
Print(x, y, "Rescued!", 140, 12, 140,false); Print(x, y, loc::gettext("Rescued!"), 140, 12, 140,false);
break; break;
case 2: case 2:
Print(x, y, "Rescued!", 140, 140, 12,false); Print(x, y, loc::gettext("Rescued!"), 140, 140, 12,false);
break; break;
case 3: case 3:
Print(x, y, "Rescued!", 140, 12, 12,false); Print(x, y, loc::gettext("Rescued!"), 140, 12, 12,false);
break; break;
case 4: case 4:
Print(x, y, "Rescued!", 12, 140, 12,false); Print(x, y, loc::gettext("Rescued!"), 12, 140, 12,false);
break; break;
case 5: case 5:
Print(x, y, "Rescued!", 12, 12, 140,false); Print(x, y, loc::gettext("Rescued!"), 12, 12, 140,false);
break; break;
} }
} }
@ -1189,6 +1188,30 @@ void Graphics::drawgui(void)
} }
if (textboxes[i].yp == 12 && textboxes[i].r == 165) if (textboxes[i].yp == 12 && textboxes[i].r == 165)
{
// Level complete
const char* english = "Level Complete!";
const char* translation = loc::gettext(english);
if (SDL_strcmp(english, translation) != 0
&& !(flipmode && fliplevelcomplete_mounted)
&& !(!flipmode && levelcomplete_mounted)
)
{
int sc = 2;
int y = 28;
if (len(translation) > 144)
{
// We told translators how long it could be... Ah well, mitigate the damage.
sc = 1;
y += 4;
}
if (flipmode)
{
y = 240 - y - 8*sc;
}
bigprint(-1, y, translation, 164, 164, 255, true, sc);
}
else
{ {
if (flipmode) if (flipmode)
{ {
@ -1199,7 +1222,32 @@ void Graphics::drawgui(void)
drawimage(0, 0, 12, true); drawimage(0, 0, 12, true);
} }
} }
}
else if (textboxes[i].yp == 12 && textboxes[i].g == 165) else if (textboxes[i].yp == 12 && textboxes[i].g == 165)
{
// Game complete
const char* english = "Game Complete!";
const char* translation = loc::gettext(english);
if (SDL_strcmp(english, translation) != 0
&& !(flipmode && flipgamecomplete_mounted)
&& !(!flipmode && gamecomplete_mounted)
)
{
int sc = 2;
int y = 28;
if (len(translation) > 144)
{
// We told translators how long it could be... Ah well, mitigate the damage.
sc = 1;
y += 4;
}
if (flipmode)
{
y = 240 - y - 8*sc;
}
bigprint(-1, y, translation, 164, 164, 255, true, sc);
}
else
{ {
if (flipmode) if (flipmode)
{ {
@ -1210,30 +1258,32 @@ void Graphics::drawgui(void)
drawimage(4, 0, 12, true); drawimage(4, 0, 12, true);
} }
} }
}
int crew_xp = textboxes[i].xp+20 - 6;
if (textboxes[i].r == 175 && textboxes[i].g == 175) if (textboxes[i].r == 175 && textboxes[i].g == 175)
{ {
//purple guy //purple guy
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textboxes[i].rand, 120- help.glow/4, 210 - help.glow/4); drawsprite(crew_xp, crew_yp, crew_sprite, 220- help.glow/4 - textboxes[i].rand, 120- help.glow/4, 210 - help.glow/4);
} }
else if (textboxes[i].r == 175 && textboxes[i].b == 175) else if (textboxes[i].r == 175 && textboxes[i].b == 175)
{ {
//red guy //red guy
drawsprite(80 - 6, crew_yp, crew_sprite, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4); drawsprite(crew_xp, crew_yp, crew_sprite, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4);
} }
else if (textboxes[i].r == 175) else if (textboxes[i].r == 175)
{ {
//green guy //green guy
drawsprite(80 - 6, crew_yp, crew_sprite, 120 - help.glow / 4 - textboxes[i].rand, 220 - help.glow / 4, 120 - help.glow / 4); drawsprite(crew_xp, crew_yp, crew_sprite, 120 - help.glow / 4 - textboxes[i].rand, 220 - help.glow / 4, 120 - help.glow / 4);
} }
else if (textboxes[i].g == 175) else if (textboxes[i].g == 175)
{ {
//yellow guy //yellow guy
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textboxes[i].rand, 210 - help.glow/4, 120- help.glow/4); drawsprite(crew_xp, crew_yp, crew_sprite, 220- help.glow/4 - textboxes[i].rand, 210 - help.glow/4, 120- help.glow/4);
} }
else if (textboxes[i].b == 175) else if (textboxes[i].b == 175)
{ {
//blue guy //blue guy
drawsprite(80 - 6, crew_yp, crew_sprite, 75, 75, 255- help.glow/4 - textboxes[i].rand); drawsprite(crew_xp, crew_yp, crew_sprite, 75, 75, 255- help.glow/4 - textboxes[i].rand);
} }
} }
} }
@ -1920,75 +1970,95 @@ void Graphics::drawtrophytext(void)
temp2 = 196; temp2 = 196;
temp3 = 255 - help.glow; temp3 = 255 - help.glow;
} }
/* These were originally all at the top of the screen, but might be too tight for localization.
* It probably makes sense to make them all have a top text now, but for now this is probably fine.
* Look at the Steam achievements, they have pretty logical titles that should probably be used. */
const char* top_text = NULL;
const char* bottom_text = NULL;
switch(obj.trophytype) switch(obj.trophytype)
{ {
case 1: case 1:
bprint( -1, 6, "SPACE STATION 1 MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("SPACE STATION 1 MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 2: case 2:
bprint( -1, 6, "LABORATORY MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("LABORATORY MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 3: case 3:
bprint( -1, 6, "THE TOWER MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("THE TOWER MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 4: case 4:
bprint( -1, 6, "SPACE STATION 2 MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("SPACE STATION 2 MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 5: case 5:
bprint( -1, 6, "WARP ZONE MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("WARP ZONE MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 6: case 6:
bprint( -1, 6, "FINAL LEVEL MASTERED", temp, temp2, temp3, true); top_text = loc::gettext("FINAL LEVEL MASTERED");
bprint( -1, 16, "Obtain a V Rank in this Time Trial", temp, temp2, temp3, true); bottom_text = loc::gettext("Obtain a V Rank in this Time Trial");
break; break;
case 7: case 7:
bprint( -1, 6, "GAME COMPLETE", temp, temp2, temp3, true); top_text = loc::gettext("GAME COMPLETE");
bprint( -1, 16, "Complete the game", temp, temp2, temp3, true); bottom_text = loc::gettext("Complete the game");
break; break;
case 8: case 8:
bprint( -1, 6, "FLIP MODE COMPLETE", temp, temp2, temp3, true); top_text = loc::gettext("FLIP MODE COMPLETE");
bprint( -1, 16, "Complete the game in flip mode", temp, temp2, temp3, true); bottom_text = loc::gettext("Complete the game in flip mode");
break; break;
case 9: case 9:
bprint( -1, 11, "Win with less than 50 deaths", temp, temp2, temp3, true); bottom_text = loc::gettext("Win with less than 50 deaths");
break; break;
case 10: case 10:
bprint( -1, 11, "Win with less than 100 deaths", temp, temp2, temp3, true); bottom_text = loc::gettext("Win with less than 100 deaths");
break; break;
case 11: case 11:
bprint( -1, 11, "Win with less than 250 deaths", temp, temp2, temp3, true); bottom_text = loc::gettext("Win with less than 250 deaths");
break; break;
case 12: case 12:
bprint( -1, 11, "Win with less than 500 deaths", temp, temp2, temp3, true); bottom_text = loc::gettext("Win with less than 500 deaths");
break; break;
case 13: case 13:
bprint( -1, 11, "Last 5 seconds on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 5 seconds on the Super Gravitron");
break; break;
case 14: case 14:
bprint( -1, 11, "Last 10 seconds on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 10 seconds on the Super Gravitron");
break; break;
case 15: case 15:
bprint( -1, 11, "Last 15 seconds on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 15 seconds on the Super Gravitron");
break; break;
case 16: case 16:
bprint( -1, 11, "Last 20 seconds on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 20 seconds on the Super Gravitron");
break; break;
case 17: case 17:
bprint( -1, 11, "Last 30 seconds on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 30 seconds on the Super Gravitron");
break; break;
case 18: case 18:
bprint( -1, 11, "Last 1 minute on the Super Gravitron", temp, temp2, temp3, true); bottom_text = loc::gettext("Last 1 minute on the Super Gravitron");
break; break;
case 20: case 20:
bprint( -1, 6, "MASTER OF THE UNIVERSE", temp, temp2, temp3, true); top_text = loc::gettext("MASTER OF THE UNIVERSE");
bprint( -1, 16, "Complete the game in no death mode", temp, temp2, temp3, true); bottom_text = loc::gettext("Complete the game in no death mode");
break; break;
} }
/* These were `bprint` before */
short lines;
if (top_text != NULL)
{
string_wordwrap(top_text, 304, &lines);
PrintWrap(-1, 11-(lines-1)*5, top_text, temp, temp2, temp3, true);
}
if (bottom_text != NULL)
{
string_wordwrap(bottom_text, 304, &lines);
PrintWrap(-1, 221-(lines-1)*5, bottom_text, temp, temp2, temp3, true);
}
} }
void Graphics::drawentities(void) void Graphics::drawentities(void)