Ejemplo n.º 1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //删除当前选中目录
            TreeNode sel = this.treeViewFileSys.SelectedNode;

            if (sel == null || sel.Tag == null)
            {
                return;
            }
            NEFileTag tag = (NEFileTag)sel.Tag;

            if (tag.path.Length == 0)
            {
                return;
            }

            DialogResult rst = MessageBox.Show("删除文件夹会删除文件夹内的所有文件,并且该操作不可撤销,\n是否继续?", "Nexus Editor", MessageBoxButtons.YesNo);

            if (rst == DialogResult.Yes)
            {
                NLevelEditorEngine.Instance.FileSystem.DeleteDirectory(tag.pkgName, tag.path);
                //更新视图
                this.treeViewFileSys.Nodes.Remove(sel);
            }
        }
Ejemplo n.º 2
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            TreeNode sel = this.treeViewFileSys.SelectedNode;

            if (sel == null || sel.Tag == null)
            {
                return;
            }
            NEFileTag tag = (NEFileTag)sel.Tag;

            if (tag.path.Length == 0)
            {
                return;
            }
            sel.BeginEdit();
        }
Ejemplo n.º 3
0
 private void treeViewFileSys_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Tag != null)
     {
         using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
         {
             NEFileTag tag = (NEFileTag)e.Node.Tag;
             NLevelEditorEngine.Instance.CurrentFolder = new NResourceLoc(tag.pkgName, tag.path);
             m_PathList.Add(NLevelEditorEngine.Instance.CurrentFolder);
             if (m_PathList.Count == 11)                         //10次回溯
             {
                 m_PathList.RemoveAt(0);
             }
             m_PathPointer = m_PathList.Count - 1;
             RefreshFileList();
         }
     }
 }
Ejemplo n.º 4
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //新建目录
            //首先要获取当前目录
            TreeNode sel = this.treeViewFileSys.SelectedNode;

            if (sel.Tag == null)
            {
                return;
            }

            NEFileTag tag  = (NEFileTag)sel.Tag;
            String    path = tag.path + "/";
            uint      i    = 1;
            String    name;
            String    full_path;

            while (true)
            {
                name      = "NewFolder" + i.ToString();
                full_path = path + name;
                if (!NLevelEditorEngine.Instance.FileSystem.IsFileExist(tag.pkgName, full_path))
                {
                    break;
                }
                ++i;
            }
            NLevelEditorEngine.Instance.FileSystem.CreateDirectory(tag.pkgName, full_path);

            //更新目录树
            TreeNode folderNode = sel.Nodes.Add(name);

            folderNode.SelectedImageIndex = 1;
            folderNode.ImageIndex         = 0;

            //-- set tag
            NEFileTag newtag;

            newtag.pkgName = tag.pkgName;
            newtag.path    = full_path;
            folderNode.Tag = newtag;
            sel.Expand();
            folderNode.BeginEdit();
        }
Ejemplo n.º 5
0
        private void makeTextureAtlasHereToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode sel = this.treeViewFileSys.SelectedNode;

            if (sel.Tag == null)
            {
                return;
            }

            NEFileTag    tag = (NEFileTag)sel.Tag;
            NResourceLoc loc = new NResourceLoc(tag.pkgName, tag.path);

            using (MakeTextureAtlasDlg dlg = new MakeTextureAtlasDlg())
            {
                dlg.SetInputLoc(loc);
                loc.fileName += "/Atlas";
                dlg.SetOutputLoc(loc);
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    dlg.MakeIt();
                } // end of if()
            }     // end of using()
        }
Ejemplo n.º 6
0
 private void treeViewFileSys_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     //重命名的处理
     if (e.Label != null)
     {
         if (e.Label.Length > 0)
         {
             if (e.Label.IndexOfAny(new char[] { '@', '.', ',', '!' }) == -1)
             {
                 //完成重命名
                 TreeNode sel = e.Node;
                 if (sel.Tag == null)
                 {
                     //如果没有关联文件夹,则取消并返回
                     e.CancelEdit = true;
                     e.Node.EndEdit(true);
                     return;
                 }
                 NEFileTag tag = (NEFileTag)sel.Tag;
                 if (tag.path.Length == 0)
                 {
                     //不能编辑package
                     e.CancelEdit = true;
                     e.Node.EndEdit(true);
                     return;
                 }
                 String oldpath = tag.path;
                 int    len     = oldpath.LastIndexOf('/');
                 if (len == -1)
                 {
                     len = oldpath.Length;
                 }
                 String newpath = oldpath.Substring(0, len) + "/" + e.Label;
                 if (NLevelEditorEngine.Instance.FileSystem.RenameDirectory(tag.pkgName, oldpath, newpath))
                 {
                     tag.path   = tag.path.Substring(0, tag.path.LastIndexOf('/')) + "/" + e.Label;
                     e.Node.Tag = tag;
                     e.Node.EndEdit(false);
                 }
                 else
                 {
                     e.CancelEdit = true;
                     MessageBox.Show("重命名文件夹时发生错误", "Nexus Editor");
                     e.Node.BeginEdit();
                 }
             }
             else
             {
                 /* Cancel the label edit action, inform the user, and
                  * place the node in edit mode again. */
                 e.CancelEdit = true;
                 MessageBox.Show("文件夹的名字格式不正确。文件夹的名字里面不能包含有这些字符: '@','.', ',', '!'", "Nexus Editor");
                 e.Node.BeginEdit();
             }
         }
         else
         {
             e.CancelEdit = true;
             MessageBox.Show("文件夹的名字不能为空.\n请重新输入一个名字.", "Nexus Editor");
             e.Node.BeginEdit();
         }
     }
 }