private void OnGUI() { lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; GUILayoutHelper.Vertical(() => { GUILayoutHelper.Area(new Rect(0, 0, 3 * position.width / 8, position.height), () => { EditorGUILayout.Space(); GUILayoutHelper.Horizontal(() => { GUILayout.Box((Texture2D)EditorGUIUtility.Load("Assets/Resources/AppIcon1.png"), GUILayout.Width(50), GUILayout.Height(50)); var titleStyle = new GUIStyle(EditorStyles.largeLabel); titleStyle.font = EditorGUIUtility.Load("Assets/Resources/Fonts/TESFonts/Kingthings Petrock.ttf") as Font; titleStyle.fontSize = 50; GUILayout.Label(modName, titleStyle); }); EditorGUILayout.Space(); GUILayoutHelper.Horizontal(() => { GUILayout.Label(localPath); if (IconButton("d_editicon.sml", "Select target path")) { if (!string.IsNullOrEmpty(targetPath = EditorUtility.OpenFolderPanel("Select mod folder", rootPath, "Mod"))) { Load(); } } if (IconButton("d_Refresh", "Reload and discharge unsaved changes")) { Load(); } using (new EditorGUI.DisabledScope(modName == "None" || duplicateSections || duplicateKeys)) if (IconButton("d_P4_CheckOutLocal", "Save settings to disk")) { Save(); } }); saveOnExit = EditorGUILayout.ToggleLeft(new GUIContent("Save on Exit", "Save automatically when window is closed."), saveOnExit); if (data == null) { EditorGUILayout.HelpBox("Select a folder to store settings.", MessageType.Info); return; } if (duplicateSections) { EditorGUILayout.HelpBox("Multiple sections with the same name detected!", MessageType.Error); } if (duplicateKeys) { EditorGUILayout.HelpBox("Multiple keys with the same name in a section detected!", MessageType.Error); } DrawHeader("Header"); EditorGUILayout.HelpBox("Version of settings checked against local values and presets.", MessageType.None); data.Version = EditorGUILayout.TextField("Version", data.Version); DrawHeader("Presets"); EditorGUILayout.HelpBox("Pre-defined values for all or a set of settings. Author is an optional field.", MessageType.None); presetsScrollPosition = GUILayoutHelper.ScrollView(presetsScrollPosition, () => presets.DoLayoutList()); EditorGUILayout.Space(); if (presets.index != -1) { var preset = data.Presets[presets.index]; preset.Author = EditorGUILayout.TextField("Author", preset.Author); EditorGUILayout.PrefixLabel("Description"); preset.Description = EditorGUILayout.TextArea(preset.Description); } GUILayout.FlexibleSpace(); DrawHeader("Tools"); if (GUILayout.Button("Import Legacy INI")) { string iniPath; if (!string.IsNullOrEmpty(iniPath = EditorUtility.OpenFilePanel("Select ini file", rootPath, "ini"))) { data.ImportLegacyIni(new IniParser.FileIniDataParser().ReadFile(iniPath)); } } else if (GUILayout.Button("Merge presets")) { string path; if (!string.IsNullOrEmpty(path = EditorUtility.OpenFilePanel("Select preset file", rootPath, "json"))) { data.LoadPresets(path, true); } } else if (GUILayout.Button("Export localization table")) { string path; if (!string.IsNullOrEmpty(path = EditorUtility.OpenFolderPanel("Select a folder", textPath, ""))) { MakeTextDatabase(Path.Combine(path, string.Format("mod_{0}.txt", modName))); } } EditorGUILayout.Space(); }); if (data == null) { return; } float areaWidth = 5 * position.width / 8; GUILayoutHelper.Area(new Rect(position.width - areaWidth, 0, areaWidth, position.height), () => { EditorGUILayout.Space(); if (data.Presets.Count > 0 && presets.index != -1) { if (GUILayout.SelectionGrid(IsPreset ? 1 : 0, new string[] { "Defaults", data.Presets[presets.index].Title }, 2) == 0) { if (IsPreset) { LoadPreset(-1); } } else { if (currentPreset != presets.index) { LoadPreset(presets.index); } } } mainScrollPosition = GUILayoutHelper.ScrollView(mainScrollPosition, () => { sections.DoLayoutList(); duplicateSections = duplicateKeys = false; var sectionNames = new List <string>(); foreach (var section in data.Sections) { section.Name = !string.IsNullOrEmpty(section.Name) ? section.Name.Replace(" ", string.Empty) : GetUniqueName(sectionNames, "Section"); sectionNames.Add(section.Name); var keyNames = new List <string>(); foreach (var key in section.Keys) { key.Name = !string.IsNullOrEmpty(key.Name) ? key.Name.Replace(" ", string.Empty) : GetUniqueName(keyNames, "Key"); keyNames.Add(key.Name); } duplicateKeys |= DuplicatesDetected(keyNames); this.keyNames.Add(keyNames); } this.sectionNames = sectionNames; duplicateSections |= DuplicatesDetected(sectionNames); }); GUILayout.FlexibleSpace(); EditorGUILayout.Space(); }); }); }