private static void InitializeWindow(TableEditorWindow window, StyleSheet utility = null, StyleSheet style = null) { utility ??= Resources.Load <StyleSheet>("Stylesheets/Utility"); style ??= Resources.Load <StyleSheet>("Stylesheets/TableEditorWindow"); try { window.AddStylesheet(utility); window.AddStylesheet(style); window.stylesheetsLoaded = true; } catch { window.deferStylesheetLoading = true; } }
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(); }