game: add 'g_language' localization cvar

This commit is contained in:
Denis Pauk 2024-11-05 23:34:01 +02:00
parent 1f0b9904ea
commit 03cb2be1e6
6 changed files with 11 additions and 2 deletions

View file

@ -79,7 +79,7 @@ Maps support:
Note:
* Non Quake 2 maps are limmited mostly view only, and could have issues
* Non Quake 2 maps are limited mostly view only, and could have issues
with tranparency or some animations flags and properties.
* If you like support some other maps type, create pull request for Mod_Load2QBSP
function and provide a link to demo maps.

View file

@ -249,6 +249,10 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable`
By default this cvar is set to `1`, and will only work if the
game.dll implements this behaviour.
* **g_language**: Default language for ReRelease game, requires `Q2Game.kpf`
or other source of `localization/loc_english.txt` like file.
Defaults to `english`.
* **g_swap_speed**: Sets the speed of the "changing weapon" animation.
Default is `1`. If set to `2`, it will be double the speed, `3` is
the triple... up until the max of `8`, since there are at least 2

View file

@ -102,6 +102,7 @@ cvar_t *aimfix;
cvar_t *g_machinegun_norecoil;
cvar_t *g_quick_weap;
cvar_t *g_swap_speed;
cvar_t *g_language;
static void G_RunFrame(void);

View file

@ -53,12 +53,14 @@ LocalizationInit(void)
byte *raw = NULL;
char *buf_local = NULL, *buf_level = NULL;
int len_local, len_level, curr_pos;
char loc_name[MAX_QPATH];
localmessages = NULL;
nlocalmessages = 0;
snprintf(loc_name, sizeof(loc_name) - 1, "localization/loc_%s.txt", g_language->string);
/* load the localization file */
len_local = gi.FS_LoadFile("localization/loc_english.txt", (void **)&raw);
len_local = gi.FS_LoadFile(loc_name, (void **)&raw);
if (len_local > 1)
{
buf_local = malloc(len_local + 1);

View file

@ -679,6 +679,7 @@ extern cvar_t *aimfix;
extern cvar_t *g_machinegun_norecoil;
extern cvar_t *g_quick_weap;
extern cvar_t *g_swap_speed;
extern cvar_t *g_language;
/* this is for the count of monsters */
#define ENT_SLOTS_LEFT \

View file

@ -263,6 +263,7 @@ InitGame(void)
g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "0", CVAR_ARCHIVE);
g_quick_weap = gi.cvar("g_quick_weap", "1", CVAR_ARCHIVE);
g_swap_speed = gi.cvar("g_swap_speed", "1", CVAR_ARCHIVE);
g_language = gi.cvar("g_language", "english", CVAR_ARCHIVE);
/* initilize localization */
LocalizationInit();