
C\c           @  sk  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z e j d e j  Z	 d e j
 k Z d e f d     YZ e e e e e d  Z e e d  Z i  i  i  e e e i  i  i  e e e e i  e d	  Z d
 e f d     YZ e e e e e d  Z d e j j f d     YZ e j j d  Z d a d e f d     YZ e e d  Z d   Z d S(   i(   t   print_functionNs(   (\{\{)|(\{(p|w|nw|fast)(?:\=([^}]*))?\})t   RENPY_LESS_PAUSESt   DialogueTextTagsc           B  s   e  Z d  Z d   Z RS(   sq   
    This object parses the text tags that only make sense in dialogue,
    like {fast}, {p}, {w}, and {nw}.
    c         C  s  d |  _  d g |  _ g  |  _ g  |  _ t |  _ t t j |   } xpt	 ryQ|  j  | j
   7_  | j
   } | j
   } | j
   } | j
   } | d  k	 r t |  } n  | d  k	 r |  j  | 7_  wH n  | d k s | d k r8t s|  j j t |  j    |  j j t |  j    |  j j |  qnW | d k rPt	 |  _ n? | d k rt |  j   g |  _ g  |  _ g  |  _ t |  _ n  |  j  | 7_  WqH t k
 rPqH XqH W|  j j t |  j    |  j r|  j j d  n |  j j d   d  S(   Nt    i    t   pt   wt   nwt   fast(   t   textt   pause_startt	   pause_endt   pause_delayt   Falset   no_waitt   itert   TAG_REt   splitt   Truet   nextt   Nonet   floatt   less_pausest   appendt   lent   StopIteration(   t   selft   st   it   quotedt   full_tagt   tagt   value(    (    s   renpy/character.pyt   __init__,   sJ    									(   t   __name__t
   __module__t   __doc__R    (    (    (    s   renpy/character.pyR   &   s   c
         K  s   | r t  j j |  n  t  j j rQ t  j j t  j j j d
 t  j j   n  | r | d k rv t  j j |   n  | |
 d <n  | r t | | | |	  } t  j j j	 | d | d |  d | d | d | |
 d	 Sd	 S(   s  
    This is the default function used by Character to predict images that
    will be used by show_display_say. It's called with more-or-less the
    same parameters as show_display_say, and it's expected to return a
    list of images used by show_display_say.
    t   sides	   <Dynamic>t   imaget   _widget_propertiest   whot   whatt
   two_windowt
   side_imageN(   R$   (
   t   renpyt   easyt   predictt   storet   _side_image_attributest   displayR%   t   ImageReferencet   compute_widget_propertiest   screen(   R'   R(   t   who_argst	   what_argst   window_argsR%   R)   R*   R3   t
   propertiest   kwargst   props(    (    s   renpy/character.pyt   predict_show_display_sayl   s&    ,c   	        s      f d   } | |  d  }  | | d  } | | d  } t  |  } x3 t j j D]% } | | j | i   |  | | <qX W| | d <| | d <|  | d <| S(   s5   
    Computes and returns the widget properties.
    c           s   |  j  d d   } | d  k r7   d  k r. |  S| } n  t j j   } | r_  r_   r_ |  S|  j   }  t | t  r   d  k	 r d j   d   d |  } n  t	 t j
 j |  }  d  k	 r |  } n  | r | d } q n  | |  d <|  S(   Nt   styles   block{}_multiple{}_{}i    i   t   rollback(   t   getR   R+   t   exportst   in_rollbackt   copyt
   isinstancet
   basestringt   formatt   getattrR.   R;   (   t   dt   nameR;   R?   (   t   multiplet   variant(    s   renpy/character.pyt
   style_args   s&    	 
R'   R(   t   window(   t   dictR+   t   configt   character_id_prefixesR=   (	   R4   R5   R6   R7   RH   RG   RI   t   rvt   prefix(    (   RG   RH   s   renpy/character.pyR2      s    "#


c           s  t   | | | d  d |       f d   }  f d   } | rt j j j |  r| d k r~ t j j } n  | } d } | r t j j j d |  r d | } | | d <n  d j | d | d |  } n    r   | d	 <n  | d k	 st j j	 r| | d
 <n  | s*t j j	 r7| | d <n  t j j j
 | d  d t d | d  d | d | | t j j   | d | f S| rt j j |  n  | rt j j | d |    t j j | d |	    |   n  t j j  d   t j j | d |
    | s#|   n  t j j |  d  } t j j   | r_t j j   n  | rxt j j |  n  t j j   | S(   sA  
    This is called (by default) by renpy.display_say to add the
    widgets corresponding to a screen of dialogue to the user. It is
    not expected to be called by the user, but instead to be called by
    display_say, or by a function passed as the show_function argument
    to Character or display_say.

    @param who: The name of the character that is speaking, or None to
    not show this name to the user.

    @param what: What that character is saying. Please not that this
    may not be a string, as it can also be a list containing both text
    and displayables, suitable for use as the first argument of ui.text().

    @param who_args: Additional keyword arguments intended to be
    supplied to the ui.text that creates the who widget of this dialogue.

    @param what_args: Additional keyword arguments intended to be
    supplied to the ui.text that creates the what widget of this dialogue.

    @param window_args: Additional keyword arguments intended to be
    supplied to the ui.window that creates the who widget of this
    dialogue.

    @param image: If True, then who should be interpreted as an image
    or displayable rather than a text string.

    @param kwargs: Additional keyword arguments should be ignored.

    This function is required to return the ui.text() widget
    displaying the what text.
    RH   RG   c             sU    rQ   r; t  j j t  j j j  d t  d  qQ t  j j    n  d  S(   Nt   looseR'   (   R+   t   uit   addR0   t   imR%   R   R   (    (   R%   R9   R'   R4   (    s   renpy/character.pyt
   handle_who   s    /c           s|   t  |  t  r' t t j j |   }  n    d  k	 r@ |    }  n  t j j   r\ |  d }  n  t	 d |   } | j
 |  | S(   NR<   R;   (   RA   RB   RD   R+   R.   R;   R   R>   R?   RK   t   update(   R;   R7   RN   (   RH   (    s   renpy/character.pyt   merge_style   s    i    t	   multiple_s   block{}_multiple{}_{}i   R%   R*   R)   R&   t
   _transientt   _tagR'   R(   t   _layert   say_two_window_vboxt   say_who_windowRJ   t   say_vboxN(   R2   R+   R0   R3   t
   has_screenR   RL   t	   say_layerRC   t   old_say_argst   show_screenR   R>   t   shown_windowRQ   t   att   vboxRJ   R   t   closeR%   (   R'   R(   R4   R5   R6   R%   R*   R)   t   two_window_vbox_propertiest   who_window_propertiest   say_vbox_propertiest	   transformRH   R3   t   layerR7   RG   R8   RT   RV   R   t   indexRN   (    (   R%   R9   RH   R'   R4   s   renpy/character.pyt   show_display_say   s`    -!
 

t   SlowDonec           B  s&   e  Z d Z i  Z d    Z d   Z RS(   c	   	      C  sL   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   ctct   ctc_positiont   callbackt   interactt   typet   cb_argst   delayt
   ctc_kwargs(	   R   Rn   Ro   Rp   Rq   Rr   Rs   Rt   Ru   (    (    s   renpy/character.pyR    Z  s    							c         C  sE  |  j  r |  j d k r t j j j d  r |  j rE |  j g } n g  } t j j j d d t d t | |  j	 t j
 j   q |  j r |  j d k r t j j j d d t d |  j t j
 j   q n  |  j d  k	 rt j j |  j t d t t j
 j   n  x3 |  j D]( } | d d	 |  j  d
 |  j |  j qWd  S(   Ni    Rn   RX   t   _ignore_extra_kwargst   fixedt   _ctct   voicet	   slow_doneRq   Rr   (   Rq   Rt   R+   R0   R3   R^   Rn   Ra   R   Ru   R>   t   restart_interactionRo   R   RQ   t   pausebehaviorRp   Rr   Rs   (   R   t   argst   c(    (    s   renpy/character.pyt   __call__d  s    	("N(   R!   R"   R   Rt   Ru   R    R   (    (    (    s   renpy/character.pyRm   V  s   	
c   ,   
   C  s~  | d  k r | } n' | \ } } | | k r6 | } n t } | sK t } n  | r t j j j r t j j   j t  r t j	 j
 d k r d  t j	 _
 n  | r t j	 j
 d k r x t j	 j D] } |   q Wt j j d   d  S| d  k rt j	 j rt j	 j g } qg  } n  t | t  s3| g } n  t j	 j | } x' | D] } | d d | d | |
 qJWt j j   } | t k rt } n  t j j } | rt } t }	 nH t j	 j
 r| rt j j j st j j   j t  rt } t }	 n  | st j j j rt }	 n  t |  } |	 r`| j d g } t | j  g } | j d g } n | j } | j } | j } d  } yxt t | | |   D]\ } \ } }  }! | t |  d k }" | rt j j d t j	 j  }# n d  }# | j }$ |" r| }% d	 }& n- |! d  k	 r1| p%| }% d
 }& n | }% d }& i |& d 6| d 6| d 6| d 6}' | ph| std  }% n  t j  j! |%  }% |% d  k	 r|% j" r|% j# d   }% |% j$   n  |! d k rd  }% n  x' | D] } | d d | d | |
 qWt% |% | | | | |
 |! |'  }( | r5| |  |$ d | }) n | |  |$  }) | sh|$ sh|% d  k	 sh|# r| rt |) t&  rt j' j( j) |) d |) d |) d  }) n  t |) t j j j*  st+ d   n  |% r| d k r|) j, |%  q| d k r|) j, d |% g  qn  |) j d |$ k rS| |) _- |  |) _. | |) _/ |( |) _0 |) j1   n t j	 j2 rnt+ d   n  |# r| r|# j3 |)  qn t } x' | D] } | d d | d | |
 qW| s|(   n  | rt j j4 d d d | d |  }* |* t k rPn  t |* t j j5 t j j6 f  r.|*  n  |" sXx t j	 j7 D] } |   qAWqXqqWWn+ t j j5 t j j6 f k
 r}+ |+ } n X| r>| j8 s| r| d  k rt j j9 t  qt j j9 |  qn | t j _ | d  k rt j	 j: } n  t j; d d  | r+t j j< j= d  d   n  t j; d d  n  x' | D] } | d d | d | |
 qEW| d  k	 rz  n  d  S(   NR   t   beginRq   Rr   i    ii   t   allow_dismisst   lastt
   timedpauset   pauset   ctc_kindt   ctc_lastt	   ctc_pauset   ctc_timedpauset   showRG   i   s<   The say screen (or show_function) must return a Text object.t   nestleds   nestled-closeu   ﻿sm   The displayable with id 'what' was not given the exact contents of the what variable given to the say screen.t	   show_donet   mouset   sayt   roll_forwards   before with nones   after with nonet   end(>   R   R   R+   t   gamet   preferencest   skip_unseent   contextt   seen_currentR   RL   t   skippingt   fast_skipping_callbacksR>   t   with_statementt   character_callbackRA   t   listt   all_character_callbackst   roll_forward_infot   after_rollbackt   self_voicingR   R	   R   R   R   R
   t	   enumeratet   zipRQ   t   saybehaviort   say_allow_dismissR,   t   displayable_or_nonet   _duplicatablet
   _duplicatet   _uniqueRm   t   tupleR0   R3   t
   get_widgett   Textt	   Exceptiont   set_ctct   startR   t   slowRz   RU   t	   developert   set_textRq   t   JumpExceptiont   CallExceptiont   say_sustain_callbacksR   t
   checkpointt   implicit_with_nonet   plogt	   interfacet   do_with(,   R'   R(   t   show_functionRq   R   t   afmRn   R   Ro   t   all_at_onceRs   t	   with_noneRp   Rr   R   R   t	   ctc_forcet   advanceRG   t   finalt   stept   totalR   R~   R   R   t   dttR	   R
   R   t	   exceptionR   R   Rt   t
   last_pauset   behaviort   what_stringt   what_ctcR   Ru   Rz   t	   what_textRN   t   e(    (    s   renpy/character.pyt   display_say  s   			A								.			
		!$*				
!!	!
	t   HistoryEntryc           B  s   e  Z d  Z d Z d   Z RS(   s^   
    Instances of this object are used to represent history entries in
    _history_list.
    c         C  s   d j  |  j |  j  S(   Ns   <History {!r} {!r}>(   RC   R'   R(   (   R   (    (    s   renpy/character.pyt   __repr__  s    N(   R!   R"   R#   R   RG   R   (    (    (    s   renpy/character.pyR     s   t   NotSeti    t   ADVCharacterc           B  s  e  Z d  Z d d d d d g Z d Z i  Z e d d  Z e d  Z	 d d  Z
 d d	  Z d d
  Z d   Z d   Z d   Z g  g  d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e e d d  Z d   Z d   Z d d  Z d   Z RS(   sE  
    The character object contains information about a character. When
    passed as the first argument to a say statement, it can control
    the name that is displayed to the user, and the style of the label
    showing the name, the text of the dialogue, and the window
    containing both the label and the dialogue.
    t   what_prefixt   what_suffixt
   who_prefixt
   who_suffixR   c           s    d  k r t j j   n  | t k	 r4 |  d <n     f d   }    f d   } | d  |  _ | d  |  _ | d  |  _ | d  |  _ | d  |  _	 | d  |  _
 | d	  |  _ | d
  |  _ | d  |  _ | d  |  _ | d  |  _ | d  |  _ t j j rHd  k r9 j d  |  _ qQ  j |  _ n	 d  |  _ t d | d  d | d  d | d  d t j j | d   d t j j | d   d t j j | d   d | d  d | d  d | d  d | d  d | d  d | d   |  _ t j t  |  _   r  j j   |  _   j j   |  _   j j   |  _   j  j   |  _    j! j   |  _! xn   j j"   D] \ } } t |  |  j | <qWn; i t# d 6|  _ i t# d 6|  _ i  |  _ i  |  _  i  |  _! t j j s(d  k r( j d  |  j  d <q(n  d  k rM j d  |  j d <n  d d d  d! d" g t j j$ } g  | D] } | d# ^ qsd$ g }	 t j j%  |	  }
 x1 t& | |
  D]  \ } } |  j | j' |  qW|  j d" j' |
 d%  |  j  j' |  j j d   |  j! j' |  j j d   |  j j' |  j j d    |  j j' |  j j d!   |  j j' |  j j d"   d  S(&   NRF   c           s*   |   k r  j  |   St   |   Sd  S(   N(   t   popRD   (   t   n(   t   kindR7   (    s   renpy/character.pyt   v  s    c           s(   |   k r  j  |   S  j |  Sd  S(   N(   R   t   display_args(   R   (   R   R7   (    s   renpy/character.pyRE     s    R   R   R   R   R   t   predict_functiont	   conditiont   dynamicR3   t   modet	   voice_tagR%   Rq   R   R   Rn   R   R   Ro   R   R   Rp   Rr   R   t
   substitutet   slow_abortableR   t   cbR(   RJ   R'   t   _R   i((   R   R+   R.   t   advR   RF   R   R   R   R   R   R   R   R   R3   R   R   RL   t   new_character_image_argumentR   t	   image_tagRK   R,   R   R   t   collectionst   defaultdictR7   R4   R@   R5   R6   t	   show_argsRs   t   itemsR   RM   t   split_propertiesR   RU   (   R   RF   R   R7   R   RE   t   kt   prefixesR   t
   split_argsR   RO   (    (   R   R7   s   renpy/character.pyR      s    				$c         K  s   t  |   | d |  | S(   NR   (   Rr   (   R   RF   R7   (    (    s   renpy/character.pyR@     s    c         C  s   d  S(   N(    (   R   R'   R(   RG   (    (    s   renpy/character.pyt   do_add  s    c         C  s   | d  k	 rU |  j | | d |  j d |  j d |  j d |  j d |  j d | |  j S|  j | | d |  j d |  j d |  j d |  j d |  j |  j Sd  S(   NR4   R5   R6   R3   R7   RG   (   R   R   R4   R5   R6   R3   R7   R   (   R   R'   R(   RG   (    (    s   renpy/character.pyt   do_show!  s(    					
				c         C  s   |  j  d | | d | d  S(   NR   RG   (   t   add_history(   R   R'   R(   RG   (    (    s   renpy/character.pyt   do_done=  s    c         C  s   |  j    d  S(   N(   t   pop_history(   R   (    (    s   renpy/character.pyt	   do_extendB  s    c         K  s   t  | | |  j |  d  S(   N(   R   R   (   R   R'   R(   R   (    (    s   renpy/character.pyt
   do_displayF  s    c         C  sC   |  j  | | d |  j d |  j d |  j d |  j d |  j |  j S(   NR4   R5   R6   R3   R7   (   R   R4   R5   R6   R3   R7   R   (   R   R'   R(   (    (    s   renpy/character.pyt
   do_predictN  s    				c   
      C  s  | p | p | s d S|  j  sI | rB | rB t d | f   qI d Sn  | d k r^ d } n t |  } |  j  f | } t j j   j } t j j	 j
 |  j  d  } | j | |  j  f  rl| j | |  j  | | |  } | d k r | } n  | j | | d t rd S|  j  f | t |  t d   | D  }	 | rU| j | |	  qt j j |	  t Sn t j j rt j j f | } | j | |  j  | | |  } | d k r| } n  | j | | d d t n | j | | d t d S(	   s   
        Deals with image attributes associated with the current say
        statement. Returns True if an image is shown, None otherwise.
        Ns]   Say has image attributes %r, but there's no image tag associated with the speaking character.t   mastert   exactc         s  s   |  ] } d  | Vq d S(   t   -N(    (   t   .0R   (    (    s   renpy/character.pys	   <genexpr>}  s    i   R   (    (   R   R   R   R   R+   R   R   t   imagesRL   t	   tag_layerR=   t   showingt   apply_attributesR   t   predict_showR>   R   t   say_attributes_use_side_imaget   side_image_prefix_tagR   (
   R   R-   t   attrst   wantedt   removet   tagged_attrsR   Rj   t	   new_imaget
   show_image(    (    s   renpy/character.pyt   resolve_say_attributesY  s<    			.	c   	      C  sv  t  j j   j } d  t  j j   _ t  j j   j } d  t  j j   _ | r | rc t |  } n g  } t  j j d  k	 r | j	 d t  j j  q n  t  j j   j
 } | j d  |  j  } d  } |  j | |  r d } n  |  j s d  S| r1| j d  |  j  } |  j | |  r1| r%d n d } q1n  | rb| j d  |  j  } |  j | | |  n  | rr| | f Sd  S(   Ni    t	   permanentt   botht	   temporary(   R+   R   R   t   say_attributesR   t   temporary_attributesR   RL   t   speaking_attributet   insertR   t   get_attributesR   R  t   handle_say_transition(	   R   t
   predictingRq   R   t   temporary_attrsR   t   beforeR   t   after(    (    s   renpy/character.pyt   handle_say_attributes  s4    		c         C  s   t  |  } t  |  } | | k r( d  St j j rC | | f } n d } t j j |  j | |  \ } } | d  k	 r | d  k r t j j |  q t j j d   t j j	 | d | n  d  S(   NRj   (    (
   t   setR+   RL   t'   say_attribute_transition_callback_attrst!   say_attribute_transition_callbackR   R   R>   R   t
   transition(   R   R   R  R  t   deltat   transRj   (    (    s   renpy/character.pyR    s    	c           s   | d  k r d  S| \   } |  j s) d  S| t j j   j k	 rE d  S| j d  |  j  }   | k rj d  S|  j f   t   f d   | D  } | j d  |  j f  r | s t j	 j
 |  t S| j d  |  n | j d  | d t d  S(   Nc         3  s%   |  ] } |   k r d  | Vq d S(   R   N(    (   R   R   (   R   (    s   renpy/character.pys	   <genexpr>  s    R   (   R   R   R+   R   R   R   R  R   R   R>   R   R   R   R   (   R   R  t   stateRq   R   t   current_attrst   image_with_attrs(    (   R   s   renpy/character.pyt   restore_say_attributes  s"    	*c         C  s;   |  j  } |  j r' t j j |  } n  t j j |  d S(   Ni    (   RF   R   R+   t   pythont   py_evalt   substitutionsR   (   R   R'   (    (    s   renpy/character.pyt   __unicode__  s    		c         C  s   t  |   j d  S(   Ns   utf-8(   t   unicodet   encode(   R   (    (    s   renpy/character.pyt   __str__  s    c         C  s   t  t |   |  S(   N(   RC   R   (   R   t   spec(    (    s   renpy/character.pyt
   __format__  s    c         C  s   d j  |  j  S(   Ns   <Character: {!r}>(   RC   RF   (   R   (    (    s   renpy/character.pyR   	  s    c         C  s\   t  j j rB |  j d  k rB |  j p* |  j rB |  j d  d  d  S|  d d t d t d  S(   NR   Rq   t
   _call_done(	   R+   RL   t   fast_empty_windowRF   R   R   R   R   R   (   R   (    (    s   renpy/character.pyt   empty_window  s    .c         K  s  | j  d d   } | j  d d   } | r^ t d |  |  | d | d | d | d | d | S|  j d  k p t j j |  j  s t St | t	  s t
 d | f   n  | d  k r d a n/ t d	 7a t | f } t | d	 k r d a n  | d  k rz|  j t |  } t j j }	 |  j rP|  j f t j j   j j d  |  j  }
 n d  }
 |
 t j _ | szt t j _ qzn  t j j d  k	 rt j j |  j  n  zV| r| p|  j } t j j |  n  |  j j   } | d o| | d <| d  k	 r	| | d <n  | d  k	 r"| | d
 <n  |  j } |  j rIt j j |  } n  d  t t d  } | d  k	 rt j j r| |  j  d |  j!  } | j" d | |   } q|  j  | |  j! } n  t j j r| |  j# d |  j$  } | j" d | | d t  } n |  j# | |  j$ } | d  k	 r?|  j% | | d | n |  j% | |  |  j& | | d |  j' | | r| d  k	 r|  j( | | d | n |  j( | |  | rt | t) t* f  rt j j+ |  n  t j j+ |  t j j+ d  n  Wd  | d  k r| r|	 t j _ | d  k	 rI| \ } } | j d  |  j  } n  |  j, t | |  r| j d  |  j  } |  j- d | |  qn  Xd  S(   Nt   _modet
   _with_noneR   Rq   R%  RG   s;   Character expects its what argument to be a string, got %r.i    i   R   c         S  s&   t  j j |  d | d | d | d S(   Nt   scopet   forcet	   translatei    (   R+   R  R   (   R   R*  R+  R,  (    (    s   renpy/character.pyt   subZ  s    s   [[who]s   [who]s   [[what]s   [what]R,  Rs   R   t   restore(.   R   R   t	   CharacterR   R+   R  R  R   RA   RB   R   t   multiple_countR  R   R.   R/   R   R   R   R   R  t   _side_image_attributes_resetRL   t   voice_tag_callbackR   R   R>   R   R@   RF   R   t   new_substitutionsR   R   t   replaceR   R   R   R   Rs   R   t   strR   t   logR  R  (   R   R(   Rq   R%  RG   R8   R(  R)  t   old_attr_statet   old_side_image_attributesR   R   R   R'   R-  t   who_patternt   what_patternR   R   R  R  (    (    s   renpy/character.pyR     s    4$	
		.		!c         C  s   |  j  t t  } t j j } |  j rU |  j f t j j   j j	 d |  j  } n d  } | t j _ z/ |  j r| d } n	 |  j } |  j | |  SWd  | t j _ |  j t | t  Xd  S(   NR   s	   <Dynamic>(   R  R   R+   R.   R/   R   R   R   R   R  R   R   RF   R   R  (   R   R(   R7  R8  R   R'   (    (    s   renpy/character.pyR-     s    	.			c         C  s3   |  j  d  k p! t j j |  j   s( t S|  j d S(   NRq   (   R   R   R+   R  R  R   R   (   R   (    (    s   renpy/character.pyt   will_interact  s    $c         K  sY  t  j j } | d k r d St  j j s, d St  j j } t   } | | _ | | _	 | | _
 |  j | _ |  j | _ |  j | _ |  j | _ |  j | _ | | _ t  j j   j r t  j j j j | _ n	 d | _ x* | j   D] \ }	 }
 t | |	 |
  q Wx t  j j D] } | |  qW| j |  x# t |  | k rT| j d  q2Wd S(   s~   
        This is intended to be called by subclasses of ADVCharacter to add
        History entries to _history_list.
        Ni    (   R+   RL   t   history_lengthR   R.   t   _historyt   _history_listR   R   R'   R(   R4   R5   R6   R   R   RG   R   R   R<   R6  t   currentt
   identifiert   rollback_identifierR   t   setattrt   history_callbacksR   R   R   (   R   R   R'   R(   RG   R8   R<  t   historyt   hR   R   R   (    (    s   renpy/character.pyR     s4    						c         C  s@   t  j j } | d k r d St  j j s, d St  j j j   d S(   sj   
        This is intended to be called by do_extend to remove entries from
        _history_list.
        N(   R+   RL   R<  R   R.   R=  R>  R   (   R   R<  (    (    s   renpy/character.pyR     s    N(   R!   R"   R#   t   special_propertiesR   R   R7   R   R    R@   R   R   R   R   R   R   R  R  R  R  R  R"  R$  R   R'  R   R   R-   R;  R   R   (    (    (    s   renpy/character.pyR     s>   	i			>	,		 						~		0c         K  s4   | d k r t j j } n  t |  |  d | | S(   s  
    :doc: character
    :args: (name, kind=adv, **args)
    :name: Character

    Creates and returns a Character object, which controls the look
    and feel of dialogue and narration.

    `name`
        If a string, the name of the character for dialogue. When
        ``name`` is None, display of the name is omitted, as for
        narration.

    `kind`
        The Character to base this Character off of. When used, the
        default value of any argument not supplied to this Character
        is the value of that argument supplied to ``kind``. This can
        be used to define a template character, and then copy that
        character with changes.

    **Linked Image.**
    An image tag may be associated with a Character. This allows a
    say statement involving this character to display an image with
    the tag, and also allows Ren'Py to automatically select a side
    image to show when this character speaks.

    `image`
         A string giving the image tag that is linked with this
         character.

    **Voice Tag.**
    If a voice tag is assign to a Character, the voice files that are
    associated with it, can be muted or played in the preference
    screen.

    `voice_tag`
        A String that enables the voice file associated with the
        Character to be muted or played in the 'voice' channel.

    **Prefixes and Suffixes.**
    These allow a prefix and suffix to be applied to the name of the
    character, and to the text being shown. This can be used, for
    example, to add quotes before and after each line of dialogue.

    `what_prefix`
        A string that is prepended to the dialogue being spoken before
        it is shown.

    `what_suffix`
        A string that is appended to the dialogue being spoken before
        it is shown.

    `who_prefix`
        A string that is prepended to the name of the character before
        it is shown.

    `who_suffix`
        A string that is appended to the name of the character before
        it is shown.

    **Changing Name Display.**
    These options help to control the display of the name.

    `dynamic`
        If true, then `name` should be a string containing a Python
        expression. That string will be evaluated before each line
        of dialogue, and the result used as the name of the character.

    **Controlling Interactions.**
    These options control if the dialogue is displayed, if an
    interaction occurs, and the mode that is entered upon display.

    `condition`
        If given, this should be a string containing a Python
        expression. If the expression is false, the dialogue
        does not occur, as if the say statement did not happen.

    `interact`
        If true, the default, an interaction occurs whenever the
        dialogue is shown. If false, an interaction will not occur,
        and additional elements can be added to the screen.

    `advance`
        If true, the default, the player can click to advance through
        the statement, and other means of advancing (such as skip and
        auto-forward mode) will also work. If false, the player will be
        unable to move past the say statement unless an alternate means
        (such as a jump hyperlink or screen) is provided.

    `mode`
        A string giving the mode to enter when this character
        speaks. See the section on :ref:`modes <modes>` for more details.

    `callback`
        A function that is called when events occur while the
        character is speaking. See the section on
        :ref:`character-callbacks` fore more information.

    **Click-to-continue.**
    A click-to-continue indicator is displayed once all the text has
    finished displaying, to prompt the user to advance.

    `ctc`
        A displayable to use as the click-to-continue indicator, unless
        a more specific indicator is used.

    `ctc_pause`
        A displayable to use a the click-to-continue indicator when the
        display of text is paused by the {p} or {w} text tags.

    `ctc_timedpause`
        A displayable to use a the click-to-continue indicator when the
        display of text is paused by the {p=} or {w=} text tags. When
        None, this takes its default from `ctc_pause`, use ``Null()``
        when you want a `ctc_pause` but no `ctc_timedpause`.

    `ctc_position`
        Controls the location of the click-to-continue indicator. If
        ``"nestled"``, the indicator is displayed as part of the text
        being shown, immediately after the last character. ``"nestled-close"`` is
        similar, except a break is not allowed between the text and the CTC
        indicator. If ``"fixed"``,
        the indicator is added to the screen, and its position is
        controlled by the position style properties.


    **Screens.**
    The display of dialogue uses a :ref:`screen <screens>`. These arguments
    allow you to select that screen, and to provide arguments to it.

    `screen`
        The name of the screen that is used to display the dialogue.

    Keyword arguments beginning with ``show_`` have the prefix
    stripped off, and are passed to the screen as arguments. For
    example, the value of ``show_myflag`` will become the value of
    the ``myflag`` variable in the screen. (The ``myflag`` variable isn't
    used by default, but can be used by a custom say screen.)

    One show variable is, for historical reasons, handled by Ren'Py itself:

    `show_layer`
        If given, this should be a string giving the name of the layer
        to show the say screen on.

    **Styling Text and Windows.**
    Keyword arguments beginning with ``who_``, ``what_``, and
    ``window_`` have their prefix stripped, and are used to :ref:`style
    <styles>` the character name, the spoken text, and the window
    containing both, respectively.

    For example, if a character is given the keyword argument
    ``who_color="#c8ffc8"``, the color of the character's name is
    changed, in this case to green. ``window_background="frame.png"``
    sets the background of the window containing this character's
    dialogue.

    The style applied to the character name, spoken text, and window
    can also be set this way, using the ``who_style``, ``what_style``, and
    ``window_style`` arguments, respectively.

    Setting :var:`config.character_id_prefixes` makes it possible to style
    other displayables as well. For example, when the default GUI is used,
    styles prefixed with ``namebox_`` are used to style the name of the
    speaking character.
    R   N(   R   R+   R.   R   Rr   (   RF   R   R7   (    (    s   renpy/character.pyR/    s    c         K  s   t  |  d t | S(   NR   (   R/  R   (   t	   name_exprR7   (    (    s   renpy/character.pyt   DynamicCharacter  s    (   t
   __future__R    t   renpy.displayR+   t   ret   osR   t   compilet   SR   t   environR   t   objectR   R   R   R:   R2   Rl   Rm   R   R   t   ObjectR   t   SentinelR   R0  R   R/  RH  (    (    (    s   renpy/character.pyt   <module>   sD   F#7		;  _