From: David Griffith Date: Sun, 30 Apr 2023 22:33:01 +0000 (-0700) Subject: Added save-restore prompt option to SDL interface with restriction to .aux. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=4b93c8360faf64cd434b74ffd8bd572bbd52ffb5;p=liskon_frotz.git Added save-restore prompt option to SDL interface with restriction to .aux. --- diff --git a/src/sdl/generic.c b/src/sdl/generic.c index cd833a1..e2e1f18 100644 --- a/src/sdl/generic.c +++ b/src/sdl/generic.c @@ -267,6 +267,7 @@ void os_warn(const char *s, ...) va_list va; char buf[1024]; int len; + int style; /* XXX Too lazy to do this right * (try again with a bigger buf if necessary). */ @@ -276,9 +277,10 @@ void os_warn(const char *s, ...) /* Solaris 2.6's cc complains if the below cast is missing */ print_c_string("\n\n"); os_beep(BEEP_HIGH); + style = os_get_text_style(); os_set_text_style(BOLDFACE_STYLE); print_c_string("Warning: "); - os_set_text_style(0); + os_set_text_style(NORMAL_STYLE); print_c_string((len < 0 ? s : buf)); print_c_string("\n"); if (len < 0) @@ -286,6 +288,7 @@ void os_warn(const char *s, ...) else if (len >= sizeof(buf)) print_c_string("(truncated)\n"); new_line(); + os_set_text_style(style); } diff --git a/src/sdl/sf_fonts.c b/src/sdl/sf_fonts.c index a1368ab..1d08e4c 100644 --- a/src/sdl/sf_fonts.c +++ b/src/sdl/sf_fonts.c @@ -635,6 +635,23 @@ void os_set_font(int new_font) } +/* + * os_get_text_style + * + * Return the current text style. Following flags can be set: + * + * REVERSE_STYLE + * BOLDFACE_STYLE + * EMPHASIS_STYLE (aka underline aka italics) + * FIXED_WIDTH_STYLE + * + */ +int os_get_text_style (void) +{ + return current.style; +} /* os_get_text_style */ + + /* * os_set_text_style * diff --git a/src/sdl/sf_images.c b/src/sdl/sf_images.c index 1c7ee89..0a5deea 100644 --- a/src/sdl/sf_images.c +++ b/src/sdl/sf_images.c @@ -227,7 +227,7 @@ static int loadpng(zbyte * data, int length, sf_picture * graphic) free(rowPointers); return 1; -} +} /* loadpng */ /**************************************************************************** * Loader for JPEG images @@ -410,7 +410,7 @@ static int sf_loadpic(int picture, sf_picture * graphic) if (st) graphic->number = picture; return st; -} +} /* sf_loadpic */ /******************* * CACHE diff --git a/src/sdl/sf_util.c b/src/sdl/sf_util.c index ff1d920..431fc9c 100644 --- a/src/sdl/sf_util.c +++ b/src/sdl/sf_util.c @@ -663,7 +663,14 @@ char *os_read_file_name(const char *default_name, int flag) * and our filename is already provided with the -L flag, * just go ahead silently. */ - if (f_setup.restore_mode) { + if (flag == FILE_NO_PROMPT) { + const char *ext = strrchr(default_name, '.'); + if (strncmp(ext, EXT_AUX, 4)) { + os_warn("Blocked unprompted access of %s. Should only be %s files.", default_name, EXT_AUX); + return NULL; + } else + strncpy(file_name, default_name, FILENAME_MAX); + } else if (f_setup.restore_mode) { strncpy(file_name, f_setup.save_name, FILENAME_MAX); } else { st = dialog_read_file_name(file_name, initname, flag);