Ejemplo n.º 1
0
        private void DeleteRule(int inIndex)
        {
            if (m_SelectionState.RuleIndex == inIndex)
            {
                SelectRule(-1);
            }
            else if (m_SelectionState.RuleIndex > inIndex)
            {
                SelectRule(m_SelectionState.RuleIndex - 1);
            }

            m_TargetState.UndoTarget.MarkDirty("Removed Rule", true);
            ArrayUtility.RemoveAt(ref m_SelectionState.Table.Rules, inIndex);
            TableUtils.UpdateUniqueRuleTriggers(m_SelectionState.Table);
        }
Ejemplo n.º 2
0
        private void InsertRule(RSRuleData inRule, int inIndex = -1)
        {
            m_TargetState.UndoTarget.MarkDirty("Added Rule", true);
            if (inIndex < 0 || inIndex >= m_SelectionState.Table.Rules.Length)
            {
                ArrayUtility.Add(ref m_SelectionState.Table.Rules, inRule);
                inIndex = m_SelectionState.Table.Rules.Length - 1;
            }
            else
            {
                ArrayUtility.Insert(ref m_SelectionState.Table.Rules, inIndex, inRule);
            }

            TableUtils.UpdateUniqueRuleTriggers(m_SelectionState.Table);
            SelectRule(inIndex);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders editor for rule info. Does not include conditions or actions.
        /// </summary>
        static public void RuleData(UndoTarget inUndo, RSRuleData ioRule, RSRuleTableData ioTable, RSValidationFlags inFlags, RSValidationContext inContext)
        {
            string preview = ioRule.GetPreviewString(null, inContext.Library);

            GUILayout.Label(preview, RSGUIStyles.RuleHeaderStyle);

            EditorGUILayout.Space();

            string newName = EditorGUILayout.TextField(Content.RuleNameLabel, ioRule.Name);

            if (newName != ioRule.Name)
            {
                inUndo.MarkDirty("Changed Rule Name");
                ioRule.Name = newName;
            }

            RSTriggerId newTriggerId;

            if (inFlags.Has(RSValidationFlags.FilterSelection) && inContext.Entity != null)
            {
                newTriggerId = LibraryGUILayout.TriggerSelector(Content.RuleTriggerLabel, ioRule.TriggerId, inContext.Entity, inContext.Library);
            }
            else
            {
                newTriggerId = LibraryGUILayout.TriggerSelector(Content.RuleTriggerLabel, ioRule.TriggerId, inContext.Library);
            }

            if (newTriggerId != ioRule.TriggerId)
            {
                inUndo.MarkDirty("Changed Rule Trigger", true);
                ioRule.TriggerId = newTriggerId;

                TableUtils.UpdateUniqueRuleTriggers(ioTable);
            }

            if (newTriggerId != RSTriggerId.Null)
            {
                RSTriggerInfo info = inContext.Library.GetTrigger(newTriggerId);
                if (info != null && info.ParameterType != null)
                {
                    using (new EditorGUI.IndentLevelScope())
                    {
                        EditorGUILayout.LabelField(Content.RuleParameterLabel, EditorGUIUtility.TrTextContent(info.ParameterType.ToStringWithoutDefault(), info.ParameterType.Tooltip));
                    }
                }
            }

            EditorGUILayout.Space();

            // Enabled
            bool bEnabled = EditorGUILayout.Toggle(Content.RuleEnabledLabel, ioRule.Enabled);

            if (bEnabled != ioRule.Enabled)
            {
                inUndo.MarkDirty("Changed Rule Enabled");
                ioRule.Enabled = bEnabled;
            }

            bool bOnlyOnce = EditorGUILayout.Toggle(Content.RuleOnlyOnceLabel, ioRule.OnlyOnce);

            if (bOnlyOnce != ioRule.OnlyOnce)
            {
                inUndo.MarkDirty("Changed Rule OnlyOnce");
                ioRule.OnlyOnce = bOnlyOnce;
            }

            bool bDontInterrupt = EditorGUILayout.Toggle(Content.RuleDontInterruptLabel, ioRule.DontInterrupt);

            if (bDontInterrupt != ioRule.DontInterrupt)
            {
                inUndo.MarkDirty("Changed Rule DontInterrupt");
                ioRule.DontInterrupt = bDontInterrupt;
            }

            EditorGUILayout.Space();

            string newGroup = EditorGUILayout.TextField(Content.RuleGroupLabel, ioRule.RoutineGroup);

            if (newGroup != ioRule.RoutineGroup)
            {
                inUndo.MarkDirty("Changed Rule Group");
                ioRule.RoutineGroup = newGroup;
            }
        }