diff --git a/data/magic-future-textless.mse-style/costmask.png b/data/magic-future-textless.mse-style/costmask.png
index ad142e29..3f8545e1 100644
Binary files a/data/magic-future-textless.mse-style/costmask.png and b/data/magic-future-textless.mse-style/costmask.png differ
diff --git a/data/magic-future.mse-style/costmask.png b/data/magic-future.mse-style/costmask.png
index c797b838..640d80de 100644
Binary files a/data/magic-future.mse-style/costmask.png and b/data/magic-future.mse-style/costmask.png differ
diff --git a/doc/type/style.txt b/doc/type/style.txt
index 16510939..a9975c90 100644
--- a/doc/type/style.txt
+++ b/doc/type/style.txt
@@ -76,6 +76,7 @@ Here are some examples:
| @bottom@ [[type:scriptable]] [[type:double]] ''Required'' Distance between bottom edge of the box and the ''top'' of the card in pixels.
| @angle@ [[type:scriptable]] [[type:int]] @0@ Rotation of this box, in degrees counter clockwise.
| @visible@ [[type:scriptable]] [[type:boolean]] @true@ Is this field visible at all?
+| @mask@ [[type:image|scriptable image]] ''none'' A mask to apply to the image, black areas in the mask become transparent, similar to [[fun:set_mask]].
The rest of the properties depend on the type of [[type:field]] this style is for.
! Type Property Type Default Description
@@ -103,9 +104,11 @@ The rest of the properties depend on the type of [[type:field]] this style is fo
| ^^^ @line height line max@ ^^^ ^^^ ^^^
| ^^^ @paragraph height@ [[type:double]] ''flexible'' The height of paragraphs. If specified, each paragraph is given this much space, and aligned inside that space as specified by @alignment@.
A paragraph break is any line break that is not soft (i.e. caused by word wrap or a @""@ break).
-| ^^^ @mask@ [[type:filename]] ''none'' A mask that indicates where in the box text can be placed.
+| ^^^ @mask@ [[type:image|scriptable image]] ''none'' A mask that indicates where in the box text can be placed.
Text is never put in black areas of the box:
-
+ 
+ The same mask image is also used to determine the size and shape of the box.
+ To include a certain pixel in the size/shape but not allow text to be placed there, it can be made dark gray (a value less than 128).
| ^^^ @content width@ [[type:double]] ''automatic'' When read from a script, gives the width of the current content in this box.
| ^^^ @content height@ [[type:double]] ''automatic'' When read from a script, gives the height of the current content in this box.
| ^^^ @content lines@ [[type:int]] ''automatic'' When read from a script, gives the number of lines of the current content in this box.
@@ -141,12 +144,10 @@ The rest of the properties depend on the type of [[type:field]] this style is fo
| ^^^ @right width@ ^^^ ^^^ ^^^
| ^^^ @top width@ ^^^ ^^^ ^^^
| ^^^ @bottom width@ ^^^ ^^^ ^^^
-| ^^^ @mask@ [[type:scriptable]] [[type:filename]] ''none'' A mask to apply to the box, black areas in the mask become transparent.
| ^^^ @combine@ [[type:combine]] @"normal"@ How to combine the color with the background? Only applies when a mask is used.
! <<< <<< <<< <<<
-| @"image"@ @mask@ [[type:scriptable]] [[type:filename]] ''none'' A mask to apply to the image, black areas in the mask become transparent, similair to [[fun:set_mask]].
-| ^^^ @default@ [[type:image|scriptable image]] ''none'' A default image to use when the card has none.
+| @"image"@ @default@ [[type:image|scriptable image]] ''none'' A default image to use when the card has none.
! <<< <<< <<< <<<
| @"symbol"@ @variations@ [[type:list]] of [[type:symbol variation]]s Available variations of the symbol, a variation describes color and border size.
diff --git a/src/data/field.cpp b/src/data/field.cpp
index 87abb71d..aee4883a 100644
--- a/src/data/field.cpp
+++ b/src/data/field.cpp
@@ -118,6 +118,7 @@ IMPLEMENT_REFLECTION(Style) {
REFLECT(bottom);
REFLECT(angle);
REFLECT(visible);
+ REFLECT(mask);
}
void init_object(const FieldP& field, StyleP& style) {
@@ -135,15 +136,16 @@ inline bool is_setw(const Scriptable& x) {
}
int Style::update(Context& ctx) {
- bool changed =
- left .update(ctx)
+ int changed =
+ ( left .update(ctx)
| width .update(ctx)
| right .update(ctx)
| top .update(ctx)
| height .update(ctx)
| bottom .update(ctx)
- | angle .update(ctx)
- | visible.update(ctx);
+ | angle .update(ctx) ) * CHANGE_SIZE
+ | visible.update(ctx) * CHANGE_OTHER
+ | mask .update(ctx) * CHANGE_MASK;
// determine automatic_side and attachment of rotation point
if (automatic_side == AUTO_UNKNOWN) {
if (!is_set (right)) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
@@ -154,7 +156,7 @@ int Style::update(Context& ctx) {
else if (!is_setw(height)) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
else if (!is_set (top)) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_TB);
- changed = true;
+ changed |= CHANGE_SIZE;
}
if (!changed) return CHANGE_NONE;
// update the automatic_side
@@ -181,7 +183,7 @@ int Style::update(Context& ctx) {
if (width < 0) width = -width;
if (height < 0) height = -height;
// done
- return CHANGE_OTHER;
+ return changed;
}
bool Style::isVisible() const {
@@ -214,6 +216,7 @@ void Style::checkContentDependencies(Context& ctx, const Dependency& dep) const
right .initDependencies(ctx,dep);
bottom .initDependencies(ctx,dep);
visible.initDependencies(ctx,dep);
+ mask .initDependencies(ctx,dep);
}
void Style::markDependencyMember(const String& name, const Dependency& dep) const {
diff --git a/src/data/field.hpp b/src/data/field.hpp
index ec7744c2..a3b604d5 100644
--- a/src/data/field.hpp
+++ b/src/data/field.hpp
@@ -16,6 +16,7 @@
#include
#include