public void TranslateTexts(Action <TextEntry> TranslateTextEntry, Func <string, string> TranslateNormalText, bool HandleType1 = true, bool AddAdditionalSpace = true) { var SpaceAssigner1D = new SpaceAssigner1D(); var SpaceAssigner1DUniqueAllocator = new SpaceAssigner1DUniqueAllocatorStream(SpaceAssigner1D, TextStream); var Entries = new List <TextEntry>(); var StringInfoList2 = new List <StringInfo>(); HandleTexts((Entry) => { if (Entry == null) { return; } Entries.Add(Entry); foreach (var StringInfo in Entry.OriginalTranslated) { //var StringLength = CountStringz((uint)StringOffset); //Console.WriteLine("{0}, {1}", StringInfo.StringzOffset, StringInfo.StringzLength); SpaceAssigner1D.AddAvailableWithLength(StringInfo.StringzOffset, StringInfo.StringzLength); } bool HasText = false; foreach (var StringInfo in Entry.OriginalTranslated) { if (StringInfo.Text.Length > 0) { HasText = true; } } if (HasText) { TranslateTextEntry(Entry); } }, (StringInfo) => { var Translated = TranslateNormalText(StringInfo.Text); if (Translated != null) { StringInfo.Text = Translated; StringInfoList2.Add(StringInfo); SpaceAssigner1D.AddAvailableWithLength(StringInfo.StringzOffset, StringInfo.StringzLength); } }, HandleType1); SpaceAssigner1DUniqueAllocator.FillSpacesWithZeroes(); Console.WriteLine("SpaceAssigner1D: {0}", SpaceAssigner1D.GetAvailableSpaces().Sum(Item => Item.Length)); if (AddAdditionalSpace) { SpaceAssigner1D.AddAvailableWithLength(TextStream.Length, 0x10000); Console.WriteLine("SpaceAssigner1D: {0}", SpaceAssigner1D.GetAvailableSpaces().Sum(Item => Item.Length)); } #if true var StringInfoList = Entries .SelectMany(Item => Item.OriginalTranslated) .OrderByDescending(Item => Item.Text.Length) .Concat(StringInfoList2) .ToArray() ; #else var StringInfoList = new List <StringInfo>(); foreach (var Entry in Entries) { foreach (var StringInfo in Entry.OriginalTranslated) { StringInfoList.Add(StringInfo); } } StringInfoList = StringInfoList.OrderByDescending(Item => Item.Text.Length).ToList(); #endif /* * foreach (var StringInfo in StringInfoList) * { * Console.WriteLine("{0}", StringInfo.Text); * } */ //throw (new Exception("Stop")); foreach (var StringInfo in StringInfoList) { var TextSpace = SpaceAssigner1DUniqueAllocator.AllocateUnique(StringInfo.Text, Encoding.UTF8); StringInfo.WritePointerValue((uint)TextSpace.Min); } }