diff --git a/code/game/src/debug_replay.c b/code/game/src/debug_replay.c index 2bd9774..66d0087 100644 --- a/code/game/src/debug_replay.c +++ b/code/game/src/debug_replay.c @@ -21,7 +21,7 @@ void debug_replay_start(void) { is_recording = true; if (records) zpl_array_free(records); - zpl_array_init(records, zpl_heap()); + zpl_array_init_reserve(records, zpl_heap(), UINT16_MAX); last_record_time = zpl_time_rel_ms(); } @@ -30,11 +30,11 @@ void debug_replay_clear(void) { if (!records || is_playing || is_recording) return; zpl_array_free(records); records = NULL; + record_pos = 0; } void debug_replay_stop(void) { is_recording = false; - // TODO(zaklaus): } void debug_replay_run(void) { diff --git a/code/game/src/debug_ui.c b/code/game/src/debug_ui.c index 4975b0d..566ae97 100644 --- a/code/game/src/debug_ui.c +++ b/code/game/src/debug_ui.c @@ -1,5 +1,11 @@ #include "debug_ui.h" #include "raylib.h" +#include "vehicle.h" +#include "camera.h" +#include "world/world.h" +#include "game.h" + +#include "modules/components.h" typedef enum { DITEM_RAW, @@ -75,6 +81,8 @@ bool is_btn_pressed(float xpos, float ypos, float w, float h, Color *color); static void UIDrawText(const char *text, float posX, float posY, int fontSize, Color color); static int UIMeasureText(const char *text, int fontSize); +#include "debug_replay.c" + #include "debug_ui_widgets.c" #include "debug_ui_actions.c" @@ -108,6 +116,7 @@ static debug_item items[] = { .list = { .items = (debug_item[]) { { .kind = DITEM_TEXT, .name = "macro", .text = "", .proc = DrawLiteral }, + { .kind = DITEM_TEXT, .name = "samples", .proc = DrawReplaySamples }, { .kind = DITEM_BUTTON, .name = "load", .on_click = NULL }, { .kind = DITEM_BUTTON, .name = "save", .on_click = NULL }, diff --git a/code/game/src/debug_ui_actions.c b/code/game/src/debug_ui_actions.c index 217e6b0..26de526 100644 --- a/code/game/src/debug_ui_actions.c +++ b/code/game/src/debug_ui_actions.c @@ -1,13 +1,4 @@ #include "debug_ui.h" -#include "raylib.h" -#include "vehicle.h" -#include "camera.h" -#include "world/world.h" -#include "game.h" - -#include "modules/components.h" - -#include "debug_replay.c" static inline void ActExitGame(void) { diff --git a/code/game/src/debug_ui_widgets.c b/code/game/src/debug_ui_widgets.c index 6ee6138..ae4623a 100644 --- a/code/game/src/debug_ui_widgets.c +++ b/code/game/src/debug_ui_widgets.c @@ -60,3 +60,13 @@ DrawProfilerDelta(debug_item *it, float xpos, float ypos) { float dt = profiler_delta(it->val); return DrawFormattedText(xpos, ypos, TextFormat("%s: %.02f ms", profiler_name(it->val), dt * 1000.0f)); } + +static inline debug_draw_result +DrawReplaySamples(debug_item *it, float xpos, float ypos) { + (void)it; + size_t cnt = 0; + if (records) { + cnt = zpl_array_count(records); + } + return DrawFormattedText(xpos, ypos, TextFormat("%d of %d", record_pos, cnt)); +}