-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConvertAllGameDataToStrings.ps1
81 lines (72 loc) · 2.37 KB
/
ConvertAllGameDataToStrings.ps1
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
[CmdletBinding()]
param (
# Output file type (Required)
# Check out help message in ConvertFrom-GameData.ps1
[Parameter(Mandatory)]
[string]
$FileType,
# Languages
# Check out help message in ConvertFrom-GameData.ps1
[Parameter()]
[string[]]
$Languages,
# Game version (Default: latest)
# Default 'latest' takes the last folder in dump directory.
# Otherwise specify the _name of the folder_ that you want
# to dump from.
[Parameter()]
[string]
$Version = 'latest',
# Overwrite EXD(s) if they exist? (Default: No)
[Parameter()]
[switch]
$Overwrite = $false,
# Compress strings files (Default: No)
# Some file formats like XLIFF may allow compressing
# by dropping all whitespace except the one in strings.
# This switch has no effect on file types without
# compression support.
[Parameter()]
[switch]
$Compress = $false
)
# Start importing stuff
$ErrorActionPreference_before = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
Import-Module -Name "./lib/file_types/$FileType.psm1"
$CONFIG = Import-PowerShellDataFile -Path "./config/config.psd1"
foreach ($path_name in [string[]] $CONFIG.PATHS.Keys) {
try {
$CONFIG.PATHS.$path_name = (Resolve-Path -Path $CONFIG.PATHS.$path_name).Path
}
catch {
Write-Error ("Path {0} could not be resolved." -f $CONFIG.PATHS.$path_name)
return 2
}
}
$ErrorActionPreference = $ErrorActionPreference_before
# Finish importing stuff
if ($Version -eq 'latest') {
$version_list = Get-ChildItem -Path $CONFIG.PATHS.DUMP_DIR -Directory
$dump_ver_path = $version_list[-1]
} else {
$dump_ver_path = "{0}/{1}" -f $CONFIG.PATHS.DUMP_DIR, $Version
if (-not $(Test-Path -Path $dump_ver_path)) {
throw "Version $Version was not found in dump folder."
}
}
$exh_list = Get-ChildItem -Path "$dump_ver_path/*.exh" -Recurse -File
foreach ($exh in $exh_list) {
$sub_path = $exh.FullName.Replace("$dump_ver_path/",'') -creplace '\.exh$', ''
$strings_path = "{0}/{1}" -f $CONFIG.PATHS.STRINGS_DIR, $sub_path
$result = ./ConvertFrom-GameData.ps1 `
-ExhPath $exh `
-FileType $FileType `
-Overwrite:$Overwrite `
-Destination $strings_path `
-Compress:$Compress
if ($result -eq 2) {
Write-Error "Critical error, stopping."
return
}
}