|
@@ -2,29 +2,113 @@
|
|
|
#include "scufeng/Mesh.h"
|
|
#include "scufeng/Mesh.h"
|
|
|
#include "scufeng/log.h"
|
|
#include "scufeng/log.h"
|
|
|
#include "cglm/vec3.h"
|
|
#include "cglm/vec3.h"
|
|
|
|
|
+#include "cglm/call/vec3.h"
|
|
|
|
|
+#include "cglm/io.h"
|
|
|
|
|
|
|
|
#include "MainMenu.h"
|
|
#include "MainMenu.h"
|
|
|
#include "game_common.h"
|
|
#include "game_common.h"
|
|
|
|
|
+#include "scufeng/text.h"
|
|
|
|
|
+
|
|
|
|
|
+static LoginPrompt LoginPrompt_alloc(const unsigned int screen_w, const unsigned int screen_h) {
|
|
|
|
|
+ LoginPrompt lp = {
|
|
|
|
|
+ .bg = SEMesh_rect_color_alloc((vec4) { 0.05f, 0.05f, 0.05f, 1.0f }),
|
|
|
|
|
+ .username_text = SEMesh_string_alloc("Username:", GLM_VEC3_ONE),
|
|
|
|
|
+ .username_input = SETextInput_alloc(
|
|
|
|
|
+ "",
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ GLM_VEC3_ONE,
|
|
|
|
|
+ (vec4) { 0.0025f, 0.0025f, 0.0025f, 1.0f },
|
|
|
|
|
+ TI_FIXED_WIDTH
|
|
|
|
|
+ ),
|
|
|
|
|
+ .password_text = SEMesh_string_alloc("Password:", GLM_VEC3_ONE),
|
|
|
|
|
+ .password_input = SETextInput_alloc(
|
|
|
|
|
+ "",
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ 0,
|
|
|
|
|
+ GLM_VEC3_ONE,
|
|
|
|
|
+ (vec4) { 0.0025f, 0.0025f, 0.0025f, 1.0f },
|
|
|
|
|
+ TI_FIXED_WIDTH
|
|
|
|
|
+ ),
|
|
|
|
|
+ .exit_text = SEMesh_string_alloc("X", GLM_VEC3_ONE),
|
|
|
|
|
+ .login_text = SEMesh_string_alloc("Login", GLM_VEC3_ONE)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ vec2 bg_dims = { screen_w * 0.75f, screen_h * 0.75f };
|
|
|
|
|
+ vec2 bg_pos = { screen_w * 0.5f, screen_h * 0.5f };
|
|
|
|
|
+ lp.bg.transform.scale[0] = bg_dims[0];
|
|
|
|
|
+ lp.bg.transform.scale[1] = bg_dims[1];
|
|
|
|
|
+ lp.bg.transform.pos[0] = bg_pos[0];
|
|
|
|
|
+ lp.bg.transform.pos[1] = bg_pos[1];
|
|
|
|
|
+ vec4 bg_bbox;
|
|
|
|
|
+ SEMesh_bbox_get_2d_v(&lp.bg, bg_bbox);
|
|
|
|
|
+
|
|
|
|
|
+ puts("bg_dims");
|
|
|
|
|
+ glm_vec2_print(bg_dims, stdout);
|
|
|
|
|
+ puts("bg_pos");
|
|
|
|
|
+ glm_vec2_print(bg_pos, stdout);
|
|
|
|
|
+ puts("bg_bbox");
|
|
|
|
|
+ glm_vec4_print(bg_bbox, stdout);
|
|
|
|
|
+
|
|
|
|
|
+ lp.exit_text.transform.pos[0] = bg_bbox[0] + bg_dims[0] * 0.025f;
|
|
|
|
|
+ lp.exit_text.transform.pos[1] = bg_bbox[1] + bg_dims[1] * 0.05f;
|
|
|
|
|
+ glm_vec3_print(lp.exit_text.transform.pos, stdout);
|
|
|
|
|
+
|
|
|
|
|
+ SETextInput_fixed_width_set(&lp.username_input, bg_dims[0] * 0.25f);
|
|
|
|
|
+ SETextInput_fixed_width_set(&lp.password_input, bg_dims[0] * 0.25f);
|
|
|
|
|
+
|
|
|
|
|
+ return lp;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void LoginPrompt_render(LoginPrompt *const lp) {
|
|
|
|
|
+ SEMesh *const meshes[] = {
|
|
|
|
|
+ &lp->bg,
|
|
|
|
|
+ &lp->username_text,
|
|
|
|
|
+ &lp->password_text,
|
|
|
|
|
+ &lp->exit_text,
|
|
|
|
|
+ &lp->login_text
|
|
|
|
|
+ };
|
|
|
|
|
+ SETextInput *const tis[] = {
|
|
|
|
|
+ &lp->username_input,
|
|
|
|
|
+ &lp->password_input
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ SEMesh_render_multiple_2d(meshes, sizeof(meshes) / sizeof(meshes[0]));
|
|
|
|
|
+ SETextInput_render_multiple_2d(tis, sizeof(tis) / sizeof(tis[0]));
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
MainMenu MainMenu_alloc(const unsigned int screen_w, const unsigned int screen_h) {
|
|
MainMenu MainMenu_alloc(const unsigned int screen_w, const unsigned int screen_h) {
|
|
|
MainMenu mm;
|
|
MainMenu mm;
|
|
|
|
|
|
|
|
- mm.title_text = SEMesh_string_alloc("Pong", 1.0f, GLM_VEC3_ONE);
|
|
|
|
|
|
|
+ mm.title_text = SEMesh_string_alloc("Pong", GLM_VEC3_ONE);
|
|
|
|
|
+ SEMesh_rect_textured_scale_set(&mm.title_text, screen_w * 0.16f, 0.0f);
|
|
|
mm.title_text.transform.pos[0] = screen_w / 2.0f;
|
|
mm.title_text.transform.pos[0] = screen_w / 2.0f;
|
|
|
- mm.title_text.transform.pos[1] = screen_h * 0.2f;
|
|
|
|
|
|
|
+ mm.title_text.transform.pos[1] = screen_h * 0.1f;
|
|
|
|
|
+
|
|
|
|
|
+ mm.login_text = SEMesh_string_alloc("Login", GLM_VEC3_ONE);
|
|
|
|
|
+ SEMesh_rect_textured_scale_set(&mm.login_text, screen_w * 0.06f, 0.0f);
|
|
|
|
|
+ mm.login_text.transform.pos[0] = screen_w / 6.0f;
|
|
|
|
|
+ mm.login_text.transform.pos[1] = screen_h * 0.2f;
|
|
|
|
|
|
|
|
- mm.sp_text = SEMesh_string_alloc("Singleplayer", 1.0f, GLM_VEC3_ONE);
|
|
|
|
|
|
|
+ mm.sp_text = SEMesh_string_alloc("Singleplayer", GLM_VEC3_ONE);
|
|
|
|
|
+ SEMesh_rect_textured_scale_set(&mm.sp_text, screen_w * 0.25f, 0.0f);
|
|
|
mm.sp_text.transform.pos[0] = screen_w * 0.25f;
|
|
mm.sp_text.transform.pos[0] = screen_w * 0.25f;
|
|
|
mm.sp_text.transform.pos[1] = screen_h * 0.5f;
|
|
mm.sp_text.transform.pos[1] = screen_h * 0.5f;
|
|
|
|
|
|
|
|
- mm.mp_text = SEMesh_string_alloc("Multiplayer", 1.0f, GLM_VEC3_ONE);
|
|
|
|
|
|
|
+ mm.mp_text = SEMesh_string_alloc("Multiplayer", GLM_VEC3_ONE);
|
|
|
|
|
+ SEMesh_rect_textured_scale_set(&mm.mp_text, mm.sp_text.transform.scale[0], 0.0f);
|
|
|
mm.mp_text.transform.pos[0] = screen_w - mm.sp_text.transform.pos[0];
|
|
mm.mp_text.transform.pos[0] = screen_w - mm.sp_text.transform.pos[0];
|
|
|
mm.mp_text.transform.pos[1] = mm.sp_text.transform.pos[1];
|
|
mm.mp_text.transform.pos[1] = mm.sp_text.transform.pos[1];
|
|
|
|
|
|
|
|
- mm.quit_text = SEMesh_string_alloc("Quit", 1.0f, GLM_VEC3_ONE);
|
|
|
|
|
|
|
+ mm.quit_text = SEMesh_string_alloc("Quit", GLM_VEC3_ONE);
|
|
|
|
|
+ SEMesh_rect_textured_scale_set(&mm.quit_text, 0.0f, mm.title_text.transform.scale[1] / 2.0f);
|
|
|
mm.quit_text.transform.pos[0] = screen_w / 2.0f;
|
|
mm.quit_text.transform.pos[0] = screen_w / 2.0f;
|
|
|
mm.quit_text.transform.pos[1] = screen_h * 0.8f;
|
|
mm.quit_text.transform.pos[1] = screen_h * 0.8f;
|
|
|
|
|
|
|
|
|
|
+ mm.login_prompt = LoginPrompt_alloc(screen_w, screen_h);
|
|
|
|
|
+
|
|
|
return mm;
|
|
return mm;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -61,9 +145,12 @@ Screen MainMenu_tick(MainMenu *const mm) {
|
|
|
&mm->title_text,
|
|
&mm->title_text,
|
|
|
&mm->sp_text,
|
|
&mm->sp_text,
|
|
|
&mm->mp_text,
|
|
&mm->mp_text,
|
|
|
- &mm->quit_text
|
|
|
|
|
|
|
+ &mm->quit_text,
|
|
|
|
|
+ &mm->login_text
|
|
|
};
|
|
};
|
|
|
SEMesh_render_multiple_2d(meshes, sizeof(meshes) / sizeof(meshes[0]));
|
|
SEMesh_render_multiple_2d(meshes, sizeof(meshes) / sizeof(meshes[0]));
|
|
|
|
|
|
|
|
|
|
+ // LoginPrompt_render(&mm->login_prompt);
|
|
|
|
|
+
|
|
|
return PONG_MAIN_MENU;
|
|
return PONG_MAIN_MENU;
|
|
|
}
|
|
}
|