mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
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:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user