current split bar

main
sandyx 1 year ago
parent 952ea0a28b
commit c35cda4f9b

@ -11,18 +11,30 @@ void ctrl_pause(GHTimer *timer) {
}
void ctrl_start(ctrl_binder *cb) {
if (cb->timer_rta->running) {
if (cb->rec_sl != NULL) {
cb->live_sl->list[cb->current_segment]->realtime = ghtimer_time(cb->timer_rta);
if (cb->current_segment < cb->live_sl->cnt) {
cb->live_sl->list[cb->current_segment]->realtime = ghtimer_time(cb->timer_rta);
//need to add a condition for igt
} else {
goto STOP;
}
cb->current_segment++;
cb->sr->current = cb->current_segment;
} else {
STOP:
//increment run count
//ask user to save splits?
cb->current_segment = 0;
cb->sr->running = false;
cb->sr->current = cb->current_segment;
ghtimer_stop(cb->timer_rta); //stop or reset, save splits
}
//pause timer if last split
if (false) {
if (cb->current_segment == cb->live_sl->cnt) {
cb->sr->running = false;
ghtimer_pause(cb->timer_rta);
return;
}

@ -0,0 +1,21 @@
#ifndef LAYOUT_MGR_H
#define LAYOUT_MGR_H
#include <raylib.h>
#include <stdlib.h>
#include <stdbool.h>
extern int windowWidth;
extern int windowHeight;
typedef struct layout_background {
Texture2D texture;
Shader shader;
} layout_background;
layout_background *layout_background_new(Color color) {
Image blank = GenImageColor(windowWidth, windowHeight, BLANK);
Texture2D texture = LoadTextureFromImage(blank);
UnloadImage(blank);
}
#endif

@ -36,12 +36,15 @@ int main(int argc, char *argv[]) {
InitWindow(windowWidth, windowHeight, "Ghost");
SetTargetFPS(60);
//use libxml or something
segment_list segments = open_splits_file("test/splits.ghs");
GHTimer *timer = ghtimer_new();
//make a layout manager for these
timer_renderer *tr = create_timer_renderer(timer, (Vector2){0.0f, 90.0f}, (Vector2){(float)windowWidth, (float)windowHeight/8});
segment_renderer *sr = create_segment_renderer(&segments, 0.0f, 0.0f);
//layout manager
Image blank = GenImageColor(windowWidth, windowHeight, BLANK);
Texture2D texture = LoadTextureFromImage(blank);
Shader shader = LoadShader(0, "shaders/frag.glsl");
@ -68,13 +71,15 @@ int main(int argc, char *argv[]) {
BeginDrawing();
//BeginShaderMode(shader);
ClearBackground(RAYWHITE);
ClearBackground(BLACK);
//DrawTexture(texture, 0, 0, WHITE);
//EndShaderMode();
render_timer(tr);
//need to make this not weird
render_segments(sr);
render_timer(tr);
EndShaderMode();
EndDrawing();
EndDrawing();
}
ghtimer_delete(timer);

@ -33,6 +33,8 @@ void render_segments(segment_renderer *sr) {
BeginShaderMode(*sr->shader);
}
//need to not draw it if its the last split
//or if the timer isnt running
if (sr->running) {
DrawRectangle(0, (sr->current) * 30, windowWidth, (float)font.baseSize/16, BLUE);
}
@ -46,6 +48,6 @@ void render_segments(segment_renderer *sr) {
for (int i = 0; i < sr->count; i++) {
DrawTextEx(font, sr->seglist->list[i]->name, (Vector2){10, 30 * i}, (float)font.baseSize/16, 2, BLACK);
DrawTextEx(font, time_unparse(sr->strfmt, FMT_SIZE, &sr->seglist->list[i]->realtime), (Vector2){200, 30 * i}, (float)font.baseSize/16, 2, BLACK);
DrawTextEx(font, time_unparse(sr->strfmt, FMT_SIZE, &sr->seglist->list[i]->realtime), (Vector2){200, 30 * i}, (float)font.baseSize/16, 2, BLACK);
}
}

@ -17,7 +17,7 @@ extern char *time_unparse(char *buffer, size_t len, struct timespec *ts);
typedef struct timer_renderer {
GHTimer *timer;
//Font font;
Font font;
Vector2 pos;
Vector2 size;
bool running;

Loading…
Cancel
Save