Update values formatting on editor options save #2213
This commit is contained in:
@@ -196,37 +196,19 @@ namespace FlaxEditor.Options
|
|||||||
[EditorDisplay("Interface"), EditorOrder(280), Tooltip("Editor content window orientation.")]
|
[EditorDisplay("Interface"), EditorOrder(280), Tooltip("Editor content window orientation.")]
|
||||||
public FlaxEngine.GUI.Orientation ContentWindowOrientation { get; set; } = FlaxEngine.GUI.Orientation.Horizontal;
|
public FlaxEngine.GUI.Orientation ContentWindowOrientation { get; set; } = FlaxEngine.GUI.Orientation.Horizontal;
|
||||||
|
|
||||||
private ValueFormattingType _valueFormatting = ValueFormattingType.None;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the formatting option for numeric values in the editor.
|
/// Gets or sets the formatting option for numeric values in the editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(ValueFormattingType.None)]
|
[DefaultValue(ValueFormattingType.None)]
|
||||||
[EditorDisplay("Interface"), EditorOrder(300), Tooltip("Formatting of numeric values.")]
|
[EditorDisplay("Interface"), EditorOrder(300)]
|
||||||
public ValueFormattingType ValueFormatting {
|
public ValueFormattingType ValueFormatting { get; set; }
|
||||||
get => _valueFormatting;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_valueFormatting = value;
|
|
||||||
Units.UseUnitsFormatting = _valueFormatting != ValueFormattingType.None;
|
|
||||||
Units.AutomaticUnitsFormatting = _valueFormatting == ValueFormattingType.AutoUnit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _spaceNumberAndUnits = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the option to put a space between numbers and units for unit formatting.
|
/// Gets or sets the option to put a space between numbers and units for unit formatting.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[EditorDisplay("Interface"), EditorOrder(310), Tooltip("Put a space between numbers and units.")]
|
[EditorDisplay("Interface"), EditorOrder(310)]
|
||||||
public bool SpaceNumberAndUnits { get => _spaceNumberAndUnits;
|
public bool SeparateValueAndUnit { get; set; }
|
||||||
set
|
|
||||||
{
|
|
||||||
_spaceNumberAndUnits = value;
|
|
||||||
Units.SpaceNumberAndUnits = _spaceNumberAndUnits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the timestamps prefix mode for output log messages.
|
/// Gets or sets the timestamps prefix mode for output log messages.
|
||||||
|
|||||||
@@ -200,6 +200,27 @@ namespace FlaxEditor.Options
|
|||||||
|
|
||||||
EditorAssets.Cache.OnEditorOptionsChanged(Options);
|
EditorAssets.Cache.OnEditorOptionsChanged(Options);
|
||||||
|
|
||||||
|
// Units formatting options
|
||||||
|
bool useUnitsFormatting = Options.Interface.ValueFormatting != InterfaceOptions.ValueFormattingType.None;
|
||||||
|
bool automaticUnitsFormatting = Options.Interface.ValueFormatting == InterfaceOptions.ValueFormattingType.AutoUnit;
|
||||||
|
bool separateValueAndUnit = Options.Interface.SeparateValueAndUnit;
|
||||||
|
if (useUnitsFormatting != Utilities.Units.UseUnitsFormatting ||
|
||||||
|
automaticUnitsFormatting != Utilities.Units.AutomaticUnitsFormatting ||
|
||||||
|
separateValueAndUnit != Utilities.Units.SeparateValueAndUnit)
|
||||||
|
{
|
||||||
|
Utilities.Units.UseUnitsFormatting = useUnitsFormatting;
|
||||||
|
Utilities.Units.AutomaticUnitsFormatting = automaticUnitsFormatting;
|
||||||
|
Utilities.Units.SeparateValueAndUnit = separateValueAndUnit;
|
||||||
|
|
||||||
|
// Refresh UI in property panels
|
||||||
|
Editor.Windows.PropertiesWin?.Presenter.BuildLayoutOnUpdate();
|
||||||
|
foreach (var window in Editor.Windows.Windows)
|
||||||
|
{
|
||||||
|
if (window is Windows.Assets.PrefabWindow prefabWindow)
|
||||||
|
prefabWindow.Presenter.BuildLayoutOnUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
OptionsChanged?.Invoke(Options);
|
OptionsChanged?.Invoke(Options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Units
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a space between numbers and units for readability.
|
/// Add a space between numbers and units for readability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool SpaceNumberAndUnits = true;
|
public static bool SeparateValueAndUnit = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If set to true, the distance unit is chosen on the magnitude, otherwise it's meters.
|
/// If set to true, the distance unit is chosen on the magnitude, otherwise it's meters.
|
||||||
@@ -34,7 +34,7 @@ public class Units
|
|||||||
/// <returns>The formatted text.</returns>
|
/// <returns>The formatted text.</returns>
|
||||||
public static string Unit(string unit)
|
public static string Unit(string unit)
|
||||||
{
|
{
|
||||||
if (SpaceNumberAndUnits)
|
if (SeparateValueAndUnit)
|
||||||
return $" {unit}";
|
return $" {unit}";
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user