2021-07-18 10:33:08 +02:00
|
|
|
import os
|
|
|
|
|
import re
|
2021-03-09 21:26:12 +01:00
|
|
|
|
2021-12-06 05:20:37 -06:00
|
|
|
from PyQt6.QtCore import QDir
|
2021-03-09 21:26:12 +01:00
|
|
|
|
2021-07-18 10:33:08 +02:00
|
|
|
from ..basic_game import BasicGame
|
2021-03-09 21:26:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class MSFS2020Game(BasicGame):
|
|
|
|
|
Name = "Microsoft Flight Simulator 2020 Support Plugin"
|
|
|
|
|
Author = "Deorder"
|
|
|
|
|
Version = "0.0.1"
|
|
|
|
|
|
|
|
|
|
GameName = "Microsoft Flight Simulator 2020"
|
|
|
|
|
GameShortName = "msfs2020"
|
|
|
|
|
GameBinary = r"FlightSimulator.exe"
|
|
|
|
|
GameSteamId = [1250410]
|
2021-12-27 00:57:18 -07:00
|
|
|
GameSupportURL = (
|
|
|
|
|
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
|
|
|
|
|
"Game:-Microsoft-Flight-Simulator-(2020)"
|
|
|
|
|
)
|
2021-03-09 21:26:12 +01:00
|
|
|
|
|
|
|
|
def dataDirectory(self) -> QDir:
|
2021-03-10 20:27:23 +01:00
|
|
|
# Find and use package path specified in Asobo engine options
|
2021-03-09 21:26:12 +01:00
|
|
|
AppDataPath = os.path.expandvars(r"%APPDATA%\Microsoft Flight Simulator")
|
|
|
|
|
UserCfgPath = os.path.join(AppDataPath, "UserCfg.opt")
|
2021-03-10 20:27:23 +01:00
|
|
|
InstalledPackagesPathPattern = re.compile(
|
2021-03-10 20:31:13 +01:00
|
|
|
r'InstalledPackagesPath\s*=\s*"(.*)"', re.IGNORECASE
|
2021-03-10 20:27:23 +01:00
|
|
|
)
|
|
|
|
|
with open(UserCfgPath, newline="") as f:
|
2021-03-09 21:26:12 +01:00
|
|
|
for _, line in enumerate(f):
|
|
|
|
|
for match in re.finditer(InstalledPackagesPathPattern, line):
|
|
|
|
|
return QDir(os.path.join(match.group(), "Community"))
|
|
|
|
|
return QDir(os.path.join(AppDataPath, "Packages", "Community"))
|