mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-19 07:04:23 +01:00
Add some better handling for Highlights, add copy/paste buttons for colors.
This commit is contained in:
parent
805e192d63
commit
d13e3ccbd7
5 changed files with 113 additions and 36 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Glamourer.GameData;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Glamourer.GameData;
|
||||||
|
|
||||||
public readonly struct CustomizeParameterValue
|
public readonly struct CustomizeParameterValue
|
||||||
{
|
{
|
||||||
|
|
@ -47,4 +49,30 @@ public readonly struct CustomizeParameterValue
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
=> _data.ToString();
|
=> _data.ToString();
|
||||||
|
|
||||||
|
public string ToJson()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return JsonConvert.SerializeObject(_data, Formatting.None);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool FromJson(string input, out CustomizeParameterValue value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
value = new CustomizeParameterValue(JsonConvert.DeserializeObject<Vector4>(input));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
value = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Glamourer.Designs;
|
using Dalamud.Interface;
|
||||||
|
using Glamourer.Designs;
|
||||||
using Glamourer.GameData;
|
using Glamourer.GameData;
|
||||||
using Glamourer.Interop.PalettePlus;
|
using Glamourer.Interop.PalettePlus;
|
||||||
using Glamourer.State;
|
using Glamourer.State;
|
||||||
|
|
@ -17,17 +18,20 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
private CustomizeParameterFlag _flags;
|
private CustomizeParameterFlag _flags;
|
||||||
private float _width;
|
private float _width;
|
||||||
|
|
||||||
|
|
||||||
public void Draw(DesignManager designManager, Design design)
|
public void Draw(DesignManager designManager, Design design)
|
||||||
{
|
{
|
||||||
using var _ = EnsureSize();
|
using var generalSize = EnsureSize();
|
||||||
DrawPaletteImport(designManager, design);
|
DrawPaletteImport(designManager, design);
|
||||||
DrawConfig(true);
|
DrawConfig(true);
|
||||||
foreach (var flag in CustomizeParameterExtensions.RgbFlags)
|
|
||||||
DrawColorInput3(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.RgbaFlags)
|
using (_ = ImRaii.ItemWidth(_width - 2 * ImGui.GetFrameHeight() - 2 * ImGui.GetStyle().ItemInnerSpacing.X))
|
||||||
DrawColorInput4(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
{
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.RgbFlags)
|
||||||
|
DrawColorInput3(CustomizeParameterDrawData.FromDesign(designManager, design, flag), true);
|
||||||
|
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.RgbaFlags)
|
||||||
|
DrawColorInput4(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.PercentageFlags)
|
foreach (var flag in CustomizeParameterExtensions.PercentageFlags)
|
||||||
DrawPercentageInput(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
DrawPercentageInput(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
||||||
|
|
@ -36,6 +40,26 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
DrawValueInput(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
DrawValueInput(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Draw(StateManager stateManager, ActorState state)
|
||||||
|
{
|
||||||
|
using var _ = EnsureSize();
|
||||||
|
DrawConfig(false);
|
||||||
|
using (_ = ImRaii.ItemWidth(_width - 2 * ImGui.GetFrameHeight() - 2 * ImGui.GetStyle().ItemInnerSpacing.X))
|
||||||
|
{
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.RgbFlags)
|
||||||
|
DrawColorInput3(CustomizeParameterDrawData.FromState(stateManager, state, flag), state.ModelData.Customize.Highlights);
|
||||||
|
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.RgbaFlags)
|
||||||
|
DrawColorInput4(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.PercentageFlags)
|
||||||
|
DrawPercentageInput(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
||||||
|
|
||||||
|
foreach (var flag in CustomizeParameterExtensions.ValueFlags)
|
||||||
|
DrawValueInput(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPaletteCombo()
|
private void DrawPaletteCombo()
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId("Palettes");
|
using var id = ImRaii.PushId("Palettes");
|
||||||
|
|
@ -97,24 +121,8 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(StateManager stateManager, ActorState state)
|
|
||||||
{
|
|
||||||
using var _ = EnsureSize();
|
|
||||||
DrawConfig(false);
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.RgbFlags)
|
|
||||||
DrawColorInput3(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.RgbaFlags)
|
private void DrawConfig(bool withApply)
|
||||||
DrawColorInput4(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.PercentageFlags)
|
|
||||||
DrawPercentageInput(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.ValueFlags)
|
|
||||||
DrawValueInput(CustomizeParameterDrawData.FromState(stateManager, state, flag));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DrawConfig(bool withApply)
|
|
||||||
{
|
{
|
||||||
if (!config.ShowColorConfig)
|
if (!config.ShowColorConfig)
|
||||||
return;
|
return;
|
||||||
|
|
@ -133,7 +141,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
"Hide the color configuration options from the Advanced Customization panel. You can re-enable it in Glamourers interface settings.");
|
"Hide the color configuration options from the Advanced Customization panel. You can re-enable it in Glamourers interface settings.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawColorDisplayOptions()
|
private void DrawColorDisplayOptions()
|
||||||
{
|
{
|
||||||
using var group = ImRaii.Group();
|
using var group = ImRaii.Group();
|
||||||
if (ImGui.RadioButton("RGB", config.UseRgbForColors) && !config.UseRgbForColors)
|
if (ImGui.RadioButton("RGB", config.UseRgbForColors) && !config.UseRgbForColors)
|
||||||
|
|
@ -150,7 +158,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawColorFormatOptions(bool withApply)
|
private void DrawColorFormatOptions(bool withApply)
|
||||||
{
|
{
|
||||||
var width = _width
|
var width = _width
|
||||||
- (ImGui.CalcTextSize("Float").X
|
- (ImGui.CalcTextSize("Float").X
|
||||||
|
|
@ -176,16 +184,22 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawColorInput3(in CustomizeParameterDrawData data)
|
private void DrawColorInput3(in CustomizeParameterDrawData data, bool allowHighlights)
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId((int)data.Flag);
|
using var id = ImRaii.PushId((int)data.Flag);
|
||||||
var value = data.CurrentValue.InternalTriple;
|
var value = data.CurrentValue.InternalTriple;
|
||||||
using (_ = ImRaii.Disabled(data.Locked))
|
var noHighlights = !allowHighlights && data.Flag is CustomizeParameterFlag.HairHighlight;
|
||||||
|
DrawCopyPasteButtons(data, data.Locked || noHighlights);
|
||||||
|
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||||
|
using (_ = ImRaii.Disabled(data.Locked || noHighlights))
|
||||||
{
|
{
|
||||||
if (ImGui.ColorEdit3("##value", ref value, GetFlags()))
|
if (ImGui.ColorEdit3("##value", ref value, GetFlags()))
|
||||||
data.ValueSetter(new CustomizeParameterValue(value));
|
data.ValueSetter(new CustomizeParameterValue(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noHighlights)
|
||||||
|
ImGuiUtil.HoverTooltip("Highlights are disabled in your regular customizations.", ImGuiHoveredFlags.AllowWhenDisabled);
|
||||||
|
|
||||||
DrawRevert(data);
|
DrawRevert(data);
|
||||||
|
|
||||||
DrawApplyAndLabel(data);
|
DrawApplyAndLabel(data);
|
||||||
|
|
@ -195,6 +209,8 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId((int)data.Flag);
|
using var id = ImRaii.PushId((int)data.Flag);
|
||||||
var value = data.CurrentValue.InternalQuadruple;
|
var value = data.CurrentValue.InternalQuadruple;
|
||||||
|
DrawCopyPasteButtons(data, data.Locked);
|
||||||
|
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||||
using (_ = ImRaii.Disabled(data.Locked))
|
using (_ = ImRaii.Disabled(data.Locked))
|
||||||
{
|
{
|
||||||
if (ImGui.ColorEdit4("##value", ref value, GetFlags() | ImGuiColorEditFlags.AlphaPreviewHalf))
|
if (ImGui.ColorEdit4("##value", ref value, GetFlags() | ImGuiColorEditFlags.AlphaPreviewHalf))
|
||||||
|
|
@ -229,7 +245,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
|
|
||||||
using (_ = ImRaii.Disabled(data.Locked))
|
using (_ = ImRaii.Disabled(data.Locked))
|
||||||
{
|
{
|
||||||
if (ImGui.SliderFloat("##value", ref value, -100f, 200f, "%.2f"))
|
if (ImGui.SliderFloat("##value", ref value, -100f, 300, "%.2f"))
|
||||||
data.ValueSetter(new CustomizeParameterValue(value / 100f));
|
data.ValueSetter(new CustomizeParameterValue(value / 100f));
|
||||||
ImGuiUtil.HoverTooltip("You can control-click this to enter arbitrary values by hand instead of dragging.");
|
ImGuiUtil.HoverTooltip("You can control-click this to enter arbitrary values by hand instead of dragging.");
|
||||||
}
|
}
|
||||||
|
|
@ -281,7 +297,29 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
||||||
private ImRaii.IEndObject EnsureSize()
|
private ImRaii.IEndObject EnsureSize()
|
||||||
{
|
{
|
||||||
var iconSize = ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 4 * ImGui.GetStyle().FramePadding.Y;
|
var iconSize = ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 4 * ImGui.GetStyle().FramePadding.Y;
|
||||||
_width = 6 * iconSize + 4 * ImGui.GetStyle().ItemInnerSpacing.X;
|
_width = 7 * iconSize + 4 * ImGui.GetStyle().ItemInnerSpacing.X;
|
||||||
return ImRaii.ItemWidth(_width);
|
return ImRaii.ItemWidth(_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void DrawCopyPasteButtons(in CustomizeParameterDrawData data, bool locked)
|
||||||
|
{
|
||||||
|
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Copy.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||||
|
"Copy this color to clipboard.", false, true))
|
||||||
|
ImGui.SetClipboardText(data.CurrentValue.ToJson());
|
||||||
|
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||||
|
if (!ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||||
|
"Try to paste this color from clipboard", locked, true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var text = ImGui.GetClipboardText();
|
||||||
|
if (CustomizeParameterValue.FromJson(text, out var v))
|
||||||
|
data.ValueSetter(v);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,8 +210,8 @@ public class StateEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the customize flags of a character. </summary>
|
/// <summary> Change the customize flags of a character. </summary>
|
||||||
public bool ChangeParameter(ActorState state, CustomizeParameterFlag flag, CustomizeParameterValue value, StateChanged.Source source, out CustomizeParameterValue oldValue,
|
public bool ChangeParameter(ActorState state, CustomizeParameterFlag flag, CustomizeParameterValue value, StateChanged.Source source,
|
||||||
uint key = 0)
|
out CustomizeParameterValue oldValue, uint key = 0)
|
||||||
{
|
{
|
||||||
oldValue = state.ModelData.Parameters[flag];
|
oldValue = state.ModelData.Parameters[flag];
|
||||||
if (!state.CanUnlock(key))
|
if (!state.CanUnlock(key))
|
||||||
|
|
@ -219,6 +219,7 @@ public class StateEditor
|
||||||
|
|
||||||
state.ModelData.Parameters.Set(flag, value);
|
state.ModelData.Parameters.Set(flag, value);
|
||||||
state[flag] = source;
|
state[flag] = source;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,10 @@ public class StateManager(
|
||||||
public void ChangeCustomizeParameter(ActorState state, CustomizeParameterFlag flag, CustomizeParameterValue value,
|
public void ChangeCustomizeParameter(ActorState state, CustomizeParameterFlag flag, CustomizeParameterValue value,
|
||||||
StateChanged.Source source, uint key = 0)
|
StateChanged.Source source, uint key = 0)
|
||||||
{
|
{
|
||||||
|
// Also apply main color to highlights when highlights is off.
|
||||||
|
if (!state.ModelData.Customize.Highlights && flag is CustomizeParameterFlag.HairDiffuse)
|
||||||
|
ChangeCustomizeParameter(state, CustomizeParameterFlag.HairHighlight, value, source, key);
|
||||||
|
|
||||||
if (!_editor.ChangeParameter(state, flag, value, source, out var old, key))
|
if (!_editor.ChangeParameter(state, flag, value, source, out var old, key))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -410,6 +414,12 @@ public class StateManager(
|
||||||
|
|
||||||
foreach (var flag in CustomizeParameterExtensions.AllFlags.Where(design.DoApplyParameter))
|
foreach (var flag in CustomizeParameterExtensions.AllFlags.Where(design.DoApplyParameter))
|
||||||
_editor.ChangeParameter(state, flag, design.DesignData.Parameters[flag], paramSource, out _, key);
|
_editor.ChangeParameter(state, flag, design.DesignData.Parameters[flag], paramSource, out _, key);
|
||||||
|
|
||||||
|
// Do not apply highlights from a design if highlights is unchecked.
|
||||||
|
if (!state.ModelData.Customize.Highlights)
|
||||||
|
_editor.ChangeParameter(state, CustomizeParameterFlag.HairHighlight,
|
||||||
|
state.ModelData.Parameters[CustomizeParameterFlag.HairDiffuse],
|
||||||
|
state[CustomizeParameterFlag.HairDiffuse], out _, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
var actors = ApplyAll(state, redraw, false);
|
var actors = ApplyAll(state, redraw, false);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit afc0345819ca64ec08432e0011b65ff9880c2967
|
Subproject commit 1ebaf1d209b7edc783896b3a6af4907c91bb302e
|
||||||
Loading…
Add table
Add a link
Reference in a new issue