public static void DrawArrayValues(ISD_PlistKey var) { var.IsListOpen = EditorGUILayout.Foldout(var.IsListOpen, "Array Values (" + var.ChildrensIds.Count + ")"); if (var.IsListOpen) { EditorGUI.indentLevel++; { foreach (string uniqueKey in var.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(uniqueKey); DrawPlistVariable(v, uniqueKey, var.ChildrensIds); if (!var.ChildrensIds.Contains(uniqueKey)) { return; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Value", GUILayout.Width(100))) { ISD_PlistKey newVar = new ISD_PlistKey(); var.AddChild(newVar); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUI.indentLevel--; } }
//-------------------------------------- // Variables //-------------------------------------- public void AddVariableToDictionary(string uniqueIdKey, ISD_PlistKey var) { ISD_PlistKeyId newVar = new ISD_PlistKeyId(); newVar.uniqueIdKey = uniqueIdKey; newVar.VariableValue = var; VariableDictionary.Add(newVar); }
//-------------------------------------- // Info.plist //-------------------------------------- /// <summary> /// Method will add or replace new <see cref="ISD_PlistKey"/> to the Info.plist keys /// </summary> /// <param name="name">Info.plist key name</param> public static void SetInfoPlistKey(ISD_PlistKey key) { ISD_PlistKey plisKey = GetInfoPlistKey(key.Name); if (plisKey != null) { ISD_Settings.Instance.PlistVariables.Remove(plisKey); } ISD_Settings.Instance.PlistVariables.Add(key); }
static void RegisterAppLanguages() { var CFBundleLocalizations = new ISD_PlistKey(); CFBundleLocalizations.Name = "CFBundleLocalizations"; CFBundleLocalizations.Type = ISD_PlistKeyType.Array; foreach (var lang in ISD_Settings.Instance.Languages) { var langItem = new ISD_PlistKey(); langItem.Type = ISD_PlistKeyType.String; langItem.StringValue = lang.Name; CFBundleLocalizations.AddChild(langItem); } }
public static void PlistValues() { SA_EditorGUILayout.Header("PLIST VALUES"); EditorGUI.indentLevel++; { foreach (ISD_PlistKey var in ISD_Settings.Instance.PlistVariables) { EditorGUILayout.BeginVertical(GUI.skin.box); DrawPlistVariable(var, (object)var, ISD_Settings.Instance.PlistVariables); EditorGUILayout.EndVertical(); if (!ISD_Settings.Instance.PlistVariables.Contains(var)) { return; } } EditorGUILayout.Space(); } EditorGUI.indentLevel--; EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("New Variable Name"); NewPlistValueName = EditorGUILayout.TextField(NewPlistValueName); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add", GUILayout.Width(100))) { if (NewPlistValueName.Length > 0) { ISD_PlistKey var = new ISD_PlistKey(); var.Name = NewPlistValueName; ISD_API.SetInfoPlistKey(var); } NewPlistValueName = string.Empty; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
/// <summary> /// Add's child key /// </summary> /// <param name="childKey"></param> public void AddChild(ISD_PlistKey childKey) { if (Type.Equals(ISD_PlistKeyType.Dictionary)) { foreach (string ChildsId in ChildrensIds) { ISD_PlistKey var = ISD_Settings.Instance.getVariableById(ChildsId); if (var.Name.Equals(childKey.Name)) { ISD_Settings.Instance.RemoveVariable(var, ChildrensIds); break; } } } string keyId = SA_IdFactory.RandomString; ISD_Settings.Instance.AddVariableToDictionary(keyId, childKey); ChildrensIds.Add(keyId); }
static PlistElementDict CreatePlistDict(ISD_PlistKey variable, PlistElementDict dict = null) { if (dict == null) { dict = new PlistElementDict(); } foreach (string variableUniqueIdKey in variable.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(variableUniqueIdKey); switch (v.Type) { case ISD_PlistKeyType.String: dict.SetString(v.Name, v.StringValue); break; case ISD_PlistKeyType.Boolean: dict.SetBoolean(v.Name, v.BooleanValue); break; case ISD_PlistKeyType.Integer: dict.SetInteger(v.Name, v.IntegerValue); break; case ISD_PlistKeyType.Array: var array = dict.CreateArray(v.Name); CreatePlistArray(v, array); break; case ISD_PlistKeyType.Dictionary: var d = dict.CreateDict(v.Name); CreatePlistDict(v, d); break; } } return(dict); }
public void RemoveVariable(ISD_PlistKey v, IList ListWithThisVariable) { if (ISD_Settings.Instance.PlistVariables.Contains(v)) { ISD_Settings.Instance.PlistVariables.Remove(v); } else { foreach (ISD_PlistKeyId vid in VariableDictionary) { if (vid.VariableValue.Equals(v)) { VariableDictionary.Remove(vid); string id = vid.uniqueIdKey; if (ListWithThisVariable.Contains(id)) { ListWithThisVariable.Remove(vid.uniqueIdKey); } break; } } } //remove junk List <ISD_PlistKeyId> keysInUse = new List <ISD_PlistKeyId>(VariableDictionary); foreach (var id in VariableDictionary) { bool isInUse = IsInUse(id.uniqueIdKey, PlistVariables); if (!isInUse) { keysInUse.Remove(id); } } VariableDictionary = keysInUse; }
public static void DrawDictionaryValues(ISD_PlistKey var) { var.IsListOpen = EditorGUILayout.Foldout(var.IsListOpen, "Dictionary Values"); if (var.IsListOpen) { EditorGUI.indentLevel++; { foreach (string uniqueKey in var.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(uniqueKey); DrawPlistVariable(v, uniqueKey, var.ChildrensIds); if (!var.ChildrensIds.Contains(uniqueKey)) { return; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("New Key"); NewValueName = EditorGUILayout.TextField(NewValueName); if (GUILayout.Button("Add", GUILayout.Width(50))) { if (NewValueName.Length > 0) { ISD_PlistKey v = new ISD_PlistKey(); v.Name = NewValueName; var.AddChild(v); } } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } }
static PlistElementArray CreatePlistArray(ISD_PlistKey variable, PlistElementArray array = null) { if (array == null) { array = new PlistElementArray(); } foreach (string variableUniqueIdKey in variable.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(variableUniqueIdKey); switch (v.Type) { case ISD_PlistKeyType.String: array.AddString(v.StringValue); break; case ISD_PlistKeyType.Boolean: array.AddBoolean(v.BooleanValue); break; case ISD_PlistKeyType.Integer: array.AddInteger(v.IntegerValue); break; case ISD_PlistKeyType.Array: CreatePlistArray(v, array.AddArray()); break; case ISD_PlistKeyType.Dictionary: CreatePlistDict(v, array.AddDict()); break; } } return(array); }
/// <summary> /// Removes Info.plist key /// </summary> /// <param name="key">Info.plist key</param> public static void RemoveInfoPlistKey(ISD_PlistKey key) { RemoveInfoPlistKey(key.Name); }
public static void DrawPlistVariable(ISD_PlistKey var, object valuePointer, IList valueOrigin) { EditorGUILayout.BeginHorizontal(); if (var.Name.Length > 0) { var.IsOpen = EditorGUILayout.Foldout(var.IsOpen, var.Name + " (" + var.Type.ToString() + ")"); } else { var.IsOpen = EditorGUILayout.Foldout(var.IsOpen, var.Type.ToString()); } bool ItemWasRemoved = SrotingButtons(valuePointer, valueOrigin); if (ItemWasRemoved) { ISD_Settings.Instance.RemoveVariable(var, valueOrigin); return; } EditorGUILayout.EndHorizontal(); if (var.IsOpen) { EditorGUI.indentLevel++; { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Type"); if (var.ChildrensIds.Count > 0) { GUI.enabled = false; var.Type = (ISD_PlistKeyType)EditorGUILayout.EnumPopup(var.Type); GUI.enabled = GUI_ENABLED; } else { var.Type = (ISD_PlistKeyType)EditorGUILayout.EnumPopup(var.Type); } EditorGUILayout.EndHorizontal(); if (var.Type == ISD_PlistKeyType.Array) { DrawArrayValues(var); } else if (var.Type == ISD_PlistKeyType.Dictionary) { DrawDictionaryValues(var); } else if (var.Type == ISD_PlistKeyType.Boolean) { var.BooleanValue = SA_EditorGUILayout.ToggleFiled("Value", var.BooleanValue, SA_StyledToggle.ToggleType.YesNo); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Value"); switch (var.Type) { case ISD_PlistKeyType.Integer: var.IntegerValue = EditorGUILayout.IntField(var.IntegerValue); break; case ISD_PlistKeyType.String: var.StringValue = EditorGUILayout.TextField(var.StringValue); break; } EditorGUILayout.EndHorizontal(); } } EditorGUI.indentLevel--; } }
public void RemoveChild(ISD_PlistKey childKey) { ISD_Settings.Instance.RemoveVariable(childKey, ChildrensIds); }