mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added warnings to Reader, fixed some bugs found that way
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@30 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+4
-1
@@ -37,6 +37,8 @@ IMPLEMENT_REFLECTION(Field) {
|
|||||||
String type = typeName();
|
String type = typeName();
|
||||||
REFLECT(type);
|
REFLECT(type);
|
||||||
}
|
}
|
||||||
|
REFLECT(name);
|
||||||
|
REFLECT(description);
|
||||||
REFLECT(editable);
|
REFLECT(editable);
|
||||||
REFLECT(save_value);
|
REFLECT(save_value);
|
||||||
REFLECT(show_statistics);
|
REFLECT(show_statistics);
|
||||||
@@ -44,7 +46,8 @@ IMPLEMENT_REFLECTION(Field) {
|
|||||||
REFLECT(card_list_column);
|
REFLECT(card_list_column);
|
||||||
REFLECT(card_list_width);
|
REFLECT(card_list_width);
|
||||||
REFLECT(card_list_allow);
|
REFLECT(card_list_allow);
|
||||||
REFLECT(card_list_align);
|
REFLECT(card_list_name);
|
||||||
|
REFLECT_N("card_list_alignment", card_list_align);
|
||||||
REFLECT(tab_index);
|
REFLECT(tab_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ String ChoiceField::typeName() const {
|
|||||||
|
|
||||||
IMPLEMENT_REFLECTION(ChoiceField) {
|
IMPLEMENT_REFLECTION(ChoiceField) {
|
||||||
REFLECT_BASE(Field);
|
REFLECT_BASE(Field);
|
||||||
REFLECT(choices);
|
REFLECT_N("choices", choices->choices);
|
||||||
REFLECT(script);
|
REFLECT(script);
|
||||||
REFLECT_N("default", default_script);
|
REFLECT_N("default", default_script);
|
||||||
REFLECT(initial);
|
REFLECT(initial);
|
||||||
|
|||||||
@@ -711,6 +711,18 @@
|
|||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\data\field\symbol.cpp">
|
RelativePath=".\data\field\symbol.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug Unicode|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\data\field\symbol.hpp">
|
RelativePath=".\data\field\symbol.hpp">
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ Reader::Reader(const InputStreamP& input, String filename)
|
|||||||
moveNext();
|
moveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reader::warning(const String& msg) {
|
||||||
|
wxMessageBox((msg + _("\nOn line: ")) << line_number << _("\nIn file: ") << filename, _("Warning"), wxOK | wxICON_EXCLAMATION);
|
||||||
|
}
|
||||||
|
|
||||||
bool Reader::enterBlock(const Char* name) {
|
bool Reader::enterBlock(const Char* name) {
|
||||||
if (just_opened) moveNext(); // on the key of the parent block, first move inside it
|
if (just_opened) moveNext(); // on the key of the parent block, first move inside it
|
||||||
if (indent != expected_indent) return false; // not enough indentation
|
if (indent != expected_indent) return false; // not enough indentation
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class Reader {
|
|||||||
/// Is the thing currently being read 'complex', i.e. does it have children
|
/// Is the thing currently being read 'complex', i.e. does it have children
|
||||||
inline bool isComplex() const { return value.empty(); }
|
inline bool isComplex() const { return value.empty(); }
|
||||||
|
|
||||||
|
/// Show a warning message, but continue reading
|
||||||
|
void warning(const String& msg);
|
||||||
|
|
||||||
// --------------------------------------------------- : Handling objects
|
// --------------------------------------------------- : Handling objects
|
||||||
/// Handle an object: read it if it's name matches
|
/// Handle an object: read it if it's name matches
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -148,7 +151,8 @@ void Reader::handle(map<K,V>& map) {
|
|||||||
UInt l = line_number; \
|
UInt l = line_number; \
|
||||||
object.reflect(*this); \
|
object.reflect(*this); \
|
||||||
if (l == line_number) { \
|
if (l == line_number) { \
|
||||||
/* error */ \
|
/* warning: unexpected key */ \
|
||||||
|
warning(_("Unexpected key: '") + key + _("'")); \
|
||||||
do { \
|
do { \
|
||||||
moveNext(); \
|
moveNext(); \
|
||||||
} while (indent > expected_indent); \
|
} while (indent > expected_indent); \
|
||||||
@@ -167,7 +171,8 @@ void Reader::handle(map<K,V>& map) {
|
|||||||
EnumReader reader(value); \
|
EnumReader reader(value); \
|
||||||
reflect_ ## Enum(enum_, reader); \
|
reflect_ ## Enum(enum_, reader); \
|
||||||
if (!reader.isDone()) { \
|
if (!reader.isDone()) { \
|
||||||
/* warning message */ \
|
/* warning: unknown value */ \
|
||||||
|
warning(_("Unrecognized value: ") + value); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +186,8 @@ class EnumReader {
|
|||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
inline void handle(const Char* name, Enum value, Enum& enum_) {
|
inline void handle(const Char* name, Enum value, Enum& enum_) {
|
||||||
if (!done && read == name) {
|
if (!done && read == name) {
|
||||||
first = true;
|
done = true;
|
||||||
|
first = false;
|
||||||
enum_ = value;
|
enum_ = value;
|
||||||
} else if (first) {
|
} else if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user