Пример #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(_items.Count, ImGui.GetTextLineHeightWithSpacing());
            var clipper    = new ImGuiListClipperPtr(clipperPtr);

            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
        public unsafe void Draw()
        {
            if (Core.Scene.Entities.Count > MIN_ENTITIES_FOR_CLIPPER)
            {
                ImGuiListClipper *  clipperPtr = ImGuiNative.ImGuiListClipper_ImGuiListClipper(Core.Scene.Entities.Count, -1);
                ImGuiListClipperPtr clipper    = new ImGuiListClipperPtr(clipperPtr);

                while (clipper.Step())
                {
                    for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
                    {
                        DrawEntity(Core.Scene.Entities[i]);
                    }
                }

                ImGuiNative.ImGuiListClipper_destroy(clipperPtr);
            }
            else
            {
                for (int i = 0; i < Core.Scene.Entities.Count; i++)
                {
                    DrawEntity(Core.Scene.Entities[i]);
                }
            }

            NezImGui.MediumVerticalSpace();
            if (NezImGui.CenteredButton("Create Entity", 0.6f))
            {
                ImGui.OpenPopup("create-entity");
            }

            DrawCreateEntityPopup();
        }
Пример #3
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();
                        }