Exemple #1
0
        protected override void OnKeyPress(KeyEventArgs e)
        {
            base.OnKeyPress(e);
            if (e.Modifiers == UnityEngine.EventModifiers.None)
            {
                switch (e.KeyCode)
                {
                case UnityEngine.KeyCode.DownArrow:
                    _SelectNext();
                    break;

                case UnityEngine.KeyCode.LeftArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case UnityEngine.KeyCode.RightArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case UnityEngine.KeyCode.UpArrow:
                    _SelectPrevious();
                    break;
                }
            }
        }
Exemple #2
0
        private void ToolBox_MouseDown(object sender, MouseEventArgs e)
        {
            SelectNodeAt(e.X, e.Y);
            if (SelectedNode == null)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (SelectedNode.Nodes.Count > 0 && (SelectedNode.AlwaysExpand || e.X < SelectedNode.Level * Indent - 10))
                {
                    if (SelectedNode.IsExpanded)
                    {
                        SelectedNode.Collapse();
                    }
                    else
                    {
                        SelectedNode.Expand();
                    }
                }
            }

            this.Refresh();
        }
Exemple #3
0
 private void tsmiNewDirectory_Click(object sender, EventArgs e)
 {
     try
     {
         SelectDirectory();
         string dir = GetTreeViewPath(SelectedNode);
         if (!Directory.Exists(dir))
         {
             return;
         }
         string folderName = "folder";
         int    i          = 1;
         while (Directory.Exists(System.IO.Path.Combine(dir, folderName)))
         {
             folderName = "folder" + i;
             i++;
         }
         Directory.CreateDirectory(System.IO.Path.Combine(dir, folderName));
         TreeNode node = new TreeNode(folderName);
         SelectedNode.Nodes.Add(node);
         UpdateIcon(node);
         SelectedNode.Expand();
         OldPath   = GetTreeViewPath(node);
         LabelEdit = true;
         node.BeginEdit();
     }
     catch (Exception ex)
     {
         ProgramData.Log("ProjectTree", ex.Message, ProgramData.LOG_STYLE_ERROR);
     }
 }
Exemple #4
0
 private void tsmiNewFile_Click(object sender, System.EventArgs e)
 {
     try
     {
         SelectDirectory();
         string dir = GetTreeViewPath(SelectedNode);
         if (!Directory.Exists(dir))
         {
             return;
         }
         string fileName = "file.js";
         int    i        = 1;
         while (File.Exists(System.IO.Path.Combine(dir, fileName)))
         {
             fileName = "file" + i + ".js";
             i++;
         }
         Path path = (Path)dir + fileName;
         File.Create(System.IO.Path.Combine(dir, fileName)).Close();
         TreeNode node = new TreeNode(fileName);
         SelectedNode.Nodes.Add(node);
         UpdateIcon(node);
         SelectedNode.Expand();
         OldPath   = GetTreeViewPath(node);
         LabelEdit = true;
         node.BeginEdit();
     }
     catch (Exception ex)
     {
         ProgramData.Log("ProjectTree", ex.Message, ProgramData.LOG_STYLE_ERROR);
     }
 }
Exemple #5
0
        public void SelectSubNode(SvnItem item)
        {
            if (item == null)
            {
                return;
            }

            FileSystemTreeNode fstn = SelectedNode as FileSystemTreeNode;

            if (fstn != null)
            {
                if (fstn.SvnItem == item)
                {
                    return;
                }
            }

            SelectedNode.Expand();

            foreach (FileSystemTreeNode tn in SelectedNode.Nodes)
            {
                if (tn.SvnItem == item)
                {
                    SelectedNode = tn;
                    return;
                }
            }

            // Walk up recursively
            SelectSubNode(item.Parent);

            // Walk back down (step down is taken by setting SelectedNode one deeper above)
            SelectSubNode(item);
        }
        private void Paste()
        {
            if (!CanMove(cutNode, SelectedNode))
            {
                return;
            }

            if (cutNode is LeafTreeNode)
            {
                LeafPasteEventArgs ee = new LeafPasteEventArgs((cutNode as LeafTreeNode).Leaf, (SelectedNode as ContainerTreeNode).Container);
                OnLeafPaste(ee);
                if (!ee.Cancel)
                {
                    cutNode.Remove();
                    SelectedNode.Expand();
                    SelectedNode.Nodes.Add(cutNode);
                }
            }
            else
            {
                ContainerPasteEventArgs ee = new ContainerPasteEventArgs((cutNode as ContainerTreeNode).Container, (SelectedNode as ContainerTreeNode).Container);
                OnContainerPaste(ee);
                if (!ee.Cancel)
                {
                    cutNode.Remove();
                    SelectedNode.Expand();
                    SelectedNode.Nodes.Insert(0, cutNode);
                }
            }

            SelectedNode.Expand();
            SortBranch(SelectedNode as ContainerTreeNode);
            CancelCut();
        }
        private void DragDropTreeView_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false) && _nodeMap != "")
            {
                var movingNode       = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                var nodeIndexes      = _nodeMap.Split('|');
                var insertCollection = Nodes;

                for (var i = 0; i < nodeIndexes.Length - 1; i++)
                {
                    insertCollection = insertCollection[Int32.Parse(nodeIndexes[i])].Nodes;
                }

                insertCollection.Insert(Int32.Parse(nodeIndexes[nodeIndexes.Length - 1]), (TreeNode)movingNode.Clone());
                SelectedNode = insertCollection[Int32.Parse(nodeIndexes[nodeIndexes.Length - 1])];

                // Remove the old ersion of the node
                movingNode.Remove();

                // Expand if necessary
                if (SelectedNode.Nodes.Count > 0 && !SelectedNode.IsExpanded)
                {
                    SelectedNode.Expand();
                }

                // Fire the event (if there is a handler attached)
                var args = new DragDropReorganizeFinishedEventArgs {
                    Node = SelectedNode
                };
                if (DragDropReorganizeFinished != null)
                {
                    DragDropReorganizeFinished(this, args);
                }
            }
        }
Exemple #8
0
 private void expandToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (SelectedNode == null)
     {
         return;
     }
     SelectedNode.Expand();
 }
Exemple #9
0
 private void    OnAddChild(Object sender, EventArgs args)
 {
     //	MessageBox.Show("OnAddChild");
     BeginUpdate();
     SelectedNode.Nodes.Add("New Child");
     SelectedNode.Expand();
     EndUpdate();
 }
Exemple #10
0
 /// <summary>
 /// Handles clicking Expand/Collapse on the context.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void contextclick_Toggle(object sender, EventArgs e)
 {
     if (SelectedNode.IsExpanded)
     {
         SelectedNode.Collapse(true);
     }
     else
     {
         SelectedNode.Expand();
     }
 }
        private void leafToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LeafTreeNode node = new LeafTreeNode(LeafName);

            SelectedNode.Expand();
            RefreshImagesIndexes(node, false);
            SelectedNode.Nodes.Add(node);
            node.ContextMenuStrip = leafMenuStrip;
            SelectedNode          = node;
            newNode = node;
            node.BeginEdit();
        }
Exemple #12
0
        private void DisplayHierarchical(IEnumerable <TagDatum> references, bool loadTags = false)
        {
            BeginUpdate();
            Nodes.Clear( );

            foreach (var reference in references)
            {
                var path        = reference.Path;
                var directories = path.Split(new[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                var length      = path.IndexOf('\\');

                // Don't process empty arrays
                if (directories.Length <= 0)
                {
                    continue;
                }

                var collection = Nodes;

                // Loop through all elements of array except the last one
                var lastElementIndex = directories.Length - 1;
                for (var index = 0; index < lastElementIndex; index++)
                {
                    var dir           = directories[index];
                    var fullDirectory = path.Substring(0, length);
                    var directoryNode = new ScenarioView.DirectoryNode(dir, fullDirectory);
                    if (!collection.ContainsKey(directoryNode.Name))
                    {
                        collection.Add(directoryNode);
                    }
                    collection = collection[directoryNode.Name].Nodes;

                    var indexOf = path.IndexOf('\\', length + 1);
                    length = indexOf < 0 ? path.Length : indexOf;
                }
                if (!loadTags)
                {
                    continue;
                }

                // Do special work on the last element:
                var text = directories[lastElementIndex];
                var guerillaBlockNode = new ScenarioView.GuerillaBlockReferenceNode(path, text, reference);
                if (!collection.ContainsKey(guerillaBlockNode.Name))
                {
                    collection.Add(guerillaBlockNode);
                }
            }
            SelectedNode = Nodes.Count > 0 ? Nodes[0] : null;
            SelectedNode?.Expand( );
            EndUpdate();
        }
        private void containerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ContainerTreeNode node = new ContainerTreeNode(ContainerName);

            SelectedNode.Expand();
            node.Tag = false;
            RefreshImagesIndexes(node, false);
            SelectedNode.Nodes.Insert(0, node);
            node.ContextMenuStrip = containerMenuStrip;
            SelectedNode          = node;
            newNode = node;
            node.BeginEdit();
        }
Exemple #14
0
        protected override void OnKeyPress(KeyPressEventArgs args)
        {
            base.OnKeyPress(args);

            var e = args.uwfKeyArgs;

            if (e.Modifiers == Keys.None)
            {
                switch (e.KeyCode)
                {
                case Keys.Space:
                case Keys.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case Keys.Down:
                    _SelectNext();
                    break;

                case Keys.Left:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case Keys.Right:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case Keys.Up:
                    _SelectPrevious();
                    break;
                }
            }

            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                filter         += c;
                resetFilterTime = 3; // sec.
                SelectNodeWText(filter);
            }
        }
Exemple #15
0
        protected override void OnKeyPress(KeyEventArgs e)
        {
            base.OnKeyPress(e);
            if (e.Modifiers == UnityEngine.EventModifiers.None)
            {
                switch (e.KeyCode)
                {
                case UnityEngine.KeyCode.Space:
                case UnityEngine.KeyCode.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case UnityEngine.KeyCode.DownArrow:
                    _SelectNext();
                    break;

                case UnityEngine.KeyCode.LeftArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case UnityEngine.KeyCode.RightArrow:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case UnityEngine.KeyCode.UpArrow:
                    _SelectPrevious();
                    break;
                }
            }

            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                _filter         += c;
                _resetFilterTime = 3; // sec.
                SelectNodeWText(_filter);
            }
        }
        public void ExpandSubNode(String text)
        {
            TreeNodeCollection nodes = SelectedNode.Nodes;

            if ((nodes.Count == 1) && (nodes[0].Text.Equals(" : ")))
            {
                SelectedNode.Expand();
            }
            foreach (TreeNode tn in nodes)
            {
                if (tn.Text == text)
                {
                    SelectedNode = tn;
                    break;
                }
            }
        }
 void treeView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (SelectedNode != null)
         {
             if (SelectedNode is LeafTreeNode)
             {
                 LeafEventArgs ee = new LeafEventArgs((SelectedNode as LeafTreeNode).Leaf);
                 OnLeafDoubleClicked(ee);
             }
             else
             {
                 if (SelectedNode.IsExpanded)
                 {
                     SelectedNode.Collapse();
                 }
                 else
                 {
                     SelectedNode.Expand();
                 }
             }
         }
     }
     else if (e.KeyCode == Keys.Escape)
     {
         CancelCut();
     }
     else if (e.KeyCode == Keys.Delete)
     {
         if (SelectedNode is ContainerTreeNode)
         {
             if (SelectedNode != treeView1.Nodes[0])
             {
                 ContainerDelete();
             }
         }
         else
         {
             LeafDelete();
         }
     }
 }
 void ExplorerTreeView_VisibleChanged(object sender, EventArgs e)
 {
     if (Visible)
     {
         imageList.SetSmallImageList(this);
         if (root != null)
         {
             root.Expand();
             if (SelectedNode != null)
             {
                 SelectedNode.Expand();
             }
             else
             {
                 SelectedNode = root;
             }
         }
     }
 }
Exemple #19
0
        /// <summary>
        /// Adds a Struct (a Feat structure) to the "FeatList" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddFeat(object sender, EventArgs e)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = 1;                                   // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            int id = SelectedNode.Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.WORD;
            field.label = "Feat";
            field.WORD  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
Exemple #20
0
        /// <summary>
        /// Finds the parent of the currently selected node and will add a new node to the parent
        /// </summary>
        /// <param name="node">node to be added</param>
        public void FindParentAndAdd(CustomNode node, bool editafter = true)
        {
            if (SelectedNode == null)
            {
                AddNode(Nodes, node, editafter);
                return;
            }

            if (SelectedNode is FolderNode)
            {
                SelectedNode.Expand();
                AddNode(SelectedNode.Nodes, node, editafter);
                return;
            }
            else
            {
                SelectedNode = SelectedNode.Parent;
                FindParentAndAdd(node, editafter);
            }
        }
Exemple #21
0
        private void OpenSelected()
        {
            string path = GetTreeViewPath(SelectedNode);

            if (Directory.Exists(path))
            {
                SelectedNode.Expand();
                return;
            }

            string extension = System.IO.Path.GetExtension(path).ToLower();

            if (extension == ".png")
            {
                Process.Start(System.IO.Path.Combine(Directory.GetCurrentDirectory(), "bin\\NPixelPaint.exe"), "\"" + path + "\"");
            }
            else if (extension == ".json")
            {
                if (ProgramData.Project.Type == ProjectType.MODPE)
                {
                    try
                    {
                        new fJsonItem(path).Show();
                    }
                    catch { EditorsManager.GetEditor(path).Edit(); }
                }
                else
                {
                    EditorsManager.GetEditor(path).Edit();
                }
            }
            else
            {
                Editor editor = EditorsManager.GetEditor(path);
                editor.Edit();
            }
        }
Exemple #22
0
        /// <summary>
        /// Adds a Struct (an InventoryItem structure) to the "ItemList" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddInventoryItem(object sender, EventArgs e)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            int id = SelectedNode.Nodes.Count;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = id.ToString();     // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = (uint)id;          // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            id       = SelectedNode.Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.BYTE;
            field.label = "Dropable";
            field.BYTE  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field         = new GffData.Field();
            field.type    = FieldTypes.CResRef;
            field.label   = "EquippedRes";
            field.CResRef = String.Empty;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.BYTE;
            field.label = "Pickpocketable";
            field.BYTE  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.WORD;
            field.label = "Repos_PosX";
            field.WORD  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.WORD;
            field.label = "Repos_PosY";
            field.WORD  = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
Exemple #23
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Modifiers == Keys.None)
            {
                switch (e.KeyCode)
                {
                case Keys.Space:
                case Keys.Return:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Toggle();
                    }
                    break;

                case Keys.Down:
                    SelectNext();
                    break;

                case Keys.Left:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Collapse();
                    }
                    break;

                case Keys.Right:
                    if (SelectedNode != null)
                    {
                        SelectedNode.Expand();
                    }
                    break;

                case Keys.Up:
                    SelectPrevious();
                    break;

                case Keys.PageDown:
                    if (nodeList.Count > 0)
                    {
                        var lNodesOnScreen = nodesOnScreen;
                        var nextIndex      = 0;
                        if (SelectedNode != null)
                        {
                            nextIndex = nodeList.IndexOf(SelectedNode);
                        }
                        nextIndex    = MathHelper.Clamp(nextIndex + lNodesOnScreen, 0, nodeList.Count - 1);
                        SelectedNode = nodeList[nextIndex];
                    }
                    break;

                case Keys.PageUp:
                    if (nodeList.Count > 0)
                    {
                        var lNodesOnScreen = nodesOnScreen;
                        var nextIndex      = 0;
                        if (SelectedNode != null)
                        {
                            nextIndex = nodeList.IndexOf(SelectedNode);
                        }
                        nextIndex    = MathHelper.Clamp(nextIndex - lNodesOnScreen, 0, nodeList.Count - 1);
                        SelectedNode = nodeList[nextIndex];
                    }
                    break;

                case Keys.End:
                    if (nodeList.Count > 0)
                    {
                        SelectedNode = nodeList[nodeList.Count - 1];
                    }
                    break;

                case Keys.Home:
                    if (nodeList.Count > 0)
                    {
                        SelectedNode = nodeList[0];
                    }
                    break;
                }
            }
            else if (e.Control)
            {
                switch (e.KeyCode)
                {
                case Keys.Down:
                    if (uwfVScrollBar.Visible)
                    {
                        uwfVScrollBar.DoScroll(ScrollEventType.SmallIncrement);
                    }
                    break;

                case Keys.Up:
                    if (uwfVScrollBar.Visible)
                    {
                        uwfVScrollBar.DoScroll(ScrollEventType.SmallDecrement);
                    }
                    break;
                }
            }


            char c = KeyHelper.GetLastInputChar();

            if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
            {
                filter         += c;
                resetFilterTime = 3; // sec.
                SelectNodeWText(filter);
            }
        }
Exemple #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddDamageReduction(object sender, EventArgs e)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = 2;                                   // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            int id = SelectedNode.Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.SHORT;
            field.label = "DmgRedctAmt";
            field.SHORT = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.SHORT;
            field.label = "DmgRedctFlags";
            field.SHORT = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.List;
            field.label = "DmgRedctSubList";

            text = GeneralGFF.ConstructNodetext(field);
            var list = new Sortable(text, field.label);

            list.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(list);

            field               = new GffData.Field();
            field.type          = FieldTypes.Struct;
            field.label         = "0";     // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = 2;       // <- that's what's in the UTCs I've looked at.

            text = GeneralGFF.ConstructNodetext(field);
            var @struct = new Sortable(text, field.label);

            @struct.Tag = field;
            list.Nodes.Add(@struct);

            field       = new GffData.Field();
            field.type  = FieldTypes.SHORT;
            field.label = "DmgRedctSubType";
            field.SHORT = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            @struct.Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.SHORT;
            field.label = "DmgRedctType";
            field.SHORT = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            @struct.Nodes.Add(node);


            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();
            list.Expand();
            @struct.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
Exemple #25
0
        /// <summary>
        /// Adds a Struct (a Class structure) to the "ClassList" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddClass(object sender, EventArgs e)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
            field.Struct        = new Struct();
            field.Struct.typeid = 2;                                   // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            int id = SelectedNode.Nodes.Add(node);


            field       = new GffData.Field();
            field.type  = FieldTypes.INT;
            field.label = "Class";
            field.INT   = 0;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.SHORT;
            field.label = "ClassLevel";
            field.SHORT = 1;

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            for (int i = 0; i != 10; ++i)
            {
                field       = new GffData.Field();
                field.type  = FieldTypes.List;
                field.label = LABEL_PREFIX_KNOWN + i;

                text     = GeneralGFF.ConstructNodetext(field);
                node     = new Sortable(text, field.label);
                node.Tag = field;
                SelectedNode.Nodes[id].Nodes.Add(node);
            }

            for (int i = 0; i != 10; ++i)
            {
                field       = new GffData.Field();
                field.type  = FieldTypes.List;
                field.label = LABEL_PREFIX_MEMORIZED + i;

                text     = GeneralGFF.ConstructNodetext(field);
                node     = new Sortable(text, field.label);
                node.Tag = field;
                SelectedNode.Nodes[id].Nodes.Add(node);
            }

            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
Exemple #26
0
        /// <summary>
        /// Adds a Struct (a Variable structure) to the "VarTable" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddVariable(object sender, EventArgs e)
        {
            using (var dialog = new VariableDialog())
            {
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    BeginUpdate();

                    TreeNode top = TopNode;

                    var field = new GffData.Field();
                    field.type          = FieldTypes.Struct;
                    field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
                    field.Struct        = new Struct();
                    field.Struct.typeid = 0;                                   // <- that's what's in the UTCs I've looked at.

                    string text = GeneralGFF.ConstructNodetext(field);
                    var    node = new Sortable(text, field.label);
                    node.Tag = field;
                    int id = SelectedNode.Nodes.Add(node);


                    field            = new GffData.Field();
                    field.type       = FieldTypes.CExoString;
                    field.label      = "Name";
                    field.CExoString = _varLabel;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field       = new GffData.Field();
                    field.type  = FieldTypes.DWORD;
                    field.label = "Type";
                    field.DWORD = _varType;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field       = new GffData.Field();
                    field.label = "Value";

                    switch (_varType)                     // TODO: delete the nodes above or put this above there
                    {
                    case VariableDialog.Type_non:         // not stable in toolset. is Disabled in the dialog
                        return;

                    case VariableDialog.Type_INT:
                        field.type = FieldTypes.INT;
                        field.INT  = Int32.Parse(_varValue);
                        break;

                    case VariableDialog.Type_FLOAT:
                        field.type  = FieldTypes.FLOAT;
                        field.FLOAT = Single.Parse(_varValue);
                        break;

                    case VariableDialog.Type_STRING:
                        field.type       = FieldTypes.CExoString;
                        field.CExoString = _varValue;
                        break;

                    case VariableDialog.Type_LOCATION:                                  // not stable in toolset. is Disabled in the dialog
                        return;

                    case VariableDialog.Type_UINT:                                      // and I can't see this being useful at all.
                        field.type  = FieldTypes.DWORD;
                        field.DWORD = UInt32.Parse(_varValue);
                        break;
                    }

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    SelectedNode = SelectedNode.Nodes[id];
                    SelectedNode.Expand();

                    TopNode = top;

                    _f.GffData.Changed = true;
                    _f.GffData         = _f.GffData;

                    EndUpdate();

                    node.EnsureVisible();                     // yes those calls are in a specific sequence.
                }
            }
        }
Exemple #27
0
        /// <summary>
        /// Adds an apparel-type.
        /// </summary>
        void AddApparel(string label)
        {
            BeginUpdate();

            TreeNode top = TopNode;

            var field = new GffData.Field();

            field.type          = FieldTypes.Struct;
            field.label         = label;
            field.Struct        = new Struct();
            field.Struct.typeid = 0;             // <- that's what's in the UTCs I've looked at.

            string text = GeneralGFF.ConstructNodetext(field);
            var    node = new Sortable(text, field.label);

            node.Tag = field;
            int id = SelectedNode.Nodes.Add(node);


            field               = new GffData.Field();
            field.type          = FieldTypes.Struct;
            field.label         = "ArmorTint";
            field.Struct        = new Struct();
            field.Struct.typeid = 0;             // <- that's what's in the UTCs I've looked at.

            text = GeneralGFF.ConstructNodetext(field);
            var tint = new Sortable(text, field.label);

            tint.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(tint);

            AddTints(tint);


            field       = new GffData.Field();
            field.type  = FieldTypes.BYTE;
            field.BYTE  = 0;
            field.label = "ArmorVisualType";

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);

            field       = new GffData.Field();
            field.type  = FieldTypes.BYTE;
            field.BYTE  = 0;
            field.label = "Variation";

            text     = GeneralGFF.ConstructNodetext(field);
            node     = new Sortable(text, field.label);
            node.Tag = field;
            SelectedNode.Nodes[id].Nodes.Add(node);


            SelectedNode = SelectedNode.Nodes[id];
            SelectedNode.Expand();

            TopNode = top;

            _f.GffData.Changed = true;
            _f.GffData         = _f.GffData;

            EndUpdate();

            node.EnsureVisible();             // yes those calls are in a specific sequence.
        }
Exemple #28
0
        /// <summary>
        /// Adds a Struct (an EquippedItem structure) to the "Equip_ItemList" List.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void contextclick_AddEquippedItem(object sender, EventArgs e)
        {
            GffData.Field field;

            _bitslot = 0;
            for (int i = 0; i != SelectedNode.Nodes.Count; ++i)
            {
                field     = (GffData.Field)SelectedNode.Nodes[i].Tag;
                _bitslot |= field.Struct.typeid;
            }

            using (var f = new EquippedItemDialog(_bitslot))
            {
                _bitslot = 0;
                if (f.ShowDialog(this) == DialogResult.OK)
                {
                    BeginUpdate();

                    TreeNode top = TopNode;

                    field               = new GffData.Field();
                    field.type          = FieldTypes.Struct;
                    field.label         = SelectedNode.Nodes.Count.ToString(); // Structs in Lists do not have a Label
                    field.Struct        = new Struct();
                    field.Struct.typeid = _bitslot;                            // <- that's what's in the UTCs I've looked at.

                    string text = GeneralGFF.ConstructNodetext(field);
                    var    node = new Sortable(text, field.label);
                    node.Tag = field;
                    int id = SelectedNode.Nodes.Add(node);


                    field       = new GffData.Field();
                    field.type  = FieldTypes.BYTE;
                    field.label = "Dropable";
                    field.BYTE  = 0;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field         = new GffData.Field();
                    field.type    = FieldTypes.CResRef;
                    field.label   = "EquippedRes";
                    field.CResRef = String.Empty;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field       = new GffData.Field();
                    field.type  = FieldTypes.BYTE;
                    field.label = "Pickpocketable";
                    field.BYTE  = 0;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field       = new GffData.Field();
                    field.type  = FieldTypes.WORD;
                    field.label = "Repos_PosX";
                    field.WORD  = 0;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);

                    field       = new GffData.Field();
                    field.type  = FieldTypes.WORD;
                    field.label = "Repos_PosY";
                    field.WORD  = 0;

                    text     = GeneralGFF.ConstructNodetext(field);
                    node     = new Sortable(text, field.label);
                    node.Tag = field;
                    SelectedNode.Nodes[id].Nodes.Add(node);


                    // keep the List's nodes in the correct sequence ->
                    // they are arranged by Struct.typeid ascending

                    int i;                     // iterator for the sortables
                    int j;                     // tracker for the node # added

                    // store all the sortable Structs in the List ->
                    // NOTE: This is not an ideal routine. Because it adds all
                    // the nodes to the tree, then removes them, then adds them
                    // all again. It should, rather, just construct the Struct
                    // and its fields, then add the Struct to the tree.

                    var sortables = new List <Sortable>();
                    for (i = 0; i != SelectedNode.Nodes.Count; ++i)
                    {
                        sortables.Add((Sortable)SelectedNode.Nodes[i]);
                    }

                    SelectedNode.Nodes.Clear();                     // NOTE: 'SelectedNode' is the "Equip_ItemList" list-field.


                    // re-add the sortables before the added sortable ->
                    i = j = 0;
                    while (i != sortables.Count)
                    {
                        field = (GffData.Field)sortables[i].Tag;
                        if (field.Struct.typeid < _bitslot)
                        {
                            // NOTE: 'field.label' doesn't need to be changed here
                            sortables[i].Text = GeneralGFF.ConstructNodetextEquipped(field);
                            SelectedNode.Nodes.Add(sortables[i]);
                            j = i;
                        }
                        ++i;
                    }

                    id = ++j;

                    // re-add the last sortable into the sequence ->
                    // replace vals that were set above for the Struct's label and its Sortable's text and label
                    field       = (GffData.Field)sortables[sortables.Count - 1].Tag;
                    field.label = sortables[sortables.Count - 1]._label = j.ToString();
                    sortables[sortables.Count - 1].Text = GeneralGFF.ConstructNodetextEquipped(field);
                    SelectedNode.Nodes.Add(sortables[sortables.Count - 1]);


                    // re-add the sortables that go after the added sortable ->
                    i = 0;
                    while (i != sortables.Count)
                    {
                        field = (GffData.Field)sortables[i].Tag;
                        if (field.Struct.typeid > _bitslot)
                        {
                            field.label       = sortables[i]._label = (++j).ToString();
                            sortables[i].Text = GeneralGFF.ConstructNodetextEquipped(field);
                            SelectedNode.Nodes.Add(sortables[i]);
                        }
                        ++i;
                    }

                    SelectedNode = SelectedNode.Nodes[id];
                    SelectedNode.Expand();

                    TopNode = top;

                    _f.GffData.Changed = true;
                    _f.GffData         = _f.GffData;

                    EndUpdate();

                    node.EnsureVisible();                     // yes those calls are in a specific sequence.
                }
            }
        }