mirror of
https://github.com/Raymonf/whack.git
synced 2024-11-24 00:20:10 +01:00
Use EnglishMessageUSA instead of JapaneseMessage (#1)
This commit is contained in:
commit
0b1e357542
@ -4,3 +4,7 @@ A collection of tools and other hacky (read: ugly) things I've made for myself,
|
||||
|
||||
* galliumhook - injects `mercuryhook.dll` (whatever that may be) and forces created windows to be 1080x1920 regardless of screen resolution
|
||||
* WTT - translation tool that exports message tables to and imports from toml files [(readme)](WTT/README.md)
|
||||
|
||||
### Changelog
|
||||
|
||||
* 11/8/2022: WTT has received an update that will impact your workflow if you're using this tool. See the tool's readme for more details.
|
@ -2,9 +2,9 @@
|
||||
|
||||
Based on [UAssetAPI](https://github.com/atenfyr/UAssetAPI).
|
||||
|
||||
It replaces existing strings, so you can't add new ones. Tested on version 3.7.10.
|
||||
It replaces existing EnglishMessageUSA strings, so you can't add new ones for whatever reason. Tested on version 3.7.10.
|
||||
|
||||
**Beware:** There is no error handling since this tool was originally meant for my personal use.
|
||||
**Beware:** There is very little error handling since this tool was originally meant for my personal use. **You should check the changelog out if you've used this in the past.**
|
||||
|
||||
### Compilation
|
||||
|
||||
@ -14,12 +14,28 @@ Compile like a normal .NET 6 application. WTT.sln has everything you will need i
|
||||
|
||||
When it asks, put in the path to your `Message` directory. Usually, this would be `C:\whatever\WindowsNoEditor\Mercury\Content\Message`.
|
||||
|
||||
Then, choose a mode:
|
||||
Then, decide whether you want to use override mode or not. The default option (when no input is received) is to enable it. When override mode is enabled, bulk import mode will not ask for a path to the uasset directory or the output uasset directory, instead opting to read in and overwrite the uasset files chosen in the first step.
|
||||
|
||||
* **bulk_export** - bulk export all the `uasset` files in the path given as toml files in the same directory
|
||||
* **bulk_import** - bulk import all the `toml` files
|
||||
Finally, choose a mode:
|
||||
|
||||
* **bulk_export** or **be** - bulk export all the `uasset` files in the path given as toml files in the same directory
|
||||
* **bulk_import** or **bi** - bulk import all the `toml` files
|
||||
* directory of TOML files: where your TOML files are
|
||||
* uasset directory: where your uasset files are (useful as a way to back up the original uasset files)
|
||||
* output uasset directory: where your new uasset files will be put
|
||||
* **e** - export single toml file from uasset
|
||||
* **i** - import single uasset file from toml
|
||||
|
||||
If you want to toggle override mode, use the **o** command.
|
||||
|
||||
### Changelog
|
||||
|
||||
* 11/8/2022
|
||||
|
||||
WTT now focuses on editing the `EnglishMessageUSA` column in the strings. Feel free to ask me how you can make your game read that column instead of the `JapaneseMessage` column if you don't know how!
|
||||
|
||||
The side effect is that previously exported TOML files need to be updated. Commit `3cfb5fbc63a536f0307e34107f154763869ceb4e` is perfect for updating your files. It'll read in the `JapaneseMessage` values from your translated TOML files, and update the `EnglishMessageUSA` columns **if the TOML `JapaneseMessage` string is not equal to the value in the uasset `JapaneseMessage`**.
|
||||
|
||||
In other words, you should use that specific commit and specify a path to a Japanese (_initially_ untouched) `Message` folder. The importer in that commit will update the `EnglishMessageUSA` column instead of the Japanese column, even though it's reading from `JapaneseMessage` in your TOML values.
|
||||
|
||||
After that, the latest commit (`dedc8f9fa6fe0d946d83050b0d7a74462ce1436c` or newer) will export Japanese, English, and Korean as separate strings in the TOML file, while outputting `false` for nonexistent (null) values.
|
@ -3,12 +3,13 @@ using UAssetAPI;
|
||||
using UAssetAPI.PropertyTypes.Structs;
|
||||
using UAssetAPI.UnrealTypes;
|
||||
using WhackTranslationTool.Exceptions;
|
||||
using WTT;
|
||||
|
||||
namespace WhackTranslationTool;
|
||||
|
||||
|
||||
public class TableExporter
|
||||
{
|
||||
private readonly char[] _multilineChars = { '\n', '"' };
|
||||
private readonly ExportSettings _settings;
|
||||
private Dictionary<string, TomlTable> strings = new();
|
||||
|
||||
@ -33,22 +34,10 @@ public class TableExporter
|
||||
private TomlTable MessageDataToTomlTable(StructPropertyData entry)
|
||||
{
|
||||
var tomlTable = new TomlTable();
|
||||
|
||||
var japaneseValue = (entry.Value[0].RawValue as FString)?.Value;
|
||||
if (japaneseValue != null)
|
||||
tomlTable.Add("JapaneseMessage", new TomlString
|
||||
{
|
||||
IsMultiline = japaneseValue.IndexOfAny(_multilineChars) != -1,
|
||||
Value = japaneseValue
|
||||
});
|
||||
|
||||
var koreanValue = (entry.Value[6].RawValue as FString)?.Value;
|
||||
if (koreanValue != null)
|
||||
tomlTable.Add("KoreanMessage", new TomlString
|
||||
{
|
||||
IsMultiline = koreanValue.IndexOfAny(_multilineChars) != -1,
|
||||
Value = koreanValue
|
||||
});
|
||||
|
||||
tomlTable.AddMessage(entry, 0, "JapaneseMessage");
|
||||
tomlTable.AddMessage(entry, 1, "EnglishMessageUSA");
|
||||
tomlTable.AddMessage(entry, 6, "KoreanMessage");
|
||||
|
||||
return tomlTable;
|
||||
}
|
||||
@ -56,22 +45,11 @@ public class TableExporter
|
||||
private TomlTable CharacterMessageDataToTomlTable(StructPropertyData entry)
|
||||
{
|
||||
var tomlTable = new TomlTable();
|
||||
|
||||
var japaneseValue = (entry.Value[3].RawValue as FString)?.Value;
|
||||
if (japaneseValue != null)
|
||||
tomlTable.Add("JapaneseMessage", new TomlString
|
||||
{
|
||||
IsMultiline = japaneseValue.IndexOfAny(_multilineChars) != -1,
|
||||
Value = japaneseValue
|
||||
});
|
||||
|
||||
var koreanValue = (entry.Value[9].RawValue as FString)?.Value;
|
||||
if (koreanValue != null)
|
||||
tomlTable.Add("KoreanMessage", new TomlString
|
||||
{
|
||||
IsMultiline = koreanValue.IndexOfAny(_multilineChars) != -1,
|
||||
Value = koreanValue
|
||||
});
|
||||
|
||||
tomlTable.AddMessage(entry, 3, "JapaneseMessage");
|
||||
tomlTable.AddMessage(entry, 4, "EnglishMessageUSA");
|
||||
if (_settings.ExportKoreanMessage)
|
||||
tomlTable.AddMessage(entry, 9, "KoreanMessage");
|
||||
|
||||
return tomlTable;
|
||||
}
|
||||
|
@ -74,7 +74,10 @@ public class TableImporter
|
||||
throw new InvalidDataException($"key '{key}' is invalid");
|
||||
if (strings.ContainsKey(key))
|
||||
throw new DuplicateKeyException($"duplicate key '{key}' found for file {tomlPath} ({asset.FilePath})");
|
||||
strings.Add(key, value.HasKey("JapaneseMessage") ? value["JapaneseMessage"].AsString.Value : null);
|
||||
|
||||
// we now output the boolean false for null values since toml doesn't have null
|
||||
var exists = value.HasKey("EnglishMessageUSA") && value["EnglishMessageUSA"].IsString;
|
||||
strings.Add(key, exists ? value["EnglishMessageUSA"].AsString.Value : null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,14 +96,18 @@ public class TableImporter
|
||||
continue;
|
||||
}
|
||||
|
||||
// index of JapaneseMessage
|
||||
var index = entry.StructType.Value.Value switch
|
||||
// index of EnglishMessageUSA
|
||||
var engIndex = entry.StructType.Value.Value switch
|
||||
{
|
||||
"MessageData" => 0,
|
||||
"CharaMessageData" => 3,
|
||||
"MessageData" => 1,
|
||||
"CharaMessageData" => 4,
|
||||
_ => throw new Exception($"Unhandled type '{entry.StructType}'")
|
||||
};
|
||||
entry.Value[index].SetObject(FString.FromString(strings[name]));
|
||||
|
||||
if (strings[name] != null)
|
||||
{
|
||||
entry.Value[engIndex].SetObject(FString.FromString(strings[name]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
29
WTT/WTT/TomlTableExtensions.cs
Normal file
29
WTT/WTT/TomlTableExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tommy;
|
||||
using UAssetAPI.PropertyTypes.Structs;
|
||||
using UAssetAPI.UnrealTypes;
|
||||
|
||||
namespace WTT
|
||||
{
|
||||
public static class TomlTableExtensions
|
||||
{
|
||||
private readonly static char[] _multilineChars = { '\n', '"' };
|
||||
|
||||
public static void AddMessage(this TomlTable tomlTable, StructPropertyData entry, int index, string key)
|
||||
{
|
||||
var value = (entry.Value[index].RawValue as FString)?.Value;
|
||||
if (value != null)
|
||||
tomlTable.Add(key, new TomlString
|
||||
{
|
||||
IsMultiline = value.IndexOfAny(_multilineChars) != -1,
|
||||
Value = value
|
||||
});
|
||||
else
|
||||
tomlTable.Add(key, false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user