-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFallout4.ts
165 lines (154 loc) · 4.96 KB
/
Fallout4.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
/**
* @description 辐射4 安装支持
*/
import { basename, join, extname } from 'node:path'
import { ElMessage } from "element-plus";
import ini from 'ini'
import { writeFileSync } from "fs";
import { homedir } from 'os'
// 修改 Archive配置
async function setArchive() {
try {
let documents = FileHandler.getMyDocuments()
const Fallout4Ini = join(documents, "My Games", "Fallout4", "Fallout4.ini")
let config = ini.parse(await FileHandler.readFileSync(Fallout4Ini, ''))
// console.log(config);
if (config.Archive?.bInvalidateOlderFiles == 1) {
console.log('Fallout4.ini 已配置过, 无需再次配置.');
return
}
if (config.Archive) {
config.Archive.bInvalidateOlderFiles = 1
config.Archive.sResourceDataDirsFinal = ""
writeFileSync(Fallout4Ini, ini.stringify(config))
}
} catch (error) {
// ElMessage.error(`配置 Fallout4.ini 失败! ${error}`)
console.log(`配置 Fallout4.ini 失败! ${error}`);
}
}
// 修改 plugins
async function setPlugins(mod: IModInfo, install: boolean) {
// AppData\Local\Fallout4\plugins.txt
let documents = join(homedir(), "AppData", "Local", "Fallout4", "plugins.txt")
let plugins = await FileHandler.readFileSync(documents)
let arr = plugins.split('\n')
mod.modFiles.forEach(item => {
if (extname(item) == '.esp' || extname(item) == '.esm') {
if (install) {
arr.push(`*${basename(item)}`)
} else {
arr = arr.filter(i => i != `*${basename(item)}`)
}
}
})
// arr 中移除空内容
arr = arr.filter(i => i != "")
FileHandler.writeFile(documents, arr.join('\n'))
}
export const supportedGames: ISupportedGames = {
GlossGameId: 6,
steamAppID: 377160,
NexusMods: {
game_domain_name: "fallout4",
game_id: 1151
},
installdir: join("Fallout 4"),
gameName: "Fallout 4",
gameExe: [
{
name: "Fallout4.exe",
rootPath: ""
},
{
name: "Fallout4Launcher.exe",
rootPath: ""
}
],
// startExe: join('bin', 'x64', 'witcher3.exe'),
startExe: [
{
name: 'Steam 启动',
cmd: 'steam://rungameid/377160'
},
{
name: '直接启动',
exePath: "Fallout4.exe"
},
{
name: 'F4SE 启动',
exePath: 'f4se_loader.exe'
}
],
archivePath: join(FileHandler.getMyDocuments(), "My Games", "Fallout4"),
gameCoverImg: "https://mod.3dmgame.com/static/upload/game/6b.png",
modType: [
{
id: 1,
name: 'Plugins',
installPath: join("Data", "F4SE", "plugins"),
async install(mod) {
return Manager.installByFolder(mod, this.installPath ?? "", "plugins", true, false, true)
},
async uninstall(mod) {
return Manager.installByFolder(mod, this.installPath ?? "", "plugins", false, false, true)
},
},
{
id: 2,
name: "Data",
installPath: "Data",
async install(mod) {
setPlugins(mod, true)
setArchive()
return Manager.installByFolder(mod, this.installPath ?? "", "data", true, false, true)
},
async uninstall(mod) {
setPlugins(mod, false)
return Manager.installByFolder(mod, this.installPath ?? "", "data", false, false, true)
}
},
{
id: 3,
name: 'f4se',
installPath: '',
async install(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "f4se_loader.exe", true)
},
async uninstall(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "f4se_loader.exe", false)
}
},
{
id: 99,
name: "未知",
installPath: "",
async install(mod) {
ElMessage.warning("未知类型, 请手动安装")
return false
},
async uninstall(mod) {
return true
}
}
],
checkModType(mod) {
// let esp = false
let data = false
let plugins = false
let f4se = false
mod.modFiles.forEach(item => {
// if (extname(item) == '.esp') esp = true
if (extname(item) == '.dll') plugins = true
if (item.toLowerCase().includes('data')) data = true
if (basename(item) == 'f4se_loader.exe') f4se = true
if (extname(item) == '.esp' || extname(item) == '.esm') data = true
})
if (f4se) return 3
if (data) return 2
if (plugins) return 1
// if (esp) return 1
// if (esm) return 3
return 99
}
}