-
Notifications
You must be signed in to change notification settings - Fork 2
/
SkyrimSE.ts
151 lines (143 loc) · 4.83 KB
/
SkyrimSE.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
/**
* @description 上古卷轴 重制版 安装支持
*/
import { basename, join, extname, dirname } from 'node:path'
import { ElMessage } from "element-plus";
import ini from 'ini'
import { readFileSync, writeFileSync } from "fs";
import { homedir } from 'os'
// 修改 Archive配置
async function setArchive() {
try {
let documents = FileHandler.getMyDocuments()
const Starfield = join(documents, "My Games", "Skyrim Special Edition", "Skyrim.ini")
let config = ini.parse(readFileSync(Starfield, 'utf-8'))
// console.log(config);
if (config.Archive?.bInvalidateOlderFiles == 1) {
console.log('Skyrim.ini 已配置过, 无需再次配置.');
return
}
if (config.Archive) {
config.Archive.bInvalidateOlderFiles = 1
config.Archive.sResourceDataDirsFinal = ""
writeFileSync(Starfield, ini.stringify(config))
}
} catch (error) {
ElMessage.error(`配置 Skyrim.ini 失败! ${error}`)
}
}
// 修改 plugins
async function setPlugins(mod: IModInfo, install: boolean) {
// AppData\Local\Fallout4\plugins.txt
let documents = join(homedir(), "AppData", "Local", "Skyrim Special Edition", "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: 2,
steamAppID: 489830,
NexusMods: {
game_domain_name: "skyrimspecialedition",
game_id: 1704
},
// curseforge: 449,
installdir: join("Skyrim Special Edition"),
gameName: "Skyrim Special Edition",
gameExe: "SkyrimSE.exe",
// startExe: join('bin', 'x64', 'witcher3.exe'),
startExe: [
{
name: 'Steam 启动',
cmd: 'steam://rungameid/489830'
},
{
name: '直接启动',
exePath: "SkyrimSE.exe"
},
{
name: 'skse 启动',
exePath: 'skse64_loader.exe'
}
],
archivePath: join(FileHandler.getMyDocuments(), "My Games", "Skyrim Special Edition"),
gameCoverImg: "https://mod.3dmgame.com/static/upload/game/2.jpg",
modType: [
{
id: 1,
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: 2,
name: 'skse64',
installPath: '',
async install(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "skse64_loader.exe", true)
// return handleSkse64(mod, true)
},
async uninstall(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "skse64_loader.exe", false)
// return handleSkse64(mod, false)
}
},
{
id: 3,
name: 'Plugins',
installPath: join('Data', 'SKSE'),
async install(mod) {
return Manager.installByFolder(mod, this.installPath ?? "", "plugins", true, true, false)
},
async uninstall(mod) {
return Manager.installByFolder(mod, this.installPath ?? "", "plugins", false, true, false)
}
},
{
id: 99,
name: "未知",
installPath: "",
async install(mod) {
ElMessage.warning("未知类型, 请手动安装")
return false
},
async uninstall(mod) {
return true
}
}
],
checkModType(mod) {
let data = false
let skse = false
let plugins = false
mod.modFiles.forEach(item => {
if (item.toLowerCase().includes('data')) data = true
if (item.toLowerCase().includes('plugins')) plugins = true
if (basename(item) == 'skse64_loader.exe') skse = true
if (extname(item) == '.esp' || extname(item) == '.esm') data = true
})
if (skse) return 2
if (data) return 1
if (plugins) return 3
return 99
}
}