ó
{‘Œ\c           @  s)  d  d l  m Z d  d l Z d Z g  Z d Z d Z g  Z	 d Z
 e Z d Z d Z d Z i  Z d Z d Z e Z g  Z e Z e Z e Z e Z d Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ  d e f d „  ƒ  YZ! d e f d „  ƒ  YZ" d e f d „  ƒ  YZ# d e f d „  ƒ  YZ$ d e f d „  ƒ  YZ% d e f d „  ƒ  YZ& d e f d „  ƒ  YZ' e e e  e! e" e# e$ e% e& e' e( f Z) d  d „ Z* d „  Z+ d „  Z, i  d „ Z- e r%e j j. ƒ  Z e j/ j0 j1 ƒ  Z
 e j2 j3 ƒ  Z e j j4 ƒ  Z n  d S(   iÿÿÿÿ(   t   print_functionNt    i    t   ExceptionInfoc           B  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sÂ   
    Context manager that sets exception_info iff an exception occurs.

    `s`
        A percent-format string to use.
    `args`
        The arguments that are percent-formatted with `s`.
    c         C  s   | |  _  | |  _ d  S(   N(   t   st   args(   t   selfR   R   (    (    s   renpy/game.pyt   __init__m   s    	c         C  s   d  S(   N(    (   R   (    (    s   renpy/game.pyt	   __enter__q   s    c         C  s#   | r |  j  |  j t j _ n  t S(   N(   R   R   t   renpyt   gamet   exception_infot   False(   R   t   exc_typet   exc_valt   exc_tb(    (    s   renpy/game.pyt   __exit__t   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s   renpy/game.pyR   c   s   		t   RestartContextc           B  s   e  Z d  Z RS(   sk   
    Restarts the current context. If `label` is given, calls that label
    in the restarted context.
    (   R   R   R   (    (    (    s   renpy/game.pyR   {   s   t   RestartTopContextc           B  s   e  Z d  Z RS(   sg   
    Restarts the top context. If `label` is given, calls that label
    in the restarted context.
    (   R   R   R   (    (    (    s   renpy/game.pyR   ‚   s   t   FullRestartExceptionc           B  s   e  Z d  Z d d „ Z RS(   st   
    An exception of this type forces a hard restart, completely
    destroying the store and config and so on.
    t   end_gamec         C  s   | |  _  d  S(   N(   t   reason(   R   R   (    (    s   renpy/game.pyR      s    (   R   R   R   R   (    (    (    s   renpy/game.pyR   ‰   s   t   UtterRestartExceptionc           B  s   e  Z d  Z RS(   st   
    An exception of this type forces an even harder restart, causing
    Ren'Py and the script to be reloaded.
    (   R   R   R   (    (    (    s   renpy/game.pyR   “   s   t   QuitExceptionc           B  s   e  Z d  Z e d d „ Z RS(   s'  
    An exception of this class will let us force a safe quit, from
    anywhere in the program.

    `relaunch`
        If given, the program will run another copy of itself, with the
        same arguments.

    `status`
        The status code Ren'Py will return to the operating system.
    i    c         C  s#   t  j |  ƒ | |  _ | |  _ d  S(   N(   t	   ExceptionR   t   relauncht   status(   R   R   R   (    (    s   renpy/game.pyR   §   s    	(   R   R   R   R   R   (    (    (    s   renpy/game.pyR   š   s   t   JumpExceptionc           B  s   e  Z d  Z RS(   s®   
    This should be raised with a label as the only argument. This causes
    the current statement to terminate, and execution to be transferred
    to the named label.
    (   R   R   R   (    (    (    s   renpy/game.pyR   ­   s   t   JumpOutExceptionc           B  s   e  Z d  Z RS(   s‡   
    This should be raised with a label as the only argument. This exits
    the current context, and then raises a JumpException.
    (   R   R   R   (    (    (    s   renpy/game.pyR   µ   s   t   CallExceptionc           B  s)   e  Z d  Z e Z e d „ Z d „  Z RS(   s   
    Raise this exception to cause the current statement to terminate,
    and control to be transferred to the named label.
    c         C  s5   t  j |  ƒ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   t   labelR   t   kwargst   from_current(   R   R    R   R!   R"   (    (    s   renpy/game.pyR   Ä   s
    			c         C  s"   t  |  j |  j |  j |  j f f S(   N(   R   R    R   R!   R"   (   R   (    (    s   renpy/game.pyt
   __reduce__Ì   s    (   R   R   R   R   R"   R   R#   (    (    (    s   renpy/game.pyR   ¼   s   t	   EndReplayc           B  s   e  Z d  Z RS(   s_   
    Raise this exception to end the current replay (the current call to
    call_replay).
    (   R   R   R   (    (    (    s   renpy/game.pyR$   Ð   s   t   ParseErrorExceptionc           B  s   e  Z d  Z RS(   s_   
    This is raised when a parse error occurs, after it has been
    reported to the user.
    (   R   R   R   (    (    (    s   renpy/game.pyR%   ×   s   c         C  s   t  |  S(   sj   
    Return the current execution context, or the context at the
    given index if one is specified.
    (   t   contexts(   t   index(    (    s   renpy/game.pyt   contextï   s    c         O  s  t  j j t t d d t ƒ} t j | ƒ t  j j d k	 rQ t  j j j
 ƒ  n  zd y |  | | Ž  SWnL t  j j k
 r³ } t t d _ t t d _ t  j j | j d ƒ ‚ n XWd | j ƒ  t j ƒ  t d j ƒ  t rt j rt rd t d j _ n  Xd S(   sÇ  
    :doc: label

    This function creates a new context, and invokes the given Python
    callable (function) in that context. When the function returns
    or raises an exception, control returns to the the original context.
    It's generally used to call a Python function that needs to display
    information to the player (like a confirmation prompt) from inside
    an event handler.

    A context maintains the state of the display (including what screens
    and images are being shown) and the audio system. Both are restored
    when the context returns.

    Additional arguments and keyword arguments are passed to the
    callable.

    A context created with this function cannot execute Ren'Py script.
    Functions that would change the flow of Ren'Py script, like
    :func:`renpy.jump`, are handled by the outer context. If you want
    to call Ren'Py script rather than a Python function, use
    :func:`renpy.call_in_new_context` instead.
    iÿÿÿÿt   cleariþÿÿÿi    N(   R   t	   executiont   ContextR   R&   t   Truet   appendt   displayt	   interfacet   Nonet   enter_contextR	   R   t   force_checkpointt   abnormalR   R   t   pop_all_dynamict   popt   do_deferred_rollbackt   restart_interactiont   scene_listst   focused(   t   callableR   R!   R(   t   e(    (    s   renpy/game.pyt   invoke_in_new_contextø   s      !

c         O  s[  t  j j t t d d t ƒ} t j | ƒ t  j j d k	 rQ t  j j j
 ƒ  n  | rf | t  j _ n d t  j _ | r“ t  j j | ƒ t  j _ n d t  j _ zt y! | j |  ƒ t  j j t ƒ SWnL t  j j k
 r} t t d _ t t d _ t  j j | j d ƒ ‚ n XWd t j ƒ  t d j ƒ  t rVt j rVt rVd t d j _ n  Xd S(   sL  
    :doc: label

    This creates a new context, and then starts executing Ren'Py script
    from the given label in that context. Rollback is disabled in the
    new context, and saving/loading will occur in the top level
    context.

    Use this to begin a second interaction with the user while
    inside an interaction.
    iÿÿÿÿR)   iþÿÿÿi    N(   R   R*   R+   R   R&   R,   R-   R.   R/   R0   R1   t   storet   _argst   pythont   RevertableDictt   _kwargst
   goto_labelt   run_contextR	   R   R2   R3   R   R   R5   R6   R7   R8   R9   (   R    R   R!   R(   R;   (    (    s   renpy/game.pyt   call_in_new_context,  s,     !
c         C  sË  t  j j j ƒ  t  j j } t  j j ƒ  t  j _ t  j j ƒ  } t  j j ƒ  t  j j	 t
 ƒ } t j | ƒ t  j j d k	 r‘ t  j j j ƒ  n  t  j j ƒ  x3 t  j j j ƒ  D] \ } } t t  j | | ƒ q± Wx- | j ƒ  D] \ } } t t  j | | ƒ qá W|  t  j _ z9 y! | j d ƒ t  j j t ƒ Wn t k
 rGn XWd | j ƒ  t j ƒ  | t  j _ | j ƒ  t ržt j  ržt ržd t d j! _" n  d t  j _# Xt  j j$ rÇt  j j$ ƒ  n  d S(   s˜   
    :doc: replay

    Calls a label as a memory.

    Keyword arguments are used to set the initial values of variables in the
    memory context.
    t   _start_replayNiÿÿÿÿ(%   R   R	   t   logt   completeR?   t   RollbackLogt   StoreBackupt   clean_storesR*   R+   R,   R&   R-   R.   R/   R0   R1   t   exportst   execute_default_statementt   configt   replay_scopet	   iteritemst   setattrR=   t
   _in_replayRB   RC   R   R$   R4   R5   t   restoreR7   R8   R9   t   skippingt   after_replay_callback(   R    t   scopet   old_logt   sbR(   t   kt   v(    (    s   renpy/game.pyt   call_replay\  s<    
 


(5   t
   __future__R    t   renpy.displayR   R0   t   basepatht
   searchpathR   t   scriptR&   R/   R   t   lintRF   R
   t   stylet   seen_sessiont   seen_translates_countt   new_translates_countt   after_rollbackt	   post_initt   less_memoryt   less_updatest
   less_mouset   less_imagedissolvet
   persistentt   preferencest   objectR   R   R   R   R   R   R   R   R   R   R$   R%   t   KeyboardInterruptt   CONTROL_EXCEPTIONSR(   R<   RD   RZ   t   ScriptR.   t   coret	   InterfaceR?   RH   t   Preferences(    (    (    s   renpy/game.pyt   <module>   sj   

			4	0=