mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Added version number to files; IndexMap now works with GetMember
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@40 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -29,6 +29,8 @@ class GetDefaultMember {
|
||||
inline bool reading() const { return false; }
|
||||
inline bool isComplex() const { return false; }
|
||||
|
||||
inline void handleAppVersion() {} // no effect
|
||||
|
||||
/// The result, or script_nil if the member was not found
|
||||
inline ScriptValueP result() { return value; }
|
||||
|
||||
|
||||
@@ -386,6 +386,7 @@ void Packaged::open(const String& package) {
|
||||
Package::open(package);
|
||||
Reader reader(openIn(typeName()), absoluteFilename() + _("/") + typeName());
|
||||
try {
|
||||
reader.handleAppVersion();
|
||||
reader.handle(*this);
|
||||
} catch (const ParseError& err) {
|
||||
throw FileParseError(err.what(), absoluteFilename() + _("/") + typeName()); // more detailed message
|
||||
|
||||
@@ -31,6 +31,21 @@ Reader::Reader(const String& filename)
|
||||
}
|
||||
|
||||
|
||||
void Reader::handleAppVersion() {
|
||||
if (enterBlock(_("mse_version"))) {
|
||||
handle(app_version);
|
||||
if (::app_version < app_version) {
|
||||
wxMessageBox(
|
||||
filename + _("\n")
|
||||
_("This file is made with a newer version of Magic Set Editor (")+ app_version.toString() +_(").\n")
|
||||
_("When you open it, some aspects of the file may be lost.\n")
|
||||
_("It is recommended that you upgrade to the latest version.\n")
|
||||
_("Visit http:://magicseteditor.sourceforge.net/"), _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
}
|
||||
exitBlock();
|
||||
}
|
||||
}
|
||||
|
||||
void Reader::warning(const String& msg) {
|
||||
wxMessageBox((msg + _("\nOn line: ")) << line_number << _("\nIn file: ") << filename, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||
}
|
||||
|
||||
+12
-1
@@ -10,10 +10,13 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/version.hpp>
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
template <typename T> class Defaultable;
|
||||
template <typename T> class Scriptable;
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StyleSheet);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Reader
|
||||
|
||||
@@ -44,6 +47,9 @@ class Reader {
|
||||
/// Is the thing currently being read 'complex', i.e. does it have children
|
||||
inline bool isComplex() const { return value.empty(); }
|
||||
|
||||
/// Read and check the application version
|
||||
void handleAppVersion();
|
||||
|
||||
/// Show a warning message, but continue reading
|
||||
void warning(const String& msg);
|
||||
|
||||
@@ -72,9 +78,14 @@ class Reader {
|
||||
template <typename T> void handle(Defaultable<T>&);
|
||||
/// Reads a Scriptable from the input stream
|
||||
template <typename T> void handle(Scriptable<T>&);
|
||||
// special behaviour
|
||||
void handle(GameP&);
|
||||
void handle(StyleSheet&);
|
||||
|
||||
private:
|
||||
// --------------------------------------------------- : Data
|
||||
/// App version this file was made with
|
||||
Version app_version;
|
||||
private:
|
||||
/// The line we read
|
||||
String line;
|
||||
/// The key and value of the last line we read
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "writer.hpp"
|
||||
#include <util/vector2d.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/version.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Writer
|
||||
|
||||
@@ -22,6 +23,10 @@ Writer::Writer(const OutputStreamP& output)
|
||||
}
|
||||
|
||||
|
||||
void Writer::handleAppVersion() {
|
||||
handle(_("mse_version"), app_version);
|
||||
}
|
||||
|
||||
void Writer::enterBlock(const Char* name) {
|
||||
// indenting into a sub-block?
|
||||
if (just_opened) {
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
template <typename T> class Defaultable;
|
||||
template <typename T> class Scriptable;
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StyleSheet);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Writer
|
||||
|
||||
@@ -30,6 +32,9 @@ class Writer {
|
||||
inline bool reading() const { return false; }
|
||||
inline bool isComplex() const { return false; }
|
||||
|
||||
/// Write the application version
|
||||
void handleAppVersion();
|
||||
|
||||
// --------------------------------------------------- : Handling objects
|
||||
/// Handle an object: write it under the given name
|
||||
template <typename T>
|
||||
@@ -58,6 +63,9 @@ class Writer {
|
||||
template <typename T> void handle(const Defaultable<T>&);
|
||||
/// Write an object of type Scriptable<T> to the output stream
|
||||
template <typename T> void handle(const Scriptable<T>&);
|
||||
// special behaviour
|
||||
void handle(const GameP&);
|
||||
void handle(const StyleSheet&);
|
||||
|
||||
private:
|
||||
// --------------------------------------------------- : Data
|
||||
|
||||
Reference in New Issue
Block a user