Allow right-clicks to clear equip (to Nothing) or stains.

This commit is contained in:
Ottermandias 2021-10-09 13:45:16 +02:00
parent b65658ef63
commit 9dafc65975
9 changed files with 92 additions and 64 deletions

View file

@ -41,5 +41,15 @@ namespace Glamourer
Name = name; Name = name;
EquippableTo = slot == EquipSlot.Unknown ? ((EquipSlot) item.EquipSlotCategory.Row).ToSlot() : slot; EquippableTo = slot == EquipSlot.Unknown ? ((EquipSlot) item.EquipSlotCategory.Row).ToSlot() : slot;
} }
public static Item Nothing(EquipSlot slot)
=> new("Nothing", slot);
private Item(string name, EquipSlot slot)
{
Name = name;
Base = new Lumina.Excel.GeneratedSheets.Item();
EquippableTo = slot;
}
} }
} }

View file

@ -37,5 +37,14 @@ namespace Glamourer
_seColorId = stain.Color | ((uint) index << 24); _seColorId = stain.Color | ((uint) index << 24);
RgbaColor = SeColorToRgba(stain.Color); RgbaColor = SeColorToRgba(stain.Color);
} }
public static readonly Stain None = new("None");
private Stain(string name)
{
Name = name;
_seColorId = 0;
RgbaColor = 0;
}
} }
} }

View file

@ -0,0 +1,14 @@
using System.Linq;
using ImGuiNET;
namespace Glamourer.Gui
{
public static partial class ImGuiCustom
{
public static void HoverTooltip(string text)
{
if (text.Any() && ImGui.IsItemHovered())
ImGui.SetTooltip(text);
}
}
}

View file

@ -44,8 +44,7 @@ namespace Glamourer.Gui
if (ImGui.Button(FontAwesomeIcon.Clipboard.ToIconString())) if (ImGui.Button(FontAwesomeIcon.Clipboard.ToIconString()))
ImGui.SetClipboardText(save.ToBase64()); ImGui.SetClipboardText(save.ToBase64());
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Copy customization code to clipboard.");
ImGui.SetTooltip("Copy customization code to clipboard.");
} }
private bool DrawApplyClipboardButton() private bool DrawApplyClipboardButton()
@ -53,8 +52,7 @@ namespace Glamourer.Gui
ImGui.PushFont(UiBuilder.IconFont); ImGui.PushFont(UiBuilder.IconFont);
var applyButton = ImGui.Button(FontAwesomeIcon.Paste.ToIconString()) && _player != null; var applyButton = ImGui.Button(FontAwesomeIcon.Paste.ToIconString()) && _player != null;
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Apply customization code from clipboard.");
ImGui.SetTooltip("Apply customization code from clipboard.");
if (!applyButton) if (!applyButton)
return false; return false;
@ -84,8 +82,7 @@ namespace Glamourer.Gui
OpenDesignNamePopup(DesignNameUse.SaveCurrent); OpenDesignNamePopup(DesignNameUse.SaveCurrent);
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Save the current design.");
ImGui.SetTooltip("Save the current design.");
DrawDesignNamePopup(DesignNameUse.SaveCurrent); DrawDesignNamePopup(DesignNameUse.SaveCurrent);
} }

View file

@ -100,8 +100,7 @@ namespace Glamourer.Gui
if (ImGui.Button(FontAwesomeIcon.UserCircle.ToIconString(), buttonWidth)) if (ImGui.Button(FontAwesomeIcon.UserCircle.ToIconString(), buttonWidth))
select = Dalamud.ClientState.LocalPlayer; select = Dalamud.ClientState.LocalPlayer;
raii.PopFonts(); raii.PopFonts();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Select the local player character.");
ImGui.SetTooltip("Select the local player character.");
ImGui.SameLine(); ImGui.SameLine();
raii.PushFont(UiBuilder.IconFont); raii.PushFont(UiBuilder.IconFont);
if (_inGPose) if (_inGPose)
@ -117,8 +116,7 @@ namespace Glamourer.Gui
} }
raii.PopFonts(); raii.PopFonts();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Select the current target, if it is in the list.");
ImGui.SetTooltip("Select the current target, if it is in the list.");
if (select == null) if (select == null)
return; return;

View file

@ -11,8 +11,7 @@ namespace Glamourer.Gui
if (DrawCheckMark(label, value, setter)) if (DrawCheckMark(label, value, setter))
Glamourer.Config.Save(); Glamourer.Config.Save();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
} }
private static void ChangeAndSave<T>(T value, T currentValue, Action<T> setter) where T : IEquatable<T> private static void ChangeAndSave<T>(T value, T currentValue, Action<T> setter) where T : IEquatable<T>
@ -34,13 +33,11 @@ namespace Glamourer.Gui
ImGui.SameLine(); ImGui.SameLine();
if (ImGui.Button($"Default##{name}")) if (ImGui.Button($"Default##{name}"))
ChangeAndSave(defaultValue, value, setter); ChangeAndSave(defaultValue, value, setter);
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(
ImGui.SetTooltip( $"Reset to default: #{defaultValue & 0xFF:X2}{(defaultValue >> 8) & 0xFF:X2}{(defaultValue >> 16) & 0xFF:X2}{defaultValue >> 24:X2}");
$"Reset to default: #{defaultValue & 0xFF:X2}{(defaultValue >> 8) & 0xFF:X2}{(defaultValue >> 16) & 0xFF:X2}{defaultValue >> 24:X2}");
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text(name); ImGui.Text(name);
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
} }
private void DrawRestorePenumbraButton() private void DrawRestorePenumbraButton()
@ -56,8 +53,7 @@ namespace Glamourer.Gui
if (ImGui.Button(buttonLabel)) if (ImGui.Button(buttonLabel))
Glamourer.Penumbra.Reattach(true); Glamourer.Penumbra.Reattach(true);
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(
ImGui.SetTooltip(
"If Penumbra did not register the functions for some reason, pressing this button might help restore functionality."); "If Penumbra did not register the functions for some reason, pressing this button might help restore functionality.");
} }

View file

@ -58,8 +58,7 @@ namespace Glamourer.Gui
ret = true; ret = true;
} }
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip($"Input Range: [{minValue}, {maxValue}]");
ImGui.SetTooltip($"Input Range: [{minValue}, {maxValue}]");
return ret; return ret;
} }
@ -103,8 +102,7 @@ namespace Glamourer.Gui
ImGui.Text(label); ImGui.Text(label);
if (tooltip.Any() && ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
} }
if (!DrawColorPickerPopup(popupName, set, id, out var newCustom)) if (!DrawColorPickerPopup(popupName, set, id, out var newCustom))
@ -148,8 +146,7 @@ namespace Glamourer.Gui
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text(label); ImGui.Text(label);
if (tooltip.Any() && ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
return ret; return ret;
} }
@ -286,8 +283,7 @@ namespace Glamourer.Gui
customization[CustomizationId.Face] = (byte) ((customization[CustomizationId.Hairstyle] + 1) / 2); customization[CustomizationId.Face] = (byte) ((customization[CustomizationId.Hairstyle] + 1) / 2);
ImGui.Text(label); ImGui.Text(label);
if (tooltip.Any() && ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
return ret; return ret;
} }
@ -317,8 +313,7 @@ namespace Glamourer.Gui
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text(label); ImGui.Text(label);
if (tooltip.Any() && ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip(tooltip);
ImGui.SetTooltip(tooltip);
return ret; return ret;
} }

View file

@ -44,8 +44,7 @@ namespace Glamourer.Gui
if (_selection!.Data.WriteProtected) if (_selection!.Data.WriteProtected)
ImGui.PopStyleVar(); ImGui.PopStyleVar();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Overwrite with customization code from clipboard.");
ImGui.SetTooltip("Overwrite with customization code from clipboard.");
if (_selection!.Data.WriteProtected || !applyButton) if (_selection!.Data.WriteProtected || !applyButton)
return; return;
@ -71,8 +70,7 @@ namespace Glamourer.Gui
if (ImGui.Button(FontAwesomeIcon.FolderPlus.ToIconString(), Vector2.UnitX * SelectorWidth / 5)) if (ImGui.Button(FontAwesomeIcon.FolderPlus.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
OpenDesignNamePopup(DesignNameUse.NewFolder); OpenDesignNamePopup(DesignNameUse.NewFolder);
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Create a new, empty Folder.");
ImGui.SetTooltip("Create a new, empty Folder.");
DrawDesignNamePopup(DesignNameUse.NewFolder); DrawDesignNamePopup(DesignNameUse.NewFolder);
} }
@ -83,8 +81,7 @@ namespace Glamourer.Gui
if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), Vector2.UnitX * SelectorWidth / 5)) if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
OpenDesignNamePopup(DesignNameUse.NewDesign); OpenDesignNamePopup(DesignNameUse.NewDesign);
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Create a new, empty Design.");
ImGui.SetTooltip("Create a new, empty Design.");
DrawDesignNamePopup(DesignNameUse.NewDesign); DrawDesignNamePopup(DesignNameUse.NewDesign);
} }
@ -95,8 +92,7 @@ namespace Glamourer.Gui
if (ImGui.Button(FontAwesomeIcon.Paste.ToIconString(), Vector2.UnitX * SelectorWidth / 5)) if (ImGui.Button(FontAwesomeIcon.Paste.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
OpenDesignNamePopup(DesignNameUse.FromClipboard); OpenDesignNamePopup(DesignNameUse.FromClipboard);
ImGui.PopFont(); ImGui.PopFont();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Create a new design from the customization string in your clipboard.");
ImGui.SetTooltip("Create a new design from the customization string in your clipboard.");
DrawDesignNamePopup(DesignNameUse.FromClipboard); DrawDesignNamePopup(DesignNameUse.FromClipboard);
} }
@ -116,8 +112,7 @@ namespace Glamourer.Gui
ImGui.PopFont(); ImGui.PopFont();
if (style) if (style)
ImGui.PopStyleVar(); ImGui.PopStyleVar();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Delete the currently selected Design.");
ImGui.SetTooltip("Delete the currently selected Design.");
} }
private void DrawDuplicateDesignButton() private void DrawDuplicateDesignButton()
@ -130,8 +125,7 @@ namespace Glamourer.Gui
ImGui.PopFont(); ImGui.PopFont();
if (_selection == null) if (_selection == null)
ImGui.PopStyleVar(); ImGui.PopStyleVar();
if (ImGui.IsItemHovered()) ImGuiCustom.HoverTooltip("Clone the currently selected Design.");
ImGui.SetTooltip("Clone the currently selected Design.");
DrawDesignNamePopup(DesignNameUse.DuplicateDesign); DrawDesignNamePopup(DesignNameUse.DuplicateDesign);
} }

View file

@ -1,4 +1,5 @@
using ImGuiNET; using Dalamud.Interface;
using ImGuiNET;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs; using Penumbra.GameData.Structs;
@ -15,39 +16,53 @@ namespace Glamourer.Gui
stainCombo.PostPreview = () => ImGui.PopStyleColor(previewPush); stainCombo.PostPreview = () => ImGui.PopStyleColor(previewPush);
} }
if (stainCombo.Draw(string.Empty, out var newStain) && !newStain.RowIndex.Equals(stainIdx)) var change = stainCombo.Draw(string.Empty, out var newStain) && !newStain.RowIndex.Equals(stainIdx);
if (!change && (byte) stainIdx != 0)
{ {
if (_player != null) ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{ {
Glamourer.RevertableDesigns.Add(_player); change = true;
newStain.Write(_player.Address, slot); newStain = Stain.None;
return true;
} }
if (_inDesignMode && (_selection?.Data.WriteStain(slot, newStain.RowIndex) ?? false))
return true;
} }
return false; if (!change)
return false;
if (_player == null)
return _inDesignMode && (_selection?.Data.WriteStain(slot, newStain.RowIndex) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newStain.Write(_player.Address, slot);
return true;
} }
private bool DrawItemSelector(ComboWithFilter<Item> equipCombo, Lumina.Excel.GeneratedSheets.Item? item) private bool DrawItemSelector(ComboWithFilter<Item> equipCombo, Lumina.Excel.GeneratedSheets.Item? item, EquipSlot slot = EquipSlot.Unknown)
{ {
var currentName = item?.Name.ToString() ?? "Nothing"; var currentName = item?.Name.ToString() ?? Item.Nothing(slot).Name;
if (equipCombo.Draw(currentName, out var newItem, _itemComboWidth) && newItem.Base.RowId != item?.RowId) var change = equipCombo.Draw(currentName, out var newItem, _itemComboWidth) && newItem.Base.RowId != item?.RowId;
if (!change && item != null)
{ {
if (_player != null) ImGuiCustom.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{ {
Glamourer.RevertableDesigns.Add(_player); change = true;
newItem.Write(_player.Address); newItem = Item.Nothing(slot);
return true;
} }
if (_inDesignMode && (_selection?.Data.WriteItem(newItem) ?? false))
return true;
} }
return false; if (!change)
return false;
if (_player == null)
return _inDesignMode && (_selection?.Data.WriteItem(newItem) ?? false);
Glamourer.RevertableDesigns.Add(_player);
newItem.Write(_player.Address);
return true;
} }
private static bool DrawCheckbox(CharacterEquipMask flag, ref CharacterEquipMask mask) private static bool DrawCheckbox(CharacterEquipMask flag, ref CharacterEquipMask mask)
@ -72,7 +87,7 @@ namespace Glamourer.Gui
var ret = DrawStainSelector(stainCombo, slot, equip.Stain); var ret = DrawStainSelector(stainCombo, slot, equip.Stain);
ImGui.SameLine(); ImGui.SameLine();
var item = _identifier.Identify(equip.Set, new WeaponType(), equip.Variant, slot); var item = _identifier.Identify(equip.Set, new WeaponType(), equip.Variant, slot);
ret |= DrawItemSelector(equipCombo, item); ret |= DrawItemSelector(equipCombo, item, slot);
return ret; return ret;
} }
@ -92,7 +107,7 @@ namespace Glamourer.Gui
var ret = DrawStainSelector(stainCombo, slot, weapon.Stain); var ret = DrawStainSelector(stainCombo, slot, weapon.Stain);
ImGui.SameLine(); ImGui.SameLine();
var item = _identifier.Identify(weapon.Set, weapon.Type, weapon.Variant, slot); var item = _identifier.Identify(weapon.Set, weapon.Type, weapon.Variant, slot);
ret |= DrawItemSelector(equipCombo, item); ret |= DrawItemSelector(equipCombo, item, slot);
return ret; return ret;
} }