mirror of
https://github.com/ModOrganizer2/modorganizer-basic_games.git
synced 2026-07-27 14:07:29 -07:00
Update game_masterduel.py
Updated to add support for AssetBundle mods.
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QFileInfo, QDir
|
||||
from typing import List, Optional, cast
|
||||
from os.path import join, exists
|
||||
|
||||
import mobase
|
||||
|
||||
from ..basic_game import BasicGame
|
||||
|
||||
|
||||
class MasterDuelGame(BasicGame):
|
||||
class MasterDuelGame(BasicGame, mobase.IPluginFileMapper):
|
||||
|
||||
Name = "Yu-Gi-Oh! Master Duel Support Plugin"
|
||||
Author = "The Conceptionist & uwx"
|
||||
Version = "1.0.1"
|
||||
Description = "Adds support for basic Yu-Gi-Oh! Master Duel mods.\nCurrently does not support any mods that require modifying the masterduel_Data/StreamingAssets folder."
|
||||
Version = "1.0.2"
|
||||
Description = "Adds support for basic Yu-Gi-Oh! Master Duel mods.\nEligible folders for mods are \"0000\" and \"AssetBundle\"."
|
||||
|
||||
GameName = "Yu-Gi-Oh! Master Duel"
|
||||
GameShortName = "masterduel"
|
||||
@@ -21,6 +22,10 @@ class MasterDuelGame(BasicGame):
|
||||
GameSteamId = 1449850
|
||||
GameBinary = "masterduel.exe"
|
||||
|
||||
def __init__(self):
|
||||
BasicGame.__init__(self)
|
||||
mobase.IPluginFileMapper.__init__(self)
|
||||
|
||||
def executables(self):
|
||||
return [
|
||||
mobase.ExecutableInfo(
|
||||
@@ -28,8 +33,52 @@ class MasterDuelGame(BasicGame):
|
||||
QFileInfo(self.gameDirectory().absoluteFilePath(self.binaryName())),
|
||||
).withArgument("-popupwindow"),
|
||||
]
|
||||
|
||||
|
||||
# dataDirectory returns the specific LocalData folder because this is where most mods will go to
|
||||
def dataDirectory(self) -> QDir:
|
||||
localData = QDir(self.gameDirectory().absoluteFilePath('LocalData'))
|
||||
subdirs = localData.entryList(filters=(QDir.Dirs | QDir.NoDotAndDotDot))
|
||||
return QDir(QDir.toNativeSeparators(localData.absoluteFilePath(subdirs[0]) + '/0000'))
|
||||
return QDir(self.userDataDir())
|
||||
|
||||
_userDataDirCached: Optional[str] = None
|
||||
|
||||
# Gets the LocalData/xxxxxxxxx directory. This directory has a different, unique, 8-character hex name for each
|
||||
# user.
|
||||
def userDataDir(self) -> str:
|
||||
if self._userDataDirCached is not None:
|
||||
return self._userDataDirCached
|
||||
|
||||
dir = self.gameDirectory()
|
||||
dir.cd('LocalData')
|
||||
|
||||
subdirs = dir.entryList(filters=cast(QDir.Filters, QDir.Dirs | QDir.NoDotAndDotDot))
|
||||
dir.cd(subdirs[0])
|
||||
|
||||
self._userDataDirCached = dir.absolutePath()
|
||||
return self._userDataDirCached
|
||||
|
||||
def mappings(self) -> List[mobase.Mapping]:
|
||||
modsPath = self._organizer.modsPath()
|
||||
unityMods = self.getUnityDataMods()
|
||||
|
||||
mappings: List[mobase.Mapping] = []
|
||||
|
||||
for modName in unityMods:
|
||||
m = mobase.Mapping()
|
||||
m.createTarget = False
|
||||
m.isDirectory = True
|
||||
m.source = join(modsPath, modName, "AssetBundle")
|
||||
m.destination = self.gameDirectory().filePath(join("masterduel_Data", "StreamingAssets", "AssetBundle"))
|
||||
mappings.append(m)
|
||||
|
||||
return mappings
|
||||
|
||||
def getUnityDataMods(self):
|
||||
modsPath = self._organizer.modsPath()
|
||||
allMods = self._organizer.modList().allModsByProfilePriority()
|
||||
|
||||
unityMods = []
|
||||
for modName in allMods:
|
||||
if self._organizer.modList().state(modName) & mobase.ModState.ACTIVE != 0:
|
||||
if exists(join(modsPath, modName, "AssetBundle")):
|
||||
unityMods.append(modName)
|
||||
|
||||
return unityMods
|
||||
|
||||
Reference in New Issue
Block a user