Keep opened files
This commit is contained in:
parent
d515575612
commit
1dcefb2895
@ -138,6 +138,9 @@ extern char svf_pass[64];
|
||||
extern char svf_user_id[64];
|
||||
extern char svf_session_id[64];
|
||||
|
||||
|
||||
extern char svf_filename[255];
|
||||
extern int svf_fileopen;
|
||||
extern int svf_open;
|
||||
extern int svf_own;
|
||||
extern int svf_myvote;
|
||||
|
@ -41,6 +41,8 @@ int svf_open = 0;
|
||||
int svf_own = 0;
|
||||
int svf_myvote = 0;
|
||||
int svf_publish = 0;
|
||||
char svf_filename[255] = "";
|
||||
int svf_fileopen = 0;
|
||||
char svf_id[16] = "";
|
||||
char svf_name[64] = "";
|
||||
char svf_description[255] = "";
|
||||
@ -636,15 +638,18 @@ void draw_svf_ui(pixel *vid_buf, int alternate)// all the buttons at the bottom
|
||||
}
|
||||
|
||||
// the reload button
|
||||
c = svf_open ? 255 : 128;
|
||||
c = (svf_open || svf_fileopen) ? 255 : 128;
|
||||
drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255);
|
||||
drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255);
|
||||
|
||||
// the save sim button
|
||||
if(alternate)
|
||||
if(alternate || svf_fileopen)
|
||||
{
|
||||
fillrect(vid_buf, 36, YRES+(MENUSIZE-16)-1, 152, 16, 255, 255, 255, 255);
|
||||
drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", 0, 0, 0, 255);
|
||||
if(svf_fileopen)
|
||||
drawtext(vid_buf, 58, YRES+(MENUSIZE-12), svf_filename, 0, 0, 0, 255);
|
||||
else
|
||||
drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[save to disk]", 0, 0, 0, 255);
|
||||
} else {
|
||||
c = svf_login ? 255 : 128;
|
||||
@ -1666,6 +1671,8 @@ int save_name_ui(pixel *vid_buf)
|
||||
svf_open = 1;
|
||||
svf_own = 1;
|
||||
svf_publish = cb.checked;
|
||||
svf_filename[0] = 0;
|
||||
svf_fileopen = 0;
|
||||
free(old_vid);
|
||||
return nd+1;
|
||||
}
|
||||
@ -3628,12 +3635,16 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
svf_tags[0] = 0;
|
||||
}
|
||||
svf_myvote = info->myvote;
|
||||
svf_filename[0] = 0;
|
||||
svf_fileopen = 0;
|
||||
retval = 1;
|
||||
break;
|
||||
} else {
|
||||
queue_open = 0;
|
||||
|
||||
svf_open = 0;
|
||||
svf_filename[0] = 0;
|
||||
svf_fileopen = 0;
|
||||
svf_publish = 0;
|
||||
svf_own = 0;
|
||||
svf_myvote = 0;
|
||||
@ -5220,6 +5231,11 @@ int save_filename_ui(pixel *vid_buf)
|
||||
ed.multiline = 0;
|
||||
ed.str[0] = 0;
|
||||
|
||||
if(svf_fileopen){
|
||||
strncpy(ed.str, svf_filename, 255);
|
||||
ed.cursor = strlen(ed.str);
|
||||
}
|
||||
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
@ -5264,8 +5280,10 @@ int save_filename_ui(pixel *vid_buf)
|
||||
if(b && !bq)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
char *savefname = malloc(strlen(ed.str)+5);
|
||||
char *filename = malloc(strlen(LOCAL_SAVE_DIR)+strlen(PATH_SEP)+strlen(ed.str)+5);
|
||||
sprintf(filename, "%s%s%s.cps", LOCAL_SAVE_DIR, PATH_SEP, ed.str);
|
||||
sprintf(savefname, "%s.cps", ed.str);
|
||||
|
||||
#ifdef WIN32
|
||||
_mkdir(LOCAL_SAVE_DIR);
|
||||
@ -5285,6 +5303,11 @@ int save_filename_ui(pixel *vid_buf)
|
||||
{
|
||||
fwrite(save_data, save_size, 1, f);
|
||||
fclose(f);
|
||||
if(svf_fileopen)
|
||||
{
|
||||
strncpy(svf_filename, savefname, 255);
|
||||
svf_fileopen = 1;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
error_ui(vid_buf, 0, "Unable to write to save file.");
|
||||
@ -5448,6 +5471,9 @@ void catalogue_ui(pixel * vid_buf)
|
||||
status = parse_save(data, size, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
||||
if(!status)
|
||||
{
|
||||
//svf_filename[0] = 0;
|
||||
strncpy(svf_filename, csave->name, 255);
|
||||
svf_fileopen = 1;
|
||||
svf_open = 0;
|
||||
svf_publish = 0;
|
||||
svf_own = 0;
|
||||
@ -5456,9 +5482,13 @@ void catalogue_ui(pixel * vid_buf)
|
||||
svf_name[0] = 0;
|
||||
svf_description[0] = 0;
|
||||
svf_tags[0] = 0;
|
||||
svf_last = data;
|
||||
data = NULL;
|
||||
svf_lsize = size;
|
||||
goto openfin;
|
||||
} else {
|
||||
error_ui(vid_buf, 0, "Save data corrupt");
|
||||
free(data);
|
||||
}
|
||||
} else {
|
||||
error_ui(vid_buf, 0, "Unable to read save file");
|
||||
|
@ -2875,6 +2875,8 @@ int main(int argc, char *argv[])
|
||||
pfree = 0;
|
||||
|
||||
legacy_enable = 0;
|
||||
svf_filename[0] = 0;
|
||||
svf_fileopen = 0;
|
||||
svf_myvote = 0;
|
||||
svf_open = 0;
|
||||
svf_publish = 0;
|
||||
@ -2940,7 +2942,7 @@ int main(int argc, char *argv[])
|
||||
memset(fire_b, 0, sizeof(fire_b));
|
||||
}
|
||||
}
|
||||
if (x>=19 && x<=35 && svf_last && svf_open && !bq) {
|
||||
if (x>=19 && x<=35 && svf_last && (svf_open || svf_fileopen) && !bq) {
|
||||
//int tpval = sys_pause;
|
||||
parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
|
||||
//sys_pause = tpval;
|
||||
|
Reference in New Issue
Block a user