can delete save, do not delete autosave when dead pc

This commit is contained in:
Ondrej Novak 2025-03-09 17:30:58 +01:00
parent 4ea74f3b15
commit 8faba63219
5 changed files with 51 additions and 26 deletions

View file

@ -1848,18 +1848,24 @@ void do_autosave() {
DEFAULT_GAME_NAME(""); DEFAULT_GAME_NAME("");
char prefix[50]; char prefix[50];
snprintf(prefix,50,"sav.%08lx.",current_campaign); snprintf(prefix,50,"sav.%08lx.",current_campaign);
TSAVEGAME_CB_STATE st; char isdead = 0;
st.files = create_list(32); for (int i = 0; i < POCET_POSTAV; ++i) {
st.prefix = prefix; isdead = isdead || (postavy[i].used && postavy[i].lives == 0 && postavy[i].inmaphash == current_map_hash);
st.prefix_len = strlen(prefix); }
st.count = 0; if (!isdead) {
st.skip_autosave = 0; TSAVEGAME_CB_STATE st;
list_files(gpathtable[SR_SAVES], file_type_just_name|file_type_need_timestamp|file_type_normal, get_all_savegames_callback, &st); st.files = create_list(32);
for (size_t i = 0; i < st.count; ++i) { st.prefix = prefix;
const char *n = st.files[i]; st.prefix_len = strlen(prefix);
if (strstr(n, AUTOSAVE_SUFFIX)) { st.count = 0;
remove(build_pathname(2, gpathtable[SR_SAVES],n)); st.skip_autosave = 0;
} list_files(gpathtable[SR_SAVES], file_type_just_name|file_type_need_timestamp|file_type_normal, get_all_savegames_callback, &st);
for (size_t i = 0; i < st.count; ++i) {
const char *n = st.files[i];
if (strstr(n, AUTOSAVE_SUFFIX)) {
remove(build_pathname(2, gpathtable[SR_SAVES],n));
}
}
} }
save_game(get_save_game_slot_id(), game_name,1); save_game(get_save_game_slot_id(), game_name,1);
} }
@ -1906,7 +1912,8 @@ static void save_as_dialog(int pos) {
todel = local_strdup(todel); todel = local_strdup(todel);
} }
unwire_proc(); unwire_proc();
if (ask_save_dialog(game_name, sizeof(game_name))) { char r = ask_save_dialog(game_name, sizeof(game_name), todel != NULL);
if (r==1) {
prev_game_time_save = cur_time; prev_game_time_save = cur_time;
save_game(get_save_game_slot_id(), game_name,0); save_game(get_save_game_slot_id(), game_name,0);
if (todel) { if (todel) {
@ -1914,6 +1921,8 @@ static void save_as_dialog(int pos) {
} }
wire_proc(); wire_proc();
return; return;
} else if (r == 2 && todel) {
remove(todel);
} }
wire_save_load(1); wire_save_load(1);
} }

View file

@ -1413,7 +1413,7 @@ void load_map_description(TMPFILE_RD *f);
void free_map_description(); void free_map_description();
void wire_save_load(char save); void wire_save_load(char save);
void do_save_dialog(); void do_save_dialog();
char ask_save_dialog(char *name_buffer, size_t name_size); char ask_save_dialog(char *name_buffer, size_t name_size, char allow_remove);
void do_autosave(); void do_autosave();
#define autosave() if (autosave_enabled) do_autosave(); #define autosave() if (autosave_enabled) do_autosave();
extern char autosave_enabled; extern char autosave_enabled;

View file

@ -1602,7 +1602,7 @@ THAGGLERESULT smlouvat_dlg(int cena,int puvod,int pocet,int posledni, int money,
return res; return res;
} }
char ask_save_dialog(char *name_buffer, size_t name_size) { char ask_save_dialog(char *name_buffer, size_t name_size, char allow_remove) {
const char *str_label = texty[98]; const char *str_label = texty[98];
// if (str_label == 0) str_label ="Ulo\x91it hru jako"; // if (str_label == 0) str_label ="Ulo\x91it hru jako";
@ -1613,11 +1613,14 @@ char ask_save_dialog(char *name_buffer, size_t name_size) {
define(10,10,30,270,13,0,input_line,name_size-1);property(def_border(5,BAR_COLOR),NULL,NULL,0);set_default(name_buffer); define(10,10,30,270,13,0,input_line,name_size-1);property(def_border(5,BAR_COLOR),NULL,NULL,0);set_default(name_buffer);
define(20,20,20,60,20,2,button,texty[239]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui); define(20,20,20,60,20,2,button,texty[239]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
define(30,90,20,60,20,2,button,texty[80]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui); define(30,90,20,60,20,2,button,texty[80]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
if (allow_remove) {
define(40,10,20,70,20,3,button,texty[172]);property(def_border(5,BAR_COLOR),NULL,NULL,BAR_COLOR);on_control_change(terminate_gui);
}
redraw_window(); redraw_window();
goto_control(10); goto_control(10);
escape(); escape();
get_value(0,10,name_buffer); get_value(0,10,name_buffer);
char ret = o_aktual->id==30; char ret = o_aktual->id==40?2:o_aktual->id==30?1:0;
close_current(); close_current();
return ret; return ret;

View file

@ -711,7 +711,7 @@ void done_skeldal(void)
close_manager(); close_manager();
close_story_file(); close_story_file();
purge_temps(1); temp_storage_clear();
stop_mixing(); stop_mixing();
// deinstall_mouse_handler(); // deinstall_mouse_handler();
if (texty != NULL) { if (texty != NULL) {
@ -805,7 +805,7 @@ void cti_texty(void)
//patch stringtable //patch stringtable
if (!texty[98]) str_replace(&texty,98,"Ulo\x91it hru jako"); if (!texty[98]) str_replace(&texty,98,"Ulo\x91it hru jako");
if (!texty[99]) str_replace(&texty,99,"CRT Filter (>720p)"); if (!texty[99]) str_replace(&texty,99,"CRT Filter (>720p)");
str_replace(&texty,0,"Byl detekov\xA0n ovlada\x87\nPro aktivaci ovlada\x87""e stiskn\x88te kt\x82rekoliv tla\x87\xA1tko na ovlada\x87i"); str_replace(&texty,0,"Byl nalezen p\xA9ipojen\x98 ovlada\x87\nPro aktivaci ovlada\x87""e stiskn\x88te kt\x82rekoliv tla\x87\xA1tko na ovlada\x87i");
lang_patch_stringtable(&texty, "ui.csv", ""); lang_patch_stringtable(&texty, "ui.csv", "");
} }
@ -945,14 +945,13 @@ void show_joystick_info(void) {
curcolor = 0; curcolor = 0;
bar32(0,0,639,479); set_font(H_FBOLD, RGB888(255,255,255));
set_font(H_FBOLD, NOSHADOW(RGB888(255,255,255)));
const char *prompt = texty[0]; const char *prompt = texty[0];
char *buff = (char *)alloca(strlen(prompt)+10); char *buff = (char *)alloca(strlen(prompt)+10);
int xs = 0; int xs = 0;
int ys = 0; int ys = 0;
zalamovani(prompt,buff,560, &xs, &ys); zalamovani(prompt,buff,560, &xs, &ys);
int y = 320; int y = 100;
while (*buff) { while (*buff) {
set_aligned_position(320,y,1,1,buff); set_aligned_position(320,y,1,1,buff);
outtext(buff); outtext(buff);
@ -972,6 +971,18 @@ void show_joystick_info(void) {
} }
void show_loading_picture(char *filename)
{
const void *p;
int32_t s;
p=afile(filename,SR_BGRAFIKA,&s);
put_picture(0,0,p);
showview(0,0,0,0);
ablock_free(p);
}
void init_skeldal(const INI_CONFIG *cfg) void init_skeldal(const INI_CONFIG *cfg)
{ {
@ -995,6 +1006,7 @@ void init_skeldal(const INI_CONFIG *cfg)
atexit(done_skeldal); atexit(done_skeldal);
init_DDL_manager(); init_DDL_manager();
show_loading_picture("LOADING.HI");
if (lang_get_folder()) { if (lang_get_folder()) {
texty_knihy = build_pathname(2, lang_get_folder(), "book.txt"); texty_knihy = build_pathname(2, lang_get_folder(), "book.txt");
@ -1742,6 +1754,7 @@ int skeldal_entry_point(const SKELDAL_CONFIG *start_cfg)
closemode(); closemode();
ini_close(cfg); ini_close(cfg);
return 0; return 0;

View file

@ -55,18 +55,18 @@ void init_joystick(const INI_CONFIG_SECTION *section) {
cfg.buttons[10] = SDLContext::JoystickButton::mod_key; cfg.buttons[10] = SDLContext::JoystickButton::mod_key;
cfg.buttons_mod[10] = SDLContext::JoystickButton::mod_key; cfg.buttons_mod[10] = SDLContext::JoystickButton::mod_key;
cfg.buttons[11] = SDLContext::JoystickButton::map; cfg.buttons[11] = SDLContext::JoystickButton::map;
cfg.buttons_mod[11] = SDLContext::JoystickButton::F6;
cfg.buttons[12] = SDLContext::JoystickButton::merge; cfg.buttons[12] = SDLContext::JoystickButton::merge;
cfg.buttons[14] = SDLContext::JoystickButton::left; cfg.buttons[14] = SDLContext::JoystickButton::left;
cfg.buttons[13] = SDLContext::JoystickButton::right; cfg.buttons[13] = SDLContext::JoystickButton::right;
cfg.buttons[9] = SDLContext::JoystickButton::backspace; cfg.buttons[9] = SDLContext::JoystickButton::backspace;
cfg.buttons_mod[5] = SDLContext::JoystickButton::escape; cfg.buttons_mod[5] = SDLContext::JoystickButton::escape;
cfg.buttons_mod[9] = SDLContext::JoystickButton::F4; cfg.buttons_mod[9] = SDLContext::JoystickButton::F4;
cfg.buttons_mod[12] = SDLContext::JoystickButton::F7; cfg.buttons_mod[14] = SDLContext::JoystickButton::F6;
cfg.buttons_mod[0] = SDLContext::JoystickButton::F8; cfg.buttons_mod[2] = SDLContext::JoystickButton::F7;
cfg.buttons_mod[3] = SDLContext::JoystickButton::F8;
cfg.buttons_mod[1] = SDLContext::JoystickButton::F9; cfg.buttons_mod[1] = SDLContext::JoystickButton::F9;
cfg.buttons_mod[2] = SDLContext::JoystickButton::F10; cfg.buttons_mod[0] = SDLContext::JoystickButton::F10;
cfg.buttons_mod[3] = SDLContext::JoystickButton::F11; cfg.buttons_mod[11] = SDLContext::JoystickButton::F11;
cfg.buttons_mod[14] = SDLContext::JoystickButton::F12; cfg.buttons_mod[14] = SDLContext::JoystickButton::F12;
cfg.buttons_mod[13] = SDLContext::JoystickButton::backspace; cfg.buttons_mod[13] = SDLContext::JoystickButton::backspace;
cfg.enabled = true; cfg.enabled = true;