'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
+5
View File
@@ -19,8 +19,13 @@ String ExportTemplate::typeName() const { return _("export-template"); }
IMPLEMENT_REFLECTION(ExportTemplate) {
REFLECT_BASE(Packaged);
REFLECT(game);
REFLECT(file_type);
REFLECT(create_directory);
REFLECT(option_fields);
REFLECT_IF_READING option_style.init(option_fields);
REFLECT(option_style);
REFLECT(script);
}
// ----------------------------------------------------------------------------- :
+1 -1
View File
@@ -25,11 +25,11 @@ class ExportTemplate : public Packaged {
ExportTemplate();
GameP game; ///< Game this template is for
OptionalScript script; ///< Export script
String file_type; ///< Type of the created file, in "name|*.ext" format
bool create_directory; ///< The export creates an entire directory
vector<FieldP> option_fields; ///< Options for exporting
IndexMap<FieldP,StyleP> option_style; ///< Style of the options
OptionalScript script; ///< Export script, for multi file templates and initialization
static String typeNameStatic();
virtual String typeName() const;
+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?
+6
View File
@@ -10,6 +10,7 @@
#include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/field.hpp>
#include <data/export_template.hpp>
#include <util/reflect.hpp>
#include <util/platform.hpp>
#include <util/io/reader.hpp>
@@ -148,6 +149,10 @@ StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet
return *ss;
}
IndexMap<FieldP,ValueP>& Settings::exportOptionsFor(const ExportTemplate& export) {
return export_options.get(export.name(), export.option_fields);
}
/// Retrieve the directory to use for settings and other data files
String user_settings_dir() {
String dir = wxStandardPaths::Get().GetUserDataDir();
@@ -180,6 +185,7 @@ IMPLEMENT_REFLECTION(Settings) {
REFLECT(game_settings);
REFLECT(stylesheet_settings);
REFLECT(default_stylesheet_settings);
REFLECT(export_options);
}
void Settings::read() {
+11
View File
@@ -15,10 +15,13 @@
class Game;
class StyleSheet;
class ExportTemplate;
class Field;
DECLARE_POINTER_TYPE(GameSettings);
DECLARE_POINTER_TYPE(StyleSheetSettings);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value);
// ----------------------------------------------------------------------------- : Extra data structures
@@ -133,6 +136,14 @@ class Settings {
public:
StyleSheetSettings default_stylesheet_settings; ///< The default settings for stylesheets
// --------------------------------------------------- : Exports
private:
DelayedIndexMaps<FieldP,ValueP> export_options;
public:
/// Get the options for an export template
IndexMap<FieldP,ValueP>& exportOptionsFor(const ExportTemplate& export);
// --------------------------------------------------- : Special game stuff
String apprentice_location;
String mws_location;