From 3e8f90cd1aee0e5c899c084ce764c06287cc2162 Mon Sep 17 00:00:00 2001 From: Rage Date: Fri, 3 Jan 2025 00:25:17 -0500 Subject: [PATCH] Added SPT MO2 Plugin + MO2 INI --- ModOrganizer.ini | 16 ++++++ plugins/basic_games/games/game_spt.py | 82 +++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 ModOrganizer.ini create mode 100644 plugins/basic_games/games/game_spt.py diff --git a/ModOrganizer.ini b/ModOrganizer.ini new file mode 100644 index 0000000..e275dbf --- /dev/null +++ b/ModOrganizer.ini @@ -0,0 +1,16 @@ +[General] +selected_profile=@ByteArray(Multiplayer) + +[Settings] +style=Dark Bronze.qss + +[customExecutables] +size=1 +1\arguments= +1\binary=D:/Games/Singleplayer Tarkov/SPT.Launcher.exe +1\hide=false +1\ownicon=false +1\steamAppID= +1\title=Multiplayer +1\toolbar=false +1\workingDirectory=D:/Games/Singleplayer Tarkov diff --git a/plugins/basic_games/games/game_spt.py b/plugins/basic_games/games/game_spt.py new file mode 100644 index 0000000..074101f --- /dev/null +++ b/plugins/basic_games/games/game_spt.py @@ -0,0 +1,82 @@ +from typing import List, Tuple +from PyQt6.QtCore import QFileInfo +import mobase +from ..basic_game import BasicGame +from ..basic_features import BasicModDataChecker, GlobPatterns + + +class SPTGame(BasicGame, mobase.IPluginFileMapper): + + Name = "SPT Plugin" + Author = "Archon" + Version = "1.1.2" + GameName = "SPT" + GameShortName = "spt" + GameBinary = "SPT.Launcher.exe" + GameDataPath = "%GAME_PATH%" + GameSaveExtension = "json" + GameSavesDirectory = "%GAME_PATH%/user/profiles" + + def __init__(self): + super().__init__() + mobase.IPluginFileMapper.__init__(self) + + def init(self, organizer: mobase.IOrganizer) -> bool: + super().init(organizer) + if hasattr(self, '_featureMap'): + self._featureMap[mobase.ModDataChecker] = SPTModDataChecker() + else: + self._register_feature(SPTModDataChecker()) + return True + + def executables(self) -> List[mobase.ExecutableInfo]: + execs = super().executables() + + """ + A bat script file to bridge the environment to server and launcher. + """ + workaroundPath = self._gamePath + "/sptvfsbridge.bat" + + try: + workaround = open(workaroundPath, "rt") + except FileNotFoundError: + with open(workaroundPath, "wt") as workaround: + workaround.write( + """ +@echo off +setlocal + +set "launcher_path=SPT.Launcher.exe" +set "server_path=SPT.Server.exe" + +REM Launch the server.exe +start "" "%server_path%" + +REM Wait for a moment to ensure the server.exe has started +timeout /t 5 /nobreak >nul + +REM Launch the launcher.exe +start "" "%launcher_path%" + +endlocal +""" + ) + workaround.close() + + execs.append( + mobase.ExecutableInfo("Launch SP Tarkov", QFileInfo(workaroundPath)) + ) + execs.pop(0) + return execs + + def mappings(self) -> list[mobase.Mapping]: + return [] + +class SPTModDataChecker(BasicModDataChecker): + def __init__(self, patterns: GlobPatterns = GlobPatterns()): + super().__init__( + GlobPatterns( + valid=["BepInEx", "User"], + move={"plugins": "BepInEx/", "patchers": "BepInEx/", "package.json": "User/Mods/", "*.dll": "BepInEx/plugins/", "*": "User/Mods/"}, + ).merge(patterns), + ) \ No newline at end of file