From 6fe19fc9d0a93adbbbf7f64b3035e6bb96c0341b Mon Sep 17 00:00:00 2001 From: bonnibel Date: Tue, 21 Nov 2023 01:16:41 -0800 Subject: [PATCH] Fixed warnings and string serializer. --- src/Murder.Editor/CustomFields/StringField.cs | 19 ++++++++++++++++++- .../InteractOnCollisionComponent.cs | 1 + src/Murder/Core/Grid/GridConfiguration.cs | 2 +- .../Core/Particles/ParticleSystemTracker.cs | 1 - 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Murder.Editor/CustomFields/StringField.cs b/src/Murder.Editor/CustomFields/StringField.cs index e4ccd9f2e..c5f1ec26e 100644 --- a/src/Murder.Editor/CustomFields/StringField.cs +++ b/src/Murder.Editor/CustomFields/StringField.cs @@ -14,7 +14,24 @@ internal class StringField : CustomField public override (bool modified, object? result) ProcessInput(EditorMember member, object? fieldValue) { bool modified = false; - string text = fieldValue as string ?? string.Empty; + string? text = fieldValue as string; + + if (text is null) + { + string buttonText = "Create Default"; + if (AttributeExtensions.TryGetAttribute(member, out DefaultAttribute? defaultAttribute)) + { + buttonText = defaultAttribute.Text; + } + + if (ImGui.Button(buttonText)) + { + modified = true; + text = string.Empty; + } + + return (modified, text); + } if (AttributeExtensions.IsDefined(member, typeof(AtlasCoordinatesAttribute))) { diff --git a/src/Murder/Components/Interactions/InteractOnCollisionComponent.cs b/src/Murder/Components/Interactions/InteractOnCollisionComponent.cs index 109c1268a..702d76fdd 100644 --- a/src/Murder/Components/Interactions/InteractOnCollisionComponent.cs +++ b/src/Murder/Components/Interactions/InteractOnCollisionComponent.cs @@ -1,6 +1,7 @@ using Bang.Components; using Bang.Interactions; using Murder.Attributes; +using Murder.Utilities.Attributes; using System.Collections.Immutable; namespace Murder.Components diff --git a/src/Murder/Core/Grid/GridConfiguration.cs b/src/Murder/Core/Grid/GridConfiguration.cs index b54769e7b..48f4823fd 100644 --- a/src/Murder/Core/Grid/GridConfiguration.cs +++ b/src/Murder/Core/Grid/GridConfiguration.cs @@ -60,7 +60,7 @@ public GridConfiguration(int cellSize) public int FloorToGrid(float value) => value % CellSize == 0 ? Calculator.RoundToInt(value / CellSize) : Calculator.FloorToInt(value / CellSize); /// - /// Find in which cell of the grid a value would land, with default behavior. + /// Find in which cell of the grid a value would land, with default behavior. /// /// The point in the grid /// The cell this would land at. diff --git a/src/Murder/Core/Particles/ParticleSystemTracker.cs b/src/Murder/Core/Particles/ParticleSystemTracker.cs index 2a1e5c3a6..fb5a81fe9 100644 --- a/src/Murder/Core/Particles/ParticleSystemTracker.cs +++ b/src/Murder/Core/Particles/ParticleSystemTracker.cs @@ -53,7 +53,6 @@ public ParticleSystemTracker(Emitter emitter, Particle particle, int seed = 0) /// /// Makes a "step" throughout the particle system. /// - /// Delta time. /// Whether spawning new entities is allowed, e.g. the entity is not deactivated. /// Emitter position in game where the particles are fired from. /// Returns whether the emitter is still running.