forked from ModOrganizer2/modorganizer-basic_games
-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_divinityoriginalsinee.py
125 lines (104 loc) · 3.99 KB
/
game_divinityoriginalsinee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# -*- encoding: utf-8 -*-
import os
from typing import List, Optional
import mobase
from ..basic_features import BasicGameSaveGameInfo
from ..basic_game import BasicGame
class DivinityOriginalSinEnhancedEditionModDataChecker(mobase.ModDataChecker):
def __init__(self):
super().__init__()
def dataLooksValid(
self, tree: mobase.IFileTree
) -> mobase.ModDataChecker.CheckReturn:
folders: List[mobase.IFileTree] = []
files: List[mobase.FileTreeEntry] = []
for entry in tree:
if isinstance(entry, mobase.IFileTree):
folders.append(entry)
else:
files.append(entry)
VALID_FOLDERS = [
"Cursors",
"DLC",
"Engine",
"Fonts",
"Localization",
"PakInfo",
"PlayerProfiles",
"Public",
"Shaders",
DivinityOriginalSinEnhancedEditionGame.DOCS_MOD_SPECIAL_NAME,
]
for src_folder in folders:
for dst_folder in VALID_FOLDERS:
if src_folder.name().lower() == dst_folder.lower():
return mobase.ModDataChecker.VALID
VALID_FILE_EXTENSIONS = [
".pak",
]
for src_file in files:
for extension in VALID_FILE_EXTENSIONS:
if src_file.name().lower().endswith(extension.lower()):
return mobase.ModDataChecker.VALID
return mobase.ModDataChecker.INVALID
def fix(self, tree: mobase.IFileTree) -> Optional[mobase.IFileTree]:
return None
class DivinityOriginalSinEnhancedEditionGame(BasicGame, mobase.IPluginFileMapper):
Name = "Divinity: Original Sin (Enhanced Edition) Support Plugin"
Author = "LostDragonist"
Version = "1.0.0"
GameName = "Divinity: Original Sin (Enhanced Edition)"
GameShortName = "divinityoriginalsinenhancededition"
GameNexusName = "divinityoriginalsinenhancededition"
GameValidShortNames = ["divinityoriginalsin"]
GameNexusId = 1995
GameSteamId = [373420]
GameGogId = [1445516929, 1445524575]
GameBinary = "Shipping/EoCApp.exe"
GameDataPath = "Data"
GameSaveExtension = "lsv"
GameDocumentsDirectory = (
"%USERPROFILE%/Documents/Larian Studios/"
"Divinity Original Sin Enhanced Edition"
)
GameSavesDirectory = (
"%USERPROFILE%/Documents/Larian Studios/"
"Divinity Original Sin Enhanced Edition/PlayerProfiles"
)
DOCS_MOD_SPECIAL_NAME = "DOCS_MOD"
def __init__(self):
BasicGame.__init__(self)
mobase.IPluginFileMapper.__init__(self)
def init(self, organizer: mobase.IOrganizer):
super().init(organizer)
self._featureMap[mobase.SaveGameInfo] = BasicGameSaveGameInfo(
lambda s: s.replace(".lsv", ".png")
)
self._featureMap[
mobase.ModDataChecker
] = DivinityOriginalSinEnhancedEditionModDataChecker()
return True
def mappings(self) -> List[mobase.Mapping]:
map = []
modDirs = [self.DOCS_MOD_SPECIAL_NAME]
self._listDirsRecursive(modDirs, prefix=self.DOCS_MOD_SPECIAL_NAME)
for dir_ in modDirs:
for file_ in self._organizer.findFiles(path=dir_, filter=lambda x: True):
m = mobase.Mapping()
m.createTarget = True
m.isDirectory = False
m.source = file_
m.destination = os.path.join(
self.documentsDirectory().absoluteFilePath("Mods"),
file_.split(self.DOCS_MOD_SPECIAL_NAME)[1].strip("\\").strip("/"),
)
map.append(m)
return map
def primarySources(self):
return self.GameValidShortNames
def _listDirsRecursive(self, dirs_list, prefix=""):
dirs = self._organizer.listDirectories(prefix)
for dir_ in dirs:
dir_ = os.path.join(prefix, dir_)
dirs_list.append(dir_)
self._listDirsRecursive(dirs_list, dir_)