diff --git a/ButterSTT/MessageSystem/MessageQueue.cs b/ButterSTT/MessageSystem/MessageQueue.cs index 98771fa..03f83a5 100644 --- a/ButterSTT/MessageSystem/MessageQueue.cs +++ b/ButterSTT/MessageSystem/MessageQueue.cs @@ -4,8 +4,24 @@ namespace ButterSTT.MessageSystem { public class MessageQueue { + /// + /// The maximum length of the message. Default is 144. + /// public int MessageLength = 144; + + /// + /// The maximum number of words to dequeue at once, regardless of their expiration time. Default is 6. + /// public int MaxWordsDequeued = 6; + + /// + /// The number of characters to allow between the current paragraph and the message length. Default is 36. + /// + public int RealtimeQueuePadding = 36; + + /// + /// The amount of time before a word will expire. + /// public TimeSpan WordTime = TimeSpan.FromSeconds(3); public Paragraph CurParagraph; @@ -100,10 +116,15 @@ public void QueueParagraphToFit(int padding = 0) private void ProgressWordQueue() { - // Make sure there is enough room to fit a new word in the message + // Make sure there is enough room to fit a new word in the message, + // if the word is too long then just give up and pass it in anyways + // TODO: Maybe handle long words better? Or maybe it's not worthwhile while ( WordQueue.TryPeek(out var newWord) - && CurMessageLength + newWord.Length < MessageLength + && ( + CurMessageLength + newWord.Length <= MessageLength + || newWord.Length > MessageLength + ) ) { var word = WordQueue.Dequeue(); @@ -136,10 +157,7 @@ public string GetCurrentMessage() } if (CurParagraph.Length >= MessageLength) - { - // Queue with a padding of the max words times the average word length - QueueParagraphToFit(MaxWordsDequeued * 6); - } + QueueParagraphToFit(RealtimeQueuePadding); ProgressWordQueue();