From: Brendan Hansen Date: Tue, 5 Apr 2022 03:49:15 +0000 (-0500) Subject: bugfixes and "title" screen X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=cfe8e01fec99c479c3f0ef054f21927ae3b1ffb4;p=voxel-shooter.git bugfixes and "title" screen --- diff --git a/lib/onyx-net b/lib/onyx-net index 19f30f1..27c896c 160000 --- a/lib/onyx-net +++ b/lib/onyx-net @@ -1 +1 @@ -Subproject commit 19f30f1562238a0bbbb23acc249311a17361e36d +Subproject commit 27c896ce946092882f9665b1ec39f6a3d74c5094 diff --git a/src/client/connect_menu.onyx b/src/client/connect_menu.onyx index 7ae101a..ab7bf39 100644 --- a/src/client/connect_menu.onyx +++ b/src/client/connect_menu.onyx @@ -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..."); diff --git a/src/client/gfx/font.onyx b/src/client/gfx/font.onyx index 0cfcafb..d4b406c 100644 --- a/src/client/gfx/font.onyx +++ b/src/client/gfx/font.onyx @@ -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); diff --git a/src/client/gfx/ui.onyx b/src/client/gfx/ui.onyx index 8ee8ab2..48e7b9e 100644 --- a/src/client/gfx/ui.onyx +++ b/src/client/gfx/ui.onyx @@ -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) { diff --git a/src/client/main.onyx b/src/client/main.onyx index 6788676..e013ecc 100644 --- a/src/client/main.onyx +++ b/src/client/main.onyx @@ -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);