Fix issue with adding mods from clipboard

This commit is contained in:
Ottermandias 2024-08-06 17:39:34 +02:00
parent 5bca4b9118
commit 2e52030c31
3 changed files with 26 additions and 9 deletions

View file

@ -248,7 +248,8 @@ public sealed class DesignManager : DesignEditor
design.LastEdit = DateTimeOffset.UtcNow;
SaveService.QueueSave(design);
Glamourer.Log.Debug($"Renamed tag {oldTag} at {tagIdx} to {newTag} in design {design.Identifier} and reordered tags.");
DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design, new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag)));
DesignChanged.Invoke(DesignChanged.Type.ChangedTag, design,
new TagChangedTransaction(oldTag, newTag, tagIdx, design.Tags.IndexOf(newTag)));
}
/// <summary> Add an associated mod to a design. </summary>
@ -278,12 +279,20 @@ public sealed class DesignManager : DesignEditor
/// <summary> Add or update an associated mod to a design. </summary>
public void UpdateMod(Design design, Mod mod, ModSettings settings)
{
var oldSettings = design.AssociatedMods[mod];
var hasOldSettings = design.AssociatedMods.TryGetValue(mod, out var oldSettings);
design.AssociatedMods[mod] = settings;
design.LastEdit = DateTimeOffset.UtcNow;
SaveService.QueueSave(design);
Glamourer.Log.Debug($"Updated (or added) associated mod {mod.DirectoryName} from design {design.Identifier}.");
DesignChanged.Invoke(DesignChanged.Type.UpdatedMod, design, new ModUpdatedTransaction(mod, oldSettings, settings));
if (hasOldSettings)
{
Glamourer.Log.Debug($"Updated associated mod {mod.DirectoryName} from design {design.Identifier}.");
DesignChanged.Invoke(DesignChanged.Type.UpdatedMod, design, new ModUpdatedTransaction(mod, oldSettings, settings));
}
else
{
Glamourer.Log.Debug($"Added associated mod {mod.DirectoryName} from design {design.Identifier}.");
DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, new ModAddedTransaction(mod, settings));
}
}
/// <summary> Set the write protection status of a design. </summary>

View file

@ -10,11 +10,10 @@ using OtterGui.Classes;
using OtterGui.Raii;
using OtterGui.Text;
using OtterGui.Text.Widget;
using OtterGui.Widgets;
namespace Glamourer.Gui.Tabs.DesignTab;
public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelector selector, DesignManager manager)
public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelector selector, DesignManager manager, Configuration config)
{
private readonly ModCombo _modCombo = new(penumbra, Glamourer.Log);
private (Mod, ModSettings)[]? _copy;
@ -127,8 +126,17 @@ public class ModAssociationsTab(PenumbraService penumbra, DesignFileSystemSelect
removedMod = null;
updatedMod = null;
ImGui.TableNextColumn();
if (ImUtf8.IconButton(FontAwesomeIcon.Trash, "Delete this mod from associations."u8))
removedMod = mod;
var canDelete = config.DeleteDesignModifier.IsActive();
if (canDelete)
{
if (ImUtf8.IconButton(FontAwesomeIcon.Trash, "Delete this mod from associations."u8))
removedMod = mod;
}
else
{
ImUtf8.IconButton(FontAwesomeIcon.Trash, $"Delete this mod from associations.\nHold {config.DeleteDesignModifier} to delete.",
disabled: true);
}
ImUtf8.SameLineInner();
if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Copy this mod setting to clipboard."u8))

@ -1 +1 @@
Subproject commit a62d62a8532de528f43515233ea44892cdb974b5
Subproject commit ad6973c559b4c05aa3c3735ec7b53cc0f5d2f203