Skip to content

Commit df3b33d

Browse files
gregbauerYoloSwagBoy
authored andcommitted
[STCC-214] Workaround for user bricks. These are now converted into note bricks instead. (Catrobat#151)
1 parent f58cc21 commit df3b33d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/catroid_class_hierarchy.jar

189 KB
Binary file not shown.

src/scratchtocatrobat/converter/converter.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ def _create_catrobat_sprite_stub(name=None):
443443
return catformula.Formula(traverser._converted_helper_brick_or_formula_element([formula_left_child, formula_right_child], ">"))
444444

445445
def _create_user_brick(context, scratch_function_header, param_values, declare=False):
446+
# TODO: remove the next line of code as soon as user bricks are supported by Catrobat
447+
# TODO: also check the other TODOs related to this issue (overall three different places in converter.py)
448+
# TODO: refactor this function; maybe split the function into definition of user brick script and usage of the brick
449+
return catbricks.NoteBrick("Sorry, we currently do not support user bricks in Catrobat!")
446450
param_labels = context.user_script_declared_labels_map[scratch_function_header]
447451
assert context is not None and isinstance(context, SpriteContext)
448452
assert not param_labels or len(param_labels) == len(param_values)
@@ -1071,6 +1075,10 @@ def _catrobat_sprite_from(self, scratch_object):
10711075
for scratch_script in scratch_object.scripts:
10721076
cat_instance = self._catrobat_script_from(scratch_script, sprite, self._catrobat_project,
10731077
sprite_context)
1078+
# TODO: remove this if and replace "elif" with "if" as soon as user bricks are supported by Catrobat
1079+
# TODO: also check the other TODOs related to this issue (overall three different places in converter.py)
1080+
if isinstance(cat_instance, catbricks.NoteBrick):
1081+
continue
10741082
if not isinstance(cat_instance, catbricks.UserBrick):
10751083
assert isinstance(cat_instance, catbase.Script)
10761084
sprite.addScript(cat_instance)
@@ -1278,7 +1286,11 @@ def _catrobat_script_from(cls, scratch_script, sprite, catrobat_project, context
12781286
ignored_blocks += 1
12791287
continue
12801288
try:
1281-
if not isinstance(cat_instance, catbricks.UserBrick):
1289+
# TODO: remove this if and replace "elif" with "if" as soon as user bricks are supported by Catrobat
1290+
# TODO: also check the other TODOs related to this issue (overall three different places in converter.py)
1291+
if isinstance(cat_instance, catbricks.NoteBrick):
1292+
continue
1293+
elif not isinstance(cat_instance, catbricks.UserBrick):
12821294
assert isinstance(cat_instance, catbase.Script)
12831295
cat_instance.brickList.add(brick)
12841296
else:

src/scratchtocatrobat/converter/test_converter.py

+4
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,9 @@ def test_can_convert_set_variable_with_list(self):
20812081
assert catr_bricks[0].getFormulas()[0].getFormulaTree().getElementType() == catElementType.USER_LIST
20822082
assert catr_bricks[0].getFormulas()[0].getFormulaTree().getValue() == self._name_of_test_list
20832083

2084+
# TODO: uncomment these tests as soon as Catrobat supports user bricks again.
2085+
# Note: these tests might have to be refactored together with the tested function.
2086+
'''
20842087
#call
20852088
def test_can_convert_call_block_user_script_already_defined_simple(self):
20862089
function_header = "number1 %n number1"
@@ -2304,6 +2307,7 @@ def test_can_convert_call_block_user_script_not_yet_defined_simple(self):
23042307
param_types = sprite_context.user_script_params_map[function_header]
23052308
assert param_types is not None
23062309
assert expected_param_types == param_types
2310+
'''
23072311

23082312
#gotoSpriteOrMouse:
23092313
def test_can_convert_go_to_sprite_block_with_sprite_afterwards(self):

0 commit comments

Comments
 (0)