'initial' property for color fields;

export options stored in settings;
editor for export options.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@429 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-23 19:44:50 +00:00
parent e46cbe66b2
commit df9bb78e51
17 changed files with 88 additions and 27 deletions
+8
View File
@@ -291,6 +291,14 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
// ----------------------------------------------------------------------------- : ChoiceValue
ChoiceValue::ChoiceValue(const ChoiceFieldP& field, bool initial_first_choice)
: Value(field)
, value( !field->initial.empty() ? field->initial
: initial_first_choice ? field->choices->choiceName(0)
: _("")
, true)
{}
String ChoiceValue::toString() const {
return value();
}
+5 -6
View File
@@ -167,12 +167,11 @@ class ChoiceStyle : public Style {
/// The Value in a ChoiceField
class ChoiceValue : public Value {
public:
inline ChoiceValue(const ChoiceFieldP& field, bool initial_empty = false)
: Value(field)
, value(field->initial.empty() && !initial_empty
? field->choices->choiceName(0) // first choice
: field->initial, true)
{}
/// Create a value for the given field
/** If initial_first_choice then the first choice should be used in the absence of
an explicit initial value
*/
ChoiceValue(const ChoiceFieldP& field, bool initial_first_choice = true);
DECLARE_HAS_FIELD(Choice)
typedef Defaultable<String> ValueType;
+9
View File
@@ -35,6 +35,7 @@ IMPLEMENT_REFLECTION(ColorField) {
REFLECT_BASE(Field);
REFLECT(script);
REFLECT_N("default", default_script);
REFLECT(initial);
REFLECT(default_name);
REFLECT(allow_custom);
REFLECT(choices);
@@ -73,6 +74,14 @@ bool ColorStyle::update(Context& ctx) {
// ----------------------------------------------------------------------------- : ColorValue
ColorValue::ColorValue(const ColorFieldP& field)
: Value(field)
, value( !field->initial.isDefault() ? field->initial()
: !field->choices.empty() ? field->choices[0]->color
: *wxBLACK
, true)
{}
String ColorValue::toString() const {
if (value.isDefault()) return field().default_name;
// is this a named color?
+7 -6
View File
@@ -29,11 +29,12 @@ class ColorField : public Field {
class Choice;
typedef intrusive_ptr<Choice> ChoiceP;
OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value
vector<ChoiceP> choices; ///< Color choices available
bool allow_custom; ///< Are colors not in the list of choices allowed?
String default_name; ///< Name of "default" value
OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value
vector<ChoiceP> choices; ///< Color choices available
bool allow_custom; ///< Are colors not in the list of choices allowed?
Defaultable<Color> initial; ///< Initial choice of a new value, if not set the first choice is used
String default_name; ///< Name of "default" value
virtual void initDependencies(Context&, const Dependency&) const;
@@ -76,7 +77,7 @@ class ColorStyle : public Style {
/// The Value in a ColorField
class ColorValue : public Value {
public:
inline ColorValue(const ColorFieldP& field) : Value(field) {}
ColorValue(const ColorFieldP& field);
DECLARE_HAS_FIELD(Color)
typedef Defaultable<Color> ValueType;
+1 -1
View File
@@ -54,7 +54,7 @@ class MultipleChoiceStyle : public ChoiceStyle {
*/
class MultipleChoiceValue : public ChoiceValue {
public:
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, true) {}
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, false) {}
DECLARE_HAS_FIELD(MultipleChoice);
String last_change; ///< Which of the choices was selected/deselected last?