示例#1
0
        public void AddConditionToConversationLine(NWN2ConversationConnector line, NWN2GameConversation conversation)
        {
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }
            if (conversation == null)
            {
                throw new ArgumentNullException("conversation");
            }
            if (!conversation.AllConnectors.Contains(line))
            {
                throw new ArgumentException("Line is not a part of the given conversation.", "line");
            }

            LaunchFlip();

            bool openingExistingScript = ScriptHelper.HasFlipScriptAttachedAsCondition(line);

            if (openingExistingScript && window.AskWhetherToSaveCurrentScript() == MessageBoxResult.Cancel)
            {
                return;
            }

            window.ConditionalFrame.Address = addressFactory.GetConversationAddress(conversation.Name, line.Line.LineGuid, ScriptType.Conditional).Value;

            if (openingExistingScript)
            {
                NWN2GameScript script = new NWN2GameScript(line.Conditions[0].Script);
                script.Demand();
                FlipScript flipScript = scriptHelper.GetFlipScript(script, Attachment.Ignore);

                window.OpenFlipScript(new ScriptTriggerTuple(flipScript, null));
                window.ConditionalFrame.Dialogue = Nwn2Strings.GetStringFromOEIString(line.Line.Text);

                //ActivityLog.Write(new Activity("OpenedScript","ScriptName",script.Name,"Event",String.Empty));
                Log.WriteAction(LogAction.opened, "script", script.Name + "(attached as condition to line '" + line.Line.Text.GetSafeString(OEIShared.Utils.BWLanguages.CurrentLanguage) + "')");
            }

            else
            {
                window.IsDirty = true;

                window.EnterConditionMode();
                window.ConditionalFrame.Dialogue = Nwn2Strings.GetStringFromOEIString(line.Line.Text);

                //ActivityLog.Write(new Activity("NewScript","CreatedVia","AddingConditionToConversationLine","Event",String.Empty));
                string lineText;
                try {
                    lineText = line.Line.Text.GetSafeString(OEIShared.Utils.BWLanguages.CurrentLanguage).Value;
                }
                catch (Exception) {
                    lineText = String.Empty;
                }
                Log.WriteAction(LogAction.added, "script", "as condition to a line of conversation ('" + lineText + "')");
            }
        }