Add "Open User Folder" button (AppData on Windows)

This commit is contained in:
Agent X 2023-12-17 09:04:01 -05:00
parent ec4b547d1d
commit 2d36bfdc99
13 changed files with 52 additions and 4 deletions

View File

@ -276,6 +276,8 @@ CONTROLS = "Ovládání"
DISPLAY = "Video"
SOUND = "Zvuk"
MISC = "Jiné"
USER_FOLDER = "Otevřít uživatelský adresář"
APPDATA = "Otevřít AppData"
[PAUSE]
QUIT_TITLE = "ODPOJIT SE"

View File

@ -276,6 +276,8 @@ CONTROLS = "Controles"
DISPLAY = "Weergave"
SOUND = "Geluid"
MISC = "Misc"
USER_FOLDER = "Gebruikersmap openen"
APPDATA = "Open AppData"
[PAUSE]
QUIT_TITLE = "STOPPEN"

View File

@ -191,9 +191,9 @@ SHARE_LIVES = "Share lives"
ENABLE_CHEATS = "Enable cheats"
BUBBLE_ON_DEATH = "Bubble on death"
NAMETAGS = "Nametags \\#ffff00\\(NEW!)"
BOUNCY_BOUNDS_ON_CAP = "On (Capped)"
BOUNCY_BOUNDS_ON = "On"
BOUNCY_BOUNDS_OFF = "Off"
BOUNCY_BOUNDS_ON_CAP = "ON (Capped)"
BOUNCY_BOUNDS_ON = "ON"
BOUNCY_BOUNDS_OFF = "OFF"
BOUNCY_LEVEL_BOUNDS = "Bouncy Level Bounds \\#ffff00\\(NEW!)"
AMOUNT_OF_PLAYERS = "Amount of players"
@ -276,6 +276,8 @@ CONTROLS = "Controls"
DISPLAY = "Display"
SOUND = "Sound"
MISC = "Misc"
USER_FOLDER = "Open User Folder"
APPDATA = "Open AppData"
[PAUSE]
QUIT_TITLE = "QUIT"

View File

@ -276,6 +276,8 @@ CONTROLS = "Contrôles"
DISPLAY = "Affichage"
SOUND = "Audio"
MISC = "Autres Paramètres"
USER_FOLDER = "Ouvrir le dossier utilisateur"
APPDATA = "Ouvrir AppData"
[PAUSE]
QUIT_TITLE = "QUITTER"

View File

@ -276,6 +276,8 @@ CONTROLS = "Steuerung"
DISPLAY = "Anzeige"
SOUND = "Sound"
MISC = "Sonstiges"
USER_FOLDER = "Benutzerordner öffnen"
APPDATA = "AppData öffnen"
[PAUSE]
QUIT_TITLE = "BEENDEN"

View File

@ -274,6 +274,8 @@ CONTROLS = "Comandi"
DISPLAY = "Grafica"
SOUND = "Suono"
MISC = "Varie"
USER_FOLDER = "Apri cartella utente"
APPDATA = "Apri AppData"
[PAUSE]
QUIT_TITLE = "ABBANDONA"

View File

@ -276,6 +276,8 @@ CONTROLS = "Sterowanie"
DISPLAY = "Wyswietlanie"
SOUND = "Dzwiek"
MISC = "Rozne"
USER_FOLDER = "Otwórz folder użytkownika"
APPDATA = "Otwórz AppData"
[PAUSE]
QUIT_TITLE = "WYJSCIE"

View File

@ -276,6 +276,8 @@ CONTROLS = "Controles"
DISPLAY = "Vídeo"
SOUND = "Som"
MISC = "Outros"
USER_FOLDER = "Abrir pasta do usuário"
APPDATA = "Abrir AppData"
[PAUSE]
QUIT_TITLE = "SAIR"

View File

@ -275,6 +275,8 @@ CONTROLS = "Управление"
DISPLAY = "Дисплей"
SOUND = "Звук"
MISC = "Разное"
USER_FOLDER = "Открыть папку пользователя"
APPDATA = "Открыть AppData"
[PAUSE]
QUIT_TITLE = "QUIT"

View File

@ -276,6 +276,8 @@ CONTROLS = "Controles"
DISPLAY = "Pantalla"
SOUND = "Sonido"
MISC = "Otros"
USER_FOLDER = "Abrir carpeta de usuario"
APPDATA = "Abrir AppData"
[PAUSE]
QUIT_TITLE = "SALIR"

View File

@ -276,6 +276,8 @@ CONTROLS = "Controles"
DISPLAY = "Pantalla"
SOUND = "Sonido"
MISC = "Otros"
USER_FOLDER = "Abrir carpeta de usuario"
APPDATA = "Abrir AppData"
[PAUSE]
QUIT_TITLE = "SALIR"

View File

@ -12,6 +12,27 @@
#include "pc/utils/misc.h"
#include "pc/pc_main.h"
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif
void djui_panel_options_open_user_folder(UNUSED struct DjuiBase* caller) {
#if defined(_WIN32) || defined(_WIN64)
// Windows
ShellExecuteA(NULL, "open", sys_user_path(), NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
// Linux
char command[512];
snprintf(command, sizeof(command), "xdg-open %s", sys_user_path());
system(command);
#elif __APPLE__
// macOS
char command[512];
snprintf(command, sizeof(command), "open %s", sys_user_path());
system(command);
#endif
}
void djui_panel_options_back(struct DjuiBase* caller) {
configfile_save(configfile_name());
djui_panel_menu_back(caller);
@ -33,6 +54,11 @@ void djui_panel_options_create(struct DjuiBase* caller) {
djui_button_create(body, DLANG(OPTIONS, DISPLAY), DJUI_BUTTON_STYLE_NORMAL, djui_panel_display_create);
djui_button_create(body, DLANG(OPTIONS, SOUND), DJUI_BUTTON_STYLE_NORMAL, djui_panel_sound_create);
djui_button_create(body, DLANG(OPTIONS, MISC), DJUI_BUTTON_STYLE_NORMAL, djui_panel_misc_create);
#if defined(_WIN32) || defined(_WIN64)
djui_button_create(body, DLANG(OPTIONS, APPDATA), DJUI_BUTTON_STYLE_NORMAL, djui_panel_options_open_user_folder);
#elif __linux__ || __APPLE__ || __MACH__
djui_button_create(body, DLANG(OPTIONS, USER_FOLDER), DJUI_BUTTON_STYLE_NORMAL, djui_panel_options_open_user_folder);
#endif
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_options_back);
}

View File

@ -626,7 +626,7 @@ const char* get_os_name(void) {
#if defined(_WIN32) || defined(_WIN64)
return "Windows";
#elif __APPLE__ || __MACH__
return "Mac OSX";
return "Mac OSX"; // should be macOS
#elif __linux__
return "Linux";
#elif __FreeBSD__