Update for Mod Organizer 2.5.0
This commit is contained in:
parent
4e4f5380c5
commit
9866410fd0
@ -1,22 +1,14 @@
|
||||
# SPT plugin for ModOrganizer, coded by a moron: Me :)
|
||||
# Note: This is highly incomplete, and will almost deffinitely break.
|
||||
# Some inconveniences exist, such as the fact that every time you install a mod that does not auto handle, you have to create the user/mods or bepinex/plugins directory manually etc.
|
||||
# I would like to expand those features, but it will probably happen slowly; I'm not a programmer.
|
||||
# This script was made by cross referencing several other basic_game extensions.
|
||||
# I sincerely hope somebody with actual experience comes along and decides to fix it up. But for now, this auto resolves the vast majority of mods on the hub :).
|
||||
# Discord: Archon001
|
||||
|
||||
from typing import List, Tuple
|
||||
from PyQt5.QtCore import QFileInfo
|
||||
from PyQt6.QtCore import QFileInfo
|
||||
import mobase
|
||||
from ..basic_game import BasicGame
|
||||
|
||||
from ..basic_features import BasicModDataChecker, GlobPatterns
|
||||
|
||||
class SPTAKIGame(BasicGame, mobase.IPluginFileMapper):
|
||||
|
||||
Name = "SPT AKI Plugin"
|
||||
Author = "Archon"
|
||||
Version = "1.0.1a"
|
||||
Version = "1.1"
|
||||
GameName = "SPT AKI"
|
||||
GameShortName = "sptaki"
|
||||
GameBinary = "aki.launcher.exe"
|
||||
@ -24,6 +16,10 @@ class SPTAKIGame(BasicGame, mobase.IPluginFileMapper):
|
||||
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)
|
||||
self._featureMap[mobase.ModDataChecker] = SPTAKIModDataChecker()
|
||||
@ -31,7 +27,6 @@ class SPTAKIGame(BasicGame, mobase.IPluginFileMapper):
|
||||
|
||||
def executables(self) -> List[mobase.ExecutableInfo]:
|
||||
execs = super().executables()
|
||||
print(execs)
|
||||
|
||||
"""
|
||||
A bat script file to bridge the environment to server and launcher.
|
||||
@ -68,64 +63,14 @@ endlocal
|
||||
mobase.ExecutableInfo("Launch SP Tarkov", QFileInfo(workaroundPath))
|
||||
)
|
||||
execs.pop(0)
|
||||
print(execs)
|
||||
return execs
|
||||
|
||||
|
||||
class SPTAKIModDataChecker(mobase.ModDataChecker):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
def get_plugins_and_mods(
|
||||
self, tree: mobase.IFileTree
|
||||
) -> Tuple[List[mobase.FileTreeEntry], List[mobase.FileTreeEntry]]:
|
||||
|
||||
plugins: List[mobase.FileTreeEntry] = []
|
||||
mods: List[mobase.FileTreeEntry] = []
|
||||
|
||||
for e in tree:
|
||||
if e.isDir() and e.exists("package.json", mobase.IFileTree.FILE):
|
||||
mods.append(e)
|
||||
elif e.isFile() and e.suffix().lower() == "dll":
|
||||
plugins.append(e)
|
||||
elif e.isDir():
|
||||
has_dll = False
|
||||
for file_entry in e:
|
||||
if file_entry.isFile() and file_entry.suffix().lower() == "dll":
|
||||
has_dll = True
|
||||
break
|
||||
if has_dll and not e.exists("package.json", mobase.IFileTree.FILE):
|
||||
plugins.append(e)
|
||||
|
||||
return plugins, mods
|
||||
|
||||
def dataLooksValid(
|
||||
self, tree: mobase.IFileTree
|
||||
) -> mobase.ModDataChecker.CheckReturn:
|
||||
# Check if we have bepinex/plugins, user/mods folders or .json/.dll
|
||||
plugins, mods = self.get_plugins_and_mods(tree)
|
||||
|
||||
if not plugins and not mods:
|
||||
if tree.exists("bepinex/plugins") or tree.exists("user/mods"):
|
||||
return mobase.ModDataChecker.VALID
|
||||
else:
|
||||
return mobase.ModDataChecker.INVALID
|
||||
|
||||
return mobase.ModDataChecker.FIXABLE
|
||||
|
||||
def fix(self, tree: mobase.IFileTree) -> mobase.IFileTree:
|
||||
plugins, mods = self.get_plugins_and_mods(tree)
|
||||
toMove = []
|
||||
if mods:
|
||||
for entry in tree:
|
||||
toMove.append((entry, "/user/mods/"))
|
||||
for (entry, path) in toMove:
|
||||
tree.move(entry, path, policy=mobase.IFileTree.MERGE)
|
||||
|
||||
if plugins:
|
||||
for entry in tree:
|
||||
toMove.append((entry, "/bepinex/plugins/"))
|
||||
for (entry, path) in toMove:
|
||||
tree.move(entry, path, policy=mobase.IFileTree.MERGE)
|
||||
|
||||
return tree
|
||||
class SPTAKIModDataChecker(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),
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user