replay: add more debug features

isolation_bkp/dynres
Dominik Madarász 2021-08-10 18:09:17 +02:00
parent 6274bb34b0
commit 3c46cca96d
4 changed files with 21 additions and 11 deletions

View File

@ -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) {

View File

@ -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 = "<unnamed>", .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 },

View File

@ -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) {

View File

@ -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));
}