// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. using System.ComponentModel; using FlaxEditor.GUI.Docking; using FlaxEditor.Utilities; using FlaxEngine; namespace FlaxEditor.Options { /// /// Editor interface options data container. /// [CustomEditor(typeof(Editor))] public class InterfaceOptions { /// /// The log timestamp modes. /// public enum TimestampsFormats { /// /// No prefix. /// None, /// /// The UTC time format. /// Utc, /// /// The local time format. /// LocalTime, /// /// The time since startup (in seconds). /// TimeSinceStartup, } /// /// A proxy DockState for window open method. /// public enum DockStateProxy { /// /// The floating window. /// Float = DockState.Float, /// /// The dock fill as a tab. /// DockFill = DockState.DockFill, /// /// The dock left. /// DockLeft = DockState.DockLeft, /// /// The dock right. /// DockRight = DockState.DockRight, /// /// The dock top. /// DockTop = DockState.DockTop, /// /// The dock bottom. /// DockBottom = DockState.DockBottom } /// /// Options for the action taken by the play button. /// public enum PlayAction { /// /// Launches the game from the First Scene defined in the project settings. /// PlayGame, /// /// Launches the game using the scenes currently loaded in the editor. /// PlayScenes, } /// /// Available window modes for the game window. /// public enum GameWindowMode { /// /// Shows the game window docked, inside the editor. /// Docked, /// /// Shows the game window as a popup. /// PopupWindow, /// /// Shows the game window maximized. (Same as pressing F11) /// MaximizedWindow, /// /// Shows the game window borderless. /// BorderlessWindow, } /// /// Options for formatting numerical values. /// public enum ValueFormattingType { /// /// No formatting. /// None, /// /// Format using the base SI unit. /// BaseUnit, /// /// Format using a unit that matches the value best. /// AutoUnit, } /// /// Gets or sets the Editor User Interface scale. Applied to all UI elements, windows and text. Can be used to scale the interface up on a bigger display. Editor restart required. /// [DefaultValue(1.0f), Limit(0.1f, 10.0f)] [EditorDisplay("Interface"), EditorOrder(10), Tooltip("Editor User Interface scale. Applied to all UI elements, windows and text. Can be used to scale the interface up on a bigger display. Editor restart required.")] public float InterfaceScale { get; set; } = 1.0f; #if PLATFORM_WINDOWS /// /// Gets or sets a value indicating whether use native window title bar. Editor restart required. /// [DefaultValue(false)] [EditorDisplay("Interface"), EditorOrder(70), Tooltip("Determines whether use native window title bar. Editor restart required.")] public bool UseNativeWindowSystem { get; set; } = false; #endif /// /// Gets or sets a value indicating whether show selected camera preview in the editor window. /// [DefaultValue(true)] [EditorDisplay("Interface"), EditorOrder(80), Tooltip("Determines whether show selected camera preview in the edit window.")] public bool ShowSelectedCameraPreview { get; set; } = true; /// /// Gets or sets a value indicating whether center mouse position on window focus in play mode. Helps when working with games that lock mouse cursor. /// [DefaultValue(false)] [EditorDisplay("Interface", "Center Mouse On Game Window Focus"), EditorOrder(100), Tooltip("Determines whether center mouse position on window focus in play mode. Helps when working with games that lock mouse cursor.")] public bool CenterMouseOnGameWinFocus { get; set; } = false; /// /// Gets or sets the method window opening. /// [DefaultValue(DockStateProxy.Float)] [EditorDisplay("Interface", "New Window Location"), EditorOrder(150), Tooltip("Define the opening method for new windows, open in a new tab by default.")] public DockStateProxy NewWindowLocation { get; set; } = DockStateProxy.Float; /// /// Gets or sets the editor icons scale. Editor restart required. /// [DefaultValue(1.0f), Limit(0.1f, 4.0f, 0.01f)] [EditorDisplay("Interface"), EditorOrder(250), Tooltip("Editor icons scale. Editor restart required.")] public float IconsScale { get; set; } = 1.0f; /// /// Gets or sets the editor content window orientation. /// [DefaultValue(FlaxEngine.GUI.Orientation.Horizontal)] [EditorDisplay("Interface"), EditorOrder(280), Tooltip("Editor content window orientation.")] public FlaxEngine.GUI.Orientation ContentWindowOrientation { get; set; } = FlaxEngine.GUI.Orientation.Horizontal; /// /// If checked, color pickers will always modify the color unless 'Cancel' if pressed, otherwise color won't change unless 'Ok' is pressed. /// [DefaultValue(true)] [EditorDisplay("Interface"), EditorOrder(290)] public bool AutoAcceptColorPickerChange { get; set; } = true; /// /// Gets or sets the formatting option for numeric values in the editor. /// [DefaultValue(ValueFormattingType.None)] [EditorDisplay("Interface"), EditorOrder(300)] public ValueFormattingType ValueFormatting { get; set; } /// /// Gets or sets the option to put a space between numbers and units for unit formatting. /// [DefaultValue(false)] [EditorDisplay("Interface"), EditorOrder(310)] public bool SeparateValueAndUnit { get; set; } /// /// Gets or sets the option to put a space between numbers and units for unit formatting. /// [DefaultValue(true)] [EditorDisplay("Interface"), EditorOrder(320)] public bool ShowTreeLines { get; set; } = true; /// /// Gets or sets the timestamps prefix mode for output log messages. /// [DefaultValue(TimestampsFormats.None)] [EditorDisplay("Debug Log"), EditorOrder(350), Tooltip("The timestamps prefix mode for debug log messages.")] public TimestampsFormats DebugLogTimestampsFormat { get; set; } = TimestampsFormats.None; /// /// Gets or sets the clear on play for debug log messages. /// [DefaultValue(true)] [EditorDisplay("Debug Log", "Clear on Play"), EditorOrder(360), Tooltip("Clears all log entries on enter playmode.")] public bool DebugLogClearOnPlay { get; set; } = true; /// /// Gets or sets the collapse mode for debug log messages. /// [DefaultValue(true)] [EditorDisplay("Debug Log"), EditorOrder(361), Tooltip("Collapses similar or repeating log entries.")] public bool DebugLogCollapse { get; set; } = true; /// /// Gets or sets the automatic pause on error for debug log messages. /// [DefaultValue(false)] [EditorDisplay("Debug Log", "Pause on Error"), EditorOrder(362), Tooltip("Performs auto pause on error.")] public bool DebugLogPauseOnError { get; set; } = false; /// /// Gets or sets the automatic pause on error for debug log messages. /// [DefaultValue(true)] [EditorDisplay("Debug Log", "Show error messages"), EditorOrder(370), Tooltip("Shows/hides error messages.")] public bool DebugLogShowErrorMessages { get; set; } = true; /// /// Gets or sets the automatic pause on error for debug log messages. /// [DefaultValue(true)] [EditorDisplay("Debug Log", "Show warning messages"), EditorOrder(371), Tooltip("Shows/hides warning messages.")] public bool DebugLogShowWarningMessages { get; set; } = true; /// /// Gets or sets the automatic pause on error for debug log messages. /// [DefaultValue(true)] [EditorDisplay("Debug Log", "Show info messages"), EditorOrder(372), Tooltip("Shows/hides info messages.")] public bool DebugLogShowInfoMessages { get; set; } = true; /// /// Gets or sets the timestamps prefix mode for output log messages. /// [DefaultValue(TimestampsFormats.TimeSinceStartup)] [EditorDisplay("Output Log", "Timestamps Format"), EditorOrder(400), Tooltip("The timestamps prefix mode for output log messages.")] public TimestampsFormats OutputLogTimestampsFormat { get; set; } = TimestampsFormats.TimeSinceStartup; /// /// Gets or sets the log type prefix mode for output log messages. /// [DefaultValue(true)] [EditorDisplay("Output Log", "Show Log Type"), EditorOrder(410), Tooltip("Determines whether show log type prefix in output log messages.")] public bool OutputLogShowLogType { get; set; } = true; /// /// Gets or sets the output log text font. /// [EditorDisplay("Output Log", "Text Font"), EditorOrder(420), Tooltip("The output log text font.")] public FontReference OutputLogTextFont { get => _outputLogFont; set { if (value == null) _outputLogFont = new FontReference(ConsoleFont, 10); else if (!value.Font) _outputLogFont.Font = ConsoleFont; else _outputLogFont = value; } } /// /// Gets or sets the output log text color. /// [DefaultValue(typeof(Color), "1,1,1,1")] [EditorDisplay("Output Log", "Text Color"), EditorOrder(430), Tooltip("The output log text color.")] public Color OutputLogTextColor { get; set; } = Color.White; /// /// Gets or sets the output log text shadow color. /// [DefaultValue(typeof(Color), "0,0,0,0.5")] [EditorDisplay("Output Log", "Text Shadow Color"), EditorOrder(440), Tooltip("The output log text shadow color.")] public Color OutputLogTextShadowColor { get; set; } = new Color(0, 0, 0, 0.5f); /// /// Gets or sets the output log text shadow offset. Set to 0 to disable this feature. /// [DefaultValue(typeof(Float2), "1,1")] [EditorDisplay("Output Log", "Text Shadow Offset"), EditorOrder(445), Tooltip("The output log text shadow offset. Set to 0 to disable this feature.")] public Float2 OutputLogTextShadowOffset { get; set; } = new Float2(1); /// /// Gets or sets a value indicating whether auto-focus output log window on code compilation error. /// [DefaultValue(true)] [EditorDisplay("Output Log", "Focus Output Log On Compilation Error"), EditorOrder(450), Tooltip("Determines whether auto-focus output log window on code compilation error.")] public bool FocusOutputLogOnCompilationError { get; set; } = true; /// /// Gets or sets a value indicating whether auto-focus output log window on game build error. /// [DefaultValue(true)] [EditorDisplay("Output Log", "Focus Output Log On Game Build Error"), EditorOrder(460), Tooltip("Determines whether auto-focus output log window on game build error.")] public bool FocusOutputLogOnGameBuildError { get; set; } = true; /// /// Gets or sets the value for automatic scroll to bottom in output log. /// [DefaultValue(true)] [EditorDisplay("Output Log", "Scroll to bottom"), EditorOrder(470), Tooltip("Scroll the output log view to bottom automatically after new lines are added.")] public bool OutputLogScrollToBottom { get; set; } = true; /// /// Gets or sets a value indicating whether auto-focus game window on play mode start. /// [DefaultValue(true)] [EditorDisplay("Play In-Editor", "Focus Game Window On Play"), EditorOrder(500), Tooltip("Determines whether auto-focus game window on play mode start.")] public bool FocusGameWinOnPlay { get; set; } = true; /// /// Gets or sets a value indicating what action should be taken upon pressing the play button. /// [DefaultValue(PlayAction.PlayScenes)] [EditorDisplay("Play In-Editor", "Play Button Action"), EditorOrder(510)] public PlayAction PlayButtonAction { get; set; } = PlayAction.PlayScenes; /// /// Gets or sets a value indicating how the game window should be displayed when the game is launched. /// [DefaultValue(GameWindowMode.Docked)] [EditorDisplay("Play In-Editor", "Game Window Mode"), EditorOrder(520), Tooltip("Determines how the game window is displayed when the game is launched.")] public GameWindowMode DefaultGameWindowMode { get; set; } = GameWindowMode.Docked; /// /// Gets or sets a value indicating the number of game clients to launch when building and/or running cooked game. /// [DefaultValue(1), Range(1, 4)] [EditorDisplay("Cook & Run"), EditorOrder(600)] public int NumberOfGameClientsToLaunch = 1; /// /// Gets or sets the visject connection curvature. /// [DefaultValue(1.0f), Range(0.0f, 2.0f)] [EditorDisplay("Visject"), EditorOrder(550)] public float ConnectionCurvature { get; set; } = 1.0f; private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal(EditorAssets.PrimaryFont); private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal(EditorAssets.InconsolataRegularFont); private FontReference _titleFont = new FontReference(DefaultFont, 18); private FontReference _largeFont = new FontReference(DefaultFont, 14); private FontReference _mediumFont = new FontReference(DefaultFont, 9); private FontReference _smallFont = new FontReference(DefaultFont, 9); private FontReference _outputLogFont = new FontReference(ConsoleFont, 10); /// /// The list of fallback fonts to use when main text font is missing certain characters. Empty to use fonts from GraphicsSettings. /// [EditorDisplay("Fonts"), EditorOrder(750)] public FontAsset[] FallbackFonts = new FontAsset[1] { FlaxEngine.Content.LoadAsyncInternal(EditorAssets.FallbackFont) }; /// /// Gets or sets the title font for editor UI. /// [EditorDisplay("Fonts"), EditorOrder(700), Tooltip("The title font for editor UI.")] public FontReference TitleFont { get => _titleFont; set { if (value == null) _titleFont = new FontReference(DefaultFont, 18); else if (!value.Font) _titleFont.Font = DefaultFont; else _titleFont = value; } } /// /// Gets or sets the large font for editor UI. /// [EditorDisplay("Fonts"), EditorOrder(710), Tooltip("The large font for editor UI.")] public FontReference LargeFont { get => _largeFont; set { if (value == null) _largeFont = new FontReference(DefaultFont, 14); else if (!value.Font) _largeFont.Font = DefaultFont; else _largeFont = value; } } /// /// Gets or sets the medium font for editor UI. /// [EditorDisplay("Fonts"), EditorOrder(720), Tooltip("The medium font for editor UI.")] public FontReference MediumFont { get => _mediumFont; set { if (value == null) _mediumFont = new FontReference(DefaultFont, 9); else if (!value.Font) _mediumFont.Font = DefaultFont; else _mediumFont = value; } } /// /// Gets or sets the small font for editor UI. /// [EditorDisplay("Fonts"), EditorOrder(730), Tooltip("The small font for editor UI.")] public FontReference SmallFont { get => _smallFont; set { if (value == null) _smallFont = new FontReference(DefaultFont, 9); else if (!value.Font) _smallFont.Font = DefaultFont; else _smallFont = value; } } } }