public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
     m_subProperties[property] = jsonValue;
     if (m_subProperties.ContainsKey("category") && m_subProperties.ContainsKey("mask") && m_subProperties.ContainsKey("group"))
     {
         JsonValue = "{ \"category\": " + m_subProperties["category"] + ", \"mask\": " + m_subProperties["mask"] + ", \"group\": " + m_subProperties["group"] + " }";
     }
 }
Example #2
0
 public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
     m_subProperties[property] = jsonValue;
     if (m_subProperties.ContainsKey("blendMode") && m_subProperties.ContainsKey("shader"))
     {
         JsonValue = "{ \"blendMode\": " + m_subProperties["blendMode"] + ", \"shader\": " + m_subProperties["shader"] + " }";
     }
 }
Example #3
0
 public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
     m_subProperties[property] = jsonValue;
     if (m_subProperties.ContainsKey("properties") && m_subProperties.ContainsKey("textures"))
     {
         JsonValue = "{ \"properties\": " + m_subProperties["properties"] + ", \"textures\": " + m_subProperties["textures"] + " }";
     }
 }
        private int InitializePropertyFragment(string component, MetaProperty property, Type editorType, int y)
        {
            if (property == null || editorType == null)
            {
                return(y);
            }

            string propertyPath = "components/" + component + "/" + property.Name;

            if (m_goData == null || !m_goData.ContainsKey(propertyPath))
            {
                return(y);
            }

            try
            {
                object           obj      = PropertyEditorsManager.Instance.CreatePropertyEditor(editorType, m_goData, propertyPath, property.ValueType);
                MetroUserControl editor   = obj as MetroUserControl;
                IEditorJsonValue jvEditor = obj as IEditorJsonValue;
                if (editor != null && jvEditor != null)
                {
                    jvEditor.Text             = property.Name;
                    jvEditor.JsonDefaultValue = property.DefaultValue;
                    jvEditor.UpdateEditorValue();
                    editor.Top    = y;
                    editor.Width  = Width;
                    editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    Controls.Add(editor);
                    jvEditor.EditorJsonValueChangedCallback = this;
                    m_editors.Add(jvEditor);
                    y = editor.Bottom + DEFAULT_SEPARATOR;
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                ErrorPropertyEditor editor = new ErrorPropertyEditor(property.Name, ex.Message);
                editor.Tag    = string.Format("{0}\n{1}\n\nStack trace:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
                editor.Top    = y;
                editor.Width  = Width;
                editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                Controls.Add(editor);
                y = editor.Bottom + DEFAULT_SEPARATOR;
            }

            return(y);
        }
Example #5
0
 public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
     if (property == "lifeCycleFixedFps")
     {
         float v   = m_lifeCycleFixedFps.Value;
         bool  irc = m_lifeCycleFixedStep.IsRaisingEditorJsonValueChangedCallback;
         m_lifeCycleFixedStep.IsRaisingEditorJsonValueChangedCallback = false;
         m_lifeCycleFixedStep.Value = v > 0.0f ? 1.0f / v : 0.0f;
         m_lifeCycleFixedStep.UpdateEditorValue();
         m_lifeCycleFixedStep.IsRaisingEditorJsonValueChangedCallback = irc;
     }
     else if (property == "lifeCycleFixedStep")
     {
         float v   = m_lifeCycleFixedStep.Value;
         bool  irc = m_lifeCycleFixedFps.IsRaisingEditorJsonValueChangedCallback;
         m_lifeCycleFixedFps.IsRaisingEditorJsonValueChangedCallback = false;
         m_lifeCycleFixedFps.Value = v > 0.0f ? 1.0f / v : 0.0f;
         m_lifeCycleFixedFps.UpdateEditorValue();
         m_lifeCycleFixedFps.IsRaisingEditorJsonValueChangedCallback = irc;
     }
 }
        public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
        {
            string query = PrepareSetQuery(property, jsonValue);
            Dictionary <string, string> result = SceneViewPlugin.QueryGameObject(m_goHandle, m_goIsPrefab, query);

            m_goData.Clear();
            foreach (var kv in result)
            {
                m_goData.Add(kv.Key, kv.Value);
            }
            bool irc;

            foreach (IEditorJsonValue e in m_editors)
            {
                if (e.PropertyName != property && result.ContainsKey(e.PropertyName))
                {
                    irc = e.IsRaisingEditorJsonValueChangedCallback;
                    e.IsRaisingEditorJsonValueChangedCallback = false;
                    e.UpdateEditorValue();
                    e.IsRaisingEditorJsonValueChangedCallback = irc;
                }
            }
            MainForm mainForm = FindForm() as MainForm;

            if (mainForm != null)
            {
                if (result != null)
                {
                    mainForm.RefreshSceneView();
                }
                if (property == "properties/Id")
                {
                    mainForm.DoAction(new MainForm.Action("GameObjectIdChanged", m_goHandle));
                }
            }
        }
Example #7
0
 public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
 }
Example #8
0
            private void InitializeComponent(ItemEditorInfo[] metaEditors, ItemEditorInfo[] propertyEditors, string id, string meta, string tags)
            {
                IsProxyEditor = true;

                m_subProperties["id"]   = Newtonsoft.Json.JsonConvert.SerializeObject(id);
                m_subProperties["tags"] = string.IsNullOrEmpty(tags) ? "null" : Newtonsoft.Json.JsonConvert.SerializeObject(tags.Split('|'));

                MetroButton applyButton = new MetroButton();

                MetroSkinManager.ApplyMetroStyle(applyButton);
                applyButton.Text   = "Apply";
                applyButton.Width  = Width - 20;
                applyButton.Top    = Height;
                applyButton.Left   = 10;
                applyButton.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                applyButton.Click += new EventHandler(applyButton_Click);
                Controls.Add(applyButton);
                Height += applyButton.Height + DEFAULT_SEPARATOR;

                MetroButton removeButton = new MetroButton();

                MetroSkinManager.ApplyMetroStyle(removeButton);
                removeButton.Text   = "Remove";
                removeButton.Width  = Width - 20;
                removeButton.Top    = Height;
                removeButton.Left   = 10;
                removeButton.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                removeButton.Click += new EventHandler(removeButton_Click);
                Controls.Add(removeButton);
                Height += removeButton.Height + DEFAULT_SEPARATOR;

                m_idEditor        = new String_PropertyEditor(m_subProperties, "id");
                m_idEditor.Width  = Width - 20;
                m_idEditor.Top    = Height;
                m_idEditor.Left   = 10;
                m_idEditor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                Controls.Add(m_idEditor);
                m_idEditor.EditorJsonValueChangedCallback = this;
                Height += m_idEditor.Height + DEFAULT_SEPARATOR;

                if (metaEditors != null && metaEditors.Length > 0)
                {
                    string[] metaParts      = string.IsNullOrEmpty(meta) ? null : meta.Split('|');
                    int      metaPartsIndex = 0;
                    foreach (ItemEditorInfo info in metaEditors)
                    {
                        if (metaParts != null && metaPartsIndex < metaParts.Length)
                        {
                            m_subProperties[info.property] = Newtonsoft.Json.JsonConvert.SerializeObject(metaParts[metaPartsIndex]);
                        }
                        metaPartsIndex++;
                        try
                        {
                            object           obj      = Activator.CreateInstance(info.editorType, m_subProperties, info.property);
                            MetroUserControl editor   = obj as MetroUserControl;
                            IEditorJsonValue jvEditor = obj as IEditorJsonValue;
                            if (editor != null && jvEditor != null)
                            {
                                jvEditor.Text = info.property;
                                jvEditor.UpdateEditorValue();
                                editor.Top    = Height;
                                editor.Width  = Width - 20;
                                editor.Left   = 10;
                                editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                                Controls.Add(editor);
                                jvEditor.EditorJsonValueChangedCallback = this;
                                m_metaEditors.Add(new KeyValuePair <string, IEditorJsonValue>(info.property, jvEditor));
                                Height += editor.Height + DEFAULT_SEPARATOR;
                            }
                        }
                        catch (Exception ex)
                        {
                            while (ex.InnerException != null)
                            {
                                ex = ex.InnerException;
                            }
                            ErrorPropertyEditor editor = new ErrorPropertyEditor(info.property, ex.Message);
                            editor.Tag    = string.Format("{0}\n{1}\n\nStack trace:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
                            editor.Top    = Height;
                            editor.Width  = Width - 20;
                            editor.Left   = 10;
                            editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                            Controls.Add(editor);
                            Height += editor.Height + DEFAULT_SEPARATOR;
                        }
                    }
                }

                if (propertyEditors != null && propertyEditors.Length > 0)
                {
                    foreach (ItemEditorInfo info in propertyEditors)
                    {
                        m_subProperties[info.property] = "null";
                        try
                        {
                            object           obj      = Activator.CreateInstance(info.editorType, m_subProperties, info.property);
                            MetroUserControl editor   = obj as MetroUserControl;
                            IEditorJsonValue jvEditor = obj as IEditorJsonValue;
                            if (editor != null && jvEditor != null)
                            {
                                jvEditor.Text = info.property;
                                jvEditor.UpdateEditorValue();
                                editor.Top    = Height;
                                editor.Width  = Width - 20;
                                editor.Left   = 10;
                                editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                                Controls.Add(editor);
                                jvEditor.EditorJsonValueChangedCallback = this;
                                m_propertyEditors.Add(new KeyValuePair <string, IEditorJsonValue>(info.property, jvEditor));
                                Height += editor.Height + DEFAULT_SEPARATOR;
                            }
                        }
                        catch (Exception ex)
                        {
                            while (ex.InnerException != null)
                            {
                                ex = ex.InnerException;
                            }
                            ErrorPropertyEditor editor = new ErrorPropertyEditor(info.property, ex.Message);
                            editor.Tag    = string.Format("{0}\n{1}\n\nStack trace:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
                            editor.Top    = Height;
                            editor.Width  = Width - 20;
                            editor.Left   = 10;
                            editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                            Controls.Add(editor);
                            Height += editor.Height + DEFAULT_SEPARATOR;
                        }
                    }
                }

                m_tagsEditor        = new Tags_PropertyEditor(m_subProperties, "tags");
                m_tagsEditor.Width  = Width - 20;
                m_tagsEditor.Top    = Height;
                m_tagsEditor.Left   = 10;
                m_tagsEditor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                Controls.Add(m_tagsEditor);
                m_tagsEditor.EditorJsonValueChangedCallback = this;
                Height += m_tagsEditor.Height;

                UpdateJsonValue();
                UpdateProperties();
            }
Example #9
0
 public void OnEditorValueChanged(IEditorJsonValue editor, string property, string jsonValue)
 {
     m_subProperties[property] = jsonValue;
     UpdateJsonValue();
 }
                public FieldContainer(
                    EditorDialog dialog,
                    CollectionPropertyEditorUtils.CollectionType collectionType,
                    Func <Dictionary <string, string>, string, PropertyEditor <T> > creator,
                    string jsonValue,
                    string memberName = null
                    )
                {
                    m_collectionType = collectionType;
                    m_creator        = creator;
                    if (m_creator == null)
                    {
                        throw new Exception("Creator cannot be null!");
                    }
                    MetroSkinManager.ApplyMetroStyle(this);
                    Height = 0;

                    MetroTile remove = new MetroTile();

                    MetroSkinManager.ApplyMetroStyle(remove);
                    remove.Text               = "-";
                    remove.TextAlign          = ContentAlignment.MiddleCenter;
                    remove.TileTextFontWeight = MetroTileTextWeight.Bold;
                    remove.Width              = DEFAULT_BUTTON_SIZE + DEFAULT_BUTTON_SIZE;
                    remove.Height             = DEFAULT_BUTTON_SIZE;
                    remove.Left               = Width - remove.Width;
                    remove.Anchor             = AnchorStyles.Top | AnchorStyles.Right;
                    remove.Click             += new EventHandler(remove_Click);
                    Controls.Add(remove);

                    MetroTile add = new MetroTile();

                    MetroSkinManager.ApplyMetroStyle(add);
                    add.Text               = "+";
                    add.TextAlign          = ContentAlignment.MiddleCenter;
                    add.TileTextFontWeight = MetroTileTextWeight.Bold;
                    add.Width              = DEFAULT_BUTTON_SIZE + DEFAULT_BUTTON_SIZE;
                    add.Height             = DEFAULT_BUTTON_SIZE;
                    add.Left               = Width - add.Width - DEFAULT_SEPARATOR - remove.Width;
                    add.Anchor             = AnchorStyles.Top | AnchorStyles.Right;
                    add.Click             += new EventHandler(add_Click);
                    Controls.Add(add);

                    Height += Math.Max(add.Height, remove.Height);

                    if (m_collectionType == CollectionPropertyEditorUtils.CollectionType.JsonObject)
                    {
                        m_memberTextBox = new MetroTextBox();
                        MetroSkinManager.ApplyMetroStyle(m_memberTextBox);
                        m_memberTextBox.Text         = memberName;
                        m_memberTextBox.Width        = Width;
                        m_memberTextBox.Top          = Height;
                        m_memberTextBox.Anchor       = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                        m_memberTextBox.TextChanged += new EventHandler(m_memberTextBox_TextChanged);
                        Controls.Add(m_memberTextBox);
                        Height += m_memberTextBox.Height;
                    }

                    try
                    {
                        m_propertyEditor = m_creator(m_imHereForNothing, "-.-");
                        if (m_propertyEditor == null)
                        {
                            throw new Exception("Property editor couldn't be created properly!");
                        }
                        MetroUserControl editor   = m_propertyEditor as MetroUserControl;
                        IEditorJsonValue jvEditor = m_propertyEditor as IEditorJsonValue;
                        if (editor != null && jvEditor != null)
                        {
                            jvEditor.Text      = "Item";
                            jvEditor.JsonValue = jsonValue;
                            jvEditor.UpdateEditorValue();
                            editor.Width  = Width;
                            editor.Top    = Height;
                            editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                            Controls.Add(editor);
                            Height += editor.Height;
                        }
                    }
                    catch (Exception ex)
                    {
                        while (ex.InnerException != null)
                        {
                            ex = ex.InnerException;
                        }
                        ErrorPropertyEditor editor = new ErrorPropertyEditor("Item", ex.Message);
                        editor.Tag    = string.Format("{0}\n{1}\n\nStack trace:\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
                        editor.Width  = Width;
                        editor.Top    = Height;
                        editor.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                        Controls.Add(editor);
                        Height += editor.Height;
                    }
                }