mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
'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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user