mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-10 19:01:46 +00:00
Add version info (Windows) + Smart update checker (#1069)
* Add version info (Windows) + Smart update checker * patch autogen, remove prints * Fix special case (min=0,fix=!0) * Not that obvious!! * Still too obvious... last one * the djoslin0 review * Nuked
This commit is contained in:
parent
0d95dfde11
commit
d973faffed
17 changed files with 93 additions and 29 deletions
|
|
@ -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/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/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/mods/mod_fs.h": [ "INT_TYPE_MAX", "FLOAT_TYPE_MAX", "FILE_SEEK_MAX" ],
|
||||||
|
"src/pc/network/version.h": [ "VERSION_OFFSET" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
include_constants = {
|
include_constants = {
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Nastavení hlavního menu"
|
||||||
INFORMATION = "Informace"
|
INFORMATION = "Informace"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Jazyk"
|
LANGUAGE = "Jazyk"
|
||||||
COOP_COMPATIBILITY = "Povolit kompatibilitu sm64ex-coop"
|
|
||||||
R_BUTTON = "Tlačítko R - Možnosti"
|
R_BUTTON = "Tlačítko R - Možnosti"
|
||||||
L_BUTTON = "Tlačítko L - Znovu načíst aktivní mody"
|
L_BUTTON = "Tlačítko L - Znovu načíst aktivní mody"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Menu Instellingen"
|
||||||
INFORMATION = "Informatie"
|
INFORMATION = "Informatie"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Taal"
|
LANGUAGE = "Taal"
|
||||||
COOP_COMPATIBILITY = "Schakel sm64ex-coop compatibiliteit in"
|
|
||||||
R_BUTTON = "R-knop - Opties"
|
R_BUTTON = "R-knop - Opties"
|
||||||
L_BUTTON = "L-knop - Actieve mods opnieuw laden"
|
L_BUTTON = "L-knop - Actieve mods opnieuw laden"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Menu Options"
|
||||||
INFORMATION = "Info"
|
INFORMATION = "Info"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Language"
|
LANGUAGE = "Language"
|
||||||
COOP_COMPATIBILITY = "Enable sm64ex-coop Compatibility"
|
|
||||||
R_BUTTON = "R Button - Options"
|
R_BUTTON = "R Button - Options"
|
||||||
L_BUTTON = "L Button - Reload Active Mods"
|
L_BUTTON = "L Button - Reload Active Mods"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Options du menu"
|
||||||
INFORMATION = "Information"
|
INFORMATION = "Information"
|
||||||
DEBUG = "Débogage"
|
DEBUG = "Débogage"
|
||||||
LANGUAGE = "Langue"
|
LANGUAGE = "Langue"
|
||||||
COOP_COMPATIBILITY = "Activer la compatibilité sm64ex-coop"
|
|
||||||
R_BUTTON = "Bouton R - Options"
|
R_BUTTON = "Bouton R - Options"
|
||||||
L_BUTTON = "Bouton L - Recharger les mods actifs"
|
L_BUTTON = "Bouton L - Recharger les mods actifs"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Menüoptionen"
|
||||||
INFORMATION = "Info"
|
INFORMATION = "Info"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Sprache"
|
LANGUAGE = "Sprache"
|
||||||
COOP_COMPATIBILITY = "Aktiviere sm64ex-coop Kompatibilität"
|
|
||||||
R_BUTTON = "R-Taste - Optionen"
|
R_BUTTON = "R-Taste - Optionen"
|
||||||
L_BUTTON = "L-Taste - Aktive Mods neu laden"
|
L_BUTTON = "L-Taste - Aktive Mods neu laden"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,6 @@ MENU_OPTIONS = "Opzioni Menù"
|
||||||
INFORMATION = "Informazione"
|
INFORMATION = "Informazione"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Lingua"
|
LANGUAGE = "Lingua"
|
||||||
COOP_COMPATIBILITY = "Abilita la compatibilità con sm64ex-coop"
|
|
||||||
R_BUTTON = "Pulsante R - Opzioni"
|
R_BUTTON = "Pulsante R - Opzioni"
|
||||||
L_BUTTON = "Pulsante L - Ricarica Mod Attive"
|
L_BUTTON = "Pulsante L - Ricarica Mod Attive"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "メニューの設定"
|
||||||
INFORMATION = "情報"
|
INFORMATION = "情報"
|
||||||
DEBUG = "デバッグ"
|
DEBUG = "デバッグ"
|
||||||
LANGUAGE = "言語"
|
LANGUAGE = "言語"
|
||||||
COOP_COMPATIBILITY = "sm64ex-coopとの互換性を有効にする"
|
|
||||||
R_BUTTON = "Rボタン - 設定"
|
R_BUTTON = "Rボタン - 設定"
|
||||||
L_BUTTON = "Lボタン - 有効化されたMODを再読み込み"
|
L_BUTTON = "Lボタン - 有効化されたMODを再読み込み"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Opcje Menu"
|
||||||
INFORMATION = "Informacja"
|
INFORMATION = "Informacja"
|
||||||
DEBUG = "Debugowanie"
|
DEBUG = "Debugowanie"
|
||||||
LANGUAGE = "Język"
|
LANGUAGE = "Język"
|
||||||
COOP_COMPATIBILITY = "Włącz kompatybilność z sm64ex-coop"
|
|
||||||
R_BUTTON = "Przycisk R - Opcje"
|
R_BUTTON = "Przycisk R - Opcje"
|
||||||
L_BUTTON = "Przycisk L - Przeładuj aktywne mody"
|
L_BUTTON = "Przycisk L - Przeładuj aktywne mody"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Opções de menu"
|
||||||
INFORMATION = "Informações"
|
INFORMATION = "Informações"
|
||||||
DEBUG = "Debug"
|
DEBUG = "Debug"
|
||||||
LANGUAGE = "Idioma"
|
LANGUAGE = "Idioma"
|
||||||
COOP_COMPATIBILITY = "Ativar a compatibilidade com sm64ex-coop"
|
|
||||||
R_BUTTON = "Botão R - Opções"
|
R_BUTTON = "Botão R - Opções"
|
||||||
L_BUTTON = "Botão L - Recarregar mods ativos"
|
L_BUTTON = "Botão L - Recarregar mods ativos"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,6 @@ MENU_OPTIONS = "Параметры меню"
|
||||||
INFORMATION = "Информация"
|
INFORMATION = "Информация"
|
||||||
DEBUG = "Отладка"
|
DEBUG = "Отладка"
|
||||||
LANGUAGE = "Язык"
|
LANGUAGE = "Язык"
|
||||||
COOP_COMPATIBILITY = "Включить совместимость sm64ex-coop"
|
|
||||||
R_BUTTON = "Кнопка R - Опции"
|
R_BUTTON = "Кнопка R - Опции"
|
||||||
L_BUTTON = "Кнопка L - Перезагрузить активные моды"
|
L_BUTTON = "Кнопка L - Перезагрузить активные моды"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,6 @@ MENU_OPTIONS = "Opciones del menú"
|
||||||
INFORMATION = "Información"
|
INFORMATION = "Información"
|
||||||
DEBUG = "Depuración"
|
DEBUG = "Depuración"
|
||||||
LANGUAGE = "Idioma"
|
LANGUAGE = "Idioma"
|
||||||
COOP_COMPATIBILITY = "Habilitar la compatibilidad con sm64ex-coop"
|
|
||||||
R_BUTTON = "Botón R - Opciones"
|
R_BUTTON = "Botón R - Opciones"
|
||||||
L_BUTTON = "Botón L - Recargar mods activos"
|
L_BUTTON = "Botón L - Recargar mods activos"
|
||||||
|
|
||||||
|
|
|
||||||
26
res/icon.rc
26
res/icon.rc
|
|
@ -1 +1,27 @@
|
||||||
id ICON res/icon.ico
|
id ICON res/icon.ico
|
||||||
|
|
||||||
|
#include <winver.h>
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -61,15 +61,18 @@ void djui_panel_main_create(struct DjuiBase* caller) {
|
||||||
djui_base_set_color(&message->base, 255, 255, 160, 255);
|
djui_base_set_color(&message->base, 255, 255, 160, 255);
|
||||||
djui_text_set_alignment(message, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
|
djui_text_set_alignment(message, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
|
||||||
} else {
|
} else {
|
||||||
#ifdef COMPILE_TIME
|
struct DjuiText* version = djui_text_create(
|
||||||
struct DjuiText* version = djui_text_create(&panel->base, get_version_with_build_date());
|
&panel->base,
|
||||||
#else
|
#ifdef COMPILE_TIME
|
||||||
struct DjuiText* version = djui_text_create(&panel->base, get_version());
|
get_version_with_build_date()
|
||||||
#endif
|
#else
|
||||||
|
get_version()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
djui_base_set_size_type(&version->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
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_size(&version->base, 1.0f, 1.0f);
|
||||||
djui_base_set_color(&version->base, 50, 50, 50, 255);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,27 @@
|
||||||
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
|
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
|
||||||
|
|
||||||
const char* get_version(void) {
|
const char* get_version(void) {
|
||||||
|
snprintf(
|
||||||
|
sVersionString, MAX_VERSION_LENGTH,
|
||||||
#if defined(VERSION_US)
|
#if defined(VERSION_US)
|
||||||
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s", SM64COOPDX_VERSION);
|
"%s", SM64COOPDX_VERSION
|
||||||
#else
|
#else
|
||||||
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %s", SM64COOPDX_VERSION, VERSION_REGION);
|
"%s %s", SM64COOPDX_VERSION, VERSION_REGION
|
||||||
#endif // VERSION_US
|
#endif // VERSION_US
|
||||||
|
);
|
||||||
return sVersionString;
|
return sVersionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COMPILE_TIME
|
#ifdef COMPILE_TIME
|
||||||
const char* get_version_with_build_date(void) {
|
const char* get_version_with_build_date(void) {
|
||||||
|
snprintf(
|
||||||
|
sVersionString, MAX_VERSION_LENGTH,
|
||||||
#if defined(VERSION_US)
|
#if defined(VERSION_US)
|
||||||
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s, %s", SM64COOPDX_VERSION, COMPILE_TIME);
|
"%s, %s", SM64COOPDX_VERSION, COMPILE_TIME
|
||||||
#else
|
#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
|
#endif // VERSION_US
|
||||||
|
);
|
||||||
return sVersionString;
|
return sVersionString;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
#define VERSION_NUMBER 42
|
#define VERSION_NUMBER 42
|
||||||
#define MINOR_VERSION_NUMBER 0
|
#define MINOR_VERSION_NUMBER 0
|
||||||
|
|
||||||
|
#define VERSION_OFFSET 37 // difference from old versioning system
|
||||||
|
|
||||||
#if defined(VERSION_JP)
|
#if defined(VERSION_JP)
|
||||||
#define VERSION_REGION "JP"
|
#define VERSION_REGION "JP"
|
||||||
#elif defined(VERSION_EU)
|
#elif defined(VERSION_EU)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,20 @@ downloading and parsing a source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char sVersionUpdateTextBuffer[256] = { 0 };
|
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;
|
bool gUpdateMessage = false;
|
||||||
|
|
||||||
|
|
@ -51,6 +64,27 @@ size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||||
}
|
}
|
||||||
#endif
|
#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) {
|
void parse_version(const char *data) {
|
||||||
const char *version = strstr(data, VERSION_IDENTIFIER);
|
const char *version = strstr(data, VERSION_IDENTIFIER);
|
||||||
if (version == NULL) { return; }
|
if (version == NULL) { return; }
|
||||||
|
|
@ -58,14 +92,17 @@ void parse_version(const char *data) {
|
||||||
version += len;
|
version += len;
|
||||||
const char *end = strchr(version, '"');
|
const char *end = strchr(version, '"');
|
||||||
size_t versionLength = (size_t)(end - version);
|
size_t versionLength = (size_t)(end - version);
|
||||||
if (versionLength > sizeof(sRemoteVersion) - 1) { return; }
|
if (versionLength > sizeof(sRemoteVersionStr) - 1) { return; }
|
||||||
memcpy(sRemoteVersion, version, versionLength);
|
memcpy(sRemoteVersionStr, version, versionLength);
|
||||||
sRemoteVersion[versionLength] = '\0';
|
sRemoteVersionStr[versionLength] = '\0';
|
||||||
|
|
||||||
|
string_to_version(sRemoteVersionStr, &sRemoteVersion);
|
||||||
|
string_to_version(get_version(), &sClientVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to download a text file from the internet
|
// function to download a text file from the internet
|
||||||
void get_version_remote(void) {
|
void get_version_remote(void) {
|
||||||
sRemoteVersion[0] = '\0';
|
sRemoteVersionStr[0] = '\0';
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
char buffer[0xFF] = { 0 };
|
char buffer[0xFF] = { 0 };
|
||||||
|
|
@ -145,13 +182,13 @@ void check_for_updates(void) {
|
||||||
LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates"));
|
LOADING_SCREEN_MUTEX(loading_screen_set_segment_text("Checking For Updates"));
|
||||||
|
|
||||||
get_version_remote();
|
get_version_remote();
|
||||||
if (sRemoteVersion[0] == 'v' && strcmp(sRemoteVersion, get_version())) {
|
if (sRemoteVersionStr[0] == 'v' && is_version_newer(sClientVersion, sRemoteVersion)) {
|
||||||
snprintf(
|
snprintf(
|
||||||
sVersionUpdateTextBuffer, 256,
|
sVersionUpdateTextBuffer, 256,
|
||||||
"\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",
|
"\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",
|
||||||
DLANG(NOTIF, UPDATE_AVAILABLE),
|
DLANG(NOTIF, UPDATE_AVAILABLE),
|
||||||
DLANG(NOTIF, LATEST_VERSION),
|
DLANG(NOTIF, LATEST_VERSION),
|
||||||
sRemoteVersion,
|
sRemoteVersionStr,
|
||||||
DLANG(NOTIF, YOUR_VERSION),
|
DLANG(NOTIF, YOUR_VERSION),
|
||||||
get_version()
|
get_version()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue