SMSModLogOutputAnalyzer/SMSModLogOutputAnalyzer/Data/Flowchart.cs
Jonathan Riedel 7f08d72ef8 Refactored a bunch of things
Added Notes Module + Data Structure
Added Config Module + Data Structure
Added Role Buttons Module + Data Structure
2024-04-12 02:25:32 +02:00

41 lines
No EOL
1.7 KiB
C#

namespace SMSModLogOutputAnalyzer
{
internal partial class Flowchart
{
public static Flowchart Parse(string file) => Parse(file.Split('\n'));
public static Flowchart Parse(string[] lines)
{
Flowchart flowchart = new();
foreach (var line in lines)
{
if (line.Contains("-->"))
{
var fc = new FlowchartConnection();
fc.FromName = line.Split("-->")[0].Trim().ToLower();
if (line.Contains("|"))
{
fc.ToName = line.Split('|')[2].Trim().ToLower();
fc.Text = line.Split('|')[1].Trim().Replace("\\n", "").Replace("]", "");
} else
{
fc.ToName = line.Split("-->")[1].Trim().ToLower();
fc.Text = "Next";
}
flowchart.Connections.Add(fc);
}
else
{
string name = line.Split('[')[0].Trim().ToLower();
string text = line.Split('[')[1].Split("<sub>")[0].Replace("\\n", "").Replace("]", "");
string description = line.Contains("<sub>") ? line.Split("<sub>")[1].Trim().Trim(']').Replace("\\n", "\n") : "";
flowchart.Nodes.Add(new FlowchartNode { Name = name, Text = text, Description = description });
}
}
return flowchart;
}
public List<FlowchartNode> Nodes { get; set; } = new();
public List<FlowchartConnection> Connections { get; set; } = new();
}
}