add repetitions

This commit is contained in:
rick 2022-12-19 15:48:33 +01:00
parent e2013f94df
commit f6da60fd6a
Signed by: Rick
GPG key ID: 4A6223D66294EB20
3 changed files with 23 additions and 3 deletions

View file

@ -10,7 +10,7 @@ extern "C" {
#include "ui.h"
}
#define WIDTH 400
#define WIDTH 425
#define HEIGHT 200
void glfw_logger(int error, const char *desc)

View file

@ -3,6 +3,7 @@
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "read_events.h"
#include "read_file.h"
@ -18,6 +19,8 @@ ui_infos * init_ui(const char *name)
ret->file = fopen(name, "w+");
ret->is_recording = 0;
ret->args_rf = args_rf_init(ret->file, 1);
ret->nb_loop = 0;
ret->sleep_loop = 0;
return ret;
}
@ -79,10 +82,23 @@ int draw_ui(ui_infos *ptr)
igInputInt("Temps de repos entre chaque clic (s)", &ptr->args_rf->time_sleep, 1, 10, 0);
if (ptr->args_rf->time_sleep <= 0) ptr->args_rf->time_sleep = 1;
igSetNextItemWidth(100.0);
igInputInt("Nombre de répétitions du fichier", &ptr->nb_loop, 1, 10, 0);
if (ptr->nb_loop < 0) ptr->nb_loop = 0;
igSetNextItemWidth(100.0);
igInputInt("Temps de repos entre chaque répétition (s)", &ptr->sleep_loop, 1, 10, 0);
if (ptr->sleep_loop < 0) ptr->sleep_loop = 0;
if (igButton("Replay", zero_vec2))
{
rewind(ptr->file);
readfile(ptr->args_rf);
int i;
for (i = 0; i <= ptr->nb_loop; i++)
{
rewind(ptr->file);
readfile(ptr->args_rf);
sleep(ptr->sleep_loop);
}
}
}

View file

@ -9,6 +9,10 @@ typedef struct {
char is_recording;
pthread_t pid;
args_readfile *args_rf;
/* Number of repetition */
int nb_loop;
/* Sleep in s between each repetition */
int sleep_loop;
} ui_infos;
ui_infos * init_ui(const char *name);