mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
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
This commit is contained in:
@@ -16,13 +16,7 @@ BooleanField::BooleanField() {
|
||||
choices->initIds();
|
||||
}
|
||||
|
||||
StyleP BooleanField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<BooleanStyle>();
|
||||
}
|
||||
|
||||
ValueP BooleanField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<BooleanValue>();
|
||||
}
|
||||
FIELD_TYPE(Boolean)
|
||||
|
||||
String BooleanField::typeName() const {
|
||||
return _("boolean");
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : BooleanField
|
||||
|
||||
DECLARE_POINTER_TYPE(BooleanField);
|
||||
|
||||
/// A field whos value is either true or false
|
||||
class BooleanField : public ChoiceField {
|
||||
public:
|
||||
@@ -34,6 +36,9 @@ class BooleanField : public ChoiceField {
|
||||
/// The Style for a BooleanField
|
||||
class BooleanStyle : public ChoiceStyle {
|
||||
public:
|
||||
inline BooleanStyle(const ChoiceFieldP& field) : ChoiceStyle(field) {}
|
||||
HAS_FIELD(Boolean)
|
||||
|
||||
// no extra data
|
||||
|
||||
private:
|
||||
@@ -45,6 +50,9 @@ class BooleanStyle : public ChoiceStyle {
|
||||
/// The Value in a BooleanField
|
||||
class BooleanValue : public ChoiceValue {
|
||||
public:
|
||||
inline BooleanValue(const ChoiceFieldP& field) : ChoiceValue(field) {}
|
||||
HAS_FIELD(Boolean)
|
||||
|
||||
// no extra data
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,13 +17,7 @@ ChoiceField::ChoiceField()
|
||||
, default_name(_("Default"))
|
||||
{}
|
||||
|
||||
StyleP ChoiceField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<ChoiceStyle>();
|
||||
}
|
||||
|
||||
ValueP ChoiceField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<ChoiceValue>();
|
||||
}
|
||||
FIELD_TYPE(Choice)
|
||||
|
||||
String ChoiceField::typeName() const {
|
||||
return _("choice");
|
||||
@@ -153,8 +147,13 @@ template <> void GetMember::handle(const ChoiceField::Choice& c) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : ChoiceStyle
|
||||
|
||||
ChoiceStyle::ChoiceStyle()
|
||||
|
||||
ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field)
|
||||
: Style(field)
|
||||
, popup_style(POPUP_DROPDOWN)
|
||||
, render_style(RENDER_TEXT)
|
||||
, combine(COMBINE_NORMAL)
|
||||
, alignment(ALIGN_STRETCH)
|
||||
, colors_card_list(false)
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(ChoicePopupStyle) {
|
||||
@@ -191,7 +190,6 @@ String ChoiceValue::toString() const {
|
||||
return value();
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(ChoiceValue) {
|
||||
REFLECT_NAMELESS(value);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : ChoiceField
|
||||
|
||||
DECLARE_POINTER_TYPE(ChoiceField);
|
||||
|
||||
/// A field that contains a list of choices
|
||||
class ChoiceField : public Field {
|
||||
public:
|
||||
@@ -108,7 +110,8 @@ enum ChoiceRenderStyle
|
||||
/// The Style for a ChoiceField
|
||||
class ChoiceStyle : public Style {
|
||||
public:
|
||||
ChoiceStyle();
|
||||
ChoiceStyle(const ChoiceFieldP& field);
|
||||
HAS_FIELD(Choice)
|
||||
|
||||
ChoicePopupStyle popup_style; ///< Style of popups/menus
|
||||
ChoiceRenderStyle render_style; ///< Style of rendering
|
||||
@@ -129,6 +132,9 @@ class ChoiceStyle : public Style {
|
||||
/// The Value in a ChoiceField
|
||||
class ChoiceValue : public Value {
|
||||
public:
|
||||
inline ChoiceValue(const ChoiceFieldP& field) : Value(field) {}
|
||||
HAS_FIELD(Choice)
|
||||
|
||||
Defaultable<String> value; /// The name of the selected choice
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
@@ -17,13 +17,7 @@ ColorField::ColorField()
|
||||
, allow_custom(true)
|
||||
{}
|
||||
|
||||
StyleP ColorField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<ColorStyle>();
|
||||
}
|
||||
|
||||
ValueP ColorField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<ColorValue>();
|
||||
}
|
||||
FIELD_TYPE(Color)
|
||||
|
||||
String ColorField::typeName() const {
|
||||
return _("color");
|
||||
@@ -47,8 +41,9 @@ IMPLEMENT_REFLECTION(ColorField::Choice) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorStyle
|
||||
|
||||
ColorStyle::ColorStyle()
|
||||
: radius(0)
|
||||
ColorStyle::ColorStyle(const ColorFieldP& field)
|
||||
: Style(field)
|
||||
, radius(0)
|
||||
, left_width(100000), right_width (100000)
|
||||
, top_width (100000), bottom_width(100000)
|
||||
{}
|
||||
@@ -65,12 +60,12 @@ IMPLEMENT_REFLECTION(ColorStyle) {
|
||||
// ----------------------------------------------------------------------------- : ColorValue
|
||||
|
||||
String ColorValue::toString() const {
|
||||
/* if (value.isDefault()) return field->default_name;
|
||||
if (value.isDefault()) return field().default_name;
|
||||
// is this a named color?
|
||||
FOR_EACH(c, field->choices) {
|
||||
if (value == c->color) return c->name;
|
||||
FOR_EACH(c, field().choices) {
|
||||
if (value() == c->color) return c->name;
|
||||
}
|
||||
*/ return _("<color>");
|
||||
return _("<color>");
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION_NAMELESS(ColorValue) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorField
|
||||
|
||||
DECLARE_POINTER_TYPE(ColorField);
|
||||
|
||||
/// A field for color values, it contains a list of choices for colors
|
||||
class ColorField : public Field {
|
||||
public:
|
||||
@@ -52,14 +54,15 @@ class ColorField::Choice {
|
||||
/// The Style for a ColorField
|
||||
class ColorStyle : public Style {
|
||||
public:
|
||||
ColorStyle();
|
||||
ColorStyle(const ColorFieldP& field);
|
||||
HAS_FIELD(Color)
|
||||
|
||||
int radius; ///< Radius of round corners
|
||||
UInt left_width; ///< Width of the colored region on the left side
|
||||
UInt right_width; ///< Width of the colored region on the right side
|
||||
UInt top_width; ///< Width of the colored region on the top side
|
||||
UInt bottom_width; ///< Width of the colored region on the bottom side
|
||||
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@@ -69,6 +72,9 @@ class ColorStyle : public Style {
|
||||
/// The Value in a ColorField
|
||||
class ColorValue : public Value {
|
||||
public:
|
||||
inline ColorValue(const ColorFieldP& field) : Value(field) {}
|
||||
HAS_FIELD(Color)
|
||||
|
||||
Defaultable<Color> value; ///< The value
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
@@ -10,13 +10,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : ImageField
|
||||
|
||||
StyleP ImageField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<ImageStyle>();
|
||||
}
|
||||
|
||||
ValueP ImageField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<ImageValue>();
|
||||
}
|
||||
FIELD_TYPE(Image)
|
||||
|
||||
String ImageField::typeName() const {
|
||||
return _("image");
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : ImageField
|
||||
|
||||
DECLARE_POINTER_TYPE(ImageField);
|
||||
|
||||
/// A field for image values
|
||||
class ImageField : public Field {
|
||||
public:
|
||||
@@ -33,7 +35,10 @@ class ImageField : public Field {
|
||||
/// The Style for a ImageField
|
||||
class ImageStyle : public Style {
|
||||
public:
|
||||
inline ImageStyle(const ImageFieldP& field) : Style(field) {}
|
||||
|
||||
Scriptable<String> mask_filename; ///< Filename for a mask image
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@@ -43,6 +48,8 @@ class ImageStyle : public Style {
|
||||
/// The Value in a ImageField, i.e. an image
|
||||
class ImageValue : public Value {
|
||||
public:
|
||||
inline ImageValue(const ImageFieldP& field) : Value(field) {}
|
||||
|
||||
String filename; ///< Filename of the image (in the current package), or ""
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
@@ -15,13 +15,7 @@ MultipleChoiceField::MultipleChoiceField()
|
||||
, maximum_selection(1000000)
|
||||
{}
|
||||
|
||||
StyleP MultipleChoiceField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<MultipleChoiceStyle>();
|
||||
}
|
||||
|
||||
ValueP MultipleChoiceField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<MultipleChoiceValue>();
|
||||
}
|
||||
FIELD_TYPE(MultipleChoice)
|
||||
|
||||
String MultipleChoiceField::typeName() const {
|
||||
return _("multiple choice");
|
||||
@@ -35,8 +29,9 @@ IMPLEMENT_REFLECTION(MultipleChoiceField) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : MultipleChoiceStyle
|
||||
|
||||
MultipleChoiceStyle::MultipleChoiceStyle()
|
||||
: direction(HORIZONTAL)
|
||||
MultipleChoiceStyle::MultipleChoiceStyle(const MultipleChoiceFieldP& field)
|
||||
: ChoiceStyle(field)
|
||||
, direction(HORIZONTAL)
|
||||
, spacing(0)
|
||||
{}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : MultipleChoiceField
|
||||
|
||||
DECLARE_POINTER_TYPE(MultipleChoiceField);
|
||||
|
||||
/// A ChoiceField where multiple choices can be selected simultaniously
|
||||
class MultipleChoiceField : public ChoiceField {
|
||||
public:
|
||||
@@ -38,7 +40,8 @@ enum Direction {
|
||||
/// The Style for a MultipleChoiceField
|
||||
class MultipleChoiceStyle : public ChoiceStyle {
|
||||
public:
|
||||
MultipleChoiceStyle();
|
||||
MultipleChoiceStyle(const MultipleChoiceFieldP& field);
|
||||
HAS_FIELD(MultipleChoice)
|
||||
|
||||
Direction direction; ///< In what direction are choices layed out?
|
||||
double spacing; ///< Spacing between choices (images) in pixels
|
||||
@@ -55,6 +58,9 @@ class MultipleChoiceStyle : public ChoiceStyle {
|
||||
*/
|
||||
class MultipleChoiceValue : public ChoiceValue {
|
||||
public:
|
||||
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field) {}
|
||||
HAS_FIELD(MultipleChoice)
|
||||
|
||||
// no extra data
|
||||
|
||||
/// Splits the value, stores the selected choices in the out parameter
|
||||
|
||||
@@ -10,13 +10,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolField
|
||||
|
||||
StyleP SymbolField::newStyle(const FieldP& thisP) const {
|
||||
return new_shared<SymbolStyle>();
|
||||
}
|
||||
|
||||
ValueP SymbolField::newValue(const FieldP& thisP) const {
|
||||
return new_shared<SymbolValue>();
|
||||
}
|
||||
FIELD_TYPE(Symbol)
|
||||
|
||||
String SymbolField::typeName() const {
|
||||
return _("symbol");
|
||||
|
||||
@@ -17,6 +17,8 @@ DECLARE_POINTER_TYPE(SymbolFilter);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolField
|
||||
|
||||
DECLARE_POINTER_TYPE(SymbolField);
|
||||
|
||||
/// A field for image values
|
||||
class SymbolField : public Field {
|
||||
public:
|
||||
@@ -35,6 +37,9 @@ class SymbolField : public Field {
|
||||
/// The Style for a SymbolField
|
||||
class SymbolStyle : public Style {
|
||||
public:
|
||||
inline SymbolStyle(const SymbolFieldP& field) : Style(field) {}
|
||||
HAS_FIELD(Symbol)
|
||||
|
||||
class Variation;
|
||||
typedef shared_ptr<Variation> VariationP;
|
||||
vector<VariationP> variations; ///< Different variantions of the same symbol
|
||||
@@ -58,6 +63,9 @@ class SymbolStyle::Variation {
|
||||
/// The Value in a SymbolField, i.e. a symbol
|
||||
class SymbolValue : public Value {
|
||||
public:
|
||||
inline SymbolValue(const SymbolFieldP& field) : Value(field) {}
|
||||
HAS_FIELD(Symbol)
|
||||
|
||||
String filename; ///< Filename of the symbol (in the current package)
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
+33
-9
@@ -16,15 +16,7 @@ TextField::TextField()
|
||||
, default_name(_("Default"))
|
||||
{}
|
||||
|
||||
StyleP TextField::newStyle(const FieldP& thisP) const {
|
||||
assert(thisP.get() == this);
|
||||
return new_shared<TextStyle>();
|
||||
}
|
||||
|
||||
ValueP TextField::newValue(const FieldP& thisP) const {
|
||||
assert(thisP.get() == this);
|
||||
return new_shared<TextValue>();
|
||||
}
|
||||
FIELD_TYPE(Text)
|
||||
|
||||
String TextField::typeName() const {
|
||||
return _("text");
|
||||
@@ -42,8 +34,40 @@ IMPLEMENT_REFLECTION(TextField) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextStyle
|
||||
|
||||
TextStyle::TextStyle(const TextFieldP& field)
|
||||
: Style(field)
|
||||
, always_symbol(false), allow_formating(true)
|
||||
, alignment(ALIGN_TOP_LEFT)
|
||||
, angle(0)
|
||||
, padding_left (0), padding_left_min (10000)
|
||||
, padding_right (0), padding_right_min (10000)
|
||||
, padding_top (0), padding_top_min (10000)
|
||||
, padding_bottom(0), padding_bottom_min(10000)
|
||||
, line_height_soft(1.0)
|
||||
, line_height_hard(1.0)
|
||||
, line_height_line(1.0)
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION(TextStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
// REFLECT(font);
|
||||
// REFLECT(symbol_font);
|
||||
REFLECT(always_symbol);
|
||||
REFLECT(allow_formating);
|
||||
REFLECT(alignment);
|
||||
REFLECT(angle);
|
||||
REFLECT(padding_left);
|
||||
REFLECT(padding_right);
|
||||
REFLECT(padding_top);
|
||||
REFLECT(padding_bottom);
|
||||
REFLECT(padding_left_min);
|
||||
REFLECT(padding_right_min);
|
||||
REFLECT(padding_top_min);
|
||||
REFLECT(padding_bottom_min);
|
||||
REFLECT(line_height_soft);
|
||||
REFLECT(line_height_hard);
|
||||
REFLECT(line_height_line);
|
||||
REFLECT_N("mask", mask_filename);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextValue
|
||||
|
||||
+14
-6
@@ -16,6 +16,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextField
|
||||
|
||||
DECLARE_POINTER_TYPE(TextField);
|
||||
|
||||
/// A field for values containing tagged text
|
||||
class TextField : public Field {
|
||||
public:
|
||||
@@ -40,16 +42,19 @@ class TextField : public Field {
|
||||
/// The Style for a TextField
|
||||
class TextStyle : public Style {
|
||||
public:
|
||||
TextStyle(const TextFieldP&);
|
||||
HAS_FIELD(Text)
|
||||
|
||||
// FontInfo font; ///< Font to use for the text
|
||||
// SymbolFontInfo symbol_font; ///< Symbol font for symbols in the text
|
||||
bool always_symbol; ///< Should everything be drawn as symbols?
|
||||
bool allow_formatting; ///< Is formating (bold/italic/..) allowed?
|
||||
bool allow_formating; ///< Is formating (bold/italic/..) allowed?
|
||||
Alignment alignment; ///< Alignment inside the box
|
||||
int angle; ///< Angle of the text inside the box
|
||||
int padding_left, padding_left_min; ///< Padding
|
||||
int padding_right, padding_right_min; ///< Padding
|
||||
int padding_top, padding_top_min; ///< Padding
|
||||
int padding_bottom, padding_bottom_min; ///< Padding
|
||||
double padding_left, padding_left_min; ///< Padding
|
||||
double padding_right, padding_right_min; ///< Padding
|
||||
double padding_top, padding_top_min; ///< Padding
|
||||
double padding_bottom, padding_bottom_min; ///< Padding
|
||||
double line_height_soft; ///< Line height for soft linebreaks
|
||||
double line_height_hard; ///< Line height for hard linebreaks
|
||||
double line_height_line; ///< Line height for <line> tags
|
||||
@@ -63,7 +68,10 @@ class TextStyle : public Style {
|
||||
|
||||
/// The Value in a TextField
|
||||
class TextValue : public Value {
|
||||
public:
|
||||
public:
|
||||
inline TextValue(const TextFieldP& field) : Value(field) {}
|
||||
HAS_FIELD(Text)
|
||||
|
||||
Defaultable<String> value; ///< The text of this value
|
||||
|
||||
virtual String toString() const;
|
||||
|
||||
Reference in New Issue
Block a user