mirror of
https://github.com/zoriya/Gamacon.git
synced 2026-06-05 04:39:37 +00:00
Adding an error message for callbacks that do not exists
This commit is contained in:
@@ -18,7 +18,6 @@ struct gc_scene
|
||||
{
|
||||
gc_list *data;
|
||||
void *(*get_data)(gc_scene *scene, const char *type, const char *name);
|
||||
void (*add_callback)(gc_scene *scene, const char *name, void *func);
|
||||
|
||||
void (*destroy)(gc_scene *scene);
|
||||
|
||||
@@ -37,6 +36,5 @@ callback_t scene_get_callback(gc_scene *scene, char *name);
|
||||
gc_scene *scene_create(gc_engine *engine, const char *mappath);
|
||||
void scene_load_data(gc_engine *engine, gc_scene *scene, node *n);
|
||||
void *scene_get_data(gc_scene *scene, const char *type, const char *name);
|
||||
void scene_add_callback(gc_scene *scene, const char *name, void *func);
|
||||
void scene_destroy(gc_scene *scene);
|
||||
void scene_load_entity(gc_scene *this, gc_engine *engine, node *n, int prefab);
|
||||
@@ -16,20 +16,28 @@ static void ctr(void *component, va_list args)
|
||||
struct clickable_component *cmp = (struct clickable_component *)component;
|
||||
gc_scene *scene = va_arg(args, gc_scene *);
|
||||
char *onclick = va_arg(args, char *);
|
||||
callback_t callback;
|
||||
|
||||
if (!scene)
|
||||
return;
|
||||
cmp->onclick = scene->get_callback(scene, onclick);
|
||||
callback = scene->get_callback(scene, onclick);
|
||||
if (!callback)
|
||||
my_printf("No callback found with the name: %s\n", onclick);
|
||||
cmp->onclick = callback;
|
||||
}
|
||||
|
||||
static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
||||
{
|
||||
struct clickable_component *cmp = (struct clickable_component *)component;
|
||||
char *onclick = xml_gettempprop(n, "click");
|
||||
callback_t callback;
|
||||
|
||||
if (!scene)
|
||||
return;
|
||||
cmp->onclick = scene->get_callback(scene, onclick);
|
||||
callback = scene->get_callback(scene, onclick);
|
||||
if (!callback)
|
||||
my_printf("No callback found with the name: %s\n", onclick);
|
||||
cmp->onclick = callback;
|
||||
}
|
||||
|
||||
static void dtr(void *component)
|
||||
|
||||
Reference in New Issue
Block a user