private void OnTablesGUI() { var settings = activeSettings.ActiveSettings; if (settings == null) { return; } if (!stylesLoaded) { LoadStyles(); } if (tableQueryChanged) { UpdateTableFilter(); tableQueryChanged = false; } GUILayout.BeginVertical(style_containerNoMarginTop); tableSearchScroll = GUILayout.BeginScrollView(tableSearchScroll, filteredTables.Count * 40 >= 200 ? new[] { GUILayout.MaxHeight(200), GUILayout.MinHeight(0) } : new GUILayoutOption[0]); selectedTable = GUILayoutExtras.Selection(selectedTable, filteredTables, (val, isSelected, index) => { var back = GUI.backgroundColor; GUI.backgroundColor = index % 2 == 0 ? new Color(0.8f, 0.8f, 0.8f) : Color.white; GUI.enabled = !isSelected; var clicked = GUILayout.Button("", style_localeSelectionEntryButton, GUILayout.MinHeight(40)); var lastRect = GUILayoutUtility.GetLastRect(); GUI.enabled = true; GUI.Label(lastRect, $"{val.TableName}", style_localeSelectionEntryLabel); GUI.backgroundColor = back; return(clicked); }); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(style_containerNoMarginTop); if (GUILayout.Button("Open Table Editor", GUILayout.Height(30))) { TableEditorWindow.Display(settings); } if (selectedTable == null) { GUI.enabled = false; } if (GUILayout.Button("Remove Selected", GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("Confirm table removal", "This action cannot be undone. Are you sure you want to delete the table?", "Yes", "No")) { settings.RemoveTable(selectedTable); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(selectedTable)); Utils.SaveChanges(); selectedTable = null; Utils.DirtyTables(settings); } } GUI.enabled = true; GUILayout.EndHorizontal(); }
private void OnLocalesGUI() { var settings = activeSettings.ActiveSettings; if (settings == null) { return; } if (!stylesLoaded) { LoadStyles(); } if (localeQueryChanged) { UpdateFilter(); localeQueryChanged = false; } GUILayout.BeginVertical(style_containerNoMarginTop); localeSearchScroll = GUILayout.BeginScrollView(localeSearchScroll, filteredLocales.Count * 40 >= 200 ? new[] { GUILayout.MaxHeight(200), GUILayout.MinHeight(0) } : new GUILayoutOption[0]); selectedLocale = GUILayoutExtras.Selection(selectedLocale, filteredLocales, (val, isSelected, index) => { var back = GUI.backgroundColor; GUI.backgroundColor = index % 2 == 0 ? new Color(0.8f, 0.8f, 0.8f) : Color.white; GUI.enabled = !isSelected; var clicked = GUILayout.Button("", style_localeSelectionEntryButton, GUILayout.MinHeight(40)); var lastRect = GUILayoutUtility.GetLastRect(); GUI.enabled = true; GUI.Label(lastRect, $"{val.EnglishName} ({val.NativeName}){(val.Equals(settings.DefaultLocale) ? " - <b>Default</b>" : "")}", style_localeSelectionEntryLabel); GUI.backgroundColor = back; return(clicked); }); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginHorizontal(style_containerNoMarginTop); if (GUILayout.Button("Add Locale", GUILayout.Height(30))) { AddLocaleWindow.Display(this, activeSettings.ActiveSettings); } if (selectedLocale == null || settings.DefaultLocale.Equals(selectedLocale)) { GUI.enabled = false; } if (GUILayout.Button("Remove Selected", GUILayout.Height(30))) { Utils.RecordChange(settings, "Removed locale"); settings.RemoveLocale(selectedLocale); Utils.SaveChanges(); selectedLocale = null; Utils.DirtyLocales(settings); } if (GUILayout.Button("Make Selected Default", GUILayout.Height(30))) { Utils.RecordChange(settings, "Set default locale"); settings.SetDefaultLocale(selectedLocale); Utils.SaveChanges(); UpdateDefaultLocaleLabel(); Utils.DirtyLocales(settings); } GUI.enabled = true; GUILayout.EndHorizontal(); }