예제 #1
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!commandTag.Equals(Commands.CreatePrefab))
            {
                return;
            }

            string filePath = Util.GetFilePath(m_fileFilter, Globals.ResourceRoot.LocalPath, true);

            if (!string.IsNullOrEmpty(filePath))
            {
                try
                {
                    // save selected gameobject to a new prototype file.
                    Uri     ur     = new Uri(filePath);
                    DomNode prefab = CreatePrefab(SelectedGobs);

                    string   filePathLocal = ur.LocalPath;
                    FileMode fileMode      = File.Exists(filePathLocal) ? FileMode.Truncate : FileMode.OpenOrCreate;
                    using (FileStream stream = new FileStream(filePathLocal, fileMode))
                    {
                        var writer = new CustomDomXmlWriter(Globals.ResourceRoot, m_schemaLoader.TypeCollection);
                        writer.Write(prefab, stream, ur);
                    }
                    m_resourceService.Unload(ur);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
        }
예제 #2
0
        public void Save(Uri uri, SchemaLoader schemaLoader)
        {
            if (Dirty || m_uriChanged)
            {
                string   filePath = uri.LocalPath;
                FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
                using (FileStream stream = new FileStream(filePath, fileMode))
                {
                    var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
                    writer.Write(DomNode, stream, uri);
                }
                m_uriChanged = false;
            }

            // save all the game-references
            foreach (var gameRef in GetChildList <GameReference>(Schema.gameType.gameReferenceChild))
            {
                GameDocument subDoc = Adapters.As <GameDocument>(gameRef.Target);
                if (subDoc == null)
                {
                    continue;
                }
                subDoc.Save(subDoc.Uri, schemaLoader);
            }

            Dirty = false;
        }
예제 #3
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!commandTag.Equals(Commands.CreatePrototype))
                return;

            string filePath = Util.GetFilePath(m_fileFilter,Globals.ResourceRoot.LocalPath,true);
            if (!string.IsNullOrEmpty(filePath))
            {
                try
                {
                    // save selected gameobject to a new prototype file.
                    Uri ur = new Uri(filePath);
                    DomNode prototype = CreatePrototype(SelectedGobs);

                    string filePathLocal = ur.LocalPath;
                    FileMode fileMode = File.Exists(filePathLocal) ? FileMode.Truncate : FileMode.OpenOrCreate;
                    using (FileStream stream = new FileStream(filePathLocal, fileMode))
                    {
                        var writer = new CustomDomXmlWriter(Globals.ResourceRoot, m_schemaLoader.TypeCollection);
                        writer.Write(prototype, stream, ur);
                    }
                    m_resourceService.Unload(ur);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(m_mainWindow.DialogOwner, ex.Message);
                }
            }
        }
예제 #4
0
파일: GameDocument.cs 프로젝트: ldh9451/XLE
 private static void SaveDomDocument(DomNode node, Uri uri, ISchemaLoader schemaLoader)
 {
     string filePath = uri.LocalPath;
     Directory.CreateDirectory(new FileInfo(filePath).Directory.FullName);
     FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
     using (FileStream stream = new FileStream(filePath, fileMode))
     {
         var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
         writer.Write(node, stream, uri);
     }
 }
예제 #5
0
        private static void SaveDomDocument(DomNode node, Uri uri, ISchemaLoader schemaLoader)
        {
            string filePath = uri.LocalPath;

            Directory.CreateDirectory(new FileInfo(filePath).Directory.FullName);
            FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;

            using (FileStream stream = new FileStream(filePath, fileMode))
            {
                var writer = new CustomDomXmlWriter(uri, schemaLoader.TypeCollection);
                writer.Write(node, stream, uri);
            }
        }
예제 #6
0
        public void Save(Uri uri, SchemaLoader schemaLoader)
        {
            if (Dirty || m_uriChanged)
            {                
                string filePath = uri.LocalPath;
                FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate;
                using (FileStream stream = new FileStream(filePath, fileMode))
                {
                    var writer = new CustomDomXmlWriter(Globals.ResourceRoot, schemaLoader.TypeCollection);
                    writer.Write(DomNode, stream, uri);
                }
                m_uriChanged = false;
            }
            
            // save all the game-references
            foreach (var gameRef in GetChildList<GameReference>(Schema.gameType.gameReferenceChild))
            {
                GameDocument subDoc = Adapters.As<GameDocument>(gameRef.Target);
                if(subDoc == null) continue;
                subDoc.Save(subDoc.Uri, schemaLoader);                
            }

            Dirty = false;
        }