def _compile_CAMERA(self, camera): if not self.use_camera_system: for a in camera['actions']: if a['type'] == 'SNAP': self._compile_line({'speaker': None, 'text': ('string', "[snap camera to %s]" % a['target'][1])}) elif a['type'] == 'PAN': self._compile_line({'speaker': None, 'text': ('string', "[pan camera to %s]" % a['target'][1])}) elif a['type'] == 'ZOOM': self._compile_line({'speaker': None, 'text': ('string', "[zoom camera %s]" % a['target'][1].lower())}) self.add_line() else: for a in camera['actions']: if a['type'] == 'SNAP': self._cam_pan = a['target'][1] self.add_line('show layer master') self.add_line('at ' + self._get_current_scene_transforms()) elif a['type'] == 'PAN': time = scp.get_duration(a['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self._cam_pan = a['target'][1] self.add_line('show layer master') self.add_line('at ' + self._get_current_scene_transforms()) self.add_line('with MoveTransition(' + time + ')') elif a['type'] == 'ZOOM': time = scp.get_duration(a['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self._cam_zoom = a['target'][1] self.add_line('show layer master') self.add_line('at ' + self._get_current_scene_transforms()) self.add_line('with MoveTransition(' + time + ')') self.add_line()
def _compile_EXIT(self, exit): if self._has_exit_trans and exit['transition'] is not None and not scp.typed_check(exit['transition'], 'rel', 'WITH PREVIOUS'): self._finish_transition() self.add_line('show ' + exit['target'][1]) geom = exit['motion'] if geom is not None: orig = None dest = None if geom['origin'] is None and geom['duration'] is not None: orig = self.default_origin elif geom['origin'] is not None: orig = geom['origin'][1] if geom['destination'] is None and orig is not None: dest = self.default_destination elif geom['destination'] is not None: dest = geom['destination'][1] if orig is None: self.add_line('at ' + dest) else: self.add_line('at ' + orig) if exit['transition'] is not None and not scp.typed_check(exit['transition'], 'rel', 'WITH PREVIOUS'): self._has_exit_trans = True self._scene_trans = exit['transition'][1] if geom is not None and orig is not None: time = scp.get_duration(geom['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add_line('show ' + exit['target'][1]) self.add_line('at ' + orig) self.add_line('with MoveTransition(' + str(time) + ')') self.add_line('hide ' + exit['target'][1]) self.add_line()
def _compile_ACTION(self, action): self.add_line(build_show(action['target'][1], action['states'])) if action['destination'] is not None: time = scp.get_duration(action['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add_line('at ' + action['destination'][1]) self.add_line('with MoveTransition(' + str(time) + ')') self.add_line()
def _compile_ENTER(self, enter): if self._has_enter_trans and enter['transition'] is not None and not scp.typed_check(enter['transition'], 'rel', 'WITH PREVIOUS'): self._finish_transition() self.add_line(build_show(enter['target'][1], enter['states'])) geom = enter['motion'] if geom is not None: orig = None dest = None if geom['origin'] is None and geom['duration'] is not None: orig = self.default_origin elif geom['origin'] is not None: orig = geom['origin'][1] if geom['destination'] is None and orig is not None: dest = self.default_destination elif geom['destination'] is not None: dest = geom['destination'][1] if orig is None: self.add_line('at ' + dest) else: self.add_line('at ' + orig) if enter['transition'] is not None and not scp.typed_check(enter['transition'], 'rel', 'WITH PREVIOUS'): self._has_enter_trans = True self._scene_trans = enter['transition'][1] if geom is not None and orig is not None: time = scp.get_duration(geom['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add_line(build_show(enter['target'][1], enter['states'])) self.add_line('at ' + dest) self.add_line('with MoveTransition(' + str(time) + ')') self.add_line()
def _compile_MUSIC(self, music): if music['action'] == 'start': self.add('play music ') if scp.typed_check(music['target'], 'id'): self.add(music['target'][1]) elif scp.typed_check(music['target'], 'string'): self.add(scp.quote(music['target'][1])) if music['fadeout'] is not None: time = scp.get_duration(music['fadeout'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add(' fadeout ' + str(time)) elif music['action'] == 'stop': explicit_all = False if scp.typed_check(music['target'], 'rel', 'ALL'): explicit_all = True self.add('stop music') if not explicit_all: self._warnings['targeted_music_stop'] = ["Ren'Py does not support targeted music stop; any such directives will be compiled as if they were STOP ALL"] if music['duration'] is not None: time = scp.get_duration(music['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add(' fadeout ' + str(time)) self.add_line() self.add_line()
def _compile_SFX(self, sfx): if sfx['action'] == 'start': self.add('play sound ') if scp.typed_check(sfx['target'], 'string'): self.add(scp.quote(sfx['target'][1])) else: self.add(sfx['target'][1]) if scp.typed_check(sfx['loop'], 'boolean', True): self.add(' loop') elif sfx['action'] == 'stop': explicit_all = False if scp.typed_check(sfx['target'], 'rel', 'ALL'): explicit_all = True self.add('stop sound') if not explicit_all: self._warnings['targeted_sfx_stop'] = ["Ren'Py does not support targeted sound stop; any such directives will be compiled as if they were STOP ALL"] if sfx['duration'] is not None: time = scp.get_duration(sfx['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) self.add(' fadeout ' + str(time)) self.add_line() self.add_line()
def _compile_GFX(self, gfx): if scp.typed_check(gfx['target'], 'id'): eff = gfx['target'][1] if eff not in self._gfx_targets: self.add_warning('no_gfx_binding', "GFX '%s' does not have any binding defined; assuming 'scene'" % eff) self.add_gfx_target(eff, 'scene') binding_type = self._gfx_targets[eff] if gfx['action'] == 'start': if scp.typed_check(gfx['loop'], 'boolean', True): if binding_type != 'DISPLAYABLE': eff += '_loop' else: self.add_warning('loop_displayable', "The GFX '%s' cannot be looped, because it is bound to a displayable" % eff) if binding_type == 'SCENE': self.add_line('show layer master') self._cur_scene_gfx.append(eff) prefix = self._get_current_scene_transforms() self.add_line('at ' + prefix) elif binding_type == 'IMAGE': img = eff + '_img' self.add_line('show ' + img) prefix = "" self._cur_img_gfx.append(eff) self.add_line('at ' + eff) elif binding_type == 'DISPLAYABLE': self.add_line('show ' + eff) elif gfx['action'] == 'stop': dissolve = None if gfx['duration'] is not None: time = scp.get_duration(gfx['duration'], self.quickly_rel, self.slowly_rel, self.default_duration) dissolve = "with Dissolve(" + str(time) + ")" if scp.typed_check(gfx['target'], 'rel', 'ALL'): self.add_line('show layer master') if self.use_camera_system: self.add_line('at ' + self._get_current_camera()) self._cur_scene_gfx = [] for fx in self._cur_img_gfx: self.add_line('hide ' + fx) self._cur_img_gfx = [] else: if binding_type == 'SCENE': try: self._cur_scene_gfx.remove(eff) self._cur_scene_gfx.remove(eff + '_loop') except: pass self.add_line("show layer master") prefix = self._get_current_scene_transforms() if len(prefix) > 0: self.add_line('at ' + prefix) elif binding_type == 'IMAGE': if eff + '_loop' in self._cur_img_gfx: self._cur_img_gfx.remove(eff + '_loop') self.add_line('hide ' + eff + '_loop' + '_img') if eff in self._cur_img_gfx: self._cur_img_gfx.remove(eff) self.add_line('hide ' + eff + '_img') elif binding_type == 'DISPLAYABLE': self.add_line('hide ' + eff) if dissolve is not None: self.add_line(dissolve) self.add_line()