Ejemplo n.º 1
0
        # build RGB values
        value = (color.r << 16) + (color.g << 8) + color.b
        # convert unsigned to signed 32-bit int
        value = struct.unpack('=i', struct.pack('=I', value))[0]
        return value


class Scratch20Plugin(KurtPlugin):
    name = "scratch20"
    display_name = "Scratch 2.0"
    extension = ".sb2"
    features = [
        "Custom Blocks",
        "Vector Images",
    ]
    blocks = make_block_types()

    def load(self, fp):
        zl = ZipReader(fp)
        zl.project._original = zl.json
        zl.finish()
        return zl.project

    def save(self, fp, project):
        zw = ZipWriter(fp, project)
        zw.finish()
        return zw.json


Kurt.register(Scratch20Plugin())
Ejemplo n.º 2
0
        for script in kurt_scriptable.hiddenscripts:
            if isinstance(script, kurt.Script):
                for block in script.blocks:
                    grab_comments(block)

        # save hidden and palettedict
        voct_scriptable.hidden = False  # default
        voct_scriptable.palettedict = kurt_scriptable.palettedict
        # sprite
        if isinstance(kurt_scriptable, kurt.Sprite):
            voct_scriptable.hidden = kurt_scriptable.hidden


class OctopiPlugin(KurtPlugin):
    name = 'octopi'
    display_name = 'Octopi from Scratch 1.4'
    extension = '.oct'
    features = []
    serializer_cls = OctopiSerializer
    blocks = block_list
    user_objects = make_user_objects(user_obj)

    def load(self, fp):
        return self.serializer_cls(self).load(fp)

    def save(self, fp, project):
        return self.serializer_cls(self).save(fp, project)


Kurt.register(OctopiPlugin())
Ejemplo n.º 3
0
        value = struct.unpack('=i', struct.pack('=I', value))[0]

        return value


class Scratch20Plugin(KurtPlugin):
    name = "scratch20"
    display_name = "Scratch 2.0"
    extension = ".sb2"
    features = [
        "Custom Blocks",
        "Vector Images",
    ]
    blocks = make_block_types()

    def load(self, fp):
        zl = ZipReader(fp)
        zl.project._original = zl.json
        zl.finish()

        return zl.project

    def save(self, fp, project):
        zw = ZipWriter(fp, project)
        zw.finish()

        return zw.json

# register the current plugin
Kurt.register(Scratch20Plugin())
Ejemplo n.º 4
0
    display_name = "Scratch 1.4"
    extension = ".sb"
    blocks = block_list
    features = []

    serializer_cls = Serializer
    user_objects = make_user_objects(user_objects_by_name)

    def load(self, fp):
        return self.serializer_cls(self).load(fp)

    def save(self, fp, project):
        return self.serializer_cls(self).save(fp, project)


Kurt.register(Scratch14Plugin())


#-- Block workarounds --#

# 1.4 -> 2.0
block_workaround('stop script', kurt.Block('stop', 'this script'))
block_workaround('stop all', kurt.Block('stop', 'all'))
block_workaround('forever if',
                 lambda block: kurt.Block('forever', [kurt.Block('if', *block.args)]))
block_workaround('loud?', kurt.Block('>', kurt.Block('loudness'), 30))

# 2.0 -> 1.4
block_workaround('stop', lambda block: {
    'this script': kurt.Block('stop script'),
    'all': kurt.Block('stop all'),
Ejemplo n.º 5
0
    display_name = "Scratch 1.4"
    extension = ".sb"
    blocks = block_list
    features = []

    serializer_cls = Serializer
    user_objects = make_user_objects(user_objects_by_name)

    def load(self, fp):
        return self.serializer_cls(self).load(fp)

    def save(self, fp, project):
        return self.serializer_cls(self).save(fp, project)


Kurt.register(Scratch14Plugin())

#-- Block workarounds --#

# 1.4 -> 2.0
block_workaround('stop script', kurt.Block('stop', 'this script'))
block_workaround('stop all', kurt.Block('stop', 'all'))
block_workaround(
    'forever if',
    lambda block: kurt.Block('forever', [kurt.Block('if', *block.args)]))
block_workaround('loud?', kurt.Block('>', kurt.Block('loudness'), 30))

# 2.0 -> 1.4
block_workaround(
    'stop', lambda block: {
        'this script': kurt.Block('stop script'),