(formating)

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@46 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-10-20 16:59:55 +00:00
parent 8a6ba132b2
commit 8a533bb61f
4 changed files with 38 additions and 38 deletions
+26 -26
View File
@@ -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);
}