From ca5d78c10109e870cc2b73c79aa64851b76990dc Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 12 Oct 2006 20:25:08 +0000 Subject: [PATCH] More field types, just the headers for now git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@21 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/field/boolean.cpp | 13 +++++ src/data/field/boolean.hpp | 51 +++++++++++++++++ src/data/field/choice.cpp | 13 +++++ src/data/field/choice.hpp | 114 +++++++++++++++++++++++++++++++++++++ src/data/field/color.cpp | 13 +++++ src/data/field/color.hpp | 76 +++++++++++++++++++++++++ src/data/field/image.cpp | 13 +++++ src/data/field/image.hpp | 47 +++++++++++++++ src/data/field/symbol.cpp | 13 +++++ src/data/field/symbol.hpp | 61 ++++++++++++++++++++ src/data/field/text.hpp | 12 ++-- 11 files changed, 420 insertions(+), 6 deletions(-) create mode 100644 src/data/field/boolean.cpp create mode 100644 src/data/field/boolean.hpp create mode 100644 src/data/field/choice.cpp create mode 100644 src/data/field/choice.hpp create mode 100644 src/data/field/color.cpp create mode 100644 src/data/field/color.hpp create mode 100644 src/data/field/image.cpp create mode 100644 src/data/field/image.hpp create mode 100644 src/data/field/symbol.cpp create mode 100644 src/data/field/symbol.hpp diff --git a/src/data/field/boolean.cpp b/src/data/field/boolean.cpp new file mode 100644 index 00000000..59392939 --- /dev/null +++ b/src/data/field/boolean.cpp @@ -0,0 +1,13 @@ +//+----------------------------------------------------------------------------+ +//| 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 + +// ----------------------------------------------------------------------------- : BooleanField +// ----------------------------------------------------------------------------- : BooleanStyle +// ----------------------------------------------------------------------------- : BooleanValue diff --git a/src/data/field/boolean.hpp b/src/data/field/boolean.hpp new file mode 100644 index 00000000..70e33b38 --- /dev/null +++ b/src/data/field/boolean.hpp @@ -0,0 +1,51 @@ +//+----------------------------------------------------------------------------+ +//| 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_BOOLEAN +#define HEADER_DATA_FIELD_BOOLEAN + +// ----------------------------------------------------------------------------- : Includes + +#include +#include + +// ----------------------------------------------------------------------------- : BooleanField + +/// A field whos value is either true or false +class BooleanField : public ChoiceField { + public: + BooleanField(); + + // no extra data + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : BooleanStyle + +/// The Style for a BooleanField +class BooleanStyle : public ChoiceStyle { + public: + // no extra data + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : BooleanValue + +/// The Value in a BooleanField +class BooleanValue : public ChoiceValue { + public: + // no extra data + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : EOF +#endif diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp new file mode 100644 index 00000000..f1e88e5c --- /dev/null +++ b/src/data/field/choice.cpp @@ -0,0 +1,13 @@ +//+----------------------------------------------------------------------------+ +//| 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 + +// ----------------------------------------------------------------------------- : ChoiceField +// ----------------------------------------------------------------------------- : ChoiceStyle +// ----------------------------------------------------------------------------- : ChoiceValue \ No newline at end of file diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp new file mode 100644 index 00000000..64e39c6e --- /dev/null +++ b/src/data/field/choice.hpp @@ -0,0 +1,114 @@ +//+----------------------------------------------------------------------------+ +//| 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_CHOICE +#define HEADER_DATA_FIELD_CHOICE + +// ----------------------------------------------------------------------------- : Includes + +#include +#include +#include +#include // for ImageCombine + +// ----------------------------------------------------------------------------- : ChoiceField + +/// A field that contains a list of choices +class ChoiceField : public Field { + public: + class Choice; + DECLARE_POINTER_TYPE(Choice); + + private: + DECLARE_REFLECTION(); +}; + +/// An item that can be chosen for this field +class ChoiceField::Choice { + public: + 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 + UInt first_id; ///< First item-id in this group (can be the default item) + + /// Is this a group? + bool isGroup() const; + /// Can this Choice itself be chosen? + bool hasDefault() const; + + /// Initialize the first_id of children + /** Returns lastId() */ + UInt initIds() const; + /// Number of choices in this group (and subgroups), 1 if it is not a group + /** The default choice also counts */ + UInt choiceCount() const; + /// item-id just beyond the end of this group + UInt lastId() const; + + /// item-id of a choice, given the internal name + /** If the id is not in this group, returns -1 */ + UInt choiceId(const String& name); + /// Internal name of a choice + /** The internal name is formed by concatenating the names of all parents, separated by spaces. + * Returns "" if id is not in this group + */ + String choiceName(UInt id); + /// Formated name of a choice. + /** Intended for use in menu structures, so it doesn't include the group name for children. + * Returns "" if id is not in this group. + */ + String choiceNameNice(UInt id); + + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : ChoiceStyle + +// How should the menu for a choice look? +enum ChoicePopupStyle +{ POPUP_MENU +, POPUP_DROPDOWN +, POPUP_DROPDOWN_IN_PLACE +}; +// How should a choice value be rendered? +enum ChoiceRenderStyle +{ RENDER_TEXT = 0x01 // render the name as text +, RENDER_IMAGE = 0x10 // render an image +, RENDER_BOTH = RENDER_TEXT | RENDER_IMAGE +, RENDER_HIDDEN = 0x20 // don't render anything, only have a menu +, RENDER_HIDDEN_IMAGE = RENDER_HIDDEN | RENDER_IMAGE +}; + +/// The Style for a ChoiceField +class ChoiceStyle : public Style { + public: + +// FontInfo font; ///< Font for drawing text (when RENDER_TEXT) +// map choice_images; ///< Images for the various choices (when RENDER_IMAGE) + map choice_colors; ///< Colors for the various choices (when color_cardlist) + bool colors_card_list;///< Does this field determine colors of the rows in the card list? + ChoicePopupStyle popup_style; ///< Style of popups/menus + ChoiceRenderStyle render_style; ///< Style of rendering + String mask_filename; ///< Filename of an additional mask over the images + ImageCombine combine; ///< Combining mode for drawing the images + Alignment alignment; ///< Alignment of images + + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : ChoiceValue + +/// The Value in a ChoiceField +class ChoiceValue : public Value { + public: + Defaultable value; /// The name of the selected choice + private: + DECLARE_REFLECTION(); +}; + +// ----------------------------------------------------------------------------- : EOF +#endif diff --git a/src/data/field/color.cpp b/src/data/field/color.cpp new file mode 100644 index 00000000..e70b4283 --- /dev/null +++ b/src/data/field/color.cpp @@ -0,0 +1,13 @@ +//+----------------------------------------------------------------------------+ +//| 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 + +// ----------------------------------------------------------------------------- : ColorField +// ----------------------------------------------------------------------------- : ColorStyle +// ----------------------------------------------------------------------------- : ColorValue diff --git a/src/data/field/color.hpp b/src/data/field/color.hpp new file mode 100644 index 00000000..0817c509 --- /dev/null +++ b/src/data/field/color.hpp @@ -0,0 +1,76 @@ +//+----------------------------------------------------------------------------+ +//| 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_COLOR +#define HEADER_DATA_FIELD_COLOR + +// ----------------------------------------------------------------------------- : Includes + +#include +#include +#include +#include