@@ -653,7 +653,7 @@ void LooksBlocks::setCostumeByIndex(Target *target, long index)
653653 index = std::fmod (index, costumeCount);
654654 }
655655
656- target->setCurrentCostume (index + 1 );
656+ target->setCostumeIndex (index);
657657}
658658
659659unsigned int LooksBlocks::switchCostumeToByIndex (VirtualMachine *vm)
@@ -693,15 +693,15 @@ unsigned int LooksBlocks::switchCostumeTo(VirtualMachine *vm)
693693unsigned int LooksBlocks::nextCostume (VirtualMachine *vm)
694694{
695695 if (Target *target = vm->target ())
696- setCostumeByIndex (target, target->currentCostume () );
696+ setCostumeByIndex (target, target->costumeIndex () + 1 );
697697
698698 return 0 ;
699699}
700700
701701unsigned int LooksBlocks::previousCostume (VirtualMachine *vm)
702702{
703703 if (Target *target = vm->target ())
704- setCostumeByIndex (target, target->currentCostume () - 2 );
704+ setCostumeByIndex (target, target->costumeIndex () - 1 );
705705
706706 return 0 ;
707707}
@@ -710,7 +710,8 @@ void LooksBlocks::startBackdropScripts(VirtualMachine *vm, bool wait)
710710{
711711 if (Stage *stage = vm->engine ()->stage ()) {
712712 if (stage->costumes ().size () > 0 )
713- vm->engine ()->broadcastByPtr (stage->costumeAt (stage->currentCostume () - 1 )->broadcast (), vm, wait);
713+ // TODO: Use currentCostume()
714+ vm->engine ()->broadcastByPtr (stage->costumeAt (stage->costumeIndex ())->broadcast (), vm, wait);
714715 }
715716}
716717
@@ -749,13 +750,13 @@ void LooksBlocks::switchBackdropToImpl(VirtualMachine *vm)
749750void LooksBlocks::nextBackdropImpl (VirtualMachine *vm)
750751{
751752 if (Stage *stage = vm->engine ()->stage ())
752- setCostumeByIndex (stage, stage->currentCostume () );
753+ setCostumeByIndex (stage, stage->costumeIndex () + 1 );
753754}
754755
755756void LooksBlocks::previousBackdropImpl (VirtualMachine *vm)
756757{
757758 if (Stage *stage = vm->engine ()->stage ())
758- setCostumeByIndex (stage, stage->currentCostume () - 2 );
759+ setCostumeByIndex (stage, stage->costumeIndex () - 1 );
759760}
760761
761762void LooksBlocks::randomBackdropImpl (VirtualMachine *vm)
@@ -767,7 +768,7 @@ void LooksBlocks::randomBackdropImpl(VirtualMachine *vm)
767768 std::size_t count = stage->costumes ().size ();
768769
769770 if (count > 0 )
770- stage->setCurrentCostume (rng->randint (1 , count));
771+ stage->setCostumeIndex (rng->randint (0 , count - 1 ));
771772 }
772773}
773774
@@ -854,7 +855,8 @@ unsigned int LooksBlocks::randomBackdropAndWait(VirtualMachine *vm)
854855unsigned int LooksBlocks::checkBackdropScripts (VirtualMachine *vm)
855856{
856857 if (Stage *stage = vm->engine ()->stage ()) {
857- if ((stage->costumes ().size () > 0 ) && vm->engine ()->broadcastByPtrRunning (stage->costumeAt (stage->currentCostume () - 1 )->broadcast (), vm))
858+ // TODO: Use currentCostume()
859+ if ((stage->costumes ().size () > 0 ) && vm->engine ()->broadcastByPtrRunning (stage->costumeAt (stage->costumeIndex ())->broadcast (), vm))
858860 vm->stop (true , true , true );
859861 }
860862
@@ -864,7 +866,7 @@ unsigned int LooksBlocks::checkBackdropScripts(VirtualMachine *vm)
864866unsigned int LooksBlocks::costumeNumber (VirtualMachine *vm)
865867{
866868 if (Target *target = vm->target ())
867- vm->addReturnValue (target->currentCostume () );
869+ vm->addReturnValue (target->costumeIndex () + 1 );
868870 else
869871 vm->addReturnValue (0 );
870872
@@ -874,7 +876,8 @@ unsigned int LooksBlocks::costumeNumber(VirtualMachine *vm)
874876unsigned int LooksBlocks::costumeName (VirtualMachine *vm)
875877{
876878 if (Target *target = vm->target ()) {
877- auto costume = target->costumeAt (target->currentCostume () - 1 );
879+ // TODO: Use currentCostume()
880+ auto costume = target->costumeAt (target->costumeIndex ());
878881
879882 if (costume)
880883 vm->addReturnValue (costume->name ());
@@ -889,7 +892,7 @@ unsigned int LooksBlocks::costumeName(VirtualMachine *vm)
889892unsigned int LooksBlocks::backdropNumber (VirtualMachine *vm)
890893{
891894 if (Stage *stage = vm->engine ()->stage ())
892- vm->addReturnValue (stage->currentCostume () );
895+ vm->addReturnValue (stage->costumeIndex () + 1 );
893896 else
894897 vm->addReturnValue (0 );
895898
@@ -899,7 +902,8 @@ unsigned int LooksBlocks::backdropNumber(VirtualMachine *vm)
899902unsigned int LooksBlocks::backdropName (VirtualMachine *vm)
900903{
901904 if (Stage *stage = vm->engine ()->stage ()) {
902- auto costume = stage->costumeAt (stage->currentCostume () - 1 );
905+ // TODO: Use currentCostume()
906+ auto costume = stage->costumeAt (stage->costumeIndex ());
903907
904908 if (costume)
905909 vm->addReturnValue (costume->name ());
0 commit comments