diff --git a/src/font.c b/src/font.c index 534c668..5a5cc5c 100644 --- a/src/font.c +++ b/src/font.c @@ -10,7 +10,7 @@ font_t font_create(char *font_name, char *filename) { char errbuf[200]; map_t *map; - printf("Processing %s...\n", font_name); + printf(" Processing %s...\n", font_name); fp = fopen(filename, "r"); diff --git a/src/main.c b/src/main.c index 829ed9d..d6bcbe2 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,7 @@ #include #include "util.h" +#include "script.h" #define ERRBUFSZ 200 @@ -37,5 +38,11 @@ int main(int argc, char **argv) { error("missing key: name", ""); } - printf("Preparing to process %s...\n", name.u.s); + printf("Processing game %s...\n", name.u.s); + toml_array_t *scripts = toml_array_in(conf, "script"); + + for (int i = 0; ; i++) { + toml_table_t *toml_script = toml_table_at(scripts, i); + script_t script = script_create(toml_script); + } } diff --git a/src/script.c b/src/script.c index 2fc030e..ec8f3dc 100644 --- a/src/script.c +++ b/src/script.c @@ -11,9 +11,11 @@ script_t script_create(toml_table_t *table) { #define TOML_GET_KEY(var, key, func) toml_datum_t (var) = func(table, (key));\ if (!(var).ok) {\ char str[200];\ - snprintf(str, 200, "key '%s' missing from", (key)); \ - error(str, filename.u.s); \ + snprintf(str, 200, "key '%s' missing", (key)); \ + error(str, ""); \ } + TOML_GET_KEY(name, "name", toml_string_in) + printf(" Processing script %s...\n", name.u.s); TOML_GET_KEY(filename, "filename", toml_string_in) TOML_GET_KEY(font_name, "font", toml_string_in) TOML_GET_KEY(min_tiles, "min_tiles_per_line", toml_int_in) diff --git a/src/script.h b/src/script.h index 337f3aa..88ff22e 100644 --- a/src/script.h +++ b/src/script.h @@ -7,6 +7,7 @@ #include "font.h" typedef struct { + char *name; char *filename; font_t font; char *format; @@ -20,4 +21,7 @@ typedef struct { bool little_endian; } script_t; +script_t script_create(toml_table_t *table); +void script_destroy(script_t script); + #endif