Ejemplo n.º 1
0
        public static IEnumerable OnGUI()
        {
            UI.ActionSelectionGrid(ref settings.selectedBPTypeFilter,
                                   blueprintTypeFilters.Select(tf => tf.name).ToArray(),
                                   10,
                                   (selected) => { UpdateSearchResults(); },
                                   UI.MinWidth(200));
            UI.Space(10);

            UI.BeginHorizontal();
            UI.ActionTextField(
                ref settings.searchText,
                "searhText",
                (text) => { },
                () => { UpdateSearchResults(); },
                UI.Width(400));
            UI.Label("Limit", UI.ExpandWidth(false));
            UI.ActionIntTextField(
                ref settings.searchLimit,
                "searchLimit",
                (limit) => { },
                () => { UpdateSearchResults(); },
                UI.Width(200));
            if (settings.searchLimit > 1000)
            {
                settings.searchLimit = 1000;
            }
            UI.Space(25);
            UI.Toggle("Show GUIs", ref settings.showAssetIDs);
            UI.Space(25);
            UI.Toggle("Dividers", ref settings.showDivisions);

            UI.EndHorizontal();
            UI.BeginHorizontal();
            UI.ActionButton("Search", () => {
                UpdateSearchResults();
            }, UI.AutoWidth());
            UI.Space(25);
            if (firstSearch)
            {
                UI.Label("please note the first search may take a few seconds.".green(), UI.AutoWidth());
            }
            else if (matchCount > 0)
            {
                String title = "Matches: ".green().bold() + $"{matchCount}".orange().bold();
                if (matchCount > settings.searchLimit)
                {
                    title += " => ".cyan() + $"{settings.searchLimit}".cyan().bold();
                }
                if (collatedBPs != null)
                {
                    foreach (var group in collatedBPs)
                    {
                        title += $" {group.Key} ({group.Count()})";
                    }
                }
                UI.Label(title, UI.ExpandWidth(false));
            }
            UI.Space(50);
            UI.Label("".green(), UI.AutoWidth());
            UI.EndHorizontal();
            UI.Space(10);

            if (filteredBPs != null)
            {
                CharacterPicker.OnGUI();
                UnitReference selected = CharacterPicker.GetSelectedCharacter();
                BlueprintListUI.OnGUI(selected, filteredBPs, collatedBPs, 0, null, selectedTypeFilter);
            }
            UI.Space(25);
            return(null);
        }
Ejemplo n.º 2
0
        public static IEnumerable OnGUI()
        {
            if (blueprints == null)
            {
                blueprints = BlueprintLoader.Shared.GetBlueprints();
                if (blueprints != null)
                {
                    UpdateSearchResults();
                }
            }
            // Stackable browser
            using (HorizontalScope(Width(350))) {
                var remainingWidth = ummWidth;
                // First column - Type Selection Grid
                using (VerticalScope(GUI.skin.box)) {
                    ActionSelectionGrid(ref settings.selectedBPTypeFilter,
                                        blueprintTypeFilters.Select(tf => tf.name).ToArray(),
                                        1,
                                        (selected) => { UpdateSearchResults(); },
                                        buttonStyle,
                                        Width(200));
                }
                remainingWidth -= 350;
                var collationChanged = false;
                if (collatedBPs != null)
                {
                    using (VerticalScope(GUI.skin.box)) {
                        var selectedKey = collationKeys.ElementAt(selectedCollationIndex);
                        if (VPicker("Categories", ref selectedKey, collationKeys, null, s => s, ref collationSearchText, Width(300)))
                        {
                            collationChanged = true; BlueprintListUI.needsLayout = true;
                        }
                        if (selectedKey != null)
                        {
                            selectedCollationIndex = collationKeys.IndexOf(selectedKey);
                        }

#if false
                        UI.ActionSelectionGrid(ref selectedCollationIndex, collationKeys.ToArray(),
                                               1,
                                               (selected) => { collationChanged = true; BlueprintListUI.needsLayout = true; },
                                               UI.buttonStyle,
                                               UI.Width(200));
#endif
                    }
                    remainingWidth -= 450;
                }

                // Section Column  - Main Area
                using (VerticalScope(MinWidth(remainingWidth))) {
                    // Search Field and modifiers
                    using (HorizontalScope()) {
                        ActionTextField(
                            ref settings.searchText,
                            "searhText",
                            (text) => { },
                            () => UpdateSearchResults(),
                            Width(400));
                        50.space();
                        Label("Limit", AutoWidth());
                        15.space();
                        ActionIntTextField(
                            ref settings.searchLimit,
                            "searchLimit",
                            (limit) => { },
                            () => UpdateSearchResults(),
                            Width(75));
                        if (settings.searchLimit > 1000)
                        {
                            settings.searchLimit = 1000;
                        }
                        25.space();
                        if (Toggle("Search Descriptions", ref settings.searchesDescriptions, AutoWidth()))
                        {
                            UpdateSearchResults();
                        }
                        25.space();
                        if (Toggle("Attributes", ref settings.showAttributes, AutoWidth()))
                        {
                            UpdateSearchResults();
                        }
                        25.space();
                        Toggle("Show GUIDs", ref settings.showAssetIDs, AutoWidth());
                        25.space();
                        Toggle("Components", ref settings.showComponents, AutoWidth());
                        25.space();
                        Toggle("Show Display & Internal Names", ref settings.showDisplayAndInternalNames, AutoWidth());
                    }
                    // Search Button and Results Summary
                    using (HorizontalScope()) {
                        ActionButton("Search", () => {
                            UpdateSearchResults();
                        }, AutoWidth());
                        Space(25);
                        if (firstSearch)
                        {
                            Label("please note the first search may take a few seconds.".green(), AutoWidth());
                        }
                        else if (matchCount > 0)
                        {
                            var title = "Matches: ".green().bold() + $"{matchCount}".orange().bold();
                            if (matchCount > settings.searchLimit)
                            {
                                title += " => ".cyan() + $"{settings.searchLimit}".cyan().bold();
                            }
                            Label(title, ExpandWidth(false));
                        }
                        Space(130);
                        Label($"Page: ".green() + $"{Math.Min(currentPage + 1, pageCount + 1)}".orange() + " / " + $"{pageCount + 1}".cyan(), AutoWidth());
                        ActionButton("-", () => {
                            currentPage = Math.Max(currentPage -= 1, 0);
                            UpdatePaginatedResults();
                        }, AutoWidth());
                        ActionButton("+", () => {
                            currentPage = Math.Min(currentPage += 1, pageCount);
                            UpdatePaginatedResults();
                        }, AutoWidth());
                        Space(25);
                        var pageNum = currentPage + 1;
                        if (Slider(ref pageNum, 1, pageCount + 1, 1))
                        {
                            UpdatePaginatedResults();
                        }
                        currentPage = pageNum - 1;
                    }
                    Space(10);

                    if (filteredBPs != null)
                    {
                        CharacterPicker.OnGUI();
                        UnitReference selected = CharacterPicker.GetSelectedCharacter();
                        var           bps      = filteredBPs;
                        if (selectedCollationIndex == 0)
                        {
                            selectedCollatedBPs = null;
                            matchCount          = uncolatedMatchCount;
                            UpdatePageCount();
                        }
                        if (selectedCollationIndex > 0)
                        {
                            if (collationChanged)
                            {
                                UpdateCollation();
                            }
                            bps = selectedCollatedBPs;
                        }
                        BlueprintListUI.OnGUI(selected, bps, 0, remainingWidth, null, selectedTypeFilter, (keys) => {
                            if (keys.Length > 0)
                            {
                                var changed = false;
                                //var bpTypeName = keys[0];
                                //var newTypeFilterIndex = blueprintTypeFilters.FindIndex(f => f.type.Name == bpTypeName);
                                //if (newTypeFilterIndex >= 0) {
                                //    settings.selectedBPTypeFilter = newTypeFilterIndex;
                                //    changed = true;
                                //}
                                if (keys.Length > 1)
                                {
                                    var collationKey      = keys[1];
                                    var newCollationIndex = collationKeys.FindIndex(ck => ck == collationKey);
                                    if (newCollationIndex >= 0)
                                    {
                                        selectedCollationIndex = newCollationIndex;
                                        UpdateCollation();
                                    }
                                }
                                if (changed)
                                {
                                    UpdateSearchResults();
                                }
                            }
                        }).ForEach(action => action());
                    }
                    Space(25);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public static IEnumerable OnGUI()
        {
            // Stackable browser
            using (UI.HorizontalScope(UI.Width(450))) {
                // First column - Type Selection Grid
                using (UI.VerticalScope(GUI.skin.box)) {
                    UI.ActionSelectionGrid(ref settings.selectedBPTypeFilter,
                                           blueprintTypeFilters.Select(tf => tf.name).ToArray(),
                                           1,
                                           (selected) => { UpdateSearchResults(); },
                                           UI.buttonStyle,
                                           UI.Width(200));
                }
                bool collationChanged = false;
                if (collatedBPs != null)
                {
                    using (UI.VerticalScope(GUI.skin.box)) {
                        UI.ActionSelectionGrid(ref selectedCollationIndex, collationKeys.ToArray(),
                                               1,
                                               (selected) => { collationChanged = true; BlueprintListUI.needsLayout = true; },
                                               UI.buttonStyle,
                                               UI.Width(200));
                    }
                }
                // Section Column  - Main Area
                float remainingWidth = Main.ummWidth - 325;
                using (UI.VerticalScope(UI.Width(remainingWidth))) {
                    // Search Field and modifiers
                    using (UI.HorizontalScope()) {
                        UI.ActionTextField(
                            ref settings.searchText,
                            "searhText",
                            (text) => { },
                            () => { UpdateSearchResults(); },
                            UI.Width(400));
                        UI.Label("Limit", UI.ExpandWidth(false));
                        UI.ActionIntTextField(
                            ref settings.searchLimit,
                            "searchLimit",
                            (limit) => { },
                            () => { UpdateSearchResults(); },
                            UI.Width(200));
                        if (settings.searchLimit > 1000)
                        {
                            settings.searchLimit = 1000;
                        }
                        UI.Space(25);
                        UI.Toggle("Show GUIDs", ref settings.showAssetIDs);
                        UI.Space(25);
                        UI.Toggle("Components", ref settings.showComponents);
                        UI.Space(25);
                        UI.Toggle("Elements", ref settings.showElements);
                        UI.Space(25);
                        UI.Toggle("Dividers", ref settings.showDivisions);
                    }
                    // Search Button and Results Summary
                    using (UI.HorizontalScope()) {
                        UI.ActionButton("Search", () => {
                            UpdateSearchResults();
                        }, UI.AutoWidth());
                        UI.Space(25);
                        if (firstSearch)
                        {
                            UI.Label("please note the first search may take a few seconds.".green(), UI.AutoWidth());
                        }
                        else if (matchCount > 0)
                        {
                            String title = "Matches: ".green().bold() + $"{matchCount}".orange().bold();
                            if (matchCount > settings.searchLimit)
                            {
                                title += " => ".cyan() + $"{settings.searchLimit}".cyan().bold();
                            }
                            UI.Label(title, UI.ExpandWidth(false));
                        }
                        UI.Space(50);
                        UI.Label($"".green(), UI.AutoWidth());
                    }
                    UI.Space(10);

                    if (filteredBPs != null)
                    {
                        CharacterPicker.OnGUI();
                        UnitReference selected = CharacterPicker.GetSelectedCharacter();
                        var           bps      = filteredBPs;
                        if (selectedCollationIndex == 0)
                        {
                            selectedCollatedBPs = null;
                        }
                        if (selectedCollationIndex > 0)
                        {
                            if (collationChanged)
                            {
                                var key = collationKeys.ElementAt(selectedCollationIndex);

                                var selectedKey = collationKeys.ElementAt(selectedCollationIndex);

                                foreach (var group in collatedBPs)
                                {
                                    if (group.Key == selectedKey)
                                    {
                                        selectedCollatedBPs = group.Take(settings.searchLimit).ToArray();
                                    }
                                }
                                BlueprintListUI.needsLayout = true;
                            }
                            bps = selectedCollatedBPs;
                        }
                        BlueprintListUI.OnGUI(selected, bps, 0, remainingWidth, null, selectedTypeFilter);
                    }
                    UI.Space(25);
                }
            }
            return(null);
        }