mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-01-03 14:23:43 +01:00
Improve respecting of design write protection.
This commit is contained in:
parent
1bee5c680b
commit
1e0b7fdfce
3 changed files with 15 additions and 7 deletions
|
|
@ -22,8 +22,10 @@ public partial class CustomizationDrawer
|
|||
using (_ = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, 2 * ImGuiHelpers.GlobalScale, current < 0))
|
||||
{
|
||||
if (ImGui.ColorButton($"{_customize[index].Value}##color", color, ImGuiColorEditFlags.None, _framedIconSize))
|
||||
{
|
||||
ImGui.OpenPopup(ColorPickerPopupName);
|
||||
else if (current >= 0 && CaptureMouseWheel(ref current, 0, _currentCount))
|
||||
}
|
||||
else if (current >= 0 && !_locked && CaptureMouseWheel(ref current, 0, _currentCount))
|
||||
{
|
||||
var data = _set.Data(_currentIndex, current, _customize.Face);
|
||||
UpdateValue(data.Value);
|
||||
|
|
@ -70,7 +72,7 @@ public partial class CustomizationDrawer
|
|||
for (var i = 0; i < _currentCount; ++i)
|
||||
{
|
||||
var custom = _set.Data(_currentIndex, i, _customize[CustomizeIndex.Face]);
|
||||
if (ImGui.ColorButton(custom.Value.ToString(), ImGui.ColorConvertU32ToFloat4(custom.Color)))
|
||||
if (ImGui.ColorButton(custom.Value.ToString(), ImGui.ColorConvertU32ToFloat4(custom.Color)) && !_locked)
|
||||
{
|
||||
UpdateValue(custom.Value);
|
||||
ImGui.CloseCurrentPopup();
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
|
||||
public void Draw(Design design)
|
||||
{
|
||||
var available = ImGui.GetContentRegionAvail().X;
|
||||
var available = ImGui.GetContentRegionAvail().X;
|
||||
_spacing = ImGui.GetStyle().ItemInnerSpacing.X;
|
||||
_buttonSize = new Vector2(ImGui.GetFrameHeight());
|
||||
var colorWidth = 4 * _buttonSize.X
|
||||
|
|
@ -64,6 +64,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
ImGui.SameLine(0, _spacing);
|
||||
PasteButton(design, key);
|
||||
ImGui.SameLine(0, _spacing);
|
||||
using var disabled = ImRaii.Disabled(design.WriteProtected());
|
||||
EnabledToggle(design, key, value.Enabled);
|
||||
ImGui.SameLine(0, _spacing);
|
||||
DrawRow(design, key, value.Value, value.Revert);
|
||||
|
|
@ -103,7 +104,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
var deleteEnabled = _config.DeleteDesignModifier.IsActive();
|
||||
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _buttonSize,
|
||||
$"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}",
|
||||
!deleteEnabled, true))
|
||||
!deleteEnabled || design.WriteProtected(), true))
|
||||
return;
|
||||
|
||||
_designManager.ChangeMaterialValue(design, index, null);
|
||||
|
|
@ -121,7 +122,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
private void PasteButton(Design design, MaterialValueIndex index)
|
||||
{
|
||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), _buttonSize,
|
||||
"Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet, true))
|
||||
"Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet || design.WriteProtected(), true))
|
||||
_designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +155,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
|||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _);
|
||||
if (ImGuiUtil.DrawDisabledButton("Add New Row", Vector2.Zero,
|
||||
exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists, false))
|
||||
exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists || design.WriteProtected()))
|
||||
_designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ public class DesignPanel
|
|||
if (!h)
|
||||
return;
|
||||
|
||||
using var disabled = ImRaii.Disabled(_selector.Selected!.WriteProtected());
|
||||
|
||||
using (var _ = ImRaii.Group())
|
||||
{
|
||||
DrawCustomizeApplication();
|
||||
|
|
@ -548,7 +550,7 @@ public class DesignPanel
|
|||
=> panel._selector.Selected != null;
|
||||
|
||||
protected override bool Disabled
|
||||
=> !panel._manager.CanUndo(panel._selector.Selected);
|
||||
=> !panel._manager.CanUndo(panel._selector.Selected) || (panel._selector.Selected?.WriteProtected() ?? true);
|
||||
|
||||
protected override string Description
|
||||
=> "Undo the last change if you accidentally overwrote your design with a different one.";
|
||||
|
|
@ -604,6 +606,9 @@ public class DesignPanel
|
|||
|
||||
protected override string Description
|
||||
=> "Overwrite this design with your character's current state.";
|
||||
|
||||
protected override bool Disabled
|
||||
=> panel._selector.Selected?.WriteProtected() ?? true;
|
||||
|
||||
protected override FontAwesomeIcon Icon
|
||||
=> FontAwesomeIcon.UserEdit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue