From d282c2e08dba706efd380702e1e1177c416f3e86 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Fri, 15 Sep 2023 19:35:32 -0500 Subject: [PATCH] Additional fixes and cleanup for python updates --- basic_features/basic_save_game_info.py | 8 ++++---- basic_game.py | 6 +++--- games/game_blackandwhite2.py | 12 ++++++------ games/game_da2.py | 2 +- games/game_darkmessiahofmightandmagic.py | 2 +- games/game_kerbalspaceprogram.py | 7 +++---- games/game_sims4.py | 2 +- games/game_trainsimulator.py | 2 +- games/game_valheim.py | 8 ++++---- games/game_vampirebloodlines.py | 2 +- games/game_witcher3.py | 2 +- 11 files changed, 26 insertions(+), 27 deletions(-) diff --git a/basic_features/basic_save_game_info.py b/basic_features/basic_save_game_info.py index 13a9b50..29172da 100644 --- a/basic_features/basic_save_game_info.py +++ b/basic_features/basic_save_game_info.py @@ -2,7 +2,7 @@ import sys from pathlib import Path -from typing import Callable +from typing import Callable, Optional from PyQt6.QtCore import QDateTime, Qt from PyQt6.QtGui import QImage, QPixmap @@ -33,7 +33,7 @@ def allFiles(self) -> list[str]: class BasicGameSaveGameInfoWidget(mobase.ISaveGameInfoWidget): - def __init__(self, parent: QWidget, get_preview: Callable[[Path], Path | None]): + def __init__(self, parent: QWidget, get_preview: Optional[Callable[[Path], Optional[QPixmap | Path | str]]]): super().__init__(parent) self._get_preview = get_preview @@ -89,9 +89,9 @@ def setSave(self, save: mobase.ISaveGame): class BasicGameSaveGameInfo(mobase.SaveGameInfo): - def __init__(self, get_preview: Callable[[Path], Path | None] | None = None): + def __init__(self, get_preview: Optional[Callable[[Path], Optional[QPixmap | Path | str]]] = None): super().__init__() - self._get_preview = get_preview + self._get_preview: Optional[Callable[[Path], Optional[QPixmap | Path | str]]] = get_preview def getMissingAssets(self, save: mobase.ISaveGame): return {} diff --git a/basic_game.py b/basic_game.py index 98e00dd..c760069 100644 --- a/basic_game.py +++ b/basic_game.py @@ -591,13 +591,13 @@ def CCPlugins(self): return [] def loadOrderMechanism(self): - return mobase.LoadOrderMechanism.PluginsTxt + return mobase.LoadOrderMechanism.PLUGINS_TXT def sortMechanism(self): return mobase.SortMechanism.NONE - def looksValid(self, aQDir: QDir): - return aQDir.exists(self.binaryName()) + def looksValid(self, directory: QDir): + return directory.exists(self.binaryName()) def isInstalled(self) -> bool: return bool(self._gamePath) diff --git a/games/game_blackandwhite2.py b/games/game_blackandwhite2.py index 4ea88bf..e7142dc 100644 --- a/games/game_blackandwhite2.py +++ b/games/game_blackandwhite2.py @@ -249,12 +249,12 @@ def getPreview(save): save = BlackAndWhite2SaveGame(save) lines = [ [ - ("Name : " + save.getName(), Qt.AlignLeft), - ("| Profile : " + save.getSaveGroupIdentifier()[1:], Qt.AlignLeft), + ("Name : " + save.getName(), Qt.AlignmentFlag.AlignLeft), + ("| Profile : " + save.getSaveGroupIdentifier()[1:], Qt.AlignmentFlag.AlignLeft), ], - [("Land number : " + save.getLand(), Qt.AlignLeft)], - [("Saved at : " + save.getCreationTime().toString(), Qt.AlignLeft)], - [("Elapsed time : " + save.getElapsed(), Qt.AlignLeft)], + [("Land number : " + save.getLand(), Qt.AlignmentFlag.AlignLeft)], + [("Saved at : " + save.getCreationTime().toString(), Qt.AlignmentFlag.AlignLeft)], + [("Elapsed time : " + save.getElapsed(), Qt.AlignmentFlag.AlignLeft)], ] pixmap = QPixmap(320, 320) @@ -277,7 +277,7 @@ def getPreview(save): bRect = fm.boundingRect(toPrint) cHeight = bRect.height() * (ln + 1) bRect.moveTop(cHeight - bRect.height()) - if align != Qt.AlignLeft: + if align != Qt.AlignmentFlag.AlignLeft: continue else: bRect.moveLeft(cWidth + margin) diff --git a/games/game_da2.py b/games/game_da2.py index a8fdc30..4a29ea3 100644 --- a/games/game_da2.py +++ b/games/game_da2.py @@ -26,7 +26,7 @@ class DA2Game(BasicGame): def version(self): # Don't forget to import mobase! - return mobase.VersionInfo(1, 0, 1, mobase.ReleaseType.final) + return mobase.VersionInfo(1, 0, 1, mobase.ReleaseType.FINAL) def init(self, organizer: mobase.IOrganizer): super().init(organizer) diff --git a/games/game_darkmessiahofmightandmagic.py b/games/game_darkmessiahofmightandmagic.py index 3c8f62f..22b110b 100644 --- a/games/game_darkmessiahofmightandmagic.py +++ b/games/game_darkmessiahofmightandmagic.py @@ -39,7 +39,7 @@ def _read_save_tga(self, filename): _, _, w, h, bpp, _ = struct.unpack(".+) v[\d\.]+?$", re.I | re.M), + content_regex=re.compile(r"\A.*plugin (?P.+) v[\d.]+?$", re.I | re.M), match_group="mod", ) @@ -202,7 +202,7 @@ def _find_mod_for_overwrite_file( """Find the mod (name) matching a file in Overwrite (using the mods dll name). Args: - file_name: The name of the file. + file_path: The name of the file. mod_dll_map: Mods names and their dll files `{mod_name: ["ModName.dll"]}`. Returns: @@ -236,8 +236,8 @@ def _get_matching_mods( """Find matching mods for the given `search_str`. Args: - search_name: A string to find a mod match for. mod_dll_map: Mods names and - their dll files `{mod_name: ["ModName.dll"]}`. + search_str: A string to find a mod match for. + mod_dll_map: Mods names and their dll files `{mod_name: ["ModName.dll"]}`. Returns: Mods with partial matches, sorted descending by their metric diff --git a/games/game_vampirebloodlines.py b/games/game_vampirebloodlines.py index 66fdf0c..ed8f286 100644 --- a/games/game_vampirebloodlines.py +++ b/games/game_vampirebloodlines.py @@ -114,7 +114,7 @@ def initializeProfile(self, path: QDir, settings: mobase.ProfileSetting): def version(self): # Don't forget to import mobase! - return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.final) + return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.FINAL) def iniFiles(self): return ["autoexec.cfg", "user.cfg"] diff --git a/games/game_witcher3.py b/games/game_witcher3.py index 12248a4..026a5ea 100644 --- a/games/game_witcher3.py +++ b/games/game_witcher3.py @@ -14,7 +14,7 @@ class Witcher3SaveGame(BasicGameSaveGame): def allFiles(self): - return [self._filename, self._filename.replace(".sav", ".png")] + return [self._filepath.name, self._filepath.name.replace(".sav", ".png")] class Witcher3Game(BasicGame):