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

preloader.cpp: make loading screen translatable

This mainly adds loc::gettext calls and replaces SDL_snprintf by
VFormat for the percentage.

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-31 02:12:57 +01:00 committed by Misa Elizabeth Kai
parent 56f812a7e9
commit b548783df2

View file

@ -1,8 +1,11 @@
#include "Constants.h"
#include "Enums.h"
#include "Game.h"
#include "Graphics.h"
#include "Localization.h"
#include "KeyPoll.h"
#include "UtilityClass.h"
#include "VFormat.h"
static int pre_fakepercent=0, pre_transition=30;
static bool pre_startgame=false;
@ -51,6 +54,8 @@ void preloaderrenderfixed(void)
void preloaderrender(void)
{
bool print_percentage = false;
if(pre_transition>=30){
switch(pre_curcol) {
case 0:
@ -97,11 +102,7 @@ void preloaderrender(void)
FillRect(graphics.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, graphics.getRGB(0x3E,0x31,0xA2));
if(pre_fakepercent==100){
graphics.Print(282-(15*8), 204, "LOADING... " + help.String(int(pre_fakepercent))+"%", 124, 112, 218, false);
}else{
graphics.Print(282-(14*8), 204, "LOADING... " + help.String(int(pre_fakepercent))+"%", 124, 112, 218, false);
}
print_percentage = true;
//Render
if (pre_startgame) {
@ -117,7 +118,20 @@ void preloaderrender(void)
ClearSurface(graphics.backBuffer);
FillRect(graphics.backBuffer, pre_frontrectx, pre_frontrecty, pre_frontrectw,pre_frontrecth, graphics.getRGB(0x3E,0x31,0xA2));
graphics.Print(282-(15*8), 204, "LOADING... 100%", 124, 112, 218, false);
print_percentage = true;
}
if (print_percentage) {
char buffer[SCREEN_WIDTH_CHARS + 1];
vformat_buf(
buffer, sizeof(buffer),
loc::gettext("LOADING... {percent|digits=2|spaces}%"),
"percent:int",
pre_fakepercent
);
int percentage_len = graphics.len(buffer);
graphics.Print(282-percentage_len, 204, buffer, 124, 112, 218, false);
}
graphics.drawfade();