From 81247fd00b99b8394de29a816cc57782c6912cf0 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sat, 6 Nov 2021 02:49:36 +0700 Subject: [PATCH] Rename `AppendPlainString()` into `AppendString()` --- sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc | 2 +- sources/Text/MutableText.uc | 5 +++-- sources/Text/Tests/TEST_Text.uc | 12 ++++++------ sources/Text/Text.uc | 6 +++--- sources/Text/TextAPI.uc | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc b/sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc index 0319a76..ed1cb8d 100644 --- a/sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc +++ b/sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc @@ -60,7 +60,7 @@ public static function array WrapVanillaShops() { nextTrader = KF1_Trader(__().memory.Allocate(class'KF1_Trader')); nextTrader.myShopVolume = __().unreal.ActorRef(nextShopVolume); - textBuilder.Clear().AppendPlainString("trader" $ shopCounter); + textBuilder.Clear().AppendString("trader" $ shopCounter); nextTrader.myName = textBuilder.Copy(); allTraders[allTraders.length] = nextTrader; shopCounter += 1; diff --git a/sources/Text/MutableText.uc b/sources/Text/MutableText.uc index d13f148..6316528 100644 --- a/sources/Text/MutableText.uc +++ b/sources/Text/MutableText.uc @@ -162,7 +162,7 @@ public final function MutableText Append( * By default defines 'null' formatting (no color set). * @return Caller `MutableText` to allow for method chaining. */ -public final function MutableText AppendPlainString( +public final function MutableText AppendString( string source, optional Formatting defaultFormatting) { @@ -282,7 +282,8 @@ private final function SplitFormattedStringIntoBlocks(string source) local FormattedBlock nextBlock; splitBlocks.length = 0; parser = _.text.ParseString(source); - while (!parser.HasFinished()) { + while (!parser.HasFinished()) + { parser.MCharacter(nextCharacter); // New formatted block by "{" if (_.text.IsCodePoint(nextCharacter, CODEPOINT_OPEN_FORMAT)) diff --git a/sources/Text/Tests/TEST_Text.uc b/sources/Text/Tests/TEST_Text.uc index aa346fc..7168ca0 100644 --- a/sources/Text/Tests/TEST_Text.uc +++ b/sources/Text/Tests/TEST_Text.uc @@ -531,7 +531,7 @@ protected static function Test_AppendStringGet() defaultTag = __().color.GetColorTagRGB(1, 1, 1); colorTag = __().color.GetColorTag(testColor); greenTag = __().color.GetColorTagRGB(0, 255, 0); - txt.AppendPlainString("Prepare to "); + txt.AppendString("Prepare to "); txt.AppendColoredString(colorTag $ "DIE"); txt.AppendFormattedString(" and be {#00ff00 reborn}!"); TEST_ExpectTrue( txt.ToString() @@ -901,7 +901,7 @@ protected static function SubTest_ReplaceEdgeCases(Text.FormatSensitivity flag) TEST_ExpectTrue(builder.Replace(P(""), P(""),, flag).ToString() == ""); TEST_ExpectTrue( builder.Replace(P(""), P("huh"),, flag).ToString() == ""); - builder.AppendPlainString("word"); + builder.AppendString("word"); TEST_ExpectTrue( builder.Replace(P(""), P(""),, flag).ToString() == "word"); TEST_ExpectTrue( @@ -919,7 +919,7 @@ protected static function SubTest_ReplaceEdgeCases(Text.FormatSensitivity flag) .Replace(F("Just {#54af4c something}"), P("Nothing really"),, flag) .ToString() == "Nothing really"); - TEST_ExpectTrue(builder.Clear().AppendPlainString("CraZy") + TEST_ExpectTrue(builder.Clear().AppendString("CraZy") .Replace(P("CRaZy"), P("calm"), SCASE_INSENSITIVE, flag) .ToString() == "calm"); @@ -940,17 +940,17 @@ protected static function SubTest_ReplaceMainCases(Text.FormatSensitivity flag) == "Mate eight said"); Issue("`Replace()` replaces sub-`Text` incorrectly."); - builder.Clear().AppendPlainString("Do it bay bee"); + builder.Clear().AppendString("Do it bay bee"); TEST_ExpectTrue(builder.Replace(P("it"), P("this"),, flag).ToString() == "Do this bay bee"); - builder.Clear().AppendPlainString("dO It bAy BEe"); + builder.Clear().AppendString("dO It bAy BEe"); TEST_ExpectTrue( builder.Replace(P("it"), P("tHis"), SCASE_INSENSITIVE, flag) .ToString() == "dO tHis bAy BEe"); Issue("`Replace()` replaces sub-`Text` incorrectly."); - builder.Clear().AppendPlainString("he and she and it"); + builder.Clear().AppendString("he and she and it"); TEST_ExpectTrue(builder.Replace(P("and"), P("OR"),, flag) .ToString() == "he OR she OR it"); diff --git a/sources/Text/Text.uc b/sources/Text/Text.uc index 7cb061b..c31d467 100644 --- a/sources/Text/Text.uc +++ b/sources/Text/Text.uc @@ -164,7 +164,7 @@ protected final function ReformatRange( local array newFormattingChunks; start = Max(start, 0); end = Min(GetLength() - 1, end); - // Formatting right after `end`, te end of re-formatted segment + // Formatting right after `end`, the end of re-formatted segment formattingAfterChangedSegment = GetFormatting(end + 1); // 1. Copy old formatting before `start` for (i = 0; i < formattingChunks.length; i += 1) @@ -222,7 +222,7 @@ public static final function Text ConstFromPlainString(string source) local MutableText builder; local Text result; builder = MutableText(__().memory.Allocate(class'MutableText')); - result = builder.AppendPlainString(source).Copy(); + result = builder.AppendString(source).Copy(); builder.FreeSelf(); return result; } @@ -807,7 +807,7 @@ public final function bool CompareToString( local MutableText builder; local bool result; builder = MutableText(_.memory.Allocate(class'MutableText')); - builder.AppendPlainString(stringToCompare); + builder.AppendString(stringToCompare); result = Compare(builder, caseSensitivity, formatSensitivity); builder.FreeSelf(); return result; diff --git a/sources/Text/TextAPI.uc b/sources/Text/TextAPI.uc index 25dafb2..5f44383 100644 --- a/sources/Text/TextAPI.uc +++ b/sources/Text/TextAPI.uc @@ -659,7 +659,7 @@ public final function MutableText FromStringM(string source) { local MutableText newText; newText = MutableText(_.memory.Allocate(class'MutableText')); - return newText.AppendPlainString(source); + return newText.AppendString(source); } /**