diff --git a/Penumbra/Mods/Mod.Creator.cs b/Penumbra/Mods/Mod.Creator.cs
index 87ebd502..86baa7d9 100644
--- a/Penumbra/Mods/Mod.Creator.cs
+++ b/Penumbra/Mods/Mod.Creator.cs
@@ -140,7 +140,7 @@ public partial class Mod
}
mod._default.IncorporateMetaChanges( directory, true );
- mod.SaveDefaultMod();
+ Penumbra.SaveService.ImmediateSave(new ModSaveGroup(mod, -1));
}
/// Return the name of a new valid directory based on the base directory and the given name.
diff --git a/Penumbra/Mods/Mod.Files.cs b/Penumbra/Mods/Mod.Files.cs
index 979a13fc..97910191 100644
--- a/Penumbra/Mods/Mod.Files.cs
+++ b/Penumbra/Mods/Mod.Files.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json.Linq;
-using OtterGui;
using Penumbra.Api.Enums;
using Penumbra.Meta.Manipulations;
using Penumbra.String.Classes;
@@ -113,8 +112,59 @@ public partial class Mod
}
if( changes )
- {
Penumbra.SaveService.SaveAllOptionGroups(this);
+ }
+
+ private void LoadDefaultOption()
+ {
+ var defaultFile = Penumbra.Filenames.OptionGroupFile(this, -1);
+ _default.SetPosition(-1, 0);
+ try
+ {
+ if (!File.Exists(defaultFile))
+ {
+ _default.Load(ModPath, new JObject(), out _);
+ }
+ else
+ {
+ _default.Load(ModPath, JObject.Parse(File.ReadAllText(defaultFile)), out _);
+ }
+ }
+ catch (Exception e)
+ {
+ Penumbra.Log.Error($"Could not parse default file for {Name}:\n{e}");
}
}
+
+ public void WriteAllTexToolsMeta()
+ {
+ try
+ {
+ _default.WriteTexToolsMeta(ModPath);
+ foreach (var group in Groups)
+ {
+ var dir = Creator.NewOptionDirectory(ModPath, group.Name);
+ if (!dir.Exists)
+ {
+ dir.Create();
+ }
+
+ foreach (var option in group.OfType())
+ {
+ var optionDir = Creator.NewOptionDirectory(dir, option.Name);
+ if (!optionDir.Exists)
+ {
+ optionDir.Create();
+ }
+
+ option.WriteTexToolsMeta(optionDir);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Penumbra.Log.Error($"Error writing TexToolsMeta:\n{e}");
+ }
+ }
+
}
\ No newline at end of file
diff --git a/Penumbra/Mods/Mod.Meta.Migration.cs b/Penumbra/Mods/Mod.Meta.Migration.cs
index 9b09c294..d993cef0 100644
--- a/Penumbra/Mods/Mod.Meta.Migration.cs
+++ b/Penumbra/Mods/Mod.Meta.Migration.cs
@@ -114,7 +114,7 @@ public sealed partial class Mod
}
fileVersion = 1;
- mod.SaveDefaultMod();
+ Penumbra.SaveService.ImmediateSave(new ModSaveGroup(mod, -1));
return true;
}
diff --git a/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs b/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs
index f1a4a24c..8b5ba641 100644
--- a/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs
+++ b/Penumbra/Mods/Subclasses/Mod.Files.SubMod.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
-using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Penumbra.Import;
using Penumbra.Meta.Manipulations;
@@ -11,90 +10,6 @@ using Penumbra.String.Classes;
namespace Penumbra.Mods;
-public partial class Mod
-{
- internal string DefaultFile
- => Path.Combine( ModPath.FullName, "default_mod.json" );
-
- // The default mod contains setting-independent sets of file replacements, file swaps and meta changes.
- // Every mod has an default mod, though it may be empty.
- public void SaveDefaultMod()
- {
- var defaultFile = DefaultFile;
-
- using var stream = File.Exists( defaultFile )
- ? File.Open( defaultFile, FileMode.Truncate )
- : File.Open( defaultFile, FileMode.CreateNew );
-
- using var w = new StreamWriter( stream );
- using var j = new JsonTextWriter( w );
- j.Formatting = Formatting.Indented;
- var serializer = new JsonSerializer
- {
- Formatting = Formatting.Indented,
- };
- ISubMod.WriteSubMod( j, serializer, _default, ModPath, 0 );
- }
-
- internal void SaveDefaultModDelayed()
- => Penumbra.Framework.RegisterDelayed( nameof( SaveDefaultMod ) + ModPath.Name, SaveDefaultMod );
-
- private void LoadDefaultOption()
- {
- var defaultFile = DefaultFile;
- _default.SetPosition( -1, 0 );
- try
- {
- if( !File.Exists( defaultFile ) )
- {
- _default.Load( ModPath, new JObject(), out _ );
- }
- else
- {
- _default.Load( ModPath, JObject.Parse( File.ReadAllText( defaultFile ) ), out _ );
- }
- }
- catch( Exception e )
- {
- Penumbra.Log.Error( $"Could not parse default file for {Name}:\n{e}" );
- }
- }
-
- public void WriteAllTexToolsMeta()
- {
- try
- {
- _default.WriteTexToolsMeta( ModPath );
- foreach( var group in Groups )
- {
- var dir = Creator.NewOptionDirectory( ModPath, group.Name );
- if( !dir.Exists )
- {
- dir.Create();
- }
-
- foreach( var option in group.OfType< SubMod >() )
- {
- var optionDir = Creator.NewOptionDirectory( dir, option.Name );
- if( !optionDir.Exists )
- {
- optionDir.Create();
- }
-
- option.WriteTexToolsMeta( optionDir );
- }
- }
- }
- catch( Exception e )
- {
- Penumbra.Log.Error( $"Error writing TexToolsMeta:\n{e}" );
- }
- }
-
-
-
-}
-
///
/// A sub mod is a collection of
/// - file replacements
diff --git a/Penumbra/Mods/Subclasses/Mod.Files.MultiModGroup.cs b/Penumbra/Mods/Subclasses/MultiModGroup.cs
similarity index 98%
rename from Penumbra/Mods/Subclasses/Mod.Files.MultiModGroup.cs
rename to Penumbra/Mods/Subclasses/MultiModGroup.cs
index 44314290..0383f763 100644
--- a/Penumbra/Mods/Subclasses/Mod.Files.MultiModGroup.cs
+++ b/Penumbra/Mods/Subclasses/MultiModGroup.cs
@@ -9,14 +9,8 @@ using Newtonsoft.Json.Linq;
using OtterGui;
using OtterGui.Filesystem;
using Penumbra.Api.Enums;
-using Penumbra.Util;
namespace Penumbra.Mods;
-
-public partial class Mod
-{
-
-}
/// Groups that allow all available options to be selected at once.
public sealed class MultiModGroup : IModGroup
diff --git a/Penumbra/Mods/Subclasses/Mod.Files.SingleModGroup.cs b/Penumbra/Mods/Subclasses/SingleModGroup.cs
similarity index 100%
rename from Penumbra/Mods/Subclasses/Mod.Files.SingleModGroup.cs
rename to Penumbra/Mods/Subclasses/SingleModGroup.cs
diff --git a/Penumbra/Mods/TemporaryMod.cs b/Penumbra/Mods/TemporaryMod.cs
index d46d00d5..b7c0d6c9 100644
--- a/Penumbra/Mods/TemporaryMod.cs
+++ b/Penumbra/Mods/TemporaryMod.cs
@@ -83,7 +83,7 @@ public class TemporaryMod : IMod
foreach( var manip in collection.MetaCache?.Manipulations ?? Array.Empty< MetaManipulation >() )
defaultMod.ManipulationData.Add( manip );
- mod.SaveDefaultMod();
+ Penumbra.SaveService.ImmediateSave(new ModSaveGroup(dir, defaultMod));
modManager.AddMod( dir );
Penumbra.Log.Information( $"Successfully generated mod {mod.Name} at {mod.ModPath.FullName} for collection {collection.Name}." );
}
diff --git a/Penumbra/PenumbraNew.cs b/Penumbra/PenumbraNew.cs
index 9d976a9a..6766d3e8 100644
--- a/Penumbra/PenumbraNew.cs
+++ b/Penumbra/PenumbraNew.cs
@@ -1,14 +1,12 @@
using System;
using Dalamud.Plugin;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.DependencyInjection.Extensions;
using OtterGui.Classes;
using OtterGui.Log;
using Penumbra.Api;
using Penumbra.Collections;
using Penumbra.GameData;
using Penumbra.GameData.Data;
-using Penumbra.Interop;
using Penumbra.Interop.ResourceLoading;
using Penumbra.Interop.PathResolving;
using Penumbra.Interop.ResourceTree;
diff --git a/Penumbra/UI/ModsTab/ModPanelEditTab.cs b/Penumbra/UI/ModsTab/ModPanelEditTab.cs
index f8a82b75..bb1b6d75 100644
--- a/Penumbra/UI/ModsTab/ModPanelEditTab.cs
+++ b/Penumbra/UI/ModsTab/ModPanelEditTab.cs
@@ -83,7 +83,7 @@ public class ModPanelEditTab : ITab
_modManager.DataEditor.ChangeModTag(_mod, tagIdx, editedTag);
UiHelpers.DefaultLineSpace();
- AddOptionGroup.Draw(_modManager, _mod);
+ AddOptionGroup.Draw(_filenames, _modManager, _mod);
UiHelpers.DefaultLineSpace();
for (var groupIdx = 0; groupIdx < _mod.Groups.Count; ++groupIdx)
@@ -222,19 +222,20 @@ public class ModPanelEditTab : ITab
public static void Reset()
=> _newGroupName = string.Empty;
- public static void Draw(ModManager modManager, Mod mod)
+ public static void Draw(FilenameService filenames, ModManager modManager, Mod mod)
{
using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3));
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3);
ImGui.InputTextWithHint("##newGroup", "Add new option group...", ref _newGroupName, 256);
ImGui.SameLine();
- var fileExists = File.Exists(mod.DefaultFile);
+ var defaultFile = filenames.OptionGroupFile(mod, -1);
+ var fileExists = File.Exists(defaultFile);
var tt = fileExists
? "Open the default option json file in the text editor of your choice."
: "The default option json file does not exist.";
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##defaultFile", UiHelpers.IconButtonSize, tt,
!fileExists, true))
- Process.Start(new ProcessStartInfo(mod.DefaultFile) { UseShellExecute = true });
+ Process.Start(new ProcessStartInfo(defaultFile) { UseShellExecute = true });
ImGui.SameLine();