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

Translate hardest room at display time instead of at time of death

The hardest room used to be stored as a room name in whatever language
it was in when you last died enough times to break the record (before
localization, that was always English). Even after localization became
a thing we could get away with this since we only had a single font,
but now we might have actual question marks appearing when the new font
doesn't support characters from the old language.

Therefore, this commit adds more info about the hardest room to save
files - everything that is needed to know in order to do the
translation at display time. These are hardestroom_x and hardestroom_y
for the room coordinates, as well as hardestroom_specialname to mark
special names, in addition to changing the stored room name back to
English. I've also added hardestroom_finalstretch in case we later
decide to drop the English name as a key and rely on just the
coordinates (even though I think that change itself would be more
complicated than any simplification it would accomplish, and I don't
think it's necessary, but better to have it if we do need it later)
This commit is contained in:
Dav999 2023-09-04 15:27:29 +02:00 committed by Misa Elizabeth Kai
parent e0e902d717
commit 3c4ed36418
3 changed files with 79 additions and 6 deletions

View file

@ -280,6 +280,10 @@ void Game::init(void)
totalflips = 0; totalflips = 0;
hardestroom = "Welcome Aboard"; hardestroom = "Welcome Aboard";
hardestroomdeaths = 0; hardestroomdeaths = 0;
hardestroom_x = 13;
hardestroom_y = 5;
hardestroom_specialname = false;
hardestroom_finalstretch = false;
currentroomdeaths=0; currentroomdeaths=0;
inertia = 1.1f; inertia = 1.1f;
@ -2951,7 +2955,10 @@ void Game::updatestate(void)
); );
graphics.createtextboxflipme(buffer, -1, 158, TEXT_COLOUR("transparent")); graphics.createtextboxflipme(buffer, -1, 158, TEXT_COLOUR("transparent"));
graphics.textboxprintflags(PR_FONT_INTERFACE); graphics.textboxprintflags(PR_FONT_INTERFACE);
graphics.createtextboxflipme(hardestroom, -1, 170, TEXT_COLOUR("transparent")); graphics.createtextboxflipme(
loc::gettext_roomname(map.custommode, hardestroom_x, hardestroom_y, hardestroom.c_str(), hardestroom_specialname),
-1, 170, TEXT_COLOUR("transparent")
);
graphics.textboxprintflags(PR_FONT_INTERFACE); graphics.textboxprintflags(PR_FONT_INTERFACE);
break; break;
} }
@ -4243,13 +4250,19 @@ void Game::gethardestroom(void)
{ {
hardestroomdeaths = currentroomdeaths; hardestroomdeaths = currentroomdeaths;
hardestroom_x = roomx;
hardestroom_y = roomy;
hardestroom_finalstretch = map.finalstretch;
if (map.roomname[0] == '\0') if (map.roomname[0] == '\0')
{ {
hardestroom = loc::gettext_roomname_special(map.hiddenname); hardestroom = map.hiddenname;
hardestroom_specialname = true;
} }
else else
{ {
hardestroom = loc::gettext_roomname(map.custommode, roomx, roomy, map.roomname, map.roomname_special); hardestroom = map.roomname;
hardestroom_specialname = map.roomname_special;
} }
} }
} }
@ -5197,6 +5210,13 @@ void Game::readmaingamesave(const char* savename, tinyxml2::XMLDocument& doc)
return; return;
} }
/* Even if we want the default hardest room to be Welcome Aboard, there are pre-2.4
* saves with JUST <hardestroom> which should take priority over the coords */
hardestroom_x = -1;
hardestroom_y = -1;
hardestroom_specialname = false;
hardestroom_finalstretch = false;
for (pElem = hDoc for (pElem = hDoc
.FirstChildElement() .FirstChildElement()
.FirstChildElement("Data") .FirstChildElement("Data")
@ -5309,6 +5329,22 @@ void Game::readmaingamesave(const char* savename, tinyxml2::XMLDocument& doc)
{ {
hardestroomdeaths = help.Int(pText); hardestroomdeaths = help.Int(pText);
} }
else if (SDL_strcmp(pKey, "hardestroom_x") == 0)
{
hardestroom_x = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_y") == 0)
{
hardestroom_y = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_specialname") == 0)
{
hardestroom_specialname = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_finalstretch") == 0)
{
hardestroom_finalstretch = help.Int(pText);
}
else if (SDL_strcmp(pKey, "currentsong") == 0) else if (SDL_strcmp(pKey, "currentsong") == 0)
{ {
int song = help.Int(pText); int song = help.Int(pText);
@ -5379,6 +5415,12 @@ void Game::customloadquick(const std::string& savfile)
return; return;
} }
// Like readmaingamesave(...), old saves have just <hardestroom>
hardestroom_x = -1;
hardestroom_y = -1;
hardestroom_specialname = false;
hardestroom_finalstretch = false;
for (pElem = hDoc for (pElem = hDoc
.FirstChildElement() .FirstChildElement()
.FirstChildElement("Data") .FirstChildElement("Data")
@ -5514,6 +5556,22 @@ void Game::customloadquick(const std::string& savfile)
{ {
hardestroomdeaths = help.Int(pText); hardestroomdeaths = help.Int(pText);
} }
else if (SDL_strcmp(pKey, "hardestroom_x") == 0)
{
hardestroom_x = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_y") == 0)
{
hardestroom_y = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_specialname") == 0)
{
hardestroom_specialname = help.Int(pText);
}
else if (SDL_strcmp(pKey, "hardestroom_finalstretch") == 0)
{
hardestroom_finalstretch = help.Int(pText);
}
else if (SDL_strcmp(pKey, "currentsong") == 0) else if (SDL_strcmp(pKey, "currentsong") == 0)
{ {
int song = help.Int(pText); int song = help.Int(pText);
@ -5815,6 +5873,10 @@ struct Game::Summary Game::writemaingamesave(tinyxml2::XMLDocument& doc)
xml::update_tag(msgs, "hardestroom", hardestroom.c_str()); xml::update_tag(msgs, "hardestroom", hardestroom.c_str());
xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths); xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths);
xml::update_tag(msgs, "hardestroom_x", hardestroom_x);
xml::update_tag(msgs, "hardestroom_y", hardestroom_y);
xml::update_tag(msgs, "hardestroom_specialname", (int) hardestroom_specialname);
xml::update_tag(msgs, "hardestroom_finalstretch", (int) hardestroom_finalstretch);
xml::update_tag(msgs, "finalmode", (int) map.finalmode); xml::update_tag(msgs, "finalmode", (int) map.finalmode);
xml::update_tag(msgs, "finalstretch", (int) map.finalstretch); xml::update_tag(msgs, "finalstretch", (int) map.finalstretch);
@ -5962,6 +6024,10 @@ bool Game::customsavequick(const std::string& savfile)
xml::update_tag(msgs, "hardestroom", hardestroom.c_str()); xml::update_tag(msgs, "hardestroom", hardestroom.c_str());
xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths); xml::update_tag(msgs, "hardestroomdeaths", hardestroomdeaths);
xml::update_tag(msgs, "hardestroom_x", hardestroom_x);
xml::update_tag(msgs, "hardestroom_y", hardestroom_y);
xml::update_tag(msgs, "hardestroom_specialname", (int) hardestroom_specialname);
xml::update_tag(msgs, "hardestroom_finalstretch", (int) hardestroom_finalstretch);
xml::update_tag(msgs, "showminimap", (int) map.customshowmm); xml::update_tag(msgs, "showminimap", (int) map.customshowmm);
@ -7391,7 +7457,7 @@ void Game::copyndmresults(void)
{ {
ndmresultcrewrescued = crewrescued(); ndmresultcrewrescued = crewrescued();
ndmresulttrinkets = trinkets(); ndmresulttrinkets = trinkets();
ndmresulthardestroom = hardestroom; ndmresulthardestroom = loc::gettext_roomname(false, hardestroom_x, hardestroom_y, hardestroom.c_str(), hardestroom_specialname);
SDL_memcpy(ndmresultcrewstats, crewstats, sizeof(ndmresultcrewstats)); SDL_memcpy(ndmresultcrewstats, crewstats, sizeof(ndmresultcrewstats));
} }

View file

@ -501,8 +501,11 @@ public:
//Some stats: //Some stats:
int totalflips; int totalflips;
std::string hardestroom; // don't change to C string unless you wanna handle language switches (or make it store coords) std::string hardestroom; // don't change to C string unless you wanna handle when this string is loaded from the XML
int hardestroomdeaths, currentroomdeaths; int hardestroomdeaths, currentroomdeaths;
int hardestroom_x, hardestroom_y;
bool hardestroom_specialname;
bool hardestroom_finalstretch;
bool quickrestartkludge; bool quickrestartkludge;

View file

@ -3187,8 +3187,12 @@ void scriptclass::hardreset(void)
game.translator_cutscene_test = false; game.translator_cutscene_test = false;
game.totalflips = 0; game.totalflips = 0;
game.hardestroom = loc::gettext_roomname(false, 13, 5, "Welcome Aboard", false); game.hardestroom = "Welcome Aboard";
game.hardestroomdeaths = 0; game.hardestroomdeaths = 0;
game.hardestroom_x = 13;
game.hardestroom_y = 5;
game.hardestroom_specialname = false;
game.hardestroom_finalstretch = false;
game.currentroomdeaths=0; game.currentroomdeaths=0;
game.swnmode = false; game.swnmode = false;