mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-14 20:54:17 +01:00
Add Undo to design panel.
This commit is contained in:
parent
d8085dc022
commit
ab771fd010
1 changed files with 30 additions and 6 deletions
|
|
@ -4,10 +4,12 @@ using Dalamud.Interface.ImGuiNotification;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
using Glamourer.Automation;
|
using Glamourer.Automation;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
|
using Glamourer.Designs.History;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Glamourer.Gui.Customization;
|
using Glamourer.Gui.Customization;
|
||||||
using Glamourer.Gui.Equipment;
|
using Glamourer.Gui.Equipment;
|
||||||
using Glamourer.Gui.Materials;
|
using Glamourer.Gui.Materials;
|
||||||
|
using Glamourer.Gui.Tabs.ActorTab;
|
||||||
using Glamourer.Interop;
|
using Glamourer.Interop;
|
||||||
using Glamourer.State;
|
using Glamourer.State;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
@ -38,6 +40,7 @@ public class DesignPanel
|
||||||
private readonly CustomizeParameterDrawer _parameterDrawer;
|
private readonly CustomizeParameterDrawer _parameterDrawer;
|
||||||
private readonly DesignLinkDrawer _designLinkDrawer;
|
private readonly DesignLinkDrawer _designLinkDrawer;
|
||||||
private readonly MaterialDrawer _materials;
|
private readonly MaterialDrawer _materials;
|
||||||
|
private readonly EditorHistory _history;
|
||||||
private readonly Button[] _leftButtons;
|
private readonly Button[] _leftButtons;
|
||||||
private readonly Button[] _rightButtons;
|
private readonly Button[] _rightButtons;
|
||||||
|
|
||||||
|
|
@ -56,7 +59,8 @@ public class DesignPanel
|
||||||
MultiDesignPanel multiDesignPanel,
|
MultiDesignPanel multiDesignPanel,
|
||||||
CustomizeParameterDrawer parameterDrawer,
|
CustomizeParameterDrawer parameterDrawer,
|
||||||
DesignLinkDrawer designLinkDrawer,
|
DesignLinkDrawer designLinkDrawer,
|
||||||
MaterialDrawer materials)
|
MaterialDrawer materials,
|
||||||
|
EditorHistory history)
|
||||||
{
|
{
|
||||||
_selector = selector;
|
_selector = selector;
|
||||||
_customizationDrawer = customizationDrawer;
|
_customizationDrawer = customizationDrawer;
|
||||||
|
|
@ -73,12 +77,14 @@ public class DesignPanel
|
||||||
_parameterDrawer = parameterDrawer;
|
_parameterDrawer = parameterDrawer;
|
||||||
_designLinkDrawer = designLinkDrawer;
|
_designLinkDrawer = designLinkDrawer;
|
||||||
_materials = materials;
|
_materials = materials;
|
||||||
|
_history = history;
|
||||||
_leftButtons =
|
_leftButtons =
|
||||||
[
|
[
|
||||||
new SetFromClipboardButton(this),
|
new SetFromClipboardButton(this),
|
||||||
new UndoButton(this),
|
new DesignUndoButton(this),
|
||||||
new ExportToClipboardButton(this),
|
new ExportToClipboardButton(this),
|
||||||
new ApplyCharacterButton(this),
|
new ApplyCharacterButton(this),
|
||||||
|
new UndoButton(this),
|
||||||
];
|
];
|
||||||
_rightButtons =
|
_rightButtons =
|
||||||
[
|
[
|
||||||
|
|
@ -544,7 +550,7 @@ public class DesignPanel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class UndoButton(DesignPanel panel) : Button
|
private sealed class DesignUndoButton(DesignPanel panel) : Button
|
||||||
{
|
{
|
||||||
public override bool Visible
|
public override bool Visible
|
||||||
=> panel._selector.Selected != null;
|
=> panel._selector.Selected != null;
|
||||||
|
|
@ -553,10 +559,10 @@ public class DesignPanel
|
||||||
=> !panel._manager.CanUndo(panel._selector.Selected) || (panel._selector.Selected?.WriteProtected() ?? true);
|
=> !panel._manager.CanUndo(panel._selector.Selected) || (panel._selector.Selected?.WriteProtected() ?? true);
|
||||||
|
|
||||||
protected override string Description
|
protected override string Description
|
||||||
=> "Undo the last change if you accidentally overwrote your design with a different one.";
|
=> "Undo the last time you applied an entire design onto this design, if you accidentally overwrote your design with a different one.";
|
||||||
|
|
||||||
protected override FontAwesomeIcon Icon
|
protected override FontAwesomeIcon Icon
|
||||||
=> FontAwesomeIcon.Undo;
|
=> FontAwesomeIcon.SyncAlt;
|
||||||
|
|
||||||
protected override void OnClick()
|
protected override void OnClick()
|
||||||
{
|
{
|
||||||
|
|
@ -632,4 +638,22 @@ public class DesignPanel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sealed class UndoButton(DesignPanel panel) : Button
|
||||||
|
{
|
||||||
|
protected override string Description
|
||||||
|
=> "Undo the last change.";
|
||||||
|
|
||||||
|
protected override FontAwesomeIcon Icon
|
||||||
|
=> FontAwesomeIcon.Undo;
|
||||||
|
|
||||||
|
public override bool Visible
|
||||||
|
=> panel._selector.Selected != null;
|
||||||
|
|
||||||
|
protected override bool Disabled
|
||||||
|
=> (panel._selector.Selected?.WriteProtected() ?? true) || !panel._history.CanUndo(panel._selector.Selected);
|
||||||
|
|
||||||
|
protected override void OnClick()
|
||||||
|
=> panel._history.Undo(panel._selector.Selected!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue