mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-09 18:31:43 +00:00
Looooooooooots of changes, throwing here to merge some prs togethere, weewowoooo
This commit is contained in:
parent
2f72b24033
commit
2d8f26ebcb
10 changed files with 41 additions and 26 deletions
|
|
@ -11,6 +11,13 @@ class Lobby;
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define COOPNET_MAX_GAME_LEN 32
|
||||
#define COOPNET_MAX_VERSION_LEN 32
|
||||
#define COOPNET_MAX_HOST_NAME_LEN 64
|
||||
#define COOPNET_MAX_MODE_LEN 64
|
||||
#define COOPNET_MAX_PASSWORD_LEN 64
|
||||
#define COOPNET_MAX_DESCRIPTION_LEN 1024
|
||||
|
||||
typedef enum {
|
||||
COOPNET_OK,
|
||||
COOPNET_FAILED,
|
||||
|
|
@ -34,7 +41,7 @@ typedef struct {
|
|||
void (*OnLobbyCreated)(uint64_t aLobbyId, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, uint16_t aMaxConnections);
|
||||
void (*OnLobbyJoined)(uint64_t aLobbyId, uint64_t aUserId, uint64_t aOwnerId, uint64_t aDestId);
|
||||
void (*OnLobbyLeft)(uint64_t aLobbyId, uint64_t aUserId);
|
||||
void (*OnLobbyListGot)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription);
|
||||
void (*OnLobbyListGot)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, int64_t aTimestamp, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription);
|
||||
void (*OnLobbyListFinish)(void);
|
||||
void (*OnReceive)(uint64_t aFromUserId, const uint8_t* aData, uint64_t aSize);
|
||||
void (*OnError)(enum MPacketErrorNumber aErrorNumber, uint64_t tag);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -13,7 +13,7 @@ void djui_panel_confirm_create(struct DjuiBase* caller, char* title, char* messa
|
|||
djui_base_set_size(&text->base, 1.0f, 64);
|
||||
djui_base_compute_tree(&text->base);
|
||||
u16 lines = djui_text_count_lines(text, 12);
|
||||
f32 textHeight = 32 * 0.8125f * lines + 8;
|
||||
f32 textHeight = 32 * text->font->lineHeight * lines + 8;
|
||||
djui_base_set_size(&text->base, 1.0f, textHeight);
|
||||
|
||||
djui_base_set_color(&text->base, 220, 220, 220, 255);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ struct ModCategory sCategories[] = {
|
|||
// lang key, mod category
|
||||
{ "ALL", NULL },
|
||||
{ "MISC", NULL },
|
||||
{ "ROMHACKS", "romhack" },
|
||||
{ "GAMEMODES", "gamemode" },
|
||||
{ "ROMHACKS", "romhack" },
|
||||
{ "MOVESETS", "moveset" },
|
||||
{ "CHARACTER_SELECT", "cs" },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include "libcoopnet.h"
|
||||
#include "djui.h"
|
||||
#include "djui_panel.h"
|
||||
#include "djui_panel_menu.h"
|
||||
|
|
@ -25,9 +26,7 @@ static struct DjuiText* sTooltip = NULL;
|
|||
static char* sPassword = NULL;
|
||||
|
||||
static void djui_panel_join_lobby_description_create(void) {
|
||||
f32 bodyHeight = 600;
|
||||
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 64, bodyHeight, 0);
|
||||
struct DjuiThreePanel* panel = djui_three_panel_create(&gDjuiRoot->base, 0, 1200, 0);
|
||||
struct DjuiThreePanelTheme theme = gDjuiThemes[configDjuiTheme]->threePanels;
|
||||
|
||||
djui_base_set_alignment(&panel->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_CENTER);
|
||||
|
|
@ -47,10 +46,11 @@ static void djui_panel_join_lobby_description_create(void) {
|
|||
djui_flow_layout_set_flow_direction(body, DJUI_FLOW_DIR_DOWN);
|
||||
|
||||
struct DjuiText* description = djui_text_create(&panel->base, "");
|
||||
djui_base_set_size_type(&description->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE);
|
||||
djui_base_set_size(&description->base, 1.0f, 1.0f);
|
||||
djui_base_set_alignment(&description->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_CENTER);
|
||||
djui_base_set_size_type(&description->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&description->base, 1.0f, 32);
|
||||
djui_base_set_color(&description->base, 222, 222, 222, 255);
|
||||
djui_text_set_alignment(description, DJUI_HALIGN_LEFT, DJUI_VALIGN_CENTER);
|
||||
djui_text_set_alignment(description, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
|
||||
sTooltip = description;
|
||||
}
|
||||
sDescriptionPanel = panel;
|
||||
|
|
@ -59,6 +59,11 @@ static void djui_panel_join_lobby_description_create(void) {
|
|||
static void djui_lobby_on_hover(struct DjuiBase* base) {
|
||||
struct DjuiLobbyEntry* entry = (struct DjuiLobbyEntry*)base;
|
||||
djui_text_set_text(sTooltip, entry->description);
|
||||
djui_base_compute_tree(&sDescriptionPanel->base);
|
||||
u16 lines = djui_text_count_lines(sTooltip, 48);
|
||||
f32 textHeight = 32 * 0.8125f * lines + 8;
|
||||
sDescriptionPanel->bodySize.value = textHeight;
|
||||
djui_base_set_size(&sTooltip->base, 1.0f, textHeight);
|
||||
}
|
||||
|
||||
static void djui_lobby_on_hover_end(UNUSED struct DjuiBase* base) {
|
||||
|
|
@ -74,23 +79,22 @@ void djui_panel_join_lobby(struct DjuiBase* caller) {
|
|||
djui_panel_join_message_create(caller);
|
||||
}
|
||||
|
||||
void djui_panel_join_query(uint64_t aLobbyId, UNUSED uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, UNUSED const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription) {
|
||||
void djui_panel_join_query(uint64_t aLobbyId, UNUSED uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, UNUSED int64_t aTimestamp, UNUSED const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription) {
|
||||
if (!sLobbyLayout) { return; }
|
||||
if (!sLobbyPaginated) { return; }
|
||||
if (aMaxConnections > MAX_PLAYERS) { return; }
|
||||
|
||||
char playerText[64] = "";
|
||||
snprintf(playerText, 63, "%u/%u", aConnections, aMaxConnections);
|
||||
snprintf(playerText, 64, "%u/%u", aConnections, aMaxConnections);
|
||||
|
||||
|
||||
char mode[64] = "";
|
||||
snprintf(mode, 64, "%s", aMode);
|
||||
char mode[COOPNET_MAX_MODE_LEN] = "";
|
||||
snprintf(mode, COOPNET_MAX_MODE_LEN, "%s", aMode);
|
||||
|
||||
char version[MAX_VERSION_LENGTH] = { 0 };
|
||||
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
|
||||
bool disabled = strcmp(version, aVersion) != 0;
|
||||
if (disabled) {
|
||||
snprintf(mode, 64, "\\#ff0000\\[%s]", aVersion);
|
||||
snprintf(mode, COOPNET_MAX_MODE_LEN, "\\#ff0000\\[%s]", aVersion);
|
||||
}
|
||||
|
||||
struct DjuiBase* layoutBase = &sLobbyLayout->base;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
#ifdef COOPNET
|
||||
|
||||
#define MAX_COOPNET_DESCRIPTION_LENGTH 1024
|
||||
|
||||
uint64_t gCoopNetDesiredLobby = 0;
|
||||
char gCoopNetPassword[64] = "";
|
||||
char sCoopNetDescription[MAX_COOPNET_DESCRIPTION_LENGTH] = "";
|
||||
char gCoopNetPassword[COOPNET_MAX_PASSWORD_LEN] = "";
|
||||
char sCoopNetDescription[COOPNET_MAX_DESCRIPTION_LEN] = "";
|
||||
|
||||
static uint64_t sLocalLobbyId = 0;
|
||||
static uint64_t sLocalLobbyOwnerId = 0;
|
||||
|
|
@ -176,16 +174,22 @@ bool ns_coopnet_is_connected(void) {
|
|||
|
||||
static void coopnet_populate_description(void) {
|
||||
char* buffer = sCoopNetDescription;
|
||||
int bufferLength = MAX_COOPNET_DESCRIPTION_LENGTH;
|
||||
int bufferLength = COOPNET_MAX_DESCRIPTION_LEN;
|
||||
// get version
|
||||
const char* version = get_version();
|
||||
int versionLength = snprintf(buffer, bufferLength, "%s\n", version);
|
||||
buffer += versionLength;
|
||||
bufferLength -= versionLength;
|
||||
|
||||
// add seperator
|
||||
char* sep = "\nMods:\n";
|
||||
snprintf(buffer, bufferLength, "%s", sep);
|
||||
buffer += strlen(sep);
|
||||
bufferLength -= strlen(sep);
|
||||
|
||||
struct ModCategory sCategories[] = {
|
||||
{ "ROMHACKS", "romhack" },
|
||||
{ "GAMEMODES", "gamemode" },
|
||||
{ "ROMHACKS", "romhack" },
|
||||
{ "MOVESETS", "moveset" },
|
||||
{ "CHARACTER_SELECT", "cs" },
|
||||
};
|
||||
|
|
@ -201,7 +205,7 @@ static void coopnet_populate_description(void) {
|
|||
for (int j = 0; j < gActiveMods.entryCount; j++) {
|
||||
struct Mod* mod = gActiveMods.entries[j];
|
||||
char* modCategory = mod->category != NULL ? mod->category : mod->incompatible;
|
||||
if (modCategory && strstr(modCategory, sCategories[i].category)) {
|
||||
if (modCategory && strcasestr(modCategory, sCategories[i].category)) {
|
||||
strings[strIndex++] = mod->name;
|
||||
}
|
||||
}
|
||||
|
|
@ -263,15 +267,15 @@ void ns_coopnet_update(void) {
|
|||
coopnet_update();
|
||||
if (gNetworkType != NT_NONE && sNetworkType != NT_NONE) {
|
||||
if (sNetworkType == NT_SERVER) {
|
||||
char mode[64] = "";
|
||||
mods_get_main_mod_name(mode, 64);
|
||||
char mode[MOD_NAME_SIZE] = "";
|
||||
mods_get_main_mod_name(mode, MOD_NAME_SIZE);
|
||||
if (sReconnecting) {
|
||||
LOG_INFO("Update lobby");
|
||||
coopnet_populate_description();
|
||||
coopnet_lobby_update(sLocalLobbyId, GAME_NAME, get_version(), configPlayerName, mode, sCoopNetDescription);
|
||||
} else {
|
||||
LOG_INFO("Create lobby");
|
||||
snprintf(gCoopNetPassword, 64, "%s", configPassword);
|
||||
snprintf(gCoopNetPassword, COOPNET_MAX_PASSWORD_LEN, "%s", configPassword);
|
||||
coopnet_populate_description();
|
||||
coopnet_lobby_create(GAME_NAME, get_version(), configPlayerName, mode, (uint16_t)configAmountOfPlayers, gCoopNetPassword, sCoopNetDescription);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define COOPNET_H
|
||||
#ifdef COOPNET
|
||||
|
||||
typedef void (*QueryCallbackPtr)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription);
|
||||
typedef void (*QueryCallbackPtr)(uint64_t aLobbyId, uint64_t aOwnerId, uint16_t aConnections, uint16_t aMaxConnections, int64_t aTimestamp, const char* aGame, const char* aVersion, const char* aHostName, const char* aMode, const char* aDescription);
|
||||
typedef void (*QueryFinishCallbackPtr)(void);
|
||||
|
||||
extern struct NetworkSystem gNetworkSystemCoopNet;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue