mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Cleaned up the reflection code a bit
* Renamed 'tag' variable to 'handler' * Removed addAlias stuff, instead check for matching names with if statements * Added after_reading function that is called by Reader after reading a complete object. This generalizes Packaged::validate, which is now also called via this mechanism. * Removed some backwards compatibility with <0.3.0 for templates
This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ IMPLEMENT_REFLECTION(Card) {
|
||||
} else if (stylesheet_for_reading()) {
|
||||
REFLECT_IF_READING styling_data.init(stylesheet_for_reading()->styling_fields);
|
||||
REFLECT(styling_data);
|
||||
} else if (tag.reading()) {
|
||||
} else if (Handler::isReading) {
|
||||
has_styling = false; // We don't know the style, this can be because of copy/pasting
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -47,7 +47,6 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(type);
|
||||
}
|
||||
REFLECT(name);
|
||||
REFLECT_IF_READING name = canonical_name_form(name);
|
||||
REFLECT(caption);
|
||||
REFLECT(description);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
@@ -63,8 +62,12 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(card_list_name);
|
||||
REFLECT(sort_script);
|
||||
REFLECT_N("card_list_alignment", card_list_align);
|
||||
REFLECT_IF_READING if(caption.empty()) caption = name_to_caption(name);
|
||||
REFLECT_IF_READING if(card_list_name.empty()) card_list_name = capitalize(caption);
|
||||
}
|
||||
|
||||
void Field::after_reading(Version ver) {
|
||||
name = canonical_name_form(name);
|
||||
if(caption.empty()) caption = name_to_caption(name);
|
||||
if(card_list_name.empty()) card_list_name = capitalize(caption);
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
+9
-3
@@ -74,6 +74,8 @@ class Field : public IntrusivePtrVirtualBase {
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
virtual void after_reading(Version ver);
|
||||
friend void after_reading(Field& s, Version ver);
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -82,6 +84,10 @@ inline void update_index(FieldP& f, size_t index) {
|
||||
f->index = index;
|
||||
}
|
||||
|
||||
inline void after_reading(Field& f, Version ver) {
|
||||
f.after_reading(ver);
|
||||
}
|
||||
|
||||
inline String type_name(const Field&) {
|
||||
return _TYPE_("field");
|
||||
}
|
||||
@@ -258,7 +264,7 @@ inline String type_name(const Value&) {
|
||||
// ----------------------------------------------------------------------------- : Utilities
|
||||
|
||||
#define DECLARE_FIELD_TYPE(Type) \
|
||||
DECLARE_REFLECTION(); public: \
|
||||
DECLARE_REFLECTION_OVERRIDE(); public: \
|
||||
virtual ValueP newValue(const FieldP& thisP) const; \
|
||||
virtual StyleP newStyle(const FieldP& thisP) const; \
|
||||
virtual String typeName() const
|
||||
@@ -284,14 +290,14 @@ inline String type_name(const Value&) {
|
||||
}
|
||||
|
||||
#define DECLARE_STYLE_TYPE(Type) \
|
||||
DECLARE_REFLECTION(); public: \
|
||||
DECLARE_REFLECTION_OVERRIDE(); public: \
|
||||
DECLARE_HAS_FIELD(Type) \
|
||||
virtual StyleP clone() const; \
|
||||
virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \
|
||||
virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP)
|
||||
|
||||
#define DECLARE_VALUE_TYPE(Type,ValueType_) \
|
||||
DECLARE_REFLECTION(); public: \
|
||||
DECLARE_REFLECTION_OVERRIDE(); public: \
|
||||
DECLARE_HAS_FIELD(Type) \
|
||||
virtual ValueP clone() const; \
|
||||
virtual String toString() const; \
|
||||
|
||||
+25
-25
@@ -34,13 +34,14 @@ IMPLEMENT_REFLECTION(ChoiceField) {
|
||||
REFLECT_N("default", default_script);
|
||||
REFLECT(initial);
|
||||
REFLECT(default_name);
|
||||
REFLECT_IF_READING {
|
||||
choices->initIds();
|
||||
}
|
||||
REFLECT(choice_colors);
|
||||
REFLECT(choice_colors_cardlist);
|
||||
}
|
||||
|
||||
void ChoiceField::after_reading(Version ver) {
|
||||
Field::after_reading(ver);
|
||||
choices->initIds();
|
||||
}
|
||||
// ----------------------------------------------------------------------------- : ChoiceField::Choice
|
||||
|
||||
ChoiceField::Choice::Choice()
|
||||
@@ -142,7 +143,9 @@ IMPLEMENT_REFLECTION_ENUM(ChoiceChoiceType) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(ChoiceField::Choice) {
|
||||
if (isGroup() || line_below || enabled.isScripted() || tag.isComplex()) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE {
|
||||
REFLECT_NAMELESS(name);
|
||||
} else {
|
||||
// complex values are groups
|
||||
REFLECT(name);
|
||||
REFLECT_N("group_choice", default_name);
|
||||
@@ -150,8 +153,6 @@ IMPLEMENT_REFLECTION(ChoiceField::Choice) {
|
||||
REFLECT(line_below);
|
||||
REFLECT(enabled);
|
||||
REFLECT(type);
|
||||
} else {
|
||||
REFLECT_NAMELESS(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,33 +243,32 @@ void ChoiceStyle::invalidate() {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(ChoicePopupStyle) {
|
||||
VALUE_N("dropdown", POPUP_DROPDOWN);
|
||||
VALUE_N("menu", POPUP_MENU);
|
||||
VALUE_N("in place", POPUP_DROPDOWN_IN_PLACE);
|
||||
VALUE_N("dropdown", POPUP_DROPDOWN);
|
||||
VALUE_N("menu", POPUP_MENU);
|
||||
VALUE_N("in place", POPUP_DROPDOWN_IN_PLACE);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) {
|
||||
VALUE_N("text", RENDER_TEXT);
|
||||
VALUE_N("image", RENDER_IMAGE);
|
||||
VALUE_N("both", RENDER_BOTH);
|
||||
VALUE_N("hidden", RENDER_HIDDEN);
|
||||
VALUE_N("image hidden", RENDER_HIDDEN_IMAGE);
|
||||
VALUE_N("checklist", RENDER_TEXT_CHECKLIST);
|
||||
VALUE_N("image checklist", RENDER_IMAGE_CHECKLIST);
|
||||
VALUE_N("both checklist", RENDER_BOTH_CHECKLIST);
|
||||
VALUE_N("text list", RENDER_TEXT_LIST);
|
||||
VALUE_N("image list", RENDER_IMAGE_LIST);
|
||||
VALUE_N("both list", RENDER_BOTH_LIST);
|
||||
VALUE_N("text", RENDER_TEXT);
|
||||
VALUE_N("image", RENDER_IMAGE);
|
||||
VALUE_N("both", RENDER_BOTH);
|
||||
VALUE_N("hidden", RENDER_HIDDEN);
|
||||
VALUE_N("image hidden", RENDER_HIDDEN_IMAGE);
|
||||
VALUE_N("checklist", RENDER_TEXT_CHECKLIST);
|
||||
VALUE_N("image checklist", RENDER_IMAGE_CHECKLIST);
|
||||
VALUE_N("both checklist", RENDER_BOTH_CHECKLIST);
|
||||
VALUE_N("text list", RENDER_TEXT_LIST);
|
||||
VALUE_N("image list", RENDER_IMAGE_LIST);
|
||||
VALUE_N("both list", RENDER_BOTH_LIST);
|
||||
}
|
||||
|
||||
template <typename T> void reflect_content(T& tag, const ChoiceStyle& cs) {}
|
||||
template <> void reflect_content(GetMember& tag, const ChoiceStyle& cs) {
|
||||
template <typename T> void reflect_content(T& handler, const ChoiceStyle& cs) {}
|
||||
template <> void reflect_content(GetMember& handler, const ChoiceStyle& cs) {
|
||||
REFLECT_N("content_width", cs.content_width);
|
||||
REFLECT_N("content_height", cs.content_height);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(ChoiceStyle) {
|
||||
REFLECT_ALIAS(300, "card_list_colors", "colors_card_list");
|
||||
REFLECT_BASE(Style);
|
||||
REFLECT(popup_style);
|
||||
REFLECT(render_style);
|
||||
@@ -277,7 +277,7 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
|
||||
REFLECT(font);
|
||||
REFLECT(image);
|
||||
REFLECT(choice_images);
|
||||
reflect_content(tag, *this);
|
||||
reflect_content(handler, *this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ChoiceValue
|
||||
@@ -301,7 +301,7 @@ bool ChoiceValue::update(Context& ctx) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(ChoiceValue) {
|
||||
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(value);
|
||||
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(value);
|
||||
}
|
||||
|
||||
INSTANTIATE_REFLECTION_NAMELESS(ChoiceValue)
|
||||
|
||||
@@ -42,6 +42,7 @@ class ChoiceField : public Field {
|
||||
map<String,Color> choice_colors_cardlist; ///< Colors for the various choices, for in the card list
|
||||
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
virtual void after_reading(Version ver);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ IMPLEMENT_REFLECTION(ColorField) {
|
||||
// ----------------------------------------------------------------------------- : ColorField::Choice
|
||||
|
||||
IMPLEMENT_REFLECTION(ColorField::Choice) {
|
||||
if (tag.reading() && !tag.isComplex()) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE {
|
||||
REFLECT_NAMELESS(name);
|
||||
color = parse_color(name);
|
||||
} else {
|
||||
@@ -98,5 +98,5 @@ bool ColorValue::update(Context& ctx) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(ColorValue) {
|
||||
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(value);
|
||||
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(value);
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ String ImageValue::toString() const {
|
||||
|
||||
// custom reflection: convert to ScriptImageP for scripting
|
||||
|
||||
void ImageValue::reflect(Reader& tag) {
|
||||
tag.handle(filename);
|
||||
void ImageValue::reflect(Reader& handler) {
|
||||
handler.handle(filename);
|
||||
}
|
||||
void ImageValue::reflect(Writer& tag) {
|
||||
if (fieldP->save_value) tag.handle(filename);
|
||||
void ImageValue::reflect(Writer& handler) {
|
||||
if (fieldP->save_value) handler.handle(filename);
|
||||
}
|
||||
void ImageValue::reflect(GetMember& tag) {}
|
||||
void ImageValue::reflect(GetDefaultMember& tag) {
|
||||
void ImageValue::reflect(GetMember& handler) {}
|
||||
void ImageValue::reflect(GetDefaultMember& handler) {
|
||||
// convert to ScriptImageP for scripting
|
||||
tag.handle( (ScriptValueP)make_intrusive<ImageValueToImage>(filename, last_update) );
|
||||
handler.handle( (ScriptValueP)make_intrusive<ImageValueToImage>(filename, last_update) );
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ bool PackageChoiceValue::update(Context& ctx) {
|
||||
return change;
|
||||
}
|
||||
|
||||
void PackageChoiceValue::reflect(Reader& tag) {
|
||||
void PackageChoiceValue::reflect(Reader& handler) {
|
||||
REFLECT_NAMELESS(package_name);
|
||||
}
|
||||
void PackageChoiceValue::reflect(Writer& tag) {
|
||||
void PackageChoiceValue::reflect(Writer& handler) {
|
||||
REFLECT_NAMELESS(package_name);
|
||||
}
|
||||
void PackageChoiceValue::reflect(GetDefaultMember& tag) {
|
||||
void PackageChoiceValue::reflect(GetDefaultMember& handler) {
|
||||
if (package_name.empty()) {
|
||||
REFLECT_NAMELESS(package_name);
|
||||
} else if(package_name != field().initial) {
|
||||
|
||||
@@ -52,5 +52,5 @@ String SymbolValue::toString() const {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(SymbolValue) {
|
||||
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(filename);
|
||||
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(filename);
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ void TextStyle::checkContentDependencies(Context& ctx, const Dependency& dep) co
|
||||
alignment.initDependencies(ctx, dep);
|
||||
}
|
||||
|
||||
template <typename T> void reflect_content(T& tag, const TextStyle& ts) {}
|
||||
template <> void reflect_content(GetMember& tag, const TextStyle& ts) {
|
||||
template <typename T> void reflect_content(T& handler, const TextStyle& ts) {}
|
||||
template <> void reflect_content(GetMember& handler, const TextStyle& ts) {
|
||||
REFLECT_N("content_width", ts.content_width);
|
||||
REFLECT_N("content_height", ts.content_height);
|
||||
REFLECT_N("content_lines", ts.content_lines);
|
||||
@@ -127,7 +127,7 @@ IMPLEMENT_REFLECTION(TextStyle) {
|
||||
REFLECT(line_height_line_max);
|
||||
REFLECT(paragraph_height);
|
||||
REFLECT(direction);
|
||||
reflect_content(tag, *this);
|
||||
reflect_content(handler, *this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextValue
|
||||
@@ -147,7 +147,7 @@ bool TextValue::update(Context& ctx) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(TextValue) {
|
||||
if (fieldP->save_value || tag.scripting() || tag.reading()) REFLECT_NAMELESS(value);
|
||||
if (fieldP->save_value || !handler.isWriting) REFLECT_NAMELESS(value);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : FakeTextValue
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ IMPLEMENT_REFLECTION(Game) {
|
||||
REFLECT_NO_SCRIPT(card_list_color_script);
|
||||
REFLECT_NO_SCRIPT(statistics_dimensions);
|
||||
REFLECT_NO_SCRIPT(statistics_categories);
|
||||
REFLECT_ALIAS(308, "pack_item", "pack_type");
|
||||
REFLECT_COMPAT(<308, "pack_item", pack_types);
|
||||
REFLECT_NO_SCRIPT(pack_types);
|
||||
REFLECT_NO_SCRIPT(keyword_match_script);
|
||||
REFLECT(has_keywords);
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ class Game : public Packaged {
|
||||
protected:
|
||||
virtual void validate(Version);
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
DECLARE_REFLECTION_OVERRIDE();
|
||||
};
|
||||
|
||||
inline String type_name(const Game&) {
|
||||
|
||||
@@ -53,9 +53,8 @@ IMPLEMENT_REFLECTION(KeywordMode) {
|
||||
|
||||
// backwards compatability
|
||||
template <typename T> void read_compat(T&, const Keyword*) {}
|
||||
void read_compat(Reader& tag, Keyword* k) {
|
||||
void read_compat(Reader& handler, Keyword* k) {
|
||||
if (!k->match.empty()) return;
|
||||
if (tag.file_app_version >= 301) return; // only for versions < 0.3.1
|
||||
String separator, parameter;
|
||||
REFLECT(separator);
|
||||
REFLECT(parameter);
|
||||
@@ -84,7 +83,7 @@ bool Keyword::contains(String const& query) const {
|
||||
|
||||
IMPLEMENT_REFLECTION(Keyword) {
|
||||
REFLECT(keyword);
|
||||
read_compat(tag, this);
|
||||
if (handler.formatVersion() < 301) read_compat(handler, this);
|
||||
REFLECT(match);
|
||||
REFLECT(reminder);
|
||||
REFLECT(rules);
|
||||
|
||||
+14
-14
@@ -38,24 +38,24 @@ IMPLEMENT_REFLECTION(PackType) {
|
||||
REFLECT(select);
|
||||
REFLECT(filter);
|
||||
REFLECT(items);
|
||||
REFLECT_IF_READING {
|
||||
if (select == SELECT_AUTO) {
|
||||
if (filter) select = SELECT_NO_REPLACE;
|
||||
else if (!items.empty()) select = SELECT_ALL;
|
||||
}
|
||||
if (indeterminate(summary)) {
|
||||
if (filter) summary = true;
|
||||
else if (!items.empty()) summary = false;
|
||||
}
|
||||
if (indeterminate(selectable)) {
|
||||
if (filter) selectable = false;
|
||||
else if (!items.empty()) selectable = true;
|
||||
}
|
||||
}
|
||||
void after_reading(PackType& pt, Version) {
|
||||
if (pt.select == SELECT_AUTO) {
|
||||
if (pt.filter) pt.select = SELECT_NO_REPLACE;
|
||||
else if (!pt.items.empty()) pt.select = SELECT_ALL;
|
||||
}
|
||||
if (indeterminate(pt.summary)) {
|
||||
if (pt.filter) pt.summary = true;
|
||||
else if (!pt.items.empty()) pt.summary = false;
|
||||
}
|
||||
if (indeterminate(pt.selectable)) {
|
||||
if (pt.filter) pt.selectable = false;
|
||||
else if (!pt.items.empty()) pt.selectable = true;
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(PackItem) {
|
||||
if (!tag.isComplex()) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE {
|
||||
REFLECT_NAMELESS(name);
|
||||
} else {
|
||||
REFLECT(name);
|
||||
|
||||
@@ -56,6 +56,7 @@ class PackType : public IntrusivePtrBase<PackType> {
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
void after_reading(PackType&, Version);
|
||||
|
||||
/// An item in a PackType
|
||||
class PackItem : public IntrusivePtrBase<PackItem> {
|
||||
|
||||
+10
-10
@@ -167,8 +167,6 @@ void Set::validate(Version file_app_version) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(Set) {
|
||||
REFLECT_ALIAS(300, "style", "stylesheet"); // < 0.3.0 used style instead of stylesheet
|
||||
REFLECT_ALIAS(300, "extra_set_info", "styling");
|
||||
REFLECT(game);
|
||||
if (game) {
|
||||
REFLECT_IF_READING {
|
||||
@@ -176,29 +174,31 @@ IMPLEMENT_REFLECTION(Set) {
|
||||
}
|
||||
WITH_DYNAMIC_ARG(game_for_reading, game.get());
|
||||
REFLECT(stylesheet);
|
||||
REFLECT_COMPAT(<300, "style", stylesheet);
|
||||
WITH_DYNAMIC_ARG(stylesheet_for_reading, stylesheet.get());
|
||||
REFLECT_N("set_info", data);
|
||||
if (stylesheet) {
|
||||
REFLECT_COMPAT(<300, "extra_set_info", styling_data);
|
||||
REFLECT_N("styling", styling_data);
|
||||
}
|
||||
// Experimental: save each card to a different file
|
||||
reflect_cards(tag);
|
||||
reflect_cards(handler);
|
||||
REFLECT(keywords);
|
||||
REFLECT(pack_types);
|
||||
}
|
||||
reflect_set_info_get_member(tag,data);
|
||||
reflect_set_info_get_member(handler,data);
|
||||
REFLECT_NO_SCRIPT_N("version_control", vcs);
|
||||
REFLECT(apprentice_code);
|
||||
}
|
||||
|
||||
// TODO: make this a more generic function to be used elsewhere
|
||||
template <typename Tag>
|
||||
void Set::reflect_cards (Tag& tag) {
|
||||
template <typename Handler>
|
||||
void Set::reflect_cards (Handler& handler) {
|
||||
REFLECT(cards);
|
||||
}
|
||||
|
||||
template <>
|
||||
void Set::reflect_cards<Writer> (Writer& tag) {
|
||||
void Set::reflect_cards<Writer> (Writer& handler) {
|
||||
// When writing to a directory, we write each card in a separate file.
|
||||
// We don't do this in zipfiles because it leads to bloat.
|
||||
if (isZipfile()) {
|
||||
@@ -251,9 +251,9 @@ void mark_dependency_member(const Set& set, const String& name, const Dependency
|
||||
}
|
||||
|
||||
// in scripts, set.something is read from the set_info
|
||||
template <typename Tag>
|
||||
void reflect_set_info_get_member(Tag& tag, const IndexMap<FieldP, ValueP>& data) {}
|
||||
void reflect_set_info_get_member(GetMember& tag, const IndexMap<FieldP, ValueP>& data) {
|
||||
template <typename Handler>
|
||||
void reflect_set_info_get_member(Handler& handler, const IndexMap<FieldP, ValueP>& data) {}
|
||||
void reflect_set_info_get_member(GetMember& handler, const IndexMap<FieldP, ValueP>& data) {
|
||||
REFLECT_NAMELESS(data);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -126,8 +126,8 @@ class Set : public Packaged {
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
template <typename Tag>
|
||||
void reflect_cards (Tag& tag);
|
||||
template <typename Handler>
|
||||
void reflect_cards(Handler& handler);
|
||||
|
||||
/// Object for managing and executing scripts
|
||||
unique_ptr<SetScriptManager> script_manager;
|
||||
|
||||
@@ -242,8 +242,6 @@ String Settings::settingsFile() {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
|
||||
REFLECT_ALIAS(300, "style_settings", "stylesheet_settings");
|
||||
REFLECT_ALIAS(300, "default_style_settings", "default_stylesheet_settings");
|
||||
REFLECT(locale);
|
||||
REFLECT(recent_sets);
|
||||
REFLECT(default_set_dir);
|
||||
@@ -264,7 +262,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
|
||||
#if USE_OLD_STYLE_UPDATE_CHECKER
|
||||
REFLECT(updates_url);
|
||||
#else
|
||||
REFLECT_IGNORE(306,"updates_url");
|
||||
REFLECT_COMPAT_IGNORE(<306,"updates_url",String);
|
||||
#endif
|
||||
REFLECT(package_versions_url);
|
||||
REFLECT(installer_list_url);
|
||||
|
||||
@@ -91,16 +91,6 @@ void mark_dependency_value(const StyleSheet& stylesheet, const Dependency& dep)
|
||||
|
||||
|
||||
IMPLEMENT_REFLECTION(StyleSheet) {
|
||||
// < 0.3.0 didn't use card_ prefix
|
||||
REFLECT_ALIAS(300, "width", "card_width");
|
||||
REFLECT_ALIAS(300, "height", "card_height");
|
||||
REFLECT_ALIAS(300, "dpi", "card_dpi");
|
||||
REFLECT_ALIAS(300, "background", "card_background");
|
||||
REFLECT_ALIAS(300, "info_style", "set_info_style");
|
||||
REFLECT_ALIAS(300, "align", "alignment");
|
||||
REFLECT_ALIAS(300, "extra_field", "styling_field");
|
||||
REFLECT_ALIAS(300, "extra_style", "styling_style");
|
||||
|
||||
REFLECT(game);
|
||||
REFLECT_BASE(Packaged);
|
||||
REFLECT(card_width);
|
||||
|
||||
+19
-23
@@ -27,10 +27,10 @@ IMPLEMENT_REFLECTION(ControlPoint) {
|
||||
REFLECT_N("position", pos);
|
||||
REFLECT_N("lock", lock);
|
||||
REFLECT_N("line_after", segment_after);
|
||||
if (tag.reading() || segment_before == SEGMENT_CURVE) {
|
||||
if (Handler::isReading || segment_before == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle_before", delta_before);
|
||||
}
|
||||
if (tag.reading() || segment_after == SEGMENT_CURVE) {
|
||||
if (Handler::isReading || segment_after == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle_after", delta_after);
|
||||
}
|
||||
}
|
||||
@@ -155,32 +155,28 @@ IMPLEMENT_REFLECTION_ENUM(SymbolShapeCombine) {
|
||||
VALUE_N("border", SYMBOL_COMBINE_BORDER);
|
||||
}
|
||||
|
||||
|
||||
template<typename T> void fix(const T&,SymbolShape&) {}
|
||||
void fix(const Reader& reader, SymbolShape& shape) {
|
||||
if (reader.file_app_version != Version()) return;
|
||||
shape.updateBounds();
|
||||
if (shape.bounds.max.x < 100 || shape.bounds.max.y < 100) return;
|
||||
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
|
||||
// adjust it
|
||||
FOR_EACH(p, shape.points) {
|
||||
p->pos /= 500.0;
|
||||
p->delta_before /= 500.0;
|
||||
p->delta_after /= 500.0;
|
||||
}
|
||||
if (shape.name.empty()) shape.name = _("Shape");
|
||||
shape.updateBounds();
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolShape) {
|
||||
REFLECT_BASE(SymbolPart);
|
||||
REFLECT(combine);
|
||||
REFLECT(points);
|
||||
}
|
||||
|
||||
void after_reading(SymbolShape& shape, Version version) {
|
||||
// Fixes after reading
|
||||
REFLECT_IF_READING {
|
||||
// enforce constraints
|
||||
enforceConstraints();
|
||||
fix(tag,*this);
|
||||
// enforce constraints
|
||||
shape.enforceConstraints();
|
||||
if (version == Version()) {
|
||||
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
|
||||
shape.updateBounds();
|
||||
if (shape.bounds.max.x < 100 || shape.bounds.max.y < 100) return;
|
||||
// adjust it
|
||||
FOR_EACH(p, shape.points) {
|
||||
p->pos /= 500.0;
|
||||
p->delta_before /= 500.0;
|
||||
p->delta_after /= 500.0;
|
||||
}
|
||||
if (shape.name.empty()) shape.name = _("Shape");
|
||||
shape.updateBounds();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -220,8 +220,9 @@ class SymbolShape : public SymbolPart {
|
||||
/// Calculate the position and size of the part using the given rotation matrix
|
||||
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity);
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
DECLARE_REFLECTION_OVERRIDE();
|
||||
};
|
||||
void after_reading(SymbolShape&, Version);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolGroup
|
||||
|
||||
@@ -242,7 +243,7 @@ class SymbolGroup : public SymbolPart {
|
||||
|
||||
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity);
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
DECLARE_REFLECTION_OVERRIDE();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolSymmetry
|
||||
@@ -273,7 +274,7 @@ class SymbolSymmetry : public SymbolGroup {
|
||||
String expectedName() const;
|
||||
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity);
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
DECLARE_REFLECTION_OVERRIDE();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Symbol
|
||||
@@ -287,7 +288,7 @@ class Symbol : public SymbolGroup {
|
||||
/// Determine the aspect ratio best suited for this symbol
|
||||
double aspectRatio() const;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
DECLARE_REFLECTION_OVERRIDE();
|
||||
};
|
||||
|
||||
/// A default symbol: a square
|
||||
|
||||
@@ -46,8 +46,6 @@ SymbolFontP SymbolFont::byName(const String& name) {
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolFont) {
|
||||
REFLECT_BASE(Packaged);
|
||||
|
||||
REFLECT_ALIAS(300, "text_align", "text_alignment");
|
||||
|
||||
REFLECT_N("image_font_size", img_size);
|
||||
REFLECT_N("horizontal_space", spacing.width);
|
||||
@@ -179,6 +177,7 @@ IMPLEMENT_REFLECTION(SymbolInFont) {
|
||||
REFLECT(draw_text);
|
||||
REFLECT(text_font);
|
||||
REFLECT(text_alignment);
|
||||
REFLECT_COMPAT(<300,"text_align",text_alignment);
|
||||
REFLECT(text_margin_left);
|
||||
REFLECT(text_margin_right);
|
||||
REFLECT(text_margin_top);
|
||||
@@ -525,18 +524,18 @@ IMPLEMENT_REFLECTION_ENUM(MenuItemType) {
|
||||
VALUE_N("code", ITEM_CODE);
|
||||
VALUE_N("custom", ITEM_CUSTOM);
|
||||
VALUE_N("line", ITEM_LINE);
|
||||
VALUE_N("submenu", ITEM_SUBMENU);
|
||||
VALUE_N("submenu", ITEM_SUBMENU);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_GET_MEMBER(InsertSymbolMenu) {
|
||||
if (!items.empty() || (tag.reading() && tag.isComplex())) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE_AND(items.empty()) {
|
||||
REFLECT_NAMELESS(name);
|
||||
} else {
|
||||
// complex values are groups
|
||||
REFLECT(type);
|
||||
REFLECT(name);
|
||||
REFLECT(items);
|
||||
if (!items.empty()) type = ITEM_SUBMENU;
|
||||
} else {
|
||||
REFLECT_NAMELESS(name);
|
||||
if (Handler::isReading && !items.empty()) type = ITEM_SUBMENU;
|
||||
}
|
||||
}
|
||||
template <> void GetDefaultMember::handle(const InsertSymbolMenu& m) {
|
||||
|
||||
@@ -17,7 +17,7 @@ WordListWord::WordListWord()
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(WordListWord) {
|
||||
if (line_below || is_prefix || isGroup() || script || (tag.reading() && tag.isComplex())) {
|
||||
REFLECT_IF_READING_SINGLE_VALUE {
|
||||
// complex value
|
||||
REFLECT(name);
|
||||
REFLECT(line_below);
|
||||
|
||||
Reference in New Issue
Block a user