Current state.

This commit is contained in:
Ottermandias 2026-01-29 18:02:11 +01:00
parent 20393be689
commit 4b005c1ca2
59 changed files with 793 additions and 861 deletions

View file

@ -1,13 +1,7 @@
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Glamourer.Designs;
using Glamourer.Designs;
using Glamourer.Interop.Material;
using Dalamud.Bindings.ImGui;
using ImSharp;
using Luna;
using OtterGui;
using OtterGui.Text;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Files.MaterialStructs;
@ -27,17 +21,17 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
public void Draw(Design design)
{
var available = ImGui.GetContentRegionAvail().X;
_spacing = ImGui.GetStyle().ItemInnerSpacing.X;
_buttonSize = new Vector2(ImGui.GetFrameHeight());
var available = Im.ContentRegion.Available.X;
_spacing = Im.Style.ItemInnerSpacing.X;
_buttonSize = new Vector2(Im.Style.FrameHeight);
var colorWidth = 4 * _buttonSize.X
+ (GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale
+ (GlossWidth + SpecularStrengthWidth) * Im.Style.GlobalScale
+ 6 * _spacing
+ ImUtf8.CalcTextSize("Revert"u8).X;
+ Im.Font.CalculateSize("Revert"u8).X;
DrawMultiButtons(design);
ImUtf8.Dummy(0);
ImGui.Separator();
ImUtf8.Dummy(0);
Im.Dummy(0);
Im.Separator();
Im.Dummy(0);
if (available > 1.95 * colorWidth)
DrawSingleRow(design);
else
@ -49,63 +43,63 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
{
var any = design.Materials.Count > 0;
var disabled = !config.DeleteDesignModifier.IsActive();
var size = new Vector2(200 * ImUtf8.GlobalScale, 0);
if (ImUtf8.ButtonEx("Enable All Advanced Dyes"u8,
var size = new Vector2(200 * Im.Style.GlobalScale, 0);
if (ImEx.Button("Enable All Advanced Dyes"u8, size,
any
? "Enable the application of all contained advanced dyes without deleting them."u8
: "This design does not contain any advanced dyes."u8, size,
: "This design does not contain any advanced dyes."u8,
!any || disabled))
designManager.ChangeApplyMulti(design, null, null, null, null, null, null, true, null);
;
designManager.ChangeApplyMulti(design, null, null, null, null, null, null, true, null);
if (disabled && any)
ImUtf8.HoverTooltip($"Hold {config.DeleteDesignModifier} while clicking to enable.");
Im.Tooltip.OnHover($"Hold {config.DeleteDesignModifier} while clicking to enable.");
Im.Line.Same();
if (ImUtf8.ButtonEx("Disable All Advanced Dyes"u8,
if (ImEx.Button("Disable All Advanced Dyes"u8, size,
any
? "Disable the application of all contained advanced dyes without deleting them."u8
: "This design does not contain any advanced dyes."u8, size,
: "This design does not contain any advanced dyes."u8,
!any || disabled))
designManager.ChangeApplyMulti(design, null, null, null, null, null, null, false, null);
if (disabled && any)
ImUtf8.HoverTooltip($"Hold {config.DeleteDesignModifier} while clicking to disable.");
Im.Tooltip.OnHover($"Hold {config.DeleteDesignModifier} while clicking to disable.");
if (ImUtf8.ButtonEx("Delete All Advanced Dyes"u8, any ? ""u8 : "This design does not contain any advanced dyes."u8, size,
if (ImEx.Button("Delete All Advanced Dyes"u8, size, any ? StringU8.Empty : "This design does not contain any advanced dyes."u8,
!any || disabled))
while (design.Materials.Count > 0)
designManager.ChangeMaterialValue(design, MaterialValueIndex.FromKey(design.Materials[0].Item1), null);
if (disabled && any)
ImUtf8.HoverTooltip($"Hold {config.DeleteDesignModifier} while clicking to delete.");
Im.Tooltip.OnHover($"Hold {config.DeleteDesignModifier} while clicking to delete.");
}
private void DrawName(MaterialValueIndex index)
{
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0.05f, 0.5f));
ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0),
borderColor: ImGui.GetColorU32(ImGuiCol.Text));
using var style = ImStyleDouble.ButtonTextAlign.Push(new Vector2(0.05f, 0.5f));
ImEx.TextFramed($"{index}", new Vector2((GlossWidth + SpecularStrengthWidth) * Im.Style.GlobalScale + _spacing, 0),
borderColor: ImGuiColor.Text.Get());
}
private void DrawSingleRow(Design design)
{
for (var i = 0; i < design.Materials.Count; ++i)
{
using var id = ImRaii.PushId(i);
using var id = Im.Id.Push(i);
var (idx, value) = design.Materials[i];
var key = MaterialValueIndex.FromKey(idx);
DrawName(key);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
DeleteButton(design, key, ref i);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
CopyButton(value.Value);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
PasteButton(design, key);
ImGui.SameLine(0, _spacing);
using var disabled = ImRaii.Disabled(design.WriteProtected());
Im.Line.Same(0, _spacing);
using var disabled = Im.Disabled(design.WriteProtected());
EnabledToggle(design, key, value.Enabled);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
DrawRow(design, key, value.Value, value.Revert);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
RevertToggle(design, key, value.Revert);
}
}
@ -114,32 +108,32 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
{
for (var i = 0; i < design.Materials.Count; ++i)
{
using var id = ImRaii.PushId(i);
using var id = Im.Id.Push(i);
var (idx, value) = design.Materials[i];
var key = MaterialValueIndex.FromKey(idx);
DrawName(key);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
DeleteButton(design, key, ref i);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
CopyButton(value.Value);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
PasteButton(design, key);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
EnabledToggle(design, key, value.Enabled);
DrawRow(design, key, value.Value, value.Revert);
ImGui.SameLine(0, _spacing);
Im.Line.Same(0, _spacing);
RevertToggle(design, key, value.Revert);
ImGui.Separator();
Im.Separator();
}
}
private void DeleteButton(Design design, MaterialValueIndex index, ref int idx)
{
var deleteEnabled = config.DeleteDesignModifier.IsActive();
if (!ImUtf8.IconButton(FontAwesomeIcon.Trash,
if (!ImEx.Icon.Button(LunaStyle.DeleteIcon,
$"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {config.DeleteDesignModifier} to delete.")}", disabled:
!deleteEnabled || design.WriteProtected()))
return;
@ -150,28 +144,28 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
private void CopyButton(in ColorRow row)
{
if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8))
if (ImEx.Icon.Button(LunaStyle.ToClipboardIcon, "Export this row to your clipboard."u8))
ColorRowClipboard.Row = row;
}
private void PasteButton(Design design, MaterialValueIndex index)
{
if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8,
if (ImEx.Icon.Button(LunaStyle.FromClipboardIcon, "Import an exported row from your clipboard onto this row."u8,
disabled: !ColorRowClipboard.IsSet || design.WriteProtected()))
designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row);
}
private void EnabledToggle(Design design, MaterialValueIndex index, bool enabled)
{
if (ImUtf8.Checkbox("Enabled"u8, ref enabled))
if (Im.Checkbox("Enabled"u8, ref enabled))
designManager.ChangeApplyMaterialValue(design, index, enabled);
}
private void RevertToggle(Design design, MaterialValueIndex index, bool revert)
{
if (ImUtf8.Checkbox("Revert"u8, ref revert))
if (Im.Checkbox("Revert"u8, ref revert))
designManager.ChangeMaterialRevert(design, index, revert);
ImUtf8.HoverTooltip(
Im.Tooltip.OnHover(
"If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8);
}
@ -179,15 +173,15 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
private void DrawSlotCombo()
{
var width = ImUtf8.CalcTextSize(EquipSlot.OffHand.ToName()).X + ImGui.GetFrameHeightWithSpacing();
ImGui.SetNextItemWidth(width);
using var combo = ImUtf8.Combo("##slot"u8, _newKey.SlotName());
var width = Im.Font.CalculateSize(EquipSlot.OffHand.ToNameU8()).X + Im.Style.FrameHeightWithSpacing;
Im.Item.SetNextWidth(width);
using var combo = Im.Combo.Begin("##slot"u8, _newKey.SlotName());
if (combo)
{
var currentSlot = _newKey.ToEquipSlot();
foreach (var tmpSlot in EquipSlotExtensions.FullSlots)
{
if (ImUtf8.Selectable(tmpSlot.ToName(), tmpSlot == currentSlot) && currentSlot != tmpSlot)
if (Im.Selectable(tmpSlot.ToNameU8(), tmpSlot == currentSlot) && currentSlot != tmpSlot)
_newKey = MaterialValueIndex.FromSlot(tmpSlot) with
{
MaterialIndex = (byte)_newMaterialIdx,
@ -198,7 +192,7 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
var currentBonus = _newKey.ToBonusSlot();
foreach (var bonusSlot in BonusExtensions.AllFlags)
{
if (ImUtf8.Selectable(bonusSlot.ToName(), bonusSlot == currentBonus) && bonusSlot != currentBonus)
if (Im.Selectable(bonusSlot.ToNameU8(), bonusSlot == currentBonus) && bonusSlot != currentBonus)
_newKey = MaterialValueIndex.FromSlot(bonusSlot) with
{
MaterialIndex = (byte)_newMaterialIdx,
@ -207,68 +201,65 @@ public class MaterialDrawer(DesignManager designManager, Configuration config) :
}
}
ImUtf8.HoverTooltip("Choose a slot for an advanced dye row."u8);
Im.Tooltip.OnHover("Choose a slot for an advanced dye row."u8);
}
public void DrawNew(Design design)
{
DrawSlotCombo();
ImUtf8.SameLineInner();
Im.Line.SameInner();
DrawMaterialIdxDrag();
ImUtf8.SameLineInner();
Im.Line.SameInner();
DrawRowIdxDrag();
ImUtf8.SameLineInner();
Im.Line.SameInner();
var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _);
if (ImUtf8.ButtonEx("Add New Row"u8,
exists ? "The selected advanced dye row already exists."u8 : "Add the selected advanced dye row."u8, Vector2.Zero,
if (ImEx.Button("Add New Row"u8, Vector2.Zero,
exists ? "The selected advanced dye row already exists."u8 : "Add the selected advanced dye row."u8,
exists || design.WriteProtected()))
designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty);
}
private void DrawMaterialIdxDrag()
{
ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Material AA"u8).X);
var format = $"Material {(char)('A' + _newMaterialIdx)}";
if (ImUtf8.DragScalar("##Material"u8, ref _newMaterialIdx, format, 0, MaterialService.MaterialsPerModel - 1, 0.01f,
ImGuiSliderFlags.NoInput))
Im.Item.SetNextWidth(Im.Font.CalculateSize("Material AA"u8).X);
if (Im.Drag("##Material"u8, ref _newMaterialIdx, $"Material {(char)('A' + _newMaterialIdx)}", 0, MaterialService.MaterialsPerModel - 1, 0.01f, SliderFlags.NoInput))
{
_newMaterialIdx = Math.Clamp(_newMaterialIdx, 0, MaterialService.MaterialsPerModel - 1);
_newKey = _newKey with { MaterialIndex = (byte)_newMaterialIdx };
}
ImUtf8.HoverTooltip("Drag this to the left or right to change its value."u8);
Im.Tooltip.OnHover("Drag this to the left or right to change its value."u8);
}
private void DrawRowIdxDrag()
{
ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Row 0000"u8).X);
var format = $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}";
if (ImUtf8.DragScalar("##Row"u8, ref _newRowIdx, format, 0, ColorTable.NumRows - 1, 0.01f, ImGuiSliderFlags.NoInput))
Im.Item.SetNextWidth(Im.Font.CalculateSize("Row 0000"u8).X);
if (Im.Drag("##Row"u8, ref _newRowIdx, $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}", 0, ColorTable.NumRows - 1, 0.01f, SliderFlags.NoInput))
{
_newRowIdx = Math.Clamp(_newRowIdx, 0, ColorTable.NumRows - 1);
_newKey = _newKey with { RowIndex = (byte)_newRowIdx };
}
ImUtf8.HoverTooltip("Drag this to the left or right to change its value."u8);
Im.Tooltip.OnHover("Drag this to the left or right to change its value."u8);
}
private void DrawRow(Design design, MaterialValueIndex index, in ColorRow row, bool disabled)
{
var tmp = row;
using var _ = ImRaii.Disabled(disabled);
using var _ = Im.Disabled(disabled);
var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", row.Diffuse, v => tmp.Diffuse = v, "D");
ImUtf8.SameLineInner();
Im.Line.SameInner();
applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", row.Specular, v => tmp.Specular = v, "S");
ImUtf8.SameLineInner();
Im.Line.SameInner();
applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E");
ImUtf8.SameLineInner();
ImGui.SetNextItemWidth(GlossWidth * ImGuiHelpers.GlobalScale);
Im.Line.SameInner();
Im.Item.SetNextWidth(GlossWidth * Im.Style.GlobalScale);
applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength);
ImUtf8.HoverTooltip("Change the gloss strength for this row."u8);
ImUtf8.SameLineInner();
ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale);
Im.Tooltip.OnHover("Change the gloss strength for this row."u8);
Im.Line.SameInner();
Im.Item.SetNextWidth(SpecularStrengthWidth * Im.Style.GlobalScale);
applied |= AdvancedDyePopup.DragSpecularStrength(ref tmp.SpecularStrength);
ImUtf8.HoverTooltip("Change the specular strength for this row."u8);
Im.Tooltip.OnHover("Change the specular strength for this row."u8);
if (applied)
designManager.ChangeMaterialValue(design, index, tmp);
}