Beispiel #1
0
 public static ValueIndex SetLastUsedTrigger(this ValueIndex index)
 {
     if (index != null)
     {
         index.TriggerIndexes = TriggerGroup.TryGetLastUsedTrigger();
     }
     return(index);
 }
Beispiel #2
0
        public static void FindAllTriggerGroups()
        {
            all = new UnnullableSTD <TriggerGroup>();

            List <Type> triggerGroups = CsharpFuncs.GetAllChildTypesOf <TriggerGroup>();

            foreach (Type group in triggerGroups)
            {
                TriggerGroup s = (TriggerGroup)Activator.CreateInstance(group);
                Browsed = s;
            }
        }
Beispiel #3
0
        public override bool PEGI()
        {
            inspected = this;

            bool changed = false;

            if (Values.current == null)
            {
                changed |= base.PEGI();
                if (showDebug)
                {
                    return(changed);
                }

                changed |= (index + " Name").edit(60, ref name).nl();
                Trigger.Search_PEGI();
            }

            if (Trigger.editedTrigger != null)
            {
                if (icon.Close.Click())
                {
                    Trigger.editedTrigger = null;
                }

                Trigger.editedTrigger.PEGI();
            }
            else
            {
                int showMax = 20;

                var lst = GetFilteredList(ref showMax);

                "Triggers".write_List(lst);

                /*  foreach (var t in lst)
                 * {
                 *
                 *    t.PEGI();
                 *
                 *
                 *
                 * }*/
            }

            pegi.nl();

            inspected = null;

            return(changed);
        }
Beispiel #4
0
        public static bool AddTrigger_PEGI(ValueIndex arg = null)
        {
            var changed = false;

            var selectedTrig = arg?.Trigger;

            if (Trigger.searchMatchesFound == 0 && selectedTrig != null && !selectedTrig.name.SameAs(Trigger.searchField))
            {
                var goodLength = Trigger.searchField.Length > 3;

                pegi.nl();

                if (goodLength && icon.Replace.ClickUnFocus(
                        "Rename {0} if group {1} to {2}".F(selectedTrig.name, selectedTrig.Group.ToPegiString(), Trigger.searchField)
                        ).changes(ref changed))
                {
                    selectedTrig.Using().name = Trigger.searchField;
                }

                var differentGroup = selectedTrig.Group != Browsed && Browsed != null;

                if (goodLength && differentGroup)
                {
                    icon.Warning.write("Trigger {0} is of group {1} not {2}".F(selectedTrig.ToPegiString(), selectedTrig.Group.ToPegiString(), Browsed.ToPegiString()));
                }

                var groupLost = all.GetAllObjsNoOrder();
                if (groupLost.Count > 0)
                {
                    var selected = Browsed?.IndexForPEGI ?? -1;

                    if (pegi.select(ref selected, all))
                    {
                        Browsed = all[selected];
                    }
                }
                else
                {
                    "No Trigger Groups found".nl();
                }

                if (goodLength)
                {
                    Browsed?.AddTriggerToGroup_PEGI(arg);
                }
            }

            pegi.nl();

            return(changed);
        }
Beispiel #5
0
        public bool SearchAndAdd_Triggers_PEGI(int index)
        {
            bool changed = false;

            Trigger t = Trigger;

            if (this == edited)
            {
                changed |= t.Inspect();
            }

            if ((pegi.nameFocused == (focusName)) && (this != edited))
            {
                selected = this;

                if (Trigger.focusIndex != index)
                {
                    Trigger.focusIndex  = index;
                    Trigger.searchField = Trigger.name;
                }

                if (Search_Triggers_PEGI(Trigger.searchField, Values.global))
                {
                    Trigger.searchField = Trigger.name;
                }

                selectedTrig = Trigger;
            }
            else if (index == Trigger.focusIndex)
            {
                Trigger.focusIndex = -2;
            }

            if (this == selected)
            {
                changed |= TriggerGroup.AddTrigger_PEGI(this);
            }

            return(changed);
        }
Beispiel #6
0
        public void SetTagEnum(int groupIndex, int tagIndex, int value)
        {
            enumTags[groupIndex][tagIndex] = value;

            TriggerGroup s = TriggerGroup.all[groupIndex];

            if (s.taggedInts[tagIndex][value].Contains(this))
            {
                if (value != 0)
                {
                    return;
                }
                else
                {
                    s.taggedInts[tagIndex][value].Remove(this);
                }
            }
            else if (value != 0)
            {
                s.taggedInts[tagIndex][value].Add(this);
            }
        }
Beispiel #7
0
        public void SetTagBool(int groupIndex, int tagIndex, bool value)
        {
            boolTags[groupIndex][tagIndex] = value;

            TriggerGroup s = TriggerGroup.all[groupIndex];

            if (s.taggedBool[tagIndex].Contains(this))
            {
                if (value)
                {
                    return;
                }
                else
                {
                    s.taggedBool[tagIndex].Remove(this);
                }
            }
            else if (value)
            {
                s.taggedBool[tagIndex].Add(this);
            }
        }
Beispiel #8
0
        public override bool Inspect()
        {
            var changed = false;

            if (inspectedItems == -1)
            {
                changed |= "{0} : ".F(_index).edit(50, ref _name).nl();


                "Share:".write("Paste message full with numbers and lost of ' | ' symbols into the first line or drop file into second", 50);

                string data;
                if (this.SendReceivePegi("Trigger Group {0} [{1}]".F(_name, _index), "Trigger Groups", out data))
                {
                    var tmp = new TriggerGroup();
                    tmp.Decode(data);
                    if (tmp._index == _index)
                    {
                        Decode(data);
                        Debug.Log("Decoded Trigger Group {0}".F(_name));
                    }
                    else
                    {
                        Debug.LogError("Pasted trigger group had different index, replacing");
                    }
                }


                pegi.line();

                "New Variable".edit(80, ref Trigger.searchField);
                AddTriggerToGroup_PEGI();

                changed |= _triggers.Nested_Inspect();
            }

            return(changed);
        }
Beispiel #9
0
        public override bool Inspect()
        {
            if (!_name.IsNullOrEmpty())
            {
                _name.nl(PEGI_Styles.ListLabel);
            }

            var before = ConditionLogic.inspectedTarget;

            ConditionLogic.inspectedTarget = Values.global;

            var changed = false;

            if (_browsedBranch == -1)
            {
                if (_type.ToString().Click((_type == ConditionBranchType.And ? "All conditions and sub branches should be true" : "At least one condition OR sub branch should be true")))
                {
                    _type = (_type == ConditionBranchType.And ? ConditionBranchType.Or : ConditionBranchType.And);
                }

                (CheckConditions(ConditionLogic.inspectedTarget) ? icon.Active : icon.InActive).nl();

                var newC = "Conditions".edit_List(ref _conditions, ref _browsedCondition, ref changed);
                if (newC != null)
                {
                    newC.TriggerIndexes = TriggerGroup.TryGetLastUsedTrigger();
                }
            }

            pegi.line(Color.black);

            changed |= "Sub Branches".edit_List(ref _branches, ref _browsedBranch);


            ConditionLogic.inspectedTarget = before;

            return(changed);
        }
Beispiel #10
0
 public void SetTagEnum(TriggerGroup gr, int tagIndex, int value) => SetTagEnum(gr.IndexForPEGI, tagIndex, value);
Beispiel #11
0
 public void SetTagBool(TriggerGroup gr, int tagIndex, bool value) => SetTagBool(gr.IndexForPEGI, tagIndex, value);
Beispiel #12
0
        public override bool Inspect()
        {
            var changed = false;

            InspectionTabs();

            changed |= base.Inspect().nl();

            if (inspectedItems == 1)
            {
                if (inspectedTriggerGroup == -1)
                {
                    #region Paste Options

                    if (_replaceReceived != null)
                    {
                        var current = TriggerGroup.all.GetIfExists(_replaceReceived.IndexForPEGI);
                        var hint    = (current != null) ? "{0} [ Old: {1} => New: {2} triggers ] ".F(_replaceReceived.NameForPEGI, current.Count, _replaceReceived.Count) : _replaceReceived.NameForPEGI;

                        if (hint.enter(ref _inspectReplacementOption))
                        {
                            _replaceReceived.Nested_Inspect();
                        }
                        else
                        {
                            if (icon.Done.ClickUnFocus())
                            {
                                TriggerGroup.all[_replaceReceived.IndexForPEGI] = _replaceReceived;
                                _replaceReceived = null;
                            }
                            if (icon.Close.ClickUnFocus())
                            {
                                _replaceReceived = null;
                            }
                        }
                    }
                    else
                    {
                        var tmp = "";
                        if ("Paste Messaged STD data".edit(140, ref tmp) || StdExtensions.LoadOnDrop(out tmp))
                        {
                            var group = new TriggerGroup();
                            group.DecodeFromExternal(tmp);

                            var current = TriggerGroup.all.GetIfExists(group.IndexForPEGI);

                            if (current == null)
                            {
                                TriggerGroup.all[group.IndexForPEGI] = group;
                            }
                            else
                            {
                                _replaceReceived = group;
                                if (!_replaceReceived.NameForPEGI.SameAs(current.NameForPEGI))
                                {
                                    _replaceReceived.NameForPEGI += " replaces {0}".F(current.NameForPEGI);
                                }
                            }
                        }
                    }
                    pegi.nl();

                    #endregion
                }

                "Trigger Groups".write(PEGI_Styles.ListLabel);
                pegi.nl();

                changed |= TriggerGroup.all.Inspect <UnNullableCfg <TriggerGroup>, TriggerGroup>(ref inspectedTriggerGroup);

                if (inspectedTriggerGroup == -1)
                {
                    "At Index: ".edit(60, ref tmpIndex);
                    if (tmpIndex >= 0 && ExtensionsForGenericCountless.TryGet(TriggerGroup.all, tmpIndex) == null && icon.Add.ClickUnFocus("Create New Group"))
                    {
                        TriggerGroup.all[tmpIndex].NameForPEGI = "Group " + tmpIndex.ToString();//.GetIndex();
                        tmpIndex++;
                    }
                    pegi.nl();
                }
            }

            pegi.nl();

            return(changed);
        }