public static PlistEntry CreateInstance() { PlistEntry entry = ScriptableObject.CreateInstance <PlistEntry> () as PlistEntry; entry.edited = true; return(entry); }
public List <PlistEntry> LoadPListEntries() { List <PlistEntry> entryList = new List <PlistEntry> (); XmlElement plistElement = (XmlElement)document.GetElementsByTagName(PLIST_TOKEN)[0]; foreach (XmlElement file in plistElement.ChildNodes) { entryList.Add(PlistEntry.CreateInstance(file)); } return(entryList); }
public PlistEntry Clone() { PlistEntry newEntry = PlistEntry.CreateInstance(); newEntry.key = key; newEntry.entryType = entryType; newEntry.arrayIndex = arrayIndex; newEntry.valueString = valueString; newEntry.valueData = valueData; newEntry.valueData = valueDate; newEntry.valueBool = valueBool; newEntry.valueNumber = valueNumber; newEntry.valueEntries = new List <PlistEntry> (); foreach (PlistEntry nestedEntry in valueEntries) { newEntry.valueEntries.Add(nestedEntry.Clone()); } return(newEntry); }
public static PlistEntry CreateInstance(XmlElement element, bool isArrayEntry = false) { PlistEntry entry = ScriptableObject.CreateInstance <PlistEntry> () as PlistEntry; entry.key = element.Attributes ["key"].Value; entry.entryType = entry.StringToEntryType(element.Attributes ["type"].Value); if (entry.isArrayEntry) { entry.arrayIndex = 0; } switch (entry.entryType) { case EntryTypes.STRING: entry.valueString = element.Attributes ["value"].Value; break; case EntryTypes.BOOL: entry.valueBool = Convert.ToBoolean(element.Attributes ["value"].Value); break; case EntryTypes.NUMBER: entry.valueNumber = (float)Convert.ToDouble(element.Attributes ["value"].Value); break; case EntryTypes.DATA: entry.valueData = element.Attributes ["value"].Value; break; case EntryTypes.DATE: entry.valueDate = element.Attributes ["value"].Value; break; default: foreach (XmlElement child in element.ChildNodes) { entry.valueEntries.Add(PlistEntry.CreateInstance(child, entry.entryType == EntryTypes.ARRAY)); } break; } return(entry); }
public void OnGUI() { Undo.RecordObject(this, "Xcode Window"); #region buttons EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Add File")) { string import = EditorUtility.OpenFilePanel("Include in Xcode project", Application.dataPath + "/..", ""); if (!import.Equals("")) { if (pbxFilePathSet.Contains(import)) { Debug.LogWarning("Already importing: " + import); } else { pbxFileList.Add(PBXFile.CreateInstance(import, importGroup)); pbxFilePathSet.Add(import); dirty = true; } } for (int i = 0; i < pbxFileList.Count; i++) { if (pbxFileList[i].removed) { pbxFileList.RemoveAt(i--); } } } if (GUILayout.Button("Add Folder")) { string import = EditorUtility.OpenFolderPanel("Include folder in Xcode project", Application.dataPath + "/..", ""); if (!import.Equals("")) { dirty = true; if (System.IO.Path.GetExtension(import).Equals(".framework")) { pbxFileList.Add(PBXFile.CreateInstance(import, importGroup)); } else { string[] filePaths = System.IO.Directory.GetFiles(import); foreach (string path in filePaths) { if (pbxFilePathSet.Contains(path)) { Debug.LogWarning("Already importing: " + path); } else { pbxFileList.Add(PBXFile.CreateInstance(path, importGroup)); pbxFilePathSet.Add(path); } } filePaths = System.IO.Directory.GetDirectories(import, "*.*"); foreach (string path in filePaths) { if (pbxFilePathSet.Contains(path)) { Debug.LogWarning("Already importing: " + path); } else { pbxFileList.Add(PBXFile.CreateInstance(path, importGroup)); pbxFilePathSet.Add(path); } } } } for (int i = 0; i < pbxFileList.Count; i++) { if (pbxFileList[i].removed) { pbxFileList.RemoveAt(i--); } } } if (GUILayout.Button("Add iOS SDK File")) { pbxSdkFileList.Add(PbxSdkFile.CreateInstance()); displaySdkFiles = true; } } try { EditorGUILayout.EndHorizontal(); } catch (System.InvalidOperationException) { Debug.Log("Caught invalidoperatinexception"); } EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Header Search Path")) { headerSearchPaths.Add(""); displayHeaderPaths = true; } if (GUILayout.Button("Library Search Path")) { librarySearchPaths.Add(""); displayLibraryPaths = true; } if (GUILayout.Button("Plist Entry")) { pListEntryList.Add(PlistEntry.CreateInstance()); displayPlistEditor = true; } } EditorGUILayout.EndHorizontal(); #endregion EditorGUILayout.Space(); importGroup = EditorGUILayout.TextField("File Import Group: ", importGroup); EditorGUI.BeginChangeCheck(); linkerFlags = EditorGUILayout.TextField("Linker Flags: ", linkerFlags); if (EditorGUI.EndChangeCheck()) { dirty = true; } EditorGUILayout.Space(); #region SDKFilesData displaySdkFiles = EditorGUILayout.Foldout(displaySdkFiles, "iOS SDK Files: (" + pbxSdkFileList.Count + ")"); if (displaySdkFiles) { BBGuiHelper.BeginIndent(); { for (int i = 0; i < pbxSdkFileList.Count; i++) { if (pbxSdkFileList[i].removed) { pbxFilePathSet.Remove(pbxSdkFileList[i].absolutePath); pbxSdkFileList.RemoveAt(i--); dirty = true; continue; } if (pbxSdkFileList[i] != null) { Undo.RecordObject(pbxSdkFileList[i], "Xcode File Import"); } pbxSdkFileList[i].OnGUI(); if (pbxSdkFileList[i].edited) { dirty = true; } } } BBGuiHelper.EndIndent(); } #endregion EditorGUILayout.Space(); #region FilesData displayFiles = EditorGUILayout.Foldout(displayFiles, "Other Files: (" + pbxFileList.Count + ")"); if (displayFiles) { BBGuiHelper.BeginIndent(); { string currentGroup = ""; BBGuiHelper.BeginIndent(); for (int i = 0; i < pbxFileList.Count; i++) { if (pbxFileList[i].removed) { pbxFilePathSet.Remove(pbxFileList[i].absolutePath); pbxFileList.RemoveAt(i--); dirty = true; continue; } if (pbxFileList[i] != null) { Undo.RecordObject(pbxFileList[i], "Xcode File Import"); } if (!pbxFileList[i].group.Equals(currentGroup)) { BBGuiHelper.EndIndent(); EditorGUILayout.LabelField(pbxFileList[i].group); currentGroup = pbxFileList[i].group; BBGuiHelper.BeginIndent(); } pbxFileList[i].OnGUI(); if (pbxFileList[i].edited) { dirty = true; } } BBGuiHelper.EndIndent(); } BBGuiHelper.EndIndent(); } #endregion EditorGUILayout.Space(); #region HeaderPaths displayHeaderPaths = EditorGUILayout.Foldout(displayHeaderPaths, "Header Search Paths: (" + headerSearchPaths.Count + ")"); if (displayHeaderPaths) { BBGuiHelper.BeginIndent(); { EditorGUI.BeginChangeCheck(); for (int i = 0; i < headerSearchPaths.Count; i++) { headerSearchPaths[i] = EditorGUILayout.TextField(headerSearchPaths[i]); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set")) { headerSearchPaths[i] = EditorUtility.OpenFolderPanel("Set Header Search Path", Application.dataPath + "/..", ""); headerSearchPaths[i] = MakePathRelative(headerSearchPaths[i]); } if (GUILayout.Button("Remove")) { headerSearchPaths.RemoveAt(i--); } EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { dirty = true; } } BBGuiHelper.EndIndent(); } #endregion EditorGUILayout.Space(); #region LibraryPaths displayLibraryPaths = EditorGUILayout.Foldout(displayLibraryPaths, "Library Search Paths: (" + librarySearchPaths.Count + ")"); if (displayLibraryPaths) { BBGuiHelper.BeginIndent(); { EditorGUI.BeginChangeCheck(); for (int i = 0; i < librarySearchPaths.Count; i++) { librarySearchPaths[i] = EditorGUILayout.TextField(librarySearchPaths[i]); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Set")) { librarySearchPaths[i] = EditorUtility.OpenFolderPanel("Set Library Search Path", Application.dataPath + "/..", ""); librarySearchPaths[i] = MakePathRelative(librarySearchPaths[i]); } if (GUILayout.Button("Remove")) { librarySearchPaths.RemoveAt(i--); } EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { dirty = true; } } BBGuiHelper.EndIndent(); } #endregion EditorGUILayout.Space(); #region plistEditor displayPlistEditor = EditorGUILayout.Foldout(displayPlistEditor, "Info.plist Editor: (" + pListEntryList.Count + ")"); if (displayPlistEditor) { for (int i = 0; i < pListEntryList.Count; i++) { if (pListEntryList[i] != null) { Undo.RecordObject(pListEntryList[i], "Plist Entry"); } pListEntryList[i].OnGUI(); if (pListEntryList[i].edited) { dirty = true; } if (pListEntryList[i].removed) { pListEntryList.RemoveAt(i--); dirty = true; } } } #endregion EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { if (dirty) { GUI.color = Color.green; } else { GUI.color = Color.gray; } if (GUILayout.Button("Apply Changes")) { ApplyChanges(); } if (dirty) { GUI.color = Color.red; } else { GUI.color = Color.gray; } if (GUILayout.Button("Cancel Changes")) { Initialize(); } } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; }
public void OnGUI() { if (removed) { return; } EditorGUILayout.BeginVertical(GUI.skin.box); EditorGUILayout.BeginHorizontal(); { display = EditorGUILayout.Foldout(display, "Plist Entry: " + (isArrayEntry ? "Array Entry " + arrayIndex : key)); if (GUILayout.Button("Remove")) { removed = true; } } EditorGUILayout.EndHorizontal(); if (!display) { EditorGUILayout.EndVertical(); return; } EditorGUI.BeginChangeCheck(); BBGuiHelper.BeginIndent(); { if (isArrayEntry) { EditorGUILayout.LabelField("Key: Array Entry " + arrayIndex); } else { key = EditorGUILayout.TextField("Key:", key); } entryType = (EntryTypes)EditorGUILayout.EnumPopup("Type:", entryType); if (entryType == EntryTypes.DICTIONARY || entryType == EntryTypes.ARRAY) { if (EditorGUI.EndChangeCheck()) { edited = true; } BBGuiHelper.BeginIndent(); for (int i = 0; i < valueEntries.Count; i++) { if (valueEntries[i].removed) { valueEntries.RemoveAt(i--); continue; } BBGuiHelper.BeginIndent(); valueEntries[i].arrayIndex = (entryType == EntryTypes.ARRAY ? i : -1); Undo.RecordObject(valueEntries[i], "Plist Entry"); valueEntries[i].OnGUI(); BBGuiHelper.EndIndent(); } BBGuiHelper.EndIndent(); EditorGUI.BeginChangeCheck(); } switch (entryType) { case EntryTypes.STRING: valueString = EditorGUILayout.TextField("Value:", valueString); break; case EntryTypes.BOOL: valueBool = EditorGUILayout.Toggle("Value:", valueBool); break; case EntryTypes.NUMBER: valueNumber = EditorGUILayout.FloatField("Value:", valueNumber); break; case EntryTypes.DATA: valueData = EditorGUILayout.TextField("Value:", valueData); break; case EntryTypes.DATE: valueDate = EditorGUILayout.TextField("Value:", valueDate); break; default: BBGuiHelper.BeginIndent(); if (GUILayout.Button("New Plist Entry")) { valueEntries.Add(PlistEntry.CreateInstance()); } BBGuiHelper.EndIndent(); break; } } BBGuiHelper.EndIndent(); if (EditorGUI.EndChangeCheck()) { edited = true; } EditorGUILayout.EndVertical(); }