Add unsolved conflicts to both mods, add button to auto-generate groups based on folders, misc. fixes.

This commit is contained in:
Ottermandias 2021-10-18 16:12:32 +02:00
parent 795d605d3f
commit 4a82e6faf1
7 changed files with 102 additions and 12 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -478,5 +479,46 @@ namespace Penumbra.Mod
RemoveUselessGroups( meta ); RemoveUselessGroups( meta );
ClearEmptySubDirectories( baseDir ); ClearEmptySubDirectories( baseDir );
} }
public static void AutoGenerateGroups( DirectoryInfo baseDir, ModMeta meta )
{
meta.Groups.Clear();
ClearEmptySubDirectories( baseDir );
foreach( var groupDir in baseDir.EnumerateDirectories() )
{
var group = new OptionGroup
{
GroupName = groupDir.Name,
SelectionType = SelectType.Single,
Options = new List< Option >(),
};
foreach( var optionDir in groupDir.EnumerateDirectories() )
{
var option = new Option
{
OptionDesc = string.Empty,
OptionName = optionDir.Name,
OptionFiles = new Dictionary< RelPath, HashSet< GamePath > >(),
};
foreach( var file in optionDir.EnumerateFiles( "*.*", SearchOption.AllDirectories ) )
{
var relPath = new RelPath( file, baseDir );
var gamePath = new GamePath( file, optionDir );
option.OptionFiles[ relPath ] = new HashSet< GamePath > { gamePath };
}
if( option.OptionFiles.Any() )
{
group.Options.Add( option );
}
}
if( group.Options.Any() )
{
meta.Groups.Add( groupDir.Name, @group );
}
}
}
} }
} }

View file

@ -97,6 +97,10 @@ namespace Penumbra.Mods
else else
{ {
mod.Cache.AddConflict( oldMod, gamePath ); mod.Cache.AddConflict( oldMod, gamePath );
if( !ReferenceEquals( mod, oldMod ) && mod.Settings.Priority == oldMod.Settings.Priority)
{
oldMod.Cache.AddConflict( mod, gamePath );
}
} }
} }
@ -223,6 +227,10 @@ namespace Penumbra.Mods
else else
{ {
mod.Cache.AddConflict( oldMod, swap.Key ); mod.Cache.AddConflict( oldMod, swap.Key );
if( !ReferenceEquals( mod, oldMod ) && mod.Settings.Priority == oldMod.Settings.Priority )
{
oldMod.Cache.AddConflict( mod, swap.Key );
}
} }
} }
} }
@ -231,13 +239,17 @@ namespace Penumbra.Mods
{ {
foreach( var manip in mod.Data.Resources.MetaManipulations.GetManipulationsForConfig( mod.Settings, mod.Data.Meta ) ) foreach( var manip in mod.Data.Resources.MetaManipulations.GetManipulationsForConfig( mod.Settings, mod.Data.Meta ) )
{ {
if( MetaManipulations.TryGetValue( manip, out var precedingMod ) ) if( !MetaManipulations.TryGetValue( manip, out var oldMod ) )
{ {
mod.Cache.AddConflict( precedingMod, manip ); MetaManipulations.ApplyMod( manip, mod );
} }
else else
{ {
MetaManipulations.ApplyMod( manip, mod ); mod.Cache.AddConflict( oldMod, manip );
if( !ReferenceEquals( mod, oldMod ) && mod.Settings.Priority == oldMod.Settings.Priority )
{
oldMod.Cache.AddConflict( mod, manip );
}
} }
} }
} }

View file

@ -298,10 +298,10 @@ namespace Penumbra.Mods
return true; return true;
} }
public bool UpdateMod( ModData mod, bool reloadMeta = false, bool recomputeMeta = false ) public bool UpdateMod( ModData mod, bool reloadMeta = false, bool recomputeMeta = false, bool force = false )
{ {
var oldName = mod.Meta.Name; var oldName = mod.Meta.Name;
var metaChanges = mod.Meta.RefreshFromFile( mod.MetaFile ); var metaChanges = mod.Meta.RefreshFromFile( mod.MetaFile ) || force;
var fileChanges = mod.Resources.RefreshModFiles( mod.BasePath ); var fileChanges = mod.Resources.RefreshModFiles( mod.BasePath );
if( !recomputeMeta && !reloadMeta && !metaChanges && fileChanges == 0 ) if( !recomputeMeta && !reloadMeta && !metaChanges && fileChanges == 0 )

View file

@ -1,7 +1,10 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics;
using Dalamud.Interface; using Dalamud.Interface;
using ImGuiNET; using ImGuiNET;
using Lumina.Data.Parsing;
using Lumina.Excel.GeneratedSheets;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using Penumbra.GameData.Util; using Penumbra.GameData.Util;
using Penumbra.Meta; using Penumbra.Meta;
@ -198,6 +201,14 @@ namespace Penumbra.UI
_base._penumbra.Api.InvokeTooltip( data ); _base._penumbra.Api.InvokeTooltip( data );
raii.Pop(); raii.Pop();
} }
if( data is Item it )
{
var modelId = $"({( ( Quad )it.ModelMain ).A})";
var offset = ImGui.CalcTextSize( modelId ).X - ImGui.GetStyle().ItemInnerSpacing.X;
ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - offset);
ImGui.TextColored( new Vector4(0.5f, 0.5f, 0.5f, 1 ), modelId );
}
} }
} }
@ -401,6 +412,7 @@ namespace Penumbra.UI
continue; continue;
} }
_fullFilenameList![ i ].selected = false;
var relName = _fullFilenameList[ i ].relName; var relName = _fullFilenameList[ i ].relName;
if( defaultIndex >= 0 ) if( defaultIndex >= 0 )
{ {
@ -428,6 +440,7 @@ namespace Penumbra.UI
if( changed ) if( changed )
{ {
_fullFilenameList = null;
_selector.SaveCurrentMod(); _selector.SaveCurrentMod();
// Since files may have changed, we need to recompute effective files. // Since files may have changed, we need to recompute effective files.
foreach( var collection in _modManager.Collections.Collections.Values foreach( var collection in _modManager.Collections.Collections.Values

View file

@ -701,7 +701,7 @@ namespace Penumbra.UI
{ {
MetaType.Est => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ), MetaType.Est => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
MetaType.Eqp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ), MetaType.Eqp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
MetaType.Eqdp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ), MetaType.Eqdp => new MetaManipulation( newManip.Value.Identifier, (ushort) def ),
MetaType.Gmp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ), MetaType.Gmp => new MetaManipulation( newManip.Value.Identifier, ( ulong )def ),
MetaType.Imc => new MetaManipulation( newManip.Value.Identifier, MetaType.Imc => new MetaManipulation( newManip.Value.Identifier,
( ( ImcFile.ImageChangeData )def ).ToInteger() ), ( ( ImcFile.ImageChangeData )def ).ToInteger() ),

View file

@ -216,6 +216,11 @@ namespace Penumbra.UI
if( ImGui.Checkbox( LabelModEnabled, ref enabled ) ) if( ImGui.Checkbox( LabelModEnabled, ref enabled ) )
{ {
Mod.Settings.Enabled = enabled; Mod.Settings.Enabled = enabled;
if( !enabled )
{
Mod.Cache.ClearConflicts();
}
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 ); _base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
_selector.Cache.TriggerFilterReset(); _selector.Cache.TriggerFilterReset();
} }
@ -425,7 +430,7 @@ namespace Penumbra.UI
{ {
if( ImGui.Button( "Recompute Metadata" ) ) if( ImGui.Button( "Recompute Metadata" ) )
{ {
_selector.ReloadCurrentMod( true, true ); _selector.ReloadCurrentMod( true, true, true );
} }
ImGuiCustom.HoverTooltip( ImGuiCustom.HoverTooltip(
@ -440,7 +445,7 @@ namespace Penumbra.UI
{ {
ModCleanup.Deduplicate( Mod!.Data.BasePath, Meta! ); ModCleanup.Deduplicate( Mod!.Data.BasePath, Meta! );
_selector.SaveCurrentMod(); _selector.SaveCurrentMod();
_selector.ReloadCurrentMod(); _selector.ReloadCurrentMod( true, true, true );
} }
ImGuiCustom.HoverTooltip( TooltipDeduplicate ); ImGuiCustom.HoverTooltip( TooltipDeduplicate );
@ -452,12 +457,28 @@ namespace Penumbra.UI
{ {
ModCleanup.Normalize( Mod!.Data.BasePath, Meta! ); ModCleanup.Normalize( Mod!.Data.BasePath, Meta! );
_selector.SaveCurrentMod(); _selector.SaveCurrentMod();
_selector.ReloadCurrentMod(); _selector.ReloadCurrentMod( true, true, true );
} }
ImGuiCustom.HoverTooltip( TooltipNormalize ); ImGuiCustom.HoverTooltip( TooltipNormalize );
} }
private void DrawAutoGenerateGroupsButton()
{
if( ImGui.Button( "Auto-Generate Groups" ) )
{
ModCleanup.AutoGenerateGroups( Mod!.Data.BasePath, Meta! );
_selector.SaveCurrentMod();
_selector.ReloadCurrentMod( true, true );
}
ImGuiCustom.HoverTooltip( "Automatically generate single-select groups from all folders (clears existing groups):\n"
+ "First subdirectory: Option Group\n"
+ "Second subdirectory: Option Name\n"
+ "Afterwards: Relative file paths.\n"
+ "Experimental - Use at own risk!" );
}
private void DrawSplitButton() private void DrawSplitButton()
{ {
if( ImGui.Button( "Split Mod" ) ) if( ImGui.Button( "Split Mod" ) )
@ -487,6 +508,8 @@ namespace Penumbra.UI
ImGui.SameLine(); ImGui.SameLine();
DrawNormalizeButton(); DrawNormalizeButton();
ImGui.SameLine(); ImGui.SameLine();
DrawAutoGenerateGroupsButton();
ImGui.SameLine();
DrawSplitButton(); DrawSplitButton();
DrawSortOrder( Mod!.Data, _modManager, _selector ); DrawSortOrder( Mod!.Data, _modManager, _selector );
@ -498,7 +521,7 @@ namespace Penumbra.UI
{ {
using var raii = ImGuiRaii.DeferredEnd( ImGui.EndChild ); using var raii = ImGuiRaii.DeferredEnd( ImGui.EndChild );
var ret = ImGui.BeginChild( LabelModPanel, AutoFillSize, true ); var ret = ImGui.BeginChild( LabelModPanel, AutoFillSize, true );
if( !ret || Mod == null ) if( !ret || Mod == null )
{ {
return; return;

View file

@ -452,14 +452,14 @@ namespace Penumbra.UI
SetSelection( idx, mod ); SetSelection( idx, mod );
} }
public void ReloadCurrentMod( bool reloadMeta = false, bool recomputeMeta = false ) public void ReloadCurrentMod( bool reloadMeta = false, bool recomputeMeta = false, bool force = false )
{ {
if( Mod == null ) if( Mod == null )
{ {
return; return;
} }
if( _index >= 0 && _modManager.UpdateMod( Mod.Data, reloadMeta, recomputeMeta ) ) if( _index >= 0 && _modManager.UpdateMod( Mod.Data, reloadMeta, recomputeMeta, force ) )
{ {
SelectModOnUpdate( Mod.Data.BasePath.Name ); SelectModOnUpdate( Mod.Data.BasePath.Name );
_base._menu.InstalledTab.ModPanel.Details.ResetState(); _base._menu.InstalledTab.ModPanel.Details.ResetState();