Skip to content

Commit a76534a

Browse files
committed
fix #458: Use Target instead of Sprite for graphic effects
1 parent 459f7c2 commit a76534a

File tree

2 files changed

+97
-97
lines changed

2 files changed

+97
-97
lines changed

src/blocks/looksblocks.cpp

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -537,172 +537,172 @@ unsigned int LooksBlocks::hide(VirtualMachine *vm)
537537

538538
unsigned int LooksBlocks::changeEffectBy(VirtualMachine *vm)
539539
{
540-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
540+
Target *target = vm->target();
541541

542-
if (sprite) {
542+
if (target) {
543543
IGraphicsEffect *effect = m_customGraphicsEffects[vm->getInput(0, 2)->toLong()];
544-
sprite->setGraphicsEffectValue(effect, sprite->graphicsEffectValue(effect) + vm->getInput(1, 2)->toDouble());
544+
target->setGraphicsEffectValue(effect, target->graphicsEffectValue(effect) + vm->getInput(1, 2)->toDouble());
545545
}
546546

547547
return 2;
548548
}
549549

550550
unsigned int LooksBlocks::changeColorEffectBy(VirtualMachine *vm)
551551
{
552-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
552+
Target *target = vm->target();
553553

554-
if (sprite)
555-
sprite->setGraphicsEffectValue(m_colorEffect, sprite->graphicsEffectValue(m_colorEffect) + vm->getInput(0, 1)->toDouble());
554+
if (target)
555+
target->setGraphicsEffectValue(m_colorEffect, target->graphicsEffectValue(m_colorEffect) + vm->getInput(0, 1)->toDouble());
556556

557557
return 1;
558558
}
559559

560560
unsigned int LooksBlocks::changeFisheyeEffectBy(VirtualMachine *vm)
561561
{
562-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
562+
Target *target = vm->target();
563563

564-
if (sprite)
565-
sprite->setGraphicsEffectValue(m_fisheyeEffect, sprite->graphicsEffectValue(m_fisheyeEffect) + vm->getInput(0, 1)->toDouble());
564+
if (target)
565+
target->setGraphicsEffectValue(m_fisheyeEffect, target->graphicsEffectValue(m_fisheyeEffect) + vm->getInput(0, 1)->toDouble());
566566

567567
return 1;
568568
}
569569

570570
unsigned int LooksBlocks::changeWhirlEffectBy(VirtualMachine *vm)
571571
{
572-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
572+
Target *target = vm->target();
573573

574-
if (sprite)
575-
sprite->setGraphicsEffectValue(m_whirlEffect, sprite->graphicsEffectValue(m_whirlEffect) + vm->getInput(0, 1)->toDouble());
574+
if (target)
575+
target->setGraphicsEffectValue(m_whirlEffect, target->graphicsEffectValue(m_whirlEffect) + vm->getInput(0, 1)->toDouble());
576576

577577
return 1;
578578
}
579579

580580
unsigned int LooksBlocks::changePixelateEffectBy(VirtualMachine *vm)
581581
{
582-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
582+
Target *target = vm->target();
583583

584-
if (sprite)
585-
sprite->setGraphicsEffectValue(m_pixelateEffect, sprite->graphicsEffectValue(m_pixelateEffect) + vm->getInput(0, 1)->toDouble());
584+
if (target)
585+
target->setGraphicsEffectValue(m_pixelateEffect, target->graphicsEffectValue(m_pixelateEffect) + vm->getInput(0, 1)->toDouble());
586586

587587
return 1;
588588
}
589589

590590
unsigned int LooksBlocks::changeMosaicEffectBy(VirtualMachine *vm)
591591
{
592-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
592+
Target *target = vm->target();
593593

594-
if (sprite)
595-
sprite->setGraphicsEffectValue(m_mosaicEffect, sprite->graphicsEffectValue(m_mosaicEffect) + vm->getInput(0, 1)->toDouble());
594+
if (target)
595+
target->setGraphicsEffectValue(m_mosaicEffect, target->graphicsEffectValue(m_mosaicEffect) + vm->getInput(0, 1)->toDouble());
596596

597597
return 1;
598598
}
599599

600600
unsigned int LooksBlocks::changeBrightnessEffectBy(VirtualMachine *vm)
601601
{
602-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
602+
Target *target = vm->target();
603603

604-
if (sprite)
605-
sprite->setGraphicsEffectValue(m_brightnessEffect, sprite->graphicsEffectValue(m_brightnessEffect) + vm->getInput(0, 1)->toDouble());
604+
if (target)
605+
target->setGraphicsEffectValue(m_brightnessEffect, target->graphicsEffectValue(m_brightnessEffect) + vm->getInput(0, 1)->toDouble());
606606

607607
return 1;
608608
}
609609

610610
unsigned int LooksBlocks::changeGhostEffectBy(VirtualMachine *vm)
611611
{
612-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
612+
Target *target = vm->target();
613613

614-
if (sprite)
615-
sprite->setGraphicsEffectValue(m_ghostEffect, sprite->graphicsEffectValue(m_ghostEffect) + vm->getInput(0, 1)->toDouble());
614+
if (target)
615+
target->setGraphicsEffectValue(m_ghostEffect, target->graphicsEffectValue(m_ghostEffect) + vm->getInput(0, 1)->toDouble());
616616

617617
return 1;
618618
}
619619

620620
unsigned int LooksBlocks::setEffectTo(VirtualMachine *vm)
621621
{
622-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
622+
Target *target = vm->target();
623623

624-
if (sprite)
625-
sprite->setGraphicsEffectValue(m_customGraphicsEffects[vm->getInput(0, 2)->toLong()], vm->getInput(1, 2)->toDouble());
624+
if (target)
625+
target->setGraphicsEffectValue(m_customGraphicsEffects[vm->getInput(0, 2)->toLong()], vm->getInput(1, 2)->toDouble());
626626

627627
return 2;
628628
}
629629

630630
unsigned int LooksBlocks::setColorEffectTo(VirtualMachine *vm)
631631
{
632-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
632+
Target *target = vm->target();
633633

634-
if (sprite)
635-
sprite->setGraphicsEffectValue(m_colorEffect, vm->getInput(0, 1)->toDouble());
634+
if (target)
635+
target->setGraphicsEffectValue(m_colorEffect, vm->getInput(0, 1)->toDouble());
636636

637637
return 1;
638638
}
639639

640640
unsigned int LooksBlocks::setFisheyeEffectTo(VirtualMachine *vm)
641641
{
642-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
642+
Target *target = vm->target();
643643

644-
if (sprite)
645-
sprite->setGraphicsEffectValue(m_fisheyeEffect, vm->getInput(0, 1)->toDouble());
644+
if (target)
645+
target->setGraphicsEffectValue(m_fisheyeEffect, vm->getInput(0, 1)->toDouble());
646646

647647
return 1;
648648
}
649649

650650
unsigned int LooksBlocks::setWhirlEffectTo(VirtualMachine *vm)
651651
{
652-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
652+
Target *target = vm->target();
653653

654-
if (sprite)
655-
sprite->setGraphicsEffectValue(m_whirlEffect, vm->getInput(0, 1)->toDouble());
654+
if (target)
655+
target->setGraphicsEffectValue(m_whirlEffect, vm->getInput(0, 1)->toDouble());
656656

657657
return 1;
658658
}
659659

660660
unsigned int LooksBlocks::setPixelateEffectTo(VirtualMachine *vm)
661661
{
662-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
662+
Target *target = vm->target();
663663

664-
if (sprite)
665-
sprite->setGraphicsEffectValue(m_pixelateEffect, vm->getInput(0, 1)->toDouble());
664+
if (target)
665+
target->setGraphicsEffectValue(m_pixelateEffect, vm->getInput(0, 1)->toDouble());
666666

667667
return 1;
668668
}
669669

670670
unsigned int LooksBlocks::setMosaicEffectTo(VirtualMachine *vm)
671671
{
672-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
672+
Target *target = vm->target();
673673

674-
if (sprite)
675-
sprite->setGraphicsEffectValue(m_mosaicEffect, vm->getInput(0, 1)->toDouble());
674+
if (target)
675+
target->setGraphicsEffectValue(m_mosaicEffect, vm->getInput(0, 1)->toDouble());
676676

677677
return 1;
678678
}
679679

680680
unsigned int LooksBlocks::setBrightnessEffectTo(VirtualMachine *vm)
681681
{
682-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
682+
Target *target = vm->target();
683683

684-
if (sprite)
685-
sprite->setGraphicsEffectValue(m_brightnessEffect, vm->getInput(0, 1)->toDouble());
684+
if (target)
685+
target->setGraphicsEffectValue(m_brightnessEffect, vm->getInput(0, 1)->toDouble());
686686

687687
return 1;
688688
}
689689

690690
unsigned int LooksBlocks::setGhostEffectTo(VirtualMachine *vm)
691691
{
692-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
692+
Target *target = vm->target();
693693

694-
if (sprite)
695-
sprite->setGraphicsEffectValue(m_ghostEffect, vm->getInput(0, 1)->toDouble());
694+
if (target)
695+
target->setGraphicsEffectValue(m_ghostEffect, vm->getInput(0, 1)->toDouble());
696696

697697
return 1;
698698
}
699699

700700
unsigned int LooksBlocks::clearGraphicEffects(VirtualMachine *vm)
701701
{
702-
Sprite *sprite = dynamic_cast<Sprite *>(vm->target());
702+
Target *target = vm->target();
703703

704-
if (sprite)
705-
sprite->clearGraphicsEffects();
704+
if (target)
705+
target->clearGraphicsEffects();
706706

707707
return 0;
708708
}

0 commit comments

Comments
 (0)