@@ -347,36 +347,8 @@ void LooksBlocks::compileSwitchCostumeTo(Compiler *compiler)
347347 if (!target)
348348 return ;
349349
350- Input *input = compiler->input (COSTUME);
351-
352- if (input->pointsToDropdownMenu ()) {
353- std::string value = input->selectedMenuItem ();
354- int index = target->findCostume (value);
355-
356- if (index == -1 ) {
357- if (value == " next costume" )
358- compiler->addFunctionCall (&nextCostume);
359- else if (value == " previous costume" )
360- compiler->addFunctionCall (&previousCostume);
361- else {
362- Value v (value);
363-
364- if (v.type () == Value::Type::Integer) {
365- compiler->addConstValue (v.toLong () - 1 );
366- compiler->addFunctionCall (&switchCostumeToByIndex);
367- } else {
368- compiler->addInput (input);
369- compiler->addFunctionCall (&switchCostumeTo);
370- }
371- }
372- } else {
373- compiler->addConstValue (index);
374- compiler->addFunctionCall (&switchCostumeToByIndex);
375- }
376- } else {
377- compiler->addInput (input);
378- compiler->addFunctionCall (&switchCostumeTo);
379- }
350+ compiler->addInput (COSTUME);
351+ compiler->addFunctionCall (&switchCostumeTo);
380352}
381353
382354void LooksBlocks::compileNextCostume (Compiler *compiler)
@@ -386,85 +358,14 @@ void LooksBlocks::compileNextCostume(Compiler *compiler)
386358
387359void LooksBlocks::compileSwitchBackdropTo (Compiler *compiler)
388360{
389- Stage *stage = compiler->engine ()->stage ();
390-
391- if (!stage)
392- return ;
393-
394- Input *input = compiler->input (BACKDROP);
395-
396- if (input->pointsToDropdownMenu ()) {
397- std::string value = input->selectedMenuItem ();
398- int index = stage->findCostume (value);
399-
400- if (index == -1 ) {
401- if (value == " next backdrop" )
402- compiler->addFunctionCall (&nextBackdrop);
403- else if (value == " previous backdrop" )
404- compiler->addFunctionCall (&previousBackdrop);
405- else if (value == " random backdrop" )
406- compiler->addFunctionCall (&randomBackdrop);
407- else {
408- Value v (value);
409-
410- if (v.type () == Value::Type::Integer) {
411- compiler->addConstValue (v.toLong () - 1 );
412- compiler->addFunctionCall (&switchBackdropToByIndex);
413- } else {
414- compiler->addInput (input);
415- compiler->addFunctionCall (&switchBackdropTo);
416- }
417- }
418- } else {
419- compiler->addConstValue (index);
420- compiler->addFunctionCall (&switchBackdropToByIndex);
421- }
422- } else {
423- compiler->addInput (input);
424- compiler->addFunctionCall (&switchBackdropTo);
425- }
361+ compiler->addInput (BACKDROP);
362+ compiler->addFunctionCall (&switchBackdropTo);
426363}
427364
428365void LooksBlocks::compileSwitchBackdropToAndWait (Compiler *compiler)
429366{
430- Stage *stage = compiler->engine ()->stage ();
431-
432- if (!stage)
433- return ;
434-
435- Input *input = compiler->input (BACKDROP);
436-
437- if (input->pointsToDropdownMenu ()) {
438- std::string value = input->selectedMenuItem ();
439- int index = stage->findCostume (value);
440-
441- if (index == -1 ) {
442- if (value == " next backdrop" )
443- compiler->addFunctionCall (&nextBackdropAndWait);
444- else if (value == " previous backdrop" )
445- compiler->addFunctionCall (&previousBackdropAndWait);
446- else if (value == " random backdrop" )
447- compiler->addFunctionCall (&randomBackdropAndWait);
448- else {
449- Value v (value);
450-
451- if (v.type () == Value::Type::Integer) {
452- compiler->addConstValue (v.toLong () - 1 );
453- compiler->addFunctionCall (&switchBackdropToByIndexAndWait);
454- } else {
455- compiler->addInput (input);
456- compiler->addFunctionCall (&switchBackdropToAndWait);
457- }
458- }
459- } else {
460- compiler->addConstValue (index);
461- compiler->addFunctionCall (&switchBackdropToByIndexAndWait);
462- }
463- } else {
464- compiler->addInput (input);
465- compiler->addFunctionCall (&switchBackdropToAndWait);
466- }
467-
367+ compiler->addInput (BACKDROP);
368+ compiler->addFunctionCall (&switchBackdropToAndWait);
468369 compiler->addFunctionCall (&backdropNumber);
469370 compiler->addFunctionCall (&checkBackdropScripts);
470371}
@@ -932,14 +833,6 @@ void LooksBlocks::setCostumeByIndex(Target *target, long index)
932833 target->setCostumeIndex (index);
933834}
934835
935- unsigned int LooksBlocks::switchCostumeToByIndex (VirtualMachine *vm)
936- {
937- if (Target *target = vm->target ())
938- setCostumeByIndex (target, vm->getInput (0 , 1 )->toLong ());
939-
940- return 1 ;
941- }
942-
943836unsigned int LooksBlocks::switchCostumeTo (VirtualMachine *vm)
944837{
945838 Target *target = vm->target ();
@@ -990,12 +883,6 @@ void LooksBlocks::startBackdropScripts(VirtualMachine *vm, bool wait)
990883 }
991884}
992885
993- void LooksBlocks::switchBackdropToByIndexImpl (VirtualMachine *vm)
994- {
995- if (Stage *stage = vm->engine ()->stage ())
996- setCostumeByIndex (stage, vm->getInput (0 , 1 )->toLong ());
997- }
998-
999886void LooksBlocks::switchBackdropToImpl (VirtualMachine *vm)
1000887{
1001888 Stage *stage = vm->engine ()->stage ();
@@ -1047,14 +934,6 @@ void LooksBlocks::randomBackdropImpl(VirtualMachine *vm)
1047934 }
1048935}
1049936
1050- unsigned int LooksBlocks::switchBackdropToByIndex (VirtualMachine *vm)
1051- {
1052- switchBackdropToByIndexImpl (vm);
1053- startBackdropScripts (vm, false );
1054-
1055- return 1 ;
1056- }
1057-
1058937unsigned int LooksBlocks::switchBackdropTo (VirtualMachine *vm)
1059938{
1060939 switchBackdropToImpl (vm);
@@ -1063,14 +942,6 @@ unsigned int LooksBlocks::switchBackdropTo(VirtualMachine *vm)
1063942 return 1 ;
1064943}
1065944
1066- unsigned int LooksBlocks::switchBackdropToByIndexAndWait (VirtualMachine *vm)
1067- {
1068- switchBackdropToByIndexImpl (vm);
1069- startBackdropScripts (vm, true );
1070-
1071- return 1 ;
1072- }
1073-
1074945unsigned int LooksBlocks::switchBackdropToAndWait (VirtualMachine *vm)
1075946{
1076947 switchBackdropToImpl (vm);
0 commit comments