a
    F^i                     @   s   d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlZd dlZdadd Zdd Zd	d
 Zdd Zdd Zdd ZdS )    )divisionabsolute_importwith_statementprint_functionunicode_literals)PY2
basestringbchrbordchropenpystrrangeroundstrtobytesunicodeNFc                 K   sz   t jj}zbt jjt j_t jjD ]}t j j	| qt jj
| fddi| t jjdddddW |t j_S |t j_0 d S )N
_transientTscreen)mousetypesuppress_overlaysuppress_underlay)renpyconfigquit_actionexportsquitlayersgamecontextscene_listsclearshow_screenuiinteract)screen_namekwargsZold_quiti r)   WC:\Program Files (x86)\Steam\steamapps\common\Selene ~Apoptosis~\renpy\display\error.pycall_exception_screen&   s    r+   c                   C   s   t jjdd d S )NT)force)r   r   rollbackr)   r)   r)   r*   rollback_action6   s    r.   c                   C   s~   t tjjddtj_tjj  tjjdur6tj  tjj	sdtj
j  tj  tj
jj  ntjj	  tj  dS )zB
    The minimum amount of code required to init the display.
    _gl2FN)getattrr   r   
persistentr   gl2preferencescheckinit_system_styles	interfacedisplaycore	Interfaceloaderindex_archivesimcacheinitstartr$   resetr)   r)   r)   r*   init_display:   s    

rA   c                   C   s   t jd dS )z:
    Handles dumps in the case where an error occurs.
    TN)r   dumpr)   r)   r)   r*   
error_dumpQ   s    rC   c              
   C   s  da t  tjjjdkrdS dtjv r*dS tj	ds:dS z
t
  W n tyX   Y dS 0 tjjdu rjdS d}d}d}zVtj jstjjrtjjj}tjd}ntjj}tjdjdurtjd}W n ty   Y n0 zXtjjtd| |||||d	 tjj jtjjjO  _tjjdur6tjj !tjj W nH tjj"yR    Y n0 ty   tjj#$d
 tjj#%   Y n0 dS )z
    Reports an exception to the user. Returns True if the exception should
    be raised by the normal reporting mechanisms. Otherwise, should raise
    the appropriate exception to cause a reload or quit or rollback.
    TrunRENPY_SIMPLE_EXCEPTIONSZ
_exceptionNZ_save_reload_gameF)shortfullr.   reload_actionignore_actiontraceback_fnWhile handling exception:)&error_handledrC   r   r   argscommandosenvironr   
has_screenrA   	Exceptionr7   drawr    
init_phaser   rollback_enablederrorr.   Zcurried_call_in_new_contextutter_restart	next_noder$   returnsinvoke_in_new_contextr+   r<   ignored_imagesimages_to_ignorestoreZ_ignore_actionbehaviorrD   CONTROL_EXCEPTIONSlogwrite	exception)rG   rH   rK   rJ   r.   rI   r)   r)   r*   report_exceptionY   s\    



rd   c                 C   s   da t  tjjjdkrdS dtjv r*dS tj	ds:dS tj
jdu rJdS t  tjj}ztjjtd|| |d W nD tjjy    Y n. ty   tjjd tjj   Y n0 dS )z
    Reports an exception to the user. Returns True if the exception should
    be raised by the normal reporting mechanisms. Otherwise, should raise
    the appropriate exception.
    TrD   rE   Z_parse_errorsN)rI   errorserror_fnrL   )rM   rC   r   r   rN   rO   rP   rQ   r   rR   r   savedirrA   rX   r[   r+   r`   rS   r7   ra   rb   rc   )re   rf   rI   r)   r)   r*   report_parse_errors   s4    

rh   )
__future__r   r   r   r   r   renpy.compatr   r   r	   r
   r   r   r   r   r   r   r   r   rP   r   rM   r+   r.   rA   rC   rd   rh   r)   r)   r)   r*   <module>   s   8K