Skip to content

Commit

Permalink
Add versions with Japanese Pokémon names
Browse files Browse the repository at this point in the history
  • Loading branch information
Xzonn committed Oct 24, 2024
1 parent 4bd5743 commit ff77ade
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@ jobs:
name: Patch
path: |
out/Patch-*.xzp
out/Patches-*.zip
out/Aikotoba-*.txt
- name: GitHub Release
if: ${{ inputs.publish }}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "out/Patch-*.xzp,out/Aikotoba-*.txt"
artifacts: "out/Patch-*.xzp,out/Patches-*.zip,out/Aikotoba-*.txt"
body: |
本页面下方的链接为自动构建并发布的开发版本补丁。**此版本补丁可能存在较多问题,仅供测试使用。**
Expand Down
20 changes: 20 additions & 0 deletions scripts/japanese_names.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$PCTRTools = "tools/PCTRTools/bin/Release/net8.0/publish/PCTRTools.exe"

python scripts/merge_messages_for_japanese_names.py

& "$PCTRTools" "text-import" -c "files/CharTable.txt" -i "original_files/DP/data/msgdata/msg.narc" -t "temp/DP/messages_J.txt" -o "out/DP_J/data/msgdata/msg.narc"
& "$PCTRTools" "text-import" -c "files/CharTable.txt" -i "original_files/Pt/data/msgdata/pl_msg.narc" -t "temp/Pt/messages_J.txt" -o "out/Pt_J/data/msgdata/pl_msg.narc"
& "$PCTRTools" "text-import" -c "files/CharTable.txt" -i "original_files/HGSS/data/a/0/2/7" -t "temp/HGSS/messages_J.txt" -o "out/HGSS_J/data/a/0/2/7"

dotnet script scripts/pad_text.csx "original_files/DP/data/msgdata/msg.narc" "out/DP_J/data/msgdata/msg.narc"
dotnet script scripts/pad_text.csx "original_files/Pt/data/msgdata/pl_msg.narc" "out/Pt/data/msgdata/pl_msg.narc"
dotnet script scripts/pad_text.csx "original_files/HGSS/data/a/0/2/7" "out/HGSS_J/data/a/0/2/7"

Compress-Archive -Path "out/DP_J/*" -DestinationPath "out/Patch-DP_J.zip" -Force
Move-Item out/Patch-DP_J.zip out/Patch-DP_J.xzp -Force
Compress-Archive -Path "out/Pt_J/*" -DestinationPath "out/Patch-Pt_J.zip" -Force
Move-Item out/Patch-Pt_J.zip out/Patch-Pt_J.xzp -Force
Compress-Archive -Path "out/HGSS_J/*" -DestinationPath "out/Patch-HGSS_J.zip" -Force
Move-Item out/Patch-HGSS_J.zip out/Patch-HGSS_J.xzp -Force
Compress-Archive -Path "out/Patch-*_J.xzp" -DestinationPath "out/Patches-J.zip" -Force
Remove-Item -Path "out/Patch-*_J.xzp"
44 changes: 44 additions & 0 deletions scripts/merge_messages_for_japanese_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os

from helper import DIR_TEMP, DIR_TEXTS, GAMES, GameInfo, load_game_data


def merge_messages_for_japanese_names(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"].replace(".txt", "_J.txt")
languages = game_info["languages"]
game_data = load_game_data(game_info, texts_root)

file_ids = sorted(game_data[languages[0]].keys())
os.makedirs(f"{output_root}/{game}", exist_ok=True)
with open(f"{output_root}/{game}/{file_name}", "w", -1, "utf8", None, "\n") as writer:
writer.write("#4\n")
for lang_i, language in enumerate(languages):
for file_id in file_ids:
if f"{game}-{file_id}" in {"DP-324", "DP-356", "Pt-369", "Pt-408", "HGSS-198", "HGSS-232"}:
continue
lines = game_data[language].get(file_id, game_data[languages[0]][file_id])
if len(lines) == 0:
continue

if len(languages) == 1:
writer.write(f"{file_id}\n")
else:
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").replace("${VERSION}", f"{version}+J")
)
if f"{game}-{file_id}" in {"DP-13", "DP-23", "Pt-17"} and line.startswith("盒子"):
continue
writer.write(f"{i}\t{line}\n")

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


if __name__ == "__main__":
merge_messages_for_japanese_names(GAMES, DIR_TEXTS, DIR_TEMP)

0 comments on commit ff77ade

Please sign in to comment.