Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            IsMdiContainer = true;

            _nodePropertyViewer      = new PropertyView();
            _nodePropertyViewer.Dock = DockStyle.Fill;
            _nodePropertyViewer.Show(dockPanel);

            //dockPanel.ShowDocumentIcon = true;
            dockPanel.ActiveContentChanged += (sender, args) =>
            {
                if (dockPanel.ActiveContent != null)
                {
                    LastActiveContent = dockPanel.ActiveContent;
                }
            };

            Viewport      = new CommonViewport();
            Viewport.Dock = DockStyle.Fill;
            Viewport.Show(dockPanel);

            //_ScriptEditor = new SubactionEditor();
            //_ScriptEditor.Dock = DockStyle.Fill;

            ImageList myImageList = new ImageList();

            myImageList.ImageSize = new System.Drawing.Size(24, 24);
            myImageList.Images.Add("unknown", Properties.Resources.ico_unknown);
            myImageList.Images.Add("known", Properties.Resources.ico_known);
            myImageList.Images.Add("folder", Properties.Resources.ico_folder);
            myImageList.Images.Add("group", Properties.Resources.ico_group);
            myImageList.Images.Add("table", Properties.Resources.ico_table);
            myImageList.Images.Add("jobj", Properties.Resources.ico_jobj);
            myImageList.Images.Add("dobj", Properties.Resources.ico_dobj);
            myImageList.Images.Add("pobj", Properties.Resources.ico_pobj);
            myImageList.Images.Add("mobj", Properties.Resources.ico_mobj);
            myImageList.Images.Add("tobj", Properties.Resources.ico_tobj);
            myImageList.Images.Add("aobj", Properties.Resources.ico_aobj);
            myImageList.Images.Add("cobj", Properties.Resources.ico_cobj);
            myImageList.Images.Add("fobj", Properties.Resources.ico_fobj);
            myImageList.Images.Add("iobj", Properties.Resources.ico_iobj);
            myImageList.Images.Add("lobj", Properties.Resources.ico_lobj);
            myImageList.Images.Add("sobj", Properties.Resources.ico_sobj);
            myImageList.Images.Add("coll", Properties.Resources.ico_coll);
            myImageList.Images.Add("anim_texture", Properties.Resources.ico_anim_texture);
            myImageList.Images.Add("anim_material", Properties.Resources.ico_anim_material);
            myImageList.Images.Add("anim_joint", Properties.Resources.ico_anim_joint);
            myImageList.Images.Add("anim_shape", Properties.Resources.ico_anim_shape);
            myImageList.Images.Add("kabii", Properties.Resources.ico_kabii);
            myImageList.Images.Add("fuma", Properties.Resources.ico_fuma);

            treeView1.ImageList = myImageList;

            bool dc = false;

            treeView1.MouseDown += (sender, args) =>
            {
                dc = args.Clicks > 1;
            };

            treeView1.BeforeExpand += (sender, args) =>
            {
                args.Cancel = dc;

                if (args.Node is DataNode node && Instance.IsOpened(node) && !dc)
                {
                    MessageBox.Show("Error: This node is currently open in an editor\nPlease close it first to expand");
                    args.Cancel = true;
                }

                dc = false;
            };

            treeView1.AfterExpand += (sender, args) =>
            {
                args.Node.Nodes.Clear();
                treeView1.BeginUpdate();
                if (args.Node is DataNode node)
                {
                    node.ExpandData();
                }
                treeView1.EndUpdate();
            };

            treeView1.AfterCollapse += (sender, args) =>
            {
                treeView1.BeginUpdate();
                args.Node.Nodes.Clear();
                args.Node.Nodes.Add(new TreeNode());
                treeView1.EndUpdate();
            };

            treeView1.AfterSelect += (sender, args) =>
            {
                SelectNode <HSDAccessor>();
            };

            treeView1.NodeMouseClick += (sender, args) =>
            {
                treeView1.SelectedNode = treeView1.GetNodeAt(args.Location);
                if (args.Button == MouseButtons.Right && args.Node != null && args.Node is DataNode node)
                {
                    PluginManager.GetContextMenuFromType(node.Accessor.GetType()).Show(this, args.Location);
                }
                try
                {
                    var kb = OpenTK.Input.Keyboard.GetState();
                    if (kb.IsKeyDown(OpenTK.Input.Key.ShiftLeft) || kb.IsKeyDown(OpenTK.Input.Key.ShiftRight))
                    {
                        treeView1.BeginUpdate();
                        treeView1.SelectedNode.ExpandAll();
                        treeView1.EndUpdate();
                    }
                }
                catch (Exception)
                {
                }
            };
        }
Esempio n. 2
0
        /// <summary>
        /// Opens editor for currently selected node if editor exists
        /// </summary>
        public void OpenEditor()
        {
            if (SelectedDataNode == null)
            {
                return;
            }

            var edit = PluginManager.GetEditorFromType(SelectedDataNode.Accessor.GetType());

            // Special animation override
            if (SelectedDataNode.Accessor is HSD_AnimJoint ||
                SelectedDataNode.Accessor is HSD_FigaTree ||
                SelectedDataNode.Accessor is HSD_MatAnimJoint ||
                SelectedDataNode.Accessor is HSD_ShapeAnimJoint ||
                SelectedDataNode.Accessor is HSD_FogDesc ||
                SelectedDataNode.Accessor is HSD_Camera ||
                SelectedDataNode.Accessor is SBM_ModelPart)
            {
                //foreach (var v in dockPanel.Contents)
                {
                    if (LastActiveContent is JobjEditorDock jedit && jedit.Visible)
                    {
                        if (SelectedDataNode.Accessor is HSD_MatAnimJoint matjoint)
                        {
                            jedit.LoadAnimation(matjoint);
                        }

                        if (SelectedDataNode.Accessor is HSD_ShapeAnimJoint shapeJoint)
                        {
                            jedit.LoadAnimation(shapeJoint);
                        }

                        if (SelectedDataNode.Accessor is HSD_AnimJoint joint)
                        {
                            jedit.LoadAnimation(new JointAnimManager(joint));
                        }

                        if (SelectedDataNode.Accessor is HSD_FigaTree tree)
                        {
                            jedit.LoadAnimation(new JointAnimManager(tree));
                        }

                        if (SelectedDataNode.Accessor is HSD_FogDesc fog)
                        {
                            jedit.Editor.SetFog(fog);
                        }

                        if (SelectedDataNode.Accessor is HSD_Camera camera)
                        {
                            jedit.Editor.SetCamera(camera);
                        }

                        if (SelectedDataNode.Accessor is SBM_ModelPart modelPart && modelPart.Anims.Length > 0)
                        {
                            if (prev_selected_part == modelPart)
                            {
                                part_select_index++;
                            }
                            else
                            {
                                part_select_index = 0;
                            }

                            prev_selected_part = modelPart;

                            if (part_select_index > modelPart.Anims.Length)
                            {
                                part_select_index = 0;
                            }

                            JointAnimManager manager = new JointAnimManager();
                            for (int i = 0; i < modelPart.StartingBone; i++)
                            {
                                manager.Nodes.Add(new AnimNode());
                            }
                            manager.Nodes.AddRange(new JointAnimManager(modelPart.Anims[part_select_index]).Nodes);
                            jedit.LoadAnimation(manager);
                        }
                    }
                }
            }

            if (IsOpened(SelectedDataNode))
            {
                var editor = GetEditors(SelectedDataNode);
                editor[0].BringToFront();
            }
            else
            if (!IsChildOpened(SelectedDataNode.Accessor._s) &&
                edit != null &&
                edit is DockContent dc)
            {
                //Editors.Add(edit);
                SelectedDataNode.Collapse();
                edit.Node = SelectedDataNode;

                dc.Show(dockPanel);

                dc.Text    = SelectedDataNode.Text;
                dc.TabText = SelectedDataNode.Text;
                //if (dc is EditorBase b)
                //    dc.DockState = b.DefaultDockState;
            }
        }