Commit fa4d91f2 authored by twanvl's avatar twanvl

'initial' property for color fields;

export options stored in settings;
editor for export options.
parent 974399c7
...@@ -348,6 +348,9 @@ label: ...@@ -348,6 +348,9 @@ label:
This is a standard %s keyword, you can not edit it. This is a standard %s keyword, you can not edit it.
If you make a copy of the keyword your copy will take precedent. If you make a copy of the keyword your copy will take precedent.
# Style tab
styling options: Styling options
# Open dialogs # Open dialogs
all files All files all files All files
...@@ -389,6 +392,7 @@ label: ...@@ -389,6 +392,7 @@ label:
# Html export # Html export
html template: Template: html template: Template:
html export options:Export options
# Image slicer # Image slicer
original: Original: original: Original:
......
...@@ -19,8 +19,13 @@ String ExportTemplate::typeName() const { return _("export-template"); } ...@@ -19,8 +19,13 @@ String ExportTemplate::typeName() const { return _("export-template"); }
IMPLEMENT_REFLECTION(ExportTemplate) { IMPLEMENT_REFLECTION(ExportTemplate) {
REFLECT_BASE(Packaged); REFLECT_BASE(Packaged);
REFLECT(game);
REFLECT(file_type); REFLECT(file_type);
REFLECT(create_directory); REFLECT(create_directory);
REFLECT(option_fields);
REFLECT_IF_READING option_style.init(option_fields);
REFLECT(option_style);
REFLECT(script);
} }
// ----------------------------------------------------------------------------- : // ----------------------------------------------------------------------------- :
...@@ -25,11 +25,11 @@ class ExportTemplate : public Packaged { ...@@ -25,11 +25,11 @@ class ExportTemplate : public Packaged {
ExportTemplate(); ExportTemplate();
GameP game; ///< Game this template is for GameP game; ///< Game this template is for
OptionalScript script; ///< Export script
String file_type; ///< Type of the created file, in "name|*.ext" format String file_type; ///< Type of the created file, in "name|*.ext" format
bool create_directory; ///< The export creates an entire directory bool create_directory; ///< The export creates an entire directory
vector<FieldP> option_fields; ///< Options for exporting vector<FieldP> option_fields; ///< Options for exporting
IndexMap<FieldP,StyleP> option_style; ///< Style of the options IndexMap<FieldP,StyleP> option_style; ///< Style of the options
OptionalScript script; ///< Export script, for multi file templates and initialization
static String typeNameStatic(); static String typeNameStatic();
virtual String typeName() const; virtual String typeName() const;
......
...@@ -291,6 +291,14 @@ IMPLEMENT_REFLECTION(ChoiceStyle) { ...@@ -291,6 +291,14 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
// ----------------------------------------------------------------------------- : ChoiceValue // ----------------------------------------------------------------------------- : 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 { String ChoiceValue::toString() const {
return value(); return value();
} }
......
...@@ -167,12 +167,11 @@ class ChoiceStyle : public Style { ...@@ -167,12 +167,11 @@ class ChoiceStyle : public Style {
/// The Value in a ChoiceField /// The Value in a ChoiceField
class ChoiceValue : public Value { class ChoiceValue : public Value {
public: public:
inline ChoiceValue(const ChoiceFieldP& field, bool initial_empty = false) /// Create a value for the given field
: Value(field) /** If initial_first_choice then the first choice should be used in the absence of
, value(field->initial.empty() && !initial_empty an explicit initial value
? field->choices->choiceName(0) // first choice */
: field->initial, true) ChoiceValue(const ChoiceFieldP& field, bool initial_first_choice = true);
{}
DECLARE_HAS_FIELD(Choice) DECLARE_HAS_FIELD(Choice)
typedef Defaultable<String> ValueType; typedef Defaultable<String> ValueType;
......
...@@ -35,6 +35,7 @@ IMPLEMENT_REFLECTION(ColorField) { ...@@ -35,6 +35,7 @@ IMPLEMENT_REFLECTION(ColorField) {
REFLECT_BASE(Field); REFLECT_BASE(Field);
REFLECT(script); REFLECT(script);
REFLECT_N("default", default_script); REFLECT_N("default", default_script);
REFLECT(initial);
REFLECT(default_name); REFLECT(default_name);
REFLECT(allow_custom); REFLECT(allow_custom);
REFLECT(choices); REFLECT(choices);
...@@ -73,6 +74,14 @@ bool ColorStyle::update(Context& ctx) { ...@@ -73,6 +74,14 @@ bool ColorStyle::update(Context& ctx) {
// ----------------------------------------------------------------------------- : ColorValue // ----------------------------------------------------------------------------- : 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 { String ColorValue::toString() const {
if (value.isDefault()) return field().default_name; if (value.isDefault()) return field().default_name;
// is this a named color? // is this a named color?
......
...@@ -29,11 +29,12 @@ class ColorField : public Field { ...@@ -29,11 +29,12 @@ class ColorField : public Field {
class Choice; class Choice;
typedef intrusive_ptr<Choice> ChoiceP; typedef intrusive_ptr<Choice> ChoiceP;
OptionalScript script; ///< Script to apply to all values OptionalScript script; ///< Script to apply to all values
OptionalScript default_script; ///< Script that generates the default value OptionalScript default_script; ///< Script that generates the default value
vector<ChoiceP> choices; ///< Color choices available vector<ChoiceP> choices; ///< Color choices available
bool allow_custom; ///< Are colors not in the list of choices allowed? bool allow_custom; ///< Are colors not in the list of choices allowed?
String default_name; ///< Name of "default" value 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; virtual void initDependencies(Context&, const Dependency&) const;
...@@ -76,7 +77,7 @@ class ColorStyle : public Style { ...@@ -76,7 +77,7 @@ class ColorStyle : public Style {
/// The Value in a ColorField /// The Value in a ColorField
class ColorValue : public Value { class ColorValue : public Value {
public: public:
inline ColorValue(const ColorFieldP& field) : Value(field) {} ColorValue(const ColorFieldP& field);
DECLARE_HAS_FIELD(Color) DECLARE_HAS_FIELD(Color)
typedef Defaultable<Color> ValueType; typedef Defaultable<Color> ValueType;
......
...@@ -54,7 +54,7 @@ class MultipleChoiceStyle : public ChoiceStyle { ...@@ -54,7 +54,7 @@ class MultipleChoiceStyle : public ChoiceStyle {
*/ */
class MultipleChoiceValue : public ChoiceValue { class MultipleChoiceValue : public ChoiceValue {
public: public:
inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, true) {} inline MultipleChoiceValue(const MultipleChoiceFieldP& field) : ChoiceValue(field, false) {}
DECLARE_HAS_FIELD(MultipleChoice); DECLARE_HAS_FIELD(MultipleChoice);
String last_change; ///< Which of the choices was selected/deselected last? String last_change; ///< Which of the choices was selected/deselected last?
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <data/game.hpp> #include <data/game.hpp>
#include <data/stylesheet.hpp> #include <data/stylesheet.hpp>
#include <data/field.hpp> #include <data/field.hpp>
#include <data/export_template.hpp>
#include <util/reflect.hpp> #include <util/reflect.hpp>
#include <util/platform.hpp> #include <util/platform.hpp>
#include <util/io/reader.hpp> #include <util/io/reader.hpp>
...@@ -148,6 +149,10 @@ StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet ...@@ -148,6 +149,10 @@ StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet
return *ss; 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 /// Retrieve the directory to use for settings and other data files
String user_settings_dir() { String user_settings_dir() {
String dir = wxStandardPaths::Get().GetUserDataDir(); String dir = wxStandardPaths::Get().GetUserDataDir();
...@@ -180,6 +185,7 @@ IMPLEMENT_REFLECTION(Settings) { ...@@ -180,6 +185,7 @@ IMPLEMENT_REFLECTION(Settings) {
REFLECT(game_settings); REFLECT(game_settings);
REFLECT(stylesheet_settings); REFLECT(stylesheet_settings);
REFLECT(default_stylesheet_settings); REFLECT(default_stylesheet_settings);
REFLECT(export_options);
} }
void Settings::read() { void Settings::read() {
......
...@@ -15,10 +15,13 @@ ...@@ -15,10 +15,13 @@
class Game; class Game;
class StyleSheet; class StyleSheet;
class ExportTemplate;
class Field; class Field;
DECLARE_POINTER_TYPE(GameSettings); DECLARE_POINTER_TYPE(GameSettings);
DECLARE_POINTER_TYPE(StyleSheetSettings); DECLARE_POINTER_TYPE(StyleSheetSettings);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value);
// ----------------------------------------------------------------------------- : Extra data structures // ----------------------------------------------------------------------------- : Extra data structures
...@@ -133,6 +136,14 @@ class Settings { ...@@ -133,6 +136,14 @@ class Settings {
public: public:
StyleSheetSettings default_stylesheet_settings; ///< The default settings for stylesheets 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 // --------------------------------------------------- : Special game stuff
String apprentice_location; String apprentice_location;
String mws_location; String mws_location;
......
...@@ -19,7 +19,7 @@ DEFINE_EVENT_TYPE(EVENT_SIZE_CHANGE); ...@@ -19,7 +19,7 @@ DEFINE_EVENT_TYPE(EVENT_SIZE_CHANGE);
// ----------------------------------------------------------------------------- : CardViewer // ----------------------------------------------------------------------------- : CardViewer
CardViewer::CardViewer(Window* parent, int id, long style) CardViewer::CardViewer(Window* parent, int id, long style)
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style) : wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style | wxNO_FULL_REPAINT_ON_RESIZE)
, up_to_date(false) , up_to_date(false)
{} {}
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <gui/value/editor.hpp> #include <gui/value/editor.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <data/stylesheet.hpp> #include <data/stylesheet.hpp>
#include <data/export_template.hpp>
#include <data/settings.hpp>
DECLARE_TYPEOF_COLLECTION(ValueViewerP); DECLARE_TYPEOF_COLLECTION(ValueViewerP);
DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>); DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
...@@ -199,3 +201,15 @@ void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) { ...@@ -199,3 +201,15 @@ void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) {
void StylingEditor::onChangeSet() { void StylingEditor::onChangeSet() {
showStylesheet(set->stylesheet); showStylesheet(set->stylesheet);
} }
// ----------------------------------------------------------------------------- : ExportOptionsEditor
ExportOptionsEditor::ExportOptionsEditor(Window* parent, int id, long style)
: NativeLookEditor(parent, id, style)
{}
void ExportOptionsEditor::showExport(const ExportTemplateP& export) {
setStyles(set->stylesheet, export->option_style);
setData(settings.exportOptionsFor(*export));
}
...@@ -84,9 +84,6 @@ class ExportOptionsEditor : public NativeLookEditor { ...@@ -84,9 +84,6 @@ class ExportOptionsEditor : public NativeLookEditor {
/// Show the options for given export template /// Show the options for given export template
void showExport(const ExportTemplateP& export); void showExport(const ExportTemplateP& export);
protected:
virtual void onChangeSet();
}; };
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <gui/html_export_window.hpp> #include <gui/html_export_window.hpp>
#include <gui/control/package_list.hpp> #include <gui/control/package_list.hpp>
#include <gui/control/native_look_editor.hpp>
#include <data/set.hpp> #include <data/set.hpp>
#include <data/game.hpp> #include <data/game.hpp>
#include <data/settings.hpp> #include <data/settings.hpp>
...@@ -20,18 +21,24 @@ DECLARE_POINTER_TYPE(ExportTemplate); ...@@ -20,18 +21,24 @@ DECLARE_POINTER_TYPE(ExportTemplate);
// ----------------------------------------------------------------------------- : HtmlExportWindow // ----------------------------------------------------------------------------- : HtmlExportWindow
HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set) HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set)
: wxDialog(parent,wxID_ANY,_TITLE_("export html"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE) : wxDialog(parent,wxID_ANY,_TITLE_("export html"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN)
, set(set) , set(set)
{ {
// init controls // init controls
list = new PackageList(this, ID_EXPORT_LIST); list = new PackageList(this, ID_EXPORT_LIST);
options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER);
options->setSet(set);
// init sizers // init sizers
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4); s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
s->Add(list, 0, wxEXPAND | wxALL & ~wxTOP, 4); s->Add(list, 0, wxEXPAND | wxALL & ~wxTOP, 4);
wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("html export options"));
s2->Add(options, 2, wxEXPAND, 0);
s->Add(s2, 1, wxEXPAND | wxALL, 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8); s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this); s->SetSizeHints(this);
SetSizer(s); SetSizer(s);
SetSize(700,500);
// list // list
list->showData<ExportTemplate>(set->game->name() + _("-*")); list->showData<ExportTemplate>(set->game->name() + _("-*"));
list->select(settings.gameSettingsFor(*set->game).default_export); list->select(settings.gameSettingsFor(*set->game).default_export);
...@@ -57,6 +64,7 @@ void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) { ...@@ -57,6 +64,7 @@ void HtmlExportWindow::onTemplateSelect(wxCommandEvent&) {
wxBusyCursor wait; wxBusyCursor wait;
ExportTemplateP export = list->getSelection<ExportTemplate>(); ExportTemplateP export = list->getSelection<ExportTemplate>();
handle_pending_errors(); handle_pending_errors();
options->showExport(export);
settings.gameSettingsFor(*set->game).default_export = export->name(); settings.gameSettingsFor(*set->game).default_export = export->name();
UpdateWindowUI(wxUPDATE_UI_RECURSE); UpdateWindowUI(wxUPDATE_UI_RECURSE);
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <util/prec.hpp> #include <util/prec.hpp>
class PackageList; class PackageList;
class ExportOptionsEditor;
DECLARE_POINTER_TYPE(Set); DECLARE_POINTER_TYPE(Set);
// ----------------------------------------------------------------------------- : HtmlExportWindow // ----------------------------------------------------------------------------- : HtmlExportWindow
...@@ -21,8 +22,9 @@ class HtmlExportWindow : public wxDialog { ...@@ -21,8 +22,9 @@ class HtmlExportWindow : public wxDialog {
HtmlExportWindow(Window* parent, const SetP& set); HtmlExportWindow(Window* parent, const SetP& set);
private: private:
PackageList* list; ///< List of templates PackageList* list; ///< List of templates
SetP set; ///< Set to export ExportOptionsEditor* options; ///< Editor for template options
SetP set; ///< Set to export
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
......
...@@ -26,14 +26,14 @@ StylePanel::StylePanel(Window* parent, int id) ...@@ -26,14 +26,14 @@ StylePanel::StylePanel(Window* parent, int id)
preview = new CardViewer (this, wxID_ANY); preview = new CardViewer (this, wxID_ANY);
editor = new StylingEditor(this, wxID_ANY, wxNO_BORDER); editor = new StylingEditor(this, wxID_ANY, wxNO_BORDER);
list = new PackageList (this, wxID_ANY); list = new PackageList (this, wxID_ANY);
use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _("Use for &all cards")); use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _BUTTON_("use for all cards"));
// init sizer // init sizer
wxSizer* s = new wxBoxSizer(wxHORIZONTAL); wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
s->Add(preview, 0, wxRIGHT, 2); s->Add(preview, 0, wxRIGHT, 2);
wxSizer* s2 = new wxBoxSizer(wxVERTICAL); wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4); s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
s2->Add(use_for_all, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 4); s2->Add(use_for_all, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 4);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _("Extra styling options")); wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
s3->Add(editor, 2, wxEXPAND, 0); s3->Add(editor, 2, wxEXPAND, 0);
s2->Add(s3, 1, wxEXPAND | wxALL, 2); s2->Add(s3, 1, wxEXPAND | wxALL, 2);
s->Add(s2, 1, wxEXPAND, 8); s->Add(s2, 1, wxEXPAND, 8);
......
...@@ -3217,9 +3217,6 @@ ...@@ -3217,9 +3217,6 @@
<File <File
RelativePath="..\data\en.mse-locale\locale"> RelativePath="..\data\en.mse-locale\locale">
</File> </File>
<File
RelativePath="..\data\nl.mse-locale\locale">
</File>
<File <File
RelativePath=".\main.cpp"> RelativePath=".\main.cpp">
</File> </File>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment