コード例 #1
0
        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);
        }
コード例 #2
0
        public static void SaveExistingTemplate(XcodeSerializer template)
        {
            int index = elements.IndexOf(template);

            if (index == -1)
            {
                return;
            }
            EditorPrefs.SetString(keyPrefix + index, template.ToString());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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]);
        }
コード例 #5
0
		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]);
			}
		}
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 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;
         }
     }
 }
コード例 #9
0
 void OnEnable()
 {
     serializer = XcodeSerializer.CreateInstance();
     templates  = XcodeTemplateManager.GetTemplates();
 }
コード例 #10
0
        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;
        }
コード例 #11
0
 public static void SaveTemplate(XcodeSerializer data)
 {
     elements.Add(data);
     EditorPrefs.SetString(keyPrefix + (elements.Count - 1), data.ToString());
 }