From 77bbe4eddb95867063ac8ae6fb7e825cb15df7fd Mon Sep 17 00:00:00 2001 From: Ryan Baldwin Date: Sun, 7 May 2023 17:38:59 -0700 Subject: [PATCH] Default to backup plan if loading screen doesn't exist, add logic for PNG loading in Draw_CachePic --- Makefile.nx | 6 +++--- source/gl_draw.c | 15 +++++++++++++-- source/gl_screen.c | 38 ++++++++++++++++++++------------------ source/gl_texmgr.c | 23 ++++++++++++++++++++++- source/gl_texmgr.h | 1 + source/host.c | 4 ++-- 6 files changed, 61 insertions(+), 26 deletions(-) diff --git a/Makefile.nx b/Makefile.nx index 528c8ed..c223751 100644 --- a/Makefile.nx +++ b/Makefile.nx @@ -31,8 +31,8 @@ include $(DEVKITPRO)/libnx/switch_rules # - /default_icon.jpg #--------------------------------------------------------------------------------- APP_TITLE := NaziZombiesPortableNX -APP_AUTHOR := naievil -APP_VERSION := 0.1.0 +APP_AUTHOR := NZP Team +APP_VERSION := 1.0.0 ICON := assets/nx/icon.jpg TARGET := nzportable @@ -293,4 +293,4 @@ $(OFILES_SRC) : $(HFILES_BIN) #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- \ No newline at end of file +#--------------------------------------------------------------------------------------- diff --git a/source/gl_draw.c b/source/gl_draw.c index 1086225..6b91096 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -311,8 +311,10 @@ qpic_t *Draw_CachePic (const char *path) if (!strcmp (path, pic->name)) return &pic->pic; } + if (menu_numcachepics == MAX_CACHED_PICS) Sys_Error ("menu_numcachepics == MAX_CACHED_PICS"); + menu_numcachepics++; strcpy (pic->name, path); @@ -328,14 +330,23 @@ qpic_t *Draw_CachePic (const char *path) src_type = SRC_TGA; dat = (qpic_t *)LoadTGAPic(path_noext); - if (!dat) + if (!dat) { Host_Error ("Draw_CachePic: failed to load %s", path); + } + } else if (!strcmp("png", extension)) { + src_type = SRC_RGBA; + + dat = (qpic_t *)LoadPNGPic(path_noext); + if (!dat) { + Host_Error ("Draw_CachePic: failed to load %s", path); + } } else { src_type = SRC_INDEXED; dat = (qpic_t *)COM_LoadTempFile (path, NULL); - if (!dat) + if (!dat) { Host_Error ("Draw_CachePic: failed to load %s", path); + } SwapPic (dat); } diff --git a/source/gl_screen.c b/source/gl_screen.c index b33f9b7..59e5435 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -1221,6 +1221,7 @@ char *ReturnLoadingtex (void) return "wut wut"; } qboolean load_screen_exists; +char lpath[MAX_QPATH]; void SCR_DrawLoadScreen (void) { int max_step = 350; @@ -1231,29 +1232,31 @@ void SCR_DrawLoadScreen (void) if (!con_forcedup) return; + load_screen_exists = false; + if (loadingScreen) { if (!loadscreeninit) { - load_screen_exists = false; - - char* lpath; - lpath = (char*)Z_Malloc(sizeof(char)*32); - strcpy(lpath, "gfx/lscreen/"); - strcat(lpath, loadname2); - + sprintf(lpath, "gfx/lscreen/%s.png", loadname2); lscreen = Draw_CachePic(lpath); + //awoo = Draw_CachePic("gfx/menu/awoo.png"); - - if (lscreen == NULL) - { - lscreen = Draw_CachePic("gfx/lscreen/lscreen"); + + // naievil -- go to default loadingscreen + if (lscreen == NULL) { + sprintf(lpath, "gfx/lscreen/lscreen.png", loadname2); + lscreen = Draw_CachePic(lpath); + } + + // naievil -- if that fails, we need to not load anything + if (lscreen == NULL) { + load_screen_exists = false; + } else { + load_screen_exists = true; + loadscreeninit = true; } - load_screen_exists = true; - - loadscreeninit = true; } - if (load_screen_exists == true) - { + if (load_screen_exists == true) { #ifdef VITA Draw_StretchPic(0, 0, lscreen, vid.width, vid.height); #else @@ -1275,8 +1278,7 @@ void SCR_DrawLoadScreen (void) } - if (loadingtimechange < Sys_DoubleTime ()) - { + if (loadingtimechange < Sys_DoubleTime ()) { lodinglinetext = ReturnLoadingtex(); loadingtextwidth = strlen(lodinglinetext); //strlen(lodinglinetext)*8 loadingtimechange = Sys_DoubleTime () + 5; diff --git a/source/gl_texmgr.c b/source/gl_texmgr.c index b94b8a3..050901d 100644 --- a/source/gl_texmgr.c +++ b/source/gl_texmgr.c @@ -720,7 +720,28 @@ qpic_t *LoadTGAPic (char *path) byte *data; int w; int h; - char *lscreendefault; + + data = Image_LoadImage(path, &w, &h); + + // Build it into a qpic for easy return + + qpic_t *pic; + + pic = (qpic_t *) Hunk_Alloc (sizeof(qpic_t) - 4 + (4 * w * h)); + + pic->width = w; + pic->height = h; + memcpy(pic->data, data, (4 * w * h)); + + return pic; +} + + +qpic_t *LoadPNGPic (char *path) +{ + byte *data; + int w; + int h; data = Image_LoadImage(path, &w, &h); diff --git a/source/gl_texmgr.h b/source/gl_texmgr.h index 29bdc97..d34e6df 100644 --- a/source/gl_texmgr.h +++ b/source/gl_texmgr.h @@ -112,6 +112,7 @@ void GL_Bind (gltexture_t *texture); void GL_ClearBindings (void); qpic_t *LoadTGAPic (char *path); +qpic_t *LoadPNGPic (char *path); #endif /* _GL_TEXMAN_H */ diff --git a/source/host.c b/source/host.c index 576f2cd..7ea18b2 100644 --- a/source/host.c +++ b/source/host.c @@ -831,8 +831,8 @@ void Preload (void) { Mod_ForName ("models/player.mdl", true); - Mod_ForName("models/ai/zb#.mdl", true); - Mod_ForName("models/ai/zbc#.mdl", true); + Mod_ForName("models/ai/zb%.mdl", true); + Mod_ForName("models/ai/zbc%.mdl", true); Mod_ForName ("models/ai/zfull.mdl",true); Mod_ForName ("models/ai/zcfull.mdl",true); Mod_ForName ("models/ai/zh^.mdl",true);