Ejemplo n.º 1
0
        private void MoveToGlobals(object userdata)
        {
            SkillVariable fsmVariable = userdata as SkillVariable;

            if (fsmVariable != null && fsmVariable.NamedVar != null)
            {
                if (SkillVariables.get_GlobalVariables().Contains(fsmVariable.Name))
                {
                    NamedVariable variable = SkillVariables.get_GlobalVariables().GetVariable(fsmVariable.Name);
                    if (variable.get_VariableType() != fsmVariable.NamedVar.get_VariableType())
                    {
                        Dialogs.OkDialog(Strings.get_Dialog_Make_Global_Variable(), Strings.get_VariableManager_MoveToGlobals_Warning());
                        return;
                    }
                    if (Dialogs.YesNoDialog(Strings.get_Dialog_Make_Global_Variable(), Strings.get_VariableManager_MoveToGlobals_Confirm()))
                    {
                        this.RemoveLocalVariable(fsmVariable);
                        return;
                    }
                }
                else
                {
                    if (Dialogs.AreYouSure(Strings.get_Dialog_Make_Global_Variable()))
                    {
                        SkillVariable.AddVariable(SkillVariables.get_GlobalVariables(), fsmVariable.NamedVar.Clone());
                        this.RemoveLocalVariable(fsmVariable);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void DeleteUnusedVariables()
        {
            SkillSearch.Update(SkillEditor.SelectedFsm);
            List <SkillVariable> unusedVariables = SkillSearch.GetUnusedVariables(SkillEditor.SelectedFsm);

            if (unusedVariables.get_Count() == 0)
            {
                EditorUtility.DisplayDialog(Strings.get_Command_Delete_Unused_Variables(), Strings.get_Label_No_unused_variables(), Strings.get_OK());
                return;
            }
            if (Dialogs.YesNoDialog(Strings.get_Command_Delete_Unused_Variables(), string.Format(Strings.get_Command_Delete_Variables_Are_you_sure(), unusedVariables.get_Count())))
            {
                SkillEditor.RegisterUndo(Strings.get_Menu_Delete_Unused_Variables());
                List <SkillVariable> list = new List <SkillVariable>(unusedVariables);
                using (List <SkillVariable> .Enumerator enumerator = list.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        SkillVariable current = enumerator.get_Current();
                        this.fsmVariablesEditor.DeleteVariable(current, false, false);
                    }
                }
                this.Reset();
            }
        }
Ejemplo n.º 3
0
        private void DeleteUnusedEvents()
        {
            SkillSearch.Update(SkillEditor.SelectedFsm);
            List <string> unusedEvents = SkillSearch.GetUnusedEvents(SkillEditor.SelectedFsm);
            int           count        = unusedEvents.get_Count();

            if (count == 0)
            {
                EditorUtility.DisplayDialog(Strings.get_Dialog_Delete_Unused_Events(), Strings.get_Dialog_No_unused_events(), Strings.get_OK());
                return;
            }
            if (Dialogs.YesNoDialog(Strings.get_Dialog_Delete_Unused_Events(), string.Format(Strings.get_Dialog_Delete_Unused_Events_Are_you_sure(), count)))
            {
                SkillEditor.RegisterUndo(Strings.get_Dialog_Delete_Unused_Events());
                using (List <string> .Enumerator enumerator = unusedEvents.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current = enumerator.get_Current();
                        if (!SkillEvent.IsEventGlobal(current))
                        {
                            SkillEditor.Builder.DeleteEvent(SkillEditor.SelectedFsm, current);
                        }
                    }
                }
                this.Reset();
            }
            SkillEditor.SetFsmDirty(true, false);
        }
Ejemplo n.º 4
0
 private bool CheckDeleteVariable(string title, string warning, SkillVariable fsmVariable)
 {
     if (this.globalsOwner != null)
     {
         return(Dialogs.YesNoDialog(title, Strings.get_Label_Check_Edit_Global_Variable()));
     }
     return(this.fsmOwner == null || SkillSearch.GetUnusedVariables(this.fsmOwner).Contains(fsmVariable) || Dialogs.YesNoDialog(title, warning));
 }
Ejemplo n.º 5
0
 public static void DeleteTemplate()
 {
     if (SkillEditor.SelectedTemplate != null && Dialogs.YesNoDialog(Strings.get_Command_DeleteTemplate()))
     {
         AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(SkillEditor.SelectedTemplate));
         Templates.InitList();
     }
 }
Ejemplo n.º 6
0
        public static void SaveFsmAsTemplate()
        {
            SkillTemplate fsmTemplate = SkillBuilder.CreateTemplate(SkillEditor.SelectedFsm);

            if (fsmTemplate != null && SkillEditor.SelectedFsmComponent != null && Dialogs.YesNoDialog(Strings.get_Dialog_Save_Template(), Strings.get_Dialog_Use_Saved_Template_in_this_FSM()))
            {
                SkillEditor.SelectedFsmComponent.SetFsmTemplate(fsmTemplate);
                SkillEditor.Inspector.SetMode(InspectorMode.FsmInspector);
            }
        }
Ejemplo n.º 7
0
 private void PasteVariables()
 {
     if (this.clipboard != null)
     {
         SkillEditor.RegisterUndo(Strings.get_Menu_Paste_Variables());
         bool overwriteValues = false;
         if (SkillBuilder.VariableInSourceExistsInTarget(this.clipboard, SkillEditor.SelectedFsm))
         {
             overwriteValues = Dialogs.YesNoDialog(Strings.get_Dialog_Paste_Variables(), Strings.get_PasteVariables_Warning_Some_variables_already_exist__overwrite_values());
         }
         SkillBuilder.PasteVariables(SkillEditor.SelectedFsm, this.clipboard, overwriteValues);
         SkillEditor.SetFsmDirty();
         this.fsmVariablesEditor.Reset();
     }
 }
Ejemplo n.º 8
0
 public static bool YesNoDialog(string message)
 {
     return(Dialogs.YesNoDialog(Strings.get_ProductName(), message));
 }
Ejemplo n.º 9
0
        public static SkillStateAction AddPlayAnimationAction(Skill targetFsm, SkillState state, AnimationClip anim, SkillStateAction beforeAction = null)
        {
            SkillStateAction fsmStateAction = ActionUtility.AddAction(state, "HutongGames.PlayMaker.Actions.PlayAnimation", beforeAction);

            if (fsmStateAction == null)
            {
                return(null);
            }
            if (!ActionUtility.GameObjectHasAnimationClip(targetFsm.get_GameObject(), anim.get_name()) && Dialogs.YesNoDialog(Strings.get_ActionUtility_Add_Animation_Clip_to_GameObject()))
            {
                ActionUtility.AddAnimationClip(targetFsm.get_GameObject(), anim);
            }
            FieldInfo field = fsmStateAction.GetType().GetField("animName", 20);

            if (field != null)
            {
                FieldInfo   arg_68_0  = field;
                object      arg_68_1  = fsmStateAction;
                SkillString fsmString = new SkillString();
                fsmString.set_Value(anim.get_name());
                arg_68_0.SetValue(arg_68_1, fsmString);
            }
            SkillEditor.SetFsmDirty(targetFsm, true, false, true);
            SkillEditor.SaveActions(targetFsm);
            return(fsmStateAction);
        }
Ejemplo n.º 10
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();
        }