mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Misc.
This commit is contained in:
parent
529788d2e5
commit
add4b8aa83
2 changed files with 11 additions and 22 deletions
|
|
@ -1,32 +1,21 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Penumbra.Mods;
|
||||
using Penumbra.Services;
|
||||
using Newtonsoft.Json;
|
||||
using Penumbra.Mods.Manager;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra.Collections;
|
||||
|
||||
/// <summary>
|
||||
/// Handle saving and loading a collection.
|
||||
/// </summary>
|
||||
internal readonly struct ModCollectionSave : ISavable
|
||||
internal readonly struct ModCollectionSave(ModStorage modStorage, ModCollection modCollection) : ISavable
|
||||
{
|
||||
private readonly ModStorage _modStorage;
|
||||
private readonly ModCollection _modCollection;
|
||||
|
||||
public ModCollectionSave(ModStorage modStorage, ModCollection modCollection)
|
||||
{
|
||||
_modStorage = modStorage;
|
||||
_modCollection = modCollection;
|
||||
}
|
||||
|
||||
public string ToFilename(FilenameService fileNames)
|
||||
=> fileNames.CollectionFile(_modCollection);
|
||||
=> fileNames.CollectionFile(modCollection);
|
||||
|
||||
public string LogName(string _)
|
||||
=> _modCollection.AnonymizedName;
|
||||
=> modCollection.AnonymizedName;
|
||||
|
||||
public string TypeName
|
||||
=> "Collection";
|
||||
|
|
@ -40,20 +29,20 @@ internal readonly struct ModCollectionSave : ISavable
|
|||
j.WritePropertyName("Version");
|
||||
j.WriteValue(ModCollection.CurrentVersion);
|
||||
j.WritePropertyName(nameof(ModCollection.Name));
|
||||
j.WriteValue(_modCollection.Name);
|
||||
j.WriteValue(modCollection.Name);
|
||||
j.WritePropertyName(nameof(ModCollection.Settings));
|
||||
|
||||
// Write all used and unused settings by mod directory name.
|
||||
j.WriteStartObject();
|
||||
var list = new List<(string, ModSettings.SavedSettings)>(_modCollection.Settings.Count + _modCollection.UnusedSettings.Count);
|
||||
for (var i = 0; i < _modCollection.Settings.Count; ++i)
|
||||
var list = new List<(string, ModSettings.SavedSettings)>(modCollection.Settings.Count + modCollection.UnusedSettings.Count);
|
||||
for (var i = 0; i < modCollection.Settings.Count; ++i)
|
||||
{
|
||||
var settings = _modCollection.Settings[i];
|
||||
var settings = modCollection.Settings[i];
|
||||
if (settings != null)
|
||||
list.Add((_modStorage[i].ModPath.Name, new ModSettings.SavedSettings(settings, _modStorage[i])));
|
||||
list.Add((modStorage[i].ModPath.Name, new ModSettings.SavedSettings(settings, modStorage[i])));
|
||||
}
|
||||
|
||||
list.AddRange(_modCollection.UnusedSettings.Select(kvp => (kvp.Key, kvp.Value)));
|
||||
list.AddRange(modCollection.UnusedSettings.Select(kvp => (kvp.Key, kvp.Value)));
|
||||
list.Sort((a, b) => string.Compare(a.Item1, b.Item1, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
foreach (var (modDir, settings) in list)
|
||||
|
|
@ -66,7 +55,7 @@ internal readonly struct ModCollectionSave : ISavable
|
|||
|
||||
// Inherit by collection name.
|
||||
j.WritePropertyName("Inheritance");
|
||||
x.Serialize(j, _modCollection.InheritanceByName ?? _modCollection.DirectlyInheritsFrom.Select(c => c.Name));
|
||||
x.Serialize(j, modCollection.InheritanceByName ?? modCollection.DirectlyInheritsFrom.Select(c => c.Name));
|
||||
j.WriteEndObject();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public unsafe class CreateFileWHook : IDisposable
|
|||
{
|
||||
// Use static storage.
|
||||
var ptr = WriteFileName(name);
|
||||
Penumbra.Log.Verbose($"[ResourceHooks] Calling CreateFileWDetour with {ByteString.FromSpanUnsafe(name, false)}.");
|
||||
Penumbra.Log.Excessive($"[ResourceHooks] Calling CreateFileWDetour with {ByteString.FromSpanUnsafe(name, false)}.");
|
||||
return _createFileWHook.OriginalDisposeSafe(ptr, access, shareMode, security, creation, flags, template);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue