@ -9,6 +9,7 @@ import tempfile
from typing import Tuple , List
from typing import Tuple , List
from zipfile import ZipFile
from zipfile import ZipFile
from PyQt6 import QtWidgets
from PyQt6 . QtWidgets import QApplication
from PyQt6 . QtWidgets import QApplication
from files . settings import LCSettings
from files . settings import LCSettings
@ -34,8 +35,22 @@ class ModManager:
self . available_mods = dict ( )
self . available_mods = dict ( )
self . installed_mods = dict ( )
self . installed_mods = dict ( )
while self . __settings . get_game_folder ( ) is None :
if self . __settings . get_game_folder ( ) is None :
dialog = QtWidgets . QMessageBox ( )
dialog . setWindowTitle ( " No Game folder " )
dialog . setInformativeText ( f " The mod manager requires the path to your Lethal Company game folder! \n "
" Please choose it in the following window. " )
dialog . setIcon ( QtWidgets . QMessageBox . Icon . Information )
dialog . exec ( )
self . __window . on_action_set_game_folder ( )
self . __window . on_action_set_game_folder ( )
if self . __settings . get_game_folder ( ) is None :
dialog = QtWidgets . QMessageBox ( )
dialog . setWindowTitle ( " No Game folder " )
dialog . setInformativeText ( f " Can ' t do anything without a valid game folder path. \n Exiting! " )
dialog . setIcon ( QtWidgets . QMessageBox . Icon . Information )
dialog . exec ( )
self . __app . exit ( 0 )
sys . exit ( 0 )
self . create_manager_folder ( )
self . create_manager_folder ( )
self . index_stored_mods ( )
self . index_stored_mods ( )
@ -71,9 +86,6 @@ class ModManager:
if not os . path . isdir ( manager_folder ) :
if not os . path . isdir ( manager_folder ) :
self . __logger . debug ( f " Creating folder: { manager_folder } " )
self . __logger . debug ( f " Creating folder: { manager_folder } " )
os . mkdir ( manager_folder )
os . mkdir ( manager_folder )
else :
self . __window . on_action_set_game_folder ( )
self . create_manager_folder ( )
def is_folder_valid_game_folder ( self , dir_path : str ) - > bool :
def is_folder_valid_game_folder ( self , dir_path : str ) - > bool :
req_files = [ " Lethal Company.exe " , " doorstop_config.ini " ]
req_files = [ " Lethal Company.exe " , " doorstop_config.ini " ]
@ -232,7 +244,8 @@ class ModManager:
unresolved_files = files . copy ( )
unresolved_files = files . copy ( )
for file in files :
for file in files :
for mod in self . installed_mods . keys ( ) :
for mod in self . installed_mods . keys ( ) :
if file [ len ( self . __settings . get_game_folder ( ) ) + 1 : ] in self . installed_mods [ mod ] [ " mod_files " ] :
file_rel = file [ len ( self . __settings . get_game_folder ( ) ) + 1 : ]
if file_rel . replace ( os . path . sep , " / " ) in self . installed_mods [ mod ] [ " mod_files " ] :
unresolved_files . remove ( file )
unresolved_files . remove ( file )
if file in unresolved_files :
if file in unresolved_files :
unknown_mod [ os . path . basename ( file ) ] = { " mod_files " : [ file ] }
unknown_mod [ os . path . basename ( file ) ] = { " mod_files " : [ file ] }
@ -327,10 +340,12 @@ class ModManager:
continue
continue
#print("Moving", os.path.join(tmp_dir, content), "to",
#print("Moving", os.path.join(tmp_dir, content), "to",
# os.path.join(self.__settings.get_game_folder(), file))
# os.path.join(self.__settings.get_game_folder(), file))
parent_dir = os . path . join ( self . __settings . get_game_folder ( ) , file ) . split ( os . path . basename ( file ) ) [ 0 ]
parent_dir = os . path . join ( self . __settings . get_game_folder ( ) . replace ( " / " , os . path . sep ) ,
file . replace ( " / " , os . path . sep ) ) . split ( file . replace ( " / " , os . path . sep ) ) [ 0 ]
if not os . path . exists ( parent_dir ) :
if not os . path . exists ( parent_dir ) :
os . mkdir ( parent_dir )
os . mkdir ( parent_dir )
shutil . move ( os . path . join ( tmp_dir , content ) , os . path . join ( self . __settings . get_game_folder ( ) , file ) )
if not os . path . exists ( os . path . join ( self . __settings . get_game_folder ( ) . replace ( " / " , os . path . sep ) , file . replace ( " / " , os . path . sep ) ) ) :
shutil . move ( os . path . join ( tmp_dir , content . replace ( " / " , os . path . sep ) ) , os . path . join ( self . __settings . get_game_folder ( ) . replace ( " / " , os . path . sep ) , file . replace ( " / " , os . path . sep ) ) )
self . index_installed_mods ( )
self . index_installed_mods ( )
def uninstall_mod ( self , mod_name : str ) :
def uninstall_mod ( self , mod_name : str ) :