mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Update 24.06.03
Stream translation text when loading. No need to allocate a few thousand strings and an array.
This commit is contained in:
parent
3ccdba4048
commit
0bbba81fca
8 changed files with 32 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>24.05.05</Version>
|
||||
<Version>24.06.03</Version>
|
||||
<LangVersion>12</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -155,6 +155,8 @@ public static partial class Util
|
|||
if (IsStringListCached(fileName, out var result))
|
||||
return result;
|
||||
var txt = GetStringResource(fileName); // Fetch File, \n to list.
|
||||
if (txt is null)
|
||||
return [];
|
||||
return LoadStringList(fileName, txt);
|
||||
}
|
||||
|
||||
|
@ -168,10 +170,8 @@ public static partial class Util
|
|||
/// Loads a text <see cref="file"/> into the program with a value of <see cref="txt"/>.
|
||||
/// </summary>
|
||||
/// <remarks>Caches the result array for future fetches.</remarks>
|
||||
public static string[] LoadStringList(string file, string? txt)
|
||||
private static string[] LoadStringList(string file, string txt)
|
||||
{
|
||||
if (txt == null)
|
||||
return [];
|
||||
string[] raw = FastSplit(txt);
|
||||
|
||||
// Make sure only one thread can write to the cache
|
||||
|
|
|
@ -1,7 +1,24 @@
|
|||
PKHeX - By Kaphotics
|
||||
http://projectpokemon.org/pkhex/
|
||||
|
||||
24/05/05 - New Update:
|
||||
24/06/03 - New Update:
|
||||
- Legality: Added automatic (basic) Trash Byte checks for Switch-era (Gen7b+) files. Further refinement & expansion in the future.
|
||||
- - Fixed: Mystery gifts distributed with nicknames no longer flag IsNicknamed as invalid.
|
||||
- Added: Entity editor move dropdown now displays the move's type on the left side.
|
||||
- Added: Entire boxes can be dragged & dropped. Must enable via setting as it is not intuitive. Drag from the Box tab rectangle.
|
||||
- Added: Report grid can now specify extra properties to show, as well as properties to hide. Change via settings.
|
||||
- Added: Gen1-3 save file language/version detection updated for more edge cases.
|
||||
- Added: Gen2-5 localization text files added for less popular languages. Thanks @abcboy101 !
|
||||
- Added: Gen3 GBA<->GC string conversion logic to handle special text entry. Thanks @abcboy101 !
|
||||
- Added: Gen4 Seal/Accessory/Backdrop editors. Thanks @abcboy101 !
|
||||
- Added: Gen5 Geonet/Unity Tower can now edit country/region data. Thanks @abcboy101 !
|
||||
- Fixed: Gen6/7 entities now save the volatile status effect rather than wiping it (see previous release notes).
|
||||
- Fixed: Gen3-7 Nidoran/Farfetch'd text char quirks updated to better align with GameFreak's mess.
|
||||
- Fixed: Gen1/2 quirks with box data have been rewritten and resolved.
|
||||
- Changed: Gen1-3 emulator save formats that store RTC data are now detected more reliably.
|
||||
- Changed: More performance improvements as always! Additionally, translations can now handle Enum localization.
|
||||
|
||||
24/05/05 - New Update: (101440) [8778313]
|
||||
- Legality: Added Regulation G.
|
||||
- Added: Entity editor can now modify battle-Status effects (Burn, Paralyze, etc). Click the bottom right corner of the window for the GUI.
|
||||
- Added: Gen5 trainer records can now be edited via Misc editor. Not documented well, but exposes the values for editing.
|
||||
|
|
|
@ -108,21 +108,19 @@ public static class WinFormsTranslator
|
|||
}
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<string> GetTranslationFile(ReadOnlySpan<char> lang)
|
||||
private static ReadOnlySpan<char> GetTranslationFile(ReadOnlySpan<char> lang)
|
||||
{
|
||||
var file = GetTranslationFileNameInternal(lang);
|
||||
// Check to see if the desired translation file exists in the same folder as the executable
|
||||
string externalLangPath = GetTranslationFileNameExternal(file);
|
||||
if (File.Exists(externalLangPath))
|
||||
{
|
||||
try { return File.ReadAllLines(externalLangPath); }
|
||||
try { return File.ReadAllText(externalLangPath); }
|
||||
catch { /* In use? Just return the internal resource. */ }
|
||||
}
|
||||
|
||||
if (Util.IsStringListCached(file, out var result))
|
||||
return result;
|
||||
var txt = (string?)Properties.Resources.ResourceManager.GetObject(file);
|
||||
return Util.LoadStringList(file, txt);
|
||||
return txt ?? "";
|
||||
}
|
||||
|
||||
private static IEnumerable<object> GetTranslatableControls(Control f)
|
||||
|
@ -320,9 +318,10 @@ public sealed class TranslationContext
|
|||
|
||||
public void Clear() => Translation.Clear();
|
||||
|
||||
public TranslationContext(ReadOnlySpan<string> content, char separator = Separator)
|
||||
public TranslationContext(ReadOnlySpan<char> content, char separator = Separator)
|
||||
{
|
||||
foreach (var line in content)
|
||||
var iterator = content.EnumerateLines();
|
||||
foreach (var line in iterator)
|
||||
LoadLine(line, separator);
|
||||
}
|
||||
|
||||
|
@ -352,18 +351,19 @@ public sealed class TranslationContext
|
|||
return Translation.Select(z => $"{z.Key}{separator}{z.Value}").OrderBy(z => z.Contains('.')).ThenBy(z => z);
|
||||
}
|
||||
|
||||
public void UpdateFrom(ReadOnlySpan<string> lines)
|
||||
public void UpdateFrom(ReadOnlySpan<char> text)
|
||||
{
|
||||
var lines = text.EnumerateLines();
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var split = line.IndexOf(Separator);
|
||||
if (split < 0)
|
||||
continue;
|
||||
var key = line[..split];
|
||||
var key = line[..split].ToString();
|
||||
|
||||
ref var exist = ref CollectionsMarshal.GetValueRefOrNullRef(Translation, key);
|
||||
if (!Unsafe.IsNullRef(ref exist))
|
||||
exist = line[(split + 1)..];
|
||||
exist = line[(split + 1)..].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue