예제 #1
0
        protected override unsafe void DrawOverride(ref bool isGameViewFocused)
        {
            ImGui.PushItemWidth(-1);
            ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText);
            UpdateSearch(searchText);
            ImGui.PopItemWidth();

            ImGui.BeginChild("files list", ImGui.GetContentRegionAvail(), true);

            var clipperPtr = ImGuiNative.ImGuiListClipper_ImGuiListClipper();
            var clipper    = new ImGuiListClipperPtr(clipperPtr);

            clipper.Begin(_items.Count, ImGui.GetTextLineHeightWithSpacing());
            while (clipper.Step())
            {
                for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
                {
                    var item = _items[i];
                    var name = GetObjectName(item);
                    if (ImGui.Selectable(name, item == _currentItem))
                    {
                        _currentItem           = item;
                        Context.SelectedObject = item;
                    }
                    ImGuiUtility.DisplayTooltipOnHover(name);
                }
            }
            clipper.Destroy();

            ImGui.EndChild();
        }
예제 #2
0
        private void PlayerList()
        {
            ImGui.BeginChild(
                "###PlayerTrack_PlayerList_Child",
                new Vector2(205 * ImGuiHelpers.GlobalScale, 0),
                true);

            if (DateUtil.CurrentTime() > this.lastPlayerListRefresh)
            {
                this.players = this.plugin.PlayerService.GetSortedPlayers(this.searchInput);
                this.lastPlayerListRefresh += this.plugin.Configuration.PlayerListRefreshFrequency;
            }

            // use clipper to avoid performance hit on large player lists
            ImGuiListClipperPtr clipper;

            unsafe
            {
                clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
            }

            clipper.Begin(this.players.Length);
            while (clipper.Step())
            {
                for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
                {
                    ImGui.BeginGroup();
                    var color = this.plugin.PlayerService.GetPlayerListColor(this.players[i]);
                    ImGui.PushStyleColor(ImGuiCol.Text, color);
                    if (ImGui.Selectable(
                            "###PlayerTrack_Player_Selectable_" + i,
                            this.plugin.WindowManager.Panel !.SelectedPlayer == this.players[i],
                            ImGuiSelectableFlags.AllowDoubleClick))
                    {
                        // suppress double clicks
                        if (ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
                        {
                            // ignored
                        }

                        // hide right panel if clicking same user while already open
                        else if (this.plugin.WindowManager.Panel !.SelectedPlayer?.Key == this.players[i].Key && this.plugin.Configuration.CurrentView == View.PlayerDetail)
                        {
                            this.ClearSelectedPlayer();
                            this.plugin.WindowManager.Panel !.HidePanel();
                        }