Added save file selection to host menu

This commit is contained in:
MysterD 2021-07-14 18:58:52 -07:00
parent 15de510a5c
commit 1ea3007256
9 changed files with 106 additions and 9 deletions

View File

@ -3550,7 +3550,7 @@ const u8* const font_normal_chars[] = {
texture_font_normal_char_92, // |
texture_font_normal_char_93, // }
texture_font_char_us_tilde, // ~
texture_font_char_us_interpunct, // DEL
texture_font_char_us_star_filled, // DEL
};
const f32 font_normal_widths[] = {
@ -3567,5 +3567,5 @@ const f32 font_normal_widths[] = {
/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
0.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.2500f, 0.3125f, 0.3125f, 0.1875f, 0.4375f, 0.3125f, 0.3125f, 0.3125f, 0.3750f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.3125f, 0.4375f, 0.4375f, 0.3125f, 0.3125f,
/* { | } ~ DEL */
0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.4375f
0.3125f, 0.2500f, 0.3125f, 0.5000f, 0.5000f
};

View File

@ -3947,6 +3947,7 @@
<ClCompile Include="..\src\pc\djui\djui_panel_controls.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_host.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_host_message.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_host_save.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_join.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_join_message.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_menu.c" />
@ -4390,6 +4391,7 @@
<ClInclude Include="..\src\pc\djui\djui_panel_controls.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_host.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_host_message.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_host_save.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_join.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_join_message.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_menu.h" />

View File

@ -15255,6 +15255,9 @@
<ClCompile Include="..\src\pc\djui\djui_popup.c">
<Filter>Source Files\src\pc\djui\component\compound</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\djui\djui_panel_host_save.c">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\actors\common0.h">
@ -16330,5 +16333,8 @@
<ClInclude Include="..\src\pc\djui\djui_popup.h">
<Filter>Source Files\src\pc\djui\component\compound</Filter>
</ClInclude>
<ClInclude Include="..\src\pc\djui\djui_panel_host_save.h">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1306,7 +1306,8 @@ s32 init_level(void) {
set_mario_action(gMarioState, ACT_IDLE, 0);
} else if (gDebugLevelSelect == 0) {
if (gMarioState->action != ACT_UNINITIALIZED) {
if (save_file_exists(gCurrSaveFileNum - 1)) {
bool skipIntro = (gNetworkType == NT_NONE);
if (save_file_exists(gCurrSaveFileNum - 1) || skipIntro) {
set_mario_action(gMarioState, ACT_IDLE, 0);
} else if (gCLIOpts.SkipIntro == 0 && configSkipIntro == 0 && gServerSettings.skipIntro == 0) {
set_mario_action(gMarioState, ACT_INTRO_CUTSCENE, 0);
@ -1377,6 +1378,7 @@ s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum) {
sWarpDest.type = WARP_TYPE_NOT_WARPING;
sDelayedWarpOp = WARP_OP_NONE;
gShouldNotPlayCastleMusic = !save_file_exists(gCurrSaveFileNum - 1) && gCLIOpts.SkipIntro == 0 && configSkipIntro == 0;
if (gNetworkType == NT_NONE) { gShouldNotPlayCastleMusic = true; }
gCurrLevelNum = levelNum;
gCurrCourseNum = COURSE_NONE;

View File

@ -34,6 +34,7 @@
#include "djui_panel_debug.h"
#include "djui_panel_main.h"
#include "djui_panel_host.h"
#include "djui_panel_host_save.h"
#include "djui_panel_host_message.h"
#include "djui_panel_join.h"
#include "djui_panel_join_message.h"

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include "djui.h"
#include "game/save_file.h"
#include "pc/network/network.h"
#include "pc/utils/misc.h"
#include "pc/configfile.h"
@ -91,6 +92,26 @@ void djui_panel_host_create(struct DjuiBase* caller) {
#endif
sInputboxPort = inputbox1;
}
struct DjuiRect* rect2 = djui_rect_create(&body->base);
djui_base_set_size_type(&rect2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&rect2->base, 1.0f, 32);
djui_base_set_color(&rect2->base, 0, 0, 0, 0);
{
struct DjuiText* text1 = djui_text_create(&rect2->base, "Save Slot");
djui_base_set_size_type(&text1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_color(&text1->base, 200, 200, 200, 255);
djui_base_set_size(&text1->base, 0.485f, 64);
djui_base_set_alignment(&text1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
char starString[32] = { 0 };
snprintf(starString, 32, "%c x%d", '~' + 1, save_file_get_total_star_count(configHostSaveSlot - 1, 0, 24));
struct DjuiButton* button1 = djui_button_create(&rect2->base, starString);
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.5f, 32);
djui_base_set_alignment(&button1->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button1->base, djui_panel_host_save_create);
}
char* iChoices[3] = { "Non-solid", "Solid", "Friendly Fire" };
struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Player interaction", iChoices, 3, &configFiltering);
@ -109,19 +130,19 @@ void djui_panel_host_create(struct DjuiBase* caller) {
djui_base_set_size_type(&checkbox3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox3->base, 1.0f, 32);
struct DjuiRect* rect2 = djui_rect_create(&body->base);
djui_base_set_size_type(&rect2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&rect2->base, 1.0f, 64);
djui_base_set_color(&rect2->base, 0, 0, 0, 0);
struct DjuiRect* rect3 = djui_rect_create(&body->base);
djui_base_set_size_type(&rect3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&rect3->base, 1.0f, 64);
djui_base_set_color(&rect3->base, 0, 0, 0, 0);
{
struct DjuiButton* button1 = djui_button_create(&rect2->base, "Back");
struct DjuiButton* button1 = djui_button_create(&rect3->base, "Back");
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.485f, 64);
djui_base_set_alignment(&button1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
djui_button_set_style(button1, 1);
djui_interactable_hook_click(&button1->base, djui_panel_menu_back);
struct DjuiButton* button2 = djui_button_create(&rect2->base, "Host");
struct DjuiButton* button2 = djui_button_create(&rect3->base, "Host");
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_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);

View File

@ -23,6 +23,8 @@ Forward port '\\#d0d0ff\\%d\\#c8c8c8\\' for UDP.\
void djui_panel_host_message_do_host(struct DjuiBase* caller) {
djui_panel_shutdown();
extern s16 gCurrSaveFileNum;
gCurrSaveFileNum = configHostSaveSlot;
#ifndef DISCORD_SDK
configNetworkSystem = 1;
network_set_system(NS_SOCKET);

View File

@ -0,0 +1,59 @@
#include <stdio.h>
#include "djui.h"
#include "game/save_file.h"
#include "pc/configfile.h"
static struct DjuiBase* sSaveButtonCaller = NULL;
static struct DjuiButton* sSaveButtons[4] = { NULL };
static void djui_panel_host_save_update_button(struct DjuiButton* button, int slot) {
char starString[32] = { 0 };
snprintf(starString, 32, "%c x%d", '~' + 1, save_file_get_total_star_count(slot, 0, 24));
djui_text_set_text(button->text, starString);
}
static void djui_panel_host_save_button_click(struct DjuiBase* caller) {
configHostSaveSlot = caller->tag + 1;
djui_panel_host_save_update_button((struct DjuiButton*)sSaveButtonCaller, configHostSaveSlot - 1);
djui_panel_menu_back(caller);
}
static void djui_panel_host_save_erase_button_click(struct DjuiBase* caller) {
save_file_erase(caller->tag);
djui_panel_host_save_update_button(sSaveButtons[caller->tag], caller->tag);
}
void djui_panel_host_save_create(struct DjuiBase* caller) {
f32 bodyHeight = 32 * 4 + 64 * 1 + 16 * 5;
sSaveButtonCaller = caller;
struct DjuiBase* defaultBase = NULL;
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\S\\#1be700\\A\\#00b3ff\\V\\#ffef00\\E");
struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel);
{
for (int i = 0; i < 4; i++) {
struct DjuiRect* rect1 = djui_rect_create(&body->base);
djui_base_set_size_type(&rect1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&rect1->base, 1.0f, 32);
djui_base_set_color(&rect1->base, 0, 0, 0, 0);
{
struct DjuiButton* button1 = djui_button_create(&rect1->base, "");
djui_panel_host_save_update_button(button1, i);
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.74f, 32);
djui_interactable_hook_click(&button1->base, djui_panel_host_save_button_click);
button1->base.tag = i;
if (i == (int)(configHostSaveSlot - 1)) { defaultBase = &button1->base; }
sSaveButtons[i] = button1;
struct DjuiButton* button2 = djui_button_create(&rect1->base, "erase");
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 0.24f, 32);
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button2->base, djui_panel_host_save_erase_button_click);
}
}
}
djui_panel_add(caller, &panel->base, defaultBase);
}

View File

@ -0,0 +1,4 @@
#pragma once
#include "djui.h"
void djui_panel_host_save_create(struct DjuiBase* caller);