mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-21 23:37:47 +01:00
Automatically incorporate all .meta and .rgsp files when adding mods via API.
This commit is contained in:
parent
ea023ebb5c
commit
1c97b52179
7 changed files with 27 additions and 11 deletions
|
|
@ -202,7 +202,7 @@ public unsafe partial class PathResolver
|
||||||
var resolveData = GetResolveData( human );
|
var resolveData = GetResolveData( human );
|
||||||
using var eqp = resolveData.Valid ? resolveData.ModCollection.TemporarilySetEqpFile() : null;
|
using var eqp = resolveData.Valid ? resolveData.ModCollection.TemporarilySetEqpFile() : null;
|
||||||
using var decals = resolveData.Valid
|
using var decals = resolveData.Valid
|
||||||
? new CharacterUtility.DecalReverter( resolveData.ModCollection, DrawObjectState.UsesDecal(0, data) )
|
? new CharacterUtility.DecalReverter( resolveData.ModCollection, DrawObjectState.UsesDecal( 0, data ) )
|
||||||
: null;
|
: null;
|
||||||
return _changeCustomize.Original( human, data, skipEquipment );
|
return _changeCustomize.Original( human, data, skipEquipment );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ public partial class Mod
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mod = new Mod( modDirectory );
|
var mod = new Mod( modDirectory );
|
||||||
mod.Reload( out _ );
|
mod.Reload( true, out _ );
|
||||||
var editor = new Editor( mod, mod.Default );
|
var editor = new Editor( mod, mod.Default );
|
||||||
editor.DuplicatesFinished = false;
|
editor.DuplicatesFinished = false;
|
||||||
editor.CheckDuplicates( editor.AvailableFiles.OrderByDescending( f => f.FileSize ).ToArray() );
|
editor.CheckDuplicates( editor.AvailableFiles.OrderByDescending( f => f.FileSize ).ToArray() );
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ public partial class Mod
|
||||||
|
|
||||||
if( deletions > 0 )
|
if( deletions > 0 )
|
||||||
{
|
{
|
||||||
_mod.Reload( out _ );
|
_mod.Reload( false, out _ );
|
||||||
UpdateFiles();
|
UpdateFiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ public partial class Mod
|
||||||
|
|
||||||
dir.Refresh();
|
dir.Refresh();
|
||||||
mod.ModPath = dir;
|
mod.ModPath = dir;
|
||||||
if( !mod.Reload( out var metaChange ) )
|
if( !mod.Reload( false, out var metaChange ) )
|
||||||
{
|
{
|
||||||
Penumbra.Log.Error( $"Error reloading moved mod {mod.Name}." );
|
Penumbra.Log.Error( $"Error reloading moved mod {mod.Name}." );
|
||||||
return;
|
return;
|
||||||
|
|
@ -81,7 +81,7 @@ public partial class Mod
|
||||||
var oldName = mod.Name;
|
var oldName = mod.Name;
|
||||||
|
|
||||||
ModPathChanged.Invoke( ModPathChangeType.StartingReload, mod, mod.ModPath, mod.ModPath );
|
ModPathChanged.Invoke( ModPathChangeType.StartingReload, mod, mod.ModPath, mod.ModPath );
|
||||||
if( !mod.Reload( out var metaChange ) )
|
if( !mod.Reload( true, out var metaChange ) )
|
||||||
{
|
{
|
||||||
Penumbra.Log.Warning( mod.Name.Length == 0
|
Penumbra.Log.Warning( mod.Name.Length == 0
|
||||||
? $"Reloading mod {oldName} has failed, new name is empty. Deleting instead."
|
? $"Reloading mod {oldName} has failed, new name is empty. Deleting instead."
|
||||||
|
|
@ -135,7 +135,7 @@ public partial class Mod
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mod = LoadMod( modFolder );
|
var mod = LoadMod( modFolder, true );
|
||||||
if( mod == null )
|
if( mod == null )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ public sealed partial class Mod
|
||||||
{
|
{
|
||||||
foreach( var modFolder in BasePath.EnumerateDirectories() )
|
foreach( var modFolder in BasePath.EnumerateDirectories() )
|
||||||
{
|
{
|
||||||
var mod = LoadMod( modFolder );
|
var mod = LoadMod( modFolder, false );
|
||||||
if( mod == null )
|
if( mod == null )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Penumbra.Mods;
|
namespace Penumbra.Mods;
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ public partial class Mod
|
||||||
_default = new SubMod( this );
|
_default = new SubMod( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Mod? LoadMod( DirectoryInfo modPath )
|
private static Mod? LoadMod( DirectoryInfo modPath, bool incorporateMetaChanges )
|
||||||
{
|
{
|
||||||
modPath.Refresh();
|
modPath.Refresh();
|
||||||
if( !modPath.Exists )
|
if( !modPath.Exists )
|
||||||
|
|
@ -36,7 +37,7 @@ public partial class Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
var mod = new Mod( modPath );
|
var mod = new Mod( modPath );
|
||||||
if( !mod.Reload( out _ ) )
|
if( !mod.Reload( incorporateMetaChanges, out _ ) )
|
||||||
{
|
{
|
||||||
// Can not be base path not existing because that is checked before.
|
// Can not be base path not existing because that is checked before.
|
||||||
Penumbra.Log.Error( $"Mod at {modPath} without name is not supported." );
|
Penumbra.Log.Error( $"Mod at {modPath} without name is not supported." );
|
||||||
|
|
@ -46,7 +47,7 @@ public partial class Mod
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool Reload( out MetaChangeType metaChange )
|
private bool Reload( bool incorporateMetaChanges, out MetaChangeType metaChange )
|
||||||
{
|
{
|
||||||
metaChange = MetaChangeType.Deletion;
|
metaChange = MetaChangeType.Deletion;
|
||||||
ModPath.Refresh();
|
ModPath.Refresh();
|
||||||
|
|
@ -63,8 +64,23 @@ public partial class Mod
|
||||||
|
|
||||||
LoadDefaultOption();
|
LoadDefaultOption();
|
||||||
LoadAllGroups();
|
LoadAllGroups();
|
||||||
|
if( incorporateMetaChanges )
|
||||||
|
{
|
||||||
|
IncorporateAllMetaChanges( true );
|
||||||
|
}
|
||||||
|
|
||||||
ComputeChangedItems();
|
ComputeChangedItems();
|
||||||
SetCounts();
|
SetCounts();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert all .meta and .rgsp files to their respective meta changes and add them to their options.
|
||||||
|
// Deletes the source files if delete is true.
|
||||||
|
private void IncorporateAllMetaChanges( bool delete )
|
||||||
|
{
|
||||||
|
foreach( var subMod in AllSubMods.OfType< SubMod >() )
|
||||||
|
{
|
||||||
|
subMod.IncorporateMetaChanges( ModPath, delete );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ public partial class Mod
|
||||||
internal static void CreateDefaultFiles( DirectoryInfo directory )
|
internal static void CreateDefaultFiles( DirectoryInfo directory )
|
||||||
{
|
{
|
||||||
var mod = new Mod( directory );
|
var mod = new Mod( directory );
|
||||||
mod.Reload( out _ );
|
mod.Reload( false, out _ );
|
||||||
foreach( var file in mod.FindUnusedFiles() )
|
foreach( var file in mod.FindUnusedFiles() )
|
||||||
{
|
{
|
||||||
if( Utf8GamePath.FromFile( new FileInfo( file.FullName ), directory, out var gamePath, true ) )
|
if( Utf8GamePath.FromFile( new FileInfo( file.FullName ), directory, out var gamePath, true ) )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue