chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Lib.@string.convert;
|
||||
|
||||
[Guid("39c96cfd-dedf-4f76-a471-d1c26c9ba9fa")]
|
||||
internal sealed class FloatToString : Instance<FloatToString>
|
||||
{
|
||||
[Output(Guid = "{C63A1977-A594-490D-B5FB-DE4D40BAD016}")]
|
||||
public readonly Slot<string> Output = new();
|
||||
|
||||
public FloatToString()
|
||||
{
|
||||
Output.UpdateAction += Update;
|
||||
}
|
||||
|
||||
private void Update(EvaluationContext context)
|
||||
{
|
||||
var v = Value.GetValue(context);
|
||||
var s = Format.GetValue(context);
|
||||
try
|
||||
{
|
||||
Output.Value = string.IsNullOrEmpty(s) ? v.ToString(CultureInfo.InvariantCulture) : string.Format(CultureInfo.InvariantCulture, s, v);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Output.Value = "Invalid Format";
|
||||
}
|
||||
}
|
||||
|
||||
[Input(Guid = "{F36E4078-2608-4308-AB5F-077C05B1181A}")]
|
||||
public readonly InputSlot<float> Value = new();
|
||||
|
||||
[Input(Guid = "{B2B32C44-62D8-4ACB-A9A7-4856EC7A33BB}")]
|
||||
public readonly InputSlot<string> Format = new();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "39c96cfd-dedf-4f76-a471-d1c26c9ba9fa"/*FloatToString*/,
|
||||
"Inputs": [
|
||||
{
|
||||
"Id": "b2b32c44-62d8-4acb-a9a7-4856ec7a33bb"/*Format*/,
|
||||
"DefaultValue": "{0:0.000}"
|
||||
},
|
||||
{
|
||||
"Id": "f36e4078-2608-4308-ab5f-077c05b1181a"/*Value*/,
|
||||
"DefaultValue": 0.0
|
||||
}
|
||||
],
|
||||
"Children": [],
|
||||
"Connections": []
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "39c96cfd-dedf-4f76-a471-d1c26c9ba9fa"/*FloatToString*/,
|
||||
"Description": "Converts a float value into a string.\n\nYou can use the .net string format descriptor for various effects, like...\n\nHere are some examples for the value 1.2345\n\n{0:P1} -> 123.45%\n{0:000.000} -> 001.234\n{0:0} -> 1\n{0:G3} -> 1.23\nneed {0:1.2} cookies -> need 1.2 cookies\n",
|
||||
"SymbolTags": "1",
|
||||
"InputUis": [
|
||||
{
|
||||
"InputId": "b2b32c44-62d8-4acb-a9a7-4856ec7a33bb"/*Format*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
},
|
||||
"Usage": "Default"
|
||||
},
|
||||
{
|
||||
"InputId": "f36e4078-2608-4308-ab5f-077c05b1181a"/*Value*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
},
|
||||
"Min": -221.0,
|
||||
"Max": 302.0
|
||||
}
|
||||
],
|
||||
"SymbolChildUis": [],
|
||||
"OutputUis": [
|
||||
{
|
||||
"OutputId": "c63a1977-a594-490d-b5fb-de4d40bad016"/*Output*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Lib.@string.convert;
|
||||
|
||||
[Guid("416a1c8d-4143-4de7-bcf9-466c4009112a")]
|
||||
internal sealed class IntToString : Instance<IntToString>
|
||||
{
|
||||
[Output(Guid = "460f2a09-b706-4e1e-a1fb-32eeab51524b")]
|
||||
public readonly Slot<string> Output = new();
|
||||
|
||||
public IntToString()
|
||||
{
|
||||
Output.UpdateAction += Update;
|
||||
}
|
||||
|
||||
private void Update(EvaluationContext context)
|
||||
{
|
||||
var v = Value.GetValue(context);
|
||||
var s = Format.GetValue(context);
|
||||
try
|
||||
{
|
||||
Output.Value = string.IsNullOrEmpty(s) ? v.ToString(CultureInfo.InvariantCulture) : string.Format(CultureInfo.InvariantCulture, s, v);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Output.Value = "Invalid Format";
|
||||
}
|
||||
}
|
||||
|
||||
[Input(Guid = "3C1A8975-AB27-40B3-9FEE-7DE38643294A")]
|
||||
public readonly InputSlot<int> Value = new();
|
||||
|
||||
[Input(Guid = "a9dd6368-455d-4b1d-8685-02d8f7640ecf")]
|
||||
public readonly InputSlot<string> Format = new();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "416a1c8d-4143-4de7-bcf9-466c4009112a"/*IntToString*/,
|
||||
"Inputs": [
|
||||
{
|
||||
"Id": "3c1a8975-ab27-40b3-9fee-7de38643294a"/*Value*/,
|
||||
"DefaultValue": 0
|
||||
},
|
||||
{
|
||||
"Id": "a9dd6368-455d-4b1d-8685-02d8f7640ecf"/*Format*/,
|
||||
"DefaultValue": "{0:0}"
|
||||
}
|
||||
],
|
||||
"Children": [],
|
||||
"Connections": []
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "416a1c8d-4143-4de7-bcf9-466c4009112a"/*IntToString*/,
|
||||
"Description": "Converts an [IntValue] to a string.\n\nTip: You can override the string formatting to something like... \"{0:0} times\" add prefixes or suffixes.",
|
||||
"SymbolTags": "1",
|
||||
"InputUis": [
|
||||
{
|
||||
"InputId": "3c1a8975-ab27-40b3-9fee-7de38643294a"/*Value*/,
|
||||
"Position": {
|
||||
"X": -200.0,
|
||||
"Y": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"InputId": "a9dd6368-455d-4b1d-8685-02d8f7640ecf"/*Format*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
},
|
||||
"Usage": "Default"
|
||||
}
|
||||
],
|
||||
"SymbolChildUis": [],
|
||||
"OutputUis": [
|
||||
{
|
||||
"OutputId": "460f2a09-b706-4e1e-a1fb-32eeab51524b"/*Output*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace Lib.@string.convert;
|
||||
|
||||
[Guid("06ae6091-ce81-4e8f-ae96-83c189c70b10")]
|
||||
internal sealed class Vec3ToString : Instance<Vec3ToString>
|
||||
{
|
||||
[Output(Guid = "bc59ac99-0e6f-4d8a-8896-661b45c86ecd")]
|
||||
public readonly Slot<string> Output = new();
|
||||
|
||||
public Vec3ToString()
|
||||
{
|
||||
Output.UpdateAction += Update;
|
||||
}
|
||||
|
||||
private void Update(EvaluationContext context)
|
||||
{
|
||||
var v = Vector.GetValue(context);
|
||||
var s = Format.GetValue(context);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
// Fixed width: 7 chars total (e.g., " -1.50" or " 1.50")
|
||||
Output.Value = string.Format(CultureInfo.InvariantCulture,
|
||||
"X: {0,7:F2}\nY: {1,7:F2}\nZ: {2,7:F2}", v.X, v.Y, v.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace literal \n with actual newline characters
|
||||
var formatWithNewlines = s.Replace("\\n", "\n");
|
||||
Output.Value = string.Format(CultureInfo.InvariantCulture, formatWithNewlines, v.X, v.Y, v.Z);
|
||||
}
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Output.Value = "Invalid Format";
|
||||
}
|
||||
}
|
||||
|
||||
[Input(Guid = "0035b185-2e0b-4854-842a-4965180177f1")]
|
||||
public readonly InputSlot<Vector3> Vector = new();
|
||||
|
||||
[Input(Guid = "045e84e3-2456-46fb-af43-30549e08afbd")]
|
||||
public readonly InputSlot<string> Format = new();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "06ae6091-ce81-4e8f-ae96-83c189c70b10"/*Vec3ToString*/,
|
||||
"Inputs": [
|
||||
{
|
||||
"Id": "0035b185-2e0b-4854-842a-4965180177f1"/*Vector*/,
|
||||
"DefaultValue": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0,
|
||||
"Z": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"Id": "045e84e3-2456-46fb-af43-30549e08afbd"/*Format*/,
|
||||
"DefaultValue": ""
|
||||
}
|
||||
],
|
||||
"Children": [],
|
||||
"Connections": []
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"FormatVersion": 3,
|
||||
"Id": "06ae6091-ce81-4e8f-ae96-83c189c70b10"/*Vec3ToString*/,
|
||||
"Description": "Converts a Vector3 into a string.\n\nFormats examples: \n({0:F2}, {1:F2}, {2:F2})\nResult: \n(0.00, 1.00, 2.00)\n\nX: {0,7:F2}\\nY: {1,7:F2}\\nZ: {2,7:F2} \nResult:\nX: 1.50\nY: 2.50\nZ: 3.50\n\n",
|
||||
"InputUis": [
|
||||
{
|
||||
"InputId": "0035b185-2e0b-4854-842a-4965180177f1"/*Vector*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
},
|
||||
"Min": -221.0,
|
||||
"Max": 302.0,
|
||||
"Scale": 5.23
|
||||
},
|
||||
{
|
||||
"InputId": "045e84e3-2456-46fb-af43-30549e08afbd"/*Format*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
},
|
||||
"Usage": "Default"
|
||||
}
|
||||
],
|
||||
"SymbolChildUis": [],
|
||||
"OutputUis": [
|
||||
{
|
||||
"OutputId": "bc59ac99-0e6f-4d8a-8896-661b45c86ecd"/*Output*/,
|
||||
"Position": {
|
||||
"X": 0.0,
|
||||
"Y": 0.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user