Skip to content

Commit

Permalink
Fix version and text keys (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xzonn authored Oct 11, 2024
1 parent eb030f8 commit 29d56e8
Show file tree
Hide file tree
Showing 1,345 changed files with 63,572 additions and 63,589 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,19 @@ jobs:
python scripts/merge_messages.py
env:
PYTHONUTF8: 1
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Diamond and Pearl
continue-on-error: true
run: |
dotnet-script scripts/DP.csx
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Platinum
continue-on-error: true
run: |
dotnet-script scripts/Pt.csx
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Heart Gold and Soul Silver
continue-on-error: true
run: |
dotnet-script scripts/HGSS.csx
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -88,7 +83,7 @@ jobs:
run: |
Push-Location tools/
nuget restore
msbuild /p:Configuration=Release /p:TargetFramework=net48 /verbosity:minimal
dotnet publish -c Release -f net8.0 PCTRTools
Pop-Location
- name: Commit Information
id: commit
Expand All @@ -110,24 +105,19 @@ jobs:
dotnet script scripts/copy_textures.csx
env:
PYTHONUTF8: 1
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Diamond and Pearl
continue-on-error: true
run: |
scripts/DP.ps1
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Platinum
continue-on-error: true
run: |
scripts/Pt.ps1
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Heart Gold and Soul Silver
continue-on-error: true
run: |
scripts/HGSS.ps1
env:
XZ_PATCH_VERSION: "${{ github.sha }}"
- name: Upload artifacts
if: ${{ !inputs.publish }}
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
maintenance/
out/
temp/

*.bak
*.nds
Expand Down
13 changes: 8 additions & 5 deletions scripts/DP.csx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ var GAME_CODE_TO_TITLE = new Dictionary<string, string>
["P"] = "宝可梦 珍珠\nNintendo",
};

var text = File.ReadAllText("temp/DP/messages.txt");
var version = Environment.GetEnvironmentVariable("XZ_PATCH_VERSION");
text = text.Replace("${VERSION}", string.IsNullOrEmpty(version) ? "UNKNOWN" : version[..7]);
File.WriteAllText("temp/DP/messages.txt", text);

var messages = LoadMessages("temp/DP/messages.txt");
var easyChatWordsIds = new int[] {
356, // monsname
Expand All @@ -37,6 +32,14 @@ foreach (var gameCode in GAME_CODE_TO_TITLE.Keys)
{
Directory.CreateDirectory($"out/{gameCode}/data/");
Directory.CreateDirectory($"out/{gameCode}/overlay/");
if (Directory.Exists("asm/DP/build"))
{
Directory.Delete("asm/DP/build", true);
}
foreach (var path in Directory.EnumerateFiles("asm/DP", "repl_*"))
{
File.Delete(path);
}

// Edit arm9.bin
var arm9 = File.ReadAllBytes($"original_files/DP/{gameCode}/arm9.bin");
Expand Down
2 changes: 1 addition & 1 deletion scripts/DP.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PCTRTools = "tools/PCTRTools/bin/Release/PCTRTools.exe"
$PCTRTools = "tools/PCTRTools/bin/Release/net8.0/publish/PCTRTools.exe"

# Replace narc
& "$PCTRTools" "replace-narc" -i "original_files/DP/data/" -n "textures/DP/" -o "out/D/data/"
Expand Down
5 changes: 0 additions & 5 deletions scripts/HGSS.csx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ var GAME_CODE_TO_TITLE = new Dictionary<string, string>
["SS"] = "宝可梦 魂银\nNintendo",
};

var text = File.ReadAllText("temp/HGSS/messages.txt");
var version = Environment.GetEnvironmentVariable("XZ_PATCH_VERSION");
text = text.Replace("${VERSION}", string.IsNullOrEmpty(version) ? "UNKNOWN" : version[..7]);
File.WriteAllText("temp/HGSS/messages.txt", text);

var messages = LoadMessages("temp/HGSS/messages.txt");
var easyChatWordsIds = new int[] {
232, // monsname
Expand Down
2 changes: 1 addition & 1 deletion scripts/HGSS.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PCTRTools = "tools/PCTRTools/bin/Release/PCTRTools.exe"
$PCTRTools = "tools/PCTRTools/bin/Release/net8.0/publish/PCTRTools.exe"

# Replace narc
& "$PCTRTools" "replace-narc" -i "original_files/HGSS/data/" -n "textures/HGSS/" -o "out/HG/data/"
Expand Down
5 changes: 0 additions & 5 deletions scripts/Pt.csx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ var GAME_CODE_TO_TITLE = new Dictionary<string, string>
["Pt"] = "宝可梦 白金\nNintendo",
};

var text = File.ReadAllText("temp/Pt/messages.txt");
var version = Environment.GetEnvironmentVariable("XZ_PATCH_VERSION");
text = text.Replace("${VERSION}", string.IsNullOrEmpty(version) ? "UNKNOWN" : version[..7]);
File.WriteAllText("temp/Pt/messages.txt", text);

var messages = LoadMessages("temp/Pt/messages.txt");
var easyChatWordsIds = new int[] {
408, // monsname
Expand Down
2 changes: 1 addition & 1 deletion scripts/Pt.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PCTRTools = "tools/PCTRTools/bin/Release/PCTRTools.exe"
$PCTRTools = "tools/PCTRTools/bin/Release/net8.0/publish/PCTRTools.exe"

# Replace narc
& "$PCTRTools" "replace-narc" -i "original_files/Pt/data/" -n "textures/Pt/" -o "out/Pt/data/"
Expand Down
9 changes: 3 additions & 6 deletions scripts/lib.csx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ void EditBanner(string parentGame, string game, string newTitle)

void CopyFolder(string from, string to, string pattern = "*")
{
if (!Directory.Exists(to))
foreach (var file in Directory.GetFiles(from, pattern, SearchOption.AllDirectories))
{
Directory.CreateDirectory(to);
}
foreach (var file in Directory.GetFiles(from, pattern))
{
var fileTo = Path.Combine(to, Path.GetFileName(file));
var fileTo = Path.Combine(to, Path.GetRelativePath(from, file));
Directory.CreateDirectory(Path.GetDirectoryName(fileTo));
File.Copy(file, fileTo, true);
Console.WriteLine($"Copied: {file} -> {fileTo}");
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/merge_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


def merge_messages(games: list[GameInfo], texts_root: str, output_root: str):
version = os.environ.get("XZ_PATCH_VERSION", "UNKNOWN")[:7]

for game_info in games:
game = game_info["game"]
file_name = game_info["file_name"]
Expand All @@ -26,7 +28,7 @@ def merge_messages(games: list[GameInfo], texts_root: str, output_root: str):
writer.write(f"{file_id}-{lang_i}\n")

for i, line in lines.items():
line = line.replace("\\f\n", "\\f").replace("\\r\n", "\\r").replace("\n", "\\n")
line = line.replace("\\f\n", "\\f").replace("\\r\n", "\\r").replace("\n", "\\n").replace("${VERSION}", version)
writer.write(f"{i}\t{line}\n")

print(f"Merged: {game}/{file_name}")
Expand Down
Loading

0 comments on commit 29d56e8

Please sign in to comment.