Пример #1
0
        private void editResource(Value value)
        {
            IDocumentPanel editorPanel = null;
            Resource       resource    = value.Getter() as Resource;

            if (value.Type == typeof(Managed.Graphics.Texture.Image))
            {
                /*editorPanel = new ImageEditorPanel() {
                 *  Image = resource as Managed.Graphics.Texture.Image
                 * };*/
            }
            else if (value.Type == typeof(Material))
            {
                editorPanel = new MaterialEditorPanel()
                {
                    Material = resource as Material
                };
            }
            else if (value.Type == typeof(Sound))
            {
                editorPanel = new SoundEditorPanel()
                {
                    Sound = resource as Sound
                };
            }
            else if (value.Type == typeof(Script))
            {
                if (resource == null)
                {
                    resource = Managed.Script.Scripts.MakeEmpty(value.Owner as Entity);
                }
                editorPanel = new ScriptEditorPanel()
                {
                    Script = resource as Script
                };
                value.Setter(resource);
            }
            else
            {
                MessageBox.Show(this, "GhurundEngine is unable to open files of that type.", "Unknown format", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            openPanel(this, editorPanel);

            if (resource.FileName != null)
            {
                Settings.AddRecentFile(resource.FileName);
            }
        }
Пример #2
0
        private void openFile(string path)
        {
            IDocumentPanel editorPanel;

            if (path.EndsWith("jpg") || path.EndsWith("jpeg") || path.EndsWith("png"))
            {
                editorPanel = new ImageEditorPanel();
            }
            else if (path.EndsWith("scene"))
            {
                editorPanel = new SceneEditorPanel();
            }
            else if (path.EndsWith("hlsl") || path.EndsWith("material"))
            {
                editorPanel = new MaterialEditorPanel();
            }
            else if (path.EndsWith("wav"))
            {
                editorPanel = new SoundEditorPanel();
            }
            else if (path.EndsWith("script"))
            {
                editorPanel = new ScriptEditorPanel();
            }
            else if (path.EndsWith("project"))
            {
                closeProject();
                openProject(path);
                Settings.AddRecentProject(path);
                return;
            }
            else
            {
                MessageBox.Show(this, "GhurundEngine is unable to open files of that type.", "Unknown format", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (!editorPanel.Load(path))
            {
                MessageBox.Show(this, "There was an error while reading the file. Please make sure that the file is correct, all dependencies are available and its format matches the extension. More information can be found in the logs.", "Error while reading the file", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            openPanel(this, editorPanel);

            Settings.AddRecentFile(path);
        }