From a2af3211a4e21bb459091c3d1ea0a84081bb1986 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 30 Aug 2008 23:49:12 +0000 Subject: [PATCH] Moved mask to Style and mask related drawing to ValueViewer. Used the same mask also for TextStyles. To keep the text selectable (since the mask is now also used for containsPoint), the future sight cost masks needed to be updated. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1183 0fc631ac-6414-0410-93d0-97cfa31319b6 --- .../costmask.png | Bin 355 -> 543 bytes data/magic-future.mse-style/costmask.png | Bin 971 -> 403 bytes doc/type/style.txt | 11 +++--- src/data/field.cpp | 15 ++++---- src/data/field.hpp | 23 ++++++++----- src/data/field/choice.cpp | 6 ++-- src/data/field/choice.hpp | 1 - src/data/field/color.cpp | 4 +-- src/data/field/color.hpp | 13 ++++--- src/data/field/image.cpp | 2 -- src/data/field/image.hpp | 3 +- src/data/field/text.cpp | 1 - src/data/field/text.hpp | 2 -- src/gfx/mask_image.cpp | 23 +++++++++---- src/render/text/viewer.cpp | 4 +-- src/render/value/choice.cpp | 32 +----------------- src/render/value/choice.hpp | 9 ----- src/render/value/color.cpp | 30 ++-------------- src/render/value/color.hpp | 6 ---- src/render/value/image.cpp | 30 +--------------- src/render/value/image.hpp | 9 ----- src/render/value/multiple_choice.cpp | 32 +----------------- src/render/value/multiple_choice.hpp | 5 --- src/render/value/text.cpp | 9 +---- src/render/value/viewer.cpp | 29 +++++++++++++--- src/render/value/viewer.hpp | 4 +++ src/script/image.cpp | 2 +- src/script/image.hpp | 14 ++++++-- 28 files changed, 105 insertions(+), 214 deletions(-) diff --git a/data/magic-future-textless.mse-style/costmask.png b/data/magic-future-textless.mse-style/costmask.png index ad142e29d811c26a51b0b56fe86cb723aee03e38..3f8545e14aecc6f259f9db6dda14880b6e0f1832 100644 GIT binary patch delta 530 zcmV+t0`2|d0-pqs7=Hu<0002S&15kE000kAOjJcbKR*Bf00993|NsB~{{H9*b+Z5f z0n155K~#9!?b{7%!!Qg5V8eC*$=d{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uU#ik`PS@=A4K0hV>O*!p$D6OTS{Tv)G*j^$QyFG@+} z)@qOXdIx6Jhgl2%9jF(nrr6s*?^(FR!cvxhY&;=lnNznDK=vC&C?= zEWQ7L(%s7|d|Mej6w+V1D5(Z1f!sWWyOLP>os&)|)*C+D5LsF2e~kf{g!Dm42<*0^ zex9FPKyy3eLFUfAwNMNsKi2~;ugFiT{7i 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