2022-10-25 09:23:44 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-02-10 11:20:50 +00:00
|
|
|
#include "window.h"
|
2022-10-25 09:23:44 +00:00
|
|
|
|
2023-02-13 11:12:04 +00:00
|
|
|
bool window_load(const char *encoded, window_t *window) {
|
2022-10-25 09:23:44 +00:00
|
|
|
float vals[4];
|
|
|
|
int i = 0;
|
|
|
|
char *token = strtok((char *)encoded, ",");
|
|
|
|
while (token != NULL) {
|
|
|
|
vals[i] = atof(token);
|
|
|
|
if (vals[i] < 0 || vals[i] > 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
token = strtok(NULL, ",");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i != 4) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-13 11:12:04 +00:00
|
|
|
window->x = vals[0];
|
|
|
|
window->y = vals[1];
|
|
|
|
window->width = vals[2];
|
|
|
|
window->height = vals[3];
|
|
|
|
|
2022-10-25 09:23:44 +00:00
|
|
|
return true;
|
|
|
|
}
|