mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Add button to remove default-valued meta entries.
This commit is contained in:
parent
3e2c9177a7
commit
233a999650
2 changed files with 72 additions and 7 deletions
|
|
@ -1,12 +1,15 @@
|
||||||
using System.Collections.Frozen;
|
using System.Collections.Frozen;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
|
using Penumbra.GameData.Structs;
|
||||||
|
using Penumbra.Meta;
|
||||||
|
using Penumbra.Meta.Files;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods.Manager;
|
using Penumbra.Mods.Manager;
|
||||||
using Penumbra.Mods.SubMods;
|
using Penumbra.Mods.SubMods;
|
||||||
|
|
||||||
namespace Penumbra.Mods.Editor;
|
namespace Penumbra.Mods.Editor;
|
||||||
|
|
||||||
public class ModMetaEditor(ModManager modManager) : MetaDictionary, IService
|
public class ModMetaEditor(ModManager modManager, MetaFileManager metaFileManager, ImcChecker imcChecker) : MetaDictionary, IService
|
||||||
{
|
{
|
||||||
public sealed class OtherOptionData : HashSet<string>
|
public sealed class OtherOptionData : HashSet<string>
|
||||||
{
|
{
|
||||||
|
|
@ -62,6 +65,65 @@ public class ModMetaEditor(ModManager modManager) : MetaDictionary, IService
|
||||||
Changes = false;
|
Changes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DeleteDefaultValues()
|
||||||
|
{
|
||||||
|
var clone = Clone();
|
||||||
|
Clear();
|
||||||
|
foreach (var (key, value) in clone.Imc)
|
||||||
|
{
|
||||||
|
var defaultEntry = imcChecker.GetDefaultEntry(key, false);
|
||||||
|
if (!defaultEntry.Entry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in clone.Eqp)
|
||||||
|
{
|
||||||
|
var defaultEntry = new EqpEntryInternal(ExpandedEqpFile.GetDefault(metaFileManager, key.SetId), key.Slot);
|
||||||
|
if (!defaultEntry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in clone.Eqdp)
|
||||||
|
{
|
||||||
|
var defaultEntry = new EqdpEntryInternal(ExpandedEqdpFile.GetDefault(metaFileManager, key), key.Slot);
|
||||||
|
if (!defaultEntry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in clone.Est)
|
||||||
|
{
|
||||||
|
var defaultEntry = EstFile.GetDefault(metaFileManager, key);
|
||||||
|
if (!defaultEntry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in clone.Gmp)
|
||||||
|
{
|
||||||
|
var defaultEntry = ExpandedGmpFile.GetDefault(metaFileManager, key);
|
||||||
|
if (!defaultEntry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in clone.Rsp)
|
||||||
|
{
|
||||||
|
var defaultEntry = CmpFile.GetDefault(metaFileManager, key.SubRace, key.Attribute);
|
||||||
|
if (!defaultEntry.Equals(value))
|
||||||
|
TryAdd(key, value);
|
||||||
|
else
|
||||||
|
Changes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Apply(IModDataContainer container)
|
public void Apply(IModDataContainer container)
|
||||||
{
|
{
|
||||||
if (!Changes)
|
if (!Changes)
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,21 @@ public partial class ModEditWindow
|
||||||
|
|
||||||
private void DrawMetaTab()
|
private void DrawMetaTab()
|
||||||
{
|
{
|
||||||
using var tab = ImRaii.TabItem("Meta Manipulations");
|
using var tab = ImUtf8.TabItem("Meta Manipulations"u8);
|
||||||
if (!tab)
|
if (!tab)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DrawOptionSelectHeader();
|
DrawOptionSelectHeader();
|
||||||
|
|
||||||
var setsEqual = !_editor.MetaEditor.Changes;
|
var setsEqual = !_editor.MetaEditor.Changes;
|
||||||
var tt = setsEqual ? "No changes staged." : "Apply the currently staged changes to the option.";
|
var tt = setsEqual ? "No changes staged."u8 : "Apply the currently staged changes to the option."u8;
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
if (ImGuiUtil.DrawDisabledButton("Apply Changes", Vector2.Zero, tt, setsEqual))
|
if (ImUtf8.ButtonEx("Apply Changes"u8, tt, Vector2.Zero, setsEqual))
|
||||||
_editor.MetaEditor.Apply(_editor.Option!);
|
_editor.MetaEditor.Apply(_editor.Option!);
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
tt = setsEqual ? "No changes staged." : "Revert all currently staged changes.";
|
tt = setsEqual ? "No changes staged."u8 : "Revert all currently staged changes."u8;
|
||||||
if (ImGuiUtil.DrawDisabledButton("Revert Changes", Vector2.Zero, tt, setsEqual))
|
if (ImUtf8.ButtonEx("Revert Changes"u8, tt, Vector2.Zero, setsEqual))
|
||||||
_editor.MetaEditor.Load(_editor.Mod!, _editor.Option!);
|
_editor.MetaEditor.Load(_editor.Mod!, _editor.Option!);
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
@ -40,8 +40,11 @@ public partial class ModEditWindow
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
CopyToClipboardButton("Copy all current manipulations to clipboard.", _iconSize, _editor.MetaEditor);
|
CopyToClipboardButton("Copy all current manipulations to clipboard.", _iconSize, _editor.MetaEditor);
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGui.Button("Write as TexTools Files"))
|
if (ImUtf8.Button("Write as TexTools Files"u8))
|
||||||
_metaFileManager.WriteAllTexToolsMeta(Mod!);
|
_metaFileManager.WriteAllTexToolsMeta(Mod!);
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImUtf8.ButtonEx("Remove All Default-Values", "Delete any entries from all lists that set the value to its default value."u8))
|
||||||
|
_editor.MetaEditor.DeleteDefaultValues();
|
||||||
|
|
||||||
using var child = ImRaii.Child("##meta", -Vector2.One, true);
|
using var child = ImRaii.Child("##meta", -Vector2.One, true);
|
||||||
if (!child)
|
if (!child)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue