예제 #1
0
        // Draw the effective tab if ShowAdvanced is on.
        public void Draw()
        {
            if (!Penumbra.Config.ShowAdvanced)
            {
                return;
            }

            using var tab = ImRaii.TabItem("Effective Changes");
            if (!tab)
            {
                return;
            }

            SetupEffectiveSizes();
            DrawFilters();
            using var child = ImRaii.Child("##EffectiveChangesTab", -Vector2.One, false);
            if (!child)
            {
                return;
            }

            var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
            var skips  = ImGuiClip.GetNecessarySkips(height);

            using var table = ImRaii.Table("##EffectiveChangesTable", 3, ImGuiTableFlags.RowBg);
            if (!table)
            {
                return;
            }

            ImGui.TableSetupColumn("##gamePath", ImGuiTableColumnFlags.WidthFixed, _effectiveLeftTextLength);
            ImGui.TableSetupColumn(string.Empty, ImGuiTableColumnFlags.WidthFixed, _effectiveArrowLength);
            ImGui.TableSetupColumn("##file", ImGuiTableColumnFlags.WidthFixed, _effectiveRightTextLength);

            DrawEffectiveRows(Penumbra.CollectionManager.Current, skips, height,
                              _effectiveFilePathFilter.Length > 0 || _effectiveGamePathFilter.Length > 0);
        }
    // Draw a simple clipped table containing all changed items.
    private void DrawChangedItemTab()
    {
        // Functions in here for less pollution.
        bool FilterChangedItem(KeyValuePair <string, (SingleArray <IMod>, object?)> item)
        => (_changedItemFilter.IsEmpty ||
            ChangedItemName(item.Key, item.Value.Item2)
            .Contains(_changedItemFilter.Lower, StringComparison.InvariantCultureIgnoreCase)) &&
        (_changedItemModFilter.IsEmpty || item.Value.Item1.Any(m => m.Name.Contains(_changedItemModFilter)));

        void DrawChangedItemColumn(KeyValuePair <string, (SingleArray <IMod>, object?)> item)
        {
            ImGui.TableNextColumn();
            DrawChangedItem(item.Key, item.Value.Item2, false);
            ImGui.TableNextColumn();
            if (item.Value.Item1.Count > 0)
            {
                ImGui.TextUnformatted(item.Value.Item1[0].Name);
                if (item.Value.Item1.Count > 1)
                {
                    ImGuiUtil.HoverTooltip(string.Join("\n", item.Value.Item1.Skip(1).Select(m => m.Name)));
                }
            }

            ImGui.TableNextColumn();
            if (item.Value.Item2 is Item it)
            {
                using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.ItemId.Value());
                ImGuiUtil.RightAlign($"({( ( Quad )it.ModelMain ).A})");
            }
        }

        using var tab = ImRaii.TabItem("Changed Items");
        if (!tab)
        {
            return;
        }

        // Draw filters.
        var varWidth = ImGui.GetContentRegionAvail().X
                       - 400 * ImGuiHelpers.GlobalScale
                       - ImGui.GetStyle().ItemSpacing.X;

        ImGui.SetNextItemWidth(400 * ImGuiHelpers.GlobalScale);
        LowerString.InputWithHint("##changedItemsFilter", "Filter Item...", ref _changedItemFilter, 128);
        ImGui.SameLine();
        ImGui.SetNextItemWidth(varWidth);
        LowerString.InputWithHint("##changedItemsModFilter", "Filter Mods...", ref _changedItemModFilter, 128);

        using var child = ImRaii.Child("##changedItemsChild", -Vector2.One);
        if (!child)
        {
            return;
        }

        // Draw table of changed items.
        var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
        var skips  = ImGuiClip.GetNecessarySkips(height);

        using var list = ImRaii.Table("##changedItems", 3, ImGuiTableFlags.RowBg, -Vector2.One);
        if (!list)
        {
            return;
        }

        const ImGuiTableColumnFlags flags = ImGuiTableColumnFlags.NoResize | ImGuiTableColumnFlags.WidthFixed;

        ImGui.TableSetupColumn("items", flags, 400 * ImGuiHelpers.GlobalScale);
        ImGui.TableSetupColumn("mods", flags, varWidth - 100 * ImGuiHelpers.GlobalScale);
        ImGui.TableSetupColumn("id", flags, 100 * ImGuiHelpers.GlobalScale);

        var items = Penumbra.CollectionManager.Current.ChangedItems;
        var rest  = _changedItemFilter.IsEmpty && _changedItemModFilter.IsEmpty
            ? ImGuiClip.ClippedDraw(items, skips, DrawChangedItemColumn, items.Count)
            : ImGuiClip.FilteredClippedDraw(items, skips, FilterChangedItem, DrawChangedItemColumn);

        ImGuiClip.DrawEndDummy(rest, height);
    }