³ò
GØNc           @   sª  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k	 Z	 d  d k
 Z
 d  d k Z d „  Z d „  Z e i Z d e f d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e e i e d d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e i ƒ  Z e i  ƒ  d a! d „  Z" d „  Z# e d „ Z$ d e% f d „  ƒ  YZ& d „  Z' d S(   iÿÿÿÿNc         C   sA   t  i i o t i |  | t i ƒ n t i |  | t i ƒ d  S(   N(   t   renpyt   configt   use_cpicklet   cPicklet   dumpt   HIGHEST_PROTOCOLt   pickle(   t   ot   f(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   *   s    c         C   s/   t  i i o t i |  ƒ Sn t i |  ƒ Sd  S(   N(   R    R   R   R   t   loadsR   (   t   s(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR	   0   s    t   IdleFilec           B   s   e  Z d  „  Z RS(   c         C   s#   t  i i i i ƒ  t i |  | ƒ S(   N(   R    t   displayt   coret   cpu_idlet   waitt   filet   write(   t   selfR
   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   p   s    (   t   __name__t
   __module__R   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   n   s   t   IdleStringIOc           B   s   e  Z d  „  Z RS(   c         C   s&   t  i i i i ƒ  t i i |  | ƒ S(   N(   R    R   R   R   R   t   StringIOR   (   R   R
   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   w   s    (   R   R   R   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   u   s   t	   SaveAbortc           B   s   e  Z RS(    (   R   R   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR   }   s   t    c   
      C   sp  |  t  }  |  t i _ t i i i d ƒ o t i i d ƒ n y t i	 t i
 i d |  ƒ Wn n X| o t t i _ n t i i i | ƒ } | ƒ  } t | t i i f | ƒ | o t i i o t ƒ  ‚ n | t i
 i d |  d ƒ } t i | d t i ƒ }	 |	 i d t i i i ƒ  ƒ |	 i d | i d ƒ ƒ |	 i d | i ƒ  ƒ |	 i ƒ  | i ƒ  d	 S(
   s  
    Saves the game in the given filename. This will save the game
    along with a screnshot and the given extra_info, which is just
    serialized.

    It's expected that a screenshot will be taken (with
    renpy.take_screenshot) before this is called.
    t   before_savet   /t   wbt   ws   screenshot.pngt
   extra_infos   utf-8t   logN(   t   savegame_suffixR    t   storet   temp_filenamet   gamet   scriptt	   has_labelt   call_in_new_contextt   ost   unlinkR   t   savedirt   Falset   pythont   mutate_flagR   t   freezeR   R   t   zipfilet   ZipFilet   ZIP_DEFLATEDt   writestrt	   interfacet   get_screenshott   encodet   getvaluet   close(
   t   filenameR   R   R   R+   R   t   rootst   logft   rft   zf(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   save€   s,    
	
c      
   C   s   y|  t  } t i t i i d | d ƒ } y t } | i d ƒ Wn t } | i d ƒ n X| i	 d ƒ i
 d ƒ } | i ƒ  t i i t i i d | ƒ } | o- t i i i t i i d | d | ƒ } n* t i i i t i i d | d | ƒ } | | | f SWn d  Sn Xd  S(   NR   t   rs   screenshot.tgas   screenshot.pngR   s   utf-8(   R   R-   R.   R    R   R(   R)   t   getinfot   Truet   readt   decodeR5   R&   t   patht   getmtimeR   t   imt   ZipFileImaget   None(   t   nameR   R:   t   pngR   t   mtimet
   screenshot(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   scan_saved_game¶   s$    
 
 -)t   .c   
      C   sä   y t  i t i i ƒ } Wn g  Sn X| i ƒ  g  } | D]? } | i t ƒ o) t i	 |  | ƒ o | | t
 t ƒ  q< q< ~ } g  } xS | D]K } t | ƒ } | d j	 o, | \ } } }	 | i | | | |	 f ƒ q‘ q‘ W| S(   sÞ  
    This scans the savegames that we know about and returns
    information about them. It returns a list of tuples, where each
    tuple represents one savegame and consists of:
    
    - The filename of the save.
    - The extra_info that was passed to renpy.save.
    - A displayable, the screenshot used to show the game.
    - The time the game was saved at, seconds since 1/1/1970 UTC.
    
    The regexp matches at the start of the filename, and filters the list.
    N(   R&   t   listdirR    R   R(   t   sortt   endswithR   t   ret   matcht   lenRJ   RE   t   append(
   t   regexpt   filest   _[1]t   it   rvR   t   infoR   RI   RH   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   list_saved_gamesÖ   s     

B !c         C   sH   y6 t  i t i i d |  t d ƒ } | i ƒ  t SWn t Sn Xd S(   sO   
    Returns true if we can load the given savegame file, False otherwise.
    R   R<   N(	   R-   R.   R    R   R(   R   R5   R>   R)   (   R6   R:   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   can_loadú   s    $
c         C   s`   t  i t i i d |  t d ƒ } t | i d ƒ ƒ \ } } | i ƒ  | i	 | d d ƒd S(   sJ   
    Loads the game from the given file. This function never returns.
    R   R<   R   t   labelt   _after_loadN(
   R-   R.   R    R   R(   R   R	   R?   R5   t   unfreeze(   R6   R:   R7   R   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   load  s    $
c         C   sB   t  | ƒ t i t i i d |  t t i i d | t ƒ d  S(   NR   (   t   unlink_saveR&   t   renameR    R   R(   R   (   t   oldt   new(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   rename_save  s    
c         C   sL   t  i i t i i d |  t ƒ o# t  i t i i d |  t ƒ n d  S(   NR   (   R&   RA   t   existsR    R   R(   R   R'   (   R6   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR_     s    %c      	   C   sœ   xO t  d | d ƒ D]: } t i i t i i d |  t | ƒ t ƒ p Pq q WxC t  | d d d ƒ D]+ } t	 |  t | ƒ |  t | d ƒ ƒ qi Wd  S(   Ni   R   i    iÿÿÿÿ(
   t   rangeR&   RA   Rd   R    R   R(   t   strR   Rc   (   RF   t   countRV   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   cycle_saves  s     /	 i    c         C   sá   t  i i i i ƒ  t d t  i i ƒ t  i i i i ƒ  t  i i o t  i i ƒ  } n d } zp yV |  o t  i	 i
 ƒ  n t d d t d t d t d t  i i i i d | ƒd	 a Wn t j
 o n XWd  t i ƒ  Xd  S(
   Ns   auto-R   s   auto-1R   R   R+   R   R   i    (   R    R   R   R   R   Rh   R   t   autosave_slotst   auto_save_extra_infot   exportst   take_screenshotR;   R   R   R>   t   autosave_counterR   t   autosave_not_runningt   set(   Rl   R   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   autosave_thread.  s    4
	c           C   s“   t  i i p d  Sn t i ƒ  p d  Sn t  i i o d  Sn t t  i i ƒ d j o d  Sn t	 d 7a	 t	 t  i i j  o d  Sn t
 t ƒ d  S(   Ni   (   R    R   t   autosave_frequencyRn   t   isSett   skippingRQ   R"   t   contextsRm   t   force_autosaveR>   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   autosaveJ  s    
c         C   sB   t  i ƒ  p d  Sn t  i ƒ  t i d t d |  f ƒ i ƒ  d  S(   Nt   targett   args(   Rn   Rr   t   cleart	   threadingt   ThreadRp   t   start(   Rl   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyRu   b  s    
t   _MultiPersistentc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s   |  i  i ƒ  } | d =| S(   Nt	   _filename(   t   __dict__t   copy(   R   t   state(    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   __getstate__n  s    c         C   s   |  i  i | ƒ d  S(   N(   R   t   update(   R   R   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   __setstate__s  s    c         C   s1   | i  d ƒ o | i d ƒ o t ƒ  ‚ n d  S(   Nt   __(   t
   startswithRN   t   AttributeErrorRE   (   R   RF   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   __getattr__v  s     c         C   sz   |  i  } t | d d ƒ } t |  | ƒ | i ƒ  y t i | d | ƒ Wn( t i | ƒ t i | d | ƒ n Xd  S(   Ns   .newR   (   R~   R   R   R5   R&   R`   R'   (   R   t   fnR   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR;   }  s    	
(   R   R   R‚   R„   Rˆ   R;   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyR}   l  s   			c         C   sX  t  i i p t d ƒ ‚ n t i d j oE t i i d ƒ g } d t i	 j o | i
 t i	 d d ƒ qÀ nO t i ƒ  d o( t i i d ƒ t i i d ƒ g } n t i i d ƒ g } y t i | d	 ƒ Wn n Xd
 } x4 | D], } | d |  } t i i | ƒ o Pqì qì Wy t t | ƒ i ƒ  ƒ } Wn t ƒ  } n X| | _ | S(   Ns>   MultiPersistent objects must be created during the init phase.t   win32s   ~/RenPy/Persistentt   APPDATAs   /RenPy/persistenti    s   ~/.renpy/persistents   ~/Library/RenPy/persistentiÿÿÿÿR   R   (   R    R"   t
   init_phaset	   Exceptiont   syst   platformR&   RA   t
   expandusert   environRR   t   mac_vert   makedirsRd   R	   R   R?   R}   R~   (   RF   RT   R‰   RW   (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pyt   MultiPersistentŠ  s4      		((   R   R   R   t	   cStringIOR-   R&   t   os.pathRO   Rz   RŽ   R   R    R   R	   R   R   R   R   R   R   R)   RE   R;   RJ   RY   RZ   R^   Rc   R_   Rh   t   EventRn   Ro   Rm   Rp   Rv   Ru   t   objectR}   R”   (    (    (    s6   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\loadsave.pys   <module>   sF   			6	4	 $					
		
