def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations) + 1 writer.putlnc('this->animations = &%s;', self.animations_name) writer.putlnc('if (!%s) {', self.initialized_name) writer.indent() writer.putlnc('%s = true;', self.initialized_name) scale_method = self.converter.config.get_scale_method(self) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc('%s[%s] = %s;', name, image_index, image) if scale_method is None: continue writer.putlnc('%s[%s]->set_filter(%s);', name, image_index, scale_method) writer.end_brace() flags = common.newFlags writer.putln(to_c('collision_box = %s;', flags['CollisionBox'])) writer.putlnc('auto_rotate = %s;', bool(flags['AutomaticRotation'])) writer.putlnc('transparent = %s;', self.get_transparent()) writer.putln('animation = %s;' % get_animation_name(min(animations))) if APPEARING in animations: writer.putln('forced_animation = current_animation = APPEARING;') else: writer.putln('current_animation = animation;') if len(animations) == 1 and DISAPPEARING in animations: writer.putln('flags |= FADEOUT;') self.destruct = True writer.putln('initialize_active();')
def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations)+1 writer.putlnc('this->animations = &%s;', self.animations_name) writer.putlnc('if (!%s) {', self.initialized_name) writer.indent() writer.putlnc('%s = true;', self.initialized_name) scale_method = self.converter.config.get_scale_method(self) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc('%s[%s] = %s;', name, image_index, image) if scale_method is None: continue writer.putlnc('%s[%s]->set_filter(%s);', name, image_index, scale_method) writer.end_brace() flags = common.newFlags writer.putln(to_c('collision_box = %s;', flags['CollisionBox'])) writer.putlnc('auto_rotate = %s;', bool(flags['AutomaticRotation'])) writer.putlnc('transparent = %s;', self.get_transparent()) writer.putln('animation = %s;' % get_animation_name(min(animations))) if APPEARING in animations: writer.putln('forced_animation = current_animation = APPEARING;') else: writer.putln('current_animation = animation;') if len(animations) == 1 and DISAPPEARING in animations: writer.putln('flags |= FADEOUT;') self.destruct = True writer.putln('initialize_active();')
def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations)+1 writer.putlnc('this->animations = &%s;', self.animations_name) writer.putlnc('if (!%s) {', self.initialized_name) writer.indent() writer.putlnc('%s = true;', self.initialized_name) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc('%s[%s] = %s;', name, image_index, image) writer.end_brace() flags = common.newFlags writer.putln(to_c('collision_box = %s;', flags['CollisionBox'])) writer.putlnc('auto_rotate = %s;', bool(flags['AutomaticRotation'])) writer.putlnc('transparent = %s;', self.get_transparent()) writer.putln('animation = %s;' % get_animation_name(min(animations))) if APPEARING in animations: writer.putln('forced_animation = APPEARING;') writer.putln('initialize_active();')
def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations) + 1 writer.putlnc('this->animations = &%s;', self.animations_name) writer.putlnc('if (!%s) {', self.initialized_name) writer.indent() writer.putlnc('%s = true;', self.initialized_name) scale_method = self.converter.config.get_scale_method(self) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc('%s[%s] = %s;', name, image_index, image) if scale_method is None: continue writer.putlnc('%s[%s]->set_filter(%s);', name, image_index, scale_method) writer.end_brace() flags = common.newFlags fade = common.fadeOut if fade and fade.name in ('FADE', 'DOOR'): writer.putlnc('fade_duration = %s;', fade.duration / 1000.0) if fade.name == 'DOOR': self.use_door_fadeout = True if flags['AutomaticRotation']: writer.putlnc('active_flags |= AUTO_ROTATE;') if self.get_transparent(): writer.putlnc('active_flags |= TRANSPARENT;') writer.putln('animation = %s;' % get_animation_name(min(animations))) if APPEARING in animations: writer.putln('forced_animation = current_animation = APPEARING;') else: writer.putln('current_animation = animation;') if len(animations) == 1 and DISAPPEARING in animations: writer.putln('flags |= FADEOUT;') self.destruct = True writer.putlnc('initialize_active(%s);', flags['CollisionBox'])
def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations)+1 writer.putlnc('this->animations = &%s;', self.animations_name) writer.putlnc('if (!%s) {', self.initialized_name) writer.indent() writer.putlnc('%s = true;', self.initialized_name) scale_method = self.converter.config.get_scale_method(self) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc('%s[%s] = %s;', name, image_index, image) if scale_method is None: continue writer.putlnc('%s[%s]->set_filter(%s);', name, image_index, scale_method) writer.end_brace() flags = common.newFlags fade = common.fadeOut if fade and fade.name in ('FADE', 'DOOR'): writer.putlnc('fade_duration = %s;', fade.duration / 1000.0) if fade.name == 'DOOR': self.use_door_fadeout = True if flags['AutomaticRotation']: writer.putlnc('active_flags |= AUTO_ROTATE;') if self.get_transparent(): writer.putlnc('active_flags |= TRANSPARENT;') writer.putln('animation = %s;' % get_animation_name(min(animations))) if APPEARING in animations: writer.putln('forced_animation = current_animation = APPEARING;') else: writer.putln('current_animation = animation;') if len(animations) == 1 and DISAPPEARING in animations: writer.putln('flags |= FADEOUT;') self.destruct = True writer.putlnc('initialize_active(%s);', flags['CollisionBox'])
def write_init(self, writer): common = self.common animations = common.animations.loadedAnimations max_anim = max(animations) + 1 writer.putlnc("this->animations = &%s;", self.animations_name) writer.putlnc("if (!%s) {", self.initialized_name) writer.indent() writer.putlnc("%s = true;", self.initialized_name) scale_method = self.converter.config.get_scale_method(self) for name, images in self.images: for image_index, image in enumerate(images): writer.putlnc("%s[%s] = %s;", name, image_index, image) if scale_method is None: continue writer.putlnc("%s[%s]->set_filter(%s);", name, image_index, scale_method) writer.end_brace() flags = common.newFlags fade = common.fadeOut if fade and fade.name in ("FADE", "DOOR"): writer.putlnc("fade_duration = %s;", fade.duration / 1000.0) if fade.name == "DOOR": self.use_door_fadeout = True if flags["AutomaticRotation"]: writer.putlnc("active_flags |= AUTO_ROTATE;") if self.get_transparent(): writer.putlnc("active_flags |= TRANSPARENT;") writer.putln("animation = %s;" % get_animation_name(min(animations))) if APPEARING in animations: writer.putln("forced_animation = current_animation = APPEARING;") else: writer.putln("current_animation = animation;") if len(animations) == 1 and DISAPPEARING in animations: writer.putln("flags |= FADEOUT;") self.destruct = True writer.putlnc("initialize_active(%s);", flags["CollisionBox"])
def write_pre(self, writer): self.animations = {} self.images = [] get_image = self.converter.get_image animations = self.common.animations.loadedAnimations prefix = self.new_class_name.lower() for animation_index in sorted(animations): animation = animations[animation_index] anim_name = animation.getName() if anim_name == 'Appearing' and direction.repeat == 0: print 'Problematic appearing?', self.data.name directions = animation.loadedDirections animation_name = get_animation_name(animation.index) direction_map = {} anim_prefix = '%s_%s' % (prefix, animation_index) for direction_index in sorted(directions): direction = directions[direction_index] dir_prefix = '%s_%s' % (anim_prefix, direction_index) image_count = len(direction.frames) images = [get_image(image) for image in direction.frames] images_name = 'images_%s' % dir_prefix writer.putlnc('static Image* %s[%s];', images_name, image_count) self.images.append((images_name, images)) loop_count = direction.repeat if loop_count == 0: loop_count = -1 direction_name = 'direction_%s' % dir_prefix writer.putlnc( 'static Direction %s = {%s, %s, %s, %s, %s, %s, ' '%s};', direction_name, direction_index, direction.minSpeed, direction.maxSpeed, direction.backTo, loop_count, image_count, images_name) direction_map[direction_index] = '&%s' % direction_name directions = [] for i in xrange(32): new_dir = get_closest_directions(i, direction_map) if new_dir is None: new_dir = 'NULL' directions.append(new_dir) directions = ', '.join(directions) anim_name = 'anim_%s' % anim_prefix writer.putlnc('static Animation %s = {%s};', anim_name, directions) self.animations[animation_index] = '&' + anim_name self.animations_name = 'anim_%s' % prefix animation_names = [] anims_array = 'anim_array_%s' % prefix for i in xrange(max(animations) + 1): animation_names.append(self.animations.get(i, 'NULL')) writer.putlnc('static Animation * %s[%s] = {%s};', anims_array, len(animation_names), ', '.join(animation_names)) writer.putlnc('static Animations %s = {%s, &%s[0]};', self.animations_name, len(animation_names), anims_array) self.initialized_name = '%s_initialized' % self.animations_name writer.putlnc('static bool %s;', self.initialized_name)
def write_pre(self, writer): self.animations = {} self.images = [] get_image = self.converter.get_image animations = self.common.animations.loadedAnimations prefix = self.new_class_name.lower() for animation_index in sorted(animations): animation = animations[animation_index] single_loop = animation.getName() in ('Appearing', 'Disappearing') # writer.putmeth('void init_anim_%s' % animation_index) directions = animation.loadedDirections animation_name = get_animation_name(animation.index) direction_map = {} anim_prefix = '%s_%s' % (prefix, animation_index) for direction_index in sorted(directions): direction = directions[direction_index] dir_prefix = '%s_%s' % (anim_prefix, direction_index) image_count = len(direction.frames) images = [get_image(image) for image in direction.frames] images_name = 'images_%s' % dir_prefix writer.putlnc('static Image* %s[%s];', images_name, image_count) self.images.append((images_name, images)) loop_count = direction.repeat if loop_count == 0: loop_count = -1 if single_loop and loop_count == -1: loop_count = 1 direction_name = 'direction_%s' % dir_prefix writer.putlnc('static Direction %s = {%s, %s, %s, %s, %s, %s, ' '%s};', direction_name, direction_index, direction.minSpeed, direction.maxSpeed, direction.backTo, loop_count, images_name, image_count) direction_map[direction_index] = '&%s' % direction_name directions = [] for i in xrange(32): new_dir = get_closest_directions(i, direction_map) if new_dir is None: new_dir = 'NULL' directions.append(new_dir) directions = ', '.join(directions) anim_name = 'anim_%s' % anim_prefix writer.putlnc('static Animation %s = {%s};', anim_name, directions) self.animations[animation_index] = '&' + anim_name self.animations_name = 'anim_%s' % prefix animation_names = [] anims_array = 'anim_array_%s' % prefix for i in xrange(max(animations)+1): animation_names.append(self.animations.get(i, 'NULL')) writer.putlnc('static Animation * %s[%s] = {%s};', anims_array, len(animation_names), ', '.join(animation_names)) writer.putlnc('static Animations %s = {%s, &%s[0]};', self.animations_name, len(animation_names), anims_array) self.initialized_name = '%s_initialized' % self.animations_name writer.putlnc('static bool %s;', self.initialized_name)
def write_pre(self, writer): self.animations = {} self.images = [] get_image = self.converter.get_image animations = self.common.animations.loadedAnimations prefix = self.new_class_name.lower() for animation_index in sorted(animations): animation = animations[animation_index] anim_name = animation.getName() if anim_name == "Appearing" and direction.repeat == 0: print "Problematic appearing?", self.data.name directions = animation.loadedDirections animation_name = get_animation_name(animation.index) direction_map = {} anim_prefix = "%s_%s" % (prefix, animation_index) for direction_index in sorted(directions): direction = directions[direction_index] dir_prefix = "%s_%s" % (anim_prefix, direction_index) image_count = len(direction.frames) images = [get_image(image) for image in direction.frames] images_name = "images_%s" % dir_prefix writer.putlnc("static Image* %s[%s];", images_name, image_count) self.images.append((images_name, images)) loop_count = direction.repeat if loop_count == 0: loop_count = -1 direction_name = "direction_%s" % dir_prefix writer.putlnc( "static Direction %s = {%s, %s, %s, %s, %s, %s, " "%s};", direction_name, direction_index, direction.minSpeed, direction.maxSpeed, direction.backTo, loop_count, image_count, images_name, ) direction_map[direction_index] = "&%s" % direction_name directions = [] for i in xrange(32): new_dir = get_closest_directions(i, direction_map) if new_dir is None: new_dir = "NULL" directions.append(new_dir) directions = ", ".join(directions) anim_name = "anim_%s" % anim_prefix writer.putlnc("static Animation %s = {%s};", anim_name, directions) self.animations[animation_index] = "&" + anim_name self.animations_name = "anim_%s" % prefix animation_names = [] anims_array = "anim_array_%s" % prefix for i in xrange(max(animations) + 1): animation_names.append(self.animations.get(i, "NULL")) writer.putlnc( "static Animation * %s[%s] = {%s};", anims_array, len(animation_names), ", ".join(animation_names) ) writer.putlnc("static Animations %s = {%s, &%s[0]};", self.animations_name, len(animation_names), anims_array) self.initialized_name = "%s_initialized" % self.animations_name writer.putlnc("static bool %s;", self.initialized_name)