From 39bacf95084b16021919c3ff18cdf6ca71e94fc9 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sun, 20 Nov 2022 20:37:17 +0000 Subject: [PATCH] fixes --- source/engine/editor.c | 27 ++++++++++++++++++--------- source/engine/sound.h | 2 +- source/engine/texture.c | 6 ++++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/source/engine/editor.c b/source/engine/editor.c index cf624c1..b0918fc 100644 --- a/source/engine/editor.c +++ b/source/engine/editor.c @@ -504,16 +504,27 @@ void editor_project_gui() { } if (nk_button_label(ctx, "Save")) { - save_level(current_level); - get_levels(); + if (strlen(current_level) == 0) { + YughWarn("Can't save level that has no name."); + } else { + save_level(current_level); + get_levels(); + } } if (nk_button_label(ctx, "Save as")) { - strcpy(current_level, levelname); - strncat(current_level, EXT_LEVEL, MAXNAME); - save_level(current_level); - levelname[0] = '\0'; - get_levels(); + if (strlen(current_level) == 0) { + YughWarn("Can't save level that has no name."); + } else { + strcpy(current_level, levelname); + strncat(current_level, EXT_LEVEL, MAXNAME); + save_level(current_level); + levelname[0] = '\0'; + get_levels(); + + + + } } nuke_nel(1); nk_edit_string_zero_terminated(ctx, NK_EDIT_SIMPLE, levelname, MAXNAME - 1, nk_filter_default); @@ -994,8 +1005,6 @@ void editor_prefab_btn(char *prefab) { if (nk_button_label(ctx, prefab)) { YughInfo("Making prefab '%s'.", prefab); gameobject_makefromprefab(prefab); - /*GameObject* newprefab = (GameObject*)createPrefab(*prefab); */ - /*cam_inverse_goto(&camera, &newprefab->transform); */ } } diff --git a/source/engine/sound.h b/source/engine/sound.h index 5e519bc..095d235 100644 --- a/source/engine/sound.h +++ b/source/engine/sound.h @@ -23,7 +23,7 @@ struct soundstream { }; struct soundconvstream { - // SDL_AudioStream *srconv; + // SDL_AudioStream *srconv; void *data; }; diff --git a/source/engine/texture.c b/source/engine/texture.c index edfa381..bbb3716 100644 --- a/source/engine/texture.c +++ b/source/engine/texture.c @@ -13,6 +13,8 @@ static struct { struct Texture *value; } *texhash = NULL; +struct Texture *tex_default; + struct Texture *texture_pullfromfile(const char *path) { int index = shgeti(texhash, path); @@ -63,8 +65,8 @@ struct Texture *texture_loadfromfile(const char *path) struct Texture *new = texture_pullfromfile(path); if (new == NULL) { - YughError("Texture not loaded!", 0); - return new; + YughError("Texture %s not loaded! Loading the default instead ...", path); + new = texture_pullfromfile("./ph.png"); } if (new->id == 0) {