Refactor Yaze initialization and cleanup functions to use yaze_editor_context

This commit is contained in:
scawful
2024-11-10 22:50:57 -05:00
parent 6e7f99f520
commit 3601fe4026
2 changed files with 12 additions and 10 deletions

View File

@@ -15,26 +15,26 @@ void yaze_check_version(const char* version) {
return; return;
} }
int yaze_init(yaze_flags* flags) { int yaze_init(yaze_editor_context* yaze_ctx) {
if (flags == nullptr) { if (yaze_ctx->flags == nullptr) {
return -1; return -1;
} }
if (flags->rom_filename == nullptr) { if (yaze_ctx->flags->rom_filename == nullptr) {
return -1; return -1;
} }
flags->rom = yaze_load_rom(flags->rom_filename); yaze_ctx->flags->rom = yaze_load_rom(yaze_ctx->flags->rom_filename);
if (flags->rom == nullptr) { if (yaze_ctx->flags->rom == nullptr) {
return -1; return -1;
} }
return 0; return 0;
} }
void yaze_cleanup(yaze_flags* flags) { void yaze_cleanup(yaze_editor_context* yaze_ctx) {
if (flags->rom) { if (yaze_ctx->flags->rom) {
yaze_unload_rom(flags->rom); yaze_unload_rom(yaze_ctx->flags->rom);
} }
} }

View File

@@ -8,6 +8,7 @@ extern "C" {
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "incl/dungeon.h"
#include "incl/overworld.h" #include "incl/overworld.h"
#include "incl/snes_color.h" #include "incl/snes_color.h"
#include "incl/sprite.h" #include "incl/sprite.h"
@@ -27,6 +28,7 @@ typedef struct yaze_editor_context yaze_editor_context;
*/ */
struct yaze_editor_context { struct yaze_editor_context {
yaze_project* project; yaze_project* project;
yaze_flags* flags;
yaze_command_registry* command_registry; yaze_command_registry* command_registry;
yaze_event_dispatcher* event_dispatcher; yaze_event_dispatcher* event_dispatcher;
@@ -48,14 +50,14 @@ void yaze_check_version(const char* version);
* *
* @param flags Flags to initialize the library. * @param flags Flags to initialize the library.
*/ */
int yaze_init(yaze_flags*); int yaze_init(yaze_editor_context*);
/** /**
* @brief Clean up the Yaze library. * @brief Clean up the Yaze library.
* *
* @param flags Flags used to initialize the library. * @param flags Flags used to initialize the library.
*/ */
void yaze_cleanup(yaze_flags*); void yaze_cleanup(yaze_editor_context*);
/** /**
* @brief Primitive of a Yaze project. * @brief Primitive of a Yaze project.