ó
Ä‚Œ\c           @  s  d  d l  m Z d  d l Z d  d l Z d  d l Z e Z e a	 d d f a
 e Z e Z e e d „ Z e d d „ Z e Z e Z i  Z e j e ƒ Z i  Z e a	 e ƒ  Z d „  Z d	 „  Z e e d
 „ Z d „  Z d „  Z d e j j j  f d „  ƒ  YZ! d „  Z" d „  Z# d „  Z$ d S(   iÿÿÿÿ(   t   print_functionNi  i,  c         C  s+   t  r | r d St j j j d d ƒ d S(   s,   
    Stops the currently playing movie.
    Nt   channelt   movie(   t
   fullscreent   renpyt   audiot   musict   stop(   t   cleart   only_fullscreen(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt
   movie_stop-   s    i    c         C  sz   t  j j r d S| d k	 r% | a n  |  g }  | d k rC t } n t } |  | d }  t  j j j	 |  d d d | ƒd S(   s&   
    This starts a movie playing.
    Niÿÿÿÿi   R   R   t   loop(
   R   t   gamet   less_updatest   Nonet   default_sizet   Truet   FalseR   R   t   play(   t   filenamet   sizet   loopsR   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   movie_start8   s    			c           C  s   t  j ƒ  t j ƒ  d S(   sU   
    Called early in the interact process, to clear out the fullscreen
    flag.
    N(   t   displayable_channelsR   t   channel_movie(    (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   early_interactg   s    
c          C  s•   x9 t  t j ƒ  ƒ D]% }  t j j j |  ƒ s t |  =q q Wt j j j d ƒ r‹ x= t j ƒ  D]  }  |  d d k r^ t a	 Pq^ q^ Wt
 a	 n t a	 t	 S(   sz   
    This is called each time the screen is drawn, and should return True
    if the movie should display fullscreen.
    R   i    (   t   listt   texturet   keysR   R   R   t   get_playingR   R   R   R   (   t   i(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   interactq   s    	c         C  sŒ  t  j j j |  ƒ s d  t f St  j j j |  ƒ } | j ƒ  } | r° | d  k	 r§ | j ƒ  \ } } | d } | j	 | d | | f ƒ } | j	 d d | | f ƒ } qà d  } n0 | rÚ t  j j j | ƒ } | j ƒ  } n d  } | d  k	 r | rt  j
 j j | | t  j
 j j ƒ q d  } n  | d  k	 rjt  j
 j j | ƒ t  j
 j j | t ƒ }	 |	 t |  <t }
 n t j |  d  ƒ }	 t }
 |	 |
 f S(   Ni   i    (   R   R   R   R   R   R   t   get_channelt
   read_videot   get_sizet
   subsurfacet   displayt   modulet   alpha_munget   imt   identityt   rendert   mutated_surfacet   drawt   load_textureR   R   t   get(   R   t   mask_channelt	   side_maskt   ct   surft   wt   ht	   mask_surft   mct   text   new(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   get_movie_textureŒ   s6    

	%	
	c         C  sÿ   t  |  ƒ \ } } | d  k r" d  S| j ƒ  \ } } t d | | d | | ƒ } | | } | | }	 t j j j | | ƒ }
 t j j j d | d d d | ƒ |
 _	 t j j j | d d | ƒ |
 _
 |
 j | t | | d ƒ t | |	 d ƒ f ƒ |
 S(   Ng      ð?g        i   (   R8   R   R"   t   minR   R$   R)   t   Rendert   Matrix2Dt   forwardt   reverset   blitt   int(   R   t   widtht   heightR6   t   _newt   swt   sht   scalet   dwt   dht   rv(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   render_movie»   s    

)!2c         C  sl   t  j j j | j d | j d | j d t ƒ| j rh t  j j j | j d | j	 d | j d t ƒn  d  S(   NR   R   t   synchro_start(
   R   R   R   R   t   _playR   R   R   t   maskR.   (   t   oldR7   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   default_play_callbackÐ   s    .	t   Moviec           B  sª   e  Z d  Z e Z d Z d
 Z d
 Z d
 Z	 e Z
 d
 Z d
 Z d
 Z e Z d „  Z d d
 d d
 d
 d
 d
 d
 e e d
 d „ Z d „  Z d „  Z d „  Z d „  Z d	 „  Z RS(   s8  
    :doc: movie

    This is a displayable that shows the current movie.

    `fps`
        The framerate that the movie should be shown at. (This is currently
        ignored, but the parameter is kept for backwards compatibility.
        The framerate is auto-detected.)

    `size`
        This should be specified as either a tuple giving the width and
        height of the movie, or None to automatically adjust to the size
        of the playing movie. (If None, the displayable will be (0, 0)
        when the movie is not playing.)

    `channel`
        The audio channel associated with this movie. When a movie file
        is played on that channel, it will be displayed in this Movie
        displayable. If this is not given, and the `play` is provided,
        a channel name is automatically selected.

    `play`
        If given, this should be the path to a movie file. The movie
        file will be automatically played on `channel` when the Movie is
        shown, and automatically stopped when the movie is hidden.

    `side_mask`
        If true, this tells Ren'Py to use the side-by-side mask mode for
        the Movie. In this case, the movie is divided in half. The left
        half is used for color information, while the right half is used
        for alpha information. The width of the displayable is half the
        width of the movie file.

        Where possible, `side_mask` should be used over `mask` as it has
        no chance of frames going out of sync.

    `mask`
        If given, this should be the path to a movie file that is used as
        the alpha channel of this displayable. The movie file will be
        automatically played on `movie_channel` when the Movie is shown,
        and automatically stopped when the movie is hidden.

    `mask_channel`
        The channel the alpha mask video is played on. If not given,
        defaults to `channel`\ _mask. (For example, if `channel` is "sprite",
        `mask_channel` defaults to "sprite_mask".)

    `start_image`
        An image that is displayed when playback has started, but the
        first frame has not yet been decoded.

    `image`
        An image that is displayed when `play` has been given, but the
        file it refers to does not exist. (For example, this can be used
        to create a slimmed-down mobile version that does not use movie
        sprites.) Users can also choose to fall back to this image as a
        preference if video is too taxing for their system. The image will
        also be used if the video plays, and then the movie ends.

    ``play_callback``
        If not None, a function that's used to start the movies playing.
        (This may do things like queue a transition between sprites, if
        desired.) It's called with the following arguments:

        `old`
            The old Movie object, or None if the movie is not playing.
        `new`
            The new Movie object.

        A movie object has the `play` parameter available as ``_play``,
        while the ``channel``, ``loop``, ``mask``, and ``mask_channel`` fields
        correspond to the given parameters.

        Generally, this will want to use :func:`renpy.music.play` to start
        the movie playing on the given channel, with synchro_start=True.
        A minimal implementation is::

            def play_callback(old, new):

                renpy.music.play(new._play, channel=new.channel, loop=new.loop, synchro_start=True)

                if new.mask:
                    renpy.music.play(new.mask, channel=new.mask_channel, loop=new.loop, synchro_start=True)

        `loop`
            If False, the movie will not loop. If `image` is defined, the image
            will be displayed when the movie ends. Otherwise, the movie will
            become transparent.



    This displayable will be transparent when the movie is not playing.
    R   c         C  sy   | d  k r d  St j j j | ƒ r) d  S|  j r; t } n t } t j j j | t j	 j
 d t d t d t d | ƒd  S(   NR   t   stop_on_muteR   t	   framedrop(   R   R   R   R   t   channel_definedRL   R   R   t   register_channelt   configt   movie_mixer(   t   selft   nameRQ   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   ensure_channelG  s    		i   c         K  sU  t  t |  ƒ j |   | d k rI | rI t j j rI d j | | ƒ } n  | |  _ | |  _ | |  _	 |
 |  _
 |	 r| d  } n  | |  _ | d  k r d  |  _ n% | d  k r¹ | d |  _ n	 | |  _ |	 |  _ |  j |  j ƒ |  j |  j ƒ t j j | ƒ |  _ t j j | ƒ |  _ | |  _ |  j d k rQt j j rQt j rQt d ƒ ‚ n  d  S(   NR   s   movie_{}_{}t   _maskso   Movie(channel='movie') doesn't work on mobile when config.hw_video is true. (Use a different channel argument.)(   t   superRO   t   __init__R   RT   t   auto_movie_channelt   formatR   R   RK   R   R   RL   R.   R/   RX   t   easyt   displayable_or_nonet   imaget   start_imaget   play_callbackt   hw_videot   mobilet	   Exception(   RV   t   fpsR   R   R   RL   R.   R`   Rb   R/   R   Ra   t
   properties(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyR[   V  s.    									$c         C  s  |  j  rM t j j j t k	 rM |  t |  j <| d k rM t j	 |  j ƒ qM n  t j
 j j |  j ƒ } | } |  j t k r„ t } n  |  j d  k	 rû | rû t j j j |  j | | | | ƒ } | j ƒ  \ } }	 t j j j | |	 ƒ }
 |
 j | d ƒ |
 S|  j d  k rt |  j |  j |  j ƒ \ } } | r{| d  k	 r{| j ƒ  \ } } t j j j | | ƒ }
 |
 j | d ƒ qg| rò|  j d  k	 ròt j j j |  j | | | | ƒ } | j ƒ  \ } }	 t j j j | |	 ƒ }
 |
 j | d ƒ qgt j j j d d ƒ }
 nZ |  j \ } }	 | s+d  }
 n t |  j | |	 ƒ }
 |
 d  k rgt j j j | |	 ƒ }
 n  t j j j |  d ƒ |
 S(   Ni    gš™™™™™¹?(   i    i    (   i    i    (   i    i    (   RK   R   R   t   preferencest   video_image_fallbackR   R   R   t   reset_channelst   addR   R   R   R   R`   R   R$   R)   R"   R:   R>   R   R8   R.   R/   Ra   RI   t   redraw(   RV   R@   RA   t   stt   att   playingt   not_playingR1   R2   R3   RH   R6   t   _(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyR)   |  sD    	$!$	c         C  s¹   | d  k r d  } n	 | j } |  j | k s9 t j j rµ |  j rt |  j d  k	 rd |  j | |  ƒ q² t | |  ƒ qµ t j j j	 d |  j
 ƒ |  j rµ t j j j	 d |  j ƒ qµ n  d  S(   NR   (   R   RK   R   RT   t   replay_movie_spritesRb   RN   R   R   R   R   RL   R.   (   RV   RM   t   old_play(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyR   ¹  s    				c         C  sN   |  j  rJ t j j j d |  j ƒ |  j rJ t j j j d |  j ƒ qJ n  d  S(   NR   (   RK   R   R   R   R   R   RL   R.   (   RV   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyR   Í  s    		c         C  s7   t  |  j |  j f j |  ƒ t j j j |  d ƒ d  S(   Ni    (   R   R   R.   t   appendR   R$   R)   Rl   (   RV   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   per_interactÔ  s    c         C  s   |  j  |  j g S(   N(   R`   Ra   (   RV   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   visitØ  s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   RK   RL   R.   R/   R`   Ra   Rb   R   R   RX   R[   R)   R   R   Ru   Rv   (    (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyRO   Ø   s$   ^	*&	=			c          C  sS   t  j j j d ƒ r t Sx3 t D]+ }  |  \ } } t  j j j | ƒ r  t Sq  Wd  S(   NR   (   R   R   R   R   R   R   (   R   R   t   _mask_channel(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyRo   Ü  s    c          C  sá   t  j j ƒ  j }  xp t j ƒ  D]b \ } } |  j | d ƒ } | t k re t  j	 j
 re | j | ƒ q | | k	 r | j | ƒ q q Wx3 |  j ƒ  D]% \ } } | t k r’ | j ƒ  q’ q’ Wt t ƒ t  j j ƒ  _ t j ƒ  d S(   s0   
    Calls play/stop on Movie displayables.
    N(   R   R   t   contextR   R   t   itemsR-   R   Rj   RT   Rr   R   R   t   dictR   (   t   old_channel_movieR0   t   mRM   (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   update_playingé  s    c          C  s?  t  ƒ  t j j j ƒ  t rê t }  xy t D]q } | \ } } t j j j | ƒ } | j ƒ  sg t }  Pn  | r* t j j j | ƒ } | j ƒ  s› t }  Pq› q* q* W|  ræ x> t j	 ƒ  D]- } x$ | D] } t j
 j j | d ƒ q¿ Wq² Wn  t St r;t j st j ot j j r;t j j j d ƒ } | j ƒ  r4t St Sn  t S(   sn   
    Called to update the video playback. Returns true if a video refresh is
    needed, false otherwise.
    g        R   (   R€   R   R   t   advance_timeR   R   R    t   video_readyR   t   valuesR$   R)   Rl   R   t   androidt   iosRT   Rc   (   t   updateR   R   R.   R0   t   vt   j(    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   frequent  s4    !%(%   t
   __future__R    t   renpy.displayR   t   renpy.audiot   collectionsR   t   current_movieR   R   R   t   surface_filet   surfaceR   R
   R   t   movie_start_fullscreent   movie_start_displayableR   t   defaultdictR   R   R   t   setRj   R   R   R8   RI   RN   R$   t   coret   DisplayableRO   Ro   R€   R‰   (    (    (    sl   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\display\video.pyt   <module>   s6   		
	/		ÿ 		