mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01:00
Move Game Complete sequence to new text box system
In order to be able to retranslate the game time text box in particular, I had to create new variables to bake the saved time, since the existing savetime variable is just an std::string. From there, the saved time can be retranslated on-the-fly.
This commit is contained in:
parent
7088858957
commit
b14ca5e366
2 changed files with 132 additions and 46 deletions
|
@ -262,6 +262,10 @@ void Game::init(void)
|
||||||
savetime = "00:00";
|
savetime = "00:00";
|
||||||
savetrinkets = 0;
|
savetrinkets = 0;
|
||||||
|
|
||||||
|
/* These are only used some of the time. */
|
||||||
|
saveframes = 0;
|
||||||
|
saveseconds = 0;
|
||||||
|
|
||||||
intimetrial = false;
|
intimetrial = false;
|
||||||
timetrialcountdown = 0;
|
timetrialcountdown = 0;
|
||||||
timetrialshinytarget = 0;
|
timetrialshinytarget = 0;
|
||||||
|
@ -1080,6 +1084,102 @@ static void foundcrewmate_textbox2(textboxclass* THIS)
|
||||||
THIS->pad(2, 2);
|
THIS->pad(2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox2(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
THIS->lines.clear();
|
||||||
|
THIS->lines.push_back(loc::gettext("All Crew Members Rescued!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox3(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
const char* label = loc::gettext("Trinkets Found:");
|
||||||
|
THIS->lines.push_back(label);
|
||||||
|
THIS->xp = 170 - font::len(PR_FONT_INTERFACE, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox4(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
extern Game game;
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
char buffer[SCREEN_WIDTH_CHARS + 1];
|
||||||
|
vformat_buf(buffer, sizeof(buffer),
|
||||||
|
loc::gettext("{gamecomplete_n_trinkets|wordy}"),
|
||||||
|
"gamecomplete_n_trinkets:int",
|
||||||
|
game.trinkets()
|
||||||
|
);
|
||||||
|
THIS->lines.push_back(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox5(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
const char* label = loc::gettext("Game Time:");
|
||||||
|
THIS->lines.push_back(label);
|
||||||
|
THIS->xp = 170 - font::len(PR_FONT_INTERFACE, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox6(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
extern Game game;
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
char buffer[SCREEN_WIDTH_CHARS + 1];
|
||||||
|
help.format_time(buffer, sizeof(buffer), game.saveseconds, game.saveframes, true);
|
||||||
|
THIS->lines.push_back(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox7(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
const char* label = loc::gettext("Total Flips:");
|
||||||
|
THIS->lines.push_back(label);
|
||||||
|
THIS->xp = 170 - font::len(PR_FONT_INTERFACE, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox9(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
const char* label = loc::gettext("Total Deaths:");
|
||||||
|
THIS->lines.push_back(label);
|
||||||
|
THIS->xp = 170 - font::len(PR_FONT_INTERFACE, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox11(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
extern Game game;
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
char buffer[SCREEN_WIDTH_CHARS + 1];
|
||||||
|
loc::gettext_plural_fill(
|
||||||
|
buffer, sizeof(buffer),
|
||||||
|
"Hardest Room (with {n_deaths} deaths)",
|
||||||
|
"Hardest Room (with {n_deaths} death)",
|
||||||
|
"n_deaths:int",
|
||||||
|
game.hardestroomdeaths
|
||||||
|
);
|
||||||
|
THIS->lines.push_back(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gamecomplete_textbox12(textboxclass* THIS)
|
||||||
|
{
|
||||||
|
extern Game game;
|
||||||
|
THIS->lines.clear();
|
||||||
|
|
||||||
|
THIS->lines.push_back(
|
||||||
|
loc::gettext_roomname(
|
||||||
|
map.custommode,
|
||||||
|
game.hardestroom_x, game.hardestroom_y,
|
||||||
|
game.hardestroom.c_str(), game.hardestroom_specialname
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void Game::setstate(const int gamestate)
|
void Game::setstate(const int gamestate)
|
||||||
{
|
{
|
||||||
if (!statelocked || GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
|
if (!statelocked || GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
|
||||||
|
@ -3077,97 +3177,82 @@ void Game::updatestate(void)
|
||||||
graphics.textboxapplyposition();
|
graphics.textboxapplyposition();
|
||||||
break;
|
break;
|
||||||
case 3502:
|
case 3502:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45+15);
|
setstatedelay(45+15);
|
||||||
|
|
||||||
graphics.createtextboxflipme(loc::gettext("All Crew Members Rescued!"), -1, 64, TEXT_COLOUR("transparent"));
|
graphics.createtextboxflipme("", -1, 64, TEXT_COLOUR("transparent"));
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
char buffer[SCREEN_WIDTH_CHARS + 1];
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox2);
|
||||||
timestringcenti(buffer, sizeof(buffer));
|
graphics.textboxapplyposition();
|
||||||
savetime = buffer;
|
saveframes = frames;
|
||||||
|
saveseconds = help.hms_to_seconds(hours, minutes, seconds);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3503:
|
case 3503:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45);
|
setstatedelay(45);
|
||||||
|
|
||||||
const char* label = loc::gettext("Trinkets Found:");
|
graphics.createtextboxflipme("", 170, 84, TEXT_COLOUR("transparent"));
|
||||||
char buffer[SCREEN_WIDTH_CHARS + 1];
|
|
||||||
vformat_buf(buffer, sizeof(buffer),
|
|
||||||
loc::gettext("{gamecomplete_n_trinkets|wordy}"),
|
|
||||||
"gamecomplete_n_trinkets:int",
|
|
||||||
trinkets()
|
|
||||||
);
|
|
||||||
graphics.createtextboxflipme(label, 170-font::len(PR_FONT_INTERFACE, label), 84, TEXT_COLOUR("transparent"));
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
graphics.createtextboxflipme(buffer, 180, 84, TEXT_COLOUR("transparent"));
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox3);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
|
graphics.createtextboxflipme("", 180, 84, TEXT_COLOUR("transparent"));
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox4);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3504:
|
case 3504:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45+15);
|
setstatedelay(45+15);
|
||||||
|
|
||||||
const char* label = loc::gettext("Game Time:");
|
graphics.createtextboxflipme("", 170, 96, TEXT_COLOUR("transparent"));
|
||||||
std::string tempstring = savetime;
|
|
||||||
graphics.createtextboxflipme(label, 170-font::len(PR_FONT_INTERFACE, label), 96, TEXT_COLOUR("transparent"));
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
graphics.createtextboxflipme(tempstring, 180, 96, TEXT_COLOUR("transparent"));
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox5);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
|
graphics.createtextboxflipme("", 180, 96, TEXT_COLOUR("transparent"));
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox6);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3505:
|
case 3505:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45);
|
setstatedelay(45);
|
||||||
|
|
||||||
const char* label = loc::gettext("Total Flips:");
|
graphics.createtextboxflipme("", 170, 123, TEXT_COLOUR("transparent"));
|
||||||
graphics.createtextboxflipme(label, 170-font::len(PR_FONT_INTERFACE, label), 123, TEXT_COLOUR("transparent"));
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox7);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
graphics.createtextboxflipme(help.String(totalflips), 180, 123, TEXT_COLOUR("transparent"));
|
graphics.createtextboxflipme(help.String(totalflips), 180, 123, TEXT_COLOUR("transparent"));
|
||||||
|
graphics.textboxoriginalcontextauto();
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3506:
|
case 3506:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45+15);
|
setstatedelay(45+15);
|
||||||
|
|
||||||
const char* label = loc::gettext("Total Deaths:");
|
graphics.createtextboxflipme("", 170, 135, TEXT_COLOUR("transparent"));
|
||||||
graphics.createtextboxflipme(label, 170-font::len(PR_FONT_INTERFACE, label), 135, TEXT_COLOUR("transparent"));
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox9);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
graphics.createtextboxflipme(help.String(deathcounts), 180, 135, TEXT_COLOUR("transparent"));
|
graphics.createtextboxflipme(help.String(deathcounts), 180, 135, TEXT_COLOUR("transparent"));
|
||||||
|
graphics.textboxoriginalcontextauto();
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
graphics.textboxprintflags(PR_FONT_INTERFACE | PR_RTL_XFLIP);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3507:
|
case 3507:
|
||||||
{
|
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(45+15);
|
setstatedelay(45+15);
|
||||||
|
|
||||||
char buffer[SCREEN_WIDTH_CHARS + 1];
|
graphics.createtextboxflipme("", -1, 158, TEXT_COLOUR("transparent"));
|
||||||
loc::gettext_plural_fill(
|
|
||||||
buffer, sizeof(buffer),
|
|
||||||
"Hardest Room (with {n_deaths} deaths)",
|
|
||||||
"Hardest Room (with {n_deaths} death)",
|
|
||||||
"n_deaths:int",
|
|
||||||
hardestroomdeaths
|
|
||||||
);
|
|
||||||
graphics.createtextboxflipme(buffer, -1, 158, TEXT_COLOUR("transparent"));
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
graphics.createtextboxflipme(
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox11);
|
||||||
loc::gettext_roomname(map.custommode, hardestroom_x, hardestroom_y, hardestroom.c_str(), hardestroom_specialname),
|
graphics.textboxapplyposition();
|
||||||
-1, 170, TEXT_COLOUR("transparent")
|
graphics.createtextboxflipme("", -1, 170, TEXT_COLOUR("transparent"));
|
||||||
);
|
|
||||||
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
graphics.textboxprintflags(PR_FONT_INTERFACE);
|
||||||
graphics.textboxcenterx();
|
graphics.textboxcenterx();
|
||||||
|
graphics.textboxtranslate(TEXTTRANSLATE_FUNCTION, gamecomplete_textbox12);
|
||||||
|
graphics.textboxapplyposition();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 3508:
|
case 3508:
|
||||||
incstate();
|
incstate();
|
||||||
setstatedelay(0);
|
setstatedelay(0);
|
||||||
|
|
|
@ -359,6 +359,7 @@ public:
|
||||||
bool gamesaved;
|
bool gamesaved;
|
||||||
bool gamesavefailed;
|
bool gamesavefailed;
|
||||||
std::string savetime;
|
std::string savetime;
|
||||||
|
int saveframes, saveseconds;
|
||||||
int savetrinkets;
|
int savetrinkets;
|
||||||
bool startscript;
|
bool startscript;
|
||||||
std::string newscript;
|
std::string newscript;
|
||||||
|
|
Loading…
Reference in a new issue