Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[STCC-187] Replace SetEffect and ChangeEffect blocks with NoteBricks #124

Merged
merged 2 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/scratchtocatrobat/converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class _ScratchToCatrobat(object):
# WORKAROUND: using ROUND for Catrobat float => Scratch int
"soundLevel": lambda *_args: catrobat.formula_element_for(catformula.Functions.ROUND,
arguments=[catrobat.formula_element_for(catformula.Sensors.LOUDNESS)]), # @UndefinedVariable
"note:": catbricks.NoteBrick,
}.items() + math_function_block_parameters_mapping.items() \
+ math_unary_operators_mapping.items() + math_binary_operators_mapping.items() \
+ user_list_block_parameters_mapping.items() \
Expand Down Expand Up @@ -2354,3 +2355,11 @@ def _convert_doBroadcastAndWait(self):
message = str(message)
return catbricks.BroadcastWaitBrick(message.lower())

#Note: NoteBricks are not implemented in scratch. We insert one in the Scratch3 parser if there is a problem(e.g.
# a block that is not implemented in Catroid) when parsing a block.
@_register_handler(_block_name_to_handler_map, "note:")
def _convert_note_block(self):
arg = self.arguments[0]
if isinstance(arg, (str, unicode)) or isinstance(arg, catformula.Formula):
return self.CatrobatClass(arg)
log.warn("Invalid argument for NoteBrick: " + arg)
6 changes: 2 additions & 4 deletions src/scratchtocatrobat/scratch/scratch3visitor/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ def visitStopallsounds(blockcontext):
return ["stopAllSounds"]

def visitChangeeffectby(blockcontext):
block = blockcontext.block
log.warn("[Scratch3] block {} ({}) possibly not available in Scratch2".format(blockcontext.block.opcode, blockcontext.block.name))
pass #TODO: doesnt exist in scratch2/catroid
return ["note:", "ChangeEffectBy block is not yet implemented in Catroid"] #TODO: doesnt exist in scratch2/catroid

def visitSeteffectto(blockcontext):
block = blockcontext.block
log.warn("[Scratch3] block {} ({}) possibly not available in Scratch2".format(blockcontext.block.opcode, blockcontext.block.name))
pass #TODO: doesnt exist in scratch2/catroid
return ["note:", "SetEffect block is not yet implemented in Catroid"] #TODO: doesnt exist in scratch2/catroid

def visitCleareffects(blockcontext):
log.warn("[Scratch3] block {} ({}) possibly not available in Scratch2".format(blockcontext.block.opcode, blockcontext.block.name))
Expand Down