From 1b46f90588fff3dc1789be23c80cc7e7f87b3707 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 17 Apr 2023 14:43:22 -0700 Subject: [PATCH] Use up all of the discord activity space for mods, list them more intelligently --- lang/Italian.ini | 320 ++++++++++++++++++++++++++++++ src/pc/discord/discord_activity.c | 49 +++-- src/pc/utils/misc.c | 50 +++++ src/pc/utils/misc.h | 2 + 4 files changed, 396 insertions(+), 25 deletions(-) create mode 100644 lang/Italian.ini diff --git a/lang/Italian.ini b/lang/Italian.ini new file mode 100644 index 00000000..780ed466 --- /dev/null +++ b/lang/Italian.ini @@ -0,0 +1,320 @@ +[NOTIF] +CONNECTED = "@ si è connesso" +DISCONNECTED = "@ si è disconnesso" +LEFT_THIS_LEVEL = "@ ha lasciato il livello" +ENTERED_THIS_LEVEL = "@ è entrato nel livello" +ENTERED = "@ è entrato in\n#" +SERVER_CLOSED = "\\#ffa0a0\\Disconnesso:\\#dcdcdc\\ server chiuso" +DISCORD_ERROR = "Errore: Discord ha avuto un errore\nPer risolverlo, prova a: \n1. Chiudere il gioco.\n2. Riavviare Discord.\n3. Avviare il gioco." +DISCORD_DETECT = "\\#ffa0a0\\Errore:\\#c8c8c8\\ impossibile individuare Discord.\n\\#a0a0a0\\Prova a chiudere il gioco, riavviare Discord, e poi riaprire il gioco." +DISCONNECT_FULL = "\\#ffa0a0\\Disconnesso:\\#c8c8c8\\ il server è pieno." +DISCONNECT_KICK = "\\#ffa0a0\\Disconnesso:\\#c8c8c8\\ sei stato espulso." +DISCONNECT_BAN = "\\#ffa0a0\\Disconnesso:\\#c8c8c8\\ sei stato bandito." +DISCONNECT_REJOIN = "\\#ffa0a0\\Disconnesso:\\#c8c8c8\\ ricollegandoti..." +DISCONNECT_CLOSED = "\\#ffa0a0\\Disconnesso:\\#c8c8c8\\ l'host ha interroto la connessione." +DISCONNECT_BIG_MOD = "Il server ha una mod troppo pesante.\nDisconnessione." +DIED = "@ è morto" +DEBUG_FLY = "@ è entrato nello stato di debug di volo libero" +IMPORT_MOD_SUCCESS = "\\#a0ffa0\\importata la mod\n\\#c8c8c8\\'@'" +IMPORT_DYNOS_SUCCESS = "\\#a0ffa0\\Importato il pacchetto DynOS\n\\#c8c8c8\\'@'" +IMPORT_FAIL = "\\#ffa0a0\\Impossibile importare\n\\#c8c8c8\\'@'" +IMPORT_FAIL_INGAME = "\\#ffa0a0\\Impossibile importare durante la partita" + +[CHAT] +KICKING = "Espulso '@'!" +BANNING = "Bandito '@'!" +SERVER_ONLY = "Solo il server può usare questo comando." +PERM_BANNING = "Bandito permanentemente '@'!" +ADD_MODERATOR = "Aggiunto '@' tra i Moderatori!" +PLAYERS = "Giocatori" +NO_PERMS = "Non hai il permesso di usare questo comando." +PLAYER_NOT_FOUND = "Impossibile trovare il giocatore." +SELF_KICK = "Non puoi espellere te stesso." +SELF_BAN = "Non puoi bandire te stesso." +SELF_MOD = "Non puoi renderti un moderatore." +KICK_CONFIRM = "Sei sicuro di voler espellere '@'?\nScrivi '\\#a0ffa0\\/confirm\\#fff982\\' per confermare." +BAN_CONFIRM = "Sei sicuro di voler bandire '@'?\nScrivi'\\#a0ffa0\\/confirm\\#fff982\\' per confermare." +PERM_BAN_CONFIRM = "Sei sicuro di voler bandire permanentemenrte '@'?\nScrivi '\\#a0ffa0\\/confirm\\#fff982\\' per confermare." +MOD_CONFIRM = "Sei sicuro di voler rendere '@' un moderatore?\nScrivi '\\#a0ffa0\\/confirm\\#fff982\\' per confermare." +PLAYERS_DESC = "/players - Lista dei giocatori e dei loro ID" +KICK_DESC = "/kick [NAME|ID] - Espelli questo giocatore dalla partita" +BAN_DESC = "/ban [NAME|ID] - Bandisci questo giocatore dalla partita" +PERM_BAN_DESC = "/permban [NAME|ID] - Bandisci questo giocatore da tutte le tue partite" +MOD_DESC = "/moderator [NAME|ID] - Dai al gicatore il permesso di eseguire comandi come /kick, /ban, /permban in ogni partita che crei" +UNRECOGNIZED = "Comando non riconosciuto." +MOD_GRANTED = "\\#fff982\\Ora sei un moderatore." + +[MENU] +BACK = "Indietro" +CANCEL = "Annulla" +NO = "No" +YES = "Si" + +[CAMERA] +CAMERA = "TELECAMERA" +FREE_CAMERA = "Telecamera libera" +ANALOG_CAMERA = "Telecamera analogica" +MOUSE_LOOK = "Telecamera con mouse" +INVERT_X = "Inverti X" +INVERT_Y = "Inverti Y" +X_SENSITIVITY = "Inverti asse X" +Y_SENSITIVITY = "Inverti asse Y" +AGGRESSION = "Aggressività" +PAN_LEVEL = "Livello di panoramica" +DECELERATION = "Decelerazione" + +[CHEATS] +CHEATS = "TRUCCHI" +MOON_JUMP = "Moon Jump" +GOD_MODE = "God Mode" +INFINITE_LIVES = "Vite infinite" +SUPER_SPEED = "Super Velocità" +RESPONSIVE_CONTROLS = "Controlli reattivi" +RAPID_FIRE = "Fuoco Rapido (A)" +BLJ_ANYWHERE = "BLJ Ovunque" +ALWAYS_TRIPLE_JUMP = "Sempre Salto triplo" + +[CONTROLS] +CONTROLS = "CONTROLLI" +N64_BINDS = "Comandi N64" +EXTRA_BINDS = "Comandi Extra" +BACKGROUND_GAMEPAD = "Azione in Background" +GAMEPAD = "Controller" +DEADZONE = "Zona Morta" +RUMBLE_STRENGTH = "Intesità Vibrazione" +CHAT = "Chat" +PLAYERS = "Giocatori" +D_UP = "D Su" +D_DOWN = "D Giù" +D_LEFT = "D Sinistra" +D_RIGHT = "D Destra" +X = "X" +Y = "Y" + +UP = "Su" +DOWN = "Giù" +LEFT = "Sinistra" +RIGHT = "Destra" +A = "A" +B = "B" +START = "Start" +L = "L" +R = "R" +Z = "Z" +C_UP = "C Su" +C_DOWN = "C Giù" +C_LEFT = "C Sinistra" +C_RIGHT = "C Destra" + +[DISPLAY] +DISPLAY = "GRAFICA" +FULLSCREEN = "Schermo intero" +PRELOAD_TEXTURES = "Precarica Textures" +VSYNC = "VSync" +UNCAPPED_FRAMERATE = "Fotogrammi Illimitati" +FRAME_LIMIT = "Limite Fotogrammi" +FAST = "Veloce" +ACCURATE = "Accurata" +INTERPOLATION = "Interpolazione" +NEAREST = "Vicino" +LINEAR = "Lineare" +TRIPOINT = "Tripunto" +FILTERING = "Filtraggio" +D0P5X = "0.5x" +D1X = "1x" +D1P5X = "1.5x" +D3X = "3x" +D10X = "10x" +D100X = "100x" +DRAW_DISTANCE = "Distanza di simulazione" +DYNOS_PACKS = "Pacchetti DynOS" + +[DYNOS] +DYNOS = "DYNOS" + +[HOST_MESSAGE] +INFO_TITLE = "INFO" +WARN_DISCORD = "Invita gli amici facendo tasto destro sul loro nome in Discord e cliccando\n'\\#d0d0ff\\Invito a giocare\\#c8c8c8\\'.\n\npuoi invitare anche i canali dei server cliccando il pulsante \\#d0d0ff\\più\\#c8c8c8\\ vicino al posto dove scrivi.\n\nLo Stato delle Attività \\#ffa0a0\\deve essere\\#c8c8c8\\ attivo nelle\nimpostazioni utente di Discord.\n\nApparire offline \\#ffa0a0\\ti impedirà\\#c8c8c8\\ di inviare inviti." +WARN_DISCORD2 = "\\#ffa0a0\\Errore:\\#c8c8c8\\ Impossibile individuare Discord.\n\n\\#a0a0a0\\prova a chiudre il gioco,\nriavviare Discord,\ne aprire di nuovo il gioco." +WARN_SOCKET = "La connessione diretta \\#ffa0a0\\richiede\\#c8c8c8\\ una configurazione port forwarding nel tuo router.\n\nTrasmetti una connessione '\\#d0d0ff\\%d\\#c8c8c8\\' per l'UDP." +HOST = "Crea" + +[HOST_MODS] +ROMHACKS = "ROMHACKS" +MODS = "MODS" + +[HOST_SAVE] +SAVE_TITLE = "SALVATAGGIO" +ERASE_TITLE = "CANCELLA" +CONFIRM = "Sei sicuro di voler cancellare questo slot di salvataggio?" +ERASE = "cancella" + +[HOST_SETTINGS] +SETTINGS = "OPZIONI" +NONSOLID = "Non-solida" +SOLID = "Solida" +FRIENDLY_FIRE = "Fuoco Amico" +PLAYER_INTERACTION = "Interazione tra Giocatori" +WEAK = "Debole" +NORMAL = "Normale" +TOO_MUCH = "Eccessiva" +KNOCKBACK_STRENGTH = "Forza di Contraccolpo" +LEAVE_LEVEL = "Lascia il livello" +STAY_IN_LEVEL = "Rimani nel livello" +NONSTOP = "Non-stop" +ON_STAR_COLLECTION = "A stella collezzionata" +SKIP_INTRO_CUTSCENE = "Salta la intro iniziale" +SHARE_LIVES = "Condividi le vite" +ENABLE_CHEATS = "Abilita i trucchi" +BUBBLE_ON_DEATH = "Bolla alla morte" +AMOUNT_OF_PLAYERS = "Numero di giocatori" + +[HOST] +SERVER_TITLE = "SERVER" +HOST_TITLE = "OSPITA" +DISCORD = "Discord" +DIRECT_CONNECTION = "Connessione diretta" +NETWORK_SYSTEM = "Sistema di connessione" +PORT = "Porta" +SAVE_SLOT = "Slot di Salvataggio" +SETTINGS = "Opzioni" +MODS = "Mods" +ROMHACKS = "Rom-Hacks" +APPLY = "Applica" +HOST = "Crea" + +[JOIN_MESSAGE] +JOINING = "CONNESSIONE" + +[JOIN] +JOIN_TITLE = "UNISCITI" +JOIN_DISCORD = "Per entrare in una partita da \\#d0d0ff\\Discord\\#c8c8c8\\:\n\nMantieni il gioco aperto e clicca sul pulsante Unisciti.\n\nSe l'invito dice che la partita è finita,/nclicca sul nome della persona che l'ha mandato per ripristinarla." +JOIN_SOCKET = "Immetti un \\#d0d0ff\\IP e una Porta\\#c8c8c8\\ per la connessione diretta:" +JOIN = "Unisciti" + +[MAIN] +QUIT_TITLE = "ABBANDONA" +QUIT_CONFIRM = "Sei sicuro do voler abbandonare?" +HOST = "Crea" +JOIN = "Unisciti" +OPTIONS = "Opzioni" +QUIT = "Abbandona" + +[MENU_OPTIONS] +MAIN_MENU = "MENÙ PRINCIPALE" +LEVEL = "Livello" +USE_STAGE_MUSIC = "Usa la musica del livello" +RANDOM_STAGE = "Livello casuale" +PLAY_VANILLA_DEMOS = "Riproduci le demo di gioco" + +[MISC] +DEBUG_TITLE = "DEBUG" +FIXED_COLLISIONS = "Collisioni Aggiustate" +LUA_PROFILER = "Profiler Lua" +DEBUG_PRINT = "Stampa di debug" +DEBUG_INFO = "Info di debug" +DEBUG_ERRORS = "Errori di debug" +MISC_TITLE = "VARIE" +PAUSE_IN_SINGLEPLAYER = "Metti in pausa in giocatore singolo" +DISABLE_POPUPS = "Disabilita Popups" +MENU_OPTIONS = "Opzioni Menù" +DEBUG = "Debug" +LANGUAGE = "Lingua" + +[MODLIST] +MODS = "MODS" + +[OPTIONS] +OPTIONS = "OPZIONI" +PLAYER = "Giocatore" +CAMERA = "Telecamera" +CONTROLS = "Comandi" +DISPLAY = "Grafica" +SOUND = "Suono" +MISC = "Varie" + +[PAUSE] +QUIT_TITLE = "ABBANDONA" +QUIT_HOST = "Sei sicuro di voler interrompere la connessione?" +QUIT_CLIENT = "Sei sicuro di volerti disconnettere?" +PAUSE_TITLE = "PAUSA" +PLAYER = "Giocatore" +DYNOS_PACKS = "Pacchetti DynOS" +OPTIONS = "Opzioni" +CHEATS = "Trucchi" +SERVER_SETTINGS = "Impostazioni Server" +RESUME = "Riprendi" +STOP_HOSTING = "Interrompi la connessione" +DISCONNECT = "Disconnettiti" + +[PLAYER] +PLAYER_TITLE = "GICATORE" +OVERALLS = "Tuta" +SHIRT = "Maglietta" +GLOVES = "Guanti" +SHOES = "Scarpe" +HAIR = "Capelli" +SKIN = "Pelle" +CAP = "Cappello" +PALETTE = "PALETTE" +PART = "Parte" +HEX_CODE = "codice Hex" +RED = "Rosso" +GREEN = "Verde" +BLUE = "Blu" +PLAYER = "Giocatore" +NAME = "Nome" +MODEL = "Modello" +PALETTE_PRESET = "Opzioni Palette" +EDIT_PALETTE = "Modifica Palette" + +[PALETTE] +MARIO = "Mario" +LUIGI = "Luigi" +WALUIGI = "Waluigi" +WARIO = "Wario" +CHUCKYA = "Chuckya" +GOOMBA = "Goomba" +CLOVER = "Trifoglio" +COBALT = "Cobalto" +FURY = "Furia" +HOT_PINK = "Rosa Caldo" +NICE_PINK = "Rosa Fresco" +SEAFOAM = "Schiuma Marina" +LILAC = "Lilla" +COPPER = "Rame" +AZURE = "Azurro" +BURGUNDY = "Borgogna" +MINT = "Menta" +EGGPLANT = "Melanzana" +ORANGE = "Arancia" +ARCTIC = "Arctico" +FIRE_MARIO = "Mario Fuoco" +FIRE_LUIGI = "Luigi Fuoco" +FIRE_WALUIGI = "Waluigi Fuoco" +FIRE_WARIO = "Wario Fuoco" +BUSY_BEE = "Ape Operaia" +FORTRESS = "Fortezza" +BATTLEMENTS = "Muraglia" +BLUEBERRY_PIE = "Torta ai Mirtilli" +RASPBERRY = "Mora" +BUBBLEGUM = "Gomma da Masticare" +ICE_MARIO = "Mario Ghiaccio" +ICE_LUIGI = "Luigi Ghiaccio" +CUSTOM = "Personalizzato" + +[PLAYER_LIST] +PLAYERS = "GIOCATORI" +NAME = "nome" +LOCATION = "posizione" +ACT = "atto" + +[SOUND] +SOUND = "SUONO" +MASTER_VOLUME = "Principale" +MUSIC_VOLUME = "Musica" +SFX_VOLUME = "Effetti sonori" +ENV_VOLUME = "Ambiente" + +[LANGUAGE] +LANGUAGE = "LINGUA" diff --git a/src/pc/discord/discord_activity.c b/src/pc/discord/discord_activity.c index 794035c4..78d04594 100644 --- a/src/pc/discord/discord_activity.c +++ b/src/pc/discord/discord_activity.c @@ -2,6 +2,7 @@ #include "pc/djui/djui.h" #include "pc/mods/mods.h" #include "pc/debuglog.h" +#include "pc/utils/misc.h" #include "pc/djui/djui_panel_join_message.h" #ifdef COOPNET #include "pc/network/coopnet/coopnet.h" @@ -64,28 +65,29 @@ static void strncat_len(char* destination, char* source, size_t destinationLengt strncat(destination, altered, destinationLength); } -static bool discord_populate_details(char* details, bool shorten) { - snprintf(details, 127, "%s", get_version()); +static void discord_populate_details(char* buffer, int bufferLength) { + // get version + char* version = get_version(); + int versionLength = strlen(version); + snprintf(buffer, bufferLength, "%s", version); + buffer += versionLength; + bufferLength -= versionLength; - bool displayDash = true; - bool displayComma = false; - size_t catLength = shorten ? 14 : 64; - - // add mods to activity - if (gActiveMods.entryCount > 0) { - for (int i = 0; i < gActiveMods.entryCount; i++) { - struct Mod* mod = gActiveMods.entries[i]; - if (displayDash) { strncat_len(details, " - ", 127, catLength); } - if (displayComma) { strncat_len(details, ", ", 127, catLength); } - - strncat_len(details, mod->name, 127, catLength); - - displayDash = false; - displayComma = true; - } + // get mod strings + if (gActiveMods.entryCount <= 0) { return; } + char* strings[gActiveMods.entryCount]; + for (int i = 0; i < gActiveMods.entryCount; i++) { + strings[i] = gActiveMods.entries[i]->name; } - return (strlen(details) >= 125); + // add seperator + snprintf(buffer, bufferLength, "%s", " - "); + buffer += 3; + bufferLength -= 3; + + + // concat mod strings + str_seperator_concat(buffer, bufferLength, strings, gActiveMods.entryCount, ", "); } void discord_activity_update(void) { @@ -113,13 +115,10 @@ void discord_activity_update(void) { if (sCurActivity.party.size.max_size < 1) { sCurActivity.party.size.max_size = 1; } } - char details[256] = { 0 }; - bool overrun = discord_populate_details(details, false); - if (overrun) { - discord_populate_details(details, true); - } + char details[128] = { 0 }; + discord_populate_details(details, 128); - if (snprintf(sCurActivity.details, 125, "%s", details) < 0) { + if (snprintf(sCurActivity.details, 128, "%s", details) < 0) { LOG_INFO("truncating details"); } diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index 246e5bc2..6567dfd6 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -531,3 +531,53 @@ void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx) { *mtx = *mtxPrev; } } + +void str_seperator_concat(char *output_buffer, int buffer_size, char** strings, int num_strings, char* seperator) { + // empty buffer + memset(output_buffer, 0, buffer_size); + if (num_strings <= 0) { return; } + + // Calculate the total length of all strings + int string_length[num_strings]; + int total_length = 0; + for (int i = 0; i < num_strings; i++) { + string_length[i] = strlen(strings[i]); + total_length += string_length[i]; + } + + // get the seperator length + int seperator_length = strlen(seperator); + int seperators_length = (num_strings - 1) * seperator_length; + if (seperators_length + 8 < buffer_size) { + // Shorten the largest string over and over until we fit + while (total_length + seperators_length >= buffer_size) { + int* largest = NULL; + for (int i = 0; i < num_strings; i++) { + if (largest == NULL || string_length[i] >= *largest) { + largest = &string_length[i]; + } + } + if (largest == NULL || *largest == 0) { break; } + *largest = *largest - 1; + total_length--; + } + } + + // Fill the buffer + int buffer_index = 0; + for (int i = 0; i < num_strings; i++) { + // Concat string + int amount = MIN(buffer_size - buffer_index, string_length[i] + 1); + if (amount <= 0) { break; } + snprintf(&output_buffer[buffer_index], amount, "%s", strings[i]); + buffer_index += string_length[i]; + + // Concat seperator + if (i != (num_strings - 1)) { + int amount = MIN(buffer_size - buffer_index, seperator_length + 1); + if (amount <= 0) { break; } + snprintf(&output_buffer[buffer_index], amount, "%s", seperator); + buffer_index += seperator_length; + } + } +} diff --git a/src/pc/utils/misc.h b/src/pc/utils/misc.h index 1c65bba3..26f7e706 100644 --- a/src/pc/utils/misc.h +++ b/src/pc/utils/misc.h @@ -23,4 +23,6 @@ void delta_interpolate_rgba(u8* res, u8* a, u8* b, f32 delta); void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta); void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx); +void str_seperator_concat(char *output_buffer, int buffer_size, char** strings, int num_strings, char* seperator); + #endif \ No newline at end of file