public static ValueIndex SetLastUsedTrigger(this ValueIndex index) { if (index != null) { index.TriggerIndexes = TriggerGroup.TryGetLastUsedTrigger(); } return(index); }
public virtual bool Inspect() { if (!_name.IsNullOrEmpty()) { _name.nl(PEGI_Styles.ListLabel); } var before = ConditionLogic.inspectedTarget; ConditionLogic.inspectedTarget = Values.global; var changed = false; if (_browsedBranch == -1) { var cnt = CountForInspector(); if (cnt > 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); } } if (cnt > 0) { (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); if (_branches.Count == 0 && "Create Sub Branch".Click().nl()) { _branches.Add(new ConditionBranch()); } if (_branches.Count > 0) { "Sub Branches".edit_List(ref _branches, ref _browsedBranch).changes(ref changed); } ConditionLogic.inspectedTarget = before; return(changed); }
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.ClickConfirm("rnmTrg", "Rename {0} if group {1} to {2}".F(selectedTrig.name, selectedTrig.Group.GetNameForInspector(), 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.GetNameForInspector(), selectedTrig.Group.GetNameForInspector(), Browsed.GetNameForInspector())); } 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); }
public bool Inspect() { var changed = false; "[{0}] Name:".F(_index).edit(70, ref _name).nl(ref changed); if ("Share".foldout(ref _shareOptions).nl()) { "Share:".write( "Paste message full with numbers and lost of ' | ' symbols into the first line or drop file into second", 50); CfgData 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(); } "Change".select(ref _replacingAuthor, Shortcuts.users.all); if (_replacingAuthor != -1 && _replacingAuthor < Shortcuts.users.all.Count && !Shortcuts.users.all[_replacingAuthor].Equals(authorName) && icon.Replace.ClickConfirm("repTgAu", "Change an author?")) { authorName = Shortcuts.users.all[_replacingAuthor]; } pegi.nl(); "New Variable".edit(80, ref Trigger.searchField); AddTriggerToGroup_PEGI(); _triggers.Nested_Inspect(ref changed); return(changed); }
public bool SearchAndAdd_Triggers_PEGI(int index) { bool changed = false; Trigger t = Trigger; if (this == edited) { t.Inspect().changes(ref changed); } if (pegi.FocusedName.Equals(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 { // Debug.Log("Focused {0}, foucsed name {1}".F(pegi.FocusedName, focusName)); if (index == Trigger.focusIndex) { Trigger.focusIndex = -2; } } if (this == selected) { changed |= TriggerGroup.AddTrigger_PEGI(this); } return(changed); }
public virtual bool Inspect() { var changed = pegi.toggleDefaultInspector(this); pegi.nl(); if (inspectedTriggerGroup == -1) { #region Paste Options if ("Paste Options".foldout().nl()) { 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) || CfgExtensions.DropStringObject(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".nl(PEGI_Styles.ListLabel); } ExtensionsForGenericCountless.Inspect <UnNullableCfg <TriggerGroup>, TriggerGroup>(TriggerGroup.all, ref inspectedTriggerGroup).changes(ref changed); if (inspectedTriggerGroup == -1) { "At Index: ".edit(60, ref tmpIndex); if (tmpIndex >= 0 && TriggerGroup.all.TryGet(tmpIndex) == null && icon.Add.ClickUnFocus("Create New Group")) { TriggerGroup.all[tmpIndex].NameForPEGI = "Group " + tmpIndex; tmpIndex++; } pegi.nl(); "Adding a group will also try to load it".writeHint(); pegi.nl(); } pegi.nl(); return(changed); }