Windows path fixes

Fixed path handling because Qt still uses "/" on windows but python's os module does not.
Also added dialogs when no game path is set and the selection is cancelled (also fixed a loop with that)
dev v0.1
Peery 12 months ago
parent c94f6236d7
commit 7293c02bc4
Signed by: pandro
SSH Key Fingerprint: SHA256:iBUZSuDxqYr4hYpe9U3BA9NJmXKpbGt4H0S8hUwIbrA

@ -9,6 +9,7 @@ import tempfile
from typing import Tuple, List
from zipfile import ZipFile
from PyQt6 import QtWidgets
from PyQt6.QtWidgets import QApplication
from files.settings import LCSettings
@ -34,8 +35,22 @@ class ModManager:
self.available_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()
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.\nExiting!")
dialog.setIcon(QtWidgets.QMessageBox.Icon.Information)
dialog.exec()
self.__app.exit(0)
sys.exit(0)
self.create_manager_folder()
self.index_stored_mods()
@ -71,9 +86,6 @@ class ModManager:
if not os.path.isdir(manager_folder):
self.__logger.debug(f"Creating folder: {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:
req_files = ["Lethal Company.exe", "doorstop_config.ini"]
@ -232,7 +244,8 @@ class ModManager:
unresolved_files = files.copy()
for file in files:
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)
if file in unresolved_files:
unknown_mod[os.path.basename(file)] = {"mod_files": [file]}
@ -327,10 +340,12 @@ class ModManager:
continue
#print("Moving", os.path.join(tmp_dir, content), "to",
# 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):
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()
def uninstall_mod(self, mod_name: str):

@ -127,7 +127,9 @@ class MainWindow(QtWidgets.QMainWindow):
result = dialog.getExistingDirectory()
dir_accepted = self.parent.set_game_folder(result)
attempt = 0
while not dir_accepted:
attempt += 1
dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle("Invalid game path")
dialog.setInformativeText(f"The given path \"{result}\" did not look like the Lethal Company game folder!\n"
@ -141,6 +143,8 @@ class MainWindow(QtWidgets.QMainWindow):
result = dialog.getExistingDirectory()
dir_accepted = self.parent.set_game_folder(result)
if attempt > 2:
return
def on_action_remove_all_files(self):
self.__logger.debug("Action: \"remove all manager files\" triggered!")

Loading…
Cancel
Save