コード例 #1
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_CHOICE(self, choice):
		if choice['label'] is not None:
			labelstmt = {'type': 'annotation', 'instruction': 'SECTION', 'section': choice['label'], 'params': []}
			self.compile_statement(labelstmt)
		self.add_paragraph("We are presented with a choice:", style='Actor Instruction')
		if choice['title'] is not None:
			self.add_paragraph(choice['title'][1], italic=False)
		for c in choice['choices']:
			self.add_paragraph(style='Choice')
			if c['condition'] is None:
				self.add_run(c['text'][1])
			else:
				self.add_run(c['text'][1] + "\n")
				if scp.typed_check(c['condition'], 'boolean', True):
					self.add_run('(always shown)', style='Choice Condition')
				elif scp.typed_check(c['condition'], 'boolean', False):
					self.add_run('(never shown)', style='Choice Condition')
				elif scp.typed_check(c['condition'], 'id'):
					cond_id = scp.to_words(c['condition'][1]).lower()
					if cond_id.startswith('have '):
						cond_ph = cond_id[len('have '):]
						self.add_run('(choice shown only if we have ' + cond_ph + ')', style='Choice Condition')
					else:
						self.add_run('(choice shown only if \'' + cond_id + '\' is set)', style='Choice Condition')
				else:
					self.add_run('(choice shown only if ' + scp.to_human_readable(c['condition'][1]) + ')', style='Choice Condition')
			if self.include_varsets:
				for v in c['sets']:
					self.add_paragraph(self.make_varset(v)[0], style='Choice Instruction')
			self.add_paragraph(style='Choice Instruction')
			go = self.make_goto({'destination': c['target']})
			self.add_run(go[0])
			self.add_internal_link(go[1], go[2])
			self.add_run('.')
コード例 #2
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_MUSIC(self, music):
		self.add_paragraph(style='Actor Instruction')
		song = music['target'][1]
		if scp.typed_check(music['target'], 'string'):
			dot = song.rfind('.')
			song = song[0:dot]
		line = 'We hear '
		if music['action'] == 'start':
			if music['fadeout'] is not None:
				line += 'the current music fade out' + scp.get_duration_words(music['fadeout'], 'over %d seconds') + ', '
				line += 'and then we hear '
			line += 'the song '
			self.add_run(line)
			self.add_run(scp.to_words(song).title(), italic=False)
			self.add_run(' begin to play.')
		elif music['action'] == 'stop':
			if scp.typed_check(music['target'], 'rel'):
				line += song.lower() + ' music '
			else:
				line += 'the song '
				self.add_run(line)
				self.add_run(scp.to_words(song).title(), italic=False)
				line = ' '
			if music['duration'] is not None:
				line += 'fade out' + scp.get_duration_words(music['duration'], 'over %d seconds') + '.'
			else:
				line += 'stop.'
			self.add_run(line)
コード例 #3
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_CAMERA(self, camera):
		line = 'We'
		acts_added = 0
		for act in camera['actions']:
			if acts_added == len(camera['actions']) - 1 and len(camera['actions']) > 1:
				line += ' and then'
			if 'duration' in act and scp.typed_check(act['duration'], 'rel'):
				line += scp.get_duration_words(act['duration'], '')
			if act['type'] == 'SNAP':
				line += ' focus on the ' + scp.to_words(act['target'][1])
			elif act['type'] == 'PAN':
				line += ' shift our focus to the ' + scp.to_words(act['target'][1])
			elif act['type'] == 'ZOOM':
				line += ' move '
				if scp.typed_check(act['target'], 'rel', 'IN'):
					line += 'in closer'
				elif scp.typed_check(act['target'], 'rel', 'OUT'):
					line += 'back farther'
			if 'duration' in act and not scp.typed_check(act['duration'], 'rel'):
				line += scp.get_duration_words(act['duration'], 'over %d seconds')
			if acts_added < len(camera['actions']) - 1 and len(camera['actions']) > 2:
				line += ','
			acts_added += 1
		line += '.'
		self.add_paragraph(line, style='Actor Instruction')
コード例 #4
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	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()
コード例 #5
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	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()
コード例 #6
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def make_varset(self, varset):
		line = ''
		if scp.typed_check(varset['value'], 'boolean'):
			return self.make_flagset(varset)
		var = scp.to_words(varset['name'][1]).lower()
		value = scp.get_expr(varset['value'])
		if scp.typed_check(varset['value'], 'incdec'):
			readable = scp.to_human_readable(var + value)
			var_in = readable.rfind(var)
			var_str = readable[var_in:].replace(var, scp.quote(var, "'"), 1)
			readable = readable[0:var_in] + var_str
			line = readable.strip().capitalize() + '.'
		else:
			line = 'Set the variable ' + scp.quote(var, "'") + ' to ' + value + '.'
		return (line, False)
コード例 #7
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_GFX(self, gfx):
		line = 'We see '
		if gfx['action'] == 'start':
			a = scp.indef_article(gfx['target'][1])
			line += a + ' ' + scp.to_words(gfx['target'][1]).upper()
			if scp.typed_check(gfx['loop'], 'boolean', True):
				line += ' effect begin and continue'
			line += '.'
		elif gfx['action'] == 'stop':
			if scp.typed_check(gfx['target'], 'rel'):
				line += gfx['target'][1].lower() + ' effects '
			else:
				line += 'the ' + scp.to_words(gfx['target'][1]).upper() + ' effect '
			if gfx['duration'] is not None:
				line += 'fade away' + scp.get_duration_words(gfx['duration'], 'over %d seconds') + '.'
			else:
				line += 'stop.'
		self.add_paragraph(line, style='Actor Instruction')
コード例 #8
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_IF(self, ifstmt):
		elsebr = None
		firstbr = True
		had_output = False
		for br in ifstmt['branches']:
			if br['condition'] is None:
				elsestmt = br
			else:
				if not self.contains_writeable(br['statements']):
					continue
				had_output = True
				negation = ''
				if firstbr:
					line = '%s do the following'
					firstbr = False
				else:
					line = 'Otherwise,%s do the following'
				cond = scp.get_expr(br['condition'])
				if scp.typed_check(br['condition'], 'boolean'):
					tcond = br['condition'][1]
					if tcond:
						negation = ' always'
						line += ':'
					else:
						negation = ' never'
						line += ':'
				elif scp.typed_check(br['condition'], 'id'):
					cond_words = scp.to_words(br['condition'][1]).lower()
					if cond_words.startswith('have '):
						cond_ph = cond_words[len('have '):]
						line += ' only if we have ' + cond_ph + ':'
					else:
						line += ' only if ' + scp.quote(cond_words, "'") + ' is set:'
				else:
					line += ' only if ' + scp.to_human_readable(cond) + ':'
				self.add_paragraph((line % negation).strip().capitalize(), style='Engine Instruction')
				self.compile_block(br['statements'])
		if elsebr is not None and had_output and self.contains_writeable(elsebr['statements']):
			self.add_paragraph("Otherwise, do the following:", style='Engine Instruction')
			self.compile_block(elsebr['statements'])
		if not had_output:
			self._add_break = False
コード例 #9
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	def _compile_CHOICE(self, choice):
		label = ""
		if scp.typed_check(choice['label'], 'id'):
			label = " " + choice['label'][1]
		self.add_line("menu" + label + ":")
		self._inc_indent()
		if scp.typed_check(choice['title'], 'string'):
			self.add_line(scp.quote(choice['title'][1]))
			self.add_line()
		for c in choice['choices']:
			cond = ""
			if c['condition'] is not None:
				cond = " if " + str(c['condition'][1])
			self.add_line(scp.quote(c['text'][1]) + cond + ":")
			self._inc_indent()
			for v in c['sets']:
				self._compile_VARSET(v, noline=True)
			self.add_line('jump ' + c['target'][1])
			self.add_line()
			self._dec_indent()
		self._dec_indent()
コード例 #10
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	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()
コード例 #11
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_SFX(self, sfx):	
		fx = sfx['target'][1]
		if scp.typed_check(sfx['target'], 'string'):
			dot = fx.rfind('.')
			fx = fx[0:dot]
		line = 'We hear '
		if sfx['action'] == 'start':
			a = scp.indef_article(fx)
			line += a + ' ' + scp.to_words(fx).upper()
			if scp.typed_check(sfx['loop'], 'boolean', True):
				line += ' sound begin to repeat'
			line += '.'
		elif sfx['action'] == 'stop':
			if scp.typed_check(sfx['target'], 'rel'):
				line += fx.lower() + ' repeating sounds '
			else:
				line += 'the repeated ' + scp.to_words(fx).upper() + ' sound '
			if sfx['duration'] is not None:
				line += 'fade away' + scp.get_duration_words(sfx['duration'], 'over %d seconds') + '.'
			else:
				line += 'stop.'
		self.add_paragraph(line, style='Actor Instruction')
コード例 #12
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	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()
コード例 #13
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def _compile_WHILE(self, whilestmt):
		line = "Do the following "
		cond = scp.get_expr(whilestmt['condition'])
		if scp.typed_check(whilestmt['condition'], 'boolean'):
			tcond = whilestmt['condition'][1]
			if tcond:
				line += 'forever:'
			else:
				line = 'Never do the following:'
		elif scp.typed_check(whilestmt['condition'], 'id'):
			cond_words = scp.to_words(whilestmt['condition'][1]).lower()
			if cond_words.startswith('have '):
				cond_ph = cond_words[len('have '):]
				line += 'while we have ' + cond_ph + ':'
			else:
				line += 'while ' + scp.quote(cond_words, "'") + ' is set:'
		else:
			line += 'while ' + scp.to_human_readable(cond) + ':'
		if self.contains_writeable(whilestmt['statements']):
			self.add_paragraph(line, style='Engine Instruction')
			self.compile_block(whilestmt['statements'])
		else:
			self._add_break = False
コード例 #14
0
ファイル: word.py プロジェクト: dekarrin/scrappy
	def make_flagset(self, flagset):
		line = ''
		value = scp.get_expr(flagset['value'])
		tvalue = flagset['value'][1]
		flag = scp.to_words(flagset['name'][1]).lower()
		nat_lang = flag.startswith('have ')
		if nat_lang:
			phrase = flag[len('have '):]
		if scp.typed_check(flagset['value'], 'boolean'):
			if not nat_lang:
				if tvalue:
					line = 'Set the flag ' + scp.quote(flag, "'") + '.'
				else:
					line = 'Unset the flag ' + scp.quote(flag, "'") + '.'
			else:
				if tvalue:
					line = 'We have now ' + phrase + '.'
				else:
					line = 'We have now not ' + phrase + '.'
		elif scp.typed_check(flagset['value'], 'id'):
			if nat_lang:
				line = 'Whether we have ' + phrase + ' is determined by '
			else:
				line = 'Set the flag ' + scp.quote(flag, "'") + ' to the same as '
			value_id = scp.to_words(value).lower()
			if value_id.startswith('have '):
				val_phrase = value_id[len('have '):]
				line += 'whether we have ' + val_phrase + '.'
			else:
				line += 'the value of the variable ' + scp.quote(value_id, "'") + '.'
		elif scp.typed_check(flagset['value'], 'expr'):
			if nat_lang:
				line = 'Whether we have now ' + flag + ' is determined by the value of the variable ' + value + '.'
			else:
				line = 'Set the flag ' + scp.quote(flag, "'") + ' to the same as the value of the variable ' + value + '.'
		return (line, nat_lang)
コード例 #15
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	def _compile_FMV(self, fmv):
		name = fmv['target'][1]
		if scp.typed_check(fmv['target'], 'string'):
			name = scp.quote(name)
		self.add_line('renpy.movie_cutscene(' + name + ')')
		self.add_line()
コード例 #16
0
ファイル: renpy.py プロジェクト: dekarrin/scrappy
	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()