mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
done language selector
This commit is contained in:
parent
ab171f8f30
commit
307cf4aa64
|
@ -124,12 +124,18 @@ Game
|
|||
Game info
|
||||
== Spel info.
|
||||
|
||||
Game over
|
||||
== Slutspelat
|
||||
|
||||
Game type
|
||||
== Speltyp
|
||||
|
||||
Game types
|
||||
== Speltyper
|
||||
|
||||
General
|
||||
== Generallt
|
||||
|
||||
Graphics
|
||||
== Grafik
|
||||
|
||||
|
@ -178,6 +184,9 @@ Kick
|
|||
LAN
|
||||
== LAN
|
||||
|
||||
Language
|
||||
== Språk
|
||||
|
||||
Lht.
|
||||
== Ljusstyrka
|
||||
|
||||
|
@ -423,9 +432,6 @@ You must restart the game for all settings to take effect.
|
|||
|
||||
##### needs translation ####
|
||||
|
||||
Game over
|
||||
==
|
||||
|
||||
N/A
|
||||
==
|
||||
|
||||
|
|
|
@ -1213,6 +1213,13 @@ void gui_messagebox(const char *title, const char *message)
|
|||
|
||||
int str_isspace(char c) { return c == ' ' || c == '\n' || c == '\t'; }
|
||||
|
||||
char str_uppercase(char c)
|
||||
{
|
||||
if(c >= 'a' && c <= 'z')
|
||||
return 'A' + (c-'a');
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int str_utf8_isstart(char c)
|
||||
|
|
|
@ -970,6 +970,7 @@ typedef struct
|
|||
void net_stats(NETSTATS *stats);
|
||||
|
||||
int str_isspace(char c);
|
||||
char str_uppercase(char c);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -157,6 +157,7 @@ class MENUS : public COMPONENT
|
|||
void render_serverbrowser(RECT main_view);
|
||||
|
||||
// found in menus_settings.cpp
|
||||
void render_settings_general(RECT main_view);
|
||||
void render_settings_player(RECT main_view);
|
||||
void render_settings_controls(RECT main_view);
|
||||
void render_settings_graphics(RECT main_view);
|
||||
|
|
|
@ -64,6 +64,9 @@ void MENUS::render_settings_player(RECT main_view)
|
|||
if(ui_do_edit_box(config.player_name, &button, config.player_name, sizeof(config.player_name), 14.0f))
|
||||
need_sendinfo = true;
|
||||
|
||||
// extra spacing
|
||||
ui_hsplit_t(&main_view, 10.0f, 0, &main_view);
|
||||
|
||||
static int dynamic_camera_button = 0;
|
||||
ui_hsplit_t(&main_view, 20.0f, &button, &main_view);
|
||||
if(ui_do_button(&dynamic_camera_button, localize("Dynamic Camera"), config.cl_mouse_deadzone != 0, &button, ui_draw_checkbox, 0))
|
||||
|
@ -622,21 +625,80 @@ void MENUS::render_settings_sound(RECT main_view)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static void menu2_render_settings_network(RECT main_view)
|
||||
struct LANGUAGE
|
||||
{
|
||||
RECT button;
|
||||
ui_vsplit_l(&main_view, 300.0f, &main_view, 0);
|
||||
LANGUAGE() {}
|
||||
LANGUAGE(const char *n, const char *f) : name(n), filename(f) {}
|
||||
|
||||
string name;
|
||||
string filename;
|
||||
|
||||
bool operator<(const LANGUAGE &other) { return name < other.name; }
|
||||
};
|
||||
|
||||
|
||||
int fs_listdir(const char *dir, FS_LISTDIR_CALLBACK cb, void *user);
|
||||
|
||||
void gather_languages(const char *name, int is_dir, void *user)
|
||||
{
|
||||
if(is_dir || name[0] == '.')
|
||||
return;
|
||||
|
||||
sorted_array<LANGUAGE> &languages = *((sorted_array<LANGUAGE> *)user);
|
||||
char filename[128];
|
||||
str_format(filename, sizeof(filename), "data/languages/%s", name);
|
||||
|
||||
char nicename[128];
|
||||
str_format(nicename, sizeof(nicename), "%s", name);
|
||||
nicename[0] = str_uppercase(nicename[0]);
|
||||
|
||||
|
||||
for(char *p = nicename; *p; p++)
|
||||
if(*p == '.')
|
||||
*p = 0;
|
||||
|
||||
languages.add(LANGUAGE(nicename, filename));
|
||||
}
|
||||
|
||||
void MENUS::render_settings_general(RECT main_view)
|
||||
{
|
||||
static int lanuagelist = 0;
|
||||
static int selected_language = 0;
|
||||
static sorted_array<LANGUAGE> languages;
|
||||
|
||||
if(languages.size() == 0)
|
||||
{
|
||||
ui_hsplit_t(&main_view, 20.0f, &button, &main_view);
|
||||
ui_do_label(&button, "Rcon Password", 14.0, -1);
|
||||
ui_vsplit_l(&button, 110.0f, 0, &button);
|
||||
ui_vsplit_l(&button, 180.0f, &button, 0);
|
||||
ui_do_edit_box(&config.rcon_password, &button, config.rcon_password, sizeof(config.rcon_password), true);
|
||||
languages.add(LANGUAGE("English", ""));
|
||||
fs_listdir("data/languages", gather_languages, &languages);
|
||||
for(int i = 0; i < languages.size(); i++)
|
||||
if(str_comp(languages[i].filename, config.cl_languagefile) == 0)
|
||||
{
|
||||
selected_language = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
int old_selected = selected_language;
|
||||
|
||||
RECT list = main_view;
|
||||
ui_do_listbox_start(&lanuagelist, &list, 24.0f, localize("Language"), languages.size(), selected_language);
|
||||
|
||||
for(sorted_array<LANGUAGE>::range r = languages.all(); !r.empty(); r.pop_front())
|
||||
{
|
||||
LISTBOXITEM item = ui_do_listbox_nextitem(&r.front());
|
||||
|
||||
if(item.visible)
|
||||
ui_do_label(&item.rect, r.front().name, 16.0f, -1);
|
||||
}
|
||||
|
||||
selected_language = ui_do_listbox_end();
|
||||
|
||||
if(old_selected != selected_language)
|
||||
{
|
||||
str_copy(config.cl_languagefile, languages[selected_language].filename, sizeof(config.cl_languagefile));
|
||||
localization.load(languages[selected_language].filename);
|
||||
}
|
||||
}
|
||||
|
||||
void MENUS::render_settings(RECT main_view)
|
||||
{
|
||||
|
@ -654,6 +716,7 @@ void MENUS::render_settings(RECT main_view)
|
|||
RECT button;
|
||||
|
||||
const char *tabs[] = {
|
||||
localize("General"),
|
||||
localize("Player"),
|
||||
localize("Controls"),
|
||||
localize("Graphics"),
|
||||
|
@ -671,12 +734,14 @@ void MENUS::render_settings(RECT main_view)
|
|||
ui_margin(&main_view, 10.0f, &main_view);
|
||||
|
||||
if(settings_page == 0)
|
||||
render_settings_player(main_view);
|
||||
render_settings_general(main_view);
|
||||
else if(settings_page == 1)
|
||||
render_settings_controls(main_view);
|
||||
render_settings_player(main_view);
|
||||
else if(settings_page == 2)
|
||||
render_settings_graphics(main_view);
|
||||
render_settings_controls(main_view);
|
||||
else if(settings_page == 3)
|
||||
render_settings_graphics(main_view);
|
||||
else if(settings_page == 4)
|
||||
render_settings_sound(main_view);
|
||||
|
||||
if(need_restart)
|
||||
|
|
|
@ -229,9 +229,6 @@ void GAMECLIENT::on_console_init()
|
|||
input.add(controls);
|
||||
input.add(binds);
|
||||
|
||||
//
|
||||
MACRO_REGISTER_COMMAND("language", "s", CFGFLAG_CLIENT, con_language, this, "Sets the language");
|
||||
|
||||
// add the some console commands
|
||||
MACRO_REGISTER_COMMAND("team", "i", CFGFLAG_CLIENT, con_team, this, "Switch team");
|
||||
MACRO_REGISTER_COMMAND("kill", "", CFGFLAG_CLIENT, con_kill, this, "Kill yourself");
|
||||
|
@ -258,6 +255,9 @@ void GAMECLIENT::on_console_init()
|
|||
|
||||
void GAMECLIENT::on_init()
|
||||
{
|
||||
// set the language
|
||||
localization.load(config.cl_languagefile);
|
||||
|
||||
// init all components
|
||||
for(int i = 0; i < all.num; i++)
|
||||
all.components[i]->on_init();
|
||||
|
@ -954,10 +954,3 @@ void GAMECLIENT::con_kill(void *result, void *user_data)
|
|||
{
|
||||
((GAMECLIENT*)user_data)->send_kill(-1);
|
||||
}
|
||||
|
||||
void GAMECLIENT::con_language(void *result, void *user_data)
|
||||
{
|
||||
char buf[128];
|
||||
str_format(buf, sizeof(buf), "data/languages/%s.txt", console_arg_string(result, 0));
|
||||
localization.load(buf);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ class GAMECLIENT
|
|||
int predicted_tick;
|
||||
int last_new_predicted_tick;
|
||||
|
||||
static void con_language(void *result, void *user_data);
|
||||
static void con_team(void *result, void *user_data);
|
||||
static void con_kill(void *result, void *user_data);
|
||||
|
||||
|
|
|
@ -51,12 +51,18 @@ void LOCALIZATIONDATABASE::add_string(const char *org_str, const char *new_str)
|
|||
|
||||
bool LOCALIZATIONDATABASE::load(const char *filename)
|
||||
{
|
||||
// empty string means unload
|
||||
if(filename[0] == 0)
|
||||
{
|
||||
strings.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
LINEREADER lr;
|
||||
IOHANDLE io = io_open(filename, IOFLAG_READ);
|
||||
if(!io)
|
||||
return false;
|
||||
|
||||
|
||||
dbg_msg("localization", "loaded '%s'", filename);
|
||||
strings.clear();
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ MACRO_CONFIG_INT(cl_motd_time, 10, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SAVE, "How lon
|
|||
|
||||
MACRO_CONFIG_STR(cl_version_server, 100, "version.teeworlds.com", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Server to use to check for new versions")
|
||||
|
||||
MACRO_CONFIG_STR(cl_languagefile, 255, "", CFGFLAG_CLIENT|CFGFLAG_SAVE, "What language file to use")
|
||||
|
||||
MACRO_CONFIG_INT(player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toggles usage of custom colors")
|
||||
MACRO_CONFIG_INT(player_color_body, 65408, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
|
||||
MACRO_CONFIG_INT(player_color_feet, 65408, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
|
||||
|
|
Loading…
Reference in a new issue