public void OnGUI(UnityModManager.ModEntry modEntry) { if (Mod == null || !Mod.Enabled) { return; } if (_buttonStyle == null) { _buttonStyle = new GUIStyle(GUI.skin.button) { alignment = TextAnchor.MiddleLeft } } ; try { // blueprint type { // refresh blueprint types if (_bpTypeNames == null) { if (GetBlueprints() == null) { GUILayout.Label("Blueprints".Orange().Bold() + " loading: " + BlueprintLoader.Shared.progress.ToString("P2").Cyan().Bold()); return; } RefreshTypeNames(); RefreshBPSearchData(); } using (new GUILayout.HorizontalScope()) { bool isDirty = false; // Blueprint Picker using (new GUILayout.VerticalScope()) { // Header and Search Field bool blueprintListIsDirty = false; GUIHelper.Div(); using (new GUILayout.HorizontalScope(GUILayout.Width(450))) { // Header and Search Field GUILayout.Label($"{_bpTypeNames[_bpTypeIndex]}".Cyan(), GUILayout.Width(300)); GUILayout.Space(10); GUIHelper.TextField(ref _selectionSearchText, () => blueprintListIsDirty = true, null, GUILayout.MinWidth(150)); } if (blueprintListIsDirty) { RefreshTypeNames(); } GUIHelper.Div(); // Blueprint Picker List if (_bpsExpanded.IsOn()) { using (var scrollView = new GUILayout.ScrollViewScope(_bpsScrollPosition, GUILayout.Width(450))) { _bpsScrollPosition = scrollView.scrollPosition; GUIHelper.SelectionGrid(ref _bpTypeIndex, _bpTypeNames, 1, () => { _searchText = null; RefreshBPSearchData(); _filteredBPs = _bpTypeIndex == 0 ? GetBlueprints() : GetBlueprints().Where(item => item.GetType() == _bpTypes[_bpTypeIndex]).ToList(); ; _treeView.SetRoot(_filteredBPs); }, _buttonStyle, GUILayout.Width(450)); // cache width if (Event.current.type == EventType.Repaint) { _bpsWidth = GUILayoutUtility.GetLastRect().width + 65f; } } //} } } using (new GUILayout.VerticalScope(GUI.skin.box)) { // Data Search Bar GUIHelper.Div(); if (_bpChildNames.Length > 0) { using (new GUILayout.HorizontalScope()) { // search bar GUILayout.Space(10f); // slelection - button using (new GUILayout.HorizontalScope()) { UI.ToggleButton(ref _searchExpanded, $"Search: {_bpChildNames[_searchIndex]}", _buttonStyle, GUILayout.ExpandWidth(false)); // _searchText input GUILayout.Space(10); GUIHelper.TextField(ref _searchText, () => isDirty = true, null, GUILayout.Width(450)); GUILayout.Space(10f); if (GUIHelper.Checkbox(ref _searchReversed, "By Excluding", _buttonStyle, GUILayout.ExpandWidth(false))) { isDirty = true; } if (_searchExpanded.IsOn()) { GUILayout.Space(10f); } } } } // Data Search Field Picker if (_searchExpanded.IsOn()) { // selection GUIHelper.Div(); var availableWidth = Main.ummWidth - 550; int xCols = (int)Math.Ceiling(availableWidth / 300); GUIHelper.SelectionGrid(ref _searchIndex, _bpChildNames, xCols, () => isDirty = true, _buttonStyle, GUILayout.Width(availableWidth)); // cache width if (Event.current.type == EventType.Repaint) { _searchWidth = GUILayoutUtility.GetLastRect().width + 65f; } } // Do the search if (isDirty) { UpdateSearchResults(); } GUIHelper.Div(); // tree view using (new GUILayout.VerticalScope()) { _treeView.OnGUI(true, false); } } } } } catch (Exception e) { _bpTypeIndex = 0; // _treeView.Clear(); modEntry.Logger.Error(e.StackTrace); throw e; } } }