mirror of
https://github.com/libretro/RetroArch
synced 2024-12-27 15:29:23 +00:00
(Frontend) Add User Options menu - add User Language setting
(Libretro) Add RETRO_ENVIRONMENT_GET_LANGUAGE - expose language to libretro core so it can do personalization. Will be used for PPSSPP
This commit is contained in:
parent
1c290c6f00
commit
cac003f2ab
@ -261,6 +261,8 @@ enum
|
||||
#define DEFAULT_GAMMA 0
|
||||
#endif
|
||||
|
||||
static const unsigned int def_user_language = 0;
|
||||
|
||||
// Windowed
|
||||
static const float xscale = 3.0; // Real x res = aspect * base_size * xscale
|
||||
static const float yscale = 3.0; // Real y res = base_size * yscale
|
||||
|
@ -342,7 +342,10 @@ static void menu_common_entries_init(void *data, unsigned menu_type)
|
||||
#ifdef HAVE_OVERLAY
|
||||
file_list_push(menu->selection_buf, "Overlay Options", MENU_SETTINGS_OVERLAY_OPTIONS, 0);
|
||||
#endif
|
||||
file_list_push(menu->selection_buf, "User Options", MENU_SETTINGS_USER_OPTIONS, 0);
|
||||
#ifdef HAVE_NETPLAY
|
||||
file_list_push(menu->selection_buf, "Netplay Options", MENU_SETTINGS_NETPLAY_OPTIONS, 0);
|
||||
#endif
|
||||
file_list_push(menu->selection_buf, "Path Options", MENU_SETTINGS_PATH_OPTIONS, 0);
|
||||
if (g_extern.main_is_init && !g_extern.libretro_dummy)
|
||||
{
|
||||
@ -376,10 +379,16 @@ static void menu_common_entries_init(void *data, unsigned menu_type)
|
||||
if ((current_setting = setting_data_find_setting(setting_data, "input_overlay_scale")))
|
||||
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_OVERLAY_SCALE, 0);
|
||||
break;
|
||||
case MENU_SETTINGS_USER_OPTIONS:
|
||||
file_list_clear(menu->selection_buf);
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_nickname")))
|
||||
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_NETPLAY_NICKNAME, 0);
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "user_language")))
|
||||
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_USER_LANGUAGE, 0);
|
||||
break;
|
||||
#ifdef HAVE_NETPLAY
|
||||
case MENU_SETTINGS_NETPLAY_OPTIONS:
|
||||
file_list_clear(menu->selection_buf);
|
||||
file_list_push(menu->selection_buf, "Username", MENU_SETTINGS_NETPLAY_NICKNAME, 0);
|
||||
#ifdef HAVE_NETPLAY
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_enable")))
|
||||
file_list_push(menu->selection_buf, current_setting->short_description, MENU_SETTINGS_NETPLAY_ENABLE, 0);
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_mode")))
|
||||
@ -1402,6 +1411,7 @@ static unsigned menu_common_type_is(unsigned type)
|
||||
type == MENU_SETTINGS_PATH_OPTIONS ||
|
||||
type == MENU_SETTINGS_PRIVACY_OPTIONS ||
|
||||
type == MENU_SETTINGS_OVERLAY_OPTIONS ||
|
||||
type == MENU_SETTINGS_USER_OPTIONS ||
|
||||
type == MENU_SETTINGS_NETPLAY_OPTIONS ||
|
||||
type == MENU_SETTINGS_OPTIONS ||
|
||||
type == MENU_SETTINGS_DRIVERS ||
|
||||
@ -1593,6 +1603,7 @@ static int menu_settings_iterate(unsigned action)
|
||||
|| menu_type == MENU_SETTINGS_PATH_OPTIONS
|
||||
|| menu_type == MENU_SETTINGS_OVERLAY_OPTIONS
|
||||
|| menu_type == MENU_SETTINGS_NETPLAY_OPTIONS
|
||||
|| menu_type == MENU_SETTINGS_USER_OPTIONS
|
||||
|| menu_type == MENU_SETTINGS_OPTIONS
|
||||
|| menu_type == MENU_SETTINGS_DRIVERS
|
||||
|| menu_type == MENU_SETTINGS_PERFORMANCE_COUNTERS
|
||||
@ -2251,6 +2262,14 @@ static void menu_common_setting_set_current_unsigned_integer(rarch_setting_t *se
|
||||
setting->change_handler(setting);
|
||||
}
|
||||
|
||||
void menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str)
|
||||
{
|
||||
strlcpy(setting->value.string, str, setting->size);
|
||||
|
||||
if (setting->change_handler)
|
||||
setting->change_handler(setting);
|
||||
}
|
||||
|
||||
static void menu_common_setting_set_current_string_path(rarch_setting_t *setting, const char *dir, const char *path)
|
||||
{
|
||||
fill_pathname_join(setting->value.string, dir, path, setting->size);
|
||||
@ -3461,6 +3480,10 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "video_gpu_screenshot")))
|
||||
menu_common_setting_set_current_boolean(current_setting, action);
|
||||
break;
|
||||
case MENU_SETTINGS_USER_LANGUAGE:
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "user_language")))
|
||||
menu_common_setting_set_current_unsigned_integer(current_setting, 1, action, true, true);
|
||||
break;
|
||||
case MENU_SETTINGS_REWIND_GRANULARITY:
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "rewind_granularity")))
|
||||
menu_common_setting_set_current_unsigned_integer(current_setting, 1, action, true, false);
|
||||
@ -4899,6 +4922,7 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
|
||||
case MENU_SETTINGS_PATH_OPTIONS:
|
||||
case MENU_SETTINGS_OVERLAY_OPTIONS:
|
||||
case MENU_SETTINGS_NETPLAY_OPTIONS:
|
||||
case MENU_SETTINGS_USER_OPTIONS:
|
||||
case MENU_SETTINGS_PRIVACY_OPTIONS:
|
||||
case MENU_SETTINGS_OPTIONS:
|
||||
case MENU_SETTINGS_PERFORMANCE_COUNTERS:
|
||||
@ -5024,6 +5048,26 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
|
||||
case MENU_SETTINGS_WINDOW_COMPOSITING_ENABLE:
|
||||
strlcpy(type_str, g_settings.video.disable_composition ? "OFF" : "ON", type_str_size);
|
||||
break;
|
||||
case MENU_SETTINGS_USER_LANGUAGE:
|
||||
{
|
||||
static const char *modes[] = {
|
||||
"English",
|
||||
"Japanese",
|
||||
"French",
|
||||
"Spanish",
|
||||
"German",
|
||||
"Italian",
|
||||
"Dutch",
|
||||
"Portuguese",
|
||||
"Russian",
|
||||
"Korean",
|
||||
"Chinese (Traditional)",
|
||||
"Chinese (Simplified)"
|
||||
};
|
||||
|
||||
strlcpy(type_str, modes[g_settings.user_language], type_str_size);
|
||||
}
|
||||
break;
|
||||
case MENU_SETTINGS_NETPLAY_NICKNAME:
|
||||
snprintf(type_str, type_str_size, "%s", g_settings.username);
|
||||
break;
|
||||
|
@ -95,6 +95,7 @@ typedef enum
|
||||
MENU_SETTINGS_INPUT_OPTIONS,
|
||||
MENU_SETTINGS_PATH_OPTIONS,
|
||||
MENU_SETTINGS_OVERLAY_OPTIONS,
|
||||
MENU_SETTINGS_USER_OPTIONS,
|
||||
MENU_SETTINGS_NETPLAY_OPTIONS,
|
||||
MENU_SETTINGS_PRIVACY_OPTIONS,
|
||||
MENU_SETTINGS_OPTIONS,
|
||||
@ -170,6 +171,7 @@ typedef enum
|
||||
MENU_SETTINGS_NETPLAY_TCP_UDP_PORT,
|
||||
MENU_SETTINGS_NETPLAY_DELAY_FRAMES,
|
||||
MENU_SETTINGS_NETPLAY_NICKNAME,
|
||||
MENU_SETTINGS_USER_LANGUAGE,
|
||||
|
||||
MENU_SETTINGS_PRIVACY_CAMERA_ALLOW,
|
||||
MENU_SETTINGS_PRIVACY_LOCATION_ALLOW,
|
||||
|
@ -310,6 +310,8 @@ static void rgui_render(void)
|
||||
strlcpy(title, "OVERLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_NETPLAY_OPTIONS)
|
||||
strlcpy(title, "NETPLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_USER_OPTIONS)
|
||||
strlcpy(title, "USER OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_PATH_OPTIONS)
|
||||
strlcpy(title, "PATH OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_OPTIONS)
|
||||
|
@ -188,6 +188,8 @@ static void rmenu_render(void)
|
||||
strlcpy(title, "OVERLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_NETPLAY_OPTIONS)
|
||||
strlcpy(title, "NETPLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_USER_OPTIONS)
|
||||
strlcpy(title, "USER OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_FONT_OPTIONS)
|
||||
strlcpy(title, "FONT OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_GENERAL_OPTIONS)
|
||||
|
@ -411,6 +411,8 @@ static void rmenu_xui_render(void)
|
||||
strlcpy(title, "OVERLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_NETPLAY_OPTIONS)
|
||||
strlcpy(title, "NETPLAY OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_USER_OPTIONS)
|
||||
strlcpy(title, "USER OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_PATH_OPTIONS)
|
||||
strlcpy(title, "PATH OPTIONS", sizeof(title));
|
||||
else if (menu_type == MENU_SETTINGS_OPTIONS)
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include "menu_common.h"
|
||||
#include "../../input/keyboard_line.h"
|
||||
#include "menu_input_line_cb.h"
|
||||
#include "../../settings_data.h"
|
||||
|
||||
//forward decls
|
||||
extern void menu_common_setting_set_current_string(rarch_setting_t *setting, const char *str);
|
||||
|
||||
void menu_key_start_line(void *data, const char *label, input_keyboard_line_complete_t cb)
|
||||
{
|
||||
@ -83,9 +87,14 @@ void netplay_ipaddress_callback(void *userdata, const char *str)
|
||||
void netplay_nickname_callback(void *userdata, const char *str)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)userdata;
|
||||
|
||||
if (str && *str)
|
||||
strlcpy(g_settings.username, str, sizeof(g_settings.username));
|
||||
rarch_setting_t *current_setting;
|
||||
rarch_setting_t *setting_data = (rarch_setting_t *)setting_data_get_list();
|
||||
|
||||
if (str && *str && setting_data)
|
||||
{
|
||||
if ((current_setting = (rarch_setting_t*)setting_data_find_setting(setting_data, "netplay_nickname")))
|
||||
menu_common_setting_set_current_string(current_setting, str);
|
||||
}
|
||||
menu_key_end_line(menu);
|
||||
}
|
||||
#endif
|
||||
|
@ -356,6 +356,7 @@ struct settings
|
||||
bool core_specific_config;
|
||||
|
||||
char username[32];
|
||||
unsigned int user_language;
|
||||
};
|
||||
|
||||
typedef struct rarch_resolution
|
||||
|
28
libretro.h
28
libretro.h
@ -164,6 +164,26 @@ extern "C" {
|
||||
#define RETRO_REGION_NTSC 0
|
||||
#define RETRO_REGION_PAL 1
|
||||
|
||||
// Id values for LANGUAGE
|
||||
enum retro_language
|
||||
{
|
||||
RETRO_LANGUAGE_ENGLISH = 0,
|
||||
RETRO_LANGUAGE_JAPANESE = 1,
|
||||
RETRO_LANGUAGE_FRENCH = 2,
|
||||
RETRO_LANGUAGE_SPANISH = 3,
|
||||
RETRO_LANGUAGE_GERMAN = 4,
|
||||
RETRO_LANGUAGE_ITALIAN = 5,
|
||||
RETRO_LANGUAGE_DUTCH = 6,
|
||||
RETRO_LANGUAGE_PORTUGUESE = 7,
|
||||
RETRO_LANGUAGE_RUSSIAN = 8,
|
||||
RETRO_LANGUAGE_KOREAN = 9,
|
||||
RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10,
|
||||
RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11,
|
||||
RETRO_LANGUAGE_LAST,
|
||||
|
||||
RETRO_LANGUAGE_DUMMY = INT_MAX // Ensure sizeof(enum) == sizeof(int)
|
||||
};
|
||||
|
||||
// Passed to retro_get_memory_data/size().
|
||||
// If the memory type doesn't apply to the implementation NULL/0 can be returned.
|
||||
#define RETRO_MEMORY_MASK 0xff
|
||||
@ -662,12 +682,18 @@ enum retro_mod
|
||||
|
||||
#define RETRO_ENVIRONMENT_GET_USERNAME 38
|
||||
// const char **
|
||||
// Returns the specified username of the frontend, if specified.
|
||||
// Returns the specified username of the frontend, if specified by the user.
|
||||
// This username can be used as a nickname for a core that has online facilities or any other mode where personalization // of the user is desirable.
|
||||
// The returned value can be NULL.
|
||||
// If this environ callback is used by a core that requires a valid username, a default username should be specified
|
||||
// by the core.
|
||||
//
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_LANGUAGE 39
|
||||
// const unsigned * --
|
||||
// Returns the specified language of the frontend, if specified by the user.
|
||||
// It can be used by the core for personalization purposes.
|
||||
//
|
||||
|
||||
#define RETRO_MEMDESC_CONST (1 << 0) // The frontend will never change this memory area once retro_load_game has returned.
|
||||
#define RETRO_MEMDESC_BIGENDIAN (1 << 1) // The memory area contains big endian data. Default is little endian.
|
||||
|
@ -456,6 +456,8 @@ void config_set_defaults(void)
|
||||
#endif
|
||||
g_settings.core_specific_config = default_core_specific_config;
|
||||
|
||||
g_settings.user_language = 0;
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
g_extern.console.screen.gamma_correction = DEFAULT_GAMMA;
|
||||
g_extern.lifecycle_state |= (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE);
|
||||
@ -1093,6 +1095,7 @@ bool config_load_file(const char *path, bool set_defaults)
|
||||
|
||||
if (!g_extern.has_set_username)
|
||||
CONFIG_GET_PATH(username, "netplay_nickname");
|
||||
CONFIG_GET_INT(user_language, "user_language");
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (!g_extern.has_set_netplay_mode)
|
||||
CONFIG_GET_BOOL_EXTERN(netplay_is_spectate, "netplay_spectator_mode_enable");
|
||||
@ -1474,6 +1477,7 @@ bool config_save_file(const char *path)
|
||||
config_set_int(conf, "netplay_delay_frames", g_extern.netplay_sync_frames);
|
||||
#endif
|
||||
config_set_string(conf, "netplay_nickname", g_settings.username);
|
||||
config_set_int(conf, "user_language", g_settings.user_language);
|
||||
|
||||
bool custom_bgm_enable_val = g_extern.lifecycle_state & (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE);
|
||||
config_set_bool(conf, "custom_bgm_enable", custom_bgm_enable_val);
|
||||
|
@ -969,6 +969,8 @@ static void general_read_handler(const void *data)
|
||||
else if (!strcmp(setting->name, "osk_enable"))
|
||||
*setting->value.boolean = g_settings.osk.enable;
|
||||
#endif
|
||||
else if (!strcmp(setting->name, "user_language"))
|
||||
*setting->value.unsigned_integer = g_settings.user_language;
|
||||
}
|
||||
|
||||
static void general_write_handler(const void *data)
|
||||
@ -1327,6 +1329,8 @@ static void general_write_handler(const void *data)
|
||||
else if (!strcmp(setting->name, "osk_enable"))
|
||||
g_settings.osk.enable = *setting->value.boolean;
|
||||
#endif
|
||||
else if (!strcmp(setting->name, "user_language"))
|
||||
g_settings.user_language = *setting->value.unsigned_integer;
|
||||
}
|
||||
|
||||
#define NEXT (list[index++])
|
||||
@ -1626,16 +1630,26 @@ rarch_setting_t* setting_data_get_list(void)
|
||||
END_GROUP()
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
/*******************/
|
||||
/* NETPLAY OPTIONS */
|
||||
/*******************/
|
||||
START_GROUP("Netplay Options")
|
||||
START_SUB_GROUP("State")
|
||||
#ifdef HAVE_NETPLAY
|
||||
CONFIG_BOOL(g_extern.netplay_enable, "netplay_enable", "Netplay Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_BOOL(g_extern.netplay_is_client, "netplay_mode", "Netplay Client Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_BOOL(g_extern.netplay_is_spectate, "netplay_spectator_mode_enable", "Netplay Spectator Enable", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
END_SUB_GROUP()
|
||||
END_GROUP()
|
||||
#endif
|
||||
|
||||
/*******************/
|
||||
/* USER OPTIONS */
|
||||
/*******************/
|
||||
START_GROUP("User Options")
|
||||
START_SUB_GROUP("State")
|
||||
CONFIG_PATH(g_settings.username, "netplay_nickname", "Username", "", GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
|
||||
CONFIG_UINT(g_settings.user_language, "user_language", "Language", def_user_language, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler) WITH_RANGE(0, RETRO_LANGUAGE_LAST-1)
|
||||
END_SUB_GROUP()
|
||||
END_GROUP()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user