diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 409cd8427..811f60508 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -68,6 +68,7 @@ exclude_constants = { "src/pc/lua/smlua_hooks.h": [ "MAX_HOOKED_MOD_MENU_ELEMENTS", "^HOOK_RETURN_.*", "^ACTION_HOOK_.*", "^MOD_MENU_ELEMENT_.*" ], "src/pc/djui/djui_panel_menu.h": [ "RAINBOW_TEXT_LEN" ], "src/pc/mods/mod_fs.h": [ "INT_TYPE_MAX", "FLOAT_TYPE_MAX", "FILE_SEEK_MAX" ], + "src/pc/network/version.h": [ "VERSION_OFFSET" ], } include_constants = { diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 1d7dfb2dc..ef30bc29f 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -11275,7 +11275,7 @@ VERSION_TEXT = "v" VERSION_NUMBER = 41 --- @type integer -MINOR_VERSION_NUMBER = 1 +MINOR_VERSION_NUMBER = 2 --- @type string GAME_NAME = "sm64coopdx" diff --git a/lang/Czech.ini b/lang/Czech.ini index 81a2e89a3..bb30bc403 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Nastavení hlavního menu" INFORMATION = "Informace" DEBUG = "Debug" LANGUAGE = "Jazyk" -COOP_COMPATIBILITY = "Povolit kompatibilitu sm64ex-coop" R_BUTTON = "Tlačítko R - Možnosti" L_BUTTON = "Tlačítko L - Znovu načíst aktivní mody" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index c4e32f77c..3f9717ab7 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Menu Instellingen" INFORMATION = "Informatie" DEBUG = "Debug" LANGUAGE = "Taal" -COOP_COMPATIBILITY = "Schakel sm64ex-coop compatibiliteit in" R_BUTTON = "R-knop - Opties" L_BUTTON = "L-knop - Actieve mods opnieuw laden" diff --git a/lang/English.ini b/lang/English.ini index 0560d9ac2..c1c68326e 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Menu Options" INFORMATION = "Info" DEBUG = "Debug" LANGUAGE = "Language" -COOP_COMPATIBILITY = "Enable sm64ex-coop Compatibility" R_BUTTON = "R Button - Options" L_BUTTON = "L Button - Reload Active Mods" diff --git a/lang/French.ini b/lang/French.ini index 645ed0c2a..575977cab 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Options du menu" INFORMATION = "Information" DEBUG = "Débogage" LANGUAGE = "Langue" -COOP_COMPATIBILITY = "Activer la compatibilité sm64ex-coop" R_BUTTON = "Bouton R - Options" L_BUTTON = "Bouton L - Recharger les mods actifs" diff --git a/lang/German.ini b/lang/German.ini index 1fb8031d7..1ddb4203e 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Menüoptionen" INFORMATION = "Info" DEBUG = "Debug" LANGUAGE = "Sprache" -COOP_COMPATIBILITY = "Aktiviere sm64ex-coop Kompatibilität" R_BUTTON = "R-Taste - Optionen" L_BUTTON = "L-Taste - Aktive Mods neu laden" diff --git a/lang/Italian.ini b/lang/Italian.ini index dfe13d3bb..e62fbf042 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -323,7 +323,6 @@ MENU_OPTIONS = "Opzioni Menù" INFORMATION = "Informazione" DEBUG = "Debug" LANGUAGE = "Lingua" -COOP_COMPATIBILITY = "Abilita la compatibilità con sm64ex-coop" R_BUTTON = "Pulsante R - Opzioni" L_BUTTON = "Pulsante L - Ricarica Mod Attive" diff --git a/lang/Japanese.ini b/lang/Japanese.ini index 05b20a216..d6b5ece33 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "メニューの設定" INFORMATION = "情報" DEBUG = "デバッグ" LANGUAGE = "言語" -COOP_COMPATIBILITY = "sm64ex-coopとの互換性を有効にする" R_BUTTON = "Rボタン - 設定" L_BUTTON = "Lボタン - 有効化されたMODを再読み込み" diff --git a/lang/Polish.ini b/lang/Polish.ini index cb983027d..8d1685658 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Opcje Menu" INFORMATION = "Informacja" DEBUG = "Debugowanie" LANGUAGE = "Język" -COOP_COMPATIBILITY = "Włącz kompatybilność z sm64ex-coop" R_BUTTON = "Przycisk R - Opcje" L_BUTTON = "Przycisk L - Przeładuj aktywne mody" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index d3b9e0c6b..e500fa1db 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Opções de menu" INFORMATION = "Informações" DEBUG = "Debug" LANGUAGE = "Idioma" -COOP_COMPATIBILITY = "Ativar a compatibilidade com sm64ex-coop" R_BUTTON = "Botão R - Opções" L_BUTTON = "Botão L - Recarregar mods ativos" diff --git a/lang/Russian.ini b/lang/Russian.ini index 85d39ae37..6039271d5 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -324,7 +324,6 @@ MENU_OPTIONS = "Параметры меню" INFORMATION = "Информация" DEBUG = "Отладка" LANGUAGE = "Язык" -COOP_COMPATIBILITY = "Включить совместимость sm64ex-coop" R_BUTTON = "Кнопка R - Опции" L_BUTTON = "Кнопка L - Перезагрузить активные моды" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 50660a637..b869e4d93 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -325,7 +325,6 @@ MENU_OPTIONS = "Opciones del menú" INFORMATION = "Información" DEBUG = "Depuración" LANGUAGE = "Idioma" -COOP_COMPATIBILITY = "Habilitar la compatibilidad con sm64ex-coop" R_BUTTON = "Botón R - Opciones" L_BUTTON = "Botón L - Recargar mods activos" diff --git a/res/icon.rc b/res/icon.rc index 7e84e50bf..c4ad9f1fe 100644 --- a/res/icon.rc +++ b/res/icon.rc @@ -1 +1,27 @@ -id ICON res/icon.ico \ No newline at end of file +id ICON res/icon.ico + +#include +#include "../src/pc/network/version.h" +VS_VERSION_INFO VERSIONINFO +FILEVERSION 1,(VERSION_NUMBER-VERSION_OFFSET),MINOR_VERSION_NUMBER,0 +PRODUCTVERSION VERSION_NUMBER,MINOR_VERSION_NUMBER,0,0 +FILEOS VOS_NT +FILETYPE VFT_APP +{ + BLOCK StringFileInfo + { + BLOCK "040904B0" + { + VALUE "FileDescription", "Super Mario 64 Coop Deluxe" + VALUE "FileVersion", SM64COOPDX_VERSION + VALUE "ProductName", "Super Mario 64 Coop Deluxe" + VALUE "ProductVersion", SM64COOPDX_VERSION + VALUE "InternalName", "sm64coopdx.exe" + VALUE "OriginalFilename", "sm64coopdx.exe" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 0x04B0 + } +} \ No newline at end of file diff --git a/src/pc/djui/djui_panel_main.c b/src/pc/djui/djui_panel_main.c index 57707045c..0a849bb51 100644 --- a/src/pc/djui/djui_panel_main.c +++ b/src/pc/djui/djui_panel_main.c @@ -61,15 +61,18 @@ void djui_panel_main_create(struct DjuiBase* caller) { djui_base_set_color(&message->base, 255, 255, 160, 255); djui_text_set_alignment(message, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM); } else { - #ifdef COMPILE_TIME - struct DjuiText* version = djui_text_create(&panel->base, get_version_with_build_date()); - #else - struct DjuiText* version = djui_text_create(&panel->base, get_version()); - #endif + struct DjuiText* version = djui_text_create( + &panel->base, + #ifdef COMPILE_TIME + get_version_with_build_date() + #else + get_version() + #endif + ); djui_base_set_size_type(&version->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&version->base, 1.0f, 1.0f); djui_base_set_color(&version->base, 50, 50, 50, 255); - djui_text_set_alignment(version, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM); + djui_text_set_alignment(version, configExCoopTheme ? DJUI_HALIGN_CENTER : DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM); } } diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index de7da771c..1c36adfca 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -4690,7 +4690,7 @@ char gSmluaConstants[] = "" "SM64COOPDX_VERSION='v1.4.2'\n" "VERSION_TEXT='v'\n" "VERSION_NUMBER=41\n" -"MINOR_VERSION_NUMBER=1\n" +"MINOR_VERSION_NUMBER=2\n" "GAME_NAME='sm64coopdx'\n" "WINDOW_NAME='Super Mario 64 Coop Deluxe'\n" "MAX_VERSION_LENGTH=128\n" diff --git a/src/pc/network/version.c b/src/pc/network/version.c index fd792dc0a..97cd04580 100644 --- a/src/pc/network/version.c +++ b/src/pc/network/version.c @@ -5,21 +5,27 @@ static char sVersionString[MAX_VERSION_LENGTH] = { 0 }; const char* get_version(void) { + snprintf( + sVersionString, MAX_VERSION_LENGTH, #if defined(VERSION_US) - snprintf(sVersionString, MAX_VERSION_LENGTH, "%s", SM64COOPDX_VERSION); + "%s", SM64COOPDX_VERSION #else - snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %s", SM64COOPDX_VERSION, VERSION_REGION); + "%s %s", SM64COOPDX_VERSION, VERSION_REGION #endif // VERSION_US + ); return sVersionString; } #ifdef COMPILE_TIME const char* get_version_with_build_date(void) { + snprintf( + sVersionString, MAX_VERSION_LENGTH, #if defined(VERSION_US) - snprintf(sVersionString, MAX_VERSION_LENGTH, "%s, %s", SM64COOPDX_VERSION, COMPILE_TIME); + "%s, %s", SM64COOPDX_VERSION, COMPILE_TIME #else - snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %s, %s", SM64COOPDX_VERSION, VERSION_REGION, COMPILE_TIME); + "%s %s, %s", SM64COOPDX_VERSION, VERSION_REGION, COMPILE_TIME #endif // VERSION_US + ); return sVersionString; } #endif \ No newline at end of file diff --git a/src/pc/network/version.h b/src/pc/network/version.h index 9bda5050c..1ed77ffae 100644 --- a/src/pc/network/version.h +++ b/src/pc/network/version.h @@ -6,7 +6,9 @@ // internal version #define VERSION_TEXT "v" #define VERSION_NUMBER 41 -#define MINOR_VERSION_NUMBER 1 +#define MINOR_VERSION_NUMBER 2 + +#define VERSION_OFFSET 37 // difference from old versioning system #if defined(VERSION_JP) #define VERSION_REGION "JP" diff --git a/src/pc/update_checker.c b/src/pc/update_checker.c index 77d21abb5..e060f6203 100644 --- a/src/pc/update_checker.c +++ b/src/pc/update_checker.c @@ -23,7 +23,20 @@ downloading and parsing a source file. */ static char sVersionUpdateTextBuffer[256] = { 0 }; -static char sRemoteVersion[8] = { 0 }; +static char sRemoteVersionStr[8] = { 0 }; + +struct Version { + int maj, min, fix; +}; + +bool is_version_newer(struct Version client, struct Version remote) { + if (remote.maj != client.maj) return remote.maj > client.maj; + if (remote.min != client.min) return remote.min > client.min; + return remote.fix > client.fix; +} + +static struct Version sClientVersion = { 0 }; +static struct Version sRemoteVersion = { 0 }; bool gUpdateMessage = false; @@ -51,6 +64,27 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { } #endif +void string_to_version(const char *str, struct Version *ver) { + char* end; + ver->maj = strtol(str+1, &end, 10); + ver->min = 0; ver->fix = 0; + if (end) ver->min = strtol(end+1, &end, 10); + if (end) ver->fix = strtol(end+1, &end, 10); +} + +void version_to_string(struct Version ver, char* str, size_t size) { + int len; + snprintf(str, size, "v%i", ver.maj); + if (ver.min || ver.fix) { + len = strlen(str); + snprintf(str + len, size - len, ".%i", ver.min); + if (ver.fix) { + len = strlen(str); + snprintf(str + len, size - len, ".%i", ver.fix); + } + } +} + void parse_version(const char *data) { const char *version = strstr(data, VERSION_IDENTIFIER); if (version == NULL) { return; } @@ -58,14 +92,17 @@ void parse_version(const char *data) { version += len; const char *end = strchr(version, '"'); size_t versionLength = (size_t)(end - version); - if (versionLength > sizeof(sRemoteVersion) - 1) { return; } - memcpy(sRemoteVersion, version, versionLength); - sRemoteVersion[versionLength] = '\0'; + if (versionLength > sizeof(sRemoteVersionStr) - 1) { return; } + memcpy(sRemoteVersionStr, version, versionLength); + sRemoteVersionStr[versionLength] = '\0'; + + string_to_version(sRemoteVersionStr, &sRemoteVersion); + string_to_version(get_version(), &sClientVersion); } // function to download a text file from the internet void get_version_remote(void) { - sRemoteVersion[0] = '\0'; + sRemoteVersionStr[0] = '\0'; #if defined(_WIN32) || defined(_WIN64) char buffer[0xFF] = { 0 }; @@ -145,13 +182,13 @@ void check_for_updates(void) { LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates")); get_version_remote(); - if (sRemoteVersion[0] == 'v' && strcmp(sRemoteVersion, get_version())) { + if (sRemoteVersionStr[0] == 'v' && is_version_newer(sClientVersion, sRemoteVersion)) { snprintf( sVersionUpdateTextBuffer, 256, "\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s", DLANG(NOTIF, UPDATE_AVAILABLE), DLANG(NOTIF, LATEST_VERSION), - sRemoteVersion, + sRemoteVersionStr, DLANG(NOTIF, YOUR_VERSION), get_version() );