// //+----------------------------------------------------------------------------+ //| Description: Magic Set Editor - Program to make Magic (tm) cards | //| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" | //| License: GNU General Public License 2 or later (see file COPYING) | //+----------------------------------------------------------------------------+ // ----------------------------------------------------------------------------- : Includes #include #include #include #include #include #include #include #include #include #include #include #include DECLARE_TYPEOF_COLLECTION(StyleListener*); // ----------------------------------------------------------------------------- : Field Field::Field() : index (0) // sensible default? , editable (true) , save_value (true) , show_statistics (true) , position_hint (0) , identifying (false) , card_list_column (100) , card_list_width (100) , card_list_visible(false) , card_list_allow (true) , card_list_align (ALIGN_LEFT) , tab_index (0) {} Field::~Field() {} void Field::initDependencies(Context& ctx, const Dependency& dep) const { sort_script.initDependencies(ctx, dep); } IMPLEMENT_REFLECTION(Field) { REFLECT_IF_NOT_READING { String type = typeName(); REFLECT(type); } REFLECT(name); REFLECT_IF_READING name = cannocial_name_form(name); REFLECT(description); REFLECT_N("icon", icon_filename); REFLECT(editable); REFLECT(save_value); REFLECT(show_statistics); REFLECT(position_hint); REFLECT(identifying); REFLECT(card_list_column); REFLECT(card_list_width); REFLECT(card_list_visible); REFLECT(card_list_allow); REFLECT(card_list_name); REFLECT(sort_script); REFLECT_IF_READING if(card_list_name.empty()) card_list_name = name; REFLECT_N("card_list_alignment", card_list_align); REFLECT(tab_index); } template <> intrusive_ptr read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); if (type == _("text")) return new_intrusive(); else if (type == _("choice")) return new_intrusive(); else if (type == _("multiple choice")) return new_intrusive(); else if (type == _("boolean")) return new_intrusive(); else if (type == _("image")) return new_intrusive(); else if (type == _("symbol")) return new_intrusive(); else if (type == _("color")) return new_intrusive(); else if (type == _("info")) return new_intrusive(); else if (type == _("package choice")) return new_intrusive(); else if (type.empty()) { reader.warning(_ERROR_1_("expected key", _("type"))); throw ParseError(_ERROR_("aborting parsing")); } else { reader.warning(_ERROR_1_("unsupported field type", type)); throw ParseError(_ERROR_("aborting parsing")); } } // ----------------------------------------------------------------------------- : Style Style::Style(const FieldP& field) : fieldP(field) , z_index(0) , left (1000000), top (1000000) , width(0), height(0) , right(1000000), bottom(1000000) , angle(0) , visible(true) , automatic_side(AUTO_UNKNOWN) , content_dependent(false) {} Style::~Style() {} IMPLEMENT_REFLECTION(Style) { REFLECT(z_index); REFLECT(left); REFLECT(width); REFLECT(right); REFLECT(top); REFLECT(height); REFLECT(bottom); REFLECT(angle); REFLECT(visible); } void init_object(const FieldP& field, StyleP& style) { if (!style) style = field->newStyle(field); } template <> StyleP read_new