-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSekiro.ts
154 lines (139 loc) · 5.11 KB
/
Sekiro.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
/**
* @description 只狼 安装支持
*/
import { basename, join } from 'node:path'
import { statSync } from "fs";
import { ElMessage } from "element-plus";
let dictionaryList: string[] = []
// function getDictionaryList(data: string[]) {
// if (dictionaryList.length == 0) {
// axios.get("res/SekiroDictionary.txt").then(({ data }) => {
// dictionaryList = data.split("\r\n")
// data = dictionaryList
// })
// }
// return dictionaryList
// }
async function handleMod(mod: IModInfo, installPath: string, isInstall: boolean) {
try {
if (isInstall) {
if (!Manager.checkInstalled("ModEngine", 71282)) return false
}
if (dictionaryList.length == 0) {
// let SekiroDictionary = (await axios.get("res/SekiroDictionary.txt")).data
let SekiroDictionary = FileHandler.readFile(join(FileHandler.getResourcesPath(), 'res', 'SekiroDictionary.txt'))
dictionaryList = SekiroDictionary.split("\r\n")
}
const manager = useManager()
let res: IState[] = []
mod.modFiles.forEach(async file => {
try {
// let modStorage = `${settings.settings.modStorageLocation}\\${settings.settings.managerGame.gameName}\\${mod.id}\\${file}`
let modStorage = join(manager.modStorage, mod.id.toString(), file)
// 判断是否是文件
if (!statSync(modStorage).isFile()) return
let name = basename(file)
// 判断name 是否在list中
if (dictionaryList.some(item => item.includes(name))) {
// 获取对应的目录
let path = dictionaryList.find(item => item.includes(name))
// let gameStorage = `${settings.settings.managerGame.gamePath}\\${installPath}\\${path}`
let gameStorage = join(manager.gameStorage ?? "", installPath, path ?? "")
if (isInstall) {
let state = await FileHandler.copyFile(modStorage, gameStorage)
res.push({ file: file, state: state })
} else {
let state = FileHandler.deleteFile(gameStorage)
res.push({ file: file, state: state })
}
}
} catch (error) {
res.push({ file: file, state: false })
}
})
return res
} catch (error) {
ElMessage.error(`错误:${error}`)
return false
}
}
export const supportedGames: ISupportedGames = {
GlossGameId: 185,
steamAppID: 814380,
NexusMods: {
game_domain_name: "sekiro",
game_id: 2763
},
installdir: "Sekiro",
gameName: "Sekiro",
gameExe: 'sekiro.exe',
startExe: [
{
name: 'Steam 启动',
cmd: 'steam://rungameid/814380'
},
{
name: '直接启动',
exePath: 'sekiro.exe'
}
],
archivePath: join(FileHandler.GetAppData(), "Roaming", "Sekiro"),
gameCoverImg: "https://mod.3dmgame.com/static/upload/game/185.png",
modType: [
{
id: 1,
name: '基础类型',
installPath: '\\mods',
install(mod) {
return handleMod(mod, this.installPath ?? "", true)
},
uninstall(mod) {
return handleMod(mod, this.installPath ?? "", false)
},
},
{
id: 2,
name: 'ModEngine',
installPath: "",
async install(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "dinput8.dll", true)
// Manager.generalInstall(mod, this.installPath ?? "")
// return true
},
async uninstall(mod) {
return Manager.installByFileSibling(mod, this.installPath ?? "", "dinput8.dll", false)
// Manager.generalUninstall(mod, this.installPath ?? "")
// return true
},
},
{
id: 99,
name: "未知",
installPath: "",
async install(mod) {
ElMessage.warning("未知类型, 请手动安装")
return false
},
async uninstall(mod) {
return true
}
}
],
checkModType(mod) {
// if (mod.webId == 71282) return 2
if (dictionaryList.length == 0) {
// let SekiroDictionary = (await axios.get("res/SekiroDictionary.txt")).data
let SekiroDictionary = FileHandler.readFile(join(FileHandler.getResourcesPath(), 'res', 'SekiroDictionary.txt'))
dictionaryList = SekiroDictionary.split("\r\n")
}
let engine = false
let mods = false
mod.modFiles.forEach(item => {
if (basename(item) == 'dinput8.dll') engine = true
if (dictionaryList.find(item2 => FileHandler.compareFileName(item, item2))) mods = true
})
if (engine) return 2
if (mods) return 1
return 99
}
}