From 8a533bb61f7d13979314b07cbb347d3447ad9282 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 20 Oct 2006 16:59:55 +0000 Subject: [PATCH] (formating) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@46 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/format/formats.cpp | 52 ++++++++++++++++++------------------- src/data/format/formats.hpp | 12 ++++----- src/gui/set/window.cpp | 10 +++---- src/main.cpp | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/data/format/formats.cpp b/src/data/format/formats.cpp index 0fc80a99..c0c9b761 100644 --- a/src/data/format/formats.cpp +++ b/src/data/format/formats.cpp @@ -15,56 +15,56 @@ DECLARE_TYPEOF_COLLECTION(FileFormatP); // ----------------------------------------------------------------------------- : Formats // All supported file formats -vector fileFormats; +vector file_formats; -void initFileFormats() { - //fileFormats.push_back(new_shared()); - //fileFormats.push_back(new_shared()); - //fileFormats.push_back(new_shared()); +void init_file_formats() { + //file_formats.push_back(new_shared()); + //file_formats.push_back(new_shared()); + //file_formats.push_back(new_shared()); } -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); } \ No newline at end of file diff --git a/src/data/format/formats.hpp b/src/data/format/formats.hpp index 40ae7e52..b0cf4890 100644 --- a/src/data/format/formats.hpp +++ b/src/data/format/formats.hpp @@ -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 diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 3cb8d90a..183ea349 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -294,7 +294,7 @@ bool SetWindow::askSaveAndContinue() { /* try { if (set->needSaveAs()) { // need save as - FileDialog dlg(&this, _("Save a set"), _(""), _(""), exportFormats(set->game), wxSAVE | wxOVERWRITE_PROMPT); + FileDialog dlg(&this, _("Save a set"), _(""), _(""), export_formats(set->game), wxSAVE | wxOVERWRITE_PROMPT); if (dlg.showModal() == wxID_OK) { exportSet(set, dlg.path, dlg.filterIndex); return true; @@ -374,9 +374,9 @@ void SetWindow::onFileNew(wxCommandEvent&) { void SetWindow::onFileOpen(wxCommandEvent&) { if (!askSaveAndContinue()) return; - wxFileDialog dlg(this, _("Open a set"), _(""), _(""), importFormats(), wxOPEN); + wxFileDialog dlg(this, _("Open a set"), _(""), _(""), import_formats(), wxOPEN); if (dlg.ShowModal() == wxID_OK) { - set = importSet(dlg.GetPath()); + set = import_set(dlg.GetPath()); } } @@ -391,9 +391,9 @@ void SetWindow::onFileSave(wxCommandEvent& ev) { } void SetWindow::onFileSaveAs(wxCommandEvent&) { - wxFileDialog dlg(this, _("Save a set"), _(""), _(""), exportFormats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); + wxFileDialog dlg(this, _("Save a set"), _(""), _(""), export_formats(*set->game), wxSAVE | wxOVERWRITE_PROMPT); if (dlg.ShowModal() == wxID_OK) { - exportSet(*set, dlg.GetPath(), dlg.GetFilterIndex()); + export_set(*set, dlg.GetPath(), dlg.GetFilterIndex()); } } diff --git a/src/main.cpp b/src/main.cpp index ee92eee9..ca6c0647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,7 +37,7 @@ IMPLEMENT_APP(MSE) bool MSE::OnInit() { try { wxInitAllImageHandlers(); - initFileFormats(); + init_file_formats(); settings.read(); //Window* wnd = new SymbolWindow(nullptr); //GameP g = Game::byName(_("magic"))