public static XcodeSerializer CreateInstance(string xml, bool isTemplate) { XcodeSerializer serializer = ScriptableObject.CreateInstance <XcodeSerializer> (); serializer.document = new XmlDocument(); serializer.document.LoadXml(xml); serializer.Initialize(); serializer.isTemplate = isTemplate; return(serializer); }
public static void SaveExistingTemplate(XcodeSerializer template) { int index = elements.IndexOf(template); if (index == -1) { return; } EditorPrefs.SetString(keyPrefix + index, template.ToString()); }
public static void DeleteTemplate(XcodeSerializer element) { int index = elements.IndexOf(element); elements.RemoveAt(index); for (int i = index; i < elements.Count; i++) { EditorPrefs.SetString(keyPrefix + i, elements[i].ToString()); } EditorPrefs.DeleteKey(keyPrefix + elements.Count); }
public static XcodeSerializer ReloadTemplate(int i) { string savedPref = EditorPrefs.GetString(keyPrefix + i); string name = savedPref.Substring(0, savedPref.IndexOf('<'));; string xml = savedPref.Substring(savedPref.IndexOf('<')); elements[i] = XcodeSerializer.CreateInstance(xml, true); elements[i].name = name; elements[i].isTemplate = true; return(elements [i]); }
public XcodeProject(string path) { projectPath = path; XcodeSerializer serializer = XcodeSerializer.CreateInstance(); fileReferences = new List<PBXFile> (serializer.LoadPBXFiles()); linkerFlags = serializer.LoadLinkerFlags (); plistEntries = serializer.LoadPListEntries (); headerPaths = serializer.LoadHeaderSearchPaths (); for (int i = 0; i < headerPaths.Count; i++) { headerPaths[i] = serializer.BuildAbsolutePath(headerPaths[i]); } libraryPaths = serializer.LoadLibrarySearchPaths (); for (int i = 0; i < libraryPaths.Count; i++) { libraryPaths[i] = serializer.BuildAbsolutePath(libraryPaths[i]); } }
public static List <XcodeSerializer> GetTemplates() { elements = new List <XcodeSerializer> (); int i = 0; while (EditorPrefs.HasKey(keyPrefix + i)) { string savedPref = EditorPrefs.GetString(keyPrefix + i); string name = savedPref.Substring(0, savedPref.IndexOf('<'));; string xml = savedPref.Substring(savedPref.IndexOf('<')); elements.Add(XcodeSerializer.CreateInstance(xml, true)); elements[i].name = name; elements[i].isTemplate = true; i++; } return(elements); }
public static XcodeSerializer CreateInstance() { XcodeSerializer serializer = ScriptableObject.CreateInstance <XcodeSerializer> (); serializer.document = new XmlDocument(); serializer.FindPath(); if (File.Exists(serializer.path)) { serializer.document.Load(serializer.path); } else { serializer.document.LoadXml(serializer.emptyImportInfo); serializer.document.Save(serializer.path); } serializer.Initialize(); return(serializer); }
void OnGUI() { if (serializer == null) { OnEnable(); } scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { serializer.OnGUI(); EditorGUILayout.Space(); templateName = EditorGUILayout.TextField("Template name: ", templateName); if (GUILayout.Button("Save as Template")) { XcodeSerializer templateSerializer = XcodeSerializer.CreateInstance(serializer.ToString(), true); templateSerializer.name = templateName; XcodeTemplateManager.SaveTemplate(templateSerializer); } EditorGUILayout.Space(); for (int i = 0; i < templates.Count; i++) { EditorGUILayout.BeginHorizontal(); { templates[i].display = EditorGUILayout.Foldout(templates[i].display, templates[i].name); if (GUILayout.Button("Import", GUILayout.Width(50))) { serializer.Merge(templates[i]); } if (GUILayout.Button("Delete", GUILayout.Width(50))) { XcodeTemplateManager.DeleteTemplate(templates[i--]); continue; } } EditorGUILayout.EndHorizontal(); BBGuiHelper.BeginIndent(); { if (templates[i].display) { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Name: ", GUILayout.Width(75)); templates[i].name = EditorGUILayout.TextField(templates[i].name); } EditorGUILayout.EndHorizontal(); templates[i].OnGUI(); } } BBGuiHelper.EndIndent(); } } EditorGUILayout.EndScrollView(); //Repaint on Undo if (Event.current.type == EventType.ValidateCommand) { switch (Event.current.commandName) { case "UndoRedoPerformed": this.Repaint(); break; } } }
void OnEnable() { serializer = XcodeSerializer.CreateInstance(); templates = XcodeTemplateManager.GetTemplates(); }
public void Merge(XcodeSerializer serializer) { for (int i = 0; i < serializer.pbxFileList.Count; i++) { pbxFileList.Add(serializer.pbxFileList [i].Clone()); } for (int i = 0; i < serializer.pbxSdkFileList.Count; i++) { pbxSdkFileList.Add(serializer.pbxSdkFileList [i].Clone()); } for (int i = 0; i < serializer.pListEntryList.Count; i++) { for (int j = 0; j < pListEntryList.Count; i++) { if (pListEntryList[j].key.Equals(serializer.pListEntryList[i].key)) { pListEntryList.RemoveAt(j); Debug.Log("Using templated copy of plist entry " + serializer.pListEntryList[i].key); } } pListEntryList.Add(serializer.pListEntryList [i].Clone()); } headerSearchPaths.AddRange(serializer.headerSearchPaths); librarySearchPaths.AddRange(serializer.librarySearchPaths); foreach (string s in serializer.pbxFilePathSet) { pbxFilePathSet.Add(s); } pbxFileList.Sort(); for (int i = 1; i < pbxFileList.Count; i++) { if (pbxFileList[i].absolutePath.Equals(pbxFileList[i - 1].absolutePath)) { pbxFileList.RemoveAt(i--); } } pbxSdkFileList.Sort(); for (int i = 1; i < pbxSdkFileList.Count; i++) { if (pbxSdkFileList[i].absolutePath.Equals(pbxSdkFileList[i - 1].absolutePath)) { pbxSdkFileList.RemoveAt(i--); } } headerSearchPaths.Sort(); for (int i = 1; i < headerSearchPaths.Count; i++) { if (headerSearchPaths[i].Equals(headerSearchPaths[i - 1])) { headerSearchPaths.RemoveAt(i--); } } librarySearchPaths.Sort(); for (int i = 1; i < librarySearchPaths.Count; i++) { if (librarySearchPaths[i].Equals(librarySearchPaths[i - 1])) { librarySearchPaths.RemoveAt(i--); } } linkerFlags += (" " + serializer.linkerFlags); List <string> flagsList = linkerFlags.Split(new string[] { " -" }, StringSplitOptions.None).ToList(); flagsList.Sort(); linkerFlags = flagsList.Count > 0 ? flagsList [0] : ""; for (int i = 1; i < flagsList.Count; i++) { if (flagsList[i].Equals(flagsList[i - 1])) { flagsList.RemoveAt(i--); } else { linkerFlags += (" -" + flagsList[i]); } } dirty = true; }
public static void SaveTemplate(XcodeSerializer data) { elements.Add(data); EditorPrefs.SetString(keyPrefix + (elements.Count - 1), data.ToString()); }