mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
(formating)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@46 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+26
-26
@@ -15,56 +15,56 @@ DECLARE_TYPEOF_COLLECTION(FileFormatP);
|
||||
// ----------------------------------------------------------------------------- : Formats
|
||||
|
||||
// All supported file formats
|
||||
vector<FileFormatP> fileFormats;
|
||||
vector<FileFormatP> file_formats;
|
||||
|
||||
void initFileFormats() {
|
||||
//fileFormats.push_back(new_shared<MSE2FileFilter>());
|
||||
//fileFormats.push_back(new_shared<MSE1FileFilter>());
|
||||
//fileFormats.push_back(new_shared<MtgEditorFileFilter>());
|
||||
void init_file_formats() {
|
||||
//file_formats.push_back(new_shared<MSE2FileFilter>());
|
||||
//file_formats.push_back(new_shared<MSE1FileFilter>());
|
||||
//file_formats.push_back(new_shared<MtgEditorFileFilter>());
|
||||
}
|
||||
|
||||
String importFormats() {
|
||||
String allExtensions; // type1;type2
|
||||
String typeStrings; // |name1|type1|name2|type2
|
||||
FOR_EACH(f, fileFormats) {
|
||||
String import_formats() {
|
||||
String all_extensions; // type1;type2
|
||||
String type_strings; // |name1|type1|name2|type2
|
||||
FOR_EACH(f, file_formats) {
|
||||
if (f->canImport()) {
|
||||
if (!allExtensions.empty()) allExtensions += _(";");
|
||||
allExtensions += _("*.") + f->extension();
|
||||
typeStrings += _("|") + f->name() + _("|*.") + f->extension();
|
||||
if (!all_extensions.empty()) all_extensions += _(";");
|
||||
all_extensions += _("*.") + f->extension();
|
||||
type_strings += _("|") + f->name() + _("|*.") + f->extension();
|
||||
}
|
||||
}
|
||||
return _("Set files|") + allExtensions + typeStrings + _("|All files (*.*)|*.*");
|
||||
return _("Set files|") + all_extensions + type_strings + _("|All files (*.*)|*.*");
|
||||
}
|
||||
|
||||
String exportFormats(const Game& game) {
|
||||
String typeStrings; // name1|type1|name2|type2
|
||||
FOR_EACH(f, fileFormats) {
|
||||
String export_formats(const Game& game) {
|
||||
String type_strings; // name1|type1|name2|type2
|
||||
FOR_EACH(f, file_formats) {
|
||||
if (f->canExport(game)) {
|
||||
if (!typeStrings.empty()) typeStrings += _("|");
|
||||
typeStrings += f->name() + _("|*.") + f->extension();
|
||||
if (!type_strings.empty()) type_strings += _("|");
|
||||
type_strings += f->name() + _("|*.") + f->extension();
|
||||
}
|
||||
}
|
||||
return typeStrings;
|
||||
return type_strings;
|
||||
}
|
||||
|
||||
void exportSet(const Set& set, const String& filename, size_t formatType) {
|
||||
FileFormatP format = fileFormats.at(formatType);
|
||||
void export_set(const Set& set, const String& filename, size_t format_type) {
|
||||
FileFormatP format = file_formats.at(format_type);
|
||||
if (!format->canExport(*set.game)) {
|
||||
throw InternalError(_("File format doesn't apply to set"));
|
||||
}
|
||||
format->exportSet(set, filename);
|
||||
}
|
||||
|
||||
SetP importSet(String name) {
|
||||
SetP import_set(String name) {
|
||||
size_t pos = name.find_last_of(_('.'));
|
||||
String extension = pos==String::npos ? _("") : name.substr(pos + 1);
|
||||
// determine format
|
||||
FOR_EACH(f, fileFormats) {
|
||||
FOR_EACH(f, file_formats) {
|
||||
if (f->extension() == extension) {
|
||||
return f->importSet(name);
|
||||
}
|
||||
}
|
||||
// default : use first format = MSE2 format
|
||||
assert(!fileFormats.empty() && fileFormats[0]->canImport());
|
||||
return fileFormats[0]->importSet(name);
|
||||
// default: use first format = MSE2 format
|
||||
assert(!file_formats.empty() && file_formats[0]->canImport());
|
||||
return file_formats[0]->importSet(name);
|
||||
}
|
||||
@@ -42,18 +42,18 @@ class FileFormat {
|
||||
|
||||
/// Initialize the list of file formats
|
||||
/** Must be called before any other methods of this header */
|
||||
void initFileFormats();
|
||||
void init_file_formats();
|
||||
|
||||
/// List of supported import formats
|
||||
/** Formated as _("All supported (type1,...)|type1,...|name|type|...|All files(*.*)|*.*").
|
||||
* For use in file selection dialogs.
|
||||
*/
|
||||
String importFormats();
|
||||
String import_formats();
|
||||
|
||||
// List of supported export formats that a set in a specific game can be exported.
|
||||
/** Similair format as importFormats, except for _('all supported') and _('all files')
|
||||
/** Similair format as importFormats, except for 'all supported' and 'all files'
|
||||
*/
|
||||
String exportFormats(const Game& game);
|
||||
String export_formats(const Game& game);
|
||||
|
||||
/// Opens a set with the specified filename.
|
||||
/** File format is chosen based on the extension, default is fileFormats[0]
|
||||
@@ -64,12 +64,12 @@ String exportFormats(const Game& game);
|
||||
* changing the recent set list could change the filename while we are opening it
|
||||
* (which would be bad)
|
||||
*/
|
||||
SetP importSet(String name);
|
||||
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
|
||||
*/
|
||||
void exportSet(const Set& set, const String& filename, size_t formatType);
|
||||
void export_set(const Set& set, const String& filename, size_t format_type);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Export
|
||||
|
||||
|
||||
Reference in New Issue
Block a user