Cleanup 2

This commit is contained in:
W2.Wizard
2021-02-21 10:23:01 +01:00
parent 52bc268ee7
commit 92fafe877c
11 changed files with 234 additions and 143 deletions

View File

@@ -138,8 +138,11 @@ namespace FlaxEditor.Modules
public void CreateSceneFile(string path)
{
// Create a sample scene
var scene = new Scene();
scene.StaticFlags = StaticFlags.FullyStatic;
var scene = new Scene
{
StaticFlags = StaticFlags.FullyStatic
};
//
var sun = scene.AddChild<DirectionalLight>();
sun.Name = "Sun";

View File

@@ -378,8 +378,10 @@ namespace FlaxEditor.Modules
private void InitMainMenu(RootControl mainWindow)
{
MainMenu = new MainMenu(mainWindow);
MainMenu.Parent = mainWindow;
MainMenu = new MainMenu(mainWindow)
{
Parent = mainWindow
};
// File
MenuFile = MainMenu.AddButton("File");

View File

@@ -21,9 +21,11 @@ namespace FlaxEditor.Options
// Reset options button
layout.Space(30);
var panel = layout.Space(30);
var resetButton = new Button(4, 4, 100);
resetButton.Text = "Reset";
resetButton.Parent = panel.ContainerControl;
var resetButton = new Button(4, 4, 100)
{
Text = "Reset",
Parent = panel.ContainerControl
};
resetButton.Clicked += OnResetButtonClicked;
}

View File

@@ -212,45 +212,46 @@ namespace FlaxEditor.Options
/// <returns>The style object.</returns>
public Style CreateDefaultStyle()
{
var style = new Style();
// Metro Style colors
style.Background = Color.FromBgra(0xFF1C1C1C);
style.LightBackground = Color.FromBgra(0xFF2D2D30);
style.Foreground = Color.FromBgra(0xFFFFFFFF);
style.ForegroundGrey = Color.FromBgra(0xFFA9A9B3);
style.ForegroundDisabled = Color.FromBgra(0xFF787883);
style.BackgroundHighlighted = Color.FromBgra(0xFF54545C);
style.BorderHighlighted = Color.FromBgra(0xFF6A6A75);
style.BackgroundSelected = Color.FromBgra(0xFF007ACC);
style.BorderSelected = Color.FromBgra(0xFF1C97EA);
style.BackgroundNormal = Color.FromBgra(0xFF3F3F46);
style.BorderNormal = Color.FromBgra(0xFF54545C);
style.TextBoxBackground = Color.FromBgra(0xFF333337);
style.TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46);
var options = Options;
var style = new Style
{
Background = Color.FromBgra(0xFF1C1C1C),
LightBackground = Color.FromBgra(0xFF2D2D30),
Foreground = Color.FromBgra(0xFFFFFFFF),
ForegroundGrey = Color.FromBgra(0xFFA9A9B3),
ForegroundDisabled = Color.FromBgra(0xFF787883),
BackgroundHighlighted = Color.FromBgra(0xFF54545C),
BorderHighlighted = Color.FromBgra(0xFF6A6A75),
BackgroundSelected = Color.FromBgra(0xFF007ACC),
BorderSelected = Color.FromBgra(0xFF1C97EA),
BackgroundNormal = Color.FromBgra(0xFF3F3F46),
BorderNormal = Color.FromBgra(0xFF54545C),
TextBoxBackground = Color.FromBgra(0xFF333337),
TextBoxBackgroundSelected = Color.FromBgra(0xFF3F3F46),
// Fonts
FontTitle = options.Interface.TitleFont.GetFont(),
FontLarge = options.Interface.LargeFont.GetFont(),
FontMedium = options.Interface.MediumFont.GetFont(),
FontSmall = options.Interface.SmallFont.GetFont(),
// Icons
ArrowDown = Editor.Icons.ArrowDown12,
ArrowRight = Editor.Icons.ArrowRight12,
Search = Editor.Icons.Search12,
Settings = Editor.Icons.Settings12,
Cross = Editor.Icons.Cross12,
CheckBoxIntermediate = Editor.Icons.CheckBoxIntermediate12,
CheckBoxTick = Editor.Icons.CheckBoxTick12,
StatusBarSizeGrip = Editor.Icons.StatusBarSizeGrip12,
Translate = Editor.Icons.Translate16,
Rotate = Editor.Icons.Rotate16,
Scale = Editor.Icons.Scale16
};
style.DragWindow = style.BackgroundSelected * 0.7f;
style.ProgressNormal = Color.FromBgra(0xFF0ad328);
// Fonts
var options = Options;
style.FontTitle = options.Interface.TitleFont.GetFont();
style.FontLarge = options.Interface.LargeFont.GetFont();
style.FontMedium = options.Interface.MediumFont.GetFont();
style.FontSmall = options.Interface.SmallFont.GetFont();
// Icons
style.ArrowDown = Editor.Icons.ArrowDown12;
style.ArrowRight = Editor.Icons.ArrowRight12;
style.Search = Editor.Icons.Search12;
style.Settings = Editor.Icons.Settings12;
style.Cross = Editor.Icons.Cross12;
style.CheckBoxIntermediate = Editor.Icons.CheckBoxIntermediate12;
style.CheckBoxTick = Editor.Icons.CheckBoxTick12;
style.StatusBarSizeGrip = Editor.Icons.StatusBarSizeGrip12;
style.Translate = Editor.Icons.Translate16;
style.Rotate = Editor.Icons.Rotate16;
style.Scale = Editor.Icons.Scale16;
style.SharedTooltip = new Tooltip();
return style;

View File

@@ -386,15 +386,20 @@ namespace FlaxEditor.SceneGraph.GUI
public ReparentAction(List<Actor> actors)
{
var allActors = new List<Actor>();
allActors.Capacity = Mathf.NextPowerOfTwo(actors.Count);
var allActors = new List<Actor>
{
Capacity = Mathf.NextPowerOfTwo(actors.Count)
};
for (int i = 0; i < actors.Count; i++)
{
GetAllActors(allActors, actors[i]);
}
var allScripts = new List<Script>();
allScripts.Capacity = allActors.Capacity;
var allScripts = new List<Script>
{
Capacity = allActors.Capacity
};
GetAllScripts(allActors, allScripts);
int allCount = allActors.Count + allScripts.Count;
@@ -570,11 +575,14 @@ namespace FlaxEditor.SceneGraph.GUI
{
// Create actor
var model = FlaxEngine.Content.LoadAsync<SkinnedModel>(assetItem.ID);
var actor = new AnimatedModel();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.SkinnedModel = model;
actor.Transform = Actor.Transform;
var actor = new AnimatedModel
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
SkinnedModel = model,
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -583,11 +591,14 @@ namespace FlaxEditor.SceneGraph.GUI
{
// Create actor
var model = FlaxEngine.Content.LoadAsync<Model>(assetItem.ID);
var actor = new StaticModel();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Model = model;
actor.Transform = Actor.Transform;
var actor = new StaticModel
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Model = model,
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -595,11 +606,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<CollisionData>())
{
// Create actor
var actor = new MeshCollider();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.CollisionData = FlaxEngine.Content.LoadAsync<CollisionData>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new MeshCollider
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
CollisionData = FlaxEngine.Content.LoadAsync<CollisionData>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -607,11 +620,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<ParticleSystem>())
{
// Create actor
var actor = new ParticleEffect();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.ParticleSystem = FlaxEngine.Content.LoadAsync<ParticleSystem>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new ParticleEffect
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
ParticleSystem = FlaxEngine.Content.LoadAsync<ParticleSystem>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -619,11 +634,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<SceneAnimation>())
{
// Create actor
var actor = new SceneAnimationPlayer();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Animation = FlaxEngine.Content.LoadAsync<SceneAnimation>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new SceneAnimationPlayer
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Animation = FlaxEngine.Content.LoadAsync<SceneAnimation>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);
@@ -631,11 +648,13 @@ namespace FlaxEditor.SceneGraph.GUI
else if (assetItem.IsOfType<AudioClip>())
{
// Create actor
var actor = new AudioSource();
actor.StaticFlags = Actor.StaticFlags;
actor.Name = assetItem.ShortName;
actor.Clip = FlaxEngine.Content.LoadAsync<AudioClip>(assetItem.ID);
actor.Transform = Actor.Transform;
var actor = new AudioSource
{
StaticFlags = Actor.StaticFlags,
Name = assetItem.ShortName,
Clip = FlaxEngine.Content.LoadAsync<AudioClip>(assetItem.ID),
Transform = Actor.Transform
};
// Spawn
ActorNode.Root.Spawn(actor, Actor);

View File

@@ -396,34 +396,45 @@ namespace FlaxEditor.Surface.Archetypes
{
var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY;
_selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY);
_selectedAnimationLabel.HorizontalAlignment = TextAlignment.Near;
_selectedAnimationLabel.Text = "Selected Animation:";
_selectedAnimationLabel.Parent = this;
_selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Selected Animation:",
Parent = this
};
_selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width)
{
Parent = this
};
_selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width);
_selectedAnimation.PopupShowing += OnSelectedAnimationPopupShowing;
_selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged;
_selectedAnimation.Parent = this;
var items = new List<string>(MaxAnimationsCount);
while (items.Count < MaxAnimationsCount)
items.Add(string.Empty);
_selectedAnimation.Items = items;
_animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4));
_animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4))
{
Parent = this
};
_animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged;
_animationPicker.Parent = this;
_animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight);
_animationSpeedLabel.HorizontalAlignment = TextAlignment.Near;
_animationSpeedLabel.Text = "Speed:";
_animationSpeedLabel.Parent = this;
_animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Speed:",
Parent = this
};
_animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4);
_animationSpeed.SlideSpeed = 0.01f;
_animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationSpeed.ValueChanged += OnAnimationSpeedValueChanged;
_animationSpeed.Parent = this;
}
private void OnSelectedAnimationPopupShowing(ComboBox comboBox)
@@ -619,15 +630,19 @@ namespace FlaxEditor.Surface.Archetypes
public MultiBlend1D(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationXLabel.HorizontalAlignment = TextAlignment.Near;
_animationXLabel.Text = "X:";
_animationXLabel.Parent = this;
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBoxBase.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "X:",
Parent = this
};
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4);
_animationX.SlideSpeed = 0.01f;
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationX.ValueChanged += OnAnimationXChanged;
_animationX.Parent = this;
_editor = new Editor(this,
FlaxEditor.Surface.Constants.NodeMarginX,
@@ -745,25 +760,33 @@ namespace FlaxEditor.Surface.Archetypes
public MultiBlend2D(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
: base(id, context, nodeArch, groupArch)
{
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationXLabel.HorizontalAlignment = TextAlignment.Near;
_animationXLabel.Text = "X:";
_animationXLabel.Parent = this;
_animationXLabel = new Label(_animationSpeedLabel.Left, _animationSpeedLabel.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "X:",
Parent = this
};
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4);
_animationX.SlideSpeed = 0.01f;
_animationX = new FloatValueBox(0.0f, _animationXLabel.Right + 4, _animationXLabel.Y, _selectedAnimation.Right - _animationXLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationX.ValueChanged += OnAnimationXChanged;
_animationX.Parent = this;
_animationYLabel = new Label(_animationXLabel.Left, _animationXLabel.Bottom + 4, 40, TextBox.DefaultHeight);
_animationYLabel.HorizontalAlignment = TextAlignment.Near;
_animationYLabel.Text = "Y:";
_animationYLabel.Parent = this;
_animationYLabel = new Label(_animationXLabel.Left, _animationXLabel.Bottom + 4, 40, TextBox.DefaultHeight)
{
HorizontalAlignment = TextAlignment.Near,
Text = "Y:",
Parent = this
};
_animationY = new FloatValueBox(0.0f, _animationYLabel.Right + 4, _animationYLabel.Y, _selectedAnimation.Right - _animationYLabel.Right - 4);
_animationY.SlideSpeed = 0.01f;
_animationY = new FloatValueBox(0.0f, _animationYLabel.Right + 4, _animationYLabel.Y, _selectedAnimation.Right - _animationYLabel.Right - 4)
{
SlideSpeed = 0.01f,
Parent = this
};
_animationY.ValueChanged += OnAnimationYChanged;
_animationY.Parent = this;
_editor = new Editor(this,
FlaxEditor.Surface.Constants.NodeMarginX,

View File

@@ -81,9 +81,11 @@ namespace FlaxEditor.Surface.Archetypes
var marginX = FlaxEditor.Surface.Constants.NodeMarginX;
var uiStartPosY = FlaxEditor.Surface.Constants.NodeMarginY + FlaxEditor.Surface.Constants.NodeHeaderSize;
var editButton = new Button(marginX, uiStartPosY, 246, 20);
editButton.Text = "Edit";
editButton.Parent = this;
var editButton = new Button(marginX, uiStartPosY, 246, 20)
{
Text = "Edit",
Parent = this
};
editButton.Clicked += Edit;
var maxTransitionsPerUpdateLabel = new Label(marginX, editButton.Bottom + 4, 153, TextBox.DefaultHeight)

View File

@@ -1432,8 +1432,11 @@ namespace FlaxEditor.Surface.Archetypes
private void LoadSignature()
{
_signature = new Signature();
_signature.Node = this;
_signature = new Signature
{
Node = this
};
if (Values[0] is byte[] data && data.Length != 0)
{
using (var stream = new MemoryStream(data))

View File

@@ -171,16 +171,22 @@ namespace FlaxEditor.Surface.ContextMenu
// Check if can create group for them
if (nodes.Count > 0)
{
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
for (int i = 0; i < nodes.Count; i++)
{
var item = new VisjectCMItem(group, groupArchetype, nodes[i]);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodes[i])
{
Parent = group
};
}
group.SortChildren();
group.Parent = panel2;
_groups.Add(group);
}
}
@@ -209,16 +215,21 @@ namespace FlaxEditor.Surface.ContextMenu
// Create new group if name is unique
if (group == null)
{
group = new VisjectCMGroup(this, info.CustomNodesGroup);
group.HeaderText = groupName;
group = new VisjectCMGroup(this, info.CustomNodesGroup)
{
HeaderText = groupName
};
group.Close(false);
group.Parent = _groupsPanel;
_groups.Add(group);
}
// Add new item
var item = new VisjectCMItem(group, info.CustomNodesGroup, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, info.CustomNodesGroup, nodeArchetype)
{
Parent = group
};
// Order items
group.SortChildren();
@@ -237,16 +248,23 @@ namespace FlaxEditor.Surface.ContextMenu
{
Profiler.BeginEvent("VisjectCM.AddGroup");
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
foreach (var nodeArchetype in groupArchetype.Archetypes)
{
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype)
{
Parent = group
};
}
group.SortChildren();
group.Parent = _groupsPanel;
_groups.Add(group);
if (!IsLayoutLocked)
@@ -281,17 +299,24 @@ namespace FlaxEditor.Surface.ContextMenu
var groups = new List<VisjectCMGroup>();
foreach (var groupArchetype in groupArchetypes)
{
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
foreach (var nodeArchetype in groupArchetype.Archetypes)
{
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, nodeArchetype)
{
Parent = group
};
}
group.SortChildren();
group.Parent = _groupsPanel;
_groups.Add(group);
groups.Add(group);
}
Profiler.EndEvent();
@@ -497,8 +522,11 @@ namespace FlaxEditor.Surface.ContextMenu
Archetypes = archetypes
};
var group = new VisjectCMGroup(this, groupArchetype);
group.HeaderText = groupArchetype.Name;
var group = new VisjectCMGroup(this, groupArchetype)
{
HeaderText = groupArchetype.Name
};
group.Close(false);
archetypeIndex = 0;
for (int i = 0; i < parameters.Count; i++)
@@ -507,13 +535,17 @@ namespace FlaxEditor.Surface.ContextMenu
if (!param.IsPublic)
continue;
var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
item.Parent = group;
var item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++])
{
Parent = group
};
if (_parameterSetNodeArchetype != null)
{
item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++]);
item.Parent = group;
item = new VisjectCMItem(group, groupArchetype, archetypes[archetypeIndex++])
{
Parent = group
};
}
}
group.SortChildren();

View File

@@ -179,8 +179,10 @@ namespace FlaxEditor.Tools.Terrain
// Start async work
_terrain = terrain;
var thread = new System.Threading.Thread(Generate);
thread.Name = "Terrain Generator";
var thread = new System.Threading.Thread(Generate)
{
Name = "Terrain Generator"
};
thread.Start();
}

View File

@@ -73,8 +73,10 @@ namespace FlaxEditor.Windows.Assets
// Create popup
var contextMenu = new ContextMenu();
contextMenu.MinimumWidth = 120;
var contextMenu = new ContextMenu
{
MinimumWidth = 120
};
// Basic editing options