
\c           @  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z d e j	 j
 f d     YZ d e j	 j
 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 g  a g  a d a g  a d   Z e j j j e  d d d  Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d d  Z% d    Z& d!   Z' d"   Z( e j	 j) d#  Z* d$   Z+ d%   Z, d Z- d& e j	 j
 f d'     YZ. d(   Z/ e. e/  Z0 d)   Z1 e. e1  Z2 d*   Z3 e. e3  Z4 e. e j5 j6 j7  Z8 e. e j9 j9 j: d+ d, d- e; Z9 e. e j5 j6 j< d. d/ d+ d0 d1 e; Z= e. e j5 j6 j< d. d2 d+ d3 d1 e; Z> e. e j5 j6 j< d. d4 d+ d4 d1 e; Z? e. e j5 j6 j< d. d4 d1 e; Z@ e. e j5 j6 jA d+ d5 d1 e; ZB e. e j5 j6 jC d+ d6 d1 e; ZD d d d7  ZE e. eE d8 e; ZF e. e j5 j6 jG d+ d9 d8 e; d: d ZH e. e j5 j6 jG d+ d; d8 e; d: d ZI e. e j5 jJ jK  ZL e. e j5 jJ jM  ZN e. e j5 jJ jO  ZP e. e j5 jJ jQ  ZR d d d<  ZS e. eS  ZT d= e f d>     YZU d? eU f d@     YZV dA eU f dB     YZW dC dD dE dF dG dH d d eX dI 	 ZY e. e j5 jJ jZ dJ dK d+ dL d- e; Z[ d dM dN dO  Z\ e. e j5 jJ j] d+ dP d8 e; Z^ d d d d d d d d d d d d d d d d dQ  Z_ e. e_ d+ dR Z` d d d e; d dS  Za e. ea  Zb d d e; d dT  Zc e. ec  Zd e j5 jJ je Zf dU   Zg e. eg d2 eX d- e; Zh e. eg d2 e; d- e; Zi e. eg d+ dV d- e; Zj e. eg d+ dW d- e; Zk e. eg d+ dX d- e; Zl e. eg d+ dY d- e; Zm dZ   Zn e jo jo en  Zp d[   Zq e. eq  Zr e. e j5 js jt d8 e; d+ d\ Zu e. e j5 jv jw d8 e; d- e; d+ d] Zx e. e j5 jv jy d1 e; d- e; d+ d^ Zz d_ Z{ d d`  Z| da   Zv db   Z} e. e j5 jJ j~ d8 e; Z e. e j5 jJ j d- e; Z e. e j5 j j d- e; d8 e; Z e. e j5 j j d- e; d1 e; Z e. e j5 jJ j d- e; Z dc e	 f dd     YZ d d d d d d d d e; e; dM de  Z e. e dM e; d+ dM Z dN df  Z e. e d+ dN d8 e; Z dg   Z d d d dh  Z e. e d+ di d- e; Z dj   Z e jo jo e  Z d dk  Z e jo jo e  Z dl   Z e jo jo e  Z dm   Z dn   Z do   Z e. e j5 jJ j  Z dp   Z dq \ Z Z x8 e   j   D]' \ Z Z e e e.  re e _ qqWd S(r   i(   t   print_functionN(   t   is_selectedt   is_sensitivet   Actionc           B  sJ   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   s   
    This can be passed to the clicked method of a button or hotspot. It is
    called when the action is selected. The other methods determine if the
    action should be displayed insensitive or disabled.
    c         C  s   t  S(   N(   t   True(   t   self(    (    s   renpy/ui.pyt   get_sensitive3   s    c         C  s   t  S(   N(   t   False(   R   (    (    s   renpy/ui.pyt   get_selected6   s    c         C  s   d  S(   N(   t   None(   R   (    (    s   renpy/ui.pyt   get_tooltip9   s    c         C  s   d  S(   N(    (   R   t   st(    (    s   renpy/ui.pyt   periodic<   s    c         C  s   d  S(   N(    (   R   (    (    s   renpy/ui.pyt   predict?   s    c         C  s   t  d   d  S(   Ns   Not implemented(   t	   Exception(   R   (    (    s   renpy/ui.pyt   __call__B   s    N(   t   __name__t
   __module__t   __doc__R	   t   altR   R   R
   R   R   R   (    (    (    s   renpy/ui.pyR   )   s   					t   BarValuec           B  sA   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z RS(   sC   
    This can be passed to the value method of bar and hotbar.
    t   Barc         C  s   d  S(   N(    (   R   t   other(    (    s   renpy/ui.pyt   replacesN   s    c         C  s   d  S(   N(    (   R   R   (    (    s   renpy/ui.pyR   Q   s    c         C  s   t  d   d  S(   Ns   Not implemented(   R   (   R   (    (    s   renpy/ui.pyt   get_adjustmentT   s    c         C  s   d S(   Nt   bart   vbar(   s   bars   vbar(    (   R   (    (    s   renpy/ui.pyt	   get_styleW   s    c         C  s   d  S(   N(   R	   (   R   (    (    s   renpy/ui.pyR
   Z   s    (	   R   R   R   R   R   R   R   R   R
   (    (    (    s   renpy/ui.pyR   F   s   				t   Addablec           B  s   e  Z d Z d    Z RS(   c         C  s
   t  d  S(   Ns+   Operation can only be performed on a layer.(   R   (   R   (    (    s   renpy/ui.pyt	   get_layerg   s    N(   R   R   R	   t   style_prefixR   (    (    (    s   renpy/ui.pyR   c   s   t   Layerc           B  s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C  s   | |  _  d  S(   N(   t   name(   R   R    (    (    s   renpy/ui.pyt   __init__m   s    c         C  s,   t  j j d  j j |  j | d | d  S(   Nit   key(   t   renpyt   gamet   contextt   scene_listst   addR    (   R   t   dR"   (    (    s   renpy/ui.pyR'   p   s    c         C  s?   t  j   | r; | |  j k r; t d |  j | f   n  d  S(   Ns.   ui.close closed layer %s, not the expected %r.(   t   stackt   popR    R   (   R   R(   (    (    s   renpy/ui.pyt   closes   s    
c         C  s   |  j  S(   N(   R    (   R   (    (    s   renpy/ui.pyR   y   s    c         C  s   d |  j  S(   Ns   <Layer: %r>(   R    (   R   (    (    s   renpy/ui.pyt   __repr__|   s    (   R   R   R!   R'   R+   R   R,   (    (    (    s   renpy/ui.pyR   k   s
   				t   Manyc           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s,   
    A widget that takes many children.
    c         C  s   | |  _  | |  _ | |  _ d  S(   N(   t   displayablet   imagemapR   (   R   R.   R/   R   (    (    s   renpy/ui.pyR!      s    		c         C  s   |  j  j |  d  S(   N(   R.   R'   (   R   R(   R"   (    (    s   renpy/ui.pyR'      s    c         C  sd   t  j   |  j r/ t j   } | j j   n  | r` | |  j k r` t d |  j | f   n  d  S(   Ns(   ui.close closed %r, not the expected %r.(   R)   R*   R/   t   imagemap_stackt   cachet   finishR.   R   (   R   R(   R/   (    (    s   renpy/ui.pyR+      s    
	c         C  s   d |  j  S(   Ns
   <Many: %r>(   R.   (   R   (    (    s   renpy/ui.pyR,      s    (   R   R   R   R!   R'   R+   R,   (    (    (    s   renpy/ui.pyR-      s
   			
t   Onec           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s2   
    A widget that expects exactly one child.
    c         C  s   | |  _  | |  _ d  S(   N(   R.   R   (   R   R.   R   (    (    s   renpy/ui.pyR!      s    	c         C  s   |  j  j |  t j   d  S(   N(   R.   R'   R)   R*   (   R   R(   R"   (    (    s   renpy/ui.pyR'      s    c         C  s   t  d |  j   d  S(   Ns   Widget %r expects a child.(   R   R.   (   R   R(   (    (    s   renpy/ui.pyR+      s    c         C  s   d |  j  S(   Ns	   <One: %r>(   R.   (   R   (    (    s   renpy/ui.pyR,      s    (   R   R   R   R!   R'   R+   R,   (    (    (    s   renpy/ui.pyR3      s
   			t   Detachedc           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   s?   
    Used to indicate a widget is detached from the stack.
    c         C  s   | |  _  d  S(   N(   R   (   R   R   (    (    s   renpy/ui.pyR!      s    c         C  s   | |  _  t j   d  S(   N(   t   childR)   R*   (   R   R(   R"   (    (    s   renpy/ui.pyR'      s    	c         C  s   t  d   d  S(   Ns%   Detached expects to be given a child.(   R   (   R   R(   (    (    s   renpy/ui.pyR+      s    (   R   R   R   R!   R'   R+   (    (    (    s   renpy/ui.pyR4      s   		t   ChildOrFixedc           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    If one widget is added, then it is added directly to our
    parent. Otherwise, a fixed is added to our parent, and all
    the widgets are added to that.
    c         C  s   g  |  _  | |  _ d  S(   N(   t   queueR   (   R   R   (    (    s   renpy/ui.pyR!      s    	c         C  s   |  j  j |  d  S(   N(   R7   t   append(   R   R(   R"   (    (    s   renpy/ui.pyR'      s    c         C  s   t  j   t |  j  d k r3 t |  j d  n, t   x |  j D] } t |  qD Wt   | d  k	 r~ t d |   n  d  S(   Ni   i    s   Did not expect to close %r.(	   R)   R*   t   lenR7   t   implicit_addt   fixedR+   R	   R   (   R   R(   t   i(    (    s   renpy/ui.pyR+      s    
(   R   R   R   R!   R'   R+   (    (    (    s   renpy/ui.pyR6      s   		c           C  s   t  d  g a g  a g  a d  S(   Nt	   transient(   R   R)   t   at_stackR0   (    (    (    s   renpy/ui.pyt   reset   s    t   miscc         K  s  t  d k r t d   n  t j j d k r< d t j _ n  t t   d k r t d d j g  t  D] } t |  ^ qa    n  t	 r t d   n  |  t j
 j   j _ t j
 j j d | |  } |  t j
 j   j _ t j j   r | d k	 r | S| Sd S(	   s  
    :doc: ui
    :args: (roll_forward=None, mouse='default')

    Causes an interaction with the user, and returns the result of that
    interaction. This causes Ren'Py to redraw the screen and begin processing
    input events. When a displayable returns a value in response to an event,
    that value is returned from ui.interact, and the interaction ends.

    This function is rarely called directly. It is usually called by other
    parts of Ren'Py, including the say statement, menu statement, with statement,
    pause statement, call screen, :func:`renpy.input`, among many other
    functions. However, it can be called directly if necessary.

    When an interaction ends, the transient layer and all screens shown with
    transient=True are cleared from the scene lists.

    The following arguments are documented. As other, undocumented arguments
    exist for Ren'Py's internal use, please pass all arguments as keyword
    arguments.

    `roll_forward`
        The information that will be returned by this function when a
        roll forward occurs. (If None, the roll forward is ignored.) This
        should usually be passed the result of the :func:`renpy.roll_forward_info`
        function.

    `mouse`
        The style of mouse cursor to use during this function.
    s*   Interaction not allowed during init phase.t   fasti   sg   ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was s   
s+   ui.interact called with non-empty at stack.t   roll_forwardN(   R)   R	   R   R#   t   configt   skippingR9   t   joint   strR>   R$   R%   t   infot   _current_interact_typet	   interfacet   interactt   _last_interact_typet   exportst   in_fixed_rollback(   t   typeRB   t   kwargst   itemt   rv(    (    s   renpy/ui.pyRJ      s     5c         C  s
   |  a  d  S(   N(   t   add_tag(   R    (    (    s   renpy/ui.pyt   tag0  s    c           C  s   t  j t t  d j   d S(   s  
    Causes the current widget to be given child-fixed semantics. This
    means that we will queue up children added to it. If there is one
    child, that child will be added to the widget directly. Otherwise,
    a fixed will be created, and the children will be added to that.
    iN(   R)   R8   R6   R   (    (    (    s   renpy/ui.pyt   child_or_fixed5  s    c         C  s3   t  d j   } t j j d  j j | |   d  S(   Ni(   R)   R   R#   R$   R%   R&   t   remove(   R(   t   layer(    (    s   renpy/ui.pyRU   @  s    c         C  s3   t  d j   } t j j d  j j | |   d  S(   Ni(   R)   R   R#   R$   R%   R&   t   remove_above(   R(   RV   (    (    s   renpy/ui.pyRW   E  s    c         C  s   t  j |   d S(   s   
    :doc: ui

    Specifies a transform that is applied to the next displayable to
    be created. This is largely obsolete, as all UI functions now take
    an `at` argument.
    N(   R>   R8   (   t	   transform(    (    s   renpy/ui.pyt   atJ  s    	c          C  s0   t  d j   }  t j j d  j j |   d  S(   Ni(   R)   R   R#   R$   R%   R&   t   clear(   RV   (    (    s   renpy/ui.pyRZ   V  s    c          C  s$   t  t d j  }  t j |   |  S(   s   
    :doc: ui

    Do not add the next displayable to any later or container. Use this if
    you want to assign the result of a ui function to a variable.
    i(   R4   R)   R   R8   (   RQ   (    (    s   renpy/ui.pyt   detached[  s    c         C  s   t  j t |    d S(   sx   
    :doc: ui

    Adds displayables to the layer named `name`. The later must be
    closed with :func:`ui.close`.
    N(   R)   R8   R   (   R    (    (    s   renpy/ui.pyRV   h  s    c         C  s*   t  d j |   t  s& t d   n  d S(   s   
    :doc: ui
    :args: ()

    Closes a displayable created with by a UI function. When a
    displayable is closed, we add new displayables to its parent,
    or to the layer if no displayable is open.
    is2   ui.close() called when no layer or widget is open.N(   R)   R+   R   (   R(   (    (    s   renpy/ui.pyR+   s  s    
c         C  s*   t  j t |    | r& g  |  j (n  d  S(   N(   R)   R8   R-   t   children(   t   wRZ   (    (    s   renpy/ui.pyt   reopen  s    c         C  sX   t  t j j d t j j  r< t j j d j |  k r< d  St d t |   j   d  S(   Nis'   %r cannot be used as a context manager.(	   t
   isinstanceR#   t   uiR)   R-   R.   R   RN   R   (   R]   (    (    s   renpy/ui.pyt   context_enter  s    8c         C  s   t  |   d  S(   N(   R+   (   R]   (    (    s   renpy/ui.pyt   context_exit  s    t   NoStylePrefixGivenc         C  s3   |  d k r | } n |  d | } t j j |  S(   s   
    Combines a style prefix and style suffix to create a style name, then
    returns the style object corresoinding to that name.
    t   _N(   R	   R#   t   styleR   (   R   t   style_suffixt	   new_style(    (    s   renpy/ui.pyt   combine_style  s    	c         C  s   t  t d j |   S(   s@   
    Combines the default style prefix with a style suffix.
    i(   Rh   R)   R   (   Rf   (    (    s   renpy/ui.pyt   prefixed_style  s    t   Wrapperc           B  s2   e  Z d    Z e e e e d d  Z d   Z RS(   c         C  s   |  j  S(   N(   R    (   R   (    (    s   renpy/ui.pyt
   __reduce__  s    c         K  sR   d  |  _ | |  _ | |  _ | p$ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(	   R	   R    t   functiont   onet   manyR/   R   RO   Re   (   R   Rl   Rm   Rn   R/   R   Re   RO   (    (    s   renpy/ui.pyR!     s    						c         O  s  t  s t d   n  | j d d   } | j d g   } t | t t f  sZ | g } n  t  d j } d | k r | j d  } n  d | k r | j d  } n  |  j r |  j j	   } | j
 |  n | } t o t j } t } t r-| t j k r| j
 t j |  n  | t j k r-t } q-n  | rmt j j | d   }	 |  j rs|	 d  k	 rs|	 | d <qsn d  }	 | j d d   p|  j }
 |
 rd	 | k rt | |
  | d	 <n  y |  j | |   } Wnj t k
 r8} t j   \ } } } | | j d  k r/| j d
 j d d |  j  f | _ n  ~   n X| j pE| } |	 d  k	 rzt j rz| t  j! j" j# t$ |	  <n  | } x t% r| j& t% j    qWxD | D]< } t | t  j! j' j(  r| d |  } q| |  } qW| rt  d j) | t*  n  |  j+ r&t  j& t, | |   n( |  j- rNt  j& t. | |  j/ |   n  t r| d  k	 r| t j0 | <t | t  j! j' j(  r| t j1 | <| rt j2 j | d   } n d  } | j3 |  | j4 |  qn  d  a* | S(   Ns(   Can't add displayable during init phase.t   idRY   it   style_groupR   R   Rf   Re   i    R   s   ui.R5   (5   R)   R   R*   R	   R_   t   listt   tupleR   RO   t   copyt   updatet   screent   old_transfersR   t   widget_propertiest   hidden_widgetsR   t   old_widgetst   getR   Re   Rh   Rl   t	   TypeErrort   syst   exc_infot   tb_nextt   argst   replaceR    t   _maint   hidingR#   t   displayt   focust   replaced_byRo   R>   R8   t   motiont	   TransformR'   RR   Rm   R3   Rn   R-   R/   t   widgetst
   transformst   old_transformst
   take_statet   take_execution_state(   R   R   RO   t	   widget_idt   at_listR   t   keywordRv   t   do_addt   old_mainRf   R]   t   et   etypet   tbt   maint   atwt   atft   oldt(    (    s   renpy/ui.pyR     s    	 )			N(   R   R   Rk   R   R	   R!   R   (    (    (    s   renpy/ui.pyRj     s   	c         K  se   t  j j |   }  |  j r7 |  j d   }  |  j   n  |  } | ra t  j j j	 d |  |  } n  | S(   NR5   (
   R#   t   easyR.   t   _duplicatablet
   _duplicateR	   t   _uniqueR   R   R   (   R(   RO   RQ   (    (    s   renpy/ui.pyt   _addH  s    	c         C  s   |  S(   se   
    A faster version of add to use when we know `d` is a displayable and isn't
    transformed.
    (    (   R(   (    (    s   renpy/ui.pyt   _implicit_addZ  s    c         K  sG   t  j j j |  d t | } | j rC | j d   } | j   n  | S(   Nt   loose(	   R#   R   t   imt   imageR   R   R   R	   R   (   R   t
   propertiesR(   (    (    s   renpy/ui.pyt   _imagef  s
    	Re   t   textR   t   layoutt
   horizontalt   hboxRn   t   verticalt   vboxR;   t   gridt   sidec         K  s   t  j j j d |  d | |  S(   Nt   xmaximumt   ymaximum(   R#   R   R   t	   Container(   t   maxwidtht	   maxheightR   (    (    s   renpy/ui.pyt   _sizer|  s    Rm   t   windowR5   t   framec         C  s;   | d  k r t d   n  t j j j d | i | |  6 S(   Ns   Action is required in ui.key.t   activate_sound(   R	   R   R#   R   t   behaviort   Keymap(   R"   t   actionR   (    (    s   renpy/ui.pyt   _key  s    t   ChoiceActionBasec           B  sG   e  Z d  Z e Z d d e d d d  Z d   Z d   Z d   Z	 RS(   sa  
    Base class for choice actions. The choice is identified by a label
    and value. The class will automatically determine the rollback state
    and supply correct "sensitive" and "selected" information to the
    widget.
    If a location is supplied, it will check whether the choice was
    previously visited and mark it so if it is chosen.
    c         C  s   | |  _  | |  _ | |  _ | |  _ | d  k rB t j j |  _ n	 | |  _ d  |  _	 |  j r t j
 j j |  _	 |  j	 d  k r i  |  _	 t j
 j _ q n  | |  _ | |  _ d  S(   N(   t   labelt   valuet   locationt	   sensitiveR	   R#   RC   t   fix_rollback_without_choicet	   block_allt   chosenR$   t
   persistentt   _chosenR   RO   (   R   R   R   R   R   R   R   RO   (    (    s   renpy/ui.pyR!     s    								c         C  s-   |  j  r t j j   p, |  j o, |  j   S(   N(   R   R#   RL   RM   R   R   (   R   (    (    s   renpy/ui.pyR     s    	c         C  s+   t  j j   } t  j j   o* | |  j k S(   N(   R#   RL   t   roll_forward_infoRM   R   (   R   RB   (    (    s   renpy/ui.pyR     s    c         C  s,   |  j  d  k r t S|  j |  j f |  j  k S(   N(   R   R	   R   R   R   (   R   (    (    s   renpy/ui.pyt
   get_chosen  s    N(
   R   R   R   R   R   R	   R!   R   R   R   (    (    (    s   renpy/ui.pyR     s   		t   ChoiceReturnc           B  s   e  Z d  Z d   Z RS(   s  
    :doc: blockrollback

    A menu choice action that returns `value`, while managing the button
    state in a manner consistent with fixed rollback. (See block_all for
    a description of the behavior.)


    `label`
        The label text of the button. For imagebuttons and hotspots this
        can be anything. This label is used as a unique identifier of
        the options within the current screen. Together with `location`
        it is used to store whether this option has been chosen.

    `value`
        The value this is returned when the choice is chosen.

    `location`
        A unique location identifier for the current choices screen.

    `block_all`
        If false, the button is given the selected role if it was
        the chosen choice, and insensitive if it was not selected.

        If true, the button is always insensitive during fixed
        rollback.

        If None, the value is taken from the :var:`config.fix_rollback_without_choice`
        variable.

        When true is given to all items in a screen, it will
        become unclickable (rolling forward will still work). This can
        be changed by calling :func:`ui.saybehavior` before the call
        to :func:`ui.interact`.
    c         C  s2   |  j  d  k	 r+ t |  j  |  j |  j f <n  |  j S(   N(   R   R	   R   R   R   R   (   R   (    (    s   renpy/ui.pyR     s    (   R   R   R   R   (    (    (    s   renpy/ui.pyR     s   #t
   ChoiceJumpc           B  s    e  Z d  Z d   Z d   Z RS(   s  
    :doc: blockrollback

    A menu choice action that returns `value`, while managing the button
    state in a manner consistent with fixed rollback. (See block_all for
    a description of the behavior.)


    `label`
        The label text of the button. For imagebuttons and hotspots this
        can be anything. This label is used as a unique identifier of
        the options within the current screen. Together with `location`
        it is used to store whether this option has been chosen.

    `value`
        The location to jump to.

    `location`
        A unique location identifier for the current choices screen.

    `block_all`
        If false, the button is given the selected role if it was
        the chosen choice, and insensitive if it was not selected.

        If true, the button is always insensitive during fixed
        rollback.

        If None, the value is taken from the :var:`config.fix_rollback_without_choice`
        variable.

        When true is given to all items in a screen, it will
        become unclickable (rolling forward will still work). This can
        be changed by calling :func:`ui.saybehavior` before the call
        to :func:`ui.interact`.
    c         C  sP   t  j j   } t | t  j j  r4 | j d } n  t  j j   oO | |  j k S(   Ni    (	   R#   RL   R   R_   R$   t   JumpExceptionR   RM   R   (   R   RB   (    (    s   renpy/ui.pyR     s    c         C  sB   |  j  d  k	 r+ t |  j  |  j |  j f <n  t j j |  j  d  S(   N(	   R   R	   R   R   R   R#   RL   t   jumpR   (   R   (    (    s   renpy/ui.pyR   !  s    (   R   R   R   R   R   (    (    (    s   renpy/ui.pyR     s   #		t   menut   menu_captiont   menu_choicet   menu_choice_chosent   menu_choice_buttont   menu_choice_chosen_buttonc
         K  s&  t  j j d | |
  x|  D] \ } } | d  k rN t  j j | d | q | } | } t | | |  } | j   r | } | } n  t | t  r t	 t  j
 j |  } n  t | t  r t	 t  j
 j |  } n  | | } | | } t  j j | d | d | d | d | d |	 q Wt   d  S(   NRe   t
   text_stylet   clickedR   t   default(   R#   R`   R   R	   R   R   R   R_   t
   basestringt   getattrR$   Re   t
   textbuttonR+   (   t	   menuitemsRe   t   caption_stylet   choice_stylet   choice_chosen_stylet   choice_button_stylet   choice_chosen_button_styleR   R   R   R   R   t   valR   t   buttonR   (    (    s   renpy/ui.pyR   (  s.    	

t   excludes   {}t   inputR/   t   hotspotc         K  s;  t  | t  r' t t j j |  } n  t d | |  | d  k rL |  } n  t |   x | D] \ } } }	 }
 } | d  k r q] n  t	 | |  } t j
 j j | | |	 | |
 | f |  } t t j
 j j | | |	 | |
 | f |  | d | d | d | d | | d | d d d | d	 d d
 t 	q] Wt   d  S(   NRe   t   selected_idle_imaget   selected_insensitive_imageR   t   xpost   xanchori    t   ypost   yanchort
   focus_mask(   R_   R   R   R#   R$   Re   R;   R	   R'   R   R   R   t   LiveCropt   imagebuttonR   R+   (   t   groundt   selectedt   hotspotst
   unselectedRe   t   button_styleR   t   x0t   y0t   x1t   y1t   resultR   t   selected_img(    (    s   renpy/ui.pyt   imagemap_compat[  s.    	
,,
R   c           s   t    f d  } | | |  d d t } | |	 | d  }	 | |
 | d  }
 | | | d  } | | | d  } | | | d  } t j j j | |	 d	 |
 d
 | d | d | d | d | | S(   Nc           s   |  r
 |  S| r | S  d  k	 rH t j j   |  } | d  k	 rH | Sn  | r   rm t d |   f   q t d | f   n  d  S(   Ns0   Imagebutton does not have a %s image. (auto=%r).s%   Imagebutton does not have a %s image.(   R	   R#   RC   t   imagemap_auto_functionR   (   t   at   bR    t   requiredRQ   (   t   auto(    s   renpy/ui.pyt   choice  s    t   idleR   t   hovert   insensitivet   selected_idlet   selected_hovert   selected_insensitivet   insensitive_imaget   activate_imageR   t   selected_hover_imageR   t   selected_activate_image(   R   R   R#   R   R   t   ImageButton(   t
   idle_imaget   hover_imageR  R  R   R  R   R  R   R   R   R   R   R   t   image_styleR   R   R   (    (   R   s   renpy/ui.pyt   _imagebutton  s"    t   image_buttonc      	   K  s  t  j j | d d  \ } } d | k rP t | d t  rP | j d  qP n  | j d d   | d  k r{ t d  } n  | d  k r t  j j	 | t d   } n  t  j
 j j d | d | |  }	 t  j j j |  d | d	 | d
 | | }
 |	 j |
  |
 |	 _ |
 g |	 _ |	 S(   Nt   text_t    t   alignt   y_fudgeR   t   button_textRe   R   t
   substitutet   scope(   R#   R   t   split_propertiesR_   t   floatR*   R	   Ri   Re   t   get_text_styleR   R   t   ButtonR   t   TextR'   R   t   _composite_parts(   R   R   Re   R   R  R  RO   t   text_kwargst   button_kwargsRQ   R   (    (    s   renpy/ui.pyt   _textbutton  s    !*	c   
   	   K  s   t  j j | d d  \ } } | d  k r9 t d  } n  | d  k rc t  j j | t d   } n  t  j j j	 d  d | | } t  j
 j
 j |  d | d | d | | }	 | j |	  |	 | _ |	 g | _ | S(   NR  R  R   t
   label_textRe   R  R  (   R#   R   R  R	   Ri   Re   R  R   R   t   WindowR   R  R'   R   R  (
   R   Re   R   R  R  RO   R  t   label_kwargsRQ   R   (    (    s   renpy/ui.pyt   _label  s    *	c          O  sy  t  |   d k r' |  \ } } } } n  t  |   d k rT |  \ } } d  } d  } n d } d } d  } d  } d | k r | j d  } n  d | k r | j d  } n  d | k r | j d  } n  d | k r | j d  } n  d	 | k rZt | t  rZ| d
 r| j   d } n | j   d } t | t  rJt |  } n  | | d	 <qZn  t j	 j
 j | | | | |  S(   Ni   i   i   i    t   widtht   heightt   rangeR   Re   R   (   R9   R	   R*   R_   R   R   R   Ri   R#   R   R   R   (   R   R   R  R   R!  R   Re   (    (    s   renpy/ui.pyt   _bar  s6    	
t   slidert   vslidert	   scrollbart
   vscrollbarc   
      K  sb   | | k r d } d  } n | | } d } | | | | }	 t j j j |  |	 d  d  |  | f S(   Ng      ?i    (   R	   R#   R   R   R   (
   R!  t   startt   endt   timeR   RY   R   t   tt   redrawR   (    (    s   renpy/ui.pyt   _autobar_interpolate)  s    	
c         K  s%   t  j j j t |  | | | |   S(   N(   R#   R   R   t   DynamicDisplayablet   autobar_interpolate(   R!  R'  R(  R)  R   (    (    s   renpy/ui.pyt   _autobar9  s    RX   t   viewportt   vpgridi  c         K  sS  | d  k r |  |   St j j | d d d d d  \ } } } } } t j j r d d l m }	 xl | j   D]N \ }
 } |
 |	 k r | | |
 <qo | r |
 d k r | | |
 <qo | | |
 <qo Wn | j	 |  t j j
 r| d	 k r| j d
 t d   n | j d
 d  t j j
 rC| d k rC| j d
 t d   n | j d
 d  | j d d  } | j d t j j |  d t j j d   | j d t j j |  d t j j d   | d	 k rFt j j r| j d d  t f  n  t d |  |  |   } t j   } t d | j |  t   t j |  | S| d k rt j j rw| j d t d  f  n  t d |  |  |   } t j   } t d | j |  t   t j |  | St j j r| j d t t f  n  t d |  |  |   } t j   } t d | j |  t d | j |  t   t j |  | Sd  S(   Nt   vscrollbar_t
   scrollbar_t   side_t	   viewport_R  i(   t   position_property_namest   spacingR   Re   R%  R   R&  R   R0  t    s   horizontal scrolls   vertical scrollt
   child_sizes   c rt
   adjustments   c bs   c r b(   R	   R#   R   R  RC   t   position_viewport_sidet   renpy.sl2.slpropertiesR6  t   itemsRt   t    prefix_viewport_scrollbar_stylest
   setdefaultRi   Rz   t   minstoret   __t   scrollbar_child_sizet   VIEWPORT_SIZER   R)   R*   R&  t   yadjustmentR+   R8   R%  t   xadjustment(   t   vpfunct   _spacing_to_sidet
   scrollbarsR   t   vscrollbar_propertiest   scrollbar_propertiest   side_propertiest   viewport_propertiest   core_propertiesR6  t   kt   vR   RQ   t   addable(    (    s   renpy/ui.pyt   viewport_commonF  sf    
000c          K  s   t  t t |   S(   N(   RQ  t	   _viewportR   (   R   (    (    s   renpy/ui.pyR0    s    c          K  s   t  t t |   S(   N(   RQ  t   _vpgridR   (   R   (    (    s   renpy/ui.pyR1    s    t   Imagemapc           B  s,   e  Z d  Z e Z e Z d   Z d   Z RS(   sB   
    Stores information about the images used by an imagemap.
    c	   	      C  s   t  j j |  |  _ t  j j |  |  _ t  j j |  |  _ t  j j |  |  _ t  j j |  |  _ t  j j |  |  _ | |  _	 | |  _
 t  j j j |  |  _ d  S(   N(   R#   R   R.   R   R   R   R   R   R   t   alphat   cache_paramR   R/   t   ImageMapCacheR1   (	   R   R   R   R   R   R   R   RU  R1   (    (    s   renpy/ui.pyR!     s    		c         C  s   t  j j j |  j  |  _ d  S(   N(   R#   R   R/   RW  RV  R1   (   R   (    (    s   renpy/ui.pyt   reuse  s    (   R   R   R   R   RU  RV  R!   RX  (    (    (    s   renpy/ui.pyRT    s
   	c      
     s]    f d   } | |  d |  }  | | d |   } | | d |  } | | d |   } | | d |  } | | d |   } | | d |  } t  j t | | | | | | | |	   | j d	 t  t j j j d
 d |  } g  } |  r| j	 t j
 j |    | j |   n  t j j j d
 d  } | j	 |  | j |  | | _ | | _ | S(   Nc           sq   |  r
 |  S  rI x6 | D]+ } t  j j   |  } | d  k	 r | Sq Wn  | d  k	 rY | St d | d   d  S(   Ns'   Could not find a %s image for imagemap.i    (   R#   RC   R   R	   R   (   t   variableR    R   R<   t   fn(   R   (    s   renpy/ui.pyt   pick  s    R   R   R   R   R   R   R   t	   fit_firstR   R;   (   s   grounds   idle(   s   idle(   s   selected_idle(   s   hover(   s   selected_hover(   s   insensitive(   s   selected_insensitive(   R0   R8   RT  R?  R   R#   R   R   t   MultiBoxR'   R   R.   R   R  (   R   R   R   R   R   R   R   R   RU  R1   Re   R   R[  RQ   t   partst   box(    (   R   s   renpy/ui.pyt	   _imagemap  s<    
		c         K  s  t  s t d   n  t  d } |  \ } } } } | j } | j }	 | j }
 | j } | j } | j } | j j	 | |   } | j j	 |	 |   }	 | j j	 |
 |   }
 | j j	 | |   } | j j	 | |   } | j j	 | |   } | j
 d |  | j
 d d  | j
 d |  | j
 d d  | j
 d |  | j
 d	 |  | j
 d
 |  | j
 d |  | j rwt } n d  } | j
 d |  t j j j d  d | d |
 d |	 d | d | d | d | | S(   Ns*   hotspot expects an imagemap to be defined.iR   R   i    R   R   t   xminimumR   t   yminimumR   R   t   idle_backgroundt   selected_idle_backgroundt   hover_backgroundt   selected_hover_backgroundt   insensitive_backgroundt   selected_insensitive_backgroundRe   (   R0   R   R   R   R   R   R   R   R1   t   cropR?  RU  R   R	   R#   R   R   R  (   t   spotRe   R   R/   t   xt   yR]   t   hR   R   R   R   R   R   R   (    (    s   renpy/ui.pyt   _hotspot  sL    
								c          O  s   t  |  |   t   d  S(   N(   t   hotspot_with_childt   null(   R   RO   (    (    s   renpy/ui.pyR   :  s    c          K  s  | d  k r3 | d  k r3 | d  k r3 t d   n  t sH t d   n  t d } |  \ } } } }	 | j d |  | j d |  | j d d  | j d d  | j j | j |   }
 | j j | j |   } | j j | j |   } | j j | j	 |   } |	 | k rM| j d	 t
  | j d
 t
  | |
 }
 } | | } } n  t j j j d | d | d | d |
 d | d | d | d d d d d t d d  d d  d d d | d |	 |  S(   Ns:   hotbar requires either an adjustment or a range and value.s)   hotbar expects an imagemap to be defined.iR   R   R   i    R   t   bar_verticalt
   bar_invertR:  R!  R   t   fore_bart   aft_bart   hover_fore_bart   hover_aft_bart   fore_guttert
   aft_guttert   bar_resizingt   thumbt   thumb_shadowt   thumb_offsetR   R   (   R	   R   R0   R?  R1   Ri  R   R   R   R   R   R#   R   R   R   R   (   Rj  R:  R!  R   R   R/   Rk  Rl  R]   Rm  Rs  Rt  Ru  Rv  (    (    s   renpy/ui.pyt   _hotbar?  sH    $
t   hotbarc         C  s   |  S(   N(    (   RO  (    (    s   renpy/ui.pyt   _returnsu  s    c         C  sY   t  | t  r$ t t j |  } n  | d  k	 rC t j j |  n  t j j |    d  S(   N(	   R_   R   R   R#   RC   R	   RL   t
   transitionR   (   R   R  (    (    s   renpy/ui.pyt   _jumps}  s
    c         C  s   t  j j |    d  S(   N(   R#   R$   t   JumpOutException(   R   (    (    s   renpy/ui.pyt   _jumpsoutofcontext  s    c          O  s   t  j j |  |   S(   N(   R#   RL   t   curried_call_in_new_context(   R   RO   (    (    s   renpy/ui.pyt   callsinnewcontext  s    c          O  s   t  j j |  |   S(   N(   R#   RL   t   curried_invoke_in_new_context(   R   RO   (    (    s   renpy/ui.pyt   invokesinnewcontext  s    c          G  s(   |  r t  d d |  d St  d  Sd  S(   Nt
   _game_menut   _game_menu_screeni    (   R  (   R   (    (    s   renpy/ui.pyt	   gamemenus  s    c         C  s,   t  d k r t d   n  | t  j |  <d S(   s   
    :doc: ui

    Assigns the displayable `d` the screen widget id `id_`, as if it had
    been created by a screen statement with that id.
    s1   ui.screen_id must be called from within a screen.N(   Ru   R	   R   R   (   t   id_R(   (    (    s   renpy/ui.pyt	   screen_id  s    (   NN(   t
   __future__R    R|   t   renpy.displayR#   t
   renpy.textt   renpy.display.behaviorR   R   t   objectt   ObjectR   R   R   R   R-   R3   R4   R6   R)   R>   R	   RR   R0   R?   R$   t	   post_initR8   RJ   RS   RT   RU   RW   RY   RZ   R[   RV   R+   R^   Ra   Rb   t   SentinelRc   Rh   Ri   Ru   Rj   R   R'   R   R:   R   R   R   R   t   NullRp  R   R  R   R]  R   R   R;   t   default_fixedt   GridR   t   SideR   R   t   sizerR  R   R   R   R   t   keymapt   SayBehaviort   saybehaviort   PauseBehaviort   pausebehaviort   SoundStopBehaviort   soundstopbehaviorR   R"   R   R   R   R   R   t   InputR   R   R  R   R	  R   R  R   R  R   t
   AdjustmentR:  R"  R   R   R#  R$  R%  R&  R,  t   curryR.  R/  t   autobarR   R   RX   R0  t   ViewportRR  t   VPGridRS  RC  RQ  R1  t   Conditionalt   conditionalt   Timert   timert   dragdropt   Dragt   dragt	   DragGroupt	   draggroupt	   MouseAreat	   mouseareaRT  R`  R/   Rn  Ro  R   R}  R~  R  t   returnsR  t   jumpsR  t   jumpsoutofcontextR  R  R  t   OnEventt   onR  RN  RO  t   globalst	   iteritemsR_   R    (    (    (    s   renpy/ui.pyt   <module>   s"   	
6													
				
!'''!!!''2,6''&!*	)		!''Y		!!*73	0						