示例#1
0
 private static void CheckForUnsavedSettings(IBuildInfoController buildInfoController,
                                             IBuildVariantsController buildVariantsController, IProjectSettingsController projectSettingsController)
 {
     if (projectSettingsController.GetDiffWithActualSettings(buildVariantsController.BuildVariants.First(v =>
                                                                                                         v.Guid == buildInfoController.BuildInfo.ActiveVariantGuid)).Any())
     {
         throw new Exception("Active variant has unsaved settings!");
     }
 }
示例#2
0
        private void DrawSettings(IBuildVariant inspectedBuildVariant, SettingsCategory category)
        {
            string categoryName;
            Action revertAction = null;
            Action saveAction   = null;
            IEnumerable <IProjectSettingsFile> settingsFiles;

            EditorGUILayout.BeginHorizontal();
            if (category == SettingsCategory.ActualSettingsDiff || category == SettingsCategory.ActualRevertableSettingsDiff)
            {
                categoryName  = "Actual project settings diff";
                settingsFiles = _projectSettingsController.GetDiffWithActualSettings(inspectedBuildVariant);
                saveAction    = () => {
                    inspectedBuildVariant.Merge(settingsFiles);
                    _projectSettingsController.InvalidateDiffCache();
                };
                if (category == SettingsCategory.ActualRevertableSettingsDiff)
                {
                    revertAction = () => _projectSettingsController.BuildAndApplyProjectSettings(inspectedBuildVariant);
                }
            }
            else if (category == SettingsCategory.VariantDiff)
            {
                categoryName  = "Variant settings";
                settingsFiles = inspectedBuildVariant.SettingsFileDiffs;
                revertAction  = () => {
                    var currentDiff = _projectSettingsController.GetDiffWithActualSettings(inspectedBuildVariant).ToList();
                    inspectedBuildVariant.Revert();
                    _projectSettingsController.BuildAndApplyProjectSettings(inspectedBuildVariant, currentDiff);
                };
            }
            else
            {
                throw new ArgumentOutOfRangeException("category", category, null);
            }

            var expanded             = inspectedBuildVariant.IsFieldExpanded(category.ToString());
            var projectSettingsFiles = settingsFiles as IProjectSettingsFile[] ?? settingsFiles.ToArray();

            expanded = EditorGUILayout.Foldout(expanded, string.Format("{0} ({1})", categoryName, projectSettingsFiles.Length));
            inspectedBuildVariant.SetFieldExpanded(category.ToString(), expanded);

            GUI.enabled = projectSettingsFiles.Length > 0;
            DrawSaveRevert(revertAction, saveAction);
            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();

            if (!expanded)
            {
                return;
            }

            foreach (var settingsFileDiff in projectSettingsFiles)
            {
                var mappingNode = settingsFileDiff.RootNode as YamlMappingNode;
                if (mappingNode != null)
                {
                    foreach (var keyValue in mappingNode.Children)
                    {
                        DrawNode(inspectedBuildVariant, settingsFileDiff, category, keyValue.Value, keyValue.Key);
                    }
                }
                else
                {
                    DrawNode(inspectedBuildVariant, settingsFileDiff, category, settingsFileDiff.RootNode);
                }
            }
        }