diff --git a/src/data/field/boolean.cpp b/src/data/field/boolean.cpp index c2501ff3..675a9ea1 100644 --- a/src/data/field/boolean.cpp +++ b/src/data/field/boolean.cpp @@ -11,9 +11,9 @@ // ----------------------------------------------------------------------------- : BooleanField BooleanField::BooleanField() { -// choices->choices.push_back(new_shared1(_("yes"))); -// choices->choices.push_back(new_shared1(_("no"))); -// choices->initIds(); + choices->choices.push_back(new_shared1(_("yes"))); + choices->choices.push_back(new_shared1(_("no"))); + choices->initIds(); } StyleP BooleanField::newStyle(const FieldP& thisP) const { diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index 2457da8c..38637188 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -43,6 +43,9 @@ IMPLEMENT_REFLECTION(ChoiceField) { ChoiceField::Choice::Choice() : first_id(0) {} +ChoiceField::Choice::Choice(const String& name) + : first_id(0), name(name) +{} bool ChoiceField::Choice::isGroup() const { diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index ea9a2739..77cb0c00 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -42,6 +42,9 @@ class ChoiceField : public Field { /// An item that can be chosen for this field class ChoiceField::Choice { public: + Choice(); + Choice(const String& name); + String name; ///< Name/value of the item String default_name; ///< A default item, if this is a group and default_name.empty() there is no default vector choices; ///< Choices and sub groups in this group @@ -50,9 +53,7 @@ class ChoiceField::Choice { * The top level group has first_id 0. */ int first_id; - - Choice(); - + /// Is this a group? bool isGroup() const; /// Can this Choice itself be chosen? diff --git a/src/data/field/multiple_choice.cpp b/src/data/field/multiple_choice.cpp new file mode 100644 index 00000000..da0e0d98 --- /dev/null +++ b/src/data/field/multiple_choice.cpp @@ -0,0 +1,58 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +// ----------------------------------------------------------------------------- : Includes + +#include + +// ----------------------------------------------------------------------------- : MultipleChoiceField + +MultipleChoiceField::MultipleChoiceField() + : minimum_selection(0) + , maximum_selection(1000000) +{} + +StyleP MultipleChoiceField::newStyle(const FieldP& thisP) const { + return new_shared(); +} + +ValueP MultipleChoiceField::newValue(const FieldP& thisP) const { + return new_shared(); +} + +String MultipleChoiceField::typeName() const { + return _("multiple choice"); +} + +IMPLEMENT_REFLECTION(MultipleChoiceField) { + REFLECT_BASE(ChoiceField); + REFLECT(minimum_selection); + REFLECT(maximum_selection); +} + +// ----------------------------------------------------------------------------- : MultipleChoiceStyle + +MultipleChoiceStyle::MultipleChoiceStyle() + : direction(HORIZONTAL) + , spacing(0) +{} + +IMPLEMENT_REFLECTION_ENUM(Direction) { + VALUE_N("horizontal", HORIZONTAL); + VALUE_N("vertical", VERTICAL); +} + +IMPLEMENT_REFLECTION(MultipleChoiceStyle) { + REFLECT_BASE(ChoiceStyle); + REFLECT(direction); + REFLECT(spacing); +} + +// ----------------------------------------------------------------------------- : MultipleChoiceValue + +IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) { + REFLECT_BASE(ChoiceValue); +} diff --git a/src/data/field/multiple_choice.hpp b/src/data/field/multiple_choice.hpp new file mode 100644 index 00000000..27d588fc --- /dev/null +++ b/src/data/field/multiple_choice.hpp @@ -0,0 +1,69 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2006 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +#ifndef HEADER_DATA_FIELD_MULTIPLE_CHOICE +#define HEADER_DATA_FIELD_MULTIPLE_CHOICE + +// ----------------------------------------------------------------------------- : Includes + +#include +#include + +// ----------------------------------------------------------------------------- : MultipleChoiceField + +/// A ChoiceField where multiple choices can be selected simultaniously +class MultipleChoiceField : public ChoiceField { + public: + MultipleChoiceField(); + + UInt minimum_selection, maximum_selection; ///< How many choices can be selected simultaniously? + + virtual ValueP newValue(const FieldP& thisP) const; + virtual StyleP newStyle(const FieldP& thisP) const; + virtual String typeName() const; + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : MultipleChoiceStyle + +enum Direction { + HORIZONTAL, VERTICAL +}; + +/// The Style for a MultipleChoiceField +class MultipleChoiceStyle : public ChoiceStyle { + public: + MultipleChoiceStyle(); + + Direction direction; ///< In what direction are choices layed out? + double spacing; ///< Spacing between choices (images) in pixels + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : MultipleChoiceValue + +/// The Value in a MultipleChoiceField +/** The value is stored as ", , " + * The choices must be ordered by id + */ +class MultipleChoiceValue : public ChoiceValue { + public: + // no extra data + + /// Splits the value, stores the selected choices in the out parameter + void get(vector& out); + + private: + DECLARE_REFLECTION(); +}; + + +// ----------------------------------------------------------------------------- : EOF +#endif