diff --git a/docker/android/build.sh b/docker/android/build.sh index a8bb5fc2..bf39226e 100755 --- a/docker/android/build.sh +++ b/docker/android/build.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e -cd /vanilla/android +cd ../../android ./gradlew -PbuildDir=/build assembleRelease zipalign -v -p 4 /build/outputs/apk/release/app-release-unsigned.apk /build/outputs/apk/release/app-release-unsigned-aligned.apk apksigner sign --ks /vanilla/docker/android/vanilla.jks --out /install/app-release.apk --ks-pass pass:$ANDROID_SIGNING_KEY /build/outputs/apk/release/app-release-unsigned-aligned.apk diff --git a/gui/assets/font/system.ttf b/gui/assets/font/system.ttf index 7e3bb2f8..4340bded 100644 Binary files a/gui/assets/font/system.ttf and b/gui/assets/font/system.ttf differ diff --git a/gui/assets/font/system_a.ttf b/gui/assets/font/system_a.ttf new file mode 100644 index 00000000..7e3bb2f8 Binary files /dev/null and b/gui/assets/font/system_a.ttf differ diff --git a/gui/lang.c b/gui/lang.c index f0c20987..43291833 100644 --- a/gui/lang.c +++ b/gui/lang.c @@ -1,60 +1,43 @@ +#include #include "lang.h" - -static const char *lang_str[__VPI_LANG_T_COUNT] = { - "Sync", - "Connect", - "Edit", - "Settings", - "OK", - "Cancel", - "Touch the symbols in the order they are displayed on the TV screen from left to right.", - "If the symbols are not displayed on the TV screen, press the SYNC Button on the Wii U console.", - "Connecting to the Wii U console...", - "Sync Failed", - "Vanilla needs root permission to configure the wireless interface for connection.", - "Please enter your \"sudo\" password here.", - "Error", - "No consoles synced", - "Connecting to \"%s\"...", - "Are you sure you want to delete \"%s\"?", - "Successfully deleted \"%s\"", - "Rename", - "Delete", - "Back", - "More", - "Controls", - "Audio", - "Connection", - "Webcam", - "Region", - "Local", - "Via Server", - "Set up how Vanilla connects to the Wii U", - "Choose 'Local' to connect directly with the hardware on your system. Otherwise, you may need a compatible 'server' to relay the necessary packets.", - "Select the wireless interface to use for the connection.", - "Enter the IP address of the server you wish to connect through.", - "Screenshot saved to \"%s\"", - "Recording started to \"%s\"", - "Recording finished", - "Connection lost, attempting to re-connect...", - "Your platform is not capable of \"Local\" connection, and must connect via a server.", - "Failed to save screenshot (%i)", - "Select gamepad region", - "Gamepad region must match the console region or else the console will throw an error. This has no other effect on usage.", - "Japan", - "America", - "Europe", - "Quit", - "Authentication failed. Please try again.", - "Don't ask again", - "WARNING", - "This option will install a Polkit rule that will allow Vanilla's backend to run as root without password entry.\n\nThere are inherent risks to bypassing security systems. Only enable this if you are willing to accept those risks.\n\nNOTE: If you are using the Steam Deck, this will also disable read-only access to your system partition.", - "I acknowledge", - "Enable Root Password Skip", - "Disable Root Password Skip", - "Swap AB/XY buttons", - "Full Screen", +#include "langs/english_en/english_en.h" +#include "langs/french_fr/french_fr.h" +static char *langs_order[2] = { + "en", + "fr", }; +static const int lang_c = sizeof(langs_order) / sizeof(langs_order[0]); +static const char *lang_str[__VPI_LANG_T_COUNT]; +char lang_history[3]; + +int lang_choice(char *curr_lang){ + if (strcmp(curr_lang, "en") == 0) { + memcpy(lang_str, lang_str_en, sizeof(lang_str)); + } + else if (strcmp(curr_lang, "fr") == 0) { + memcpy(lang_str, lang_str_fr, sizeof(lang_str)); + } + else { + return 0; + } + memcpy(lang_history, curr_lang, sizeof(lang_history)); + return 1; +} + +char *switch_lang(const char *curr_lang){ + for(int i = 0; i < lang_c; i++){ + if(strcmp(langs_order[i], curr_lang) == 0) { + int next = (i + 1) % lang_c; + lang_choice(langs_order[next]); + return langs_order[next]; + } + } + return NULL; +} + +const char *get_lang(){ + return lang_history; +} const char *lang(vpi_lang_t id) { diff --git a/gui/lang.h b/gui/lang.h index e39c7ef2..927ccb2f 100644 --- a/gui/lang.h +++ b/gui/lang.h @@ -55,9 +55,13 @@ typedef enum { VPI_LANG_DISABLE_PASSWORD_SKIP, VPI_LANG_SWAP_ABXY_BUTTONS, VPI_LANG_FULLSCREEN, + VPI_LANG_LANG_CHOICE, __VPI_LANG_T_COUNT } vpi_lang_t; +int lang_choice(char *curr_lang); +char *switch_lang(const char *curr_lang); const char *lang(vpi_lang_t id); +const char *get_lang(); #endif // VANILLA_PI_LANG_H diff --git a/gui/langs/english_en/english_en.h b/gui/langs/english_en/english_en.h new file mode 100644 index 00000000..808bc016 --- /dev/null +++ b/gui/langs/english_en/english_en.h @@ -0,0 +1,63 @@ +#ifndef ENGLISH_EN_H +#define ENGLISH_EN_H + +#include "lang.h" + +static const char *lang_str_en[__VPI_LANG_T_COUNT] = { + "Sync", + "Connect", + "Edit", + "Settings", + "OK", + "Cancel", + "Touch the symbols in the order they are displayed on the TV screen from left to right.", + "If the symbols are not displayed on the TV screen, press the SYNC Button on the Wii U console.", + "Connecting to the Wii U console...", + "Sync Failed", + "Vanilla needs root permission to configure the wireless interface for connection.", + "Please enter your \"sudo\" password here.", + "Error", + "No consoles synced", + "Connecting to \"%s\"...", + "Are you sure you want to delete \"%s\"?", + "Successfully deleted \"%s\"", + "Rename", + "Delete", + "Back", + "More", + "Controls", + "Audio", + "Connection", + "Webcam", + "Region", + "Local", + "Via Server", + "Set up how Vanilla connects to the Wii U", + "Choose 'Local' to connect directly with the hardware on your system. Otherwise, you may need a compatible 'server' to relay the necessary packets.", + "Select the wireless interface to use for the connection.", + "Enter the IP address of the server you wish to connect through.", + "Screenshot saved to \"%s\"", + "Recording started to \"%s\"", + "Recording finished", + "Connection lost, attempting to re-connect...", + "Your platform is not capable of \"Local\" connection, and must connect via a server.", + "Failed to save screenshot (%i)", + "Select gamepad region", + "Gamepad region must match the console region or else the console will throw an error. This has no other effect on usage.", + "Japan", + "America", + "Europe", + "Quit", + "Authentication failed. Please try again.", + "Don't ask again", + "WARNING", + "This option will install a Polkit rule that will allow Vanilla's backend to run as root without password entry.\n\nThere are inherent risks to bypassing security systems. Only enable this if you are willing to accept those risks.\n\nNOTE: If you are using the Steam Deck, this will also disable read-only access to your system partition.", + "I acknowledge", + "Enable Root Password Skip", + "Disable Root Password Skip", + "Swap AB/XY buttons", + "Full Screen", + "Language: English", +}; + +#endif diff --git a/gui/langs/french_fr/french_fr.h b/gui/langs/french_fr/french_fr.h new file mode 100644 index 00000000..0c188b8e --- /dev/null +++ b/gui/langs/french_fr/french_fr.h @@ -0,0 +1,63 @@ +#ifndef FRENCH_FR_H +#define FRENCH_FR_H + +#include "lang.h" + +static const char *lang_str_fr[__VPI_LANG_T_COUNT] = { + "Synchroniser", + "Connecte", + "Modifier", + "Paramétres", + "OK", + "Annuler", + "Cliquez sur les symboles dans l'ordre affiché dans l'écran TV de gauche à droite.", + "Si les symboles ne sont pas affichés dans l'écran TV, appuyez sur le bouton SYNC sur la console Wii U.", + "Connexion à la console Wii U...", + "Synchronisation échouée", + "Vanilla a besoin de la permission root pour configurer l'interface sans fils pour la connexion.", + "Entrez votre \"sudo\" mot de passe ici.", + "Erreur", + "Aucune consoles synchronisée", + "Connexion à \"%s\" en cours...", + "Êtes-vous sûre que vous voulez supprimer \"%s\"?", + "\"%s\" Supprimé avec Succès", + "Renommer", + "Supprimer", + "Retour", + "Plus", + "Controlles", + "Audio", + "Connexion", + "Caméra", + "Région", + "Local", + "Via Serveur", + "Mettre en place comment Vanilla se connecte à la Wii U", + "Choisissez 'Local' pour vous connecter directement avec la matériel sur votre système. Sinon, vous aurez peut-être besoin d'un serveur compatible pour relayer les paquets nécessaires.", + "Choisissez l'interface sans fil à utiliser pour la connexion.", + "Entrez l'adresse IP du serveur auquel vous voulez vous connecter", + "Capture d'écran enregistrée à \"%s\"", + "L'enregistrement a commencé à \"%s\"", + "Enregistrement terminé", + "Connexion perdu, tenter de re-connecter...", + "Votre plateforme n'est pas capable de \"Local\" connexion, et doit être connectée via un serveur.", + "Impossible d'enregistrer la capture d'écran (%i)", + "Choisissez la région du gamepad", + "La région du gamepad doit être la même que celle de la console ,sinon la console donnera une erreur. Ça n'a pas d'autre effet sur l'usage.", + "Japan", + "Amérique", + "Europe", + "Quitter", + "L'authentification a échoué. Veuillez réessayer.", + "Ne pas demander encore", + "AVERTISSEMENT", + "Cette option va installer une règle Polkit qui va permettre au backend de Vanilla d'éxecuter en root sans entrée de mot de passe.\n\nIl n'y a pas de risques inhérents de contourner les systèmes de sécurité. Activez cette option si vous acceptez cez risques.\n\nNOTE: Si vous utilisez le Steam Deck, ça va aussi déactiver read-only access de votre partition système.", + "Je comprend", + "Activer le Skip de Mot de Passe Root", + "Désactiver le Skip du Mot de Passe Root", + "Inverser les boutons AB/XY", + "Plein Écran", + "Language: Français" +}; + +#endif diff --git a/gui/main.c b/gui/main.c index 483478a9..e9d28e8b 100644 --- a/gui/main.c +++ b/gui/main.c @@ -7,6 +7,8 @@ #include "platform.h" #include "ui/ui.h" #include "ui/ui_sdl.h" +#include "lang.h" +char curr_lang[3] = "en"; #define SCREEN_WIDTH 854 #define SCREEN_HEIGHT 480 @@ -34,7 +36,15 @@ int SDL_main(int argc, const char **argv) } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { display_cli_help(argv); return 0; - } + } else if (!strcmp(argv[i], "--lang")){ + if (!((i + 1) < argc)) { + vpilog("Error: No language specified!\n"); + display_cli_help(argv); + return 1; + } + consumed = 2; + strcpy(curr_lang, argv[i+1]); + } if (consumed <= 0) { vpilog("Invalid argument(s): %s\n\n", argv[i]); display_cli_help(argv); @@ -42,6 +52,11 @@ int SDL_main(int argc, const char **argv) } } + if (!lang_choice(curr_lang)) { + vpilog("Invalid language: %s\n\n", curr_lang); + return 1; + } + vanilla_install_logger(vpilog_va); // Load config @@ -90,7 +105,8 @@ int SDL_main(int argc, const char **argv) void display_cli_help(const char **argv) { vpilog("Usage: %s [options]\n\n", argv[0]); vpilog("Options:\n"); - vpilog(" -w, --window Run Vanilla in a window (overrides config)\n"); - vpilog(" -f, --fullscreen Run Vanilla full screen (overrides config)\n"); - vpilog(" -h, --help Show this help message\n"); + vpilog(" -w --window Run Vanilla in a window (overrides config)\n"); + vpilog(" -f --fullscreen Run Vanilla full screen (overrides config)\n"); + vpilog(" -h --help Show this help message\n"); + vpilog(" --lang Override the default language\n"); } diff --git a/gui/menu/menu.c b/gui/menu/menu.c index b1cba8b3..29f9cb09 100644 --- a/gui/menu/menu.c +++ b/gui/menu/menu.c @@ -11,8 +11,11 @@ #include "menu_common.h" #include "menu_game.h" #include "menu_main.h" +#include "menu_settings.h" #include "platform.h" +#include "ui/ui_anim.h" + void vpi_mic_callback(void *userdata, const uint8_t *data, size_t len) { vanilla_send_audio(data, len); @@ -66,8 +69,13 @@ void vpi_menu_action(vui_context_t *vui, vpi_extra_action_t action) // Send shutdown signal vpi_game_shutdown(); } else { - // Quit Vanilla entirely - vpi_menu_quit_vanilla(vui); + // Quit Vanilla entirely or go back to menu + if(IsSettings == 1){ + vui_transition_fade_layer_out(vui, 0, vpi_menu_main, (void *) (intptr_t) 1); + } + else{ + vpi_menu_quit_vanilla(vui); + } } break; } diff --git a/gui/menu/menu_main.c b/gui/menu/menu_main.c index 2df91a6c..df0e83b2 100644 --- a/gui/menu/menu_main.c +++ b/gui/menu/menu_main.c @@ -191,4 +191,5 @@ void vpi_menu_main(vui_context_t *vui, void *v) } else { vui_transition_fade_layer_in(vui, layer, NULL, NULL); } + IsSettings = 0; } diff --git a/gui/menu/menu_settings.c b/gui/menu/menu_settings.c index e043a8cf..4ca8e871 100644 --- a/gui/menu/menu_settings.c +++ b/gui/menu/menu_settings.c @@ -14,6 +14,11 @@ #include "pipe/def.h" #include "ui/ui_anim.h" +vui_context_t *vui_count[16]; +vpi_lang_t text_count[16]; +int old_back_layer; +int IsSettings = 0; + static void return_to_main(vui_context_t *vui, int btn, void *v) { int layer = (intptr_t) v; @@ -43,6 +48,17 @@ static void thunk_to_quit(vui_context_t *vui, int button, void *v) vpi_menu_quit_vanilla(vui); } +static void change_language(vui_context_t *vui, int button, void *v) +{ + switch_lang(get_lang()); + for(int i = 0; i < 16; i++){ + if(!vui_count[i]) {continue;} + vui_button_update_text(vui_count[i], i, lang(text_count[i])); + vpi_menu_create_back_button(vui, old_back_layer, return_to_main, (void *) (intptr_t) old_back_layer); + } +} + + #ifdef VANILLA_POLKIT_AVAILABLE static void do_polkit_install(vui_context_t *vui, void *v) { @@ -106,8 +122,10 @@ static void toggle_fullscreen(vui_context_t *vui, int button, void *v) void vpi_menu_settings(vui_context_t *vui, void *v) { vui_reset(vui); + IsSettings = 1; int fglayer = vui_layer_create(vui); + old_back_layer = fglayer; int scrw, scrh; vui_get_screen_size(vui, &scrw, &scrh); @@ -121,6 +139,7 @@ void vpi_menu_settings(vui_context_t *vui, void *v) VPI_LANG_REGION, -1, -1, + VPI_LANG_LANG_CHOICE, }; // Highlight currently implemented functionality @@ -130,8 +149,10 @@ void vpi_menu_settings(vui_context_t *vui, void *v) transition_to_region, 0, 0, + change_language, }; + static const int button_count = sizeof(SETTINGS_NAMES) / sizeof(int); int buttons[button_count]; @@ -154,11 +175,14 @@ void vpi_menu_settings(vui_context_t *vui, void *v) int btnw = scrw*3/4; int btnx = scrw/2 - btnw/2; - int btny = scrh/10; + int btny = scrh/16; + int btnh = BTN_SZ/1.1; for (int index = 0; index < button_count; index++) { if (SETTINGS_ACTION[index]) { - buttons[index] = vui_button_create(vui, btnx, btny, btnw, BTN_SZ, lang(SETTINGS_NAMES[index]), 0, VUI_BUTTON_STYLE_BUTTON, fglayer, SETTINGS_ACTION[index], (void *) (intptr_t) fglayer); - btny += BTN_SZ; + vui_count[index] = vui; + text_count[index] = SETTINGS_NAMES[index]; + buttons[index] = vui_button_create(vui, btnx, btny, btnw, btnh, lang(SETTINGS_NAMES[index]), 0, VUI_BUTTON_STYLE_BUTTON, fglayer, SETTINGS_ACTION[index], (void *) (intptr_t) fglayer); + btny += btnh; } } @@ -169,6 +193,7 @@ void vpi_menu_settings(vui_context_t *vui, void *v) #endif // Back button + vpi_menu_create_back_button(vui, fglayer, return_to_main, (void *) (intptr_t) fglayer); vui_transition_fade_layer_in(vui, fglayer, 0, 0); diff --git a/gui/menu/menu_settings.h b/gui/menu/menu_settings.h index e6bbbeeb..d3a9d5aa 100644 --- a/gui/menu/menu_settings.h +++ b/gui/menu/menu_settings.h @@ -4,5 +4,6 @@ #include "ui/ui.h" void vpi_menu_settings(vui_context_t *vui, void *v); +extern int IsSettings; #endif // VANILLA_PI_MENU_SETTINGS_H \ No newline at end of file