-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheFootball-ePatchManager.ps1
More file actions
407 lines (331 loc) · 14.7 KB
/
eFootball-ePatchManager.ps1
File metadata and controls
407 lines (331 loc) · 14.7 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# eFootball Mod Manager v1.0
$GamePath = "C:\Program Files (x86)\Steam\steamapps\common\eFootball"
$ModPath = "C:\Games\epatch"
$BackupBasePath = "C:\Games\efootbackupEPATCH"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
function Write-ColorText {
param([string]$Text, [string]$Color = "White")
Write-Host $Text -ForegroundColor $Color
}
function Write-Header {
param([string]$Text)
Write-Host ""
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host " $Text" -ForegroundColor Cyan
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host ""
}
function Write-Step {
param([string]$Text)
Write-Host "[→] $Text" -ForegroundColor Yellow
}
function Write-Success {
param([string]$Text)
Write-Host "[✓] $Text" -ForegroundColor Green
}
function Write-Error {
param([string]$Text)
Write-Host "[✗] $Text" -ForegroundColor Red
}
function Write-Info {
param([string]$Text)
Write-Host "[i] $Text" -ForegroundColor Blue
}
function Test-Paths {
$errors = @()
if (-not (Test-Path "$GamePath\eFootball\Binaries\Win64\eFootball.exe")) {
$errors += "Неверный путь к игре: $GamePath"
}
if (-not (Test-Path $ModPath)) {
$errors += "Папка с модом не найдена: $ModPath"
}
if (-not (Test-Path $BackupBasePath)) {
New-Item -ItemType Directory -Path $BackupBasePath -Force | Out-Null
Write-Success "Создана папка для бэкапов: $BackupBasePath"
}
if ($errors.Count -gt 0) {
Write-Header "ОШИБКА КОНФИГУРАЦИИ"
foreach ($error in $errors) {
Write-Error $error
}
Write-Host ""
Write-Host "Нажмите любую клавишу для выхода..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit
}
}
function Create-Backup {
Write-Header "СОЗДАНИЕ РЕЗЕРВНОЙ КОПИИ"
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$backupPath = Join-Path $BackupBasePath "backup_$timestamp"
Write-Info "Создается бэкап: backup_$timestamp"
Write-Host ""
New-Item -ItemType Directory -Path $backupPath -Force | Out-Null
$modExtraFilesPath = Join-Path $backupPath "mod_extra_files.txt"
Write-Step "Анализ файлов мода..."
Write-Host ""
$modFiles = Get-ChildItem -Path $ModPath -Recurse -File
$totalFiles = $modFiles.Count
$current = 0
$backedUp = 0
$newFiles = 0
foreach ($modFile in $modFiles) {
$current++
$relativePath = $modFile.FullName.Substring($ModPath.Length)
$gameFile = Join-Path $GamePath $relativePath
$backupFile = Join-Path $backupPath $relativePath
if ($current % 10 -eq 0 -or $current -eq $totalFiles) {
Write-Progress -Activity "Обработка файлов" -Status "Файл $current из $totalFiles" -PercentComplete (($current / $totalFiles) * 100)
}
$backupDir = Split-Path $backupFile -Parent
if (-not (Test-Path $backupDir)) {
New-Item -ItemType Directory -Path $backupDir -Force | Out-Null
}
if (Test-Path $gameFile) {
Copy-Item -Path $gameFile -Destination $backupFile -Force
Write-Host "[OK] $relativePath" -ForegroundColor Green
$backedUp++
}
else {
Add-Content -Path $modExtraFilesPath -Value $relativePath -Encoding UTF8
Write-Host "[НОВЫЙ] $relativePath" -ForegroundColor Cyan
$newFiles++
}
}
Write-Progress -Activity "Обработка файлов" -Completed
$infoPath = Join-Path $backupPath "backup_info.txt"
@"
Дата создания: $(Get-Date -Format "dd.MM.yyyy HH:mm:ss")
Всего файлов в моде: $totalFiles
Скопировано оригинальных файлов: $backedUp
Новых файлов мода: $newFiles
"@ | Out-File -FilePath $infoPath -Encoding UTF8
Write-Host ""
Write-Header "БЭКАП СОЗДАН УСПЕШНО"
Write-Success "Папка: backup_$timestamp"
Write-Success "Скопировано оригинальных файлов: $backedUp"
Write-Info "Новых файлов мода (будут удалены при restore): $newFiles"
Write-Host ""
}
function Install-Mod {
Write-Header "УСТАНОВКА МОДА"
Write-Info "Копирование файлов мода в папку игры..."
Write-Host ""
$modFiles = Get-ChildItem -Path $ModPath -Recurse -File
$totalFiles = $modFiles.Count
$current = 0
foreach ($modFile in $modFiles) {
$current++
$relativePath = $modFile.FullName.Substring($ModPath.Length)
$gameFile = Join-Path $GamePath $relativePath
if ($current % 10 -eq 0 -or $current -eq $totalFiles) {
Write-Progress -Activity "Копирование файлов мода" -Status "Файл $current из $totalFiles" -PercentComplete (($current / $totalFiles) * 100)
}
$gameDir = Split-Path $gameFile -Parent
if (-not (Test-Path $gameDir)) {
New-Item -ItemType Directory -Path $gameDir -Force | Out-Null
}
Copy-Item -Path $modFile.FullName -Destination $gameFile -Force
}
Write-Progress -Activity "Копирование файлов мода" -Completed
Write-Host ""
Write-Header "МОД УСТАНОВЛЕН"
Write-Success "Скопировано файлов: $totalFiles"
Write-Host ""
}
function Get-Backups {
$backups = Get-ChildItem -Path $BackupBasePath -Directory | Where-Object { $_.Name -like "backup_*" } | Sort-Object Name -Descending
return $backups
}
function Restore-Backup {
Write-Header "ВОССТАНОВЛЕНИЕ ИЗ БЭКАПА"
$backups = Get-Backups
if ($backups.Count -eq 0) {
Write-Error "Не найдено ни одного бэкапа!"
Write-Host ""
return
}
Write-Info "Доступные бэкапы:"
Write-Host ""
for ($i = 0; $i -lt $backups.Count; $i++) {
$backup = $backups[$i]
$infoPath = Join-Path $backup.FullName "backup_info.txt"
Write-Host " [$($i + 1)] " -ForegroundColor Yellow -NoNewline
Write-Host $backup.Name -ForegroundColor White
if (Test-Path $infoPath) {
$info = Get-Content $infoPath -Encoding UTF8
foreach ($line in $info) {
Write-Host " $line" -ForegroundColor Gray
}
}
Write-Host ""
}
Write-Host " [0] Отмена" -ForegroundColor Red
Write-Host ""
$choice = Read-Host "Выберите номер бэкапа для восстановления"
if ($choice -eq "0" -or $choice -eq "") {
Write-Info "Отменено."
Write-Host ""
return
}
$selectedIndex = [int]$choice - 1
if ($selectedIndex -lt 0 -or $selectedIndex -ge $backups.Count) {
Write-Error "Неверный номер!"
Write-Host ""
return
}
$selectedBackup = $backups[$selectedIndex]
$backupPath = $selectedBackup.FullName
Write-Host ""
Write-Step "Восстановление из: $($selectedBackup.Name)"
Write-Host ""
$modExtraFilesPath = Join-Path $backupPath "mod_extra_files.txt"
if (Test-Path $modExtraFilesPath) {
Write-Step "ШАГ 1/2: Удаление дополнительных файлов мода..."
Write-Host ""
$extraFiles = Get-Content $modExtraFilesPath -Encoding UTF8
$deleted = 0
$notFound = 0
foreach ($relativePath in $extraFiles) {
$fileToDelete = Join-Path $GamePath $relativePath
if (Test-Path $fileToDelete) {
Remove-Item -Path $fileToDelete -Force
Write-Host "[УДАЛЕНО] $relativePath" -ForegroundColor Yellow
$deleted++
}
else {
Write-Host "[ПРОПУСК] $relativePath" -ForegroundColor Gray
$notFound++
}
}
Write-Host ""
Write-Success "Удалено файлов: $deleted"
if ($notFound -gt 0) {
Write-Info "Пропущено (уже отсутствуют): $notFound"
}
Write-Host ""
}
Write-Step "ШАГ 2/2: Восстановление оригинальных файлов..."
Write-Host ""
$backupFiles = Get-ChildItem -Path $backupPath -Recurse -File | Where-Object { $_.Name -ne "mod_extra_files.txt" -and $_.Name -ne "backup_info.txt" }
$totalFiles = $backupFiles.Count
$current = 0
foreach ($backupFile in $backupFiles) {
$current++
$relativePath = $backupFile.FullName.Substring($backupPath.Length)
$gameFile = Join-Path $GamePath $relativePath
if ($current % 10 -eq 0 -or $current -eq $totalFiles) {
Write-Progress -Activity "Восстановление файлов" -Status "Файл $current из $totalFiles" -PercentComplete (($current / $totalFiles) * 100)
}
$gameDir = Split-Path $gameFile -Parent
if (-not (Test-Path $gameDir)) {
New-Item -ItemType Directory -Path $gameDir -Force | Out-Null
}
Copy-Item -Path $backupFile.FullName -Destination $gameFile -Force
}
Write-Progress -Activity "Восстановление файлов" -Completed
Write-Host ""
Write-Header "ВОССТАНОВЛЕНИЕ ЗАВЕРШЕНО"
Write-Success "Игра восстановлена в оригинальное состояние"
Write-Success "Восстановлено файлов: $totalFiles"
Write-Host ""
}
function Show-Menu {
Clear-Host
Write-Host ""
Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
Write-Host "║ ║" -ForegroundColor Cyan
Write-Host "║ eFootball Mod Manager v1.0 ║" -ForegroundColor Cyan
Write-Host "║ Менеджер модов для eFootball ║" -ForegroundColor Cyan
Write-Host "║ ║" -ForegroundColor Cyan
Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Cyan
Write-Host ""
Write-Host " Путь к игре: " -NoNewline
Write-Host $GamePath -ForegroundColor Yellow
Write-Host " Путь к моду: " -NoNewline
Write-Host $ModPath -ForegroundColor Yellow
Write-Host " Папка бэкапов: " -NoNewline
Write-Host $BackupBasePath -ForegroundColor Yellow
Write-Host ""
Write-Host "────────────────────────────────────────────────────────────" -ForegroundColor Gray
Write-Host ""
Write-Host " [1] " -ForegroundColor Green -NoNewline
Write-Host "Создать новый бэкап оригинальных файлов"
Write-Host ""
Write-Host " [2] " -ForegroundColor Yellow -NoNewline
Write-Host "Установить мод в игру"
Write-Host ""
Write-Host " [3] " -ForegroundColor Blue -NoNewline
Write-Host "Восстановить оригинальные файлы из бэкапа"
Write-Host ""
Write-Host " [4] " -ForegroundColor Magenta -NoNewline
Write-Host "Показать список бэкапов"
Write-Host ""
Write-Host " [0] " -ForegroundColor Red -NoNewline
Write-Host "Выход"
Write-Host ""
Write-Host "────────────────────────────────────────────────────────────" -ForegroundColor Gray
Write-Host ""
}
function Show-BackupList {
Write-Header "СПИСОК БЭКАПОВ"
$backups = Get-Backups
if ($backups.Count -eq 0) {
Write-Error "Не найдено ни одного бэкапа!"
Write-Host ""
return
}
foreach ($backup in $backups) {
$infoPath = Join-Path $backup.FullName "backup_info.txt"
Write-Host "📦 " -NoNewline -ForegroundColor Yellow
Write-Host $backup.Name -ForegroundColor White
if (Test-Path $infoPath) {
$info = Get-Content $infoPath -Encoding UTF8
foreach ($line in $info) {
Write-Host " $line" -ForegroundColor Gray
}
}
$size = (Get-ChildItem -Path $backup.FullName -Recurse | Measure-Object -Property Length -Sum).Sum
$sizeMB = [math]::Round($size / 1MB, 2)
Write-Host " Размер: $sizeMB MB" -ForegroundColor Gray
Write-Host ""
}
}
Test-Paths
while ($true) {
Show-Menu
$choice = Read-Host "Выберите действие"
switch ($choice) {
"1" {
Create-Backup
Write-Host "Нажмите любую клавишу для продолжения..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
"2" {
Install-Mod
Write-Host "Нажмите любую клавишу для продолжения..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
"3" {
Restore-Backup
Write-Host "Нажмите любую клавишу для продолжения..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
"4" {
Show-BackupList
Write-Host "Нажмите любую клавишу для продолжения..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
"0" {
Write-Host ""
Write-ColorText "Всего доброго! До встречи!" "Cyan"
Write-Host ""
exit
}
default {
Write-Error "Неверный выбор! Используйте цифры 0-4."
Start-Sleep -Seconds 1
}
}
}