Skip to content

Commit

Permalink
Update Scheme constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Dec 26, 2023
1 parent 4927c8c commit e1b783c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/HUDMerger/Models/Scheme/ClientScheme.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using VDF.Models;

namespace HUDMerger.Models.Scheme;

Expand All @@ -11,4 +12,8 @@ public ClientScheme() : base()
public ClientScheme(string filePath) : base(filePath)
{
}

public ClientScheme(string filePath, KeyValues keyValues) : base(filePath, keyValues)
{
}
}
8 changes: 5 additions & 3 deletions src/HUDMerger/Models/Scheme/SchemeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public SchemeBase()
{
}

public SchemeBase(string filePath)
public SchemeBase(string filePath) : this(filePath, VDFSerializer.Deserialize(File.ReadAllText(filePath)))
{
}

public SchemeBase(string filePath, KeyValues keyValues)
{
static SchemeFile? ReadBaseFile(FileInfo file)
{
Expand Down Expand Up @@ -153,8 +157,6 @@ public SchemeBase(string filePath)
static KeyValues GetValueOrDefault(KeyValues keyValues, string key) =>
keyValues.FirstOrDefault((kv) => StringComparer.OrdinalIgnoreCase.Equals(kv.Key, key)).Value is KeyValues v ? v : [];

KeyValues keyValues = VDFSerializer.Deserialize(File.ReadAllText(filePath));

KeyValues header = keyValues.Header();

foreach (KeyValue colour in GetValueOrDefault(header, "Colors"))
Expand Down
5 changes: 5 additions & 0 deletions src/HUDMerger/Models/Scheme/SourceScheme.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using VDF.Models;

namespace HUDMerger.Models.Scheme;

Expand All @@ -11,4 +12,8 @@ public SourceScheme() : base()
public SourceScheme(string filePath) : base(filePath)
{
}

public SourceScheme(string filePath, KeyValues keyValues) : base(filePath, keyValues)
{
}
}

0 comments on commit e1b783c

Please sign in to comment.