Ejemplo n.º 1
0
	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)
Ejemplo n.º 2
0
	def _compile_ENTER(self, enter):
		geom = enter['motion']
		dest = None
		origin = None
		if geom is not None:
			if geom['destination'] is not None:
				dest = geom['destination'][1]
			if geom['origin'] is not None:
				origin = geom['origin'][1]
				
		line = scp.to_words(enter['target'][1]).title()
		if len(enter['states']) > 0:
			line += ','
			line += make_states(enter['states'])
			line += ', '
		else:
			line += ' '
		if enter['transition'] is not None:
			line += scp.to_words(enter['transition'][1]).lower() + 's in to '
		else:
			line += 'enters '
		line += 'the scene'
		if origin is not None:
			line += ' near the ' + scp.to_words(origin).lower()
		if dest is not None:
			line += ' and moves to the ' + scp.to_words(dest).lower()
		if geom is not None:
			line += scp.get_duration_words(geom['duration'], 'over %d seconds')
		line += '.'
		self.add_paragraph(line, style='Actor Instruction')
Ejemplo n.º 3
0
	def _compile_EXIT(self, exit):
		geom = exit['motion']
		dest = None
		origin = None
		if geom is not None:
			if geom['destination'] is not None:
				dest = geom['destination'][1]
			if geom['origin'] is not None:
				origin = geom['origin'][1]
		
		line = scp.to_words(exit['target'][1]).title() + ' '
		if geom is not None:
			line += 'moves '
		if origin is not None:
			line += 'from the ' + scp.to_words(origin).lower() + ' '
		if dest is not None:
			line += 'to the ' + scp.to_words(dest).lower() + ' '
		if geom is not None:
			line += 'and '
		if exit['transition'] is not None:
			line += scp.to_words(exit['transition'][1]).lower() + 's out of '
		else:
			line += 'exits '
		line += 'the scene'
		if geom is not None:
			line += scp.get_duration_words(geom['duration'], 'over %d seconds')
		line += '.'
		self.add_paragraph(line, style='Actor Instruction')
Ejemplo n.º 4
0
	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')
Ejemplo n.º 5
0
	def _compile_ACTION(self, action):
		line = scp.to_words(action['target'][1]).title() + ' '
		if len(action['states']) > 0:
			line += 'changes to appear'
			line += make_states(action['states'])
			if action['destination'] is not None:
				line += ', and then '
		if action['destination'] is not None:
			line += 'moves to the ' + scp.to_words(action['destination'][1]).lower()
			line += scp.get_duration_words(action['duration'], 'over %d seconds')
		line += '.'
		self.add_paragraph(line, style='Actor Instruction')
Ejemplo n.º 6
0
	def _compile_DESCRIPTION(self, desc):
		self.add_paragraph(style='Actor Instruction')
		line = ''
		if desc['target'] is not None:
			self.add_run("Regarding ")
			self.add_run(scp.to_words(desc['target'][1]).title() + ': ', italic=False)
		self.add_run(desc['text'][1])
Ejemplo n.º 7
0
	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('.')
Ejemplo n.º 8
0
	def _compile_SCENE(self, scene):
		if scene['transition'] is None:
			trans = "cut to:"
		else:
			trans = scene['transition'][1] + " to:"
		self.add_paragraph(trans.capitalize() + "\n\n", style='Slugline Transition')
		name = scp.to_words(scene['name'][1])
		self.add_paragraph(name, style='Slugline')
Ejemplo n.º 9
0
	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')
Ejemplo n.º 10
0
def make_states(states):	
	states_added = 0
	line = ''
	for s in states:
		if states_added == len(states) - 1 and len(states) > 1: # we are on the last one
			line += ' and'
		line += ' ' + scp.to_words(s[1]).lower()
		if states_added < len(states) - 1 and len(states) > 2:
			line += ','
		states_added += 1
	return line
Ejemplo n.º 11
0
	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')
Ejemplo n.º 12
0
	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)
Ejemplo n.º 13
0
	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)
Ejemplo n.º 14
0
	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
Ejemplo n.º 15
0
	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
Ejemplo n.º 16
0
	def make_goto(self, goto):
		bookmark = self.to_bookmark(scp.to_words(goto['destination'][1]).title())
		return ('Jump to ', scp.to_words(goto['destination'][1]).title(), bookmark)
Ejemplo n.º 17
0
	def _compile_EXECUTE(self, execute):
		section_name = scp.to_words(execute['section'][1]).title()
		bookmark = self.to_bookmark(section_name)
		self.add_paragraph("Execute ", style='Reader Instruction')
		self.add_internal_link(section_name, bookmark)
Ejemplo n.º 18
0
	def _compile_SECTION(self, section):
		name = scp.to_words(section['section'][1]).title()
		bookmark = self.to_bookmark(name)
		self._document.add_heading(scp.to_words(section['section'][1]).title(), level=2, bookmark_name=bookmark)
		self._add_break = False
Ejemplo n.º 19
0
	def _compile_FMV(self, fmv):
		self.add_paragraph(style='Actor Instruction')
		self.add_run("We see the full-motion video ")
		self.add_run(scp.to_words(fmv['target'][1]), italic=False)
		self.add_run(' play.')