Replaced old host/join menu with new DJUI menu system

This commit is contained in:
MysterD 2021-07-04 22:40:04 -07:00
parent 733217a07a
commit 13d504a953
12 changed files with 53 additions and 25 deletions

View file

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
#make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here' make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here'
make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here' -ex 'run --server 27015 --configfile sm64config_server.txt' #make BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 STRICT=1 && winpty cgdb ./build/us_pc/sm64.us.f3dex2e.exe -ex 'break debug_breakpoint_here' -ex 'run --server 27015 --configfile sm64config_server.txt'

View file

@ -5,6 +5,7 @@
#ifdef IMMEDIATELOAD #ifdef IMMEDIATELOAD
#include "levels/menu/header.h" #include "levels/menu/header.h"
#include "levels/scripts.h"
#else #else
#include "levels/intro/header.h" #include "levels/intro/header.h"
#endif #endif
@ -12,15 +13,14 @@
#include "make_const_nonconst.h" #include "make_const_nonconst.h"
const LevelScript level_script_entry[] = { const LevelScript level_script_entry[] = {
INIT_LEVEL(), SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS),
SLEEP(/*frames*/ 2), JUMP(/*target*/ level_main_scripts_entry),
BLACKOUT(/*active*/ FALSE),
SET_REG(/*value*/ 0), // old behavior (intro)
#ifdef IMMEDIATELOAD //INIT_LEVEL(),
EXECUTE(/*seg*/ 0x14, /*script*/ _introSegmentRomStart, /*scriptEnd*/ _introSegmentRomEnd, /*entry*/ level_main_menu_entry_1), //SLEEP(/*frames*/ 2),
JUMP(/*target*/ level_main_menu_entry_1), //BLACKOUT(/*active*/ FALSE),
#else //SET_REG(/*value*/ 0),
EXECUTE(/*seg*/ 0x14, /*script*/ _introSegmentRomStart, /*scriptEnd*/ _introSegmentRomEnd, /*entry*/ level_intro_entry_1), //EXECUTE(/*seg*/ 0x14, /*script*/ _introSegmentRomStart, /*scriptEnd*/ _introSegmentRomEnd, /*entry*/ level_intro_entry_1),
JUMP(/*target*/ level_script_entry), //JUMP(/*target*/ level_script_entry),
#endif
}; };

View file

@ -1867,7 +1867,7 @@ s32 execute_mario_action(UNUSED struct Object *o) {
s32 inLoop = TRUE; s32 inLoop = TRUE;
// hide inactive players // hide inactive players
struct NetworkPlayer* np = &gNetworkPlayers[gMarioState->playerIndex]; struct NetworkPlayer* np = &gNetworkPlayers[gMarioState->playerIndex];
if (np->type != NPT_LOCAL) { if (gMarioState->playerIndex != 0) {
bool levelAreaMismatch = bool levelAreaMismatch =
(np->currCourseNum != gCurrCourseNum (np->currCourseNum != gCurrCourseNum
|| np->currActNum != gCurrActNum || np->currActNum != gCurrActNum

View file

@ -514,6 +514,8 @@ s32 is_point_within_radius_of_mario(f32 x, f32 y, f32 z, s32 dist) {
} }
u8 is_player_active(struct MarioState* m) { u8 is_player_active(struct MarioState* m) {
if (gNetworkType == NT_NONE && m == &gMarioStates[0]) { return TRUE; }
if (m->action == ACT_BUBBLED) { return FALSE; } if (m->action == ACT_BUBBLED) { return FALSE; }
struct NetworkPlayer* np = &gNetworkPlayers[m->playerIndex]; struct NetworkPlayer* np = &gNetworkPlayers[m->playerIndex];
if (np->type != NPT_LOCAL) { if (np->type != NPT_LOCAL) {

View file

@ -199,7 +199,7 @@ void unload_object(struct Object *obj) {
obj->header.gfx.node.flags &= ~GRAPH_RENDER_CYLBOARD; obj->header.gfx.node.flags &= ~GRAPH_RENDER_CYLBOARD;
obj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; obj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
if (obj->oSyncID != 0) { if (obj->oSyncID != 0 && gNetworkType != NT_NONE) {
if (gSyncObjects[obj->oSyncID].syncDeathEvent) { if (gSyncObjects[obj->oSyncID].syncDeathEvent) {
network_send_object(obj); network_send_object(obj);
} else { } else {

View file

@ -129,5 +129,6 @@ void djui_panel_shutdown(void) {
sPanelList = NULL; sPanelList = NULL;
sPanelRemoving = NULL; sPanelRemoving = NULL;
sMoveAmount = 0; sMoveAmount = 0;
gInteractableOverridePad = false;
djui_cursor_set_visible(false);
} }

View file

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include "djui.h" #include "djui.h"
#include "src/pc/network/network.h"
#include "src/pc/utils/misc.h" #include "src/pc/utils/misc.h"
#include "src/pc/configfile.h" #include "src/pc/configfile.h"
@ -18,6 +19,23 @@ Direct connections \\#ffa0a0\\require you\\#c8c8c8\\ to configure port forwardin
Forward port '\\#d0d0ff\\%d\\#c8c8c8\\' for UDP.\ Forward port '\\#d0d0ff\\%d\\#c8c8c8\\' for UDP.\
"; ";
void djui_panel_host_message_do_host(struct DjuiBase* caller) {
djui_panel_shutdown();
#ifndef DISCORD_SDK
configNetworkSystem = 1;
network_set_system(NS_SOCKET);
#else
if (configNetworkSystem == 0) {
network_set_system(NS_DISCORD);
} else {
network_set_system(NS_SOCKET);
}
#endif
network_init(NT_SERVER);
extern s16 gChangeLevel;
gChangeLevel = 16;
}
void djui_panel_host_message_create(struct DjuiBase* caller) { void djui_panel_host_message_create(struct DjuiBase* caller) {
f32 warningLines = 0; f32 warningLines = 0;
char* warningMessage = NULL; char* warningMessage = NULL;
@ -62,7 +80,7 @@ void djui_panel_host_message_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 0.485f, 64); djui_base_set_size(&button2->base, 0.485f, 64);
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button2->base, djui_panel_menu_back); djui_interactable_hook_click(&button2->base, djui_panel_host_message_do_host);
defaultBase = &button2->base; defaultBase = &button2->base;
} }
} }

View file

@ -1,4 +1,5 @@
#include "djui.h" #include "djui.h"
#include "src/pc/network/network.h"
#include "src/pc/utils/misc.h" #include "src/pc/utils/misc.h"
#include "src/pc/configfile.h" #include "src/pc/configfile.h"
@ -14,6 +15,12 @@ static char* sJoiningDirect = "\
Enter \\#d0d0ff\\direct connection\\#c8c8c8\\ IP and port:\ Enter \\#d0d0ff\\direct connection\\#c8c8c8\\ IP and port:\
"; ";
void djui_panel_join_do_join(struct DjuiBase* caller) {
djui_panel_shutdown();
network_set_system(NS_SOCKET);
network_init(NT_CLIENT);
}
void djui_panel_join_create(struct DjuiBase* caller) { void djui_panel_join_create(struct DjuiBase* caller) {
f32 bodyHeight = 2 + 32 + 16 * 2 + 64; f32 bodyHeight = 2 + 32 + 16 * 2 + 64;
@ -69,7 +76,7 @@ void djui_panel_join_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 0.485f, 64); djui_base_set_size(&button2->base, 0.485f, 64);
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP); djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button2->base, djui_panel_menu_back); djui_interactable_hook_click(&button2->base, djui_panel_join_do_join);
defaultBase = &button2->base; defaultBase = &button2->base;
} }
} }

View file

@ -1,12 +1,6 @@
#include "djui.h" #include "djui.h"
#include "src/pc/controller/controller_sdl.h" #include "src/pc/controller/controller_sdl.h"
static void djui_panel_main_close(struct DjuiBase* caller) {
gInteractableOverridePad = false;
djui_panel_shutdown();
djui_cursor_set_visible(false);
}
void djui_panel_main_create(struct DjuiBase* caller) { void djui_panel_main_create(struct DjuiBase* caller) {
f32 bodyHeight = 64 * 4 + 16 * 3; f32 bodyHeight = 64 * 4 + 16 * 3;

View file

@ -152,5 +152,7 @@ void network_receive_join(struct Packet* p) {
network_player_connected(NPT_LOCAL, myGlobalIndex); network_player_connected(NPT_LOCAL, myGlobalIndex);
save_file_load_all(TRUE); save_file_load_all(TRUE);
//custom_menu_goto_game(gCurrSaveFileNum);
extern s16 gChangeLevel;
gChangeLevel = 16;
} }

View file

@ -93,6 +93,8 @@ static u16 get_spawn_info_index_of_object(struct Object* o) {
//// ////
void network_send_level_respawn_info(struct Object* o, u8 respawnInfoBits) { void network_send_level_respawn_info(struct Object* o, u8 respawnInfoBits) {
if (gNetworkType == NT_NONE) { return; }
// make sure our area is valid // make sure our area is valid
if (!gNetworkPlayerLocal->currAreaSyncValid) { if (!gNetworkPlayerLocal->currAreaSyncValid) {
LOG_ERROR("my area is invalid"); LOG_ERROR("my area is invalid");

View file

@ -383,6 +383,8 @@ static void packet_read_object_only_death(struct Packet* p, struct Object* o) {
// ----- main send/receive ----- // // ----- main send/receive ----- //
void network_send_object(struct Object* o) { void network_send_object(struct Object* o) {
if (gNetworkType == NT_NONE) { return; }
// sanity check SyncObject // sanity check SyncObject
if (!network_sync_object_initialized(o)) { return; } if (!network_sync_object_initialized(o)) { return; }
if (o->behavior == bhvRespawner) { return; } if (o->behavior == bhvRespawner) { return; }