feat(ui): add decision-log reader and overlay components
This commit is contained in:
parent
c1259ecba4
commit
2dc711a55c
9 changed files with 469 additions and 0 deletions
21
ui/JevOverlay/Core/OverlayConfig.cs
Normal file
21
ui/JevOverlay/Core/OverlayConfig.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Text.Json;
|
||||
|
||||
namespace JevOverlay.Core;
|
||||
|
||||
public static class OverlayConfig
|
||||
{
|
||||
public const string FileName = "JevOverlay.config.json";
|
||||
|
||||
public static string LoadLogPath(string modDirectory)
|
||||
{
|
||||
using var document = JsonDocument.Parse(File.ReadAllText(Path.Combine(modDirectory, FileName)));
|
||||
var root = document.RootElement;
|
||||
if (root.ValueKind != JsonValueKind.Object ||
|
||||
!root.TryGetProperty("log_path", out var value) ||
|
||||
value.ValueKind != JsonValueKind.String ||
|
||||
string.IsNullOrWhiteSpace(value.GetString()) ||
|
||||
!Path.IsPathFullyQualified(value.GetString()!))
|
||||
throw new FormatException("log_path must be an absolute file path.");
|
||||
return Path.GetFullPath(value.GetString()!);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue