-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMonsterHunterWorld.ts
194 lines (178 loc) · 6.67 KB
/
MonsterHunterWorld.ts
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/**
* @description 怪物猎人世界 支持
*/
import { join, basename, extname } from 'path'
import { statSync } from "fs";
import { ElMessage } from "element-plus";
// let dictionaryList: string[] = []
async function handleMod(mod: IModInfo, installPath: string, isInstall: boolean) {
if (isInstall) {
if (!Manager.checkInstalled("Stracker's Loader", 197740)) return false
}
// if (dictionaryList.length == 0) {
// let dictionary = (await axios.get("res/MonsterHunterWorldDictionary.txt")).data
// dictionaryList = dictionary.split("\r\n")
// }
const manager = useManager()
let res: IState[] = []
mod.modFiles.forEach(async item => {
try {
let modStorage = join(manager.modStorage ?? "", mod.id.toString(), item)
if (statSync(modStorage).isFile()) {
// 获取 nativePC 后的路径, 包含 nativePC
// let path = modStorage.split(/nativepc/i)[1]
let path = FileHandler.getFolderFromPath(modStorage, "nativepc")
if (path) {
let gameStorage = join(manager.gameStorage ?? "", installPath, path ?? "")
if (isInstall) {
let state = await FileHandler.copyFile(modStorage, gameStorage)
res.push({ file: item, state: state })
} else {
let state = FileHandler.deleteFile(gameStorage)
res.push({ file: item, state: state })
}
}
}
} catch {
res.push({ file: item, state: false })
}
})
return res
}
export const supportedGames: ISupportedGames = {
GlossGameId: 161,
steamAppID: 582010,
NexusMods: {
game_domain_name: "monsterhunterworld",
game_id: 2531
},
installdir: "Monster Hunter World",
gameName: "Monster Hunter World",
gameExe: "MonsterHunterWorld.exe",
startExe: [
{
name: 'Steam 启动',
cmd: 'steam://rungameid/582010'
},
{
name: '直接启动',
exePath: 'MonsterHunterWorld.exe'
}
],
gameCoverImg: "https://mod.3dmgame.com/static/upload/game/161b.png",
archivePath: join(Steam.getSteamInstallPath() || "", "userdata", Steam.GetLastSteamId32(), "582010", "remote"),
modType: [
{
id: 1,
name: "Stracker's Loader",
installPath: '\\',
async install(mod) {
const manager = useManager()
let modStorage = join(manager.modStorage ?? "", mod.id.toString())
mod.modFiles.forEach(item => {
try {
let file = join(modStorage, item)
if (statSync(file).isFile()) {
FileHandler.copyFile(file, join(manager.gameStorage ?? "", item))
}
} catch { }
})
return true
},
async uninstall(mod) {
const manager = useManager()
mod.modFiles.forEach(item => {
try {
let target = join(manager.gameStorage ?? "", item)
if (statSync(target).isFile()) {
FileHandler.deleteFile(target)
}
} catch { }
})
return true
}
},
{
id: 2,
name: "通用类型",
installPath: '\\nativePC',
async install(mod) {
return handleMod(mod, this.installPath ?? "", true)
},
async uninstall(mod) {
return handleMod(mod, this.installPath ?? "", false)
}
},
{
id: 3,
name: '插件',
installPath: join('nativePC', 'plugins'),
async install(mod) {
const manager = useManager()
let res: IState[] = []
mod.modFiles.forEach(async item => {
try {
let modStorage = join(manager.modStorage ?? "", mod.id.toString(), item)
let gameStorage = join(manager.gameStorage ?? "", this.installPath ?? "", basename(item))
if (statSync(modStorage).isFile()) {
// 获取文件后缀名
if (extname(modStorage) == '.dll') {
let state = FileHandler.deleteFile(gameStorage)
res.push({ file: item, state: state })
}
}
} catch (error) {
res.push({ file: item, state: false })
}
})
return res
},
async uninstall(mod) {
const manager = useManager()
let res: IState[] = []
mod.modFiles.forEach(async item => {
try {
let modStorage = join(manager.modStorage ?? "", mod.id.toString(), item)
let gameStorage = join(manager.gameStorage ?? "", this.installPath ?? "", basename(item))
if (statSync(modStorage).isFile()) {
// 获取文件后缀名
if (extname(modStorage) == '.dll') {
let state = await FileHandler.copyFile(modStorage, gameStorage)
res.push({ file: item, state: state })
}
}
} catch (error) {
res.push({ file: item, state: false })
}
})
return res
}
},
{
id: 4,
name: '未知',
installPath: "",
async install(mod) {
ElMessage.warning("该mod类型未知, 无法自动安装, 请手动安装!")
return false
},
async uninstall(mod) {
return false
}
}
],
checkModType(mod) {
// 判断是否是 Stracker's Loader
if (mod.webId == 197740) return 1
let nativePC = false
let plugins = false
mod.modFiles.forEach(item => {
if (item.toLowerCase().includes('nativepc')) nativePC = true
// 判断后缀是否有 dll
if (item.endsWith('.dll')) plugins = true
})
if (nativePC) return 2
if (plugins) return 3
return 4
}
}