private static void GetItemNames(StoryNode node, ref List <string> Names)
        {
            foreach (InventoryOperation operation in node.OnEnter)
            {
                if (!Names.Contains(operation.ItemName))
                {
                    Names.Add(operation.ItemName);
                }
            }

            foreach (Option opt in node.Options)
            {
                foreach (InventoryOperation operation in opt.OnSelect)
                {
                    if (!Names.Contains(operation.ItemName))
                    {
                        Names.Add(operation.ItemName);
                    }
                }

                foreach (InventoryConditional conditional in opt.Conditionals)
                {
                    if (!Names.Contains(conditional.InventoryItem))
                    {
                        Names.Add(conditional.InventoryItem);
                    }
                }

                if (!(opt.Node is ReferenceNode))
                {
                    GetItemNames(opt.Node, ref Names);
                }
            }
        }
        private static void GetItemNames(StoryNode node, ref List<string> Names)
        {
            foreach (InventoryOperation operation in node.OnEnter) {
                if (!Names.Contains(operation.ItemName)) {
                    Names.Add(operation.ItemName);
                }
            }

            foreach (Option opt in node.Options) {
                foreach (InventoryOperation operation in opt.OnSelect) {
                    if (!Names.Contains(operation.ItemName)) {
                        Names.Add(operation.ItemName);
                    }
                }

                foreach (InventoryConditional conditional in opt.Conditionals) {
                    if (!Names.Contains(conditional.InventoryItem)) {
                        Names.Add(conditional.InventoryItem);
                    }
                }

                if (!(opt.Node is ReferenceNode)) {
                    GetItemNames(opt.Node, ref Names);
                }
            }
        }
        public TreeNode GetNode(StoryNode node)
        {
            if (node is ReferenceNode) return GetNode(((ReferenceNode)node).Reference);

            if(ReverseNodeMapping.ContainsKey(node)) {
                return ReverseNodeMapping[node];
            } else {
                throw new Exception("Failed to find Storynode in Reverse Node Mapping");
            }
        }
Пример #4
0
 public void EnterStoryNode(StoryNode node)
 {
     CurrentNode = node;
     node.Selected(Items);
 }
Пример #5
0
 public ReferenceNode(StoryNode reference)
 {
     this.Reference = reference;
 }
Пример #6
0
 public ReferenceNode()
 {
     Reference = null;
 }
 public StoryChangedEventArgs(StoryNode node)
 {
     this.NewStoryNode = node;
 }
Пример #8
0
 private void TriggerStoryNodeChanged(StoryNode newnode)
 {
     if(OnStoryNodeChanged != null) {
         OnStoryNodeChanged(this, new StoryChangedEventArgs(newnode));
     }
 }
Пример #9
0
 public ReferenceNode(StoryNode reference)
 {
     this.Reference = reference;
 }
Пример #10
0
 public ReferenceNode()
 {
     Reference = null;
 }
Пример #11
0
        private void NewAdventure()
        {
            LastFileAccess = null;
            saveToolStripMenuItem.Enabled = false;

            CurrentAdventure = new Adventure();
            StoryNode root = new StoryNode();
            CurrentAdventure.RootStoryNodes.Add(root);
            CurrentAdventure.StartingPoint = root;
            CurrentAdventureChanged();
            Dirty = false;
        }
Пример #12
0
        public override void Refresh()
        {
            StoryNode selectednode = this.SelectedStoryNode;

            ReverseNodeMapping.Clear();
            if (Adventure == null) return;

            /* Remove Old Nodes */
            List<TreeNode> ToRemove = new List<TreeNode>();
            foreach(TreeNode node in this.Nodes) {
                bool Found = false;
                foreach(StoryNode storynode in Adventure.RootStoryNodes) {
                    if(node.Tag == storynode) {
                        Found = true;
                        break;
                    }
                }
                if (!Found) {
                    ToRemove.Add(node);
                }
            }
            foreach(TreeNode node in ToRemove) {
                this.Nodes.Remove(node);
            }

            /* Add/Update Existing Nodes */
            foreach(StoryNode storyNode in Adventure.RootStoryNodes) {
                TreeNode child = null;
                foreach(TreeNode node in this.Nodes) {
                    if(node.Tag == storyNode) {
                        child = node;
                        break;
                    }
                }

                if (child == null){
                    this.Nodes.Add(CreateTreeNode(storyNode));
                } else {
                    this.BindData(child, storyNode);
                    UpdateNode(child);
                }
            }

            if(selectednode != null && ReverseNodeMapping.ContainsKey(selectednode)) {
                this.SelectedStoryNode = selectednode;
            }

            /* Ensure all reference nodes reference an existing node */
            List<KeyValuePair<StoryNode, TreeNode>> ToUpdate = new List<KeyValuePair<StoryNode, TreeNode>>();
            foreach (KeyValuePair<StoryNode, TreeNode> kvp in ReverseNodeMapping) {
                if (kvp.Key is ReferenceNode) {
                    ReferenceNode node = kvp.Key as ReferenceNode;
                    if (!ReverseNodeMapping.ContainsKey(node.Reference)) {
                        ToUpdate.Add(kvp);
                    }
                }
            }
            if (ToUpdate.Count > 0) {
                foreach (KeyValuePair<StoryNode, TreeNode> node in ToUpdate) {
                    ReferenceNode refNode = node.Key as ReferenceNode;

                    if (ReverseNodeMapping.ContainsKey(refNode.Reference)) {
                        continue; // Already updated...
                    }
                    StoryNode parentNode = (StoryNode)node.Value.Parent.Tag;

                    bool FoundOne = false;
                    foreach (Option opt in parentNode.Options) {
                        if (opt.Node == refNode) {
                            opt.Node = refNode.Reference;
                            node.Value.Tag = opt.Node;
                            ReverseNodeMapping[opt.Node] = node.Value;
                            FoundOne = true;
                            break;
                        }
                    }

                    if (!FoundOne) {
                        throw new Exception("Failed to find reference node to non existant story node");
                    }
                }
                Refresh();
            }
        }
Пример #13
0
        private TreeNode CreateTreeNode(StoryNode storyNode)
        {
            TreeNode node = new TreeNode(storyNode.Name);
            this.BindData(node, storyNode);

            /* Context Menu Strip */
            ContextMenuStrip NodeOptions = new ContextMenuStrip();
            NodeOptions.Tag = node;
            ToolStripItem ExpandAll = NodeOptions.Items.Add("Expand All");
            ExpandAll.Tag = node;
            ExpandAll.Click += new EventHandler(ExpandAll_Click);

            ToolStripItem CollapseAll = NodeOptions.Items.Add("Collapse All");
            CollapseAll.Tag = node;
            CollapseAll.Click += new EventHandler(CollapseAll_Click);

            node.ContextMenuStrip = NodeOptions;

            /* Children */
            if(!(storyNode is ReferenceNode)) {
                foreach(Option option in storyNode.Options) {
                    node.Nodes.Add(CreateTreeNode(option.Node));
                }
            }
            return node;
        }
Пример #14
0
        private void BindData(TreeNode node, StoryNode data)
        {
            node.Text = data.Name;
            node.Tag = data;

            if(!ReverseNodeMapping.ContainsKey(data)) {
                ReverseNodeMapping.Add(data, node);
            } else {
                ReverseNodeMapping[data] = node;
            }

            if(data == Adventure.StartingPoint) {
                node.ForeColor = Color.Green;
            } else if(data is ReferenceNode) {
                node.ForeColor = Color.Blue;
            } else {
                node.ForeColor = Color.Black;
            }
        }