Current state.

This commit is contained in:
Ottermandias 2024-12-27 16:02:50 +01:00
parent 67305d507a
commit 98a89bb2b4
28 changed files with 606 additions and 265 deletions

View file

@ -737,7 +737,7 @@ public class ItemSwapTab : IDisposable, ITab, IUiService
if (collectionType is not CollectionType.Current || _mod == null || newCollection == null)
return;
UpdateMod(_mod, _mod.Index < newCollection.Settings.Count ? newCollection[_mod.Index].Settings : null);
UpdateMod(_mod, _mod.Index < newCollection.Settings.Count ? newCollection.GetInheritedSettings(_mod.Index).Settings : null);
}
private void OnSettingChange(ModCollection collection, ModSettingChange type, Mod? mod, Setting oldValue, int groupIdx, bool inherited)
@ -754,7 +754,7 @@ public class ItemSwapTab : IDisposable, ITab, IUiService
if (collection != _collectionManager.Active.Current || _mod == null)
return;
UpdateMod(_mod, collection[_mod.Index].Settings);
UpdateMod(_mod, collection.GetInheritedSettings(_mod.Index).Settings);
_swapData.LoadMod(_mod, _modSettings);
_dirty = true;
}

View file

@ -101,7 +101,7 @@ public partial class ModEditWindow : Window, IDisposable, IUiService
_modelTab.Reset();
_materialTab.Reset();
_shaderPackageTab.Reset();
_itemSwapTab.UpdateMod(mod, _activeCollections.Current[mod.Index].Settings);
_itemSwapTab.UpdateMod(mod, _activeCollections.Current.GetInheritedSettings(mod.Index).Settings);
UpdateModels();
_forceTextureStartPath = true;
});

View file

@ -15,6 +15,7 @@ using Penumbra.Collections.Manager;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Enums;
using Penumbra.Mods.Manager;
using Penumbra.Mods.Settings;
using Penumbra.Services;
using Penumbra.UI.Classes;
@ -497,7 +498,7 @@ public sealed class CollectionPanel(
ImGui.Separator();
var buttonHeight = 2 * ImGui.GetTextLineHeightWithSpacing();
if (_inUseCache.Count == 0 && collection.DirectParentOf.Count == 0)
if (_inUseCache.Count == 0 && collection.Inheritance.DirectlyInheritedBy.Count == 0)
{
ImGui.Dummy(Vector2.One);
using var f = _nameFont.Push();
@ -559,7 +560,7 @@ public sealed class CollectionPanel(
private void DrawInheritanceStatistics(ModCollection collection, Vector2 buttonWidth)
{
if (collection.DirectParentOf.Count <= 0)
if (collection.Inheritance.DirectlyInheritedBy.Count <= 0)
return;
using (var _ = ImRaii.PushStyle(ImGuiStyleVar.FramePadding, Vector2.Zero))
@ -570,11 +571,11 @@ public sealed class CollectionPanel(
using var f = _nameFont.Push();
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
using var color = ImRaii.PushColor(ImGuiCol.Border, Colors.MetaInfoText);
ImGuiUtil.DrawTextButton(Name(collection.DirectParentOf[0]), Vector2.Zero, 0);
ImGuiUtil.DrawTextButton(Name(collection.Inheritance.DirectlyInheritedBy[0]), Vector2.Zero, 0);
var constOffset = (ImGui.GetStyle().FramePadding.X + ImGuiHelpers.GlobalScale) * 2
+ ImGui.GetStyle().ItemSpacing.X
+ ImGui.GetStyle().WindowPadding.X;
foreach (var parent in collection.DirectParentOf.Skip(1))
foreach (var parent in collection.Inheritance.DirectlyInheritedBy.Skip(1))
{
var name = Name(parent);
var size = ImGui.CalcTextSize(name).X;
@ -602,7 +603,7 @@ public sealed class CollectionPanel(
ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, 1.75f * ImGui.GetFrameHeight());
ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, 2.5f * ImGui.GetFrameHeight());
ImGui.TableHeadersRow();
foreach (var (mod, (settings, parent)) in mods.Select(m => (m, collection[m.Index]))
foreach (var (mod, (settings, parent)) in mods.Select(m => (m, collection.GetInheritedSettings(m.Index)))
.Where(t => t.Item2.Settings != null)
.OrderBy(t => t.m.Name))
{
@ -625,12 +626,12 @@ public sealed class CollectionPanel(
private void DrawInactiveSettingsList(ModCollection collection)
{
if (collection.UnusedSettings.Count == 0)
if (collection.Settings.Unused.Count == 0)
return;
ImGui.Dummy(Vector2.One);
var text = collection.UnusedSettings.Count > 1
? $"Clear all {collection.UnusedSettings.Count} unused settings from deleted mods."
var text = collection.Settings.Unused.Count > 1
? $"Clear all {collection.Settings.Unused.Count} unused settings from deleted mods."
: "Clear the currently unused setting from a deleted mods.";
if (ImGui.Button(text, new Vector2(ImGui.GetContentRegionAvail().X, 0)))
_collections.CleanUnavailableSettings(collection);
@ -638,7 +639,7 @@ public sealed class CollectionPanel(
ImGui.Dummy(Vector2.One);
var size = new Vector2(ImGui.GetContentRegionAvail().X,
Math.Min(10, collection.UnusedSettings.Count + 1) * ImGui.GetFrameHeightWithSpacing());
Math.Min(10, collection.Settings.Unused.Count + 1) * ImGui.GetFrameHeightWithSpacing());
using var table = ImRaii.Table("##inactiveSettings", 4, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY, size);
if (!table)
return;
@ -650,7 +651,7 @@ public sealed class CollectionPanel(
ImGui.TableSetupColumn("Priority", ImGuiTableColumnFlags.WidthFixed, 2.5f * ImGui.GetFrameHeight());
ImGui.TableHeadersRow();
string? delete = null;
foreach (var (name, settings) in collection.UnusedSettings.OrderBy(n => n.Key))
foreach (var (name, settings) in collection.Settings.Unused.OrderBy(n => n.Key))
{
using var id = ImRaii.PushId(name);
ImGui.TableNextColumn();

View file

@ -107,7 +107,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
var lineEnd = lineStart;
// Skip the collection itself.
foreach (var inheritance in collection.GetFlattenedInheritance().Skip(1))
foreach (var inheritance in collection.Inheritance.FlatHierarchy.Skip(1))
{
// Draw the child, already seen collections are colored as conflicts.
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.HandledConflictMod.Value(),
@ -150,7 +150,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
DrawInheritedChildren(collection);
else
// We still want to keep track of conflicts.
_seenInheritedCollections.UnionWith(collection.GetFlattenedInheritance());
_seenInheritedCollections.UnionWith(collection.Inheritance.FlatHierarchy);
}
/// <summary> Draw the list box containing the current inheritance information. </summary>
@ -163,7 +163,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
_seenInheritedCollections.Clear();
_seenInheritedCollections.Add(_active.Current);
foreach (var collection in _active.Current.DirectlyInheritsFrom.ToList())
foreach (var collection in _active.Current.Inheritance.DirectlyInheritsFrom.ToList())
DrawInheritance(collection);
}
@ -180,7 +180,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
using var target = ImRaii.DragDropTarget();
if (target.Success && ImGuiUtil.IsDropping(InheritanceDragDropLabel))
_inheritanceAction = (_active.Current.DirectlyInheritsFrom.IndexOf(_movedInheritance!), -1);
_inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(_movedInheritance!), -1);
}
/// <summary>
@ -244,7 +244,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
{
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton);
_newInheritance ??= _collections.FirstOrDefault(c
=> c != _active.Current && !_active.Current.DirectlyInheritsFrom.Contains(c))
=> c != _active.Current && !_active.Current.Inheritance.DirectlyInheritsFrom.Contains(c))
?? ModCollection.Empty;
using var combo = ImRaii.Combo("##newInheritance", Name(_newInheritance));
if (!combo)
@ -271,8 +271,8 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
if (_movedInheritance != null)
{
var idx1 = _active.Current.DirectlyInheritsFrom.IndexOf(_movedInheritance);
var idx2 = _active.Current.DirectlyInheritsFrom.IndexOf(collection);
var idx1 = _active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(_movedInheritance);
var idx2 = _active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(collection);
if (idx1 >= 0 && idx2 >= 0)
_inheritanceAction = (idx1, idx2);
}
@ -302,7 +302,7 @@ public class InheritanceUi(CollectionManager collectionManager, IncognitoService
if (ImGui.GetIO().KeyCtrl && ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
if (withDelete && ImGui.GetIO().KeyShift)
_inheritanceAction = (_active.Current.DirectlyInheritsFrom.IndexOf(collection), -1);
_inheritanceAction = (_active.Current.Inheritance.DirectlyInheritsFrom.IndexOf(collection), -1);
else
_newCurrentCollection = collection;
}

View file

@ -201,7 +201,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
if (ImGui.IsItemClicked(ImGuiMouseButton.Middle))
{
_modManager.SetKnown(leaf.Value);
var (setting, collection) = _collectionManager.Active.Current[leaf.Value.Index];
var (setting, collection) = _collectionManager.Active.Current.GetActualSettings(leaf.Value.Index);
if (_config.DeleteModModifier.ForcedModifier(new DoubleModifier(ModifierHotkey.Control, ModifierHotkey.Shift)).IsActive())
{
_collectionManager.Editor.SetModInheritance(_collectionManager.Active.Current, leaf.Value, true);
@ -580,7 +580,14 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
return ColorId.UndefinedMod;
if (!settings.Enabled)
return collection != _collectionManager.Active.Current ? ColorId.InheritedDisabledMod : ColorId.DisabledMod;
return collection != _collectionManager.Active.Current
? ColorId.InheritedDisabledMod
: settings is TemporaryModSettings
? ColorId.TemporaryDisabledMod
: ColorId.DisabledMod;
if (settings is TemporaryModSettings)
return ColorId.TemporaryEnabledMod;
var conflicts = _collectionManager.Active.Current.Conflicts(mod);
if (conflicts.Count == 0)
@ -631,7 +638,11 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
}
else if (!settings.Enabled)
{
state.Color = collection == _collectionManager.Active.Current ? ColorId.DisabledMod : ColorId.InheritedDisabledMod;
state.Color = collection != _collectionManager.Active.Current
? ColorId.InheritedDisabledMod
: settings is TemporaryModSettings
? ColorId.TemporaryDisabledMod
: ColorId.DisabledMod;
if (!_stateFilter.HasFlag(ModFilter.Disabled)
|| !_stateFilter.HasFlag(ModFilter.NoConflict))
return true;
@ -641,7 +652,10 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
if (!_stateFilter.HasFlag(ModFilter.Enabled))
return true;
// Conflicts can only be relevant if the mod is enabled.
if (settings is TemporaryModSettings)
state.Color = ColorId.TemporaryEnabledMod;
// Conflicts can only be relevant if the mod is enabled.
var conflicts = _collectionManager.Active.Current.Conflicts(mod);
if (conflicts.Count > 0)
{
@ -650,14 +664,14 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
if (!_stateFilter.HasFlag(ModFilter.UnsolvedConflict))
return true;
state.Color = ColorId.ConflictingMod;
state.Color = settings is TemporaryModSettings ? ColorId.TemporaryEnabledMod : ColorId.ConflictingMod;
}
else
{
if (!_stateFilter.HasFlag(ModFilter.SolvedConflict))
return true;
state.Color = ColorId.HandledConflictMod;
state.Color = settings is TemporaryModSettings ? ColorId.TemporaryEnabledMod : ColorId.HandledConflictMod;
}
}
else if (!_stateFilter.HasFlag(ModFilter.NoConflict))
@ -677,7 +691,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
private bool ApplyFiltersAndState(ModFileSystem.Leaf leaf, out ModState state)
{
var mod = leaf.Value;
var (settings, collection) = _collectionManager.Active.Current[mod.Index];
var (settings, collection) = _collectionManager.Active.Current.GetActualSettings(mod.Index);
state = new ModState
{

View file

@ -120,7 +120,7 @@ public class ModPanelCollectionsTab(CollectionManager manager, ModFileSystemSele
var inheritedCount = 0;
foreach (var collection in manager.Storage)
{
var (settings, parent) = collection[mod.Index];
var (settings, parent) = collection.GetInheritedSettings(mod.Index);
var (color, text) = settings == null
? (undefined, ModState.Unconfigured)
: settings.Enabled

View file

@ -34,7 +34,7 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy
if (conflicts.Mod2.Index < 0)
return conflicts.Mod2.Priority;
return collectionManager.Active.Current[conflicts.Mod2.Index].Settings?.Priority ?? ModPriority.Default;
return collectionManager.Active.Current.GetActualSettings(conflicts.Mod2.Index).Settings?.Priority ?? ModPriority.Default;
}
public void DrawContent()
@ -74,22 +74,27 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(selector.Selected!.Name);
ImGui.TableNextColumn();
var priority = collectionManager.Active.Current[selector.Selected!.Index].Settings!.Priority.Value;
ImGui.SetNextItemWidth(priorityWidth);
if (ImGui.InputInt("##priority", ref priority, 0, 0, ImGuiInputTextFlags.EnterReturnsTrue))
_currentPriority = priority;
if (ImGui.IsItemDeactivatedAfterEdit() && _currentPriority.HasValue)
var actualSettings = collectionManager.Active.Current.GetActualSettings(selector.Selected!.Index).Settings!;
var priority = actualSettings.Priority.Value;
// TODO
using (ImRaii.Disabled(actualSettings is TemporaryModSettings))
{
if (_currentPriority != collectionManager.Active.Current[selector.Selected!.Index].Settings!.Priority.Value)
collectionManager.Editor.SetModPriority(collectionManager.Active.Current, selector.Selected!,
new ModPriority(_currentPriority.Value));
ImGui.SetNextItemWidth(priorityWidth);
if (ImGui.InputInt("##priority", ref priority, 0, 0, ImGuiInputTextFlags.EnterReturnsTrue))
_currentPriority = priority;
_currentPriority = null;
}
else if (ImGui.IsItemDeactivated())
{
_currentPriority = null;
if (ImGui.IsItemDeactivatedAfterEdit() && _currentPriority.HasValue)
{
if (_currentPriority != actualSettings.Priority.Value)
collectionManager.Editor.SetModPriority(collectionManager.Active.Current, selector.Selected!,
new ModPriority(_currentPriority.Value));
_currentPriority = null;
}
else if (ImGui.IsItemDeactivated())
{
_currentPriority = null;
}
}
ImGui.TableNextColumn();
@ -138,7 +143,7 @@ public class ModPanelConflictsTab(CollectionManager collectionManager, ModFileSy
ImGui.TableNextColumn();
var conflictPriority = DrawPriorityInput(conflict, priorityWidth);
ImGui.SameLine();
var selectedPriority = collectionManager.Active.Current[selector.Selected!.Index].Settings!.Priority.Value;
var selectedPriority = collectionManager.Active.Current.GetActualSettings(selector.Selected!.Index).Settings!.Priority.Value;
DrawPriorityButtons(conflict.Mod2 as Mod, conflictPriority, selectedPriority, buttonSize);
ImGui.TableNextColumn();
DrawExpandButton(conflict.Mod2, expanded, buttonSize);

View file

@ -204,11 +204,45 @@ public class DebugTab : Window, ITab, IUiService
if (collection.HasCache)
{
using var color = PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value());
using var node = TreeNode($"{collection.Identity.Name} (Change Counter {collection.Counters.Change})###{collection.Identity.Name}");
using var node =
TreeNode($"{collection.Identity.Name} (Change Counter {collection.Counters.Change})###{collection.Identity.Name}");
if (!node)
continue;
color.Pop();
using (var inheritanceNode = ImUtf8.TreeNode("Inheritance"u8))
{
if (inheritanceNode)
{
using var table = ImUtf8.Table("table"u8, 3,
ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersInnerV);
if (table)
{
var max = Math.Max(
Math.Max(collection.Inheritance.DirectlyInheritedBy.Count, collection.Inheritance.DirectlyInheritsFrom.Count),
collection.Inheritance.FlatHierarchy.Count);
for (var i = 0; i < max; ++i)
{
ImGui.TableNextColumn();
if (i < collection.Inheritance.DirectlyInheritsFrom.Count)
ImUtf8.Text(collection.Inheritance.DirectlyInheritsFrom[i].Identity.Name);
else
ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, ImGui.GetTextLineHeight()));
ImGui.TableNextColumn();
if (i < collection.Inheritance.DirectlyInheritedBy.Count)
ImUtf8.Text(collection.Inheritance.DirectlyInheritedBy[i].Identity.Name);
else
ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, ImGui.GetTextLineHeight()));
ImGui.TableNextColumn();
if (i < collection.Inheritance.FlatHierarchy.Count)
ImUtf8.Text(collection.Inheritance.FlatHierarchy[i].Identity.Name);
else
ImGui.Dummy(new Vector2(200 * ImUtf8.GlobalScale, ImGui.GetTextLineHeight()));
}
}
}
}
using (var resourceNode = ImUtf8.TreeNode("Custom Resources"u8))
{
if (resourceNode)
@ -239,7 +273,7 @@ public class DebugTab : Window, ITab, IUiService
else
{
using var color = PushColor(ImGuiCol.Text, ColorId.UndefinedMod.Value());
TreeNode($"{collection.Identity.AnonymizedName} (Change Counter {collection.Counters.Change})",
TreeNode($"{collection.Identity.Name} (Change Counter {collection.Counters.Change})",
ImGuiTreeNodeFlags.Bullet | ImGuiTreeNodeFlags.Leaf).Dispose();
}
}
@ -682,13 +716,11 @@ public class DebugTab : Window, ITab, IUiService
{
using var table = Table("###TmbTable", 2, ImGuiTableFlags.SizingFixedFit);
if (table)
{
foreach (var (id, name) in _schedulerService.ListedTmbs.OrderBy(kvp => kvp.Key))
{
ImUtf8.DrawTableColumn($"{id:D6}");
ImUtf8.DrawTableColumn(name.Span);
}
}
}
}
}

View file

@ -82,7 +82,7 @@ public class ModsTab(
+ $"{selector.SortMode.Name} Sort Mode\n"
+ $"{selector.SelectedLeaf?.Name ?? "NULL"} Selected Leaf\n"
+ $"{selector.Selected?.Name ?? "NULL"} Selected Mod\n"
+ $"{string.Join(", ", _activeCollections.Current.DirectlyInheritsFrom.Select(c => c.Identity.AnonymizedName))} Inheritances\n");
+ $"{string.Join(", ", _activeCollections.Current.Inheritance.DirectlyInheritsFrom.Select(c => c.Identity.AnonymizedName))} Inheritances\n");
}
}