From 4b2f44b63e8cdce17032e1458732105386f6f8f5 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 22 Feb 2026 22:29:46 +0100 Subject: [PATCH] Add roughness enum. --- Glamourer/Config/Configuration.cs | 3 +- Glamourer/Config/RoughnessSetting.cs | 27 ++++++++++++++++++ Glamourer/Gui/Materials/AdvancedDyePopup.cs | 4 +-- Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 28 ++++++------------- 4 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 Glamourer/Config/RoughnessSetting.cs diff --git a/Glamourer/Config/Configuration.cs b/Glamourer/Config/Configuration.cs index 8b80527..b7c9424 100644 --- a/Glamourer/Config/Configuration.cs +++ b/Glamourer/Config/Configuration.cs @@ -52,10 +52,11 @@ public sealed partial class Configuration : IPluginConfiguration, ISavable, ISer public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; public bool PreventRandomRepeats { get; set; } = false; - public bool? AlwaysEditAsRoughness { get; set; } = null; public string PcpFolder { get; set; } = "PCP"; public string PcpColor { get; set; } = ""; + public RoughnessSetting RoughnessSetting { get; set; } = RoughnessSetting.AsIs; + public DesignPanelFlag HideDesignPanel { get; set; } = 0; public DesignPanelFlag AutoExpandDesignPanel { get; set; } = 0; diff --git a/Glamourer/Config/RoughnessSetting.cs b/Glamourer/Config/RoughnessSetting.cs new file mode 100644 index 0000000..2df167e --- /dev/null +++ b/Glamourer/Config/RoughnessSetting.cs @@ -0,0 +1,27 @@ +using Luna.Generators; + +namespace Glamourer.Config; + +[NamedEnum(Utf16: false)] +public enum RoughnessSetting +{ + [Name("As-Is")] + AsIs, + + [Name("Always Roughness")] + AlwaysRoughness, + + [Name("Always Gloss Strength")] + AlwaysGloss, +} + +public static partial class RoughnessSettingExtensions +{ + public static bool Get(this RoughnessSetting setting, bool roughness) + => setting switch + { + RoughnessSetting.AlwaysRoughness => true, + RoughnessSetting.AlwaysGloss => false, + _ => roughness, + }; +} diff --git a/Glamourer/Gui/Materials/AdvancedDyePopup.cs b/Glamourer/Gui/Materials/AdvancedDyePopup.cs index f234313..3f34dec 100644 --- a/Glamourer/Gui/Materials/AdvancedDyePopup.cs +++ b/Glamourer/Gui/Materials/AdvancedDyePopup.cs @@ -453,14 +453,14 @@ public sealed unsafe class AdvancedDyePopup( else { Im.Item.SetNextWidthScaled(100); - var editAsRoughness = config.AlwaysEditAsRoughness ?? _mode is ColorRow.Mode.Dawntrail; + var editAsRoughness = config.RoughnessSetting.Get(_mode is ColorRow.Mode.Dawntrail); applied |= (_mode, editAsRoughness) switch { (ColorRow.Mode.Legacy, false) => DragGloss(ref value.Model.GlossStrength, false), (ColorRow.Mode.Legacy, true) => DragGlossAsRoughness(ref value.Model.GlossStrength, false), (ColorRow.Mode.Dawntrail, false) => DragRoughnessAsGloss(ref value.Model.Roughness, false), (ColorRow.Mode.Dawntrail, true) => DragRoughness(ref value.Model.Roughness, false), - _ => throw new NotImplementedException(), + _ => false, }; Im.Tooltip.OnHover(editAsRoughness ? "Change the roughness for this row."u8 : "Change the gloss strength for this row."u8); diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 1577ea9..6acb3fd 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -508,7 +508,7 @@ public sealed class SettingsTab( "Select how to display the height of characters in real-world units, if at all."u8); } -private string _newIgnoredMod = string.Empty; + private string _newIgnoredMod = string.Empty; private void DrawIgnoredMods() { @@ -530,15 +530,15 @@ private string _newIgnoredMod = string.Empty; delete = mod; Im.Line.SameInner(); - ImEx.TextFramed(mod, Im.ContentRegion.Available with { Y = Im.Style.FrameHeight}); + ImEx.TextFramed(mod, Im.ContentRegion.Available with { Y = Im.Style.FrameHeight }); } if (delete.Length > 0) ignoredMods.Remove(delete); - var tt = _newIgnoredMod.Length is 0 ? "Please enter a new mod name or mod directory to ignore."u8 : + var tt = _newIgnoredMod.Length is 0 ? "Please enter a new mod name or mod directory to ignore."u8 : ignoredMods.Contains(_newIgnoredMod) ? "This mod is already ignored."u8 : - "Ignore all mods with this name or directory in the Unlocks tab."u8; + "Ignore all mods with this name or directory in the Unlocks tab."u8; if (ImEx.Icon.Button(LunaStyle.AddObjectIcon, tt, tt[0] is not (byte)'I')) { ignoredMods.Add(_newIgnoredMod); @@ -553,30 +553,20 @@ private string _newIgnoredMod = string.Empty; private void DrawRoughnessSettings() { Im.Item.SetNextWidthScaled(300); - using (var combo = Im.Combo.Begin("##alwaysEditAsRoughness"u8, ToRoughnessSettingString(config.AlwaysEditAsRoughness))) + using (var combo = Im.Combo.Begin("##alwaysEditAsRoughness"u8, config.RoughnessSetting.ToNameU8())) { if (combo) - foreach (var type in (IEnumerable)[null, true, false,]) + foreach (var type in RoughnessSetting.Values) { - if (Im.Selectable(ToRoughnessSettingString(type), config.AlwaysEditAsRoughness == type)) + if (Im.Selectable(type.ToNameU8(), config.RoughnessSetting == type)) { - config.AlwaysEditAsRoughness = type; + config.RoughnessSetting = type; config.Save(); } } } LunaStyle.DrawAlignedHelpMarkerLabel("Gloss Strength and Roughness Display Type"u8, - "Select how to display and edit Gloss Strength and Roughness values.\nThe conversion formula used is an approximation and does not account for all the subtleties of legacy vs PBR shaders."u8); - - return; - - static ReadOnlySpan ToRoughnessSettingString(bool? alwaysEditAsRoughness) - => alwaysEditAsRoughness switch - { - null => "As-Is"u8, - true => "Always Roughness"u8, - false => "Always Gloss Strength"u8, - }; + "Select how to display and edit Gloss Strength and Roughness values.\nThe conversion formula used is an approximation and does not account for all the subtleties of legacy versus PBR shaders."u8); } }