ó
Ä‚Œ\c           @  sS   d  d l  m Z d  d l Z d  d l Z d  d l Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿ(   t   print_functionNc           s†   ‡  f d †  } g  } xN t  j j j D]= } | | ƒ } | d k	 r% | j t | ƒ | | f ƒ q% q% W| sp d S| j ƒ  | d d S(   s/  
    Trues to find the focus with the shortest alt text containing `pattern`.
    If found, returns a random coordinate within that displayable.

    If `pattern` is None, returns a random coordinate that will trigger the
    default focus.

    If `pattern` could not be found, returns None, None.
    c           s€   ˆ  d  k r& |  j d  k r d Sd  Sn  |  j d  k rM t j j j j ƒ  } n |  j j ƒ  } ˆ  j ƒ  | j ƒ  k rx | Sd  Sd  S(   Nt   default(	   t   Nonet   xt   renpyt   displayt   ttst   roott   _tts_allt   widgett   lower(   t   ft   t(   t   pattern(    sm   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\test\testfocus.pyt   match'   s    i    i   N(   R   R   t   focust
   focus_listR   t   appendt   lent   sort(   R   R   t   matchingR   t   alt(    (   R   sm   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\test\testfocus.pyt
   find_focus   s    #
c         C  sE   | d  k	 r; t | t ƒ r2 t | | d ƒ }  q; | }  n  t |  ƒ S(   Ni   (   R   t
   isinstancet   floatt   int(   R   t   posxt   width(    (    sm   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\test\testfocus.pyt   relative_positionL   s
    	c   	      C  s  | \ } } t  j j j d k	 r9 t  j j j \ } } n* t j t  j j ƒ } t j t  j j	 ƒ } |  d k r t
 | | t  j j ƒ t
 | | t  j j	 ƒ f S|  } |  j d k rñ |  j ƒ  }  d |  _ d |  _ t  j j |  _ t  j j	 |  _ n  t
 | | |  j ƒ |  j } t
 | | |  j ƒ |  j } xë t d ƒ D]Ê } t | ƒ } t | ƒ } t  j j j | | ƒ } | d k r”| j d k rÂ| | f Sn. | j |  j k rÂ| j |  j k rÂ| | f St j |  j |  j |  j ƒ } t j |  j |  j |  j ƒ } q6Wt ƒ  t d ƒ ‚ d S(   s  
    Returns the virtual position of a coordinate located within focus `f`.
    If position is (None, None) returns the current mouse position (if in
    the focus), or a random position.

    If `f` is None, returns a position relative to the screen as a whole.
    i    id   s!   Could not locate the displayable.N(   R   t   testt	   testmouset	   mouse_posR   t   randomt	   randranget   configt   screen_widtht   screen_heightR   R   t   copyt   yt   wt   ht   rangeR   R   t   rendert   focus_at_pointR	   t   argt   printt	   Exception(	   R   t   positionR   t   posyR   R&   t   orig_ft   _it   nf(    (    sm   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\test\testfocus.pyt   find_positionV   s<    			$
#(	   t
   __future__R    t
   renpy.testR   t   renpy.displayR    R   R   R4   (    (    (    sm   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\test\testfocus.pyt   <module>   s   	0	
