예제 #1
0
        public void EditMessageScript(bool currentLineOnly)
        {
            var messageList = MainConversation.File.MessageList;

            if (messageList.Count < 1)
            {
                MessageBox.Show("There is nothing to edit.", "Cannot Edit", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            var rawLine = string.Empty;

            if (currentLineOnly)
            {
                messageList[MainConversation.MessageIndex].MessageLines[MainConversation.LineIndex]
                .UpdateRawWithNewDialogue();
                rawLine = messageList[MainConversation.MessageIndex].MessageLines[MainConversation.LineIndex].RawLine;
                rawLine = rawLine.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n");
            }

            using (var messageEdit = new DirectEdit())
            {
                var editCont = new ImportExportController(messageEdit,
                                                          currentLineOnly ? rawLine : messageList[MainConversation.MessageIndex].CompileMessage(false));

                if (messageEdit.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var newMessage = string.Empty;
                if (currentLineOnly)
                {
                    messageList[MainConversation.MessageIndex].MessageLines[MainConversation.LineIndex].RawLine =
                        editCont.MessageScript;

                    newMessage = messageList[MainConversation.MessageIndex].MessageLines
                                 .Aggregate(newMessage,
                                            (current, msg) => current + msg.RawLine);
                }
                else
                {
                    newMessage = editCont.MessageScript;
                }

                messageList[MainConversation.MessageIndex].MessageLines.Clear();
                messageList[MainConversation.MessageIndex].ParseMessage(newMessage);

                if (currentLineOnly)
                {
                    SetCurrentLine();
                }
                else
                {
                    SetCurrentMessage();
                }
            }
        }
예제 #2
0
        public void EditSourceMessageScript(bool currentLineOnly)
        {
            if (sourceConv.File.MessageList.Count < 1)
            {
                MessageBox.Show("There is nothing to edit.", "Cannot Edit", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            var rawLine = string.Empty;

            if (currentLineOnly)
            {
                sourceConv.File.MessageList[sourceConv.MessageIndex].MessageLines[sourceConv.LineIndex]
                .UpdateRawWithNewDialogue();
                rawLine =
                    sourceConv.File.MessageList[sourceConv.MessageIndex].MessageLines[sourceConv.LineIndex].RawLine;
                rawLine = rawLine.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n");
            }

            using (var messageEdit = new DirectEdit())
            {
                var editCont = new ImportExportController(messageEdit,
                                                          currentLineOnly
                        ? rawLine
                        : sourceConv.File.MessageList[sourceConv.MessageIndex].CompileMessage(false));

                if (messageEdit.ShowDialog() == DialogResult.OK)
                {
                    var newMessage = string.Empty;
                    if (currentLineOnly)
                    {
                        sourceConv.File.MessageList[sourceConv.MessageIndex].MessageLines[sourceConv.LineIndex].RawLine
                            = editCont.MessageScript;

                        foreach (var msg in sourceConv.File.MessageList[sourceConv.MessageIndex].MessageLines)
                        {
                            newMessage += msg.RawLine;
                        }
                    }
                    else
                    {
                        newMessage = editCont.MessageScript;
                    }

                    sourceConv.File.MessageList[sourceConv.MessageIndex].MessageLines.Clear();
                    sourceConv.File.MessageList[sourceConv.MessageIndex].ParseMessage(newMessage);

                    if (currentLineOnly)
                    {
                        SetCurrentSourceLine();
                    }
                    else
                    {
                        SetCurrentSourceMessage();
                    }
                }
            }
        }