Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

STCC-329/330/331 Fixed bugs in conversion [TN] #248

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/scratchtocatrobat/converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@ def _convert_scene_block(self):
# 3rd step: determine look number, i.e. (((value - 1) % number_of_looks) + 1)
index_formula_elem = self._converted_helper_brick_or_formula_element([index_formula_elem, 1], "+")
index_formula_elem = index_formula_elem if number_of_looks != 1 else 1
set_background_by_index_brick = catbricks.SetBackgroundByIndexBrick(catrobat.create_formula_with_value(index_formula_elem))
set_background_by_index_brick = catbricks.SetLookByIndexBrick(catrobat.create_formula_with_value(index_formula_elem))
return set_background_by_index_brick

look_name = argument
Expand Down
7 changes: 6 additions & 1 deletion src/scratchtocatrobat/scratch/scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,16 @@ def preprocess_object(self, all_sprite_names):
for script in self.scripts:
for blocks in script.blocks:
if isinstance(blocks, list) and len(blocks) >= 2:
if not self.is_stage() and isinstance(blocks[1], basestring) and 'backdrop' in blocks[1]:
if not self.is_stage() and isinstance(blocks[1], basestring) and blocks[1] in {'next backdrop', 'previous backdrop', 'random backdrop'}:
blocks[0] = 'broadcast:'
workaround_info[ADD_BACKDROP_RECEIVE].add(blocks[1])
elif self.is_stage() and blocks[1] == 'random backdrop':
blocks[1] = ['randomFrom:to:', 1.0, float(len(self._dict_object[JsonKeys.COSTUMES]))]
# workaround for the next backdrop scratch block
if len(blocks) == 1 and not self.is_stage() and 'nextScene' in blocks[0]:
blocks.append('next backdrop')
blocks[0] = 'broadcast:'
workaround_info[ADD_BACKDROP_RECEIVE].add(blocks[1])
script.script_element = script.script_element.from_raw_block(script.blocks)

############################################################################################
Expand Down
4 changes: 2 additions & 2 deletions src/scratchtocatrobat/scratch/scratch3visitor/looks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def visitSwitchbackdropto(blockcontext):
return ["startScene", backdrop]

def visitNextbackdrop(blockcontext):
return ["nextCostume"]
return ["nextScene"]

def visitChangesizeby(blockcontext):
size = visitGeneric(blockcontext, "CHANGE")
Expand Down Expand Up @@ -99,4 +99,4 @@ def visitCostume(blockcontext):

def visitBackdrops(blockcontext):
block = blockcontext.block
return block.fields['BACKDROP'][0]
return block.fields['BACKDROP'][0]