summaryrefslogtreecommitdiff
path: root/src/interface.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-06-25 15:59:25 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-06-25 15:59:25 (GMT)
commit1dcefb2895eea8ea5e09e11f0f639d50693cfb96 (patch)
tree85bda7f4786bc424b740ea23ff00dc0e20d35078 /src/interface.c
parentd515575612ef26e183d5fcf0ab4a04c38cb9a26e (diff)
downloadpowder-1dcefb2895eea8ea5e09e11f0f639d50693cfb96.zip
powder-1dcefb2895eea8ea5e09e11f0f639d50693cfb96.tar.gz
Keep opened files
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/interface.c b/src/interface.c
index a85ea1f..f67bfe6 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -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,16 +638,19 @@ 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);
- drawtext(vid_buf, 58, YRES+(MENUSIZE-12), "[save to disk]", 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;
drawtext(vid_buf, 40, YRES+(MENUSIZE-14), "\x82", c, c, c, 255);
@@ -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;
@@ -5219,6 +5230,11 @@ int save_filename_ui(pixel *vid_buf)
ed.cursor = 0;
ed.multiline = 0;
ed.str[0] = 0;
+
+ if(svf_fileopen){
+ strncpy(ed.str, svf_filename, 255);
+ ed.cursor = strlen(ed.str);
+ }
while (!sdl_poll())
{
@@ -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");