Add color display options.

This commit is contained in:
Ottermandias 2024-01-17 17:22:32 +01:00
parent 4abae59974
commit 53c4dfeee5
3 changed files with 79 additions and 5 deletions

View file

@ -3,6 +3,7 @@ using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Internal.Notifications;
using Glamourer.Designs;
using Glamourer.Gui;
using Glamourer.Gui.Customization;
using Glamourer.Services;
using Newtonsoft.Json;
using OtterGui;
@ -37,6 +38,9 @@ public class Configuration : IPluginConfiguration, ISavable
public bool UseAdvancedParameters { get; set; } = true;
public bool ShowRevertAdvancedParametersButton { get; set; } = true;
public bool ShowPalettePlusImport { get; set; } = true;
public bool UseFloatForColors { get; set; } = true;
public bool UseRgbForColors { get; set; } = true;
public bool ShowColorConfig { get; set; } = true;
public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY);
public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift);
public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New;
@ -45,7 +49,7 @@ public class Configuration : IPluginConfiguration, ISavable
[JsonProperty(Order = int.MaxValue)]
public ISortMode<Design> SortMode { get; set; } = ISortMode<Design>.FoldersFirst;
public List<(string Code, bool Enabled)> Codes { get; set; } = [];
public List<(string Code, bool Enabled)> Codes { get; set; } = [];
#if DEBUG
public bool DebugMode { get; set; } = true;

View file

@ -22,6 +22,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
{
using var _ = EnsureSize();
DrawPaletteImport(designManager, design);
DrawConfig(true);
foreach (var flag in CustomizeParameterExtensions.RgbFlags)
DrawColorInput3(CustomizeParameterDrawData.FromDesign(designManager, design, flag));
@ -99,6 +100,7 @@ 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));
@ -112,6 +114,68 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
DrawValueInput(CustomizeParameterDrawData.FromState(stateManager, state, flag));
}
public void DrawConfig(bool withApply)
{
if (!config.ShowColorConfig)
return;
DrawColorDisplayOptions();
DrawColorFormatOptions(withApply);
var value = config.ShowColorConfig;
ImGui.SameLine();
if (ImGui.Checkbox("Show Config", ref value))
{
config.ShowColorConfig = value;
config.Save();
}
ImGuiUtil.HoverTooltip(
"Hide the color configuration options from the Advanced Customization panel. You can re-enable it in Glamourers interface settings.");
}
public void DrawColorDisplayOptions()
{
using var group = ImRaii.Group();
if (ImGui.RadioButton("RGB", config.UseRgbForColors) && !config.UseRgbForColors)
{
config.UseRgbForColors = true;
config.Save();
}
ImGui.SameLine();
if (ImGui.RadioButton("HSV", !config.UseRgbForColors) && config.UseRgbForColors)
{
config.UseRgbForColors = false;
config.Save();
}
}
public void DrawColorFormatOptions(bool withApply)
{
var width = _width
- (ImGui.CalcTextSize("Float").X
+ ImGui.CalcTextSize("Integer").X
+ 2 * (ImGui.GetFrameHeight() + ImGui.GetStyle().ItemSpacing.X)
+ ImGui.GetStyle().ItemInnerSpacing.X
+ ImGui.GetItemRectSize().X);
if (!withApply)
width -= ImGui.GetFrameHeight() + ImGui.GetStyle().ItemInnerSpacing.X;
ImGui.SameLine(0, width);
if (ImGui.RadioButton("Float", config.UseFloatForColors) && !config.UseFloatForColors)
{
config.UseFloatForColors = true;
config.Save();
}
ImGui.SameLine();
if (ImGui.RadioButton("Integer", !config.UseFloatForColors) && config.UseFloatForColors)
{
config.UseFloatForColors = false;
config.Save();
}
}
private void DrawColorInput3(in CustomizeParameterDrawData data)
{
using var id = ImRaii.PushId((int)data.Flag);
@ -169,6 +233,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
data.ValueSetter(new CustomizeParameterValue(value / 100f));
ImGuiUtil.HoverTooltip("You can control-click this to enter arbitrary values by hand instead of dragging.");
}
DrawRevert(data);
DrawApplyAndLabel(data);
@ -204,11 +269,14 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
ImGui.TextUnformatted(data.Flag.ToName());
}
private static ImGuiColorEditFlags GetFlags()
=> ImGui.GetIO().KeyCtrl
? ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions
: ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR;
private ImGuiColorEditFlags GetFlags()
=> Format | Display | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions;
private ImGuiColorEditFlags Format
=> config.UseFloatForColors ? ImGuiColorEditFlags.Float : ImGuiColorEditFlags.Uint8;
private ImGuiColorEditFlags Display
=> config.UseRgbForColors ? ImGuiColorEditFlags.DisplayRGB : ImGuiColorEditFlags.DisplayHSV;
private ImRaii.IEndObject EnsureSize()
{

View file

@ -167,6 +167,8 @@ public class SettingsTab(
Checkbox("Show Revert Advanced Customizations Button in Quick Design Bar",
"Show a button to revert only advanced customizations on your character or a target in the quick design bar.",
config.ShowRevertAdvancedParametersButton, v => config.ShowRevertAdvancedParametersButton = v);
Checkbox("Show Color Display Config", "Show the Color Display configuration options in the Advanced Customization panels.",
config.ShowColorConfig, v => config.ShowColorConfig = v);
Checkbox("Show Palette+ Import Button",
"Show the import button that allows you to import Palette+ palettes onto a design in the Advanced Customization options section for designs.",
config.ShowPalettePlusImport, v => config.ShowPalettePlusImport = v);