public static void DrawArrayValues(ISD_PlistKey plistKey) { plistKey.IsListOpen = EditorGUILayout.Foldout(plistKey.IsListOpen, "Array Values (" + plistKey.ChildrensIds.Count + ")"); if (plistKey.IsListOpen) { EditorGUI.indentLevel++; { foreach (string uniqueKey in plistKey.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(uniqueKey); DrawPlistVariable(v, uniqueKey, plistKey.ChildrensIds); if (!plistKey.ChildrensIds.Contains(uniqueKey)) { return; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Value", GUILayout.Width(100))) { ISD_PlistKey newVar = new ISD_PlistKey(); plistKey.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); } ISD_API.SetInfoPlistKey(CFBundleLocalizations); }
/// <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); }
public override void OnGUI() { SA_EditorGUILayout.Header("PLIST VALUES"); foreach (ISD_PlistKey plistKey in ISD_Settings.Instance.PlistVariables) { EditorGUILayout.BeginVertical(GUI.skin.box); DrawPlistVariable(plistKey, (object)plistKey, ISD_Settings.Instance.PlistVariables); EditorGUILayout.EndVertical(); if (!ISD_Settings.Instance.PlistVariables.Contains(plistKey)) { return; } } EditorGUILayout.Space(); 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 v = new ISD_PlistKey(); v.Name = NewPlistValueName; ISD_API.SetInfoPlistKey(v); } NewPlistValueName = string.Empty; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
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; }
static void RegisterAppLanguages() { //We have nothing to register, no point to add en empty CFBundleLocalizations key. if (ISD_Settings.Instance.Languages.Count == 0) { return; } var CFBundleLocalizations = new ISD_PlistKey(); CFBundleLocalizations.Name = ISD_Settings.CF_LOCLIZATIONS_PLIST_KEY; 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); } ISD_API.SetInfoPlistKey(CFBundleLocalizations); }
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); }
public static void DrawDictionaryValues(ISD_PlistKey plistKey) { plistKey.IsListOpen = EditorGUILayout.Foldout(plistKey.IsListOpen, "Dictionary Values"); if (plistKey.IsListOpen) { EditorGUI.indentLevel++; { foreach (string uniqueKey in plistKey.ChildrensIds) { ISD_PlistKey v = ISD_Settings.Instance.getVariableById(uniqueKey); DrawPlistVariable(v, uniqueKey, plistKey.ChildrensIds); if (!plistKey.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; plistKey.AddChild(v); } } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } }
/// <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 plistKey, object valuePointer, IList valueOrigin) { EditorGUILayout.BeginHorizontal(); if (plistKey.Name.Length > 0) { plistKey.IsOpen = EditorGUILayout.Foldout(plistKey.IsOpen, plistKey.Name + " (" + plistKey.Type.ToString() + ")"); } else { plistKey.IsOpen = EditorGUILayout.Foldout(plistKey.IsOpen, plistKey.Type.ToString()); } bool ItemWasRemoved = SrotingButtons(valuePointer, valueOrigin); if (ItemWasRemoved) { ISD_Settings.Instance.RemoveVariable(plistKey, valueOrigin); return; } EditorGUILayout.EndHorizontal(); if (plistKey.IsOpen) { EditorGUI.indentLevel++; { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Type"); if (plistKey.ChildrensIds.Count > 0) { GUI.enabled = false; plistKey.Type = (ISD_PlistKeyType)EditorGUILayout.EnumPopup(plistKey.Type); } else { plistKey.Type = (ISD_PlistKeyType)EditorGUILayout.EnumPopup(plistKey.Type); } EditorGUILayout.EndHorizontal(); if (plistKey.Type == ISD_PlistKeyType.Array) { DrawArrayValues(plistKey); } else if (plistKey.Type == ISD_PlistKeyType.Dictionary) { DrawDictionaryValues(plistKey); } else if (plistKey.Type == ISD_PlistKeyType.Boolean) { plistKey.BooleanValue = SA_EditorGUILayout.ToggleFiled("Value", plistKey.BooleanValue, SA_StyledToggle.ToggleType.YesNo); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Value"); switch (plistKey.Type) { case ISD_PlistKeyType.Integer: plistKey.IntegerValue = EditorGUILayout.IntField(plistKey.IntegerValue); break; case ISD_PlistKeyType.String: plistKey.StringValue = EditorGUILayout.TextField(plistKey.StringValue); break; } EditorGUILayout.EndHorizontal(); } } EditorGUI.indentLevel--; } }
public void RemoveChild(ISD_PlistKey childKey) { ISD_Settings.Instance.RemoveVariable(childKey, ChildrensIds); }