Beispiel #1
0
        private void DrawDisplayListRecursive(int depth, DisplayItem item)
        {
            var treeNodeFlags = ImGuiTreeNodeFlags.DefaultOpen | ImGuiTreeNodeFlags.OpenOnDoubleClick;

            // workaround for Apt Editor
            var type = item.GetType();

            if (type.FullName == "OpenSage.Tools.AptEditor.Apt.WrappedDisplayItem")
            {
                item = (DisplayItem)type.GetProperty("Item").GetValue(item);
            }


            if (_currentClipDepth.HasValue && (depth > _currentClipDepth.Value))
            {
                _currentClipDepth = null;
            }

            if (item.ClipDepth.HasValue)
            {
                _currentClipDepth = item.ClipDepth;
            }

            if (!(item is SpriteItem))
            {
                treeNodeFlags = ImGuiTreeNodeFlags.Leaf;
            }

            if (item == _selectedItem)
            {
                treeNodeFlags |= ImGuiTreeNodeFlags.Selected;
            }

            if (item.ClipDepth.HasValue)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.5f, 1.0f, 0.5f, 1.0f));
            }
            else if (_currentClipDepth.HasValue)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0.5f, 0.5f, 0.5f, 1.0f));
            }

            bool hasRenderCallback = false;

            if (item is RenderItem renderItem && renderItem.RenderCallback != null)
            {
                hasRenderCallback = true;
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1.0f, 0.5f, 0.5f, 1.0f));
            }

            var opened = ImGui.TreeNodeEx($"[{depth}] {item.Name}", treeNodeFlags);

            if (hasRenderCallback)
            {
                ImGui.PopStyleColor();
            }

            if (_currentClipDepth.HasValue)
            {
                ImGui.PopStyleColor();
            }

            ImGuiUtility.DisplayTooltipOnHover("MovieClip: " + item.Character.Container.MovieName);

            if (ImGuiNative.igIsItemClicked(0) > 0)
            {
                SelectDisplayItem(item);
            }

            if (opened)
            {
                if (item is SpriteItem)
                {
                    var spriteItem = item as SpriteItem;
                    foreach (var pair in spriteItem.Content.Items)
                    {
                        DrawDisplayListRecursive(pair.Key, pair.Value);
                    }
                }

                ImGui.TreePop();
            }
        }