Commit ecf5f834 authored by twanvl's avatar twanvl

Incremented version number to 0.3.7

When saving files an older version number is used if that version of MSE would be able to open the set
parent 0936f635
...@@ -20,6 +20,7 @@ ExportTemplate::ExportTemplate() ...@@ -20,6 +20,7 @@ ExportTemplate::ExportTemplate()
String ExportTemplate::typeNameStatic() { return _("export-template"); } String ExportTemplate::typeNameStatic() { return _("export-template"); }
String ExportTemplate::typeName() const { return _("export-template"); } String ExportTemplate::typeName() const { return _("export-template"); }
Version ExportTemplate::fileVersion() const { return file_version_export_template; }
void ExportTemplate::validate(Version) { void ExportTemplate::validate(Version) {
if (!game) { if (!game) {
......
...@@ -35,6 +35,7 @@ class ExportTemplate : public Packaged { ...@@ -35,6 +35,7 @@ class ExportTemplate : public Packaged {
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
Version fileVersion() const;
virtual void validate(Version = app_version); virtual void validate(Version = app_version);
private: private:
DECLARE_REFLECTION(); DECLARE_REFLECTION();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
template <typename T> template <typename T>
String serialize_for_clipboard(Package& package, T& object) { String serialize_for_clipboard(Package& package, T& object) {
shared_ptr<wxStringOutputStream> stream( new wxStringOutputStream ); shared_ptr<wxStringOutputStream> stream( new wxStringOutputStream );
Writer writer(stream); Writer writer(stream, file_version_clipboard);
WITH_DYNAMIC_ARG(clipboard_package, &package); WITH_DYNAMIC_ARG(clipboard_package, &package);
writer.handle(object); writer.handle(object);
return stream->GetString(); return stream->GetString();
......
...@@ -39,6 +39,7 @@ bool Game::isMagic() const { ...@@ -39,6 +39,7 @@ bool Game::isMagic() const {
String Game::typeNameStatic() { return _("game"); } String Game::typeNameStatic() { return _("game"); }
String Game::typeName() const { return _("game"); } String Game::typeName() const { return _("game"); }
Version Game::fileVersion() const { return file_version_game; }
IMPLEMENT_REFLECTION(Game) { IMPLEMENT_REFLECTION(Game) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
......
...@@ -69,6 +69,7 @@ class Game : public Packaged { ...@@ -69,6 +69,7 @@ class Game : public Packaged {
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
Version fileVersion() const;
protected: protected:
virtual void validate(Version); virtual void validate(Version);
......
...@@ -35,6 +35,7 @@ DECLARE_POINTER_TYPE(wxZipInputStream); ...@@ -35,6 +35,7 @@ DECLARE_POINTER_TYPE(wxZipInputStream);
// ----------------------------------------------------------------------------- : Installer // ----------------------------------------------------------------------------- : Installer
String Installer::typeName() const { return _("installer"); } String Installer::typeName() const { return _("installer"); }
Version Installer::fileVersion() const { return file_version_installer; }
IMPLEMENT_REFLECTION(Installer) { IMPLEMENT_REFLECTION(Installer) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
......
...@@ -45,6 +45,7 @@ class Installer : public Packaged { ...@@ -45,6 +45,7 @@ class Installer : public Packaged {
protected: protected:
String typeName() const; String typeName() const;
Version fileVersion() const;
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -28,6 +28,7 @@ DECLARE_TYPEOF(map<String COMMA SubLocaleP>); ...@@ -28,6 +28,7 @@ DECLARE_TYPEOF(map<String COMMA SubLocaleP>);
LocaleP the_locale; LocaleP the_locale;
String Locale::typeName() const { return _("locale"); } String Locale::typeName() const { return _("locale"); }
Version Locale::fileVersion() const { return file_version_locale; }
LocaleP Locale::byName(const String& name) { LocaleP Locale::byName(const String& name) {
return package_manager.open<Locale>(name + _(".mse-locale")); return package_manager.open<Locale>(name + _(".mse-locale"));
......
...@@ -51,6 +51,7 @@ class Locale : public Packaged { ...@@ -51,6 +51,7 @@ class Locale : public Packaged {
protected: protected:
String typeName() const; String typeName() const;
Version fileVersion() const;
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -119,6 +119,7 @@ String Set::identification() const { ...@@ -119,6 +119,7 @@ String Set::identification() const {
String Set::typeName() const { return _("set"); } String Set::typeName() const { return _("set"); }
Version Set::fileVersion() const { return file_version_set; }
// fix values for versions < 0.2.7 // fix values for versions < 0.2.7
void fix_value_207(const ValueP& value) { void fix_value_207(const ValueP& value) {
......
...@@ -113,6 +113,7 @@ class Set : public Packaged { ...@@ -113,6 +113,7 @@ class Set : public Packaged {
void clearOrderCache(); void clearOrderCache();
virtual String typeName() const; virtual String typeName() const;
Version fileVersion() const;
/// Validate that the set is correctly loaded /// Validate that the set is correctly loaded
virtual void validate(Version = app_version); virtual void validate(Version = app_version);
......
...@@ -277,6 +277,6 @@ void Settings::read() { ...@@ -277,6 +277,6 @@ void Settings::read() {
} }
void Settings::write() { void Settings::write() {
Writer writer(new_shared1<wxFileOutputStream>(settingsFile())); Writer writer(new_shared1<wxFileOutputStream>(settingsFile()), app_version);
writer.handle(*this); writer.handle(*this);
} }
...@@ -63,6 +63,7 @@ String StyleSheet::stylesheetName() const { ...@@ -63,6 +63,7 @@ String StyleSheet::stylesheetName() const {
String StyleSheet::typeNameStatic() { return _("style"); } String StyleSheet::typeNameStatic() { return _("style"); }
String StyleSheet::typeName() const { return _("style"); } String StyleSheet::typeName() const { return _("style"); }
Version StyleSheet::fileVersion() const { return file_version_stylesheet; }
void StyleSheet::validate(Version ver) { void StyleSheet::validate(Version ver) {
Packaged::validate(ver); Packaged::validate(ver);
......
...@@ -64,6 +64,7 @@ class StyleSheet : public Packaged { ...@@ -64,6 +64,7 @@ class StyleSheet : public Packaged {
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
Version fileVersion() const;
/// Validate the stylesheet /// Validate the stylesheet
virtual void validate(Version = app_version); virtual void validate(Version = app_version);
......
...@@ -40,6 +40,7 @@ SymbolFont::~SymbolFont() { ...@@ -40,6 +40,7 @@ SymbolFont::~SymbolFont() {
String SymbolFont::typeNameStatic() { return _("symbol-font"); } String SymbolFont::typeNameStatic() { return _("symbol-font"); }
String SymbolFont::typeName() const { return _("symbol-font"); } String SymbolFont::typeName() const { return _("symbol-font"); }
Version SymbolFont::fileVersion() const { return file_version_symbol_font; }
SymbolFontP SymbolFont::byName(const String& name) { SymbolFontP SymbolFont::byName(const String& name) {
return package_manager.open<SymbolFont>( return package_manager.open<SymbolFont>(
......
...@@ -70,6 +70,7 @@ class SymbolFont : public Packaged { ...@@ -70,6 +70,7 @@ class SymbolFont : public Packaged {
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
Version fileVersion() const;
/// Generate a 'insert symbol' menu. /// Generate a 'insert symbol' menu.
/** This class owns the menu! /** This class owns the menu!
......
...@@ -237,7 +237,7 @@ void SymbolWindow::onFileSave(wxCommandEvent& ev) { ...@@ -237,7 +237,7 @@ void SymbolWindow::onFileSave(wxCommandEvent& ev) {
void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) { void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) {
String name = wxFileSelector(_("Save symbol"),_(""),_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this); String name = wxFileSelector(_("Save symbol"),_(""),_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this);
if (!name.empty()) { if (!name.empty()) {
Writer writer(new_shared1<wxFileOutputStream>(name)); Writer writer(new_shared1<wxFileOutputStream>(name), file_version_symbol);
writer.handle(control->getSymbol()); writer.handle(control->getSymbol());
} }
} }
...@@ -247,7 +247,7 @@ void SymbolWindow::onFileStore(wxCommandEvent& ev) { ...@@ -247,7 +247,7 @@ void SymbolWindow::onFileStore(wxCommandEvent& ev) {
SymbolValueP value = static_pointer_cast<SymbolValue>(performer->value); SymbolValueP value = static_pointer_cast<SymbolValue>(performer->value);
Package& package = performer->getLocalPackage(); Package& package = performer->getLocalPackage();
FileName new_filename = package.newFileName(value->field().name,_(".mse-symbol")); // a new unique name in the package FileName new_filename = package.newFileName(value->field().name,_(".mse-symbol")); // a new unique name in the package
Writer writer(package.openOut(new_filename)); Writer writer(package.openOut(new_filename), file_version_symbol);
writer.handle(control->getSymbol()); writer.handle(control->getSymbol());
performer->addAction(value_action(value, new_filename)); performer->addAction(value_action(value, new_filename));
} }
......
...@@ -193,15 +193,15 @@ expected_locale_keys TEXT "../common/expected_locale_keys" ...@@ -193,15 +193,15 @@ expected_locale_keys TEXT "../common/expected_locale_keys"
// -------------------------------------------------------- : Version info // -------------------------------------------------------- : Version info
1 VERSIONINFO 1 VERSIONINFO
FILEVERSION 0,3,6,1 FILEVERSION 0,3,7,0
PRODUCTVERSION 0,3,6,1 PRODUCTVERSION 0,3,7,0
FILETYPE VFT_APP FILETYPE VFT_APP
{ {
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
{ {
BLOCK "040904E4" BLOCK "040904E4"
{ {
VALUE "FileVersion", "0.3.6b" VALUE "FileVersion", "0.3.7"
VALUE "License", "GNU General Public License 2 or later; This is free software, and you are welcome to redistribute it under certain conditions; See the help file for details" VALUE "License", "GNU General Public License 2 or later; This is free software, and you are welcome to redistribute it under certain conditions; See the help file for details"
VALUE "FileDescription", "Magic Set Editor" VALUE "FileDescription", "Magic Set Editor"
VALUE "InternalName", "mse2/8" VALUE "InternalName", "mse2/8"
......
...@@ -30,7 +30,6 @@ class GetDefaultMember { ...@@ -30,7 +30,6 @@ class GetDefaultMember {
inline bool isComplex() const { return false; } inline bool isComplex() const { return false; }
inline void addAlias(int, const Char*, const Char*) {} inline void addAlias(int, const Char*, const Char*) {}
inline void handleIgnore(int, const Char*) {} inline void handleIgnore(int, const Char*) {}
inline void handleAppVersion() {} // no effect
/// The result, or script_nil if the member was not found /// The result, or script_nil if the member was not found
inline ScriptValueP result() { return value; } inline ScriptValueP result() { return value; }
...@@ -78,7 +77,6 @@ class GetMember : private GetDefaultMember { ...@@ -78,7 +77,6 @@ class GetMember : private GetDefaultMember {
inline bool isComplex() const { return false; } inline bool isComplex() const { return false; }
inline void addAlias(int, const Char*, const Char*) {} inline void addAlias(int, const Char*, const Char*) {}
inline void handleIgnore(int, const Char*) {} inline void handleIgnore(int, const Char*) {}
inline void handleAppVersion() {} // no effect
/// The result, or script_nil if the member was not found /// The result, or script_nil if the member was not found
inline ScriptValueP result() { return gdm.result(); } inline ScriptValueP result() { return gdm.result(); }
......
...@@ -530,13 +530,13 @@ void Packaged::loadFully() { ...@@ -530,13 +530,13 @@ void Packaged::loadFully() {
void Packaged::save() { void Packaged::save() {
WITH_DYNAMIC_ARG(writing_package, this); WITH_DYNAMIC_ARG(writing_package, this);
writeFile(typeName(), *this); writeFile(typeName(), *this, fileVersion());
referenceFile(typeName()); referenceFile(typeName());
Package::save(); Package::save();
} }
void Packaged::saveAs(const String& package, bool remove_unused) { void Packaged::saveAs(const String& package, bool remove_unused) {
WITH_DYNAMIC_ARG(writing_package, this); WITH_DYNAMIC_ARG(writing_package, this);
writeFile(typeName(), *this); writeFile(typeName(), *this, fileVersion());
referenceFile(typeName()); referenceFile(typeName());
Package::saveAs(package, remove_unused); Package::saveAs(package, remove_unused);
} }
...@@ -574,6 +574,7 @@ void Packaged::requireDependency(Packaged* package) { ...@@ -574,6 +574,7 @@ void Packaged::requireDependency(Packaged* package) {
// ----------------------------------------------------------------------------- : IncludePackage // ----------------------------------------------------------------------------- : IncludePackage
String IncludePackage::typeName() const { return _("include"); } String IncludePackage::typeName() const { return _("include"); }
Version IncludePackage::fileVersion() const { return file_version_script; }
IMPLEMENT_REFLECTION(IncludePackage) { IMPLEMENT_REFLECTION(IncludePackage) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
......
...@@ -133,8 +133,8 @@ class Package : public IntrusivePtrVirtualBase { ...@@ -133,8 +133,8 @@ class Package : public IntrusivePtrVirtualBase {
} }
template <typename T> template <typename T>
void writeFile(const String& file, const T& obj) { void writeFile(const String& file, const T& obj, Version file_version) {
Writer writer(openOut(file)); Writer writer(openOut(file), file_version);
writer.handle(obj); writer.handle(obj);
} }
...@@ -229,6 +229,8 @@ class Packaged : public Package { ...@@ -229,6 +229,8 @@ class Packaged : public Package {
virtual String typeName() const = 0; virtual String typeName() const = 0;
/// Can be overloaded to do validation after loading /// Can be overloaded to do validation after loading
virtual void validate(Version file_app_version); virtual void validate(Version file_app_version);
/// What file version should be used for writing files?
virtual Version fileVersion() const = 0;
DECLARE_REFLECTION_VIRTUAL(); DECLARE_REFLECTION_VIRTUAL();
...@@ -244,6 +246,7 @@ class Packaged : public Package { ...@@ -244,6 +246,7 @@ class Packaged : public Package {
class IncludePackage : public Packaged { class IncludePackage : public Packaged {
protected: protected:
String typeName() const; String typeName() const;
Version fileVersion() const;
DECLARE_REFLECTION(); DECLARE_REFLECTION();
}; };
......
...@@ -310,7 +310,7 @@ void PackageDirectory::loadDatabase() { ...@@ -310,7 +310,7 @@ void PackageDirectory::loadDatabase() {
} }
void PackageDirectory::saveDatabase() { void PackageDirectory::saveDatabase() {
Writer writer(new_shared1<wxFileOutputStream>(databaseFile())); Writer writer(new_shared1<wxFileOutputStream>(databaseFile()), app_version);
writer.handle(*this); writer.handle(*this);
} }
String PackageDirectory::databaseFile() { String PackageDirectory::databaseFile() {
......
...@@ -15,18 +15,15 @@ ...@@ -15,18 +15,15 @@
// ----------------------------------------------------------------------------- : Writer // ----------------------------------------------------------------------------- : Writer
Writer::Writer(const OutputStreamP& output) Writer::Writer(const OutputStreamP& output, Version file_app_version)
: indentation(0), just_opened(false) : indentation(0), just_opened(false)
, output(output), stream(*output) , output(output), stream(*output)
{ {
stream.WriteString(BYTE_ORDER_MARK); stream.WriteString(BYTE_ORDER_MARK);
handleAppVersion(); handle(_("mse_version"), file_app_version);
} }
void Writer::handleAppVersion() {
handle(_("mse_version"), app_version);
}
void Writer::enterBlock(const Char* name) { void Writer::enterBlock(const Char* name) {
// indenting into a sub-block? // indenting into a sub-block?
......
...@@ -26,7 +26,7 @@ typedef shared_ptr<wxOutputStream> OutputStreamP; ...@@ -26,7 +26,7 @@ typedef shared_ptr<wxOutputStream> OutputStreamP;
class Writer { class Writer {
public: public:
/// Construct a writer that writes to the given output stream /// Construct a writer that writes to the given output stream
Writer(const OutputStreamP& output); Writer(const OutputStreamP& output, Version file_app_version);
/// Tell the reflection code we are not reading /// Tell the reflection code we are not reading
inline bool reading() const { return false; } inline bool reading() const { return false; }
...@@ -35,9 +35,6 @@ class Writer { ...@@ -35,9 +35,6 @@ class Writer {
inline void addAlias(int, const Char*, const Char*) {} inline void addAlias(int, const Char*, const Char*) {}
inline void handleIgnore(int, const Char*) {} inline void handleIgnore(int, const Char*) {}
/// Write the application version
void handleAppVersion();
// --------------------------------------------------- : Handling objects // --------------------------------------------------- : Handling objects
/// Handle an object: write it under the given name /// Handle an object: write it under the given name
template <typename T> template <typename T>
......
...@@ -50,14 +50,18 @@ template <> void GetDefaultMember::handle(const Version& v) { ...@@ -50,14 +50,18 @@ template <> void GetDefaultMember::handle(const Version& v) {
// ----------------------------------------------------------------------------- : Versions // ----------------------------------------------------------------------------- : Versions
// NOTE: Don't use leading zeroes, they mean octal // NOTE: Don't use leading zeroes, they mean octal
const Version app_version = 306; // 0.3.6 const Version app_version = 307; // 0.3.7
#ifdef UNICODE #ifdef UNICODE
const Char* version_suffix = _(" (beta)"); const Char* version_suffix = _(" (beta)");
#else #else
const Char* version_suffix = _(" (beta, ascii build)"); const Char* version_suffix = _(" (beta, ascii build)");
#endif #endif
/* Changes: /// Which version of MSE are the files we write out compatible with?
/* The saved files will have these version numbers attached.
* They should be updated whenever a change breaks backwards compatability.
*
* Changes:
* 0.2.0 : start of version numbering practice * 0.2.0 : start of version numbering practice
* 0.2.2 : _("include file") * 0.2.2 : _("include file")
* 0.2.6 : fix in settings loading * 0.2.6 : fix in settings loading
...@@ -70,4 +74,13 @@ const Char* version_suffix = _(" (beta, ascii build)"); ...@@ -70,4 +74,13 @@ const Char* version_suffix = _(" (beta, ascii build)");
* 0.3.5 : word lists, symbol font 'as text' * 0.3.5 : word lists, symbol font 'as text'
* 0.3.6 : free rotation, rotation behaviour changed. * 0.3.6 : free rotation, rotation behaviour changed.
*/ */
const Version file_version = 306; // 0.3.6 const Version file_version_locale = 307; // 0.3.7
const Version file_version_set = 306; // 0.3.6
const Version file_version_game = 307; // 0.3.7
const Version file_version_stylesheet = 307; // 0.3.7
const Version file_version_symbol_font = 306; // 0.3.6
const Version file_version_export_template = 307; // 0.3.7
const Version file_version_installer = 307; // 0.3.7
const Version file_version_symbol = 305; // 0.3.5
const Version file_version_clipboard = 306; // 0.3.6
const Version file_version_script = 307; // 0.3.7
...@@ -50,10 +50,19 @@ struct Version { ...@@ -50,10 +50,19 @@ struct Version {
extern const Version app_version; extern const Version app_version;
extern const Char* version_suffix; extern const Char* version_suffix;
/// File version, usually the same as program version, /// Which version of MSE are the files we write out compatible with?
/** When no files are changed the file version is not incremented /** When no files are changed the file version is not incremented
*/ */
extern const Version file_version; extern const Version file_version_locale;
extern const Version file_version_set;
extern const Version file_version_game;
extern const Version file_version_stylesheet;
extern const Version file_version_symbol_font;
extern const Version file_version_export_template;
extern const Version file_version_installer;
extern const Version file_version_symbol;
extern const Version file_version_clipboard;
extern const Version file_version_script;
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment