From ff96f1522aafb11bf8eee6e29deebc599444c3bf Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 19 Oct 2006 18:44:27 +0000 Subject: [PATCH] added FieldP to values and styles, implemented reflection for IndexMap git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@36 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/action/symbol.cpp | 10 +++---- src/data/action/symbol.hpp | 4 +-- src/data/card.cpp | 1 + src/data/card.hpp | 11 ++++---- src/data/field.cpp | 33 ++++++++++++++++------- src/data/field.hpp | 36 ++++++++++++++++++++++--- src/data/field/boolean.cpp | 8 +----- src/data/field/boolean.hpp | 8 ++++++ src/data/field/choice.cpp | 18 ++++++------- src/data/field/choice.hpp | 8 +++++- src/data/field/color.cpp | 21 ++++++--------- src/data/field/color.hpp | 10 +++++-- src/data/field/image.cpp | 8 +----- src/data/field/image.hpp | 7 +++++ src/data/field/multiple_choice.cpp | 13 +++------ src/data/field/multiple_choice.hpp | 8 +++++- src/data/field/symbol.cpp | 8 +----- src/data/field/symbol.hpp | 8 ++++++ src/data/field/text.cpp | 42 +++++++++++++++++++++++------- src/data/field/text.hpp | 20 +++++++++----- src/data/set.cpp | 2 +- src/data/set.hpp | 10 ++++--- src/gui/symbol/part_list.cpp | 8 +++--- src/main.cpp | 5 +++- src/mse.vcproj | 36 +++++++++++++++++++++++++ src/script/value.hpp | 4 ++- src/util/index_map.hpp | 28 +++++++++++--------- src/util/io/get_member.hpp | 11 ++++++++ src/util/io/reader.hpp | 15 +++++++++-- src/util/io/writer.hpp | 11 ++++++++ 30 files changed, 290 insertions(+), 122 deletions(-) diff --git a/src/data/action/symbol.cpp b/src/data/action/symbol.cpp index 01ea5908..36795e83 100644 --- a/src/data/action/symbol.cpp +++ b/src/data/action/symbol.cpp @@ -355,8 +355,8 @@ void DuplicateSymbolPartsAction::getParts(set& parts) { // ----------------------------------------------------------------------------- : Reorder symbol parts -ReorderSymbolPartsAction::ReorderSymbolPartsAction(Symbol& symbol, size_t partId1, size_t partId2) - : symbol(symbol), partId1(partId1), partId2(partId2) +ReorderSymbolPartsAction::ReorderSymbolPartsAction(Symbol& symbol, size_t part_id1, size_t part_id2) + : symbol(symbol), part_id1(part_id1), part_id2(part_id2) {} String ReorderSymbolPartsAction::getName(bool to_undo) const { @@ -364,7 +364,7 @@ String ReorderSymbolPartsAction::getName(bool to_undo) const { } void ReorderSymbolPartsAction::perform(bool to_undo) { - assert(partId1 < symbol.parts.size()); - assert(partId2 < symbol.parts.size()); - swap(symbol.parts[partId1], symbol.parts[partId2]); + assert(part_id1 < symbol.parts.size()); + assert(part_id2 < symbol.parts.size()); + swap(symbol.parts[part_id1], symbol.parts[part_id2]); } diff --git a/src/data/action/symbol.hpp b/src/data/action/symbol.hpp index 0a2159ae..08795a3f 100644 --- a/src/data/action/symbol.hpp +++ b/src/data/action/symbol.hpp @@ -223,7 +223,7 @@ class DuplicateSymbolPartsAction : public SymbolPartListAction { /// Change the position of a part in a symbol, by swapping two parts. class ReorderSymbolPartsAction : public SymbolPartListAction { public: - ReorderSymbolPartsAction(Symbol& symbol, size_t partId1, size_t partId2); + ReorderSymbolPartsAction(Symbol& symbol, size_t part_id1, size_t part_id2); virtual String getName(bool to_undo) const; virtual void perform(bool to_undo); @@ -231,7 +231,7 @@ class ReorderSymbolPartsAction : public SymbolPartListAction { private: Symbol& symbol; ///< Symbol to swap the parts in public: - size_t partId1, partId2; ///< Indeces of parts to swap + size_t part_id1, part_id2; ///< Indeces of parts to swap }; diff --git a/src/data/card.cpp b/src/data/card.cpp index fa258cc7..a85a5963 100644 --- a/src/data/card.cpp +++ b/src/data/card.cpp @@ -35,5 +35,6 @@ String Card::identification() const { IMPLEMENT_REFLECTION(Card) { REFLECT(notes); + REFLECT_NAMELESS(data); } diff --git a/src/data/card.hpp b/src/data/card.hpp index 893ce3f1..b4671e61 100644 --- a/src/data/card.hpp +++ b/src/data/card.hpp @@ -31,20 +31,19 @@ class Card { /// Creates a card using the given game Card(const Game& game); - /// Get an identification of the card, an identification is something like a name, title, etc. - String identification() const; - /// The values on the fields of the card. - /** The indices should correspond to the cardFields in the Game */ + /** The indices should correspond to the card_fields in the Game */ IndexMap data; - /// Notes for this card String notes; - /// Alternative style to use for this card /** Optional; if not set use the card style from the set */ StyleSheetP stylesheet; + /// Get the identification of this card, an identification is something like a name, title, etc. + /** May return "" */ + String identification() const; + DECLARE_REFLECTION(); }; diff --git a/src/data/field.cpp b/src/data/field.cpp index 689d49c5..520dc108 100644 --- a/src/data/field.cpp +++ b/src/data/field.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -56,21 +57,29 @@ shared_ptr read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); - if (type == _("text")) return new_shared(); - else if (type == _("choice")) return new_shared(); - else if (type == _("boolean")) return new_shared(); - else if (type == _("image")) return new_shared(); - else if (type == _("symbol")) return new_shared(); - else if (type == _("color")) return new_shared(); + if (type == _("text")) return new_shared(); + else if (type == _("choice")) return new_shared(); + else if (type == _("multiple choice")) return new_shared(); + else if (type == _("boolean")) return new_shared(); + else if (type == _("image")) return new_shared(); + else if (type == _("symbol")) return new_shared(); + else if (type == _("color")) return new_shared(); else { throw ParseError(_("Unsupported field type: '") + type + _("'")); } } - // ----------------------------------------------------------------------------- : Style +Style::Style(const FieldP& field) + : fieldP(field) + , z_index(0) + , left(0), width (1) + , top (0), height(1) + , visible(true) +{} + Style::~Style() {} IMPLEMENT_REFLECTION(Style) { @@ -82,9 +91,12 @@ IMPLEMENT_REFLECTION(Style) { REFLECT(visible); } -void initObject(const FieldP& field, StyleP& style) { +void init_object(const FieldP& field, StyleP& style) { style = field->newStyle(field); } +template <> StyleP read_new