Added Package::saveCopy, which is used to implement the write_set_file script function.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1169 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-08-24 19:48:51 +00:00
parent 2a4a896540
commit 42d40dbd1e
12 changed files with 119 additions and 32 deletions
+3 -3
View File
@@ -48,12 +48,12 @@ String export_formats(const Game& game) {
return type_strings;
}
void export_set(Set& set, const String& filename, size_t format_type) {
FileFormatP format = file_formats.at(format_type);
void export_set(Set& set, const String& filename, size_t format_index, bool is_copy) {
FileFormatP format = file_formats.at(format_index);
if (!format->canExport(*set.game)) {
throw InternalError(_("File format doesn't apply to set"));
}
format->exportSet(set, filename);
format->exportSet(set, filename, is_copy);
}
SetP import_set(String name) {
+4 -3
View File
@@ -37,7 +37,8 @@ class FileFormat : public IntrusivePtrVirtualBase {
throw InternalError(_("Import not supported by this file format"));
}
/// Export using this filter
virtual void exportSet(Set& set, const String& filename) {
/** If is_copy, then the set should not be modified */
virtual void exportSet(Set& set, const String& filename, bool is_copy = false) {
throw InternalError(_("Export not supported by this file format"));
}
};
@@ -71,9 +72,9 @@ String export_formats(const Game& game);
SetP import_set(String name);
/// Save a set under the specified name.
/** filterType specifies what format to use for saving, used as index in the list of file formats
/** format_index specifies what format to use for saving, used as index in the list of file formats
*/
void export_set(Set& set, const String& filename, size_t format_type);
void export_set(Set& set, const String& filename, size_t format_index, bool is_copy = false);
// ----------------------------------------------------------------------------- : The formats
+8 -4
View File
@@ -26,10 +26,14 @@ class MSE2FileFormat : public FileFormat {
settings.addRecentFile(filename);
return set;
}
virtual void exportSet(Set& set, const String& filename) {
set.saveAs(filename);
settings.addRecentFile(filename);
set.actions.setSavePoint();
virtual void exportSet(Set& set, const String& filename, bool is_copy) {
if (is_copy) {
set.saveCopy(filename);
} else {
set.saveAs(filename);
settings.addRecentFile(filename);
set.actions.setSavePoint();
}
}
};