Make user folder sm64coopdx instead of sm64ex-coop, add auto folder copy

This commit is contained in:
Agent X 2024-05-12 14:04:12 -04:00
parent 6995b1a07c
commit 12aff40090
19 changed files with 68 additions and 5 deletions

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "host lobby"
UPDATE_AVAILABLE = "Nová aktualizace!"
LATEST_VERSION = "Nejnovější verze"
YOUR_VERSION = "Vaše verze"
USER_FOLDER_COPIED = "\\#a0ffa0\\Úspěch!\n\\#dcdcdc\\Složka uživatele sm64ex-coop byla zkopírována do nové složky sm64coopdx."
[CHAT]
KICKING = "Vyhazování '@'!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "De Lobby's organisator."
UPDATE_AVAILABLE = "Nieuwe update!"
LATEST_VERSION = "Laatste versie"
YOUR_VERSION = "Uw versie"
USER_FOLDER_COPIED = "\\#a0ffa0\\Succes!\n\\#dcdcdc\\De gebruikersmap van sm64ex-coop is gekopieerd naar de nieuwe sm64coopdx."
[CHAT]
KICKING = "'@' eruit schoppen!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "the lobby's host"
UPDATE_AVAILABLE = "A new update is available!"
LATEST_VERSION = "Latest version"
YOUR_VERSION = "Your version"
USER_FOLDER_COPIED = "\\#a0ffa0\\Success!\n\\#dcdcdc\\The sm64ex-coop user folder has been copied over to the new sm64coopdx one."
[CHAT]
KICKING = "Kicking '@'!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "l'hôte de la partie"
UPDATE_AVAILABLE = "Nouvelle mise à jour !"
LATEST_VERSION = "Dernière version"
YOUR_VERSION = "Votre version"
USER_FOLDER_COPIED = "\\#a0ffa0\\Succès !\n\\#dcdcdc\\Le dossier utilisateur sm64ex-coop a été copié dans le nouveau sm64coopdx."
[CHAT]
KICKING = "Vous avez expulsé '@' !"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "Lobby-Hoster"
UPDATE_AVAILABLE = "Neues Update!"
LATEST_VERSION = "Aktuellste Version"
YOUR_VERSION = "Ihre Version"
USER_FOLDER_COPIED = "\\#a0ffa0\\Erfolg!\n\\#dcdcdc\\Der Benutzerordner sm64ex-coop wurde in den neuen sm64coopdx kopiert."
[CHAT]
KICKING = "'@' wird hinausgeworfen!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "the lobby's host"
UPDATE_AVAILABLE = "Nuovo aggiornamento!"
LATEST_VERSION = "Ultima versione"
YOUR_VERSION = "La tua versione"
USER_FOLDER_COPIED = "\\#a0ffa0\\Successo!\n\\#dcdcdc\\La cartella utente sm64ex-coop è stata copiata nella nuova sm64coopdx."
[CHAT]
KICKING = "Espulso '@'!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "Host lobby"
UPDATE_AVAILABLE = "Nowa aktualizacja!"
LATEST_VERSION = "Najnowsza wersja"
YOUR_VERSION = "Twoja wersja"
USER_FOLDER_COPIED = "\\#a0ffa0\\Sukces!\n\\#dcdcdc\\Folder użytkownika sm64ex-coop został skopiowany do nowego sm64coopdx."
[CHAT]
KICKING = "Wyrzucanie gracza '@'!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "o criador da partida"
UPDATE_AVAILABLE = "Nova atualização!"
LATEST_VERSION = "Versão mais recente"
YOUR_VERSION = "Sua versão"
USER_FOLDER_COPIED = "\\#a0ffa0\\Sucesso!\n\\#dcdcdc\\A pasta de usuário sm64ex-coop foi copiada para a nova sm64coopdx."
[CHAT]
KICKING = "'@' foi expulso!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "Создать группу"
UPDATE_AVAILABLE = "Новое обновление!"
LATEST_VERSION = "Последняя версия"
YOUR_VERSION = "Ваша версия"
USER_FOLDER_COPIED = "\\#a0ffa0\\Успех!\n\\#dcdcdc\\Папка пользователя sm64ex-coop была скопирована в новую sm64coopdx."
[CHAT]
KICKING = "'@' выгнан!"

View file

@ -31,6 +31,7 @@ LOBBY_HOST = "la partida del anfitrión"
UPDATE_AVAILABLE = "¡Nueva actualización!"
LATEST_VERSION = "Última versión"
YOUR_VERSION = "Su versión"
USER_FOLDER_COPIED = "\\#a0ffa0\\¡Éxito!\n\\#dcdcdc\\La carpeta de usuario sm64ex-coop ha sido copiada a la nueva sm64coopdx."
[CHAT]
KICKING = "¡'@' ha sido expulsado!"

View file

@ -15,6 +15,7 @@
#include "djui_hud_utils.h"
#include "engine/math_util.h"
#include "pc/utils/misc.h"
#include "pc/startup.h"
static Gfx* sSavedDisplayListHead = NULL;
@ -109,6 +110,10 @@ void djui_init_late(void) {
// djui_panel_debug_create();
djui_cursor_create();
if (gUserFolderCopied) {
djui_popup_create(DLANG(NOTIF, USER_FOLDER_COPIED), 4);
}
}
void djui_connect_menu_open(void) {

View file

@ -42,7 +42,7 @@
#include "pc/controller/controller_bind_mapping.h"
#include "pc/utils/misc.h"
#include "pc/mods/mod_import.h"
#include "pc/rom_checker.h"
#include "pc/startup.h"
#ifndef GL_MAX_SAMPLES
#define GL_MAX_SAMPLES 0x8D57

View file

@ -5,7 +5,7 @@
#include "loading.h"
#include "pc/utils/misc.h"
#include "pc/cliopts.h"
#include "rom_checker.h"
#include "startup.h"
extern ALIGNED8 u8 texture_coopdx_logo[];

View file

@ -19,7 +19,7 @@
#include "audio/audio_null.h"
#include "rom_assets.h"
#include "rom_checker.h"
#include "startup.h"
#include "pc_main.h"
#include "loading.h"
#include "cliopts.h"
@ -373,6 +373,8 @@ int main(int argc, char *argv[]) {
#endif
old_user_folder_handler();
const char *userpath = gCLIOpts.savePath[0] ? gCLIOpts.savePath : sys_user_path();
fs_init(userpath);
configfile_load();

View file

@ -84,6 +84,28 @@ void sys_fatal(const char *fmt, ...) {
const char *sys_user_path(void) {
static char path[SYS_MAX_PATH] = { 0 };
// get the new pref path from SDL
char *sdlpath = SDL_GetPrefPath("", "sm64coopdx");
if (sdlpath) {
const unsigned int len = strlen(sdlpath);
strncpy(path, sdlpath, sizeof(path));
path[sizeof(path)-1] = 0;
SDL_free(sdlpath);
if (path[len-1] == '/' || path[len-1] == '\\')
path[len-1] = 0; // strip the trailing separator
if (!fs_sys_dir_exists(path) && !fs_sys_mkdir(path))
path[0] = 0; // somehow failed, we got no user path
}
return path;
}
const char *sys_old_user_path(void) {
static char path[SYS_MAX_PATH] = { 0 };
// get the new pref path from SDL
char *sdlpath = SDL_GetPrefPath("", "sm64ex-coop");
if (sdlpath) {
@ -135,6 +157,10 @@ const char *sys_user_path(void) {
return ".";
}
const char *sys_old_user_path(void) {
return ".";
}
const char *sys_exe_path(void) {
return ".";
}

View file

@ -16,6 +16,7 @@ int sys_strcasecmp(const char *s1, const char *s2);
// path stuff
const char *sys_user_path(void);
const char *sys_old_user_path(void);
const char *sys_exe_path(void);
const char *sys_file_extension(const char *fpath);
const char *sys_file_name(const char *fpath);

View file

@ -1,7 +1,7 @@
#include <PR/ultratypes.h>
#include "rom_assets.h"
#include "pc/debuglog.h"
#include "rom_checker.h"
#include "startup.h"
struct RomAsset {
void* ptr;

View file

@ -7,10 +7,12 @@ extern "C" {
#include "platform.h"
#include "mods/mods_utils.h" // for str_ends_with
#include "mods/mod_cache.h" // for md5 hashing
#include "loading.h"
}
#include "loading.h"
namespace fs = std::filesystem;
bool gUserFolderCopied = false;
bool gRomIsValid = false;
char gRomFilename[255] = "";
@ -28,6 +30,16 @@ static struct VanillaMD5 sVanillaMD5[] = {
{ NULL, NULL },
};
static void copy_old_user_folder() {
char* oldpath = (char*)sys_old_user_path();
char* newpath = (char*)sys_user_path();
if (fs::exists(oldpath) && (fs::is_empty(newpath) || !fs::exists(newpath))) {
fs::copy(oldpath, newpath);
gUserFolderCopied = true;
}
}
static bool is_rom_valid(const std::string romPath) {
u8 dataHash[16] = { 0 };
mod_cache_md5(romPath.c_str(), dataHash);
@ -71,6 +83,10 @@ inline static bool scan_path_for_rom(const char *dir) {
}
extern "C" {
void old_user_folder_handler(void) {
copy_old_user_folder();
}
bool main_rom_handler(void) {
if (scan_path_for_rom(sys_user_path())) { return true; }
scan_path_for_rom(sys_exe_path());

View file

@ -1,7 +1,10 @@
#include "types.h"
extern bool gUserFolderCopied;
extern bool gRomIsValid;
extern char gRomFilename[];
void old_user_folder_handler(void);
bool main_rom_handler(void);
void rom_on_drop_file(const char *path);