예제 #1
0
        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();
        }
예제 #2
0
        private void DoVariableTable()
        {
            this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, new GUILayoutOption[0]);
            if (FsmEditorSettings.ShowHints)
            {
                GUILayout.Box(Strings.get_Hint_Variable_Panel(), SkillEditorStyles.HintBox, new GUILayoutOption[0]);
            }
            if (this.fsmVariables.get_Count() == 0)
            {
                GUILayout.BeginHorizontal(SkillEditorStyles.TableRowBox, new GUILayoutOption[0]);
                GUILayout.Label(Strings.get_Label_None_In_Table(), new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
            }
            else
            {
                if (this.filteredVariables.get_Count() == 0)
                {
                    GUILayout.Label("No search results for: " + this.searchString, new GUILayoutOption[0]);
                }
            }
            int num = 0;

            for (int i = 0; i < this.filteredVariables.get_Count(); i++)
            {
                SkillVariable fsmVariable = this.filteredVariables.get_Item(i);
                int           categoryID  = fsmVariable.CategoryID;
                if (categoryID > 0 && categoryID != num)
                {
                    num = categoryID;
                    this.categoryLabels.get_Item(num).OnGUI(new GUILayoutOption[0]);
                    SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]);
                }
                bool flag = fsmVariable == this.selectedFsmVariable;
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.BeginHorizontal(flag ? SkillEditorStyles.SelectedEventBox : (FsmEditorSettings.DebugVariables ? SkillEditorStyles.TableRowBoxNoDivider : SkillEditorStyles.TableRowBox), new GUILayoutOption[0]);
                GUIStyle gUIStyle = flag ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText;
                if (GUILayout.Button(new GUIContent(fsmVariable.Name, fsmVariable.Tooltip), gUIStyle, new GUILayoutOption[]
                {
                    GUILayout.MinWidth(155f)
                }))
                {
                    this.SelectVariable(fsmVariable);
                    if ((Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) && this.VariableContextClicked != null)
                    {
                        this.VariableContextClicked(fsmVariable);
                    }
                }
                GUILayout.FlexibleSpace();
                int usedCount = this.GetUsedCount(fsmVariable.NamedVar);
                GUILayout.Label((usedCount >= 0) ? usedCount.ToString(CultureInfo.get_CurrentCulture()) : "-", gUIStyle, new GUILayoutOption[0]);
                GUILayout.Space(10f);
                bool changed = GUI.get_changed();
                GUI.set_changed(false);
                VariableType newType = EditorGUILayout.Popup(fsmVariable.Type, SkillVariable.VariableTypeNames, new GUILayoutOption[]
                {
                    GUILayout.MaxWidth(114f)
                });
                if (GUI.get_changed())
                {
                    this.ChangeVariableType(fsmVariable, newType);
                    GUIUtility.ExitGUI();
                    return;
                }
                GUI.set_changed(changed);
                if (SkillEditorGUILayout.DeleteButton())
                {
                    this.DeleteVariable(fsmVariable, true, true);
                    GUIUtility.ExitGUI();
                    return;
                }
                GUILayout.EndHorizontal();
                if (FsmEditorSettings.DebugVariables)
                {
                    SkillEditorGUILayout.ReadonlyTextField(fsmVariable.NamedVar.ToString(), new GUILayoutOption[0]);
                }
                GUILayout.EndVertical();
                if (flag)
                {
                    this.selectedIndex = i;
                    if (Event.get_current().get_type() == 7)
                    {
                        this.selectedRect = GUILayoutUtility.GetLastRect();
                        this.selectedRect.set_y(this.selectedRect.get_y() - this.scrollPosition.y);
                    }
                }
            }
            Rect lastRect = GUILayoutUtility.GetLastRect();

            this.mouseOverTable = (Event.get_current().get_mousePosition().y < lastRect.get_y() + lastRect.get_height());
            if (this.fsmOwner != null)
            {
                this.DoGlobalVariablesTable();
            }
            GUILayout.Space(20f);
            GUILayout.FlexibleSpace();
            GUILayout.EndScrollView();
            this.DoAutoScroll();
            GUILayout.EndVertical();
            if (Event.get_current().get_type() == 7)
            {
                FsmVariablesEditor.tableHeight = GUILayoutUtility.GetLastRect().get_height() + GUI.get_skin().get_horizontalScrollbar().get_fixedHeight() + EditorStyles.get_toolbar().get_fixedHeight();
            }
        }
예제 #3
0
        private void DoEventLine(SkillEvent fsmEvent)
        {
            int num;

            this.usageCount.TryGetValue(fsmEvent, ref num);
            if (num == 0 && FsmEditorSettings.HideUnusedEvents)
            {
                return;
            }
            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(), new GUIContent("", Strings.get_Label_Global()), SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(17f),
                GUILayout.MinWidth(17f)
            });

            if (flag != fsmEvent.get_IsGlobal())
            {
                SkillEditor.Builder.SetEventIsGlobal(null, fsmEvent, flag);
            }
            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(base.get_position().get_width() - 100f)
            }))
            {
                this.SelectEvent(fsmEvent);
                if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey())
                {
                    this.GenerateUsageContextMenu(this.selectedEvent).ShowAsContext();
                }
                if (EditorApplication.get_timeSinceStartup() - this.clickTime < 0.3)
                {
                    this.AddSelectedEventToState();
                }
                this.clickTime = EditorApplication.get_timeSinceStartup();
            }
            GUILayout.FlexibleSpace();
            GUILayout.Label(num.ToString(CultureInfo.get_CurrentCulture()), gUIStyle, new GUILayoutOption[0]);
            GUILayout.Space(10f);
            EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent());
            if (SkillEditorGUILayout.DeleteButton() && Dialogs.YesNoDialog(Strings.get_Dialog_Delete_Event(), string.Format(Strings.get_Dialog_Delete_Event_Are_you_sure(), (num > 0) ? string.Concat(new object[]
            {
                "\n\n",
                Strings.get_Dialog_Delete_Event_Used_By(),
                num,
                (num > 1) ? Strings.get_Label_Postfix_FSMs_Plural() : Strings.get_Label_Postfix_FSM()
            }) : "")))
            {
                EditorCommands.DeleteEventFromAll(fsmEvent);
                SkillEditor.EventManager.Reset();
                SkillEvent.RemoveEventFromEventList(fsmEvent);
                if (fsmEvent.get_IsGlobal())
                {
                    SkillEvent.get_globalEvents().RemoveAll((string r) => r == fsmEvent.get_Name());
                    SkillEditor.SaveGlobals();
                }
                this.BuildFilteredList();
                base.Repaint();
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
예제 #4
0
        private static void StateTools()
        {
            ToolWindow.Header(Strings.get_ToolWindow_Header_State_Tools());
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button(Strings.get_Command_Copy(), new GUILayoutOption[0]))
            {
                EditorCommands.CopyStateSelection();
            }
            EditorGUI.BeginDisabledGroup(!SkillEditor.Builder.CanPaste());
            if (GUILayout.Button(Strings.get_Command_Paste(), new GUILayoutOption[0]))
            {
                EditorCommands.PasteStates(FsmGraphView.GetViewCenter());
                SkillEditor.RepaintAll();
            }
            EditorGUI.EndDisabledGroup();
            if (GUILayout.Button(Strings.get_Command_Delete(), new GUILayoutOption[0]))
            {
                SkillEditor.RepaintAll();
                EditorCommands.DeleteMultiSelection();
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button(Strings.get_Command_Save_Selection_as_Template(), new GUILayoutOption[0]))
            {
                EditorCommands.SaveSelectionAsTemplate();
            }
            if (GUILayout.Button(Strings.get_Command_Set_As_Start_State(), new GUILayoutOption[0]))
            {
                EditorCommands.SetSelectedStateAsStartState();
                SkillEditor.RepaintAll();
            }
            if (GUILayout.Button(Strings.get_Command_Toggle_Breakpoint(), new GUILayoutOption[0]))
            {
                EditorCommands.ToggleBreakpointOnSelectedState();
                SkillEditor.RepaintAll();
            }
            ToolWindow.Divider(Strings.get_ToolWindow_Header_Transitions());
            if (GUILayout.Button(Strings.get_Command_Add_Transition(), new GUILayoutOption[0]))
            {
                EditorCommands.AddTransitionToSelectedState();
                SkillEditor.RepaintAll();
            }
            if (GUILayout.Button(Strings.get_Command_Add_Global_Transition(), new GUILayoutOption[0]))
            {
                EditorCommands.AddGlobalTransitionToSelectedState();
                SkillEditor.RepaintAll();
            }
            if (!SkillEditor.Builder.HasGlobalTransition(SkillEditor.SelectedState))
            {
                return;
            }
            ToolWindow.Divider(Strings.get_ToolWindow_Header_Global_Transitions());
            SkillState selectedState = SkillEditor.SelectedState;

            SkillTransition[] globalTransitions = SkillEditor.SelectedFsm.get_GlobalTransitions();
            for (int i = 0; i < globalTransitions.Length; i++)
            {
                SkillTransition fsmTransition = globalTransitions[i];
                if (!(fsmTransition.get_ToState() != selectedState.get_Name()))
                {
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    if (GUILayout.Button(Labels.GetEventLabel(fsmTransition), EditorStyles.get_popup(), new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(140f)
                    }))
                    {
                        ToolWindow.editingTransition = fsmTransition;
                        SkillEditorGUILayout.GenerateEventSelectionMenu(SkillEditor.SelectedFsm, fsmTransition.get_FsmEvent(), new GenericMenu.MenuFunction2(ToolWindow.SelectGlobalTransitionEvent), new GenericMenu.MenuFunction(SkillEditor.OpenEventManager)).ShowAsContext();
                    }
                    if (SkillEditorGUILayout.DeleteButton())
                    {
                        EditorCommands.DeleteGlobalTransition(fsmTransition);
                        SkillEditor.RepaintAll();
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }