private int CompareEventsByUseCount(SkillEvent event1, SkillEvent event2) { if (event1 == null) { if (event2 == null) { return(0); } return(-1); } else { if (event2 == null) { return(1); } int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event1.get_Name()); int num = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event2.get_Name()).CompareTo(eventUseCount); if (num == 0) { return(string.Compare(event1.get_Name(), event2.get_Name(), 0)); } return(num); } }
private void DoEventLine(SkillEvent fsmEvent) { int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()); GUILayout.BeginHorizontal((this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.SelectedEventBox : SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent()); bool flag = GUILayout.Toggle(fsmEvent.get_IsGlobal(), SkillEditorContent.GlobalEventTooltipLabel, SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[] { GUILayout.MaxWidth(17f), GUILayout.MinWidth(17f) }); if (flag != fsmEvent.get_IsGlobal()) { SkillEditor.Builder.SetEventIsGlobal(SkillEditor.SelectedFsm, fsmEvent, flag); GlobalEventsWindow.ResetView(); } EditorGUI.EndDisabledGroup(); GUIStyle gUIStyle = (this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText; if (GUILayout.Button(fsmEvent.get_Name(), gUIStyle, new GUILayoutOption[] { GUILayout.MinWidth(244f) })) { this.SelectEvent(fsmEvent, true); GUIUtility.set_keyboardControl(0); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { this.GenerateStateListMenu(this.selectedEvent).ShowAsContext(); } } GUILayout.FlexibleSpace(); GUILayout.Label(eventUseCount.ToString(CultureInfo.get_CurrentCulture()), gUIStyle, new GUILayoutOption[0]); GUILayout.Space(5f); if (SkillEditorGUILayout.DeleteButton()) { EditorCommands.DeleteEvent(fsmEvent); this.Reset(); } GUILayout.EndHorizontal(); }
private GenericMenu GenerateStateListMenu(SkillEvent fsmEvent) { GenericMenu genericMenu = new GenericMenu(); if (SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()) == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Unused_Event())); return(genericMenu); } List <SkillState> list = SkillInfo.FindStatesUsingEvent(SkillEditor.SelectedFsm, fsmEvent.get_Name()); using (List <SkillState> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { SkillState current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(current.get_Name()), SkillEditor.SelectedState == current, new GenericMenu.MenuFunction2(EditorCommands.SelectState), current); } } return(genericMenu); }