mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Implemented the context management part of the ScriptManager
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@61 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -388,6 +388,7 @@ void Packaged::open(const String& package) {
|
||||
try {
|
||||
reader.handleAppVersion();
|
||||
reader.handle(*this);
|
||||
validate(reader.file_app_version);
|
||||
} catch (const ParseError& err) {
|
||||
throw FileParseError(err.what(), absoluteFilename() + _("/") + typeName()); // more detailed message
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class Packaged : public Package {
|
||||
/// filename of the data file, and extension of the package file
|
||||
virtual String typeName() const = 0;
|
||||
/// Can be overloaded to do validation after loading
|
||||
virtual void validate() {}
|
||||
virtual void validate(Version file_app_version) {}
|
||||
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
};
|
||||
|
||||
@@ -31,18 +31,18 @@ Reader::Reader(const String& filename)
|
||||
}
|
||||
|
||||
void Reader::addAlias(Version end_version, const Char* a, const Char* b) {
|
||||
if (app_version < end_version) {
|
||||
if (file_app_version < end_version) {
|
||||
aliasses[a] = b;
|
||||
}
|
||||
}
|
||||
|
||||
void Reader::handleAppVersion() {
|
||||
if (enterBlock(_("mse_version"))) {
|
||||
handle(app_version);
|
||||
if (::app_version < app_version) {
|
||||
handle(file_app_version);
|
||||
if (app_version < file_app_version) {
|
||||
wxMessageBox(
|
||||
filename + _("\n")
|
||||
_("This file is made with a newer version of Magic Set Editor (")+ app_version.toString() +_(").\n")
|
||||
_("This file is made with a newer version of Magic Set Editor (")+ file_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);
|
||||
|
||||
@@ -48,7 +48,7 @@ class Reader {
|
||||
inline bool reading() const { return true; }
|
||||
/// Is the thing currently being read 'complex', i.e. does it have children
|
||||
inline bool isComplex() const { return value.empty(); }
|
||||
/// Add a as an alias for b, all keys a will be replaced with b, only if app_version < end_version
|
||||
/// Add a as an alias for b, all keys a will be replaced with b, only if file_app_version < end_version
|
||||
void addAlias(Version end_version, const Char* a, const Char* b);
|
||||
|
||||
/// Read and check the application version
|
||||
@@ -90,7 +90,7 @@ class Reader {
|
||||
|
||||
// --------------------------------------------------- : Data
|
||||
/// App version this file was made with
|
||||
Version app_version;
|
||||
Version file_app_version;
|
||||
private:
|
||||
/// The line we read
|
||||
String line;
|
||||
|
||||
Reference in New Issue
Block a user