Default to backup plan if loading screen doesn't exist, add logic for PNG loading in Draw_CachePic

This commit is contained in:
Ryan Baldwin 2023-05-07 17:38:59 -07:00
parent b0fdf9436a
commit 77bbe4eddb
6 changed files with 61 additions and 26 deletions

View File

@ -31,8 +31,8 @@ include $(DEVKITPRO)/libnx/switch_rules
# - <libnx folder>/default_icon.jpg # - <libnx folder>/default_icon.jpg
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
APP_TITLE := NaziZombiesPortableNX APP_TITLE := NaziZombiesPortableNX
APP_AUTHOR := naievil APP_AUTHOR := NZP Team
APP_VERSION := 0.1.0 APP_VERSION := 1.0.0
ICON := assets/nx/icon.jpg ICON := assets/nx/icon.jpg
TARGET := nzportable TARGET := nzportable

View File

@ -311,8 +311,10 @@ qpic_t *Draw_CachePic (const char *path)
if (!strcmp (path, pic->name)) if (!strcmp (path, pic->name))
return &pic->pic; return &pic->pic;
} }
if (menu_numcachepics == MAX_CACHED_PICS) if (menu_numcachepics == MAX_CACHED_PICS)
Sys_Error ("menu_numcachepics == MAX_CACHED_PICS"); Sys_Error ("menu_numcachepics == MAX_CACHED_PICS");
menu_numcachepics++; menu_numcachepics++;
strcpy (pic->name, path); strcpy (pic->name, path);
@ -328,14 +330,23 @@ qpic_t *Draw_CachePic (const char *path)
src_type = SRC_TGA; src_type = SRC_TGA;
dat = (qpic_t *)LoadTGAPic(path_noext); dat = (qpic_t *)LoadTGAPic(path_noext);
if (!dat) if (!dat) {
Host_Error ("Draw_CachePic: failed to load %s", path); 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 { } else {
src_type = SRC_INDEXED; src_type = SRC_INDEXED;
dat = (qpic_t *)COM_LoadTempFile (path, NULL); dat = (qpic_t *)COM_LoadTempFile (path, NULL);
if (!dat) if (!dat) {
Host_Error ("Draw_CachePic: failed to load %s", path); Host_Error ("Draw_CachePic: failed to load %s", path);
}
SwapPic (dat); SwapPic (dat);
} }

View File

@ -1221,6 +1221,7 @@ char *ReturnLoadingtex (void)
return "wut wut"; return "wut wut";
} }
qboolean load_screen_exists; qboolean load_screen_exists;
char lpath[MAX_QPATH];
void SCR_DrawLoadScreen (void) void SCR_DrawLoadScreen (void)
{ {
int max_step = 350; int max_step = 350;
@ -1231,29 +1232,31 @@ void SCR_DrawLoadScreen (void)
if (!con_forcedup) if (!con_forcedup)
return; return;
load_screen_exists = false;
if (loadingScreen) { if (loadingScreen) {
if (!loadscreeninit) { if (!loadscreeninit) {
load_screen_exists = false; sprintf(lpath, "gfx/lscreen/%s.png", loadname2);
char* lpath;
lpath = (char*)Z_Malloc(sizeof(char)*32);
strcpy(lpath, "gfx/lscreen/");
strcat(lpath, loadname2);
lscreen = Draw_CachePic(lpath); lscreen = Draw_CachePic(lpath);
//awoo = Draw_CachePic("gfx/menu/awoo.png"); //awoo = Draw_CachePic("gfx/menu/awoo.png");
if (lscreen == NULL) // naievil -- go to default loadingscreen
{ if (lscreen == NULL) {
lscreen = Draw_CachePic("gfx/lscreen/lscreen"); sprintf(lpath, "gfx/lscreen/lscreen.png", loadname2);
lscreen = Draw_CachePic(lpath);
} }
load_screen_exists = true;
loadscreeninit = true; // naievil -- if that fails, we need to not load anything
if (lscreen == NULL) {
load_screen_exists = false;
} else {
load_screen_exists = true;
loadscreeninit = true;
}
} }
if (load_screen_exists == true) if (load_screen_exists == true) {
{
#ifdef VITA #ifdef VITA
Draw_StretchPic(0, 0, lscreen, vid.width, vid.height); Draw_StretchPic(0, 0, lscreen, vid.width, vid.height);
#else #else
@ -1275,8 +1278,7 @@ void SCR_DrawLoadScreen (void)
} }
if (loadingtimechange < Sys_DoubleTime ()) if (loadingtimechange < Sys_DoubleTime ()) {
{
lodinglinetext = ReturnLoadingtex(); lodinglinetext = ReturnLoadingtex();
loadingtextwidth = strlen(lodinglinetext); //strlen(lodinglinetext)*8 loadingtextwidth = strlen(lodinglinetext); //strlen(lodinglinetext)*8
loadingtimechange = Sys_DoubleTime () + 5; loadingtimechange = Sys_DoubleTime () + 5;

View File

@ -720,7 +720,28 @@ qpic_t *LoadTGAPic (char *path)
byte *data; byte *data;
int w; int w;
int h; 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); data = Image_LoadImage(path, &w, &h);

View File

@ -112,6 +112,7 @@ void GL_Bind (gltexture_t *texture);
void GL_ClearBindings (void); void GL_ClearBindings (void);
qpic_t *LoadTGAPic (char *path); qpic_t *LoadTGAPic (char *path);
qpic_t *LoadPNGPic (char *path);
#endif /* _GL_TEXMAN_H */ #endif /* _GL_TEXMAN_H */

View File

@ -831,8 +831,8 @@ void Preload (void)
{ {
Mod_ForName ("models/player.mdl", true); Mod_ForName ("models/player.mdl", true);
Mod_ForName("models/ai/zb#.mdl", true); Mod_ForName("models/ai/zb%.mdl", true);
Mod_ForName("models/ai/zbc#.mdl", true); Mod_ForName("models/ai/zbc%.mdl", true);
Mod_ForName ("models/ai/zfull.mdl",true); Mod_ForName ("models/ai/zfull.mdl",true);
Mod_ForName ("models/ai/zcfull.mdl",true); Mod_ForName ("models/ai/zcfull.mdl",true);
Mod_ForName ("models/ai/zh^.mdl",true); Mod_ForName ("models/ai/zh^.mdl",true);