public AH_BuildReportWindowData(AH_SerializedBuildInfo buildInfo)
            {
                this.buildSize   = buildInfo.TotalSize;
                this.buildTarget = buildInfo.buildTargetInfo;
                this.buildDate   = buildInfo.dateTime;

                roleInfoList = new List <AH_BuildReportWindowRoleInfo>();
                foreach (var item in buildInfo.BuildReportInfoList)
                {
                    //Check if role exists already
                    if (roleInfoList.Exists(val => val.roleName.Equals(item.Role)))
                    {
                        roleInfoList.First(val => val.roleName.Equals(item.Role)).AddToRoleInfo(item);
                    }
                    //If not, add new roleentry
                    else
                    {
                        roleInfoList.Add(new AH_BuildReportWindowRoleInfo(item));
                    }
                }

                //Sort roles
                IEnumerable <AH_BuildReportWindowRoleInfo> tmp = roleInfoList.OrderByDescending(val => val.combinedRoleSize);

                roleInfoList = tmp.ToList();

                //Sort elements in roles
                foreach (var item in roleInfoList)
                {
                    item.Order();
                }
            }
Esempio n. 2
0
        internal static AH_SerializedBuildInfo LoadBuildReport(string path)
        {
            string fileContent = "";

            try
            {
                fileContent = System.IO.File.ReadAllText(path);
            }
            catch (System.IO.FileNotFoundException e)
            {
                EditorUtility.DisplayDialog(
                    "File Not Found",
                    "Unable to find:" + Environment.NewLine + path,
                    "Ok");

                Debug.LogError("AH: Unable to find: " + path + Environment.NewLine + e);

                return(null);
            }

            try
            {
                AH_SerializedBuildInfo buildInfo = JsonUtility.FromJson <AH_SerializedBuildInfo>(fileContent);
                buildInfo.Sort();
                return(buildInfo);
            }
            catch (Exception e)
            {
                Debug.LogError("AH: JSON Parse error of " + path + Environment.NewLine + "- " + e.ToString());
                return(null);
            }
        }
        internal void MergeWith(string fullName)
        {
            AH_SerializedBuildInfo newBuildInfo = AH_SerializationHelper.LoadBuildReport(fullName);

            if (newBuildInfo != null)
            {
                Debug.Log("AH: Merging with " + fullName);
                foreach (var newItem in newBuildInfo.AssetListUnSorted)
                {
                    //If asset ID already exists
                    if (AssetListUnSorted.Any(val => val.ID == newItem.ID))
                    {
                        AH_SerializableAssetInfo OrigItem = AssetListUnSorted.Find(val => val.ID == newItem.ID);
                        //Check if new scene ref list have entries that doesn't exist in orig
                        bool newSceneRefsExist = newItem.Refs.Any(val => !OrigItem.Refs.Contains(val));
                        //Get the new refs
                        if (newSceneRefsExist)
                        {
                            List <string> newSceneRefs = newItem.Refs.FindAll(val => !OrigItem.Refs.Contains(val));
                            //Add them to list
                            OrigItem.Refs.AddRange(newSceneRefs);
                        }
                    }
                    else
                    {
                        AssetListUnSorted.Add(newItem);
                    }
                }
            }
            else
            {
                Debug.Log("AH: Merging failed: " + fullName);
            }
        }
        internal void SelectBuildInfo(string filePath)
        {
            hasTreeviewSelection = false;
            chosenFilePath       = filePath;
            chosenBuildInfo      = AH_SerializationHelper.LoadBuildReport(filePath);

            if (chosenBuildInfo == null)
            {
                return;
            }


            //Make sure JSON is valid
            if (populateBuildReport())
            {
                hasTreeviewSelection = true;

                if (OnBuildInfoSelectionChanged != null)
                {
                    OnBuildInfoSelectionChanged();
                }
            }
            else
            {
                EditorUtility.DisplayDialog(
                    "JSON Parse error",
                    "The selected file could not be parsed",
                    "Ok");
            }
        }
Esempio n. 5
0
        private void OnGUI()
        {
            if (!m_window)
            {
                Init();
            }

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            Heureka_WindowStyler.DrawGlobalHeader(m_window, AH_EditorData.Instance.WindowHeaderIcon.Icon, Heureka_WindowStyler.clr_Dark, "BUILD INFO MERGER");
            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("Select a folder that contains buildinfo files", MessageType.Info);

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Change", GUILayout.ExpandWidth(false)))
            {
                buildInfoFolder = EditorUtility.OpenFolderPanel("Buildinfo folder", buildInfoFolder, "");
                updateBuildInfoFiles();
            }
            EditorGUILayout.LabelField("Current folder: " + buildInfoFolder);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //Show all used types
            EditorGUILayout.BeginVertical();

            foreach (var item in buildInfoFiles)
            {
                item.Selected = EditorGUILayout.ToggleLeft(item.BuildInfoFile.Name, item.Selected);
            }

            EditorGUILayout.Space();
            EditorGUI.BeginDisabledGroup(buildInfoFiles.Count(val => val.Selected == true) < 2);
            if (GUILayout.Button("Merge Selected", GUILayout.ExpandWidth(false)))
            {
                AH_SerializedBuildInfo merged = new AH_SerializedBuildInfo();
                foreach (var item in buildInfoFiles.FindAll(val => val.Selected))
                {
                    merged.MergeWith(item.BuildInfoFile.FullName);
                }
                merged.SaveAfterMerge();

                EditorUtility.DisplayDialog("Merge completed", "A new buildinfo was created by combined existing buildinfos", "Ok");
                //Reset
                buildInfoFiles.ForEach(val => val.Selected = false);
                updateBuildInfoFiles();
            }
            EditorGUI.EndDisabledGroup();
            //Make sure this window has focus to update contents
            Repaint();

            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
Esempio n. 6
0
        internal static void SerializeAndSave(AH_SerializedBuildInfo ahBuildInfo)
        {
            string buildinfoFileName = ahBuildInfo.buildTargetInfo + "_" + ahBuildInfo.dateTime + "." + BuildInfoExtension;
            string filePath          = GetBuildInfoFolder() + System.IO.Path.DirectorySeparatorChar + buildinfoFileName;

            System.IO.Directory.CreateDirectory(GetBuildInfoFolder());

            System.IO.File.WriteAllText(filePath, JsonUtility.ToJson(ahBuildInfo));
            if (AH_SettingsManager.Instance.AutoOpenLog)
            {
                EditorUtility.RevealInFinder(filePath);
            }

            if (NewBuildInfoCreated != null)
            {
                NewBuildInfoCreated(filePath);
            }
        }