mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Remove SaveDefaultMod.
This commit is contained in:
parent
fbe2ed1a71
commit
c31a2f5a42
9 changed files with 60 additions and 102 deletions
|
|
@ -140,7 +140,7 @@ public partial class Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
mod._default.IncorporateMetaChanges( directory, true );
|
mod._default.IncorporateMetaChanges( directory, true );
|
||||||
mod.SaveDefaultMod();
|
Penumbra.SaveService.ImmediateSave(new ModSaveGroup(mod, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Return the name of a new valid directory based on the base directory and the given name. </summary>
|
/// <summary> Return the name of a new valid directory based on the base directory and the given name. </summary>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OtterGui;
|
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.String.Classes;
|
using Penumbra.String.Classes;
|
||||||
|
|
@ -113,8 +112,59 @@ public partial class Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
if( changes )
|
if( changes )
|
||||||
{
|
|
||||||
Penumbra.SaveService.SaveAllOptionGroups(this);
|
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<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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@ public sealed partial class Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
fileVersion = 1;
|
fileVersion = 1;
|
||||||
mod.SaveDefaultMod();
|
Penumbra.SaveService.ImmediateSave(new ModSaveGroup(mod, -1));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Penumbra.Import;
|
using Penumbra.Import;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
|
|
@ -11,90 +10,6 @@ using Penumbra.String.Classes;
|
||||||
|
|
||||||
namespace Penumbra.Mods;
|
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}" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A sub mod is a collection of
|
/// A sub mod is a collection of
|
||||||
/// - file replacements
|
/// - file replacements
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,8 @@ using Newtonsoft.Json.Linq;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using OtterGui.Filesystem;
|
using OtterGui.Filesystem;
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.Util;
|
|
||||||
|
|
||||||
namespace Penumbra.Mods;
|
namespace Penumbra.Mods;
|
||||||
|
|
||||||
public partial class Mod
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Groups that allow all available options to be selected at once. </summary>
|
/// <summary> Groups that allow all available options to be selected at once. </summary>
|
||||||
public sealed class MultiModGroup : IModGroup
|
public sealed class MultiModGroup : IModGroup
|
||||||
|
|
@ -83,7 +83,7 @@ public class TemporaryMod : IMod
|
||||||
foreach( var manip in collection.MetaCache?.Manipulations ?? Array.Empty< MetaManipulation >() )
|
foreach( var manip in collection.MetaCache?.Manipulations ?? Array.Empty< MetaManipulation >() )
|
||||||
defaultMod.ManipulationData.Add( manip );
|
defaultMod.ManipulationData.Add( manip );
|
||||||
|
|
||||||
mod.SaveDefaultMod();
|
Penumbra.SaveService.ImmediateSave(new ModSaveGroup(dir, defaultMod));
|
||||||
modManager.AddMod( dir );
|
modManager.AddMod( dir );
|
||||||
Penumbra.Log.Information( $"Successfully generated mod {mod.Name} at {mod.ModPath.FullName} for collection {collection.Name}." );
|
Penumbra.Log.Information( $"Successfully generated mod {mod.Name} at {mod.ModPath.FullName} for collection {collection.Name}." );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using Penumbra.Api;
|
using Penumbra.Api;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.GameData;
|
using Penumbra.GameData;
|
||||||
using Penumbra.GameData.Data;
|
using Penumbra.GameData.Data;
|
||||||
using Penumbra.Interop;
|
|
||||||
using Penumbra.Interop.ResourceLoading;
|
using Penumbra.Interop.ResourceLoading;
|
||||||
using Penumbra.Interop.PathResolving;
|
using Penumbra.Interop.PathResolving;
|
||||||
using Penumbra.Interop.ResourceTree;
|
using Penumbra.Interop.ResourceTree;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public class ModPanelEditTab : ITab
|
||||||
_modManager.DataEditor.ChangeModTag(_mod, tagIdx, editedTag);
|
_modManager.DataEditor.ChangeModTag(_mod, tagIdx, editedTag);
|
||||||
|
|
||||||
UiHelpers.DefaultLineSpace();
|
UiHelpers.DefaultLineSpace();
|
||||||
AddOptionGroup.Draw(_modManager, _mod);
|
AddOptionGroup.Draw(_filenames, _modManager, _mod);
|
||||||
UiHelpers.DefaultLineSpace();
|
UiHelpers.DefaultLineSpace();
|
||||||
|
|
||||||
for (var groupIdx = 0; groupIdx < _mod.Groups.Count; ++groupIdx)
|
for (var groupIdx = 0; groupIdx < _mod.Groups.Count; ++groupIdx)
|
||||||
|
|
@ -222,19 +222,20 @@ public class ModPanelEditTab : ITab
|
||||||
public static void Reset()
|
public static void Reset()
|
||||||
=> _newGroupName = string.Empty;
|
=> _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));
|
using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, new Vector2(UiHelpers.ScaleX3));
|
||||||
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3);
|
ImGui.SetNextItemWidth(UiHelpers.InputTextMinusButton3);
|
||||||
ImGui.InputTextWithHint("##newGroup", "Add new option group...", ref _newGroupName, 256);
|
ImGui.InputTextWithHint("##newGroup", "Add new option group...", ref _newGroupName, 256);
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
var fileExists = File.Exists(mod.DefaultFile);
|
var defaultFile = filenames.OptionGroupFile(mod, -1);
|
||||||
|
var fileExists = File.Exists(defaultFile);
|
||||||
var tt = fileExists
|
var tt = fileExists
|
||||||
? "Open the default option json file in the text editor of your choice."
|
? "Open the default option json file in the text editor of your choice."
|
||||||
: "The default option json file does not exist.";
|
: "The default option json file does not exist.";
|
||||||
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##defaultFile", UiHelpers.IconButtonSize, tt,
|
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##defaultFile", UiHelpers.IconButtonSize, tt,
|
||||||
!fileExists, true))
|
!fileExists, true))
|
||||||
Process.Start(new ProcessStartInfo(mod.DefaultFile) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(defaultFile) { UseShellExecute = true });
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue