Merge branch 'coop' of github.com:sm64ex-coop-dev/sm64ex-coop into coop

This commit is contained in:
MysterD 2023-04-13 21:35:08 -07:00
commit e6343238db
6 changed files with 60 additions and 36 deletions

View File

@ -8,16 +8,11 @@
// events //
////////////
static void djui_paginated_prev(struct DjuiBase* base) {
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
paginated->startIndex -= paginated->showCount;
if (paginated->startIndex < 0) { paginated->startIndex = 0; }
}
static void djui_paginated_next(struct DjuiBase* base) {
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
paginated->startIndex += paginated->showCount;
static struct DjuiButton* sPrevButton = NULL;
static struct DjuiButton* sNextButton = NULL;
static struct DjuiText* sPageNumText = NULL;
static s32 djui_paginated_get_count(struct DjuiPaginated* paginated) {
s32 count = 0;
struct DjuiBaseChild* dbc = paginated->layout->base.child;
while (dbc != NULL) {
@ -25,6 +20,35 @@ static void djui_paginated_next(struct DjuiBase* base) {
dbc = dbc->next;
}
return count;
}
static void djui_paginated_prev(struct DjuiBase* base) {
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
paginated->startIndex -= paginated->showCount;
djui_base_set_enabled(&sPrevButton->base, (paginated->startIndex > 0));
djui_base_set_enabled(&sNextButton->base, true);
char pageNumString[32] = { 0 };
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, djui_paginated_get_count(paginated) / paginated->showCount + 1);
djui_text_set_text(sPageNumText, pageNumString);
if (paginated->startIndex < 0) { paginated->startIndex = 0; }
}
static void djui_paginated_next(struct DjuiBase* base) {
struct DjuiPaginated* paginated = (struct DjuiPaginated*)base->parent;
paginated->startIndex += paginated->showCount;
s32 count = djui_paginated_get_count(paginated);
djui_base_set_enabled(&sNextButton->base, (paginated->startIndex < count - 8));
djui_base_set_enabled(&sPrevButton->base, true);
char pageNumString[32] = { 0 };
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, count / paginated->showCount + 1);
djui_text_set_text(sPageNumText, pageNumString);
if (paginated->startIndex >= count) { paginated->startIndex -= paginated->showCount; }
}
@ -57,6 +81,10 @@ void djui_paginated_calculate_height(struct DjuiPaginated* paginated) {
}
djui_base_set_size(&paginated->base, paginated->base.width.value, height);
char pageNumString[32] = { 0 };
snprintf(pageNumString, 32, "%d/%d", paginated->startIndex / paginated->showCount + 1, count / paginated->showCount + 1);
djui_text_set_text(sPageNumText, pageNumString);
}
bool djui_paginated_render(struct DjuiBase* base) {
@ -112,22 +140,23 @@ struct DjuiPaginated* djui_paginated_create(struct DjuiBase* parent, u32 showCou
paginated->layout = layout;
}
{
struct DjuiButton* button = djui_button_create(&paginated->base, "<", DJUI_BUTTON_STYLE_NORMAL, djui_paginated_prev);
djui_base_set_alignment(&button->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_BOTTOM);
djui_base_set_size_type(&button->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button->base, 128, 32);
paginated->prevButton = button;
}
sPrevButton = djui_button_create(&paginated->base, "<", DJUI_BUTTON_STYLE_NORMAL, djui_paginated_prev);
djui_base_set_alignment(&sPrevButton->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_BOTTOM);
djui_base_set_size_type(&sPrevButton->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&sPrevButton->base, 128, 32);
djui_base_set_enabled(&sPrevButton->base, false);
paginated->prevButton = sPrevButton;
{
struct DjuiButton* button = djui_button_create(&paginated->base, ">", DJUI_BUTTON_STYLE_NORMAL, djui_paginated_next);
djui_base_set_alignment(&button->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM);
djui_base_set_size_type(&button->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button->base, 128, 32);
djui_interactable_hook_click(&button->base, djui_paginated_next);
paginated->nextButton = button;
}
sPageNumText = djui_text_create(&paginated->base, "");
djui_base_set_color(&sPageNumText->base, 200, 200, 200, 255);
djui_base_set_alignment(&sPageNumText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
sPageNumText->base.y.value -= 30;
sNextButton = djui_button_create(&paginated->base, ">", DJUI_BUTTON_STYLE_NORMAL, djui_paginated_next);
djui_base_set_alignment(&sNextButton->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM);
djui_base_set_size_type(&sNextButton->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&sNextButton->base, 128, 32);
paginated->nextButton = sNextButton;
return paginated;
}

View File

@ -441,15 +441,10 @@ bool mod_load(struct Mods* mods, char* basePath, char* modName) {
valid = true;
} else if (is_directory(fullPath)) {
char tmpPath[SYS_MAX_PATH] = { 0 };
char path1[SYS_MAX_PATH] = { 0 };
char path2[SYS_MAX_PATH] = { 0 };
if (!concat_path(tmpPath, fullPath, "main.lua")) {
LOG_ERROR("Failed to concat path '%s' + '%s'", fullPath, "main.lua");
return true;
}
if ((concat_path(path1, fullPath, "c-update.lua") && path_exists(path1)) || (concat_path(path2, fullPath, "m-update.lua") && path_exists(path2))) {
return true;
}
valid = path_exists(tmpPath);
}

View File

@ -52,8 +52,8 @@ void packet_process(struct Packet* p) {
case PACKET_JOIN: network_receive_join(p); break;
case PACKET_CHAT: network_receive_chat(p); break;
case PACKET_KICK: network_receive_kick(p); break;
case PACKET_COMMAND: network_recieve_chat_command(p); break;
case PACKET_MODERATOR: network_recieve_moderator(p); break;
case PACKET_COMMAND: network_receive_chat_command(p); break;
case PACKET_MODERATOR: network_receive_moderator(p); break;
case PACKET_KEEP_ALIVE: network_receive_keep_alive(p); break;
case PACKET_LEAVING: network_receive_leaving(p); break;
case PACKET_SAVE_FILE: network_receive_save_file(p); break;

View File

@ -234,11 +234,11 @@ void network_receive_kick(struct Packet* p);
// packet_command_mod.c
void network_send_chat_command(u8 localIndex, enum ChatConfirmCommand CCC);
void network_recieve_chat_command(struct Packet* p);
void network_receive_chat_command(struct Packet* p);
// packet_moderator.c
void network_send_moderator(u8 localIndex);
void network_recieve_moderator(struct Packet* p);
void network_receive_moderator(struct Packet* p);
// packet_keep_alive.c
void network_send_keep_alive(u8 localIndex);

View File

@ -138,7 +138,7 @@ void network_receive_area(struct Packet* p) {
LOG_INFO("rx area");
if (p == NULL) {
LOG_ERROR("rx area: the packet was NULL, failed to recieve the area.");
LOG_ERROR("rx area: the packet was NULL, failed to receive the area.");
return;
}

View File

@ -18,7 +18,7 @@ void network_send_chat_command(u8 globalIndex, enum ChatConfirmCommand ccc) {
}
}
void network_recieve_chat_command(struct Packet *p) {
void network_receive_chat_command(struct Packet *p) {
if (!moderator_list_contains(gNetworkSystem->get_id_str(p->localIndex))) {
return;
}
@ -59,7 +59,7 @@ void network_send_moderator(u8 localIndex) {
network_send_to(localIndex, &p);
}
void network_recieve_moderator(struct Packet *p) {
void network_receive_moderator(struct Packet *p) {
if ((gIsModerator) || (network_player_any_connected() && gNetworkPlayers[p->localIndex].type != NPT_SERVER)) {
return;
}