Exemple #1
0
        /// <summary>
        /// Overridden OpenScene function
        /// </summary>
        /// <param name="relFilename"></param>
        /// <returns></returns>
        public override bool OpenScene(string relFilename)
        {
            // project must not have an active scene
            if (Scene != null)
            {
                return(false);
            }

            object[]    parameters = { this, relFilename };
            EditorScene scene      = EditorManager.SceneFactory.CreateInstance(parameters) as EditorScene;

            if (scene == null)
            {
                EditorManager.ShowMessageBox("Scene must be derived from class 'EditorScene'", "Failed to create scene", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // installer assembly resolver for editor plugin assemblies
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(SceneLoader_AssemblyResolve);

            // We set the scene here to make scene information available to de-serialization code that needs to load custom data.
            // I.e. profile specific settings that need to know the scene name to get the correct path.
            _currentlyLoadingScene = scene;
            if (!scene.Load(relFilename))
            {
                _currentlyLoadingScene = null;
                return(false);
            }
            _currentlyLoadingScene = null;

            AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(SceneLoader_AssemblyResolve);

            EditorManager.Progress.StatusString = "Create Shapes";
            Scene = scene; // this creates the engine instances since it calls EditorApp.Scene

            if (scene.SceneVersion != EditorScene.SCENE_VERSION_CURRENT)
            {
                // output info that the scene version is out of data
                EditorManager.ShowMessageBox("Scene file has outdated version number.\nPlease re-save scene.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                scene.Dirty = true;
            }

            return(true);
        }