Signify freshly added mods in the mod-selector.

This commit is contained in:
Ottermandias 2021-10-21 15:12:47 +02:00
parent e488506cde
commit 906e057943
8 changed files with 71 additions and 26 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
@ -35,6 +36,8 @@ namespace Penumbra.UI
private readonly SettingsInterface _base;
private readonly ModManager _manager;
public readonly HashSet< string > NewMods = new();
public TabImport( SettingsInterface ui )
{
_base = ui;
@ -72,7 +75,11 @@ namespace Penumbra.UI
try
{
_texToolsImport = new TexToolsImport( _manager.BasePath );
_texToolsImport.ImportModPack( new FileInfo( fileName ) );
var dir = _texToolsImport.ImportModPack( new FileInfo( fileName ) );
if( dir.Name.Any() )
{
NewMods.Add( dir.Name );
}
PluginLog.Information( $"-> {fileName} OK!" );
}

View file

@ -18,11 +18,13 @@ namespace Penumbra.UI
HasNoConfig = 1 << 10,
HasNoFiles = 1 << 11,
HasFiles = 1 << 12,
IsNew = 1 << 13,
NotNew = 1 << 14,
};
public static class ModFilterExtensions
{
public const ModFilter UnfilteredStateMods = ( ModFilter )( ( 1 << 13 ) - 1 );
public const ModFilter UnfilteredStateMods = ( ModFilter )( ( 1 << 15 ) - 1 );
public static string ToName( this ModFilter filter )
=> filter switch
@ -40,6 +42,8 @@ namespace Penumbra.UI
ModFilter.HasConfig => "Configuration",
ModFilter.HasNoFiles => "No Files",
ModFilter.HasFiles => "Files",
ModFilter.IsNew => "Newly Imported",
ModFilter.NotNew => "Not Newly Imported",
_ => throw new ArgumentOutOfRangeException( nameof( filter ), filter, null ),
};
}

View file

@ -8,6 +8,7 @@ namespace Penumbra.UI
{
public class ModListCache : IDisposable
{
public const uint NewModColor = 0xFF66DD66u;
public const uint DisabledModColor = 0xFF666666u;
public const uint ConflictingModColor = 0xFFAAAAFFu;
public const uint HandledConflictModColor = 0xFF88DDDDu;
@ -17,6 +18,7 @@ namespace Penumbra.UI
private readonly List< Mod.Mod > _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;
@ -40,9 +42,10 @@ namespace Penumbra.UI
}
}
public ModListCache( ModManager manager )
public ModListCache( ModManager manager, IReadOnlySet< string > newMods )
{
_manager = manager;
_newMods = newMods;
ResetModList();
ModFileSystem.ModFileSystemChanged += TriggerListReset;
}
@ -225,6 +228,7 @@ namespace Penumbra.UI
private (bool, uint) CheckFilters( Mod.Mod mod )
{
var ret = ( false, 0u );
if( _modFilter.Any() && !mod.Data.Meta.LowerName.Contains( _modFilter ) )
{
return ret;
@ -261,6 +265,12 @@ namespace Penumbra.UI
return ret;
}
var isNew = _newMods.Contains( mod.Data.BasePath.Name );
if( CheckFlags( isNew ? 1 : 0, ModFilter.IsNew, ModFilter.NotNew ) )
{
return ret;
}
if( !mod.Settings.Enabled )
{
if( !StateFilter.HasFlag( ModFilter.Disabled ) || !StateFilter.HasFlag( ModFilter.NoConflict ) )
@ -303,6 +313,11 @@ namespace Penumbra.UI
}
ret.Item1 = true;
if( isNew )
{
ret.Item2 = NewModColor;
}
SetFolderAndParentsVisible( mod.Data.SortOrder.ParentFolder );
return ret;
}

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using ImGuiNET;
using Penumbra.Mods;
using Penumbra.UI.Custom;
@ -15,10 +16,10 @@ namespace Penumbra.UI
public readonly Selector Selector;
public readonly ModPanel ModPanel;
public TabInstalled( SettingsInterface ui )
public TabInstalled( SettingsInterface ui, HashSet< string > newMods )
{
Selector = new Selector( ui );
ModPanel = new ModPanel( ui, Selector );
Selector = new Selector( ui, newMods );
ModPanel = new ModPanel( ui, Selector, newMods );
_modManager = Service< ModManager >.Get();
}

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Numerics;
@ -50,16 +51,18 @@ namespace Penumbra.UI
private readonly SettingsInterface _base;
private readonly Selector _selector;
private readonly ModManager _modManager;
private readonly HashSet< string > _newMods;
public readonly PluginDetails Details;
private bool _editMode;
private string _currentWebsite;
private bool _validWebsite;
public ModPanel( SettingsInterface ui, Selector s )
public ModPanel( SettingsInterface ui, Selector s, HashSet< string > newMods )
{
_base = ui;
_selector = s;
_newMods = newMods;
Details = new PluginDetails( _base, _selector );
_currentWebsite = Meta?.Website ?? "";
_modManager = Service< ModManager >.Get();
@ -216,7 +219,11 @@ namespace Penumbra.UI
if( ImGui.Checkbox( LabelModEnabled, ref enabled ) )
{
Mod.Settings.Enabled = enabled;
if( !enabled )
if( enabled )
{
_newMods.Remove( Mod.Data.BasePath.Name );
}
else
{
Mod.Cache.ClearConflicts();
}

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
@ -196,7 +197,7 @@ namespace Penumbra.UI
private static void DrawModHelpPopup()
{
ImGui.SetNextWindowPos( ImGui.GetMainViewport().GetCenter(), ImGuiCond.Appearing, Vector2.One / 2 );
ImGui.SetNextWindowSize( new Vector2( 5 * SelectorPanelWidth, 33 * ImGui.GetTextLineHeightWithSpacing() ),
ImGui.SetNextWindowSize( new Vector2( 5 * SelectorPanelWidth, 34 * ImGui.GetTextLineHeightWithSpacing() ),
ImGuiCond.Appearing );
var _ = true;
if( !ImGui.BeginPopupModal( LabelModHelpPopup, ref _, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove ) )
@ -219,6 +220,10 @@ namespace Penumbra.UI
ImGui.TextColored( ImGui.ColorConvertU32ToFloat4( ModListCache.DisabledModColor ), "Disabled in the current collection." );
ImGui.Bullet();
ImGui.SameLine();
ImGui.TextColored( ImGui.ColorConvertU32ToFloat4( ModListCache.NewModColor ),
"Newly imported during this session. Will go away when first enabling a mod or when Penumbra is reloaded." );
ImGui.Bullet();
ImGui.SameLine();
ImGui.TextColored( ImGui.ColorConvertU32ToFloat4( ModListCache.HandledConflictModColor ),
"Enabled and conflicting with another enabled Mod, but on different priorities (i.e. the conflict is solved)." );
ImGui.Bullet();
@ -582,11 +587,11 @@ namespace Penumbra.UI
private float _selectorScalingFactor = 1;
public Selector( SettingsInterface ui )
public Selector( SettingsInterface ui, IReadOnlySet< string > newMods )
{
_base = ui;
_modManager = Service< ModManager >.Get();
Cache = new ModListCache( _modManager );
Cache = new ModListCache( _modManager, newMods );
}
private void DrawCollectionButton( string label, string tooltipLabel, float size, ModCollection collection )

View file

@ -30,7 +30,7 @@ namespace Penumbra.UI
_settingsTab = new TabSettings( _base );
_importTab = new TabImport( _base );
_browserTab = new TabBrowser();
InstalledTab = new TabInstalled( _base );
InstalledTab = new TabInstalled( _base, _importTab.NewMods );
CollectionsTab = new TabCollections( InstalledTab.Selector );
_effectiveTab = new TabEffective();
_changedItems = new TabChangedItems( _base );