mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 20:24:17 +01:00
Add new Mod Collections tab.
This commit is contained in:
parent
835020229c
commit
e9fc57022e
5 changed files with 126 additions and 10 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8ebcbf3e78ed498be35fa2b9a13d9765d109c428
|
Subproject commit 51c350b5f129b53afda3a51b057c228e152a6b88
|
||||||
|
|
@ -10,7 +10,6 @@ using Penumbra.Mods;
|
||||||
using Penumbra.UI.Classes;
|
using Penumbra.UI.Classes;
|
||||||
using Penumbra.UI.Tabs;
|
using Penumbra.UI.Tabs;
|
||||||
using Penumbra.Util;
|
using Penumbra.Util;
|
||||||
|
|
||||||
namespace Penumbra.UI;
|
namespace Penumbra.UI;
|
||||||
|
|
||||||
public sealed class ConfigWindow : Window
|
public sealed class ConfigWindow : Window
|
||||||
|
|
@ -45,7 +44,7 @@ public sealed class ConfigWindow : Window
|
||||||
RespectCloseHotkey = true;
|
RespectCloseHotkey = true;
|
||||||
SizeConstraints = new WindowSizeConstraints()
|
SizeConstraints = new WindowSizeConstraints()
|
||||||
{
|
{
|
||||||
MinimumSize = new Vector2(800, 600),
|
MinimumSize = new Vector2(900, 600),
|
||||||
MaximumSize = new Vector2(4096, 2160),
|
MaximumSize = new Vector2(4096, 2160),
|
||||||
};
|
};
|
||||||
tutorial.UpdateTutorialStep();
|
tutorial.UpdateTutorialStep();
|
||||||
|
|
@ -112,9 +111,12 @@ public sealed class ConfigWindow : Window
|
||||||
var text = e.ToString();
|
var text = e.ToString();
|
||||||
if (text == _lastException)
|
if (text == _lastException)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_lastException = text;
|
_lastException = text;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_lastException = e.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
Penumbra.Log.Error($"Exception thrown during UI Render:\n{_lastException}");
|
Penumbra.Log.Error($"Exception thrown during UI Render:\n{_lastException}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
107
Penumbra/UI/ModsTab/ModPanelCollectionsTab.cs
Normal file
107
Penumbra/UI/ModsTab/ModPanelCollectionsTab.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Dalamud.Interface;
|
||||||
|
using ImGuiNET;
|
||||||
|
using Lumina.Data.Parsing.Layer;
|
||||||
|
using OtterGui;
|
||||||
|
using OtterGui.Raii;
|
||||||
|
using OtterGui.Widgets;
|
||||||
|
using Penumbra.Collections;
|
||||||
|
using Penumbra.Collections.Manager;
|
||||||
|
using Penumbra.Mods;
|
||||||
|
using Penumbra.UI.Classes;
|
||||||
|
|
||||||
|
namespace Penumbra.UI.ModsTab;
|
||||||
|
|
||||||
|
public class ModPanelCollectionsTab : ITab
|
||||||
|
{
|
||||||
|
private readonly Configuration _config;
|
||||||
|
private readonly ModFileSystemSelector _selector;
|
||||||
|
private readonly CollectionStorage _collections;
|
||||||
|
|
||||||
|
private readonly List<(ModCollection, ModCollection, uint, string)> _cache = new();
|
||||||
|
|
||||||
|
public ModPanelCollectionsTab(Configuration config, CollectionStorage storage, ModFileSystemSelector selector)
|
||||||
|
{
|
||||||
|
_config = config;
|
||||||
|
_collections = storage;
|
||||||
|
_selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlySpan<byte> Label
|
||||||
|
=> "Collections"u8;
|
||||||
|
|
||||||
|
public void DrawContent()
|
||||||
|
{
|
||||||
|
var (direct, inherited) = CountUsage(_selector.Selected!);
|
||||||
|
ImGui.NewLine();
|
||||||
|
if (direct == 1)
|
||||||
|
ImGui.TextUnformatted("This Mod is directly configured in 1 collection.");
|
||||||
|
else if (direct == 0)
|
||||||
|
ImGuiUtil.TextColored(Colors.RegexWarningBorder, "This mod is entirely unused.");
|
||||||
|
else
|
||||||
|
ImGui.TextUnformatted($"This Mod is directly configured in {direct} collections.");
|
||||||
|
if (inherited > 0)
|
||||||
|
{
|
||||||
|
ImGui.TextUnformatted($"It is also implicitly used in {inherited} {(inherited == 1 ? "collection" : "collections")} through inheritance.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.NewLine();
|
||||||
|
ImGui.Separator();
|
||||||
|
ImGui.NewLine();
|
||||||
|
using var table = ImRaii.Table("##modCollections", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
|
||||||
|
if (!table)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var size = ImGui.CalcTextSize("Unconfigured").X + 20 * ImGuiHelpers.GlobalScale;
|
||||||
|
var collectionSize = 200 * ImGuiHelpers.GlobalScale;
|
||||||
|
ImGui.TableSetupColumn("Collection", ImGuiTableColumnFlags.WidthFixed, collectionSize);
|
||||||
|
ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, size);
|
||||||
|
ImGui.TableSetupColumn("Inherited From", ImGuiTableColumnFlags.WidthFixed, collectionSize);
|
||||||
|
|
||||||
|
ImGui.TableHeadersRow();
|
||||||
|
foreach (var (collection, parent, color, text) in _cache)
|
||||||
|
{
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(collection.Name);
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
using (var c = ImRaii.PushColor(ImGuiCol.Text, color))
|
||||||
|
{
|
||||||
|
ImGui.TextUnformatted(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(parent == collection ? string.Empty : parent.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private (int Direct, int Inherited) CountUsage(Mod mod)
|
||||||
|
{
|
||||||
|
_cache.Clear();
|
||||||
|
var undefined = ColorId.UndefinedMod.Value(_config);
|
||||||
|
var enabled = ColorId.EnabledMod.Value(_config);
|
||||||
|
var inherited = ColorId.InheritedMod.Value(_config);
|
||||||
|
var disabled = ColorId.DisabledMod.Value(_config);
|
||||||
|
var disInherited = ColorId.InheritedDisabledMod.Value(_config);
|
||||||
|
var directCount = 0;
|
||||||
|
var inheritedCount = 0;
|
||||||
|
foreach (var collection in _collections)
|
||||||
|
{
|
||||||
|
var (settings, parent) = collection[mod.Index];
|
||||||
|
var (color, text) = settings == null
|
||||||
|
? (undefined, "Unconfigured")
|
||||||
|
: settings.Enabled
|
||||||
|
? (parent == collection ? enabled : inherited, "Enabled")
|
||||||
|
: (parent == collection ? disabled : disInherited, "Disabled");
|
||||||
|
_cache.Add((collection, parent, color, text));
|
||||||
|
|
||||||
|
if (color == enabled)
|
||||||
|
++directCount;
|
||||||
|
else if (color == inherited)
|
||||||
|
++inheritedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (directCount, inheritedCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -198,13 +198,13 @@ public class ModPanelEditTab : ITab
|
||||||
_delayedActions.Enqueue(() => DescriptionEdit.OpenPopup(_filenames, _mod, Input.Description));
|
_delayedActions.Enqueue(() => DescriptionEdit.OpenPopup(_filenames, _mod, Input.Description));
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
var fileExists = File.Exists(_modManager.DataEditor.MetaFile(_mod));
|
var fileExists = File.Exists(_filenames.ModMetaPath(_mod));
|
||||||
var tt = fileExists
|
var tt = fileExists
|
||||||
? "Open the metadata json file in the text editor of your choice."
|
? "Open the metadata json file in the text editor of your choice."
|
||||||
: "The metadata json file does not exist.";
|
: "The metadata json file does not exist.";
|
||||||
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##metaFile", UiHelpers.IconButtonSize, tt,
|
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##metaFile", UiHelpers.IconButtonSize, tt,
|
||||||
!fileExists, true))
|
!fileExists, true))
|
||||||
Process.Start(new ProcessStartInfo(_modManager.DataEditor.MetaFile(_mod)) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(_filenames.ModMetaPath(_mod)) { UseShellExecute = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Do some edits outside of iterations. </summary>
|
/// <summary> Do some edits outside of iterations. </summary>
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,13 @@ public class ModPanelTabBar
|
||||||
Settings,
|
Settings,
|
||||||
ChangedItems,
|
ChangedItems,
|
||||||
Conflicts,
|
Conflicts,
|
||||||
|
Collections,
|
||||||
Edit,
|
Edit,
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly ModPanelSettingsTab Settings;
|
public readonly ModPanelSettingsTab Settings;
|
||||||
public readonly ModPanelDescriptionTab Description;
|
public readonly ModPanelDescriptionTab Description;
|
||||||
|
public readonly ModPanelCollectionsTab Collections;
|
||||||
public readonly ModPanelConflictsTab Conflicts;
|
public readonly ModPanelConflictsTab Conflicts;
|
||||||
public readonly ModPanelChangedItemsTab ChangedItems;
|
public readonly ModPanelChangedItemsTab ChangedItems;
|
||||||
public readonly ModPanelEditTab Edit;
|
public readonly ModPanelEditTab Edit;
|
||||||
|
|
@ -37,7 +39,7 @@ public class ModPanelTabBar
|
||||||
|
|
||||||
public ModPanelTabBar(ModEditWindow modEditWindow, ModPanelSettingsTab settings, ModPanelDescriptionTab description,
|
public ModPanelTabBar(ModEditWindow modEditWindow, ModPanelSettingsTab settings, ModPanelDescriptionTab description,
|
||||||
ModPanelConflictsTab conflicts, ModPanelChangedItemsTab changedItems, ModPanelEditTab edit, ModManager modManager,
|
ModPanelConflictsTab conflicts, ModPanelChangedItemsTab changedItems, ModPanelEditTab edit, ModManager modManager,
|
||||||
TutorialService tutorial)
|
TutorialService tutorial, ModPanelCollectionsTab collections)
|
||||||
{
|
{
|
||||||
_modEditWindow = modEditWindow;
|
_modEditWindow = modEditWindow;
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
|
|
@ -47,6 +49,7 @@ public class ModPanelTabBar
|
||||||
Edit = edit;
|
Edit = edit;
|
||||||
_modManager = modManager;
|
_modManager = modManager;
|
||||||
_tutorial = tutorial;
|
_tutorial = tutorial;
|
||||||
|
Collections = collections;
|
||||||
|
|
||||||
Tabs = new ITab[]
|
Tabs = new ITab[]
|
||||||
{
|
{
|
||||||
|
|
@ -54,6 +57,7 @@ public class ModPanelTabBar
|
||||||
Description,
|
Description,
|
||||||
Conflicts,
|
Conflicts,
|
||||||
ChangedItems,
|
ChangedItems,
|
||||||
|
Collections,
|
||||||
Edit,
|
Edit,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +87,7 @@ public class ModPanelTabBar
|
||||||
ModPanelTabType.Settings => Settings.Label,
|
ModPanelTabType.Settings => Settings.Label,
|
||||||
ModPanelTabType.ChangedItems => ChangedItems.Label,
|
ModPanelTabType.ChangedItems => ChangedItems.Label,
|
||||||
ModPanelTabType.Conflicts => Conflicts.Label,
|
ModPanelTabType.Conflicts => Conflicts.Label,
|
||||||
|
ModPanelTabType.Collections => Collections.Label,
|
||||||
ModPanelTabType.Edit => Edit.Label,
|
ModPanelTabType.Edit => Edit.Label,
|
||||||
_ => ReadOnlySpan<byte>.Empty,
|
_ => ReadOnlySpan<byte>.Empty,
|
||||||
};
|
};
|
||||||
|
|
@ -97,6 +102,8 @@ public class ModPanelTabBar
|
||||||
return ModPanelTabType.ChangedItems;
|
return ModPanelTabType.ChangedItems;
|
||||||
if (label == Conflicts.Label)
|
if (label == Conflicts.Label)
|
||||||
return ModPanelTabType.Conflicts;
|
return ModPanelTabType.Conflicts;
|
||||||
|
if (label == Collections.Label)
|
||||||
|
return ModPanelTabType.Collections;
|
||||||
if (label == Edit.Label)
|
if (label == Edit.Label)
|
||||||
return ModPanelTabType.Edit;
|
return ModPanelTabType.Edit;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue