bugfixes and "title" screen
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 5 Apr 2022 03:49:15 +0000 (22:49 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 5 Apr 2022 03:49:15 +0000 (22:49 -0500)
lib/onyx-net
src/client/connect_menu.onyx
src/client/gfx/font.onyx
src/client/gfx/ui.onyx
src/client/main.onyx

index 19f30f1562238a0bbbb23acc249311a17361e36d..27c896ce946092882f9665b1ec39f6a3d74c5094 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 19f30f1562238a0bbbb23acc249311a17361e36d
+Subproject commit 27c896ce946092882f9665b1ec39f6a3d74c5094
index 7ae101a891a42e1d9bf6dcaa0794b927d017686a..ab7bf394ccd2345d82b0ff6b09b92f4932cfa7a9 100644 (file)
@@ -7,6 +7,8 @@ use package opengles
     ip_addr: [..] u8;
     port:    [..] u8;
     name:    [..] u8;
+
+    title_font: Font;
 }
 
 Connect_Menu :: struct {
@@ -14,6 +16,8 @@ Connect_Menu :: struct {
         array.clear(^port);
         port_buffer: [8] u8;
         string.concat(^port, conv.format(port_buffer, "{}", (package runtime.vars).Game_Port));
+
+        title_font = font_lookup(.{"./assets/fonts/calibri.ttf", 64});
     }
 
     join :: (_: rawptr) {
@@ -34,6 +38,8 @@ Connect_Menu :: struct {
 
         ww, wh := camera.window_width, camera.window_height;
 
+        font_draw_centered(title_font, 0, (wh - 70) / 3, ww, "Untitled Shooter Game");
+
         tx := (ww - 200) / 2;
         ty := (wh - 160) / 2;
         textbox_list_start();
@@ -93,6 +99,8 @@ Connecting_Menu :: struct {
 
         ww, wh := camera.window_width, camera.window_height;
 
+        font_draw_centered(title_font, 0, (wh - 70) / 3, ww, "Untitled Shooter Game");
+
         tx := (ww - 200) / 2;
         ty := (wh - 16) / 2;
         font_draw_centered(font, tx, ty, 200, "Connecting...");
index 0cfcafbaf314c91eb20abd18bccb3a90ae1c236a..d4b406c36f54013ce8010a7dce988f83f3f6384e 100644 (file)
@@ -71,7 +71,10 @@ Font :: struct {
 }
 
 font_make :: (fd: FontDescriptor) -> Font {
-    texture_size :: 256;
+    texture_size := 256;
+    if fd.size > 40 {
+        texture_size = 512;
+    }
 
     char_data := memory.make_slice(stbtt_packedchar, 96);
 
index 8ee8ab235d3d526baa5aaabae0665e9fc96254c7..48e7b9e8600d99a6678265ca24c85d71692f3569 100644 (file)
@@ -246,7 +246,7 @@ draw_textbox :: (use r: Rect, text_buffer: ^[..] u8, placeholder := null_str, th
 
     border_width := theme.border_width;
     text_color := theme.text_color;
-    text := str.{text_buffer.data, text_buffer.count};
+    text := cast(str) *text_buffer;
     if text.count == 0 && placeholder.count > 0 {
         text = placeholder;
         text_color = theme.placeholder_text_color;
@@ -336,7 +336,7 @@ draw_textbox :: (use r: Rect, text_buffer: ^[..] u8, placeholder := null_str, th
         textbox_editing_state.cursor_position = math.clamp(textbox_editing_state.cursor_position, 0, text_buffer.count);
         textbox_editing_state.cursor_animation = 1.0f;
 
-        text = str.{text_buffer.data, text_buffer.count};
+        text = *text_buffer;
     }
 
     if is_hot_item(hash) {
index 67886766720b4c64a7483096d9e5b52b099aa18a..e013ecc9ac5e1474054463203477fa59525cf12d 100644 (file)
@@ -8,24 +8,25 @@ use package core.intrinsics.onyx { __initialize }
 State :: struct {
     data:   rawptr;
 
-    init:   (rawptr) -> void;
-    deinit: (rawptr) -> void;
-    enter:  (rawptr, ^State) -> void;
-    leave:  (rawptr) -> void;
-    update: (rawptr, dt: f32) -> void;
-    draw:   (rawptr) -> void;
+    init:   (rawptr) -> void          = null_proc;
+    deinit: (rawptr) -> void          = null_proc;
+    enter:  (rawptr, ^State) -> void  = null_proc;
+    leave:  (rawptr) -> void          = null_proc;
+    update: (rawptr, dt: f32) -> void = null_proc;
+    draw:   (rawptr) -> void          = null_proc;
 }
 
 #local state_stack: [..] State;
 
 push_game_state :: (state: type_expr, data: rawptr) -> ^State {
     s := array.alloc_one(^state_stack);
+    *s = .{ data };
+
     type_info.populate_struct_vtable(s, state, safe=false);
-    s.data = data;
 
     parent := array.get_ptr(state_stack, -2) if state_stack.count > 1 else null;
     if parent != null {
-        if parent.deinit != null_proc do parent.deinit(parent.data);
+        if parent.leave != null_proc do parent.leave(parent.data);
     }
 
     if s.init  != null_proc do s.init(s.data);