Exemplo n.º 1
0
        public List <PBXFile> LoadPBXFiles()
        {
            pbxFileList.Clear();
            pbxSdkFileList.Clear();
            foreach (XmlElement file in document.GetElementsByTagName("pbxfile"))
            {
                string filePath = file.Attributes["path"].Value;
                if (filePath.Equals(FRAMEWORK_PATH_TOKEN))
                {
                    pbxSdkFileList.Add(PbxSdkFile.CreateInstance(file));
                    continue;
                }
                pbxFileList.Add(PBXFile.CreateInstance(file));
            }
            List <PBXFile> allFiles = new List <PBXFile>(pbxFileList);

            allFiles.AddRange(pbxSdkFileList);
            return(allFiles);
        }
Exemplo n.º 2
0
        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;
        }