mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Add a overwrite with player state button to design tab.
This commit is contained in:
parent
91138176e0
commit
e4883b15cc
1 changed files with 35 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ using OtterGui.Raii;
|
|||
using Penumbra.GameData.Enums;
|
||||
using System;
|
||||
using static Glamourer.Gui.Tabs.HeaderDrawer;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Glamourer.Gui.Tabs.DesignTab;
|
||||
|
||||
|
|
@ -38,8 +39,8 @@ public class DesignPanel
|
|||
private readonly CustomizeParameterDrawer _parameterDrawer;
|
||||
private readonly DesignLinkDrawer _designLinkDrawer;
|
||||
private readonly MaterialDrawer _materials;
|
||||
private readonly Button[] _leftButtons;
|
||||
private readonly Button[] _rightButtons;
|
||||
private readonly Button[] _leftButtons;
|
||||
private readonly Button[] _rightButtons;
|
||||
|
||||
|
||||
public DesignPanel(DesignFileSystemSelector selector,
|
||||
|
|
@ -78,6 +79,7 @@ public class DesignPanel
|
|||
new SetFromClipboardButton(this),
|
||||
new UndoButton(this),
|
||||
new ExportToClipboardButton(this),
|
||||
new ApplyCharacterButton(this),
|
||||
];
|
||||
_rightButtons =
|
||||
[
|
||||
|
|
@ -561,4 +563,35 @@ public class DesignPanel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ApplyCharacterButton(DesignPanel panel) : Button
|
||||
{
|
||||
public override bool Visible
|
||||
=> panel._selector.Selected != null && panel._objects.Player.Valid;
|
||||
|
||||
protected override string Description
|
||||
=> "Overwrite this design with your character's current state.";
|
||||
|
||||
protected override FontAwesomeIcon Icon
|
||||
=> FontAwesomeIcon.UserEdit;
|
||||
|
||||
protected override void OnClick()
|
||||
{
|
||||
try
|
||||
{
|
||||
var (player, actor) = panel._objects.PlayerData;
|
||||
if (!player.IsValid || !actor.Valid || !panel._state.GetOrCreate(player, actor.Objects[0], out var state))
|
||||
throw new Exception("No player state available.");
|
||||
|
||||
var design = panel._converter.Convert(state, ApplicationRules.FromModifiers(state))
|
||||
?? throw new Exception("The clipboard did not contain valid data.");
|
||||
panel._manager.ApplyDesign(panel._selector.Selected!, design);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Glamourer.Messager.NotificationMessage(ex, $"Could not apply player state to {panel._selector.Selected!.Name}.",
|
||||
$"Could not apply player state to design {panel._selector.Selected!.Identifier}", NotificationType.Error, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue