From 607505a31653aaba31b15d1f0433f2c3ba6a452a Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:11:07 -0600 Subject: [PATCH 1/7] Always capitalize the first letter of a property name label --- Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs index b050e60c3..18bc1878d 100644 --- a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs +++ b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs @@ -51,6 +51,9 @@ namespace FlaxEditor.CustomEditors.GUI /// The name. public PropertyNameLabel(string name) { + // Format name with capital first letter + name = name[0].ToString().ToUpper() + name.Substring(1); + Text = name; HorizontalAlignment = TextAlignment.Near; VerticalAlignment = TextAlignment.Center; From 9d3b8eeeaff18ebc186e5ba7b3573196bad99aeb Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:21:48 -0600 Subject: [PATCH 2/7] changed to change it in property UI --- Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs | 3 --- Source/Editor/Utilities/Utils.cs | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs index 18bc1878d..b050e60c3 100644 --- a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs +++ b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs @@ -51,9 +51,6 @@ namespace FlaxEditor.CustomEditors.GUI /// The name. public PropertyNameLabel(string name) { - // Format name with capital first letter - name = name[0].ToString().ToUpper() + name.Substring(1); - Text = name; HorizontalAlignment = TextAlignment.Near; VerticalAlignment = TextAlignment.Center; diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index ea7f44efc..c89d824e7 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -912,6 +912,12 @@ namespace FlaxEditor.Utilities { var c = name[i]; + if (i == 0) + { + sb.Append(char.ToUpper(c)); + continue; + } + // Space before word starting with uppercase letter if (char.IsUpper(c) && i > 0) { From 5f83918c06d0b3717eef6ce2903803fe02374dbe Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:25:12 -0600 Subject: [PATCH 3/7] small fix --- Source/Editor/Utilities/Utils.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index c89d824e7..e4c06fd9b 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -906,13 +906,16 @@ namespace FlaxEditor.Utilities if (name.StartsWith("g_") || name.StartsWith("m_")) startIndex = 2; + if (name.StartsWith("_")) + startIndex = 1; + // Filter text var lastChar = '\0'; for (int i = startIndex; i < length; i++) { var c = name[i]; - if (i == 0) + if (i == startIndex) { sb.Append(char.ToUpper(c)); continue; From f52e76fe309ef15b5b582e0c017f5ea7b622d91f Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:11:07 -0600 Subject: [PATCH 4/7] Always capitalize the first letter of a property name label --- Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs index b050e60c3..18bc1878d 100644 --- a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs +++ b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs @@ -51,6 +51,9 @@ namespace FlaxEditor.CustomEditors.GUI /// The name. public PropertyNameLabel(string name) { + // Format name with capital first letter + name = name[0].ToString().ToUpper() + name.Substring(1); + Text = name; HorizontalAlignment = TextAlignment.Near; VerticalAlignment = TextAlignment.Center; From cf908fcfeb30c3e7d283a82e72a498b5a7554c35 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:21:48 -0600 Subject: [PATCH 5/7] changed to change it in property UI --- Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs | 3 --- Source/Editor/Utilities/Utils.cs | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs index 18bc1878d..b050e60c3 100644 --- a/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs +++ b/Source/Editor/CustomEditors/GUI/PropertyNameLabel.cs @@ -51,9 +51,6 @@ namespace FlaxEditor.CustomEditors.GUI /// The name. public PropertyNameLabel(string name) { - // Format name with capital first letter - name = name[0].ToString().ToUpper() + name.Substring(1); - Text = name; HorizontalAlignment = TextAlignment.Near; VerticalAlignment = TextAlignment.Center; diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index ea7f44efc..c89d824e7 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -912,6 +912,12 @@ namespace FlaxEditor.Utilities { var c = name[i]; + if (i == 0) + { + sb.Append(char.ToUpper(c)); + continue; + } + // Space before word starting with uppercase letter if (char.IsUpper(c) && i > 0) { From 7c3d5d739a2a9cf4092733914e4c61e8dd407908 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 15:25:12 -0600 Subject: [PATCH 6/7] small fix --- Source/Editor/Utilities/Utils.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index c89d824e7..e4c06fd9b 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -906,13 +906,16 @@ namespace FlaxEditor.Utilities if (name.StartsWith("g_") || name.StartsWith("m_")) startIndex = 2; + if (name.StartsWith("_")) + startIndex = 1; + // Filter text var lastChar = '\0'; for (int i = startIndex; i < length; i++) { var c = name[i]; - if (i == 0) + if (i == startIndex) { sb.Append(char.ToUpper(c)); continue; From 80baa1381460baad30708d97ab4294025b8e4223 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 29 Dec 2022 21:14:51 -0600 Subject: [PATCH 7/7] Fix tests to match captial first letter --- Source/Tools/FlaxEngine.Tests/TestPropertyNameUI.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Tools/FlaxEngine.Tests/TestPropertyNameUI.cs b/Source/Tools/FlaxEngine.Tests/TestPropertyNameUI.cs index 0b7644190..14adb0c40 100644 --- a/Source/Tools/FlaxEngine.Tests/TestPropertyNameUI.cs +++ b/Source/Tools/FlaxEngine.Tests/TestPropertyNameUI.cs @@ -11,10 +11,10 @@ namespace FlaxEditor.Tests [Test] public void TestFormatting() { - Assert.AreEqual("property", Utils.GetPropertyNameUI("property")); - Assert.AreEqual("property", Utils.GetPropertyNameUI("_property")); - Assert.AreEqual("property", Utils.GetPropertyNameUI("m_property")); - Assert.AreEqual("property", Utils.GetPropertyNameUI("g_property")); + Assert.AreEqual("Property", Utils.GetPropertyNameUI("property")); + Assert.AreEqual("Property", Utils.GetPropertyNameUI("_property")); + Assert.AreEqual("Property", Utils.GetPropertyNameUI("m_property")); + Assert.AreEqual("Property", Utils.GetPropertyNameUI("g_property")); Assert.AreEqual("Property", Utils.GetPropertyNameUI("Property")); Assert.AreEqual("Property 1", Utils.GetPropertyNameUI("Property1")); Assert.AreEqual("Property Name", Utils.GetPropertyNameUI("PropertyName"));