diff --git a/data/magic-new.mse-style/style b/data/magic-new.mse-style/style index 0a4acb70..69e011de 100644 --- a/data/magic-new.mse-style/style +++ b/data/magic-new.mse-style/style @@ -41,54 +41,6 @@ init script: } -############################################################## Set info fields -info style: - title: - padding left: 2 - font: - size: 16 - symbol: - variation: - name: common - border radius: 0.10 - fill type: solid - fill color: rgb(0,0,0) - border color: rgb(255,255,255) - variation: - name: uncommon - border radius: 0.05 - fill type: linear gradient - fill color 1: rgb(224,224,224) - fill color 2: rgb(84, 84, 84) - border color 1: rgb(0, 0, 0) - border color 2: rgb(0, 0, 0) - variation: - name: rare - border radius: 0.05 - fill type: linear gradient - fill color 1: rgb(214,196,94) - fill color 2: rgb(95, 84, 40) - border color 1: rgb(0, 0, 0) - border color 2: rgb(0, 0, 0) - variation: - name: special - border radius: 0.10 - fill type: linear gradient - fill color 1: rgb(224,170,247) - fill color 2: rgb(58,7,80) - border color 1: rgb(255,255,255) - border color 2: rgb(255,255,255) - automatic reminder text: - render style: both - choice images: - yes: script: buildin_image("bool_yes") - no: script: buildin_image("bool_no") - use gradient multicolor: - render style: both - choice images: - yes: script: buildin_image("bool_yes") - no: script: buildin_image("bool_no") - ############################################################## Extra style diff --git a/data/magic.mse-game/game b/data/magic.mse-game/game index 40f1dbfd..a64b6833 100644 --- a/data/magic.mse-game/game +++ b/data/magic.mse-game/game @@ -273,6 +273,15 @@ set field: choice: only for custom keywords choice: no description: Should reminder text be added to keywords by default? Note: you can enable/disable reminder text by right clicking the keyword. +set field: + # TODO : RENAME + type: multiple choice + name: automatic reminder text2 + choice: old keywords + choice: core set keywords + choice: expert level keywords + choice: custom keywords + description: Should reminder text be added to keywords by default? Note: you can enable/disable reminder text by right clicking the keyword. set field: type: boolean name: automatic card numbers @@ -290,6 +299,58 @@ set field: description: Use gradients on multicolor cards by default, you can always change it be clicking on the card border. initial: no +############################# Default style + +default set style: + title: + padding left: 2 + font: + size: 16 + symbol: + variation: + name: common + border radius: 0.10 + fill type: solid + fill color: rgb(0,0,0) + border color: rgb(255,255,255) + variation: + name: uncommon + border radius: 0.05 + fill type: linear gradient + fill color 1: rgb(224,224,224) + fill color 2: rgb(84, 84, 84) + border color 1: rgb(0, 0, 0) + border color 2: rgb(0, 0, 0) + variation: + name: rare + border radius: 0.05 + fill type: linear gradient + fill color 1: rgb(214,196,94) + fill color 2: rgb(95, 84, 40) + border color 1: rgb(0, 0, 0) + border color 2: rgb(0, 0, 0) + variation: + name: special + border radius: 0.10 + fill type: linear gradient + fill color 1: rgb(224,170,247) + fill color 2: rgb(58,7,80) + border color 1: rgb(255,255,255) + border color 2: rgb(255,255,255) + automatic reminder text: + render style: both + choice images: + yes: script: buildin_image("bool_yes") + no: script: buildin_image("bool_no") + automatic reminder text2: + render style: checklist + direction: vertical + use gradient multicolor: + render style: both + choice images: + yes: script: buildin_image("bool_yes") + no: script: buildin_image("bool_no") + ############################################################## Card fields ############################# Background stuff @@ -719,10 +780,6 @@ statistics dimension: numeric: true icon: stats/casting_cost.png -statistics dimension: - name: rarity_twice - script: card.rarity + card.rarity - statistics category: name: color / rarity dimension: card_color @@ -805,6 +862,19 @@ statistics category: has keywords: true +keyword mode: + name: old + description: Old keywords (Banding, Phasing, etc.) +keyword mode: + name: core + description: Core set keywords (Flying, Haste, etc.) +keyword mode: + name: expert + description: Expert level keywords (Cycling, Vanishing, etc.) +keyword mode: + name: custom + description: Custom keywords + keyword parameter type: name: no parameter keyword parameter type: diff --git a/src/data/field.hpp b/src/data/field.hpp index 5f8ce0b9..809b0218 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -92,6 +92,9 @@ class Style { inline RealSize getSize() const { return RealSize ( width, height); } inline RealRect getRect() const { return RealRect (left, top, width, height); } + /// Get a copy of this style + virtual StyleP clone() const = 0; + /// Make a viewer object for values using this style /** thisP is a smart pointer to this */ virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP) = 0; @@ -157,12 +160,16 @@ template <> ValueP read_new(Reader&); ValueP Type ## Field::newValue(const FieldP& thisP) const { \ assert(thisP.get() == this); \ return new_shared1(static_pointer_cast(thisP)); \ + } \ + StyleP Type ## Style::clone() const { \ + return new_shared1(*this); \ } #define DECLARE_STYLE_TYPE(Type) \ DECLARE_HAS_FIELD(Type) \ + virtual StyleP clone() const; \ virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \ - virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP) + virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP); // implement field() which returns a field with the right (derived) type #define DECLARE_HAS_FIELD(Type) \ diff --git a/src/data/field/boolean.hpp b/src/data/field/boolean.hpp index ca58f8f0..b9cde89a 100644 --- a/src/data/field/boolean.hpp +++ b/src/data/field/boolean.hpp @@ -37,6 +37,7 @@ class BooleanStyle : public ChoiceStyle { public: BooleanStyle(const ChoiceFieldP& field); DECLARE_HAS_FIELD(Boolean); // not DECLARE_STYLE_TYPE, because we use a normal ChoiceValueViewer/Editor + virtual StyleP clone() const; // no extra data diff --git a/src/data/game.cpp b/src/data/game.cpp index 9f21bc63..c8012109 100644 --- a/src/data/game.cpp +++ b/src/data/game.cpp @@ -40,6 +40,9 @@ IMPLEMENT_REFLECTION(Game) { REFLECT_BASE(Packaged); REFLECT(init_script); REFLECT(set_fields); + REFLECT_IF_READING { + default_set_style.init(set_fields); + } REFLECT(default_set_style); REFLECT(card_fields); REFLECT(statistics_dimensions); diff --git a/src/data/stylesheet.cpp b/src/data/stylesheet.cpp index 43233764..81a5182f 100644 --- a/src/data/stylesheet.cpp +++ b/src/data/stylesheet.cpp @@ -69,8 +69,8 @@ IMPLEMENT_REFLECTION(StyleSheet) { REFLECT(card_background); if (game) { REFLECT_IF_READING { - card_style .init(game->card_fields); - set_info_style.init(game->set_fields); + card_style.init(game->card_fields); + set_info_style.cloneFrom(game->default_set_style); } REFLECT(card_style); REFLECT(set_info_style); diff --git a/src/util/index_map.hpp b/src/util/index_map.hpp index caefbb8d..98feb933 100644 --- a/src/util/index_map.hpp +++ b/src/util/index_map.hpp @@ -53,6 +53,15 @@ class IndexMap : private vector { init_object(key, (*this)[key->index]); } } + /// Initialize this map with cloned values from another list + void cloneFrom(const IndexMap& values) { + if (this->size() == values.size()) return; + this->reserve(values.size()); + for(size_t index = size() ; index < values.size() ; ++index) { + const Value& value = values[index]; + push_back(value ? value->clone() : value); + } + } /// Change this map by adding an additional key and value void add(const Key& key, const Value& value) { assert(get_key(value) == key);