Refactor yaze_project structure to use 'filepath' instead of 'filename' for clarity and improve project loading function
This commit is contained in:
12
src/yaze.cc
12
src/yaze.cc
@@ -9,9 +9,7 @@ void yaze_check_version(const char* version) {
|
|||||||
printf("Yaze version: %s\n", version);
|
printf("Yaze version: %s\n", version);
|
||||||
auto version_check = yaze::app::core::CheckVersion(version);
|
auto version_check = yaze::app::core::CheckVersion(version);
|
||||||
if (!version_check.ok()) {
|
if (!version_check.ok()) {
|
||||||
// Print the error message to the console for a pure C interface.
|
|
||||||
printf("%s\n", version_check.status().message().data());
|
printf("%s\n", version_check.status().message().data());
|
||||||
// Exit the program if the version check fails.
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -40,11 +38,9 @@ void yaze_cleanup(yaze_flags* flags) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
yaze_project* yaze_load_project(const char* filename) {
|
yaze_project yaze_load_project(const char* filename) {
|
||||||
yaze_project* project = new yaze_project();
|
yaze_project project;
|
||||||
project->filename = filename;
|
project.filepath = filename;
|
||||||
project->rom = yaze_load_rom(filename);
|
|
||||||
project->overworld = yaze_load_overworld(project->rom);
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,4 +118,4 @@ z3_overworld* yaze_load_overworld(const z3_rom* rom) {
|
|||||||
map_id++;
|
map_id++;
|
||||||
}
|
}
|
||||||
return overworld;
|
return overworld;
|
||||||
}
|
}
|
||||||
|
|||||||
41
src/yaze.h
41
src/yaze.h
@@ -13,27 +13,13 @@ extern "C" {
|
|||||||
#include "incl/sprite.h"
|
#include "incl/sprite.h"
|
||||||
|
|
||||||
typedef struct z3_rom z3_rom;
|
typedef struct z3_rom z3_rom;
|
||||||
|
|
||||||
typedef struct yaze_flags yaze_flags;
|
typedef struct yaze_flags yaze_flags;
|
||||||
typedef struct yaze_project yaze_project;
|
typedef struct yaze_project yaze_project;
|
||||||
|
|
||||||
typedef struct yaze_command_registry yaze_command_registry;
|
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;
|
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;
|
typedef struct yaze_editor_context yaze_editor_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,13 +61,14 @@ void yaze_cleanup(yaze_flags*);
|
|||||||
* @brief Primitive of a Yaze project.
|
* @brief Primitive of a Yaze project.
|
||||||
*/
|
*/
|
||||||
struct yaze_project {
|
struct yaze_project {
|
||||||
const char* filename;
|
const char* name;
|
||||||
|
const char* filepath;
|
||||||
z3_rom* rom;
|
const char* rom_filename;
|
||||||
z3_overworld* overworld;
|
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.
|
* @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);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user