Skip to content

Commit

Permalink
Move cur paragraph logic to earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterscotchV committed Jan 29, 2024
1 parent 65ea17e commit 6accf1f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions ButterSTT/MessageSystem/MessageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ public string GetCurrentMessage()
}
}

// If there's no queue and there's new words to display
if (WordQueue.Count <= 0 && CurParagraph.Length > 0)
{
// Fit the whole current paragraph in the message if possible
if (CurParagraph.Length <= MessageLength - CurMessageLength)
{
return string.Concat(
string.Concat(MessageWordQueue.Select(w => w.Text)),
string.Concat(
CurParagraph.Sentences.SelectMany(x => x.Words, (x, y) => y.Text)
)
)
.Trim();
}
}

// Make sure there is enough room to fit a new word in the message and
// allow space for a dash after the current text if there is already more
while (
Expand All @@ -94,22 +110,6 @@ public string GetCurrentMessage()
CurMessageLength += word.Length;
}

// If there's no queue and there's new words to display
if (WordQueue.Count <= 0 && CurParagraph.Length > 0)
{
// Fit the whole current paragraph in the message if possible
if (CurParagraph.Length <= MessageLength - CurMessageLength)
{
return string.Concat(
string.Concat(MessageWordQueue.Select(w => w.Text)),
string.Concat(
CurParagraph.Sentences.SelectMany(x => x.Words, (x, y) => y.Text)
)
)
.Trim();
}
}

var message = string.Concat(MessageWordQueue.Select(w => w.Text)).Trim();
return $"{message}{(WordQueue.Count > 0 ? "-" : "")}";
}
Expand Down

0 comments on commit 6accf1f

Please sign in to comment.