Ejemplo n.º 1
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.º 2
0
        private void RegenContext(bool inbForce = false)
        {
            if (!inbForce && Event.current.type != EventType.Layout)
            {
                return;
            }

            m_SelfUndoTarget = new UndoTarget(this, "RuleTableEditor");
            m_TargetState.Refresh();

            if (m_TargetState.SelectedObject == null)
            {
                m_TargetState.Clear();
                m_SelectionState.ClearAll();
                return;
            }

            if (m_TargetState.SelectedObject != null && m_SelectionState.Source == null)
            {
                IRSRuleTableSource tableSource;
                if (!RSEditorUtility.EditorPlugin.TryGetRuleTable(m_TargetState.SelectedObject, out tableSource))
                {
                    m_TargetState.Clear();
                    m_SelectionState.ClearAll();
                    return;
                }

                if (tableSource.TableData == null)
                {
                    m_TargetState.Clear();
                    m_SelectionState.ClearAll();
                    return;
                }

                m_SelectionState.Source = tableSource;
                m_SelectionState.Table  = tableSource.TableData;

                bool bCleanUpChanged = TableUtils.CleanUp(tableSource.TableData);
                if (bCleanUpChanged)
                {
                    m_TargetState.UndoTarget.MarkDirtyWithoutUndo("Cleaned up Rule Table data");
                }
            }

            m_SelectionState.Refresh();

            m_Context = m_Context.WithLibrary(RSEditorUtility.EditorPlugin.Library);

            IRSEntity entity = null;

            if (m_TargetState.SelectedObject)
            {
                RSEditorUtility.EditorPlugin.TryGetEntity(m_TargetState.SelectedObject, out entity);
            }

            m_Context = m_Context.WithEntity(entity);

            IRSEntityMgr manager = null;

            if (manager == null || m_TargetState.SelectedObject)
            {
                RSEditorUtility.EditorPlugin.TryGetEntityManager(m_TargetState.SelectedObject, out manager);
            }

            m_Context = m_Context.WithManager(manager);
        }