json generator alternator and vibrator (#718)
* json generator alternator and vibrator * каким хуем ты не закоммитился уебан
This commit is contained in:
40
Content.Server/_White/GuideGenerator/ReagentEffectEntry.cs
Normal file
40
Content.Server/_White/GuideGenerator/ReagentEffectEntry.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Content.Server._White.GuideGenerator;
|
||||
public sealed class ReagentEffectEntry
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public string Id { get; }
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string Description { get; }
|
||||
|
||||
public ReagentEffectEntry(ReagentEffect proto)
|
||||
{
|
||||
var prototype = IoCManager.Resolve<IPrototypeManager>();
|
||||
var entSys = IoCManager.Resolve<IEntitySystemManager>();
|
||||
|
||||
Id = proto.GetType().Name;
|
||||
Description = GuidebookEffectDescriptionToWeb(proto.GuidebookEffectDescription(prototype, entSys) ?? "");
|
||||
}
|
||||
|
||||
private string GuidebookEffectDescriptionToWeb(string guideBookText)
|
||||
{
|
||||
guideBookText = guideBookText.Replace("[", "<");
|
||||
guideBookText = guideBookText.Replace("]", ">");
|
||||
guideBookText = guideBookText.Replace("color", "span");
|
||||
|
||||
while (guideBookText.IndexOf("<span=") != -1)
|
||||
{
|
||||
var first = guideBookText.IndexOf("<span=") + "<span=".Length - 1;
|
||||
var last = guideBookText.IndexOf(">", first);
|
||||
var replacementString = guideBookText.Substring(first, last - first);
|
||||
var color = replacementString.Substring(1);
|
||||
guideBookText = guideBookText.Replace(replacementString, string.Format(" style=\"color: {0};\"", color));
|
||||
}
|
||||
|
||||
return guideBookText;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user