mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Made Lua mods show up in player list
This commit is contained in:
parent
948e4283de
commit
0c05fbae87
8 changed files with 90 additions and 8 deletions
|
|
@ -47,6 +47,7 @@
|
|||
#include "djui_panel_options.h"
|
||||
#include "djui_panel_player.h"
|
||||
#include "djui_panel_playerlist.h"
|
||||
#include "djui_panel_modlist.h"
|
||||
#include "djui_panel_camera.h"
|
||||
#include "djui_panel_controls.h"
|
||||
#include "djui_panel_controls_n64.h"
|
||||
|
|
|
|||
|
|
@ -221,10 +221,15 @@ bool djui_interactable_on_key_down(int scancode) {
|
|||
}
|
||||
}
|
||||
|
||||
if (gDjuiPlayerList != NULL) {
|
||||
if (gDjuiPlayerList != NULL || gDjuiModList != NULL) {
|
||||
for (int i = 0; i < MAX_BINDS; i++) {
|
||||
if (scancode == (int)configKeyPlayerList[i]) {
|
||||
if (gDjuiPlayerList != NULL) {
|
||||
djui_base_set_visible(&gDjuiPlayerList->base, true);
|
||||
}
|
||||
if (gDjuiModList != NULL) {
|
||||
djui_base_set_visible(&gDjuiModList->base, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -249,10 +254,15 @@ void djui_interactable_on_key_up(int scancode) {
|
|||
&& (gInteractableFocus->interactable != NULL)
|
||||
&& (gInteractableFocus->interactable->on_key_up != NULL);
|
||||
|
||||
if (gDjuiPlayerList != NULL) {
|
||||
if (gDjuiPlayerList != NULL || gDjuiModList != NULL) {
|
||||
for (int i = 0; i < MAX_BINDS; i++) {
|
||||
if (scancode == (int)configKeyPlayerList[i]) {
|
||||
if (gDjuiPlayerList != NULL) {
|
||||
djui_base_set_visible(&gDjuiPlayerList->base, false);
|
||||
}
|
||||
if (gDjuiModList != NULL) {
|
||||
djui_base_set_visible(&gDjuiModList->base, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ void djui_panel_host_message_do_host(UNUSED struct DjuiBase* caller) {
|
|||
}
|
||||
#endif
|
||||
network_init(NT_SERVER);
|
||||
djui_panel_modlist_create(NULL);
|
||||
fake_lvl_init_from_save_file();
|
||||
extern s16 gChangeLevelTransition;
|
||||
gChangeLevelTransition = 16;
|
||||
|
|
|
|||
61
src/pc/djui/djui_panel_modlist.c
Normal file
61
src/pc/djui/djui_panel_modlist.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "djui.h"
|
||||
#include "pc/mod_list.h"
|
||||
|
||||
struct DjuiThreePanel* gDjuiModList = NULL;
|
||||
|
||||
void djui_panel_modlist_create(UNUSED struct DjuiBase* caller) {
|
||||
// delete old mod list
|
||||
if (gDjuiModList != NULL) {
|
||||
djui_base_destroy(&gDjuiModList->base);
|
||||
gDjuiModList = NULL;
|
||||
}
|
||||
|
||||
// count mods
|
||||
int enabledCount = 0;
|
||||
for (int i = 0; i < gModTableCurrent->entryCount; i++) {
|
||||
struct ModListEntry* entry = &gModTableCurrent->entries[i];
|
||||
if (!entry->enabled) { continue; }
|
||||
enabledCount++;
|
||||
}
|
||||
|
||||
// only create if we have mods
|
||||
if (enabledCount == 0) { return; }
|
||||
|
||||
f32 bodyHeight = (enabledCount * 32) + (enabledCount - 1) * 4;
|
||||
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\M\\#1be700\\O\\#00b3ff\\D\\#ffef00\\S");
|
||||
gDjuiModList = panel;
|
||||
|
||||
djui_base_set_alignment(&panel->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_CENTER);
|
||||
|
||||
djui_base_set_location_type(&panel->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_location(&panel->base, 0.1f, 0);
|
||||
|
||||
djui_base_set_size_type(&panel->base, DJUI_SVT_ABSOLUTE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&panel->base, 280, bodyHeight + (32 + 16) + 32 + 32);
|
||||
|
||||
djui_base_set_visible(&panel->base, false);
|
||||
struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel);
|
||||
djui_flow_layout_set_margin(body, 4);
|
||||
|
||||
for (int i = 0; i < gModTableCurrent->entryCount; i++) {
|
||||
struct ModListEntry* entry = &gModTableCurrent->entries[i];
|
||||
if (!entry->enabled) { continue; }
|
||||
|
||||
struct DjuiFlowLayout* row = djui_flow_layout_create(&body->base);
|
||||
djui_base_set_size_type(&row->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&row->base, 1.0f, 32.0f);
|
||||
int v = (i % 2) ? 16 : 32;
|
||||
djui_base_set_color(&row->base, v, v, v, 128);
|
||||
djui_flow_layout_set_flow_direction(row, DJUI_FLOW_DIR_RIGHT);
|
||||
djui_flow_layout_set_margin(row, 8);
|
||||
|
||||
int t = 220;
|
||||
struct DjuiText* t2 = djui_text_create(&row->base, entry->displayName ? entry->displayName : entry->name);
|
||||
djui_base_set_size_type(&t2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&t2->base, 1.0f, 32.0f);
|
||||
djui_base_set_color(&t2->base, t, t, t, 255);
|
||||
}
|
||||
|
||||
}
|
||||
6
src/pc/djui/djui_panel_modlist.h
Normal file
6
src/pc/djui/djui_panel_modlist.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
#include "djui.h"
|
||||
|
||||
extern struct DjuiThreePanel* gDjuiModList;
|
||||
|
||||
void djui_panel_modlist_create(UNUSED struct DjuiBase* caller);
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "game/level_info.h"
|
||||
#include "pc/network/network.h"
|
||||
#include "djui.h"
|
||||
#include "djui_panel_playerlist.h"
|
||||
#include "src/pc/utils/misc.h"
|
||||
#include "src/pc/configfile.h"
|
||||
#include "game/level_info.h"
|
||||
#include "game/mario_misc.h"
|
||||
#include "pc/configfile.h"
|
||||
#include "pc/network/network.h"
|
||||
#include "pc/utils/misc.h"
|
||||
|
||||
struct DjuiThreePanel* gDjuiPlayerList = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#include "pc/djui/djui.h"
|
||||
#include "pc/mod_list.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
|
|
@ -22,6 +23,7 @@ void network_send_next_download_request(void) {
|
|||
}
|
||||
//LOG_INFO("sending join request");
|
||||
network_send_join_request();
|
||||
djui_panel_modlist_create(NULL);
|
||||
}
|
||||
|
||||
void network_send_download_request(u16 clientIndex, u16 serverIndex, u64 offset) {
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ void main_func(void) {
|
|||
configHostPort = gCLIOpts.NetworkPort;
|
||||
network_init(NT_SERVER);
|
||||
djui_panel_shutdown();
|
||||
djui_panel_modlist_create(NULL);
|
||||
} else {
|
||||
network_init(NT_NONE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue