|
@@ -1,9 +1,11 @@
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
+#include "scufcont/scufcont.h"
|
|
|
#include "scufeng/engine.h"
|
|
#include "scufeng/engine.h"
|
|
|
#include "scufeng/Mesh.h"
|
|
#include "scufeng/Mesh.h"
|
|
|
#include "scufeng/keys.h"
|
|
#include "scufeng/keys.h"
|
|
|
#include "scufeng/log.h"
|
|
#include "scufeng/log.h"
|
|
|
|
|
+#include "scufeng/http.h"
|
|
|
#include "cglm/vec3.h"
|
|
#include "cglm/vec3.h"
|
|
|
#include "cglm/io.h"
|
|
#include "cglm/io.h"
|
|
|
|
|
|
|
@@ -16,7 +18,6 @@
|
|
|
return (res); \
|
|
return (res); \
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
static SEResult LoginPrompt_alloc(LoginPrompt *const lp, const unsigned int screen_w, const unsigned int screen_h) {
|
|
static SEResult LoginPrompt_alloc(LoginPrompt *const lp, const unsigned int screen_w, const unsigned int screen_h) {
|
|
|
lp->bg = SEMesh_rect_color_alloc((vec4) { 0.05f, 0.05f, 0.05f, 1.0f });
|
|
lp->bg = SEMesh_rect_color_alloc((vec4) { 0.05f, 0.05f, 0.05f, 1.0f });
|
|
|
vec2 bg_dims = { screen_w * 0.75f, screen_h * 0.75f };
|
|
vec2 bg_dims = { screen_w * 0.75f, screen_h * 0.75f };
|
|
@@ -162,6 +163,51 @@ SEResult MainMenu_alloc(
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void login(const char *username, const char *password) {
|
|
|
|
|
+#define SC_CHECK(res) \
|
|
|
|
|
+ if ((res) != SCUFCONT_SUCCESS) { \
|
|
|
|
|
+ SE_LOG_FATALF("[login] %s", ScufContResult_to_str((res))); \
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const size_t host_len = strlen(auth_server_host);
|
|
|
|
|
+ SCDString login_dto;
|
|
|
|
|
+ ScufContResult sc_res = SCDString_alloc_concat_c_strs(
|
|
|
|
|
+ &login_dto,
|
|
|
|
|
+ "{\"username\": \"",
|
|
|
|
|
+ strlen("{\"username\": \""),
|
|
|
|
|
+ username,
|
|
|
|
|
+ strlen(username)
|
|
|
|
|
+ );
|
|
|
|
|
+ SC_CHECK(sc_res);
|
|
|
|
|
+
|
|
|
|
|
+ sc_res = SCDString_concat_c_str(
|
|
|
|
|
+ &login_dto,
|
|
|
|
|
+ "\", \"password\": \"",
|
|
|
|
|
+ strlen("\", \"password\": \"")
|
|
|
|
|
+ );
|
|
|
|
|
+ SC_CHECK(sc_res);
|
|
|
|
|
+
|
|
|
|
|
+ sc_res = SCDString_concat_c_str(
|
|
|
|
|
+ &login_dto,
|
|
|
|
|
+ password,
|
|
|
|
|
+ strlen(password)
|
|
|
|
|
+ );
|
|
|
|
|
+ SC_CHECK(sc_res);
|
|
|
|
|
+
|
|
|
|
|
+ sc_res = SCDString_concat_c_str(
|
|
|
|
|
+ &login_dto,
|
|
|
|
|
+ "\"}",
|
|
|
|
|
+ strlen("\"}")
|
|
|
|
|
+ );
|
|
|
|
|
+ SC_CHECK(sc_res);
|
|
|
|
|
+
|
|
|
|
|
+ se_http_request_send();
|
|
|
|
|
+
|
|
|
|
|
+ SCDString_free(&login_dto);
|
|
|
|
|
+
|
|
|
|
|
+#undef SC_CHECK
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void MainMenu_mouse_button_callback(SEMouseButton button, SEKeyAction action, SEKeyMod mods, void *data) {
|
|
static void MainMenu_mouse_button_callback(SEMouseButton button, SEKeyAction action, SEKeyMod mods, void *data) {
|
|
|
(void) mods;
|
|
(void) mods;
|
|
|
|
|
|
|
@@ -202,6 +248,17 @@ static void MainMenu_mouse_button_callback(SEMouseButton button, SEKeyAction act
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (SEMesh_rect_is_pos_inside(&mm->login_prompt.login_button, x, y)) {
|
|
|
|
|
+ mm->login_render = false;
|
|
|
|
|
+ mm->next_screen = PONG_MAIN_MENU;
|
|
|
|
|
+ ;
|
|
|
|
|
+ login(
|
|
|
|
|
+ SETextInput_c_str(&mm->login_prompt.username_input),
|
|
|
|
|
+ SETextInput_c_str(&mm->login_prompt.password_input)
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
SETextInput *const tis[] = {
|
|
SETextInput *const tis[] = {
|
|
|
&mm->login_prompt.username_input,
|
|
&mm->login_prompt.username_input,
|
|
|
&mm->login_prompt.password_input,
|
|
&mm->login_prompt.password_input,
|