mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-14 12:44:19 +01:00
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using System.Numerics;
|
|
using ImGuiNET;
|
|
using OtterGui.Raii;
|
|
using OtterGui.Widgets;
|
|
using Penumbra.Collections;
|
|
using Penumbra.Meta.Manipulations;
|
|
using Penumbra.Mods;
|
|
using Penumbra.String.Classes;
|
|
using Penumbra.UI.Classes;
|
|
|
|
namespace Penumbra.UI.ModsTab;
|
|
|
|
public class ModPanelConflictsTab : ITab
|
|
{
|
|
private readonly ModFileSystemSelector _selector;
|
|
private readonly ModCollection.Manager _collectionManager;
|
|
|
|
public ModPanelConflictsTab(ModCollection.Manager collectionManager, ModFileSystemSelector selector)
|
|
{
|
|
_collectionManager = collectionManager;
|
|
_selector = selector;
|
|
}
|
|
|
|
public ReadOnlySpan<byte> Label
|
|
=> "Conflicts"u8;
|
|
|
|
public bool IsVisible
|
|
=> _collectionManager.Current.Conflicts(_selector.Selected!).Count > 0;
|
|
|
|
public void DrawContent()
|
|
{
|
|
using var box = ImRaii.ListBox("##conflicts", -Vector2.One);
|
|
if (!box)
|
|
return;
|
|
|
|
// Can not be null because otherwise the tab bar is never drawn.
|
|
var mod = _selector.Selected!;
|
|
foreach (var conflict in Penumbra.CollectionManager.Current.Conflicts(mod))
|
|
{
|
|
if (ImGui.Selectable(conflict.Mod2.Name) && conflict.Mod2 is Mod otherMod)
|
|
_selector.SelectByValue(otherMod);
|
|
|
|
ImGui.SameLine();
|
|
using (var color = ImRaii.PushColor(ImGuiCol.Text,
|
|
conflict.HasPriority ? ColorId.HandledConflictMod.Value(Penumbra.Config) : ColorId.ConflictingMod.Value(Penumbra.Config)))
|
|
{
|
|
var priority = conflict.Mod2.Index < 0
|
|
? conflict.Mod2.Priority
|
|
: _collectionManager.Current[conflict.Mod2.Index].Settings!.Priority;
|
|
ImGui.TextUnformatted($"(Priority {priority})");
|
|
}
|
|
|
|
using var indent = ImRaii.PushIndent(30f);
|
|
foreach (var data in conflict.Conflicts)
|
|
{
|
|
unsafe
|
|
{
|
|
var _ = data switch
|
|
{
|
|
Utf8GamePath p => ImGuiNative.igSelectable_Bool(p.Path.Path, 0, ImGuiSelectableFlags.None, Vector2.Zero) > 0,
|
|
MetaManipulation m => ImGui.Selectable(m.Manipulation?.ToString() ?? string.Empty),
|
|
_ => false,
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|