1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-05-28 20:14:06 +00:00

improved handling of missing models/images

This commit is contained in:
Zeno Rogue 2022-04-07 21:06:47 +02:00
parent d075987fa4
commit e318410bff
3 changed files with 16 additions and 4 deletions

View File

@ -17,7 +17,7 @@ char peek(fhstream& fs) {
bool model::available() { bool model::available() {
if(av_checked) return is_available; if(av_checked) return is_available;
av_checked = true; av_checked = true;
is_available = false; is_available = file_exists(path + fname);
return false; return false;
} }

View File

@ -1015,10 +1015,19 @@ slide dmv_slides[] = {
"(the animation is not included with RogueViz)" "(the animation is not included with RogueViz)"
, ,
[] (presmode mode) { [] (presmode mode) {
static bool pic_exists, video_exists;
if(mode == pmStartAll || mode == pmStart) {
pic_exists = file_exists("rogueviz/nil/emty-ring.png");
video_exists = file_exists("rogueviz/nil/emty-ring.mp4");
}
slide_url(mode, 'i', "Instagram link", "https://www.instagram.com/p/B756GCynErw/"); slide_url(mode, 'i', "Instagram link", "https://www.instagram.com/p/B756GCynErw/");
empty_screen(mode); empty_screen(mode);
// show_picture(mode, "rogueviz/nil/emty-ring.png"); if(video_exists)
// show_animation(mode, "rogueviz/nil/emty-ring.mp4", 720, 900, 300, 30); show_animation(mode, "rogueviz/nil/emty-ring.mp4", 720, 900, 300, 30);
else if(pic_exists)
show_picture(mode, "rogueviz/nil/emty-ring.png");
else
slide_error(mode, "(image not available)");
no_other_hud(mode); no_other_hud(mode);
} }
}, },

View File

@ -163,7 +163,10 @@ void read_all(int fd, void *buf, int cnt) {
/* note: this loads the whole animation uncompressed into memory, so it is suitable only for short presentations */ /* note: this loads the whole animation uncompressed into memory, so it is suitable only for short presentations */
void show_animation(presmode mode, string s, int sx, int sy, int frames, int fps) { void show_animation(presmode mode, string s, int sx, int sy, int frames, int fps) {
#if CAP_VIDEO #if CAP_VIDEO
if(mode == pmStartAll) { if(mode == pmStartAll || mode == pmStart) {
/* load only once */
if(textures.count(s + "@0")) return;
/* actually load */
array<int, 2> tab; array<int, 2> tab;
if(pipe(&tab[0])) { if(pipe(&tab[0])) {
addMessage(format("Error: %s", strerror(errno))); addMessage(format("Error: %s", strerror(errno)));