Browse Source

Rename `AppendPlainString()` into `AppendString()`

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
81247fd00b
  1. 2
      sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc
  2. 5
      sources/Text/MutableText.uc
  3. 12
      sources/Text/Tests/TEST_Text.uc
  4. 6
      sources/Text/Text.uc
  5. 2
      sources/Text/TextAPI.uc

2
sources/Gameplay/KF1Frontend/Trading/KF1_Trader.uc

@ -60,7 +60,7 @@ public static function array<KF1_Trader> WrapVanillaShops()
{ {
nextTrader = KF1_Trader(__().memory.Allocate(class'KF1_Trader')); nextTrader = KF1_Trader(__().memory.Allocate(class'KF1_Trader'));
nextTrader.myShopVolume = __().unreal.ActorRef(nextShopVolume); nextTrader.myShopVolume = __().unreal.ActorRef(nextShopVolume);
textBuilder.Clear().AppendPlainString("trader" $ shopCounter); textBuilder.Clear().AppendString("trader" $ shopCounter);
nextTrader.myName = textBuilder.Copy(); nextTrader.myName = textBuilder.Copy();
allTraders[allTraders.length] = nextTrader; allTraders[allTraders.length] = nextTrader;
shopCounter += 1; shopCounter += 1;

5
sources/Text/MutableText.uc

@ -162,7 +162,7 @@ public final function MutableText Append(
* By default defines 'null' formatting (no color set). * By default defines 'null' formatting (no color set).
* @return Caller `MutableText` to allow for method chaining. * @return Caller `MutableText` to allow for method chaining.
*/ */
public final function MutableText AppendPlainString( public final function MutableText AppendString(
string source, string source,
optional Formatting defaultFormatting) optional Formatting defaultFormatting)
{ {
@ -282,7 +282,8 @@ private final function SplitFormattedStringIntoBlocks(string source)
local FormattedBlock nextBlock; local FormattedBlock nextBlock;
splitBlocks.length = 0; splitBlocks.length = 0;
parser = _.text.ParseString(source); parser = _.text.ParseString(source);
while (!parser.HasFinished()) { while (!parser.HasFinished())
{
parser.MCharacter(nextCharacter); parser.MCharacter(nextCharacter);
// New formatted block by "{<color>" // New formatted block by "{<color>"
if (_.text.IsCodePoint(nextCharacter, CODEPOINT_OPEN_FORMAT)) if (_.text.IsCodePoint(nextCharacter, CODEPOINT_OPEN_FORMAT))

12
sources/Text/Tests/TEST_Text.uc

@ -531,7 +531,7 @@ protected static function Test_AppendStringGet()
defaultTag = __().color.GetColorTagRGB(1, 1, 1); defaultTag = __().color.GetColorTagRGB(1, 1, 1);
colorTag = __().color.GetColorTag(testColor); colorTag = __().color.GetColorTag(testColor);
greenTag = __().color.GetColorTagRGB(0, 255, 0); greenTag = __().color.GetColorTagRGB(0, 255, 0);
txt.AppendPlainString("Prepare to "); txt.AppendString("Prepare to ");
txt.AppendColoredString(colorTag $ "DIE"); txt.AppendColoredString(colorTag $ "DIE");
txt.AppendFormattedString(" and be {#00ff00 reborn}!"); txt.AppendFormattedString(" and be {#00ff00 reborn}!");
TEST_ExpectTrue( txt.ToString() 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(""),, flag).ToString() == "");
TEST_ExpectTrue( TEST_ExpectTrue(
builder.Replace(P(""), P("huh"),, flag).ToString() == ""); builder.Replace(P(""), P("huh"),, flag).ToString() == "");
builder.AppendPlainString("word"); builder.AppendString("word");
TEST_ExpectTrue( TEST_ExpectTrue(
builder.Replace(P(""), P(""),, flag).ToString() == "word"); builder.Replace(P(""), P(""),, flag).ToString() == "word");
TEST_ExpectTrue( TEST_ExpectTrue(
@ -919,7 +919,7 @@ protected static function SubTest_ReplaceEdgeCases(Text.FormatSensitivity flag)
.Replace(F("Just {#54af4c something}"), P("Nothing really"),, flag) .Replace(F("Just {#54af4c something}"), P("Nothing really"),, flag)
.ToString() .ToString()
== "Nothing really"); == "Nothing really");
TEST_ExpectTrue(builder.Clear().AppendPlainString("CraZy") TEST_ExpectTrue(builder.Clear().AppendString("CraZy")
.Replace(P("CRaZy"), P("calm"), SCASE_INSENSITIVE, flag) .Replace(P("CRaZy"), P("calm"), SCASE_INSENSITIVE, flag)
.ToString() .ToString()
== "calm"); == "calm");
@ -940,17 +940,17 @@ protected static function SubTest_ReplaceMainCases(Text.FormatSensitivity flag)
== "Mate eight said"); == "Mate eight said");
Issue("`Replace()` replaces sub-`Text` incorrectly."); 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() TEST_ExpectTrue(builder.Replace(P("it"), P("this"),, flag).ToString()
== "Do this bay bee"); == "Do this bay bee");
builder.Clear().AppendPlainString("dO It bAy BEe"); builder.Clear().AppendString("dO It bAy BEe");
TEST_ExpectTrue( TEST_ExpectTrue(
builder.Replace(P("it"), P("tHis"), SCASE_INSENSITIVE, flag) builder.Replace(P("it"), P("tHis"), SCASE_INSENSITIVE, flag)
.ToString() .ToString()
== "dO tHis bAy BEe"); == "dO tHis bAy BEe");
Issue("`Replace()` replaces sub-`Text` incorrectly."); 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) TEST_ExpectTrue(builder.Replace(P("and"), P("OR"),, flag)
.ToString() .ToString()
== "he OR she OR it"); == "he OR she OR it");

6
sources/Text/Text.uc

@ -164,7 +164,7 @@ protected final function ReformatRange(
local array<FormattingChunk> newFormattingChunks; local array<FormattingChunk> newFormattingChunks;
start = Max(start, 0); start = Max(start, 0);
end = Min(GetLength() - 1, end); 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); formattingAfterChangedSegment = GetFormatting(end + 1);
// 1. Copy old formatting before `start` // 1. Copy old formatting before `start`
for (i = 0; i < formattingChunks.length; i += 1) for (i = 0; i < formattingChunks.length; i += 1)
@ -222,7 +222,7 @@ public static final function Text ConstFromPlainString(string source)
local MutableText builder; local MutableText builder;
local Text result; local Text result;
builder = MutableText(__().memory.Allocate(class'MutableText')); builder = MutableText(__().memory.Allocate(class'MutableText'));
result = builder.AppendPlainString(source).Copy(); result = builder.AppendString(source).Copy();
builder.FreeSelf(); builder.FreeSelf();
return result; return result;
} }
@ -807,7 +807,7 @@ public final function bool CompareToString(
local MutableText builder; local MutableText builder;
local bool result; local bool result;
builder = MutableText(_.memory.Allocate(class'MutableText')); builder = MutableText(_.memory.Allocate(class'MutableText'));
builder.AppendPlainString(stringToCompare); builder.AppendString(stringToCompare);
result = Compare(builder, caseSensitivity, formatSensitivity); result = Compare(builder, caseSensitivity, formatSensitivity);
builder.FreeSelf(); builder.FreeSelf();
return result; return result;

2
sources/Text/TextAPI.uc

@ -659,7 +659,7 @@ public final function MutableText FromStringM(string source)
{ {
local MutableText newText; local MutableText newText;
newText = MutableText(_.memory.Allocate(class'MutableText')); newText = MutableText(_.memory.Allocate(class'MutableText'));
return newText.AppendPlainString(source); return newText.AppendString(source);
} }
/** /**

Loading…
Cancel
Save