private void ChangeVariableType(SkillVariable fsmVariable, VariableType newType) { if (!this.CheckDeleteVariable(Strings.get_Dialog_Edit_Variable_Type(), Strings.get_Dialog_Edit_Variable_Type_Are_you_sure(), fsmVariable)) { return; } this.RegisterUndo(Strings.get_Label_Edit_Variable()); string name = fsmVariable.Name; string tooltip = fsmVariable.Tooltip; string category = fsmVariable.Category; bool showInInspector = fsmVariable.ShowInInspector; if (this.fsmOwner != null) { SkillBuilder.RemoveVariableUsage(fsmVariable.NamedVar); } else { SkillSearch.UpdateAll(); SkillBuilder.RemoveGlobalVariableUsage(fsmVariable.NamedVar); } SkillVariable.DeleteVariable(this.target, fsmVariable); SkillVariable fsmVariable2 = this.AddVariable(newType, name, false); fsmVariable2.Tooltip = tooltip; fsmVariable2.SetCategory(category); fsmVariable2.ShowInInspector = showInInspector; this.BuildFsmVariableList(true); this.SelectVariable(name); }
private static void DoVariablesMenu(GameObject go, string fsmName, UIHint hint) { GenericMenu genericMenu = new GenericMenu(); using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); if (current.get_GameObject() == go && current.get_Name() == fsmName) { NamedVariable[] names = current.get_Variables().GetNames(SkillVariable.GetVariableType(hint)); NamedVariable[] array = names; for (int i = 0; i < array.Length; i++) { NamedVariable namedVariable = array[i]; genericMenu.AddItem(new GUIContent(namedVariable.get_Name()), false, new GenericMenu.MenuFunction2(StringEditor.SetStringValue), namedVariable.get_Name()); } } } } if (genericMenu.GetItemCount() == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Label_None())); } genericMenu.ShowAsContext(); }
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); } } } }
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(); } }
public void BuildFsmVariableList(bool keepSelection = true) { if (this.target == null) { return; } string name = ""; if (this.selectedFsmVariable != null) { name = this.selectedFsmVariable.Name; } this.fsmVariables = SkillVariable.GetFsmVariableList(this.owner); this.SortVariableList(); this.listIsDirty = false; this.categoryLabels.Clear(); while (this.categoryLabels.get_Count() < this.target.get_Categories().Length) { string text = this.target.get_Categories()[this.categoryLabels.get_Count()]; EditableLabel editableLabel = new EditableLabel(this.window, text) { ID = this.categoryLabels.get_Count(), EditCommited = new EditableLabel.EditCommitedCallback(this.CommitCategoryEdit), ContextClick = new EditableLabel.ContextClickCallback(this.DoCategoryContextMenu), Style = EditorStyles.get_boldLabel() }; this.categoryLabels.Add(editableLabel); } if (keepSelection && this.categoryTextField != null) { this.SelectVariable(name); } this.BuildFilteredList(); }
private void BuildFilteredList() { if (string.IsNullOrEmpty(this.searchString)) { this.filteredVariables = new List <SkillVariable>(this.fsmVariables); return; } this.filteredVariables.Clear(); string text = this.searchString.ToUpper(); using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (current.Name.ToUpper().Contains(text)) { this.filteredVariables.Add(current); } else { if (this.selectedFsmVariable == current) { this.Deselect(); this.searchBox.Focus(); } } } } }
private void RemoveLocalVariable(SkillVariable variable) { SkillVariable.DeleteVariable(SkillEditor.SelectedFsm.get_Variables(), variable); SkillEditor.SelectedFsm.Reinitialize(); SkillEditor.SetFsmDirty(); this.Reset(); GlobalVariablesWindow.ResetView(); }
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)); }
private void AddVariable(TextField textField) { SkillVariable variable = this.AddVariable(this.newVariableType, textField.Text, true); if (FsmEditorSettings.SelectNewVariables) { this.SelectVariable(variable); } }
public void Deselect() { this.isVariableSelected = false; this.selectedFsmVariable = null; this.selectedIndex = -1; this.addVariableTextField.Text = ""; SkillEditor.RepaintAll(); Keyboard.ResetFocus(); this.SaveSelection(""); }
private void RemoveUnusedCategories(SkillVariables variables, List <SkillVariable> fsmVariables) { List <string> usedVariableCategories = FsmVariablesEditor.GetUsedVariableCategories(fsmVariables); usedVariableCategories.Add(""); List <string> list = new List <string>(variables.get_Categories()); list.Sort(); variables.set_Categories(Enumerable.ToArray <string>(Enumerable.Where <string>(list, new Func <string, bool>(usedVariableCategories.Contains)))); SkillVariable.RemapVariableCategories(variables, fsmVariables); }
private void UpdateVariable(SkillVariable fsmVariable, string newName = "") { this.RegisterUndo(Strings.get_Label_Edit_Variable()); if (!string.IsNullOrEmpty(newName)) { SkillBuilder.RenameVariable(fsmVariable.NamedVar, newName); SkillVariable.RenameVariable(this.target, fsmVariable, newName); this.listIsDirty = true; } this.SetDirty(true); }
public void SetTarget(Object newOwner) { if (newOwner == this.owner) { return; } this.owner = newOwner; this.target = SkillVariable.GetVariables(this.owner); this.editingGlobalVariables = (newOwner is PlayMakerGlobals); this.editingAsset = (this.editingGlobalVariables || newOwner is SkillTemplate); this.Reset(); }
public SkillVariable AddVariable(VariableType type, string name, bool undo = true) { if (undo) { SkillEditor.RegisterUndo("Add Variable"); } SkillVariable.AddVariable(this.target, type, name, null, 0); SkillVariable.RemapVariableCategories(this.target, this.fsmVariables); this.BuildFsmVariableList(false); this.SetDirty(true); return(this.GetVariable(name)); }
private static List <string> GetUsedVariableCategories(IEnumerable <SkillVariable> fsmVariables) { List <string> list = new List <string>(); using (IEnumerator <SkillVariable> enumerator = fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); list.Add(current.Category); } } return(list); }
private SkillVariable GetVariable(string name) { using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (current.Name == name) { return(current); } } } return(null); }
private void UpdateUnusedVariables() { this.unusedVariables.Clear(); using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (this.GetVariableUseCount(current.NamedVar) == 0) { this.unusedVariables.Add(current); } } } }
public void SelectVariable(SkillVariable variable) { if (variable == null) { this.Deselect(); return; } this.isVariableSelected = true; this.selectedFsmVariable = variable; this.editNameTextField.Text = variable.Name; this.categoryTextField.Text = variable.GetCategory(); Keyboard.ResetFocus(); this.autoScroll = true; this.SaveSelection(variable.Name); }
private void RenameVariable(SkillVariable fsmVariable, string newName) { if (fsmVariable == null) { return; } this.RegisterUndo(Strings.get_Label_Edit_Variable()); this.UpdateVariable(fsmVariable, newName); if (this.fsmOwner != null) { SkillEditor.SaveActions(this.fsmOwner); this.fsmOwner.InitData(); } this.SaveSelection(fsmVariable.Name); }
private bool VariableNameExists(string name) { using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (name == current.Name) { return(true); } } } return(false); }
public static GenericMenu GenerateEnumTypesMenu(SkillVariable fsmVariable) { TypeHelpers.targetFsmVariable = fsmVariable; GenericMenu genericMenu = new GenericMenu(); using (List <Type> .Enumerator enumerator = TypeHelpers.EnumTypeList.GetEnumerator()) { while (enumerator.MoveNext()) { Type current = enumerator.get_Current(); string fullName = current.get_FullName(); string text = fullName.Replace('.', '/'); genericMenu.AddItem(new GUIContent(text), fullName == fsmVariable.TypeName, new GenericMenu.MenuFunction2(TypeHelpers.SetFsmVariableObjectType), fullName); } } return(genericMenu); }
public List <string> FindVariablesUsedByAction(SkillStateAction action) { List <string> list = new List <string>(); using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (this.ActionUsesVariable(action, current.NamedVar)) { list.Add(current.NamedVar.get_Name()); } } } return(list); }
private static void MoveToLocal(object userdata) { NamedVariable namedVariable = userdata as NamedVariable; if (namedVariable != null && SkillEditor.SelectedFsm != null) { SkillVariables variables = SkillEditor.SelectedFsm.get_Variables(); if (variables.Contains(namedVariable.get_Name())) { Dialogs.OkDialog(Strings.get_Dialog_Make_Local_Variable(), Strings.get_Dialog_Error_Variable_with_same_name_already_exists()); return; } SkillVariable.AddVariable(variables, namedVariable.Clone()); SkillEditor.SelectedFsm.Reinitialize(); SkillEditor.SetFsmDirty(); SkillEditor.VariableManager.Reset(); SkillEditor.RepaintAll(); } }
private void DeleteCategory(object userdata) { EditableLabel editableLabel = (EditableLabel)userdata; string text = editableLabel.Text; using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (current.Category == text) { current.SetCategory(""); } } } this.RemoveUnusedCategories(); this.BuildFsmVariableList(true); }
private bool IsValidVariableRename(string currentName, string name) { if (string.IsNullOrEmpty(name)) { return(false); } using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); if (currentName != current.Name && name == current.Name) { return(false); } } } return(true); }
private void PerformDrop(Object obj) { string text = this.ValidateDrop(obj); if (!string.IsNullOrEmpty(text)) { Dialogs.OkDialog(text); return; } string name = this.MakeVariableNameUnique(obj.get_name()); SkillVariable fsmVariable = this.AddVariable(12, name, true); fsmVariable.TypeName = obj.GetType().ToString(); fsmVariable.ObjectType = obj.GetType(); fsmVariable.ObjectValue = obj; fsmVariable.UpdateVariableValue(); this.SetDirty(true); this.BuildFsmVariableList(false); this.SelectVariable(name); GUIUtility.ExitGUI(); }
private static void DoVariableContextMenu(SkillVariable variable) { GenericMenu genericMenu = new GenericMenu(); List <SkillInfo> globalVariablesUsageList = SkillSearch.GetGlobalVariablesUsageList(variable.NamedVar); if (globalVariablesUsageList.get_Count() == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_No_FSMs_use_this_variable())); } else { using (List <SkillInfo> .Enumerator enumerator = globalVariablesUsageList.GetEnumerator()) { while (enumerator.MoveNext()) { SkillInfo current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(Labels.GetFullFsmLabel(current.fsm)), SkillEditor.SelectedFsm == current.fsm, new GenericMenu.MenuFunction2(EditorCommands.SelectFsm), current.fsm); } } } genericMenu.ShowAsContext(); }
private void DebugFsmVariables(string prefix = "") { string text = prefix; using (List <SkillVariable> .Enumerator enumerator = this.fsmVariables.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); string text2 = text; text = string.Concat(new string[] { text2, current.Name, "[", current.Category, "]," }); } } Debug.Log(text); }
private void DebugCategories() { string text = ""; List <SkillVariable> unsortedFsmVariableList = SkillVariable.GetUnsortedFsmVariableList(this.owner); using (List <SkillVariable> .Enumerator enumerator = unsortedFsmVariableList.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); string text2 = text; text = string.Concat(new string[] { text2, current.Name, "[", current.Category, "]," }); } } GUILayout.Label(text.Substring(0, text.get_Length() - 1), new GUILayoutOption[0]); text = ""; int[] categoryIDs = this.target.get_CategoryIDs(); for (int i = 0; i < categoryIDs.Length; i++) { int num = categoryIDs[i]; text = text + num + ","; } GUILayout.Label(text.Substring(0, text.get_Length() - 1), new GUILayoutOption[0]); text = ""; string[] categories = this.target.get_Categories(); for (int j = 0; j < categories.Length; j++) { string text3 = categories[j]; text = text + text3 + ","; } GUILayout.Label(text.Substring(0, text.get_Length() - 1), new GUILayoutOption[0]); }
private static NamedVariable VariableToggle(NamedVariable variable, string label) { bool flag = VariableEditor.VariableToggle(variable.get_UseVariable()); if (flag != variable.get_UseVariable()) { if (!flag) { return(SkillVariable.GetNewVariableOfSameType(variable)); } variable.set_UseVariable(true); variable.set_Name(null); if (EditorGUI.get_actionKey()) { return(EditorCommands.AddVariable(SkillVariable.GetVariableType(variable), label.Trim(new char[] { '*' }).ToCamelCase())); } } return(variable); }