Added 'position hint' to packages, used to specify the order of the packages in a package list;

Added 'pack type', intended for playtesting (random boosters/starters);
Added 'default(_image)' property to ImageStyle, and added the frame fillers for magic;
Added blurring and bold printing (rather hacky) to the text rendering functions (used for "double click to add image" text);
Added 'symmetric overlay' combine mode, which will look really nice for hybrids;
Moved the watermark choices from the game to an include file in magic-watermarks;
Working on a replacement for the image scripting system that plays nicer with the rest of the code. In particular, it will be possible to compare generated images quickly, so they can be updated continuously. This is a work in progress, currently there are two versions of everything.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@327 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-09 21:41:15 +00:00
parent 6f7db851a7
commit 3c4729aaa2
63 changed files with 964 additions and 134 deletions
+16 -11
View File
@@ -24,17 +24,24 @@ String ValueAction::getName(bool to_undo) const {
// ----------------------------------------------------------------------------- : Simple
/// Swap the value in a Value object with a new one
inline void swap_value(ChoiceValue& a, ChoiceValue ::ValueType& b) { swap(a.value, b); }
inline void swap_value(MultipleChoiceValue& a, MultipleChoiceValue::ValueType& b) { swap(a.value, b); }
inline void swap_value(ColorValue& a, ColorValue ::ValueType& b) { swap(a.value, b); }
inline void swap_value(ImageValue& a, ImageValue ::ValueType& b) { swap(a.filename, b); a.last_update.update(); }
inline void swap_value(SymbolValue& a, SymbolValue ::ValueType& b) { swap(a.filename, b); a.last_update.update(); }
inline void swap_value(TextValue& a, TextValue ::ValueType& b) { swap(a.value, b); a.last_update.update(); }
/// A ValueAction that swaps between old and new values
template <typename T, bool ALLOW_MERGE>
class SimpleValueAction : public ValueAction {
public:
inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value, typename T::ValueType T::*member)
inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value)
: ValueAction(value), new_value(new_value)
, member(member)
{}
virtual void perform(bool to_undo) {
swap(static_cast<T&>(*valueP).*member, new_value);
swap_value(static_cast<T&>(*valueP), new_value);
valueP->onAction(*this, to_undo); // notify value
}
@@ -52,14 +59,13 @@ class SimpleValueAction : public ValueAction {
private:
typename T::ValueType new_value;
typename T::ValueType T::*member;
};
ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<ChoiceValue, true> (value, new_value, &ChoiceValue::value); }
ValueAction* value_action(const MultipleChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<MultipleChoiceValue, false>(value, new_value, &MultipleChoiceValue::value); }
ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value) { return new SimpleValueAction<ColorValue, true> (value, new_value, &ColorValue::value); }
ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, false>(value, new_value, &ImageValue::filename); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, false>(value, new_value, &SymbolValue::filename); }
ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<ChoiceValue, true> (value, new_value); }
ValueAction* value_action(const MultipleChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<MultipleChoiceValue, false>(value, new_value); }
ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value) { return new SimpleValueAction<ColorValue, true> (value, new_value); }
ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, false>(value, new_value); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, false>(value, new_value); }
// ----------------------------------------------------------------------------- : Text
@@ -74,8 +80,7 @@ TextValueAction::TextValueAction(const TextValueP& value, size_t start, size_t e
String TextValueAction::getName(bool to_undo) const { return name; }
void TextValueAction::perform(bool to_undo) {
swap(value().value, new_value);
value().last_update.update();
swap_value(value(), new_value);
swap(selection_end, new_selection_end);
valueP->onAction(*this, to_undo); // notify value
}
+3 -1
View File
@@ -26,11 +26,13 @@ IMPLEMENT_REFLECTION(ImageField) {
IMPLEMENT_REFLECTION(ImageStyle) {
REFLECT_BASE(Style);
REFLECT_N("mask", mask_filename);
REFLECT_N("default", default_image);
}
bool ImageStyle::update(Context& ctx) {
return Style ::update(ctx)
| mask_filename.update(ctx);
| mask_filename.update(ctx)
| default_image.update(ctx);
}
// ----------------------------------------------------------------------------- : ImageValue
+4 -1
View File
@@ -12,6 +12,7 @@
#include <util/prec.hpp>
#include <data/field.hpp>
#include <script/scriptable.hpp>
#include <script/image.hpp>
// ----------------------------------------------------------------------------- : ImageField
@@ -38,6 +39,7 @@ class ImageStyle : public Style {
DECLARE_STYLE_TYPE(Image);
Scriptable<String> mask_filename; ///< Filename for a mask image
ScriptableImage2 default_image; ///< Placeholder
virtual bool update(Context&);
@@ -53,7 +55,8 @@ class ImageValue : public Value {
inline ImageValue(const ImageFieldP& field) : Value(field) {}
typedef FileName ValueType;
ValueType filename; ///< Filename of the image (in the current package), or ""
ValueType filename; ///< Filename of the image (in the current package), or ""
Age last_update; ///< When was the image last changed?
virtual String toString() const;
+2 -2
View File
@@ -29,11 +29,11 @@ IMPLEMENT_REFLECTION(SymbolStyle) {
REFLECT(variations);
}
SymbolStyle::Variation::Variation()
SymbolVariation::SymbolVariation()
: border_radius(0.05)
{}
IMPLEMENT_REFLECTION(SymbolStyle::Variation) {
IMPLEMENT_REFLECTION(SymbolVariation) {
REFLECT(name);
REFLECT(border_radius);
REFLECT_NAMELESS(filter);
+6 -6
View File
@@ -14,6 +14,7 @@
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE(SymbolFilter);
DECLARE_POINTER_TYPE(SymbolVariation);
// ----------------------------------------------------------------------------- : SymbolField
@@ -39,18 +40,16 @@ class SymbolStyle : public Style {
inline SymbolStyle(const SymbolFieldP& field) : Style(field) {}
DECLARE_STYLE_TYPE(Symbol);
class Variation;
typedef shared_ptr<Variation> VariationP;
vector<VariationP> variations; ///< Different variantions of the same symbol
vector<SymbolVariationP> variations; ///< Different variantions of the same symbol
private:
DECLARE_REFLECTION();
};
/// Styling for a symbol variation, defines color, border, etc.
class SymbolStyle::Variation {
class SymbolVariation {
public:
Variation();
SymbolVariation();
String name; ///< Name of this variation
SymbolFilterP filter; ///< Filter to color the symbol
double border_radius; ///< Border radius for the symbol
@@ -66,7 +65,8 @@ class SymbolValue : public Value {
DECLARE_HAS_FIELD(Symbol)
typedef FileName ValueType;
ValueType filename; ///< Filename of the symbol (in the current package)
ValueType filename; ///< Filename of the symbol (in the current package)
Age last_update; ///< When was the symbol last changed?
virtual String toString() const;
+2
View File
@@ -10,6 +10,7 @@
#include <data/field.hpp>
#include <data/keyword.hpp>
#include <data/statistics.hpp>
#include <data/pack.hpp>
#include <util/io/package_manager.hpp>
#include <script/script.hpp>
@@ -47,6 +48,7 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT(card_fields);
REFLECT(statistics_dimensions);
REFLECT(statistics_categories);
REFLECT(pack_types);
REFLECT(has_keywords);
REFLECT(keyword_modes);
REFLECT(keyword_parameter_types);
+2
View File
@@ -20,6 +20,7 @@ DECLARE_POINTER_TYPE(Style);
DECLARE_POINTER_TYPE(Game);
DECLARE_POINTER_TYPE(StatsDimension);
DECLARE_POINTER_TYPE(StatsCategory);
DECLARE_POINTER_TYPE(PackType);
DECLARE_POINTER_TYPE(KeywordParam);
DECLARE_POINTER_TYPE(KeywordMode);
DECLARE_POINTER_TYPE(Keyword);
@@ -40,6 +41,7 @@ class Game : public Packaged {
vector<FieldP> card_fields; ///< Fields on each card
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
vector<PackTypeP> pack_types; ///< Types of random card packs to generate
bool has_keywords; ///< Does this game use keywords?
vector<KeywordParamP> keyword_parameter_types;///< Types of keyword parameters
+29
View File
@@ -0,0 +1,29 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/pack.hpp>
// ----------------------------------------------------------------------------- : PackType
PackType::PackType()
: enabled(true)
{}
IMPLEMENT_REFLECTION(PackType) {
REFLECT(name);
REFLECT(enabled);
REFLECT(card_types);
}
// ----------------------------------------------------------------------------- : CardType
IMPLEMENT_REFLECTION(CardType) {
REFLECT(name);
REFLECT(amount);
REFLECT(filter);
}
+51
View File
@@ -0,0 +1,51 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_PACK
#define HEADER_DATA_PACK
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/reflect.hpp>
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE(CardType);
DECLARE_POINTER_TYPE(Card);
class Set;
// ----------------------------------------------------------------------------- : PackType
/// A card pack description for playtesting
class PackType {
public:
PackType();
String name; ///< Name of this pack
vector<CardTypeP> card_types; ///< Cards in this pack
Scriptable<bool> enabled; ///< Is this pack enabled?
/// Generate a random pack of cards
void generate(Set& set, vector<CardP>& out);
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : CardType
/// A card type description for playtesting
class CardType {
public:
String name; ///< Name of this type of cards
Scriptable<int> amount; ///< Number of cards of this type
OptionalScript filter; ///< Filter to select this type of cards
private:
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : EOF
#endif