示例#1
0
        /// <summary>
        /// 拖放结束事件, Resource Quick List中拖动一个Mesh资源文件,创建响应的Actor到Level中
        /// </summary>
        void NEMainViewport_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(NexusEngine.NFileEntity)))
            {
                NFileEntity  resFile = (NFileEntity)e.Data.GetData(typeof(NFileEntity));
                NResourceLoc resLoc  = new NResourceLoc(resFile.PackageName, resFile.FilePath);

                if (ResourceEditor.ResourceActorCreator.AcceptResoruceFile(resLoc))
                {
                    NLevel mainLv   = NLevelEditorEngine.Instance.MainLevel;
                    NActor newActor = ResourceEditor.ResourceActorCreator.CreateActor(resLoc);
                    if (newActor == null)
                    {
                        MessageBox.Show("添加对象失败,可能的原因是读取对象数据失败,或者当前作业层被锁定,等等", "错误");
                        return;
                    }
                    Point        scrPt    = new Point(e.X, e.Y);
                    Point        clientPt = this.PointToClient(scrPt);
                    Ray          ray      = m_view.Camera.GetMouseRay(clientPt.X, clientPt.Y);
                    NCheckResult chk;
                    if (RayCheck(out chk, ray, 512 * 1024, LineCheckType.Terrain))
                    {
                        newActor.Location = chk.location;
                    }
                    else
                    {
                        Vector3 pt = ray.Position + ray.Direction * 500;
                        newActor.Location = pt;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 响应Resource列表选中事件, 将选中的文件的缩略图显示到列表下方的PictureBox上
        /// </summary>
        private void listViewResource_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = this.listViewResource.SelectedItems;
            if (selItems.Count <= 0)
            {
                return;
            }

            ListViewItem sel    = selItems[0];
            NFileEntity  nfile  = (NFileEntity)sel.Tag;
            NResourceLoc resLoc = new NResourceLoc(nfile.PackageName, nfile.FilePath);
            //m_resPreview.ShowResource(resLoc);
            //m_resPreview.ZoomExtents();

            int i = m_resBigImgList.Images.IndexOfKey(resLoc.ToString());

            if (i == -1)
            {
                this.pictureBoxResource.Image = null;
            }
            else
            {
                this.pictureBoxResource.Image = m_resBigImgList.Images[i];
            }
        }
示例#3
0
        private void ImportPSK()
        {
            try
            {
                int maxLOD = 0;
                if (SkeletalMeshPreview != null)
                {
                    maxLOD = SkeletalMeshPreview.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Skeletal Mesh LOD";
                dlg.FileFilter = "ActorX Skeletal Mesh file(*.PSK)|*.PSK";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (SkeletalMeshPreview == null)
                    {
                        // 产生一个不重复的名称
                        string resName = "NewSkeletalMesh";
                        resName += DateTime.Now.ToFileTime();

                        // 创建空白资源和内部数据
                        SkeletalMeshPreview = NResourceManager.Instance.NewSkeletalMesh(resName);
                    }

                    //-- 使得Resource的名称与LOD 0的文件名相同
                    if (skeletalMeshProperty != null && dlg.SelectedLOD == 0)
                    {
                        NFileEntity fileName = new NFileEntity();
                        fileName.path = dlg.SelectedFile;
                        fileName.path = fileName.path.Replace('\\', '/');

                        skeletalMeshProperty.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        try
                        {
                            SkeletalMeshPreview.ImportSkeletalMeshLOD(dlg.SelectedLOD, dlg.SelectedFile);
                            SkeletalMeshPreview.PostEditChange(true);
                            // 必须重置Preview
                            previewControl.ResetSkeletalMeshResource(skeletalMeshPreview);
                        }
                        catch (System.Exception ex)
                        {
                            NexusEditor.Program.ShowException(ex, "Import Skeletal Mesh LOD FAILED!");
                        }

                        // 更新界面
                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Skeletal Mesh LOD FAILED!");
            }
        }
        private void listViewResource_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            if (e.IsSelected)
            {
                object      itemTag = e.Item.Tag;
                NFileEntity file    = (NFileEntity)itemTag;

                NLevelEditorEngine.Instance.CurrentResource =
                    new NResourceLoc(file.PackageName, file.FilePath);
            }
        }
        protected void NGUIRenderControl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            try
            {
                Point     pt             = this.PointToClient(new Point(e.X, e.Y));
                Vector2   DropPosition   = new Vector2(pt.X, pt.Y);
                GUISystem guiSystem      = GUISystem.Instance;
                Vector2   screenPosition = guiSystem.ClientToScreen(new Vector2(pt.X, pt.Y));

                if (e.Data.GetDataPresent(typeof(NFileEntity)))
                {
                    NFileEntity entity = (NFileEntity)e.Data.GetData(typeof(NFileEntity));
                    m_owner.CreateStyleWindow(entity, screenPosition);
                }
                else
                {
                    //获得进行"Drag"操作中拖动的字符串
                    string controlType = e.Data.GetData(typeof(string)) as string;

                    // 在拖放的位置创建窗口
                    if (!WindowManager.Instance.IsTypeRegedited(controlType))
                    {
                        return;
                    }

                    Window parentWnd = guiSystem.GetTargetWindow(screenPosition);
                    if (parentWnd == null)
                    {
                        parentWnd = guiSystem.RootWindow;
                    }

                    Window wnd = WindowManager.Instance.CreateWindow(controlType, parentWnd);
                    wnd.AbsolutePosition = screenPosition;
                    if (wnd.AbsoluteSize.Length() == 0)
                    {
                        wnd.Width  = new UIDim(0, 150);
                        wnd.Height = new UIDim(0, 100);
                    }
                    parentWnd.AddChild(wnd);

                    // 发送响应事件
                    if (WindowCreated != null)
                    {
                        UIECreateWindowEventArg createEvent = new UIECreateWindowEventArg(wnd);
                        WindowCreated(this, createEvent);
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Drag drop failed!");
            }
        }
示例#6
0
        /// <summary>
        /// 引擎Callback函数
        /// </summary>
        /// <param name="file">文件对象描述</param>
        public override void OnFileEntity(ref NFileEntity file)
        {
            if (file.type != EFileEntityType.Regular)
            {
                return;
            }

            if (file.FileName.Substring(file.FileName.Length - 4).Equals(".nui"))
            {
                ListViewItem it = listView.Items.Add(file.FilePath);
                it.Tag = file;
            }
        }
示例#7
0
        public bool FileEnabled(NFileEntity file)
        {
            if (file.type != EFileEntityType.Regular)
            {
                return(false);
            }

            if (m_allPass)
            {
                return(true);
            }

            return(m_fileExtSet.Contains(file.FileExtension));
        }
        /// <summary>
        /// 引擎Callback函数
        /// </summary>
        /// <param name="file">文件对象描述</param>
        public override void OnFileEntity(ref NFileEntity file)
        {
            if (file.type == EFileEntityType.Regular)
            {
                bool add = true;
                if (m_filter != null)
                {
                    add = m_filter.FileEnabled(file);
                }

                if (add)
                {
                    ListViewItem it        = m_listCtrl.Items.Add(file.FileName);
                    string       thumbName =
                        ThumbnailManager.Instance.LoadThumbnail(file.PackageName, file.FilePath,
                                                                m_imgList, m_imgListSmall);

                    uint     fileSize = NEngine.Instance().FileSystem.GetFileSize(file.PackageName, file.FilePath);
                    DateTime fileTime = NEngine.Instance().FileSystem.GetFileTime(file.PackageName, file.FilePath);

                    it.ImageKey = thumbName;
                    it.Tag      = file;

                    //-- sub item [file size]
                    string strFileSize;
                    if (fileSize > 1024)
                    {
                        strFileSize = string.Format("{0}KB", fileSize / 1024);
                    }
                    else
                    {
                        strFileSize = fileSize.ToString();
                    }
                    it.SubItems.Add(strFileSize);

                    //-- sub item [resource type]
                    it.SubItems.Add(GetResourceTypeByFileExt(file.FileExtension));

                    //-- sub item [file time]
                    string strFileTime = string.Format("{0} {1}",
                                                       fileTime.ToShortDateString(), fileTime.ToShortTimeString());
                    it.SubItems.Add(strFileTime);
                }
            }
        }
        private void toolStripButtonImport_Click(object sender, EventArgs e)
        {
            try
            {
                int maxLOD = 0;
                if (m_resAnimMesh != null)
                {
                    maxLOD = m_resAnimMesh.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Anim Mesh LOD";
                dlg.FileFilter = "All Support Files(*.fak;*.md2)|*.fak;*.md2|F3D Anim Mesh file(*.fak)|*.fak|Quake2 Anim Mesh file(*.md2)|*.md2";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (m_resAnimMesh == null)
                    {
                        CreateResource();
                    }

                    //-- 使得Resource的名称与LOD 0的文件名相同
                    if (dlg.SelectedLOD == 0)
                    {
                        NFileEntity fileName = new NFileEntity();
                        fileName.path = dlg.SelectedFile;
                        fileName.path = fileName.path.Replace('\\', '/');

                        m_prop.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        m_resAnimMesh.ImportLOD(dlg.SelectedLOD, dlg.SelectedFile);
                        m_resAnimMesh.PostEditChange(true);

                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Static Mesh LOD FAILED!");
            }
        }
示例#10
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int maxLOD = 0;
                if (m_resStaticMesh != null)
                {
                    maxLOD = m_resStaticMesh.GetNumLOD();
                }

                ImportLODDlg dlg = new ImportLODDlg(maxLOD);
                dlg.Text       = "Import Static Mesh LOD";
                dlg.FileFilter = "All Support Files(*.obj;*.fsm;*.fscn)|*.obj;*.fsm;*.fscn|Wavefront OBJ file(*.obj)|*.obj|F3D Static mesh file(*.fsm)|*.fsm|F3D Scene mesh file(*.fscn)|*.fscn";
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (m_resStaticMesh == null)
                    {
                        CreateResource();
                    }

                    //-- 使得Resource的名称与LOD 0的文件名相同
                    if (dlg.SelectedLOD == 0)
                    {
                        NFileEntity fileName = new NFileEntity();
                        fileName.path = dlg.SelectedFile;
                        fileName.path = fileName.path.Replace('\\', '/');

                        m_prop.Name = fileName.FileNameNoExtension;
                    }

                    using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
                    {
                        m_resStaticMesh.ImportLOD(dlg.SelectedLOD, dlg.SelectedFile);
                        m_resStaticMesh.PostEditChange(true);
                        m_preview.ShowStaticMesh(m_resStaticMesh);
                        RefreshLOD();
                    }
                }
            }
            catch (System.Exception ex)
            {
                NexusEditor.Program.ShowException(ex, "Import Static Mesh LOD FAILED!");
            }
        }
        public override void OnFileEntity(ref NFileEntity file)
        {
            if (file.type == EFileEntityType.Folder)
            {
                TreeNode folderNode = m_pkgNode.Nodes.Add(file.FileName);
                folderNode.SelectedImageIndex = 1;
                folderNode.ImageIndex         = 0;

                //-- set tag
                NEFileTag tag;
                tag.pkgName    = m_pkgName;
                tag.path       = file.path;
                folderNode.Tag = tag;

                //-- query the folder
                NFileSystem        fileSys = Program.engine.FileSystem;
                NEFolderTreeWalker fq      = new NEFolderTreeWalker(folderNode, m_pkgName, file.path);
                fileSys.QueryPackage(m_pkgName, file.path, fq);
            }
        }
示例#12
0
        private void toolStripReplace_Click(object sender, EventArgs e)
        {
            //用资源列表中选定的对象替换当前level中选定的所有对象
            if (listViewResource.SelectedItems.Count == 0)
            {
                toolStripStatusLableNote.Text = "资源列表中没有选中的对象";
                return;
            }
            ListViewItem item   = listViewResource.SelectedItems[0];
            NFileEntity  nfile  = (NFileEntity)item.Tag;
            NResourceLoc resLoc = new NResourceLoc(nfile.PackageName, nfile.FilePath);

            if (ResourceEditor.ResourceActorCreator.AcceptResoruceFile(resLoc))
            {
                List <NActor> actors      = NLevelEditorEngine.Instance.ActorEd.GetSelectedActors();
                List <NActor> newActors   = new List <NActor>();
                NActor        activeActor = NLevelEditorEngine.Instance.ActorEd.GetActor();
                for (int i = 0; i < actors.Count; ++i)
                {
                    NActor act = actors[i];
                    if (act.Frozen)
                    {
                        continue;
                    }
                    NActor newActor = ResourceEditor.ResourceActorCreator.CreateActor(resLoc);
                    if (newActor != null)
                    {
                        newActor.Layer     = act.Layer;
                        newActor.SpaceData = act.SpaceData;
                        newActors.Add(newActor);
                    }
                }
                NLevelEditorEngine.Instance.ActorEd.DeleteSelectedActors();
                for (int i = 0; i < newActors.Count; ++i)
                {
                    NLevelEditorEngine.Instance.ActorEd.AddSelectedActor(newActors[i]);
                }
            }
        }
示例#13
0
 internal void CreateStyleWindow(NFileEntity entity, Vector2 screenPosition)
 {
     ReloadResource(GUISystem.Instance.GetTargetWindow(screenPosition),
                    entity.PackageName, entity.FilePath, true);
 }
        private void listViewResource_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListView.SelectedListViewItemCollection selItems = this.listViewResource.SelectedItems;
            if (selItems.Count <= 0)
            {
                return;
            }

            ListViewItem sel = selItems[0];

            NFileEntity nfile = (NFileEntity)sel.Tag;

            using (NexusEngineExtension.NWaitCursor wc = new NexusEngineExtension.NWaitCursor(this))
            {
                switch (nfile.FileExtension)
                {
                case "spt":
                    m_sptViewer.ShowSpt(nfile.pkg, nfile.path);
                    m_sptViewer.Show(this);
                    break;

                case "nmdl":
                    m_staticMeshEditor.LoadStaticMesh(nfile.PackageName, nfile.FilePath);
                    m_staticMeshEditor.Show();
                    break;

                case "nam":
                    m_animMeshEditor.LoadAnimMesh(nfile.PackageName, nfile.FilePath);
                    m_animMeshEditor.Show();
                    break;

                case "skm":
                    m_animSetEditor.LoadSkeletalMesh(nfile.PackageName, nfile.FilePath);
                    m_animSetEditor.Show();
                    break;

                case "animset":
                    m_animSetEditor.LoadAnimSet(nfile.PackageName, nfile.FilePath);
                    m_animSetEditor.Show();
                    break;

                case "txa":
                    m_texAtlasViewer.LoadTextureAtlas(nfile.pkg, nfile.path);
                    m_texAtlasViewer.Show(this);
                    break;

                case "nui":
                    m_guiEditor.LoadUI(nfile.pkg, nfile.path);
                    if (!m_guiEditor.Visible)
                    {
                        m_guiEditor.Show();
                    }
                    break;

                case "mtl":
                    m_MaterialEditor.LoadMaterial(nfile.PackageName, nfile.FilePath);
                    m_MaterialEditor.Show();
                    break;

                case "att":
                    ResAttributeInfoEditor infoEditor = new ResAttributeInfoEditor();
                    infoEditor.ResetAttributeInfo(nfile.PackageName, nfile.FilePath);
                    infoEditor.Show();
                    break;
                }
            }
        }