Complete mod collection cleanup, initial stuff for inheritance. Some further cleanup.

This commit is contained in:
Ottermandias 2022-03-28 17:25:59 +02:00
parent 7915d516e2
commit 1861c40a4f
48 changed files with 1151 additions and 898 deletions

View file

@ -7,7 +7,6 @@ using Dalamud.Interface.Components;
using Dalamud.Logging;
using ImGuiNET;
using Penumbra.Collections;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
@ -22,7 +21,7 @@ public partial class SettingsInterface
private readonly Selector _selector;
private string _collectionNames = null!;
private string _collectionNamesWithNone = null!;
private ModCollection[] _collections = null!;
private ModCollection[] _collections = null!;
private int _currentCollectionIndex;
private int _currentDefaultIndex;
private readonly Dictionary< string, int > _currentCharacterIndices = new();
@ -192,6 +191,65 @@ public partial class SettingsInterface
}
}
private static void DrawInheritance( ModCollection collection )
{
ImGui.PushID( collection.Index );
if( ImGui.TreeNodeEx( collection.Name, ImGuiTreeNodeFlags.DefaultOpen ) )
{
foreach( var inheritance in collection.Inheritance )
{
DrawInheritance( inheritance );
}
}
ImGui.PopID();
}
private void DrawCurrentCollectionInheritance()
{
if( !ImGui.BeginListBox( "##inheritanceList",
new Vector2( SettingsMenu.InputTextWidth, ImGui.GetTextLineHeightWithSpacing() * 10 ) ) )
{
return;
}
using var end = ImGuiRaii.DeferredEnd( ImGui.EndListBox );
DrawInheritance( _collections[ _currentCollectionIndex + 1 ] );
}
private static int _newInheritanceIdx = 0;
private void DrawNewInheritanceSelection()
{
ImGui.SetNextItemWidth( SettingsMenu.InputTextWidth - ImGui.GetFrameHeight() - ImGui.GetStyle().ItemSpacing.X );
if( ImGui.BeginCombo( "##newInheritance", Penumbra.CollectionManager[ _newInheritanceIdx ].Name ) )
{
using var end = ImGuiRaii.DeferredEnd( ImGui.EndCombo );
foreach( var collection in Penumbra.CollectionManager )
{
if( ImGui.Selectable( collection.Name, _newInheritanceIdx == collection.Index ) )
{
_newInheritanceIdx = collection.Index;
}
}
}
ImGui.SameLine();
var valid = _newInheritanceIdx > ModCollection.Empty.Index
&& _collections[ _currentCollectionIndex + 1 ].Index != _newInheritanceIdx
&& _collections[ _currentCollectionIndex + 1 ].Inheritance.All( c => c.Index != _newInheritanceIdx );
using var style = ImGuiRaii.PushStyle( ImGuiStyleVar.Alpha, 0.5f, !valid );
using var font = ImGuiRaii.PushFont( UiBuilder.IconFont );
if( ImGui.Button( $"{FontAwesomeIcon.Plus.ToIconString()}##newInheritanceAdd", ImGui.GetFrameHeight() * Vector2.One ) && valid )
{
_collections[ _currentCollectionIndex + 1 ].AddInheritance( Penumbra.CollectionManager[ _newInheritanceIdx ] );
}
style.Pop();
font.Pop();
ImGuiComponents.HelpMarker( "Add a new inheritance to the collection." );
}
private void DrawDefaultCollectionSelector()
{
var index = _currentDefaultIndex;
@ -344,12 +402,14 @@ public partial class SettingsInterface
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndTabItem )
.Push( ImGui.EndChild );
if( ImGui.BeginChild( "##CollectionHandling", new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 6 ), true ) )
if( ImGui.BeginChild( "##CollectionHandling", new Vector2( -1, ImGui.GetTextLineHeightWithSpacing() * 17 ), true ) )
{
DrawCurrentCollectionSelector( true );
ImGuiHelpers.ScaledDummy( 0, 10 );
DrawNewCollectionInput();
ImGuiHelpers.ScaledDummy( 0, 10 );
DrawCurrentCollectionInheritance();
DrawNewInheritanceSelection();
}
raii.Pop();

View file

@ -6,8 +6,8 @@ using ImGuiNET;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Util;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
namespace Penumbra.UI;
@ -17,10 +17,8 @@ public partial class SettingsInterface
{
private const string LabelTab = "Effective Changes";
private string _gamePathFilter = string.Empty;
private string _gamePathFilterLower = string.Empty;
private string _filePathFilter = string.Empty;
private string _filePathFilterLower = string.Empty;
private LowerString _gamePathFilter = LowerString.Empty;
private LowerString _filePathFilter = LowerString.Empty;
private const float LeftTextLength = 600;
@ -57,47 +55,49 @@ public partial class SettingsInterface
}
ImGui.SetNextItemWidth( LeftTextLength * ImGuiHelpers.GlobalScale );
if( ImGui.InputTextWithHint( "##effective_changes_gfilter", "Filter game path...", ref _gamePathFilter, 256 ) )
var tmp = _gamePathFilter.Text;
if( ImGui.InputTextWithHint( "##effective_changes_gfilter", "Filter game path...", ref tmp, 256 ) )
{
_gamePathFilterLower = _gamePathFilter.ToLowerInvariant();
_gamePathFilter = tmp;
}
ImGui.SameLine( ( LeftTextLength + _arrowLength ) * ImGuiHelpers.GlobalScale + 3 * ImGui.GetStyle().ItemSpacing.X );
ImGui.SetNextItemWidth( -1 );
if( ImGui.InputTextWithHint( "##effective_changes_ffilter", "Filter file path...", ref _filePathFilter, 256 ) )
tmp = _filePathFilter.Text;
if( ImGui.InputTextWithHint( "##effective_changes_ffilter", "Filter file path...", ref tmp, 256 ) )
{
_filePathFilterLower = _filePathFilter.ToLowerInvariant();
_filePathFilter = tmp;
}
}
private bool CheckFilters( KeyValuePair< Utf8GamePath, FullPath > kvp )
{
if( _gamePathFilter.Any() && !kvp.Key.ToString().Contains( _gamePathFilterLower ) )
if( _gamePathFilter.Length > 0 && !kvp.Key.ToString().Contains( _gamePathFilter.Lower ) )
{
return false;
}
return !_filePathFilter.Any() || kvp.Value.FullName.ToLowerInvariant().Contains( _filePathFilterLower );
return _filePathFilter.Length == 0 || kvp.Value.FullName.ToLowerInvariant().Contains( _filePathFilter.Lower );
}
private bool CheckFilters( KeyValuePair< Utf8GamePath, Utf8GamePath > kvp )
{
if( _gamePathFilter.Any() && !kvp.Key.ToString().Contains( _gamePathFilterLower ) )
if( _gamePathFilter.Length > 0 && !kvp.Key.ToString().Contains( _gamePathFilter.Lower ) )
{
return false;
}
return !_filePathFilter.Any() || kvp.Value.ToString().Contains( _filePathFilterLower );
return _filePathFilter.Length == 0 || kvp.Value.ToString().Contains( _filePathFilter.Lower );
}
private bool CheckFilters( (string, string, string) kvp )
private bool CheckFilters( (string, LowerString) kvp )
{
if( _gamePathFilter.Any() && !kvp.Item1.ToLowerInvariant().Contains( _gamePathFilterLower ) )
if( _gamePathFilter.Length > 0 && !kvp.Item1.ToLowerInvariant().Contains( _gamePathFilter.Lower ) )
{
return false;
}
return !_filePathFilter.Any() || kvp.Item3.Contains( _filePathFilterLower );
return _filePathFilter.Length == 0 || kvp.Item2.Contains( _filePathFilter.Lower );
}
private void DrawFilteredRows( ModCollection active )
@ -113,49 +113,43 @@ public partial class SettingsInterface
return;
}
foreach( var (mp, mod, _) in cache.Cmp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Cmp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );
}
foreach( var (mp, mod, _) in cache.Eqp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Eqp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );
}
foreach( var (mp, mod, _) in cache.Eqdp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Eqdp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );
}
foreach( var (mp, mod, _) in cache.Gmp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Gmp.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );
}
foreach( var (mp, mod, _) in cache.Est.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Est.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );
}
foreach( var (mp, mod, _) in cache.Imc.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name,
Penumbra.ModManager.Mods[ p.Value ].Meta.LowerName ) )
foreach( var (mp, mod) in cache.Imc.Manipulations
.Select( p => ( p.Key.ToString(), Penumbra.ModManager.Mods[ p.Value ].Meta.Name ) )
.Where( CheckFilters ) )
{
DrawLine( mp, mod );

View file

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Logging;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.Util;
@ -15,19 +14,19 @@ public class ModListCache : IDisposable
public const uint ConflictingModColor = 0xFFAAAAFFu;
public const uint HandledConflictModColor = 0xFF88DDDDu;
private readonly Mod.Mod.Manager _manager;
private readonly Mods.Mod.Manager _manager;
private readonly List< FullMod > _modsInOrder = new();
private readonly List< (bool visible, uint color) > _visibleMods = new();
private readonly Dictionary< ModFolder, (bool visible, bool enabled) > _visibleFolders = new();
private readonly IReadOnlySet< string > _newMods;
private string _modFilter = string.Empty;
private string _modFilterChanges = string.Empty;
private string _modFilterAuthor = string.Empty;
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
private bool _listResetNecessary;
private bool _filterResetNecessary;
private LowerString _modFilter = LowerString.Empty;
private LowerString _modFilterAuthor = LowerString.Empty;
private LowerString _modFilterChanges = LowerString.Empty;
private ModFilter _stateFilter = ModFilterExtensions.UnfilteredStateMods;
private bool _listResetNecessary;
private bool _filterResetNecessary;
public ModFilter StateFilter
@ -44,7 +43,7 @@ public class ModListCache : IDisposable
}
}
public ModListCache( Mod.Mod.Manager manager, IReadOnlySet< string > newMods )
public ModListCache( Mods.Mod.Manager manager, IReadOnlySet< string > newMods )
{
_manager = manager;
_newMods = newMods;
@ -123,20 +122,20 @@ public class ModListCache : IDisposable
if( lower.StartsWith( "c:" ) )
{
_modFilterChanges = lower[ 2.. ];
_modFilter = string.Empty;
_modFilterAuthor = string.Empty;
_modFilter = LowerString.Empty;
_modFilterAuthor = LowerString.Empty;
}
else if( lower.StartsWith( "a:" ) )
{
_modFilterAuthor = lower[ 2.. ];
_modFilter = string.Empty;
_modFilterChanges = string.Empty;
_modFilter = LowerString.Empty;
_modFilterChanges = LowerString.Empty;
}
else
{
_modFilter = lower;
_modFilterAuthor = string.Empty;
_modFilterChanges = string.Empty;
_modFilterAuthor = LowerString.Empty;
_modFilterChanges = LowerString.Empty;
}
ResetFilters();
@ -233,12 +232,12 @@ public class ModListCache : IDisposable
{
var ret = ( false, 0u );
if( _modFilter.Length > 0 && !mod.Data.Meta.LowerName.Contains( _modFilter ) )
if( _modFilter.Length > 0 && !mod.Data.Meta.Name.Contains( _modFilter ) )
{
return ret;
}
if( _modFilterAuthor.Length > 0 && !mod.Data.Meta.LowerAuthor.Contains( _modFilterAuthor ) )
if( _modFilterAuthor.Length > 0 && !mod.Data.Meta.Author.Contains( _modFilterAuthor ) )
{
return ret;
}

View file

@ -10,7 +10,6 @@ using Penumbra.GameData.Enums;
using Penumbra.GameData.Util;
using Penumbra.Meta;
using Penumbra.Meta.Manipulations;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
@ -201,7 +200,7 @@ public partial class SettingsInterface
raii.Push( ImGui.EndListBox );
using var indent = ImGuiRaii.PushIndent( 0 );
Mod.Mod? oldBadMod = null;
Mods.Mod? oldBadMod = null;
foreach( var conflict in conflicts )
{
var badMod = Penumbra.ModManager[ conflict.Mod2 ];
@ -224,14 +223,14 @@ public partial class SettingsInterface
indent.Push( 30f );
}
if( conflict.Conflict is Utf8GamePath p )
if( conflict.Data is Utf8GamePath p )
{
unsafe
{
ImGuiNative.igSelectable_Bool( p.Path.Path, 0, ImGuiSelectableFlags.None, Vector2.Zero );
}
}
else if( conflict.Conflict is MetaManipulation m )
else if( conflict.Data is MetaManipulation m )
{
ImGui.Selectable( m.Manipulation?.ToString() ?? string.Empty );
}

View file

@ -5,7 +5,6 @@ using Dalamud.Interface;
using ImGuiNET;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Util;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;

View file

@ -6,7 +6,6 @@ using System.Numerics;
using Dalamud.Interface;
using Dalamud.Logging;
using ImGuiNET;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
@ -69,7 +68,7 @@ public partial class SettingsInterface
_currentWebsite = Meta?.Website ?? "";
}
private Mod.FullMod? Mod
private Mods.FullMod? Mod
=> _selector.Mod;
private ModMeta? Meta
@ -77,7 +76,7 @@ public partial class SettingsInterface
private void DrawName()
{
var name = Meta!.Name;
var name = Meta!.Name.Text;
var modManager = Penumbra.ModManager;
if( ImGuiCustom.InputOrText( _editMode, LabelEditName, ref name, 64 ) && modManager.RenameMod( name, Mod!.Data ) )
{
@ -122,7 +121,7 @@ public partial class SettingsInterface
ImGui.TextColored( GreyColor, "by" );
ImGui.SameLine();
var author = Meta!.Author;
var author = Meta!.Author.Text;
if( ImGuiCustom.InputOrText( _editMode, LabelEditAuthor, ref author, 64 )
&& author != Meta.Author )
{
@ -228,7 +227,7 @@ public partial class SettingsInterface
}
}
public static bool DrawSortOrder( Mod.Mod mod, Mod.Mod.Manager manager, Selector selector )
public static bool DrawSortOrder( Mods.Mod mod, Mods.Mod.Manager manager, Selector selector )
{
var currentSortOrder = mod.Order.FullPath;
ImGui.SetNextItemWidth( 300 * ImGuiHelpers.GlobalScale );

View file

@ -10,7 +10,6 @@ using Dalamud.Logging;
using ImGuiNET;
using Penumbra.Collections;
using Penumbra.Importer;
using Penumbra.Mod;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
@ -410,11 +409,11 @@ public partial class SettingsInterface
// Selection
private partial class Selector
{
public Mod.FullMod? Mod { get; private set; }
public Mods.FullMod? Mod { get; private set; }
private int _index;
private string _nextDir = string.Empty;
private void SetSelection( int idx, Mod.FullMod? info )
private void SetSelection( int idx, Mods.FullMod? info )
{
Mod = info;
if( idx != _index )
@ -480,7 +479,7 @@ public partial class SettingsInterface
private partial class Selector
{
// === Mod ===
private void DrawModOrderPopup( string popupName, Mod.FullMod mod, bool firstOpen )
private void DrawModOrderPopup( string popupName, Mods.FullMod mod, bool firstOpen )
{
if( !ImGui.BeginPopup( popupName ) )
{
@ -664,7 +663,7 @@ public partial class SettingsInterface
idx += sub.TotalDescendantMods();
}
}
else if( item is Mod.Mod _ )
else if( item is Mods.Mod _ )
{
var (mod, visible, color) = Cache.GetMod( idx );
if( mod != null && visible )
@ -721,7 +720,7 @@ public partial class SettingsInterface
}
}
private void DrawMod( Mod.FullMod mod, int modIndex, uint color )
private void DrawMod( Mods.FullMod mod, int modIndex, uint color )
{
using var colorRaii = ImGuiRaii.PushColor( ImGuiCol.Text, color, color != 0 );

View file

@ -10,7 +10,6 @@ using Dalamud.Logging;
using ImGuiNET;
using Penumbra.GameData.ByteString;
using Penumbra.Interop;
using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;