From b03f979e87ae0e53dc7d4043e3ee9b32b22d9333 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 8 Nov 2024 00:13:49 -0500 Subject: [PATCH] Refactor yaze_project structure to use 'filepath' instead of 'filename' for clarity and improve project loading function --- src/yaze.cc | 12 ++++-------- src/yaze.h | 41 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/yaze.cc b/src/yaze.cc index 7f23f262..c3a42b9d 100644 --- a/src/yaze.cc +++ b/src/yaze.cc @@ -9,9 +9,7 @@ void yaze_check_version(const char* version) { printf("Yaze version: %s\n", version); auto version_check = yaze::app::core::CheckVersion(version); if (!version_check.ok()) { - // Print the error message to the console for a pure C interface. printf("%s\n", version_check.status().message().data()); - // Exit the program if the version check fails. exit(1); } return; @@ -40,11 +38,9 @@ void yaze_cleanup(yaze_flags* flags) { } } -yaze_project* yaze_load_project(const char* filename) { - yaze_project* project = new yaze_project(); - project->filename = filename; - project->rom = yaze_load_rom(filename); - project->overworld = yaze_load_overworld(project->rom); +yaze_project yaze_load_project(const char* filename) { + yaze_project project; + project.filepath = filename; return project; } @@ -122,4 +118,4 @@ z3_overworld* yaze_load_overworld(const z3_rom* rom) { map_id++; } return overworld; -} \ No newline at end of file +} diff --git a/src/yaze.h b/src/yaze.h index cb6f0ae0..02231f11 100644 --- a/src/yaze.h +++ b/src/yaze.h @@ -13,27 +13,13 @@ extern "C" { #include "incl/sprite.h" typedef struct z3_rom z3_rom; + typedef struct yaze_flags yaze_flags; typedef struct yaze_project yaze_project; typedef struct yaze_command_registry yaze_command_registry; - -/** - * @brief Command registry. - */ -struct yaze_command_registry { - void (*register_command)(const char* name, void (*command)(void)); -}; - typedef struct yaze_event_dispatcher yaze_event_dispatcher; -/** - * @brief Event dispatcher. - */ -struct yaze_event_dispatcher { - void (*register_event_hook)(void (*event_hook)(void)); -}; - typedef struct yaze_editor_context yaze_editor_context; /** @@ -75,13 +61,14 @@ void yaze_cleanup(yaze_flags*); * @brief Primitive of a Yaze project. */ struct yaze_project { - const char* filename; - - z3_rom* rom; - z3_overworld* overworld; + const char* name; + const char* filepath; + const char* rom_filename; + const char* code_folder; + const char* labels_filename; }; -yaze_project* yaze_load_project(const char* filename); +yaze_project yaze_load_project(const char* filename); /** * @brief Primitive of a Zelda3 ROM. @@ -111,6 +98,20 @@ snes_color yaze_get_color_from_paletteset(const z3_rom* rom, int palette_set, z3_overworld* yaze_load_overworld(const z3_rom* rom); +/** + * @brief Command registry. + */ +struct yaze_command_registry { + void (*register_command)(const char* name, void (*command)(void)); +}; + +/** + * @brief Event dispatcher. + */ +struct yaze_event_dispatcher { + void (*register_event_hook)(void (*event_hook)(void)); +}; + #ifdef __cplusplus } #endif