diff --git a/Source/Editor/Content/Proxy/PrefabProxy.cs b/Source/Editor/Content/Proxy/PrefabProxy.cs index 276bc0d30..ff3a5bd17 100644 --- a/Source/Editor/Content/Proxy/PrefabProxy.cs +++ b/Source/Editor/Content/Proxy/PrefabProxy.cs @@ -78,8 +78,10 @@ namespace FlaxEditor.Content if (actor == null) { // Create default prefab root object - actor = new EmptyActor(); - actor.Name = "Root"; + actor = new EmptyActor + { + Name = "Root" + }; // Cleanup it after usage Object.Destroy(actor, 20.0f); diff --git a/Source/Editor/Content/Tree/ContentTreeNode.cs b/Source/Editor/Content/Tree/ContentTreeNode.cs index 4370bc8e7..78cc7f2b5 100644 --- a/Source/Editor/Content/Tree/ContentTreeNode.cs +++ b/Source/Editor/Content/Tree/ContentTreeNode.cs @@ -120,9 +120,8 @@ namespace FlaxEditor.Content } else { - QueryFilterHelper.Range[] ranges; var text = Text; - if (QueryFilterHelper.Match(filterText, text, out ranges)) + if (QueryFilterHelper.Match(filterText, text, out QueryFilterHelper.Range[] ranges)) { // Update highlights if (_highlights == null) diff --git a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs index ad974c55a..93eed826f 100644 --- a/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ActorEditor.cs @@ -70,8 +70,10 @@ namespace FlaxEditor.CustomEditors.Dedicated var scriptsMember = type.GetProperty("Scripts"); if (scriptsMember != ScriptMemberInfo.Null) { - var item = new ItemInfo(scriptsMember); - item.CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor)); + var item = new ItemInfo(scriptsMember) + { + CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor)) + }; items.Add(item); } @@ -232,9 +234,10 @@ namespace FlaxEditor.CustomEditors.Dedicated private TreeNode CreateDiffNode(CustomEditor editor) { - var node = new TreeNode(false); - - node.Tag = editor; + var node = new TreeNode(false) + { + Tag = editor + }; // Removed Script if (editor is RemovedScriptDummy removed) diff --git a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs index f577e9bae..1e4116894 100644 --- a/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/ScriptsEditor.cs @@ -493,8 +493,10 @@ namespace FlaxEditor.CustomEditors.Dedicated var index = (int)image.Tag; - var cm = new ContextMenu(); - cm.Tag = index; + var cm = new ContextMenu + { + Tag = index + }; cm.AddButton("Remove", OnClickMissingRemove); cm.Show(image, image.Size); } @@ -746,8 +748,10 @@ namespace FlaxEditor.CustomEditors.Dedicated var scriptType = TypeUtils.GetType(script.TypeName); var item = scriptType.ContentItem; - var cm = new ContextMenu(); - cm.Tag = script; + var cm = new ContextMenu + { + Tag = script + }; cm.AddButton("Remove", OnClickRemove).Icon = Editor.Instance.Icons.Cross12; cm.AddButton("Move up", OnClickMoveUp).Enabled = script.OrderInParent > 0; cm.AddButton("Move down", OnClickMoveDown).Enabled = script.OrderInParent < script.Actor.Scripts.Length - 1; diff --git a/Source/Editor/CustomEditors/Elements/LabelElement.cs b/Source/Editor/CustomEditors/Elements/LabelElement.cs index 4dd2b0302..d8a91b52e 100644 --- a/Source/Editor/CustomEditors/Elements/LabelElement.cs +++ b/Source/Editor/CustomEditors/Elements/LabelElement.cs @@ -21,8 +21,10 @@ namespace FlaxEditor.CustomEditors.Elements /// public LabelElement() { - Label = new Label(0, 0, 100, 18); - Label.HorizontalAlignment = TextAlignment.Near; + Label = new Label(0, 0, 100, 18) + { + HorizontalAlignment = TextAlignment.Near + }; // TODO: auto height for label } diff --git a/Source/Editor/GUI/ContextMenu/ContextMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenu.cs index 45eff148e..04dded53c 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenu.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenu.cs @@ -193,8 +193,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuButton AddButton(string text) { - var item = new ContextMenuButton(this, text); - item.Parent = _panel; + var item = new ContextMenuButton(this, text) + { + Parent = _panel + }; SortButtons(); return item; } @@ -207,8 +209,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuButton AddButton(string text, string shortKeys) { - var item = new ContextMenuButton(this, text, shortKeys); - item.Parent = _panel; + var item = new ContextMenuButton(this, text, shortKeys) + { + Parent = _panel + }; SortButtons(); return item; } @@ -221,8 +225,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuButton AddButton(string text, Action clicked) { - var item = new ContextMenuButton(this, text); - item.Parent = _panel; + var item = new ContextMenuButton(this, text) + { + Parent = _panel + }; item.Clicked += clicked; SortButtons(); return item; @@ -236,8 +242,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuButton AddButton(string text, Action clicked) { - var item = new ContextMenuButton(this, text); - item.Parent = _panel; + var item = new ContextMenuButton(this, text) + { + Parent = _panel + }; item.ButtonClicked += clicked; SortButtons(); return item; @@ -252,8 +260,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuButton AddButton(string text, string shortKeys, Action clicked) { - var item = new ContextMenuButton(this, text, shortKeys); - item.Parent = _panel; + var item = new ContextMenuButton(this, text, shortKeys) + { + Parent = _panel + }; item.Clicked += clicked; SortButtons(); return item; @@ -285,8 +295,10 @@ namespace FlaxEditor.GUI.ContextMenu var item = GetChildMenu(text); if (item == null) { - item = new ContextMenuChildMenu(this, text); - item.Parent = _panel; + item = new ContextMenuChildMenu(this, text) + { + Parent = _panel + }; } return item; @@ -299,8 +311,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuChildMenu AddChildMenu(string text) { - var item = new ContextMenuChildMenu(this, text); - item.Parent = _panel; + var item = new ContextMenuChildMenu(this, text) + { + Parent = _panel + }; return item; } @@ -310,8 +324,10 @@ namespace FlaxEditor.GUI.ContextMenu /// Created context menu item control. public ContextMenuSeparator AddSeparator() { - var item = new ContextMenuSeparator(this); - item.Parent = _panel; + var item = new ContextMenuSeparator(this) + { + Parent = _panel + }; return item; } diff --git a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs index 9eb63ee48..c409dbbd1 100644 --- a/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs +++ b/Source/Editor/GUI/Dialogs/ColorPickerDialog.cs @@ -113,53 +113,71 @@ namespace FlaxEditor.GUI.Dialogs _onClosed = pickerClosed; // Selector - _cSelector = new ColorSelectorWithSliders(180, 18); - _cSelector.Location = new Vector2(PickerMargin, PickerMargin); + _cSelector = new ColorSelectorWithSliders(180, 18) + { + Location = new Vector2(PickerMargin, PickerMargin), + Parent = this + }; _cSelector.ColorChanged += x => SelectedColor = x; - _cSelector.Parent = this; // Red - _cRed = new FloatValueBox(0, _cSelector.Right + PickerMargin + RGBAMargin + ChannelTextWidth, PickerMargin, 100, 0, float.MaxValue, 0.001f); + _cRed = new FloatValueBox(0, _cSelector.Right + PickerMargin + RGBAMargin + ChannelTextWidth, PickerMargin, 100, 0, float.MaxValue, 0.001f) + { + Parent = this + }; _cRed.ValueChanged += OnRGBAChanged; - _cRed.Parent = this; // Green - _cGreen = new FloatValueBox(0, _cRed.X, _cRed.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f); + _cGreen = new FloatValueBox(0, _cRed.X, _cRed.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f) + { + Parent = this + }; _cGreen.ValueChanged += OnRGBAChanged; - _cGreen.Parent = this; // Blue - _cBlue = new FloatValueBox(0, _cRed.X, _cGreen.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f); + _cBlue = new FloatValueBox(0, _cRed.X, _cGreen.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f) + { + Parent = this + }; _cBlue.ValueChanged += OnRGBAChanged; - _cBlue.Parent = this; // Alpha - _cAlpha = new FloatValueBox(0, _cRed.X, _cBlue.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f); + _cAlpha = new FloatValueBox(0, _cRed.X, _cBlue.Bottom + ChannelsMargin, _cRed.Width, 0, float.MaxValue, 0.001f) + { + Parent = this + }; _cAlpha.ValueChanged += OnRGBAChanged; - _cAlpha.Parent = this; // Hue - _cHue = new FloatValueBox(0, PickerMargin + HSVMargin + ChannelTextWidth, _cSelector.Bottom + PickerMargin, 100, 0, 360); + _cHue = new FloatValueBox(0, PickerMargin + HSVMargin + ChannelTextWidth, _cSelector.Bottom + PickerMargin, 100, 0, 360) + { + Parent = this + }; _cHue.ValueChanged += OnHSVChanged; - _cHue.Parent = this; // Saturation - _cSaturation = new FloatValueBox(0, _cHue.X, _cHue.Bottom + ChannelsMargin, _cHue.Width, 0, 100.0f, 0.1f); + _cSaturation = new FloatValueBox(0, _cHue.X, _cHue.Bottom + ChannelsMargin, _cHue.Width, 0, 100.0f, 0.1f) + { + Parent = this + }; _cSaturation.ValueChanged += OnHSVChanged; - _cSaturation.Parent = this; // Value - _cValue = new FloatValueBox(0, _cHue.X, _cSaturation.Bottom + ChannelsMargin, _cHue.Width, 0, float.MaxValue, 0.1f); + _cValue = new FloatValueBox(0, _cHue.X, _cSaturation.Bottom + ChannelsMargin, _cHue.Width, 0, float.MaxValue, 0.1f) + { + Parent = this + }; _cValue.ValueChanged += OnHSVChanged; - _cValue.Parent = this; // Set valid dialog size based on UI content _dialogSize = Size = new Vector2(_cRed.Right + PickerMargin, 300); // Hex const float hexTextBoxWidth = 80; - _cHex = new TextBox(false, Width - hexTextBoxWidth - PickerMargin, _cSelector.Bottom + PickerMargin, hexTextBoxWidth); - _cHex.Parent = this; + _cHex = new TextBox(false, Width - hexTextBoxWidth - PickerMargin, _cSelector.Bottom + PickerMargin, hexTextBoxWidth) + { + Parent = this + }; _cHex.EditEnd += OnHexChanged; // Cancel diff --git a/Source/Editor/GUI/Docking/DockPanel.cs b/Source/Editor/GUI/Docking/DockPanel.cs index f6e10e653..2865515da 100644 --- a/Source/Editor/GUI/Docking/DockPanel.cs +++ b/Source/Editor/GUI/Docking/DockPanel.cs @@ -597,8 +597,10 @@ namespace FlaxEditor.GUI.Docking if (_tabsProxy == null) { // Create proxy and make set simple full dock - _tabsProxy = new DockPanelProxy(this); - _tabsProxy.Parent = this; + _tabsProxy = new DockPanelProxy(this) + { + Parent = this + }; _tabsProxy.UnlockChildrenRecursive(); } } diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index 748ae726c..f83f23ad9 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -496,8 +496,10 @@ namespace FlaxEditor.GUI.Docking private void ShowContextMenu(DockWindow tab, ref Vector2 location) { - var menu = new ContextMenu.ContextMenu(); - menu.Tag = tab; + var menu = new ContextMenu.ContextMenu + { + Tag = tab + }; tab.OnShowContextMenu(menu); menu.AddButton("Close", OnTabMenuCloseClicked); menu.AddButton("Close All", OnTabMenuCloseAllClicked); diff --git a/Source/Editor/GUI/PrefabDiffContextMenu.cs b/Source/Editor/GUI/PrefabDiffContextMenu.cs index 9f40b11fb..8adda75e5 100644 --- a/Source/Editor/GUI/PrefabDiffContextMenu.cs +++ b/Source/Editor/GUI/PrefabDiffContextMenu.cs @@ -41,13 +41,19 @@ namespace FlaxEditor.GUI // Buttons float buttonsWidth = (width - 6.0f) * 0.5f; float buttonsHeight = 20.0f; - var revertAll = new Button(2.0f, 2.0f, buttonsWidth, buttonsHeight); - revertAll.Text = "Revert All"; - revertAll.Parent = this; + + var revertAll = new Button(2.0f, 2.0f, buttonsWidth, buttonsHeight) + { + Text = "Revert All", + Parent = this + }; revertAll.Clicked += OnRevertAllClicked; - var applyAll = new Button(revertAll.Right + 2.0f, 2.0f, buttonsWidth, buttonsHeight); - applyAll.Text = "Apply All"; - applyAll.Parent = this; + + var applyAll = new Button(revertAll.Right + 2.0f, 2.0f, buttonsWidth, buttonsHeight) + { + Text = "Apply All", + Parent = this + }; applyAll.Clicked += OnApplyAllClicked; // Actual panel @@ -56,6 +62,7 @@ namespace FlaxEditor.GUI Bounds = new Rectangle(0, applyAll.Bottom + 2.0f, Width, Height - applyAll.Bottom - 2.0f), Parent = this }; + Tree = new Tree.Tree { AnchorPreset = AnchorPresets.HorizontalStretchTop, diff --git a/Source/Editor/GUI/Timeline/Tracks/EventTrack.cs b/Source/Editor/GUI/Timeline/Tracks/EventTrack.cs index 683458b16..cdd6fc83f 100644 --- a/Source/Editor/GUI/Timeline/Tracks/EventTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/EventTrack.cs @@ -72,8 +72,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks { var time = stream.ReadSingle(); - var key = new EventKey(); - key.Parameters = new object[paramsCount]; + var key = new EventKey + { + Parameters = new object[paramsCount] + }; + for (int j = 0; j < paramsCount; j++) { stream.Read(dataBuffer, 0, e.EventParamsSizes[j]); @@ -316,8 +319,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks } // Build default value - var defaultValue = new EventKey(); - defaultValue.Parameters = new object[EventParamsTypes.Length]; + var defaultValue = new EventKey + { + Parameters = new object[EventParamsTypes.Length] + }; + for (int i = 0; i < EventParamsTypes.Length; i++) defaultValue.Parameters[i] = Activator.CreateInstance(EventParamsTypes[i]); Events.DefaultValue = defaultValue; diff --git a/Source/Engine/UI/GUI/RenderOutputControl.cs b/Source/Engine/UI/GUI/RenderOutputControl.cs index 74210c9df..be0c300fe 100644 --- a/Source/Engine/UI/GUI/RenderOutputControl.cs +++ b/Source/Engine/UI/GUI/RenderOutputControl.cs @@ -89,13 +89,11 @@ namespace FlaxEngine.GUI /// Invalid task. public RenderOutputControl(SceneRenderTask task) { - if (task == null) - throw new ArgumentNullException(); + _task = task ?? throw new ArgumentNullException(); _backBuffer = GPUDevice.Instance.CreateTexture(); _resizeTime = ResizeCheckTime; - _task = task; _task.Output = _backBuffer; _task.End += OnEnd;