Ë
    Î£jÆ  ã                   ó�   — d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZ d dlmZ  e j                  «       Z G d„ de«      Zy)	é    N)ÚPath)ÚQObjectÚ
pyqtSignal)ÚInstallOperationÚ
Sourcemods)ÚInstallService)Úvalidate_game_directoryc                   óŒ  ‡ — e Zd Z eee«      Z ee«      Z eee«      Z	 e«       Z
dˆ fd„	Zed„ «       Zej                  d„ «       Zdeddfd„Zded	efd
„Zej&                  fdedefd„Zddej&                  fdee   dedz  defd„Zej&                  fdedefd„Zdej&                  fdedz  defd„Zd„ Zddedz  fd„Zˆ xZS )ÚInstallControllerNc                 ój   •— t         ‰| �  «        || _        t        «       | _        d | _        d| _        y ©NF)ÚsuperÚ__init__Úsettingsr   ÚserviceÚtf_pathÚ
processing)Úselfr   Ú	__class__s     €úIC:\Users\pivot\Documents\cueki\casual-preloader\gui\install_controller.pyr   zInstallController.__init__   s-   ø€ Ü‰ÑÔØ ˆŒÜ%Ó'ˆŒØ$(ˆŒØˆ�ó    c                 ó.   — | j                   j                  S ©N)r   Úcancel_requested©r   s    r   r   z"InstallController.cancel_requested   s   € à�|‰|×,Ñ,Ð,r   c                 ó`   — |r| j                   j                  «        y d| j                   _        y r   )r   Úrequest_cancelr   )r   Úvalues     r   r   z"InstallController.cancel_requested   s!   € áØ�L‰L×'Ñ'Õ)à,1ˆD�L‰LÕ)r   ÚpathÚreturnc                 ó   — || _         y r   )r   )r   r   s     r   Úset_tf_pathzInstallController.set_tf_path&   s	   € Øˆ�r   ÚprogressÚmessagec                 ó<   — | j                   j                  ||«       y r   )Úprogress_updateÚemit)r   r#   r$   s      r   Ú_on_progresszInstallController._on_progress)   s   € Ø×Ñ×!Ñ! (¨GÕ4r   Úinstall_pathÚ	sourcemodc                 ó   — 	 d}d}d}d}| j                   rX| j                   j                  }| j                   j                  }| j                   j                  }| j                   j                  }d }	|r|j
                  }	| j                  j                  ||| j                  |	|||||¬«	       | j                  j                  dt        j                  «       | j                  dd«       d| _        | j&                  j                  «        y # t        $ rÄ}
dt        |
«      j                  «       v }|r| j                  dd«       n| j                  dd	«       	 | j                  j!                  ||¬
«       |s| j"                  j                  d|
›d�«       n8# t        $ r,}| j"                  j                  d|
›d|›d�«       Y d }~nd }~ww xY wY d }
~
Œêd }
~
ww xY w# d| _        | j&                  j                  «        w xY w)NFT)	r   Úselected_addonsÚon_progressÚapply_particle_selectionsÚdisable_paint_colorsÚshow_console_on_startupÚfix_mdl_pathsÚskip_quickprecacher*   zMods installed successfully!r   zInstallation completezcancelled by userz+Cancelling installation, restoring files...z*Installation failed, attempting cleanup...)r   r*   zInstallation failed: z,

Files have been restored to default state.z>Installation failed and cleanup also failed.

Original error: z
Cleanup error: z”

Please verify your game files through Steam:
Library > Right-click Team Fortress 2 > Properties > Installed Files > Verify integrity of game files)r   r/   r0   r1   r2   r.   r   Úinstallr(   Úoperation_successr'   r   ÚINSTALLÚ	ExceptionÚstrÚlowerÚ	uninstallÚoperation_errorr   Úoperation_finished)r   r)   r,   Úmod_drop_zoner*   r/   Úshow_consoler1   r2   Úapply_particlesÚeÚwas_cancelledÚcleanup_errors                r   Ú_run_installzInstallController._run_install,   sè  € ð2	+Ø#(Ð ØˆLØ ˆMØ!&ÐØ�}Š}Ø'+§}¡}×'IÑ'IÐ$Ø#Ÿ}™}×DÑD�Ø $§¡× ;Ñ ;�Ø%)§]¡]×%EÑ%EÐ"à"ˆOÙØ"/×"IÑ"I�à�L‰L× Ñ Ø$Ø /Ø ×-Ñ-Ø*9Ø%9Ø(4Ø+Ø#5Ø#ð !ô 
ð ×"Ñ"×'Ñ'Ð(FÔHX×H`ÑH`ÔaØ×Ñ˜aÐ!8Ô9ð, $ˆDŒOØ×#Ñ#×(Ñ(Õ*øô+ ò 	Ø/´3°q³6·<±<³>ÐAˆMÙØ×!Ñ! !Ð%RÕSà×!Ñ! !Ð%QÔRðØ—‘×&Ñ&¨|ÀyÐ&ÔQÙ$Ø×(Ñ(×-Ñ-Ð0EÀaÀUÐJxÐ.yÔzùÜò Ø×$Ñ$×)Ñ)ð'Ø'( eð ,&Ø&3Ð%6ð 7|ð}÷ñ ûðÿûð	ûð( $ˆDŒOØ×#Ñ#×(Ñ(Õ*úsU   ‚C&D
 Ä
	GÄAGÅ>FÆGÆ	G
Æ"GÇ GÇG
Ç
GÇG ÇGÇG Ç#G=r,   Útarget_pathc                 ó   — |r|n| j                   }t        |«      s6| j                  j                  d«       | j                  j                  «        y d| _        t        j                  | j                  ||||fd¬«      }|j                  «        y )NzInvalid target directory!T©ÚtargetÚargsÚdaemon)
r   r	   r:   r'   r;   r   Ú	threadingÚThreadrB   Ústart)r   r,   r<   rC   r*   r)   Úthreads          r   r3   zInstallController.installa   s{   € Ù&1‘{°t·|±|ˆä& |Ô4Ø× Ñ ×%Ñ%Ð&AÔBØ×#Ñ#×(Ñ(Ô*ØàˆŒÜ×!Ñ!Ø×$Ñ$Ø °À	ÐJØô
ˆð
 	�‰�r   Úrestore_pathc                 ó   — 	 | j                   j                  || j                  |¬«       | j                  j	                  dt
        j                  «       d| _	        | j                  j	                  «        y # t        $ r(}| j                  j	                  d|›�«       Y d }~ŒNd }~ww xY w# d| _	        | j                  j	                  «        w xY w)N)r   r-   r*   zMods uninstalled successfully!z&An error occurred while uninstalling: F)r   r9   r(   r4   r'   r   Ú	UNINSTALLr6   r:   r   r;   )r   rM   r*   r?   s       r   Ú_run_uninstallz InstallController._run_uninstallq   s·   € ð	+Ø�L‰L×"Ñ"Ø$Ø ×-Ñ-Ø#ð #ô ð
 ×"Ñ"×'Ñ'Ð(HÔJZ×JdÑJdÔeð $ˆDŒOØ×#Ñ#×(Ñ(Õ*øô	 ò 	VØ× Ñ ×%Ñ%Ð(NÈqÈeÐ&T×UÑUûð	Vûð $ˆDŒOØ×#Ñ#×(Ñ(Õ*ús*   ‚AA6 Á6	B'Á?B"ÂB* Â"B'Â'B* Â*#Cc                 óÖ   — |r|n| j                   }|s| j                  j                  d«       yd| _        t	        j
                  | j                  ||fd¬«      }|j                  «        y)zAStart uninstall operation. Caller should confirm with user first.z!Please select a target directory!FTrE   )r   r:   r'   r   rI   rJ   rP   rK   )r   rC   r*   rM   rL   s        r   r9   zInstallController.uninstall   sc   € á&1‘{°t·|±|ˆáØ× Ñ ×%Ñ%Ð&IÔJØàˆŒÜ×!Ñ!Ø×&Ñ&Ø 	Ð*Øô
ˆð
 	�‰ŒØr   c                 ó,   — | j                   rd| _        y y )NT)r   r   r   s    r   Úcancel_operationz"InstallController.cancel_operation�   s   € Ø�?Š?Ø$(ˆDÕ!ð r   c                 óX   — |r|n| j                   }| j                  j                  |«      S r   )r   r   Úis_modified)r   rC   Ú
check_paths      r   rU   zInstallController.is_modified”   s$   € Ù$/‘[°T·\±\ˆ
Ø�|‰|×'Ñ'¨
Ó3Ð3r   r   )Ú__name__Ú
__module__Ú__qualname__r   Úintr7   r&   r:   Úobjectr4   r;   r   Úpropertyr   Úsetterr   r"   r(   r   ÚDEFAULTrB   Úlistr3   rP   r9   rS   rU   Ú__classcell__)r   s   @r   r   r      sG  ø„ Ù   cÓ*€OÙ  “o€OÙ" 3¨Ó/ÐÙ#›Ðõ ð ñ-ó ð-ð ×Ññ2ó ð2ð ð ¨ó ð5 Sð 5°3ó 5ð hr×gyÑgyñ 3+¨ð 3+ÐZdó 3+ðj AEÐaeð  @J÷  @Rñ  @Rñ  t¨C¡yð ÐSWÐZ^ÑS^ð Ðr|ó ð  JT×I[ÑI[ñ +¨4ð +¸Jó +ð 48ÐQ[×QcÑQcñ  T¨D¡[ð ÀJó ò")ñ4 t¨d¡{÷ 4r   r   )ÚloggingrI   Úpathlibr   ÚPyQt6.QtCorer   r   Úcore.constantsr   r   Úcore.services.installr   Úcore.util.sourcemodr	   Ú	getLoggerÚlogr   © r   r   Ú<module>rj      s8   ðÛ Û Ý ç ,ç 7Ý 0Ý 7à€g×ÑÓ€ôH4˜õ H4r   