public string GetParsedCommands(MessageLine line)
        {
            //TODO(Robin): Move to CommandTokens?
            Func <string, bool, string> purify = (s, replaceEnvironment) =>
            {
                s = s.Replace("\\n", "\n")
                    .Replace("$k\n", "$k\\n");
                if (replaceEnvironment)
                {
                    s = s.Replace("\n", Environment.NewLine);
                }
                return(s);
            };

            if (line.SpokenText != string.Empty)
            {
                line.UpdateRawWithNewDialogue();
                line.RawLine = purify(line.RawLine, false);
            }

            line.SpokenText = line.RawLine;

            for (var i = 0; i < line.SpokenText.Length; i++)
            {
                if (line.SpokenText[i] != '$')
                {
                    continue;
                }

                var res = MessageBlock.ParseCommand(line.SpokenText, i);
                line.SpokenText = res.Item1;

                var command = res.Item2;
                var @params = command.Params;
                if (command.numParams > 0)
                {
                    if (@params[0] == "ベロア")
                    {
                        @params[0] = "べロア"; // Velour Fix
                    }
                }
                switch (command.CommandWithPrefix)
                {
                case CommandTokens.E:
                    var emotion = @params[0] != "," ? @params[0] : DefaultEmotion;
                    if (string.IsNullOrEmpty(charActive) || charActive != charB)
                    {
                        emotionA = emotion;
                    }
                    else
                    {
                        Debug.Assert(charActive == charB, $"{charActive} == {charB}");
                        emotionB = emotion;
                    }
                    break;

                case CommandTokens.Ws:
                    charActive = @params[0];
                    break;

                case CommandTokens.Wm:
                    CharSide = Convert.ToInt32(@params[1]);

                    //NOTE(Robin): Prepare an exception for multiple possible fail states below
                    var unexpectedCharSideException = new ArgumentOutOfRangeException(nameof(CharSide), CharSide,
                                                                                      "Unexpected character side parameter.");

                    switch (conversationType)
                    {
                    case ConversationTypes.Type0:
                    {
                        switch (CharSide)
                        {
                        case 0:
                        case 2:
                            charA    = @params[0];
                            emotionA = DefaultEmotion;
                            break;

                        case 6:
                            charB    = @params[0];
                            emotionB = DefaultEmotion;
                            break;

                        default:
                            throw unexpectedCharSideException;
                        }
                        break;
                    }

                    case ConversationTypes.Type1:
                    {
                        switch (CharSide)
                        {
                        case 3:
                            charA    = @params[0];
                            emotionA = DefaultEmotion;
                            break;

                        case 7:
                            charB    = @params[0];
                            emotionB = DefaultEmotion;
                            break;

                        default:
                            throw unexpectedCharSideException;
                        }
                        break;
                    }

                    default:
                        throw new ArgumentOutOfRangeException(nameof(conversationType), conversationType,
                                                              "Unexpected conversation type.");
                    }
                    break;

                case CommandTokens.Wd:
                    if (charActive == charB)
                    {
                        charActive = charA;
                        charB      = string.Empty;
                    }
                    else
                    {
                        Debug.Assert(charActive == charA, $"{nameof(charActive)} == {nameof(charA)}");
                        charA = string.Empty;
                    }
                    break;

                case CommandTokens.a:
                    hasPerms = true;
                    break;

                case CommandTokens.t0:
                    if (!setType)
                    {
                        conversationType = ConversationTypes.Type0;
                    }
                    setType = true;
                    break;

                case CommandTokens.t1:
                    if (!setType)
                    {
                        conversationType = ConversationTypes.Type1;
                    }
                    setType = true;
                    break;

                case CommandTokens.Nu:
                    line.SpokenText = $"{line.SpokenText.Substring(0, i)}$Nu{line.SpokenText.Substring(i)}";
                    i += 2;
                    break;

                default:
                    Debug.WriteLine($"Unhandled command: {command.CommandWithPrefix}");
                    if (!CommandTokens.IsValid(command.CommandWithPrefix))
                    {
                        throw new ArgumentOutOfRangeException(nameof(command.CommandWithPrefix),
                                                              command.CommandWithPrefix,
                                                              "Unexpected command.");
                    }
                    break;
                }
                i--;
            }

            if (string.IsNullOrWhiteSpace(line.SpokenText))
            {
                line.SpokenText = string.Empty;
            }

            line.SpeechIndex = line.RawLine.LastIndexOf(line.SpokenText, StringComparison.Ordinal);


            line.RawLine    = purify(line.RawLine, false);
            line.SpokenText = purify(line.SpokenText, true);

            return(line.SpokenText);
        }
        private bool LoadConversationFromString(IReadOnlyList <string> fileLines)
        {
            //Parse for header and message blocks
            if (fileLines[0].StartsWith("MESS_"))
            {
                //Find where the header ends
                //Should be after "Message Name: Message"
                var headerEndIndex = 0;
                for (var i = 0; i < fileLines.Count; i++)
                {
                    if (!fileLines[i].Contains(":"))
                    {
                        continue;
                    }
                    if (headerEndIndex != 0)
                    {
                        headerEndIndex = i;
                        break;
                    }
                    headerEndIndex = i;
                }

                //If we found the header, add it to Header
                if (headerEndIndex != 0)
                {
                    Header = new string[headerEndIndex];
                    for (var i = 0; i < headerEndIndex; i++)
                    {
                        Header[i] = fileLines[i];
                    }

                    //Create messages from the rest of the lines
                    for (var i = headerEndIndex; i < fileLines.Count; i++)
                    {
                        //Separate the prefix from the message itself
                        if (fileLines[i].Contains(":"))
                        {
                            var newMessage  = new MessageBlock();
                            var prefixIndex = fileLines[i].IndexOf(":", StringComparison.Ordinal);
                            newMessage.Prefix = fileLines[i].Substring(0, prefixIndex);

                            //Get the message by itself
                            var message = fileLines[i].Substring(prefixIndex + 2);

                            //Make sure we didn't leave any prefix stuff behind
                            if (message.StartsWith(":"))
                            {
                                message = message.Remove(0, 2);

                                return(false);
                            }
                            if (char.IsWhiteSpace(message[0]))
                            {
                                message = message.Remove(0, 1);
                            }

                            //Have the message parse the rest
                            newMessage.ParseMessage(message);

                            //Add it to our list
                            MessageList.Add(newMessage);
                        }
                        else
                        {
                            MessageBox.Show(
                                "Message lines don't appear to be formatted correctly. Please make sure each message is preceeded with a Message Name.",
                                "Error");
                            return(false);
                        }
                        //TODO: messageProgress = (int)((float)i / fileLines.Length * 100);
                    }
                }
                else
                {
                    MessageBox.Show(
                        "File header doesn't appear to be formatted correctly. Please make sure the formatting is correct.",
                        "Error");
                    return(false);
                }
            }
            else
            {
                MessageBox.Show(
                    "File contents don't appear to be formatted correctly. Please make sure the formatting is correct and the file is compatible with FEITS.",
                    "Error");
                return(false);
            }

            return(true);
        }