Only draw shadows for layers that should have them (#704)

* Don't draw shadows for transparent layers

* Also use cof shadow setting
This commit is contained in:
Ziemas 2020-08-16 20:59:34 +02:00 committed by GitHub
parent 8d87c19532
commit dccb930f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 1 deletions

View File

@ -40,3 +40,11 @@ const (
// no effect
DrawEffectNone
)
func (d DrawEffect) Transparent() bool {
if d == DrawEffectNone {
return false
}
return true
}

View File

@ -38,4 +38,5 @@ type Animation interface {
GetPlayedCount() int
ResetPlayedCount()
SetEffect(effect d2enum.DrawEffect)
SetShadow(shadow bool)
}

View File

@ -54,6 +54,7 @@ type animation struct {
originAtBottom bool
playLoop bool
hasSubLoop bool // runs after first animation ends
hasShadow bool
}
// SetSubLoop sets a sub loop for the animation
@ -158,7 +159,7 @@ func (a *animation) RenderFromOrigin(target d2iface.Surface, shadow bool) error
defer target.Pop()
}
if shadow {
if shadow && !a.effect.Transparent() && a.hasShadow {
_, height := a.GetFrameBounds()
height = int(math.Abs(float64(height)))
@ -338,3 +339,7 @@ func (a *animation) ResetPlayedCount() {
func (a *animation) SetEffect(e d2enum.DrawEffect) {
a.effect = e
}
func (a *animation) SetShadow(shadow bool) {
a.hasShadow = shadow
}

View File

@ -275,6 +275,7 @@ func (c *Composite) createMode(animationMode animationMode, weaponClass string)
if err == nil {
layer.SetPlaySpeed(mode.animationSpeed)
layer.PlayForward()
layer.SetShadow(cofLayer.Shadow != 0)
if err := layer.SetDirection(c.direction); err != nil {
return nil, err