示例#1
0
 public StringMapPathPropertyEditor(Dictionary <string, string> properties, string propertyName, string rootPath)
     : base(
         properties,
         propertyName,
         CollectionPropertyEditorUtils.CollectionType.JsonObject,
         (pd, pn) => {
     Path_PropertyEditor editor = new Path_PropertyEditor(pd, pn);
     editor.FileFilter          = ScenePageControl.DEFAULT_SCENE_FILTER;
     editor.RootPath            = rootPath;
     return(editor);
 })
 {
 }
示例#2
0
        private int AddAsset(string id, string meta, string tags, ProjectModel projectModel, out Asset_PropertyEditor outEditor, int y)
        {
            m_properties[id] = "null";
            Asset_PropertyEditor editor = null;

            if (m_type == SceneViewPlugin.AssetType.Texture)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                },
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("smooth", typeof(Bool_PropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("repeated", typeof(Bool_PropertyEditor))
                }, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Texture files (*.png)|*.png";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Shader)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("vspath", typeof(Path_PropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("fspath", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor vspathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("vspath");
                if (vspathEditor != null)
                {
                    vspathEditor.FileFilter = "Vertex shader files (*.vs)|*.vs";
                    if (projectModel != null)
                    {
                        vspathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
                Path_PropertyEditor fspathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("fspath");
                if (fspathEditor != null)
                {
                    fspathEditor.FileFilter = "Fragment shader files (*.fs)|*.fs";
                    if (projectModel != null)
                    {
                        fspathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Sound)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Sound files (*.mp3)|*.mp3";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Music)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Music files (*.mp3)|*.mp3";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.Font)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Font files (*.ttf)|*.ttf";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            else if (m_type == SceneViewPlugin.AssetType.CustomAsset)
            {
                editor = new Asset_PropertyEditor(m_properties, id, m_type,
                                                  new Asset_PropertyEditor.ItemEditorInfo[] {
                    new Asset_PropertyEditor.ItemEditorInfo("type", typeof(EnumPropertyEditor)),
                    new Asset_PropertyEditor.ItemEditorInfo("path", typeof(Path_PropertyEditor))
                }, null, id, meta, tags);
                EnumPropertyEditor typeEditor = editor == null ? null : editor.GetMetaEditor <EnumPropertyEditor>("type");
                if (typeEditor != null)
                {
                    List <string> values = SceneViewPlugin.ListCustomAssets();
                    typeEditor.ValuesSource = values == null ? null : values.ToArray();
                }
                Path_PropertyEditor pathEditor = editor == null ? null : editor.GetMetaEditor <Path_PropertyEditor>("path");
                if (pathEditor != null)
                {
                    pathEditor.FileFilter = "Custom asset files (*.*)|*.*";
                    if (projectModel != null)
                    {
                        pathEditor.RootPath = projectModel.WorkingDirectory + @"\" + projectModel.ActiveTargetWorkingDirectory;
                    }
                }
            }
            if (editor != null)
            {
                editor.Text = id;
                editor.UpdateEditorValue();
                editor.Top    = y;
                editor.Width  = Width;
                editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                Controls.Add(editor);
                editor.EditorJsonValueChangedCallback = this;
                y = editor.Bottom;
            }
            outEditor = editor;
            return(y + DEFAULT_SEPARATOR + DEFAULT_SEPARATOR);
        }