コード例 #1
0
ファイル: FlipPlugin.cs プロジェクト: KateHowland/flip
        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 + "')");
            }
        }
コード例 #2
0
ファイル: FlipPlugin.cs プロジェクト: KateHowland/flip
        public void UseConversationLineAsTrigger(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();

            window.LeaveConditionMode();

            bool openingExistingScript = ScriptHelper.HasFlipScriptAttachedAsAction(line);

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

            TriggerControl trigger = triggers.GetTrigger(line, conversation);

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

                window.OpenFlipScript(new ScriptTriggerTuple(flipScript, trigger));

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

            else
            {
                window.SetTrigger(trigger);
                window.IsDirty = true;

                //ActivityLog.Write(new Activity("NewScript","CreatedVia","UsingConversationLineAsEvent","Event",trigger.GetLogText()));
                string lineText;
                try {
                    lineText = line.Line.Text.GetSafeString(OEIShared.Utils.BWLanguages.CurrentLanguage).Value;
                }
                catch (Exception) {
                    lineText = String.Empty;
                }
                Log.WriteAction(LogAction.added, "script", "to a line of conversation ('" + lineText + "')");
            }
        }
コード例 #3
0
ファイル: ScriptHelper.cs プロジェクト: KateHowland/flip
        public static bool HasFlipScriptAttachedAsCondition(NWN2ConversationConnector line)
        {
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }

            try {
                if (line.Conditions.Count > 0)
                {
                    NWN2GameScript script = new NWN2GameScript(line.Conditions[0].Script);
                    return(WasCreatedByFlip(script));
                }
            }
            catch (Exception) {}

            return(false);
        }
コード例 #4
0
 public DialogueWasSpoken(NWN2ConversationConnector line, NWN2GameConversation conversation) : this(line.Line.Text.GetSafeString(BWLanguages.CurrentLanguage).Value,
                                                                                                    conversation.Name,
                                                                                                    line.Line.LineGuid)
 {
 }
コード例 #5
0
 public TriggerControl GetTrigger(NWN2ConversationConnector line, NWN2GameConversation conversation)
 {
     return(new DialogueWasSpoken(line, conversation));
 }
コード例 #6
0
ファイル: StoryNode.cs プロジェクト: kjmikkel/NWN2_QuestMaker
        /// <summary>
        /// This adds many of the conditions and scripts to the conversation
        /// </summary>
        /// <param name="conv1">The first part of the conversation - this can be equal to the second</param>
        /// <param name="conv2">The second part of the conversation - this can be equal to the first</param>
        /// <param name="questName">The name of the quest</param>
        private void setConvValues(ref NWN2ConversationConnector conv1, ref NWN2ConversationConnector conv2, String questName)
        {
            if (takeGold > 0)
                {
                conv1.Conditions.Add(checkGold(giveGold));
                conv2.Actions.Add(giveOrTakeGold(false, giveGold));
                }

            if (takeItem != null)
                {
                conv1.Conditions.Add(checkItem(takeItem.Tag));
                conv2.Actions.Add(giveOrTakeItem(false, takeItem.Tag, takeNumber));
                }

            if (giveGold > 0)
                {
                conv2.Actions.Add(giveOrTakeGold(true, giveGold));
                }

            if (giveItem != null)
                {
                conv2.Actions.Add(giveOrTakeItem(true, giveItem.Tag, giveNumber));
                }

            // I add the advancement
            // conv1.Actions.Add(  //advanceQuest(questName, questId));

            if (convHappens == convType.Escort)
                {
                conv2.Actions.Add(addHenchMan(actor));
                }

            // Unless there we are dealing with a villain - we advance the quest
            if (happensEnum != EnumTypes.happens.Conflict)
                {
                conv2.Quest = makeQuest(questName, questId);
                //         conv2.Actions.Add(makeJournal(questName, questId));
                }
            /*
            if (happensEnum == EnumTypes.happens.Conv && convHappens != convType.None)
                {
                conv1.Actions.Add(EscortExplore(triggerHappens, convHappens, actor, trigger, name));
                }
            */
            if (xp > 0 && happensEnum != EnumTypes.happens.Conflict)
                {
                conv2.Actions.Add(XP(xp));
                }

            if (happensEnum == EnumTypes.happens.Trigger && triggerHappens == convType.Escort)
                {
                conv2.Actions.Add(removeHenchMan(actor));
                }

            //If we have a villian, he attacks
            if (happensEnum == EnumTypes.happens.Conflict)
                {
                conv2.Actions.Add(conflict());
                }
        }
コード例 #7
0
ファイル: ToolsetUIModifier.cs プロジェクト: KateHowland/flip
        /// <summary>
        /// Notifies the client that a resource viewer has been opened.
        /// </summary>
        protected void ViewerOpened(int index, object value)
        {
            TabPage page = (TabPage)value;
            NWN2ConversationViewer viewer = page.Control as NWN2ConversationViewer;

            if (viewer == null)
            {
                return;
            }

            try {
                GlacialTreeList tree = (GlacialTreeList)viewer.Controls["panelResults"].Controls["treeListResults"];
                if (tree == null)
                {
                    throw new ApplicationException("Couldn't find GlacialTreeList.");
                }

                winforms.MenuItem addEditScript    = new winforms.MenuItem("Add script");
                winforms.MenuItem deleteScript     = new winforms.MenuItem("Delete script");
                winforms.MenuItem addEditCondition = new winforms.MenuItem("Add condition");
                winforms.MenuItem deleteCondition  = new winforms.MenuItem("Delete condition");

                addEditScript.Click += delegate
                {
                    if (tree.SelectedNodes.Count != 1)
                    {
                        MessageBox.Show("Select a single line of the conversation.");
                    }

                    else
                    {
                        try {
                            GTLTreeNode node = (GTLTreeNode)tree.SelectedNodes[0];

                            NWN2ConversationConnector connector = node.Tag as NWN2ConversationConnector;

                            if (connector != null)
                            {
                                addScriptToLine.Invoke(connector, viewer.Conversation);
                            }
                        }
                        catch (Exception x) {
                            MessageBox.Show("Something went wrong when adding/editing the script.\n\n" + x);
                        }
                    }
                };

                addEditCondition.Click += delegate
                {
                    if (tree.SelectedNodes.Count != 1)
                    {
                        MessageBox.Show("Select a single line of the conversation.");
                    }

                    else
                    {
                        try {
                            GTLTreeNode node = (GTLTreeNode)tree.SelectedNodes[0];

                            NWN2ConversationConnector connector = node.Tag as NWN2ConversationConnector;

                            if (connector != null)
                            {
                                addConditionToLine.Invoke(connector, viewer.Conversation);
                            }
                        }
                        catch (Exception x) {
                            MessageBox.Show("Something went wrong when adding/editing the script.\n\n" + x);
                        }
                    }
                };

                deleteScript.Click += delegate
                {
                    if (tree.SelectedNodes.Count != 1)
                    {
                        MessageBox.Show("Select a single line of the conversation.");
                    }

                    else
                    {
                        try {
                            GTLTreeNode node = (GTLTreeNode)tree.SelectedNodes[0];

                            NWN2ConversationConnector connector = node.Tag as NWN2ConversationConnector;

                            if (connector != null && connector.Actions.Count > 0)
                            {
                                MessageBoxResult result = MessageBox.Show("Delete the script on this line?", "Delete?", MessageBoxButton.YesNo);
                                if (result == MessageBoxResult.Yes)
                                {
                                    string scriptName = connector.Actions[0].Script.FullName;
                                    connector.Actions.Clear();
                                    viewer.RefreshTreeItemForConnector(connector);
                                    Log.WriteAction(LogAction.deleted, "script", scriptName + " (was attached to line '" + connector.Line.Text.GetSafeString(OEIShared.Utils.BWLanguages.CurrentLanguage) + "')");
                                }
                            }
                        }
                        catch (Exception x) {
                            MessageBox.Show("Something went wrong when deleting the script.\n\n" + x);
                        }
                    }
                };

                deleteCondition.Click += delegate
                {
                    if (tree.SelectedNodes.Count != 1)
                    {
                        MessageBox.Show("Select a single line of the conversation.");
                    }

                    else
                    {
                        try {
                            GTLTreeNode node = (GTLTreeNode)tree.SelectedNodes[0];

                            NWN2ConversationConnector connector = node.Tag as NWN2ConversationConnector;

                            if (connector != null && connector.Conditions.Count > 0)
                            {
                                MessageBoxResult result = MessageBox.Show("Delete the condition on this line?", "Delete?", MessageBoxButton.YesNo);
                                if (result == MessageBoxResult.Yes)
                                {
                                    string scriptName = connector.Conditions[0].Script.FullName;
                                    connector.Conditions.Clear();
                                    viewer.RefreshTreeItemForConnector(connector);
                                    Log.WriteAction(LogAction.deleted, "script", scriptName + " (was attached as condition to line '" + connector.Line.Text.GetSafeString(OEIShared.Utils.BWLanguages.CurrentLanguage) + "')");
                                }
                            }
                        }
                        catch (Exception x) {
                            MessageBox.Show("Something went wrong when deleting the condition.\n\n" + x);
                        }
                    }
                };

                tree.ContextMenu.Popup += delegate
                {
                    if (tree.SelectedNodes.Count != 1)
                    {
                        addEditScript.Enabled    = false;
                        addEditCondition.Enabled = false;
                        deleteScript.Enabled     = false;
                        deleteCondition.Enabled  = false;
                    }

                    else
                    {
                        GTLTreeNode node = (GTLTreeNode)tree.SelectedNodes[0];

                        NWN2ConversationConnector connector = node.Tag as NWN2ConversationConnector;

                        if (connector == null)
                        {
                            addEditScript.Enabled    = false;
                            addEditCondition.Enabled = false;
                        }
                        else
                        {
                            addEditScript.Enabled    = true;
                            addEditCondition.Enabled = true;
                        }

                        if (connector != null && ScriptHelper.HasFlipScriptAttachedAsAction(connector))
                        {
                            addEditScript.Text   = "Edit script";
                            deleteScript.Enabled = true;
                        }
                        else
                        {
                            addEditScript.Text   = "Add script";
                            deleteScript.Enabled = false;
                        }

                        if (connector != null && ScriptHelper.HasFlipScriptAttachedAsCondition(connector))
                        {
                            addEditCondition.Text   = "Edit condition";
                            deleteCondition.Enabled = true;
                        }
                        else
                        {
                            addEditCondition.Text   = "Add condition";
                            deleteCondition.Enabled = false;
                        }
                    }
                };

                tree.ContextMenu.MenuItems.Add("-");
                tree.ContextMenu.MenuItems.Add(addEditScript);
                tree.ContextMenu.MenuItems.Add(deleteScript);
                tree.ContextMenu.MenuItems.Add("-");
                tree.ContextMenu.MenuItems.Add(addEditCondition);
                tree.ContextMenu.MenuItems.Add(deleteCondition);
            }
            catch (Exception x) {
                MessageBox.Show("Error when trying to integrate Flip with conversation editor.", x.ToString());
            }
        }