This commit is contained in:
Cooliokid956 2026-03-27 20:10:00 -05:00
parent d63bfd1719
commit ad26fc4abb
12 changed files with 23 additions and 102 deletions

View file

@ -68,7 +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", "EX_WINDOW_NAME" ],
"src/pc/network/version.h": [ "VERSION_OFFSET" ],
}
include_constants = {

View file

@ -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"

View file

@ -87,7 +87,7 @@ void djui_panel_join_query(uint64_t aLobbyId, UNUSED uint64_t aOwnerId, uint16_t
snprintf(mode, 64, "%s", aMode);
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
bool disabled = strcmp(version, aVersion) != 0;
if (disabled) {
snprintf(mode, 64, "\\#ff0000\\[%s]", aVersion);

View file

@ -6,17 +6,12 @@
#include "djui_panel_menu.h"
#include "djui_panel_confirm.h"
#include "pc/controller/controller_sdl.h"
#include "pc/controller/controller_mouse.h"
#include "pc/pc_main.h"
#include "pc/update_checker.h"
#include "sounds.h"
#include "audio/external.h"
#include "game/area.h"
extern ALIGNED8 u8 texture_coopdx_logo[];
bool gDjuiPanelMainCreated = false;
static struct DjuiThreePanel* sPanelMain = NULL;
static void djui_panel_main_quit_yes(UNUSED struct DjuiBase* caller) {
game_exit();
@ -29,60 +24,10 @@ static void djui_panel_main_quit(struct DjuiBase* caller) {
djui_panel_main_quit_yes);
}
static int sEggCounter;
static u32 sEggLastFired;
static f32 sEggLastY;
static bool sEggHovered = false;
static bool sEggClicked = false;
static void djui_panel_main_egg_end(struct DjuiBase *base, UNUSED bool *noRender) {
sPanelMain->base.x.value -= gGlobalTimer - sEggLastFired + 60;
base->color.a = MAX(255.f - ((gGlobalTimer - sEggLastFired + 60) << 3), 0);
if (gGlobalTimer == sEggLastFired) {
configExCoopTheme = !configExCoopTheme;
game_exit();
}
}
static void djui_panel_main_egg(struct DjuiBase *base, UNUSED bool *noRender) {
if (sEggCounter && sEggLastY == base->clip.y) {
bool hovering = djui_cursor_inside_base(base);
bool clicking = ((gInteractablePad.button & PAD_BUTTON_A) || (mouse_buttons & L_MOUSE_BUTTON));
if (hovering) {
if (!sEggHovered && sEggLastFired + 20 < gGlobalTimer) {
play_sound(SOUND_GENERAL_COIN, gGlobalSoundSource);
}
sEggLastFired = gGlobalTimer;
if (!sEggClicked && clicking) {
play_sound(SOUND_MENU_COLLECT_SECRET + ((5 - sEggCounter) << 16), gGlobalSoundSource);
if (!--sEggCounter) {
play_transition(WARP_TRANSITION_FADE_INTO_COLOR, 0x1E, 0xFF, 0xFF, 0xFF);
fade_volume_scale(SEQ_PLAYER_LEVEL, 0, 40);
sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_ALL & ~(1 << SOUND_BANK_MENU));
sEggLastFired = gGlobalTimer + 60;
extern struct DjuiImage* sMouseCursor;
sMouseCursor->base.on_render_pre = djui_panel_main_egg_end;
}
}
}
sEggHovered = hovering;
sEggClicked = clicking;
return;
}
sEggLastY = base->clip.y;
}
void djui_panel_main_create(struct DjuiBase* caller) {
sPanelMain = djui_panel_menu_create(configExCoopTheme ? "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP" : "", false);
if (configExCoopTheme) { djui_three_panel_get_header(sPanelMain)->on_render_pre = djui_panel_main_egg; }
struct DjuiThreePanel* panel = djui_panel_menu_create(configExCoopTheme ? "\\#ff0800\\SM\\#1be700\\64\\#00b3ff\\EX\n\\#ffef00\\COOP" : "", false);
{
struct DjuiBase* body = djui_three_panel_get_body(sPanelMain);
struct DjuiBase* body = djui_three_panel_get_body(panel);
{
if (!configExCoopTheme) {
struct DjuiImage* logo = djui_image_create(body, texture_coopdx_logo, 2048, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b);
@ -94,7 +39,6 @@ void djui_panel_main_create(struct DjuiBase* caller) {
djui_base_set_alignment(&logo->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
djui_base_set_location_type(&logo->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_location(&logo->base, 0, -30);
logo->base.on_render_pre = djui_panel_main_egg;
}
struct DjuiButton* button1 = djui_button_create(body, DLANG(MAIN, HOST), DJUI_BUTTON_STYLE_NORMAL, djui_panel_host_create);
@ -111,14 +55,14 @@ void djui_panel_main_create(struct DjuiBase* caller) {
// these two cannot co-exist for some reason
if (gUpdateMessage) {
struct DjuiText* message = djui_text_create(&sPanelMain->base, DLANG(NOTIF, UPDATE_AVAILABLE));
struct DjuiText* message = djui_text_create(&panel->base, DLANG(NOTIF, UPDATE_AVAILABLE));
djui_base_set_size_type(&message->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&message->base, 1.0f, 1.0f);
djui_base_set_color(&message->base, 255, 255, 160, 255);
djui_text_set_alignment(message, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
} else {
struct DjuiText* version = djui_text_create(
&sPanelMain->base,
&panel->base,
#ifdef COMPILE_TIME
get_version_with_build_date()
#else
@ -132,8 +76,7 @@ void djui_panel_main_create(struct DjuiBase* caller) {
}
}
djui_panel_add(caller, sPanelMain, NULL);
djui_panel_add(caller, panel, NULL);
gInteractableOverridePad = true;
gDjuiPanelMainCreated = true;
sEggCounter = 5;
}

View file

@ -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"

View file

@ -177,7 +177,7 @@ static void coopnet_populate_description(void) {
char* buffer = sCoopNetDescription;
int bufferLength = MAX_COOPNET_DESCRIPTION_LENGTH;
// get version
const char* version = get_version_online();
const char* version = get_version();
int versionLength = strlen(version);
snprintf(buffer, bufferLength, "%s", version);
buffer += versionLength;
@ -212,12 +212,12 @@ void ns_coopnet_update(void) {
if (sReconnecting) {
LOG_INFO("Update lobby");
coopnet_populate_description();
coopnet_lobby_update(sLocalLobbyId, GAME_NAME, get_version_online(), configPlayerName, mode, sCoopNetDescription);
coopnet_lobby_update(sLocalLobbyId, GAME_NAME, get_version(), configPlayerName, mode, sCoopNetDescription);
} else {
LOG_INFO("Create lobby");
snprintf(gCoopNetPassword, 64, "%s", configPassword);
coopnet_populate_description();
coopnet_lobby_create(GAME_NAME, get_version_online(), configPlayerName, mode, (uint16_t)configAmountOfPlayers, gCoopNetPassword, sCoopNetDescription);
coopnet_lobby_create(GAME_NAME, get_version(), configPlayerName, mode, (uint16_t)configAmountOfPlayers, gCoopNetPassword, sCoopNetDescription);
}
} else if (sNetworkType == NT_CLIENT) {
LOG_INFO("Join lobby");

View file

@ -45,7 +45,7 @@ void network_send_join_request(void) {
struct Packet p = { 0 };
packet_init(&p, PACKET_JOIN_REQUEST, true, PLMT_NONE);
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
packet_write(&p, &configPlayerModel, sizeof(u8));
@ -107,7 +107,7 @@ void network_send_join(struct Packet* joinRequestPacket) {
}
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
LOG_INFO("sending version: %s", version);
struct Packet p = { 0 };
@ -143,7 +143,7 @@ void network_receive_join(struct Packet* p) {
gOverrideEeprom = eeprom;
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
LOG_INFO("client has version: %s", version);
char remoteVersion[MAX_VERSION_LENGTH] = { 0 };

View file

@ -20,7 +20,7 @@ void network_send_mod_list_request(void) {
struct Packet p = { 0 };
packet_init(&p, PACKET_MOD_LIST_REQUEST, true, PLMT_NONE);
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
network_send_to(PACKET_DESTINATION_SERVER, &p);
@ -47,7 +47,7 @@ void network_send_mod_list(void) {
packet_init(&p, PACKET_MOD_LIST, true, PLMT_NONE);
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
LOG_INFO("sending version: %s", version);
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
packet_write(&p, &gActiveMods.entryCount, sizeof(u16));
@ -135,7 +135,7 @@ void network_receive_mod_list(struct Packet* p) {
}
char version[MAX_VERSION_LENGTH] = { 0 };
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_online());
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
LOG_INFO("client has version: %s", version);
// verify version

View file

@ -4,7 +4,7 @@
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
const char* get_version_online(void) {
const char* get_version(void) {
snprintf(
sVersionString, MAX_VERSION_LENGTH,
#if defined(VERSION_US)
@ -16,12 +16,6 @@ const char* get_version_online(void) {
return sVersionString;
}
const char* get_version(void) {
get_version_online();
extern void exify_version_str(char* str);
if (configExCoopTheme) { exify_version_str(sVersionString); }
return sVersionString; }
#ifdef COMPILE_TIME
const char* get_version_with_build_date(void) {
snprintf(

View file

@ -6,7 +6,7 @@
// 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
@ -30,11 +30,9 @@
#define GAME_NAME "sm64coopdx"
#define WINDOW_NAME "Super Mario 64 Coop Deluxe"
#endif
#define EX_WINDOW_NAME "sm64ex-coop:"
#define MAX_VERSION_LENGTH 128
const char* get_version_online(void);
const char* get_version(void);
#ifdef COMPILE_TIME
const char* get_version_with_build_date(void);

View file

@ -54,9 +54,9 @@ extern "C" {
#endif
#ifdef GIT_HASH
#define TITLE ({ char title[96] = ""; snprintf(title, 96, "%s %s, [%s]", configExCoopTheme ? EX_WINDOW_NAME : WINDOW_NAME, get_version(), GIT_HASH); title; })
#define TITLE ({ char title[96] = ""; snprintf(title, 96, "%s %s, [%s]", WINDOW_NAME, get_version(), GIT_HASH); title; })
#else
#define TITLE ({ char title[96] = ""; snprintf(title, 96, "%s %s", configExCoopTheme ? EX_WINDOW_NAME : WINDOW_NAME, get_version()); title; })
#define TITLE ({ char title[96] = ""; snprintf(title, 96, "%s %s", WINDOW_NAME, get_version()); title; })
#endif
#define AT_STARTUP __attribute__((constructor))

View file

@ -85,19 +85,6 @@ void version_to_string(struct Version ver, char* str, size_t size) {
}
}
void exify_version(struct Version *ver) {
ver->maj = ver->min + VERSION_OFFSET;
ver->min = ver->fix;
ver->fix = 0;
}
void exify_version_str(char* str) {
struct Version ver;
string_to_version(str, &ver);
exify_version(&ver);
version_to_string(ver, str, 8);
}
void parse_version(const char *data) {
const char *version = strstr(data, VERSION_IDENTIFIER);
if (version == NULL) { return; }
@ -110,7 +97,7 @@ void parse_version(const char *data) {
sRemoteVersionStr[versionLength] = '\0';
string_to_version(sRemoteVersionStr, &sRemoteVersion);
string_to_version(get_version_online(), &sClientVersion);
string_to_version(get_version(), &sClientVersion);
}
// function to download a text file from the internet
@ -196,7 +183,6 @@ void check_for_updates(void) {
get_version_remote();
if (sRemoteVersionStr[0] == 'v' && is_version_newer(sClientVersion, sRemoteVersion)) {
if (configExCoopTheme) { exify_version_str(sRemoteVersionStr); }
snprintf(
sVersionUpdateTextBuffer, 256,
"\\#ffffa0\\%s\n\\#dcdcdc\\%s: %s\n%s: %s",