mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 05:04:16 +01:00
Fix display and initial values of design color rows.
This commit is contained in:
parent
af58a52a59
commit
edc54203b5
2 changed files with 42 additions and 47 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Interface.Utility.Raii;
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using FFXIVClientStructs.FFXIV.Common.Lua;
|
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
using Glamourer.Interop.Material;
|
using Glamourer.Interop.Material;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
|
using OtterGui.Text;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
using Penumbra.GameData.Files.MaterialStructs;
|
using Penumbra.GameData.Files.MaterialStructs;
|
||||||
using Penumbra.GameData.Gui;
|
using Penumbra.GameData.Gui;
|
||||||
|
|
@ -28,13 +28,13 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
|
|
||||||
public void Draw(Design design)
|
public void Draw(Design design)
|
||||||
{
|
{
|
||||||
var available = ImGui.GetContentRegionAvail().X;
|
var available = ImGui.GetContentRegionAvail().X;
|
||||||
_spacing = ImGui.GetStyle().ItemInnerSpacing.X;
|
_spacing = ImGui.GetStyle().ItemInnerSpacing.X;
|
||||||
_buttonSize = new Vector2(ImGui.GetFrameHeight());
|
_buttonSize = new Vector2(ImGui.GetFrameHeight());
|
||||||
var colorWidth = 4 * _buttonSize.X
|
var colorWidth = 4 * _buttonSize.X
|
||||||
+ (GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale
|
+ (GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale
|
||||||
+ 6 * _spacing
|
+ 6 * _spacing
|
||||||
+ ImGui.CalcTextSize("Revert").X;
|
+ ImUtf8.CalcTextSize("Revert"u8).X;
|
||||||
if (available > 1.95 * colorWidth)
|
if (available > 1.95 * colorWidth)
|
||||||
DrawSingleRow(design);
|
DrawSingleRow(design);
|
||||||
else
|
else
|
||||||
|
|
@ -44,9 +44,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
|
|
||||||
private void DrawName(MaterialValueIndex index)
|
private void DrawName(MaterialValueIndex index)
|
||||||
{
|
{
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale).Push(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
|
||||||
using var color = ImRaii.PushColor(ImGuiCol.Border, ImGui.GetColorU32(ImGuiCol.Text));
|
ImUtf8.TextFramed(index.ToString(), 0, new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0),
|
||||||
ImGuiUtil.DrawTextButton(index.ToString(), new Vector2((GlossWidth + SpecularStrengthWidth) * ImGuiHelpers.GlobalScale + _spacing, 0), 0);
|
borderColor: ImGui.GetColorU32(ImGuiCol.Text));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawSingleRow(Design design)
|
private void DrawSingleRow(Design design)
|
||||||
|
|
@ -55,11 +55,11 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId(i);
|
using var id = ImRaii.PushId(i);
|
||||||
var (idx, value) = design.Materials[i];
|
var (idx, value) = design.Materials[i];
|
||||||
var key = MaterialValueIndex.FromKey(idx);
|
var key = MaterialValueIndex.FromKey(idx);
|
||||||
|
|
||||||
DrawName(key);
|
DrawName(key);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImGui.SameLine(0, _spacing);
|
||||||
DeleteButton(design, key, ref i);
|
DeleteButton(design, key, ref i);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImGui.SameLine(0, _spacing);
|
||||||
CopyButton(value.Value);
|
CopyButton(value.Value);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImGui.SameLine(0, _spacing);
|
||||||
|
|
@ -91,7 +91,7 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
PasteButton(design, key);
|
PasteButton(design, key);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImGui.SameLine(0, _spacing);
|
||||||
EnabledToggle(design, key, value.Enabled);
|
EnabledToggle(design, key, value.Enabled);
|
||||||
|
|
||||||
|
|
||||||
DrawRow(design, key, value.Value, value.Revert);
|
DrawRow(design, key, value.Value, value.Revert);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImGui.SameLine(0, _spacing);
|
||||||
|
|
@ -103,9 +103,9 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
private void DeleteButton(Design design, MaterialValueIndex index, ref int idx)
|
private void DeleteButton(Design design, MaterialValueIndex index, ref int idx)
|
||||||
{
|
{
|
||||||
var deleteEnabled = _config.DeleteDesignModifier.IsActive();
|
var deleteEnabled = _config.DeleteDesignModifier.IsActive();
|
||||||
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _buttonSize,
|
if (!ImUtf8.IconButton(FontAwesomeIcon.Trash,
|
||||||
$"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}",
|
$"Delete this color row.{(deleteEnabled ? string.Empty : $"\nHold {_config.DeleteDesignModifier} to delete.")}", disabled:
|
||||||
!deleteEnabled || design.WriteProtected(), true))
|
!deleteEnabled || design.WriteProtected()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_designManager.ChangeMaterialValue(design, index, null);
|
_designManager.ChangeMaterialValue(design, index, null);
|
||||||
|
|
@ -114,31 +114,29 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
|
|
||||||
private void CopyButton(in ColorRow row)
|
private void CopyButton(in ColorRow row)
|
||||||
{
|
{
|
||||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Clipboard.ToIconString(), _buttonSize, "Export this row to your clipboard.",
|
if (ImUtf8.IconButton(FontAwesomeIcon.Clipboard, "Export this row to your clipboard."u8))
|
||||||
false,
|
|
||||||
true))
|
|
||||||
ColorRowClipboard.Row = row;
|
ColorRowClipboard.Row = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PasteButton(Design design, MaterialValueIndex index)
|
private void PasteButton(Design design, MaterialValueIndex index)
|
||||||
{
|
{
|
||||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), _buttonSize,
|
if (ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8,
|
||||||
"Import an exported row from your clipboard onto this row.", !ColorRowClipboard.IsSet || design.WriteProtected(), true))
|
disabled: !ColorRowClipboard.IsSet || design.WriteProtected()))
|
||||||
_designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row);
|
_designManager.ChangeMaterialValue(design, index, ColorRowClipboard.Row);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnabledToggle(Design design, MaterialValueIndex index, bool enabled)
|
private void EnabledToggle(Design design, MaterialValueIndex index, bool enabled)
|
||||||
{
|
{
|
||||||
if (ImGui.Checkbox("Enabled", ref enabled))
|
if (ImUtf8.Checkbox("Enabled"u8, ref enabled))
|
||||||
_designManager.ChangeApplyMaterialValue(design, index, enabled);
|
_designManager.ChangeApplyMaterialValue(design, index, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RevertToggle(Design design, MaterialValueIndex index, bool revert)
|
private void RevertToggle(Design design, MaterialValueIndex index, bool revert)
|
||||||
{
|
{
|
||||||
if (ImGui.Checkbox("Revert", ref revert))
|
if (ImUtf8.Checkbox("Revert"u8, ref revert))
|
||||||
_designManager.ChangeMaterialRevert(design, index, revert);
|
_designManager.ChangeMaterialRevert(design, index, revert);
|
||||||
ImGuiUtil.HoverTooltip(
|
ImUtf8.HoverTooltip(
|
||||||
"If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row.");
|
"If this is checked, Glamourer will try to revert the advanced dye row to its game state instead of applying a specific row."u8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawNew(Design design)
|
public void DrawNew(Design design)
|
||||||
|
|
@ -149,41 +147,38 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
MaterialIndex = (byte)_newMaterialIdx,
|
MaterialIndex = (byte)_newMaterialIdx,
|
||||||
RowIndex = (byte)_newRowIdx,
|
RowIndex = (byte)_newRowIdx,
|
||||||
};
|
};
|
||||||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
ImUtf8.SameLineInner();
|
||||||
DrawMaterialIdxDrag();
|
DrawMaterialIdxDrag();
|
||||||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
ImUtf8.SameLineInner();
|
||||||
DrawRowIdxDrag();
|
DrawRowIdxDrag();
|
||||||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
ImUtf8.SameLineInner();
|
||||||
var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _);
|
var exists = design.GetMaterialDataRef().TryGetValue(_newKey, out _);
|
||||||
if (ImGuiUtil.DrawDisabledButton("Add New Row", Vector2.Zero,
|
if (ImUtf8.ButtonEx("Add New Row"u8,
|
||||||
exists ? "The selected advanced dye row already exists." : "Add the selected advanced dye row.", exists || design.WriteProtected()))
|
exists ? "The selected advanced dye row already exists."u8 : "Add the selected advanced dye row."u8, Vector2.Zero,
|
||||||
|
exists || design.WriteProtected()))
|
||||||
_designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty);
|
_designManager.ChangeMaterialValue(design, _newKey, ColorRow.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMaterialIdxDrag()
|
private void DrawMaterialIdxDrag()
|
||||||
{
|
{
|
||||||
_newMaterialIdx += 1;
|
ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Material AA"u8).X);
|
||||||
ImGui.SetNextItemWidth(ImGui.CalcTextSize("Material #000").X);
|
var format = $"Material {(char)('A' + _newMaterialIdx)}";
|
||||||
if (ImGui.DragInt("##Material", ref _newMaterialIdx, 0.01f, 1, MaterialService.MaterialsPerModel, "Material #%i"))
|
if (ImUtf8.DragScalar("##Material"u8, ref _newMaterialIdx, format, 0, MaterialService.MaterialsPerModel - 1, 0.01f))
|
||||||
{
|
{
|
||||||
_newMaterialIdx = Math.Clamp(_newMaterialIdx, 1, MaterialService.MaterialsPerModel);
|
_newMaterialIdx = Math.Clamp(_newMaterialIdx, 0, MaterialService.MaterialsPerModel - 1);
|
||||||
_newKey = _newKey with { MaterialIndex = (byte)(_newMaterialIdx - 1) };
|
_newKey = _newKey with { MaterialIndex = (byte)_newMaterialIdx };
|
||||||
}
|
}
|
||||||
|
|
||||||
_newMaterialIdx -= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRowIdxDrag()
|
private void DrawRowIdxDrag()
|
||||||
{
|
{
|
||||||
_newRowIdx += 1;
|
ImGui.SetNextItemWidth(ImUtf8.CalcTextSize("Row 0000"u8).X);
|
||||||
ImGui.SetNextItemWidth(ImGui.CalcTextSize("Row #0000").X);
|
var format = $"Row {_newRowIdx / 2 + 1}{(char)(_newRowIdx % 2 + 'A')}";
|
||||||
if (ImGui.DragInt("##Row", ref _newRowIdx, 0.01f, 1, ColorTable.NumRows, "Row #%i"))
|
if (ImUtf8.DragScalar("##Row"u8, ref _newRowIdx, format, 0, ColorTable.NumRows - 1, 0.01f))
|
||||||
{
|
{
|
||||||
_newRowIdx = Math.Clamp(_newRowIdx, 1, ColorTable.NumRows);
|
_newRowIdx = Math.Clamp(_newRowIdx, 0, ColorTable.NumRows - 1);
|
||||||
_newKey = _newKey with { RowIndex = (byte)(_newRowIdx - 1) };
|
_newKey = _newKey with { RowIndex = (byte)_newRowIdx };
|
||||||
}
|
}
|
||||||
|
|
||||||
_newRowIdx -= 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawRow(Design design, MaterialValueIndex index, in ColorRow row, bool disabled)
|
private void DrawRow(Design design, MaterialValueIndex index, in ColorRow row, bool disabled)
|
||||||
|
|
@ -191,18 +186,18 @@ public class MaterialDrawer(DesignManager _designManager, Configuration _config)
|
||||||
var tmp = row;
|
var tmp = row;
|
||||||
using var _ = ImRaii.Disabled(disabled);
|
using var _ = ImRaii.Disabled(disabled);
|
||||||
var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", row.Diffuse, v => tmp.Diffuse = v, "D");
|
var applied = ImGuiUtil.ColorPicker("##diffuse", "Change the diffuse value for this row.", row.Diffuse, v => tmp.Diffuse = v, "D");
|
||||||
ImGui.SameLine(0, _spacing);
|
ImUtf8.SameLineInner();
|
||||||
applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", row.Specular, v => tmp.Specular = v, "S");
|
applied |= ImGuiUtil.ColorPicker("##specular", "Change the specular value for this row.", row.Specular, v => tmp.Specular = v, "S");
|
||||||
ImGui.SameLine(0, _spacing);
|
ImUtf8.SameLineInner();
|
||||||
applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E");
|
applied |= ImGuiUtil.ColorPicker("##emissive", "Change the emissive value for this row.", row.Emissive, v => tmp.Emissive = v, "E");
|
||||||
ImGui.SameLine(0, _spacing);
|
ImUtf8.SameLineInner();
|
||||||
ImGui.SetNextItemWidth(GlossWidth * ImGuiHelpers.GlobalScale);
|
ImGui.SetNextItemWidth(GlossWidth * ImGuiHelpers.GlobalScale);
|
||||||
applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength);
|
applied |= AdvancedDyePopup.DragGloss(ref tmp.GlossStrength);
|
||||||
ImGuiUtil.HoverTooltip("Change the gloss strength for this row.");
|
ImUtf8.HoverTooltip("Change the gloss strength for this row."u8);
|
||||||
ImGui.SameLine(0, _spacing);
|
ImUtf8.SameLineInner();
|
||||||
ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale);
|
ImGui.SetNextItemWidth(SpecularStrengthWidth * ImGuiHelpers.GlobalScale);
|
||||||
applied |= AdvancedDyePopup.DragSpecularStrength(ref tmp.SpecularStrength);
|
applied |= AdvancedDyePopup.DragSpecularStrength(ref tmp.SpecularStrength);
|
||||||
ImGuiUtil.HoverTooltip("Change the specular strength for this row.");
|
ImUtf8.HoverTooltip("Change the specular strength for this row."u8);
|
||||||
if (applied)
|
if (applied)
|
||||||
_designManager.ChangeMaterialValue(design, index, tmp);
|
_designManager.ChangeMaterialValue(design, index, tmp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public struct ColorRow(Vector3 diffuse, Vector3 specular, Vector3 emissive, floa
|
||||||
Dawntrail,
|
Dawntrail,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly ColorRow Empty = new(Vector3.Zero, Vector3.Zero, Vector3.Zero, 0, 0);
|
public static readonly ColorRow Empty = new(Vector3.Zero, Vector3.Zero, Vector3.Zero, 1f, 1f);
|
||||||
|
|
||||||
public Vector3 Diffuse = diffuse;
|
public Vector3 Diffuse = diffuse;
|
||||||
public Vector3 Specular = specular;
|
public Vector3 Specular = specular;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue