diff --git a/build-windows-visual-studio/sm64ex.vcxproj b/build-windows-visual-studio/sm64ex.vcxproj
index f1982d5c9..bd4b12c64 100644
--- a/build-windows-visual-studio/sm64ex.vcxproj
+++ b/build-windows-visual-studio/sm64ex.vcxproj
@@ -3950,6 +3950,7 @@
+
@@ -4392,6 +4393,7 @@
+
diff --git a/build-windows-visual-studio/sm64ex.vcxproj.filters b/build-windows-visual-studio/sm64ex.vcxproj.filters
index 8b64f8821..e79928b1b 100644
--- a/build-windows-visual-studio/sm64ex.vcxproj.filters
+++ b/build-windows-visual-studio/sm64ex.vcxproj.filters
@@ -15252,6 +15252,9 @@
Source Files\src\pc\djui\component\compound
+
+ Source Files\src\pc\djui\panel
+
@@ -16324,5 +16327,8 @@
Source Files\src\pc\djui\component\compound
+
+ Source Files\src\pc\djui\panel
+
\ No newline at end of file
diff --git a/src/pc/djui/djui.h b/src/pc/djui/djui.h
index 4cf5227ba..b47956a6e 100644
--- a/src/pc/djui/djui.h
+++ b/src/pc/djui/djui.h
@@ -34,6 +34,7 @@
#include "djui_panel_main.h"
#include "djui_panel_host.h"
#include "djui_panel_host_message.h"
+#include "djui_panel_join.h"
#include "djui_panel_options.h"
#include "djui_panel_camera.h"
#include "djui_panel_controls.h"
diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c
index 966037946..9006da3c9 100644
--- a/src/pc/djui/djui_inputbox.c
+++ b/src/pc/djui/djui_inputbox.c
@@ -15,6 +15,15 @@ static u8 sHeldShift = 0;
static u8 sHeldControl = 0;
static u8 sCursorBlink = 0;
+void djui_inputbox_set_text(struct DjuiInputbox* inputbox, char* text) {
+ snprintf(inputbox->buffer, inputbox->bufferSize, "%s", text);
+}
+
+void djui_inputbox_select_all(struct DjuiInputbox* inputbox) {
+ inputbox->selection[1] = 0;
+ inputbox->selection[0] = strlen(inputbox->buffer);
+}
+
void djui_inputbox_hook_enter_press(struct DjuiInputbox* inputbox, void (*on_enter_press)(void)) {
inputbox->on_enter_press = on_enter_press;
}
@@ -54,15 +63,6 @@ static u16 djui_inputbox_get_cursor_index(struct DjuiInputbox* inputbox) {
return index;
}
-static void djui_inputbox_on_cursor_down_begin(struct DjuiBase* base, bool inputCursor) {
- struct DjuiInputbox* inputbox = (struct DjuiInputbox*)base;
- u16 index = djui_inputbox_get_cursor_index(inputbox);
- inputbox->selection[0] = index;
- inputbox->selection[1] = index;
- sCursorBlink = 0;
- djui_interactable_set_input_focus(base);
-}
-
static void djui_inputbox_on_cursor_down(struct DjuiBase* base) {
struct DjuiInputbox* inputbox = (struct DjuiInputbox*)base;
u16 index = djui_inputbox_get_cursor_index(inputbox);
@@ -73,6 +73,21 @@ static void djui_inputbox_on_cursor_down_end(struct DjuiBase* base) {
djui_inputbox_set_default_style(base);
}
+static void djui_inputbox_on_cursor_down_begin(struct DjuiBase* base, bool inputCursor) {
+ struct DjuiInputbox* inputbox = (struct DjuiInputbox*)base;
+ u16 index = djui_inputbox_get_cursor_index(inputbox);
+ u16 selLength = abs(inputbox->selection[0] - inputbox->selection[1]);
+ if (selLength != strlen(inputbox->buffer) || djui_interactable_is_input_focus(base)) {
+ inputbox->selection[0] = index;
+ inputbox->selection[1] = index;
+ djui_interactable_hook_cursor_down(base, djui_inputbox_on_cursor_down_begin, djui_inputbox_on_cursor_down, djui_inputbox_on_cursor_down_end);
+ } else {
+ djui_interactable_hook_cursor_down(base, djui_inputbox_on_cursor_down_begin, NULL, djui_inputbox_on_cursor_down_end);
+ }
+ sCursorBlink = 0;
+ djui_interactable_set_input_focus(base);
+}
+
static u16 djui_inputbox_jump_word_left(char* msg, u16 len, u16 i) {
if (i == 0) { return i; }
diff --git a/src/pc/djui/djui_inputbox.h b/src/pc/djui/djui_inputbox.h
index 9d7ca72c6..c85b05d81 100644
--- a/src/pc/djui/djui_inputbox.h
+++ b/src/pc/djui/djui_inputbox.h
@@ -11,6 +11,8 @@ struct DjuiInputbox {
void (*on_enter_press)(void);
};
+void djui_inputbox_set_text(struct DjuiInputbox* inputbox, char* text);
+void djui_inputbox_select_all(struct DjuiInputbox* inputbox);
void djui_inputbox_hook_enter_press(struct DjuiInputbox* inputbox, void (*on_enter_press)(void));
struct DjuiInputbox* djui_inputbox_create(struct DjuiBase* parent, u16 bufferSize);
diff --git a/src/pc/djui/djui_panel_join.c b/src/pc/djui/djui_panel_join.c
new file mode 100644
index 000000000..08ea4238d
--- /dev/null
+++ b/src/pc/djui/djui_panel_join.c
@@ -0,0 +1,78 @@
+#include "djui.h"
+#include "src/pc/utils/misc.h"
+#include "src/pc/configfile.h"
+
+#ifdef DISCORD_SDK
+static char* sJoiningDiscord = "\
+To join a \\#d0d0ff\\Discord\\#c8c8c8\\ lobby:\n\n\
+Keep the game open and click the join button on the invite.\n\n\
+If the invite says that the game has ended, click the name of the person that sent the invite to refresh it.\
+";
+#endif
+
+static char* sJoiningDirect = "\
+Enter \\#d0d0ff\\direct connection\\#c8c8c8\\ IP and port:\
+";
+
+void djui_panel_join_create(struct DjuiBase* caller) {
+ f32 bodyHeight = 2 + 32 + 16 * 2 + 64;
+
+ u16 directLines = 1;
+ f32 directTextHeight = 32 * 0.8125f * directLines + 8;
+ bodyHeight += directTextHeight + 16;
+
+#ifdef DISCORD_SDK
+ u16 discordLines = 8;
+ f32 discordTextHeight = 32 * 0.8125f * discordLines + 8;
+ bodyHeight += discordTextHeight + 16;
+#endif
+
+ struct DjuiBase* defaultBase = NULL;
+ struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\J\\#1be700\\O\\#00b3ff\\I\\#ffef00\\N");
+ struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel);
+ {
+#ifdef DISCORD_SDK
+ struct DjuiText* text1 = djui_text_create(&body->base, sJoiningDiscord);
+ djui_base_set_size_type(&text1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
+ djui_base_set_size(&text1->base, 1.0f, discordTextHeight);
+ djui_base_set_color(&text1->base, 200, 200, 200, 255);
+#endif
+ 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, 2);
+ djui_base_set_color(&rect1->base, 150, 150, 150, 255);
+
+ struct DjuiText* text2 = djui_text_create(&body->base, sJoiningDirect);
+ djui_base_set_size_type(&text2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
+ djui_base_set_size(&text2->base, 1.0f, directTextHeight);
+ djui_base_set_color(&text2->base, 200, 200, 200, 255);
+
+ struct DjuiInputbox* inputbox1 = djui_inputbox_create(&body->base, 256);
+ djui_base_set_size_type(&inputbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
+ djui_base_set_size(&inputbox1->base, 1.0f, 32.0f);
+ djui_inputbox_set_text(inputbox1, configJoinIp);
+ djui_inputbox_select_all(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, 64);
+ djui_base_set_color(&rect2->base, 0, 0, 0, 0);
+ {
+ struct DjuiButton* button1 = djui_button_create(&rect2->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, "Join");
+ 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);
+ djui_interactable_hook_click(&button2->base, djui_panel_menu_back);
+ defaultBase = &button2->base;
+ }
+ }
+
+ djui_panel_add(caller, &panel->base, defaultBase);
+}
diff --git a/src/pc/djui/djui_panel_join.h b/src/pc/djui/djui_panel_join.h
new file mode 100644
index 000000000..1b099fc5b
--- /dev/null
+++ b/src/pc/djui/djui_panel_join.h
@@ -0,0 +1,4 @@
+#pragma once
+#include "djui.h"
+
+void djui_panel_join_create(struct DjuiBase* caller);
diff --git a/src/pc/djui/djui_panel_main.c b/src/pc/djui/djui_panel_main.c
index decb731f3..4ab47d838 100644
--- a/src/pc/djui/djui_panel_main.c
+++ b/src/pc/djui/djui_panel_main.c
@@ -25,6 +25,7 @@ void djui_panel_main_create(struct DjuiBase* caller) {
struct DjuiButton* button2 = djui_button_create(&body->base, "Join");
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 1.0f, 64);
+ djui_interactable_hook_click(&button2->base, djui_panel_join_create);
struct DjuiButton* button3 = djui_button_create(&body->base, "Options");
djui_base_set_size_type(&button3->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
@@ -46,9 +47,6 @@ void djui_panel_main_create(struct DjuiBase* caller) {
djui_text_set_alignment(footer, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM);
}
- struct DjuiInputbox* inputbox = djui_inputbox_create(&gDjuiRoot->base, 256);
- djui_base_set_location(&inputbox->base, 400, 100);
-
djui_panel_add(caller, &panel->base, defaultBase);
gInteractableOverridePad = true;
}