Ejemplo n.º 1
0
        private bool TryOpen(TableLineRef inRef)
        {
            UnityEngine.Object obj = inRef.TableSource as UnityEngine.Object;
            if (obj == null)
            {
                return(false);
            }

            if (!TryEdit(obj))
            {
                return(false);
            }

            int ruleIdx = TableUtils.IndexOfRule(m_SelectionState.Table, inRef.RuleId);

            if (ruleIdx >= 0)
            {
                SelectRule(ruleIdx);
                if (inRef.ConditionIndex >= 0)
                {
                    SelectCondition(inRef.ConditionIndex);
                }
                else if (inRef.ActionIndex >= 0)
                {
                    SelectAction(inRef.ActionIndex);
                }
            }

            m_SelectionState.Refresh();
            return(true);
        }
Ejemplo n.º 2
0
        static public bool Open(TableLineRef inRef)
        {
            RuleTableEditor window = GetWindow <RuleTableEditor>();

            if (window.TryOpen(inRef))
            {
                window.Show();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        private void PerformTableSearch(TableParams inTableParams)
        {
            m_LineRefs.Clear();

            if (m_TableMgr == null)
            {
                Debug.LogError("No rule table manager found");
                return;
            }

            AbstractTableRefVisitor visitor = null;

            switch (inTableParams.Mode)
            {
            case TableMode.Action:
            {
                visitor = new TableUtils.ActionIdRefVisitor(inTableParams.ElementSearchId);
                break;
            }

            case TableMode.Query:
            {
                visitor = new TableUtils.QueryIdRefVisitor(inTableParams.ElementSearchId);
                break;
            }

            case TableMode.Trigger:
            {
                visitor = new TableUtils.TriggerIdRefVisitor(new RSTriggerId(inTableParams.ElementSearchId));
                break;
            }

            case TableMode.Entity:
            {
                visitor = new TableUtils.EntityIdRefVisitor(inTableParams.EntitySearch);
                break;
            }

            case TableMode.String:
            {
                visitor = new TableUtils.StringRefVisitor(inTableParams.StringSearch);
                break;
            }

            case TableMode.Issues:
            {
                var validationContext = new RSValidationContext(RSEditorUtility.EditorPlugin.Library);
                validationContext = validationContext.WithManager(m_EntityMgr);
                foreach (var table in m_TableMgr.AllTableSources())
                {
                    var validationState = RSValidator.Validate(table.TableData, validationContext);
                    if (validationState.IssueCount > 0)
                    {
                        m_LineRefs.Add(TableLineRef.FromTable(table).WithDescriptor("{0} errors, {1} warnings", validationState.ErrorCount, validationState.WarningCount));
                    }
                }
                break;
            }
            }

            if (visitor != null)
            {
                foreach (var table in m_TableMgr.AllTableSources())
                {
                    visitor.Visit(table);
                }
                m_LineRefs.AddRange(visitor.CollectedRefs);
            }
        }
Ejemplo n.º 4
0
        private void RenderLineRef(TableLineRef inLineRef, int inIndex)
        {
            using (var scope = new EditorGUILayout.HorizontalScope())
                using (new GUIScopes.ColorScope(inLineRef.Enabled ? Color.white : Color.gray))
                {
                    if (Event.current.type == EventType.MouseDown)
                    {
                        Rect r = scope.rect;
                        if (r.Contains(Event.current.mousePosition))
                        {
                            RuleTableEditor.Open(inLineRef);
                        }
                    }

                    string prefix = string.Format("#{0}", inIndex + 1);
                    using (new EditorGUI.DisabledScope(true))
                        using (new GUIScopes.LabelWidthScope(50))
                        {
                            RSEditorUtility.EditorPlugin.RuleTableSourceField(EditorGUIUtility.TrTempContent(prefix), inLineRef.TableSource, m_TableMgr, GUILayout.Width(300));
                        }

                    string ruleName = "[Unknown Rule]";
                    if (!string.IsNullOrEmpty(inLineRef.RuleId) && inLineRef.TableSource != null)
                    {
                        int ruleIdx = TableUtils.IndexOfRule(inLineRef.TableSource.TableData, inLineRef.RuleId);
                        if (ruleIdx >= 0)
                        {
                            ruleName = inLineRef.TableSource.TableData.Rules[ruleIdx].Name;
                        }
                    }

                    using (new GUIScopes.LabelWidthScope(400))
                    {
                        if (inLineRef.ActionIndex >= 0)
                        {
                            string actionLabel = string.Format("Rule '{0}' -> Action {1}", ruleName, inLineRef.ActionIndex);
                            EditorGUILayout.LabelField(actionLabel);
                        }
                        else if (inLineRef.ConditionIndex >= 0)
                        {
                            string conditionLabel = string.Format("Rule '{0}' -> Condition {1}", ruleName, inLineRef.ConditionIndex);
                            EditorGUILayout.LabelField(conditionLabel);
                        }
                        else if (!string.IsNullOrEmpty(inLineRef.RuleId))
                        {
                            string ruleLabel = string.Format("Rule '{0}'", ruleName);
                            EditorGUILayout.LabelField(ruleLabel);
                        }
                    }

                    GUILayout.FlexibleSpace();

                    if (!string.IsNullOrEmpty(inLineRef.Descriptor))
                    {
                        GUILayout.Label(inLineRef.Descriptor);
                    }

                    if (GUILayout.Button("...", GUILayout.Width(25)))
                    {
                        RuleTableEditor.Open(inLineRef);
                    }
                }
        }