Add a "copy" option to the save_as_mainfile operator. It saves the current
state but does not make the saved file active, so further save won't use this filepath.
This commit is contained in:
@@ -78,7 +78,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type);
|
||||
int WM_read_homefile (struct bContext *C, struct wmOperator *op);
|
||||
int WM_write_homefile (struct bContext *C, struct wmOperator *op);
|
||||
void WM_read_file (struct bContext *C, char *name, struct ReportList *reports);
|
||||
int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports);
|
||||
int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy);
|
||||
void WM_read_autosavefile(struct bContext *C);
|
||||
void WM_autosave_init (struct wmWindowManager *wm);
|
||||
|
||||
|
@@ -566,7 +566,7 @@ int write_crash_blend(void)
|
||||
}
|
||||
}
|
||||
|
||||
int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
|
||||
int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy)
|
||||
{
|
||||
Library *li;
|
||||
int len;
|
||||
@@ -620,11 +620,13 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports)
|
||||
do_history(di, reports);
|
||||
|
||||
if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) {
|
||||
strcpy(G.sce, di);
|
||||
G.relbase_valid = 1;
|
||||
strcpy(G.main->name, di); /* is guaranteed current file */
|
||||
|
||||
G.save_over = 1; /* disable untitled.blend convention */
|
||||
if(!copy) {
|
||||
strcpy(G.sce, di);
|
||||
G.relbase_valid = 1;
|
||||
strcpy(G.main->name, di); /* is guaranteed current file */
|
||||
|
||||
G.save_over = 1; /* disable untitled.blend convention */
|
||||
}
|
||||
|
||||
if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS;
|
||||
else G.fileflags &= ~G_FILE_COMPRESS;
|
||||
|
@@ -1783,6 +1783,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char path[FILE_MAX];
|
||||
int fileflags;
|
||||
int copy=0;
|
||||
|
||||
save_set_compress(op);
|
||||
|
||||
@@ -1793,6 +1794,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
|
||||
untitled(path);
|
||||
}
|
||||
|
||||
if(RNA_property_is_set(op->ptr, "copy"))
|
||||
copy = RNA_boolean_get(op->ptr, "copy");
|
||||
|
||||
fileflags= G.fileflags;
|
||||
|
||||
/* set compression flag */
|
||||
@@ -1801,7 +1805,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
|
||||
if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP;
|
||||
else fileflags &= ~G_FILE_RELATIVE_REMAP;
|
||||
|
||||
if ( WM_write_file(C, path, fileflags, op->reports) != 0)
|
||||
if ( WM_write_file(C, path, fileflags, op->reports, copy) != 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
|
||||
@@ -1822,6 +1826,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
|
||||
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");
|
||||
RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory");
|
||||
RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active.");
|
||||
}
|
||||
|
||||
/* *************** save file directly ******** */
|
||||
@@ -1873,7 +1878,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
|
||||
RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
|
||||
}
|
||||
|
||||
|
||||
/* XXX: move these collada operators to a more appropriate place */
|
||||
#ifdef WITH_COLLADA
|
||||
|
||||
|
Reference in New Issue
Block a user