Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/*.csproj') }}
- name: Build
run: dotnet build -warnaserror
- name: Build and test
run: dotnet test -warnaserror
- name: Build nuget
if: github.event_name == 'workflow_dispatch'
run: dotnet pack PolyMod.csproj -o nuget
Expand Down
6 changes: 5 additions & 1 deletion PolyMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PolyMod", "PolyMod.csproj", "{58B09361-FD7A-48F1-82E1-E2359ADA512F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PolyMod", "src\PolyMod.csproj", "{58B09361-FD7A-48F1-82E1-E2359ADA512F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "tests\Tests.csproj", "{85432E7B-2023-477C-861E-0141E8974DDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -12,6 +14,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{58B09361-FD7A-48F1-82E1-E2359ADA512F}.IL2CPP|Any CPU.ActiveCfg = IL2CPP|Any CPU
{58B09361-FD7A-48F1-82E1-E2359ADA512F}.IL2CPP|Any CPU.Build.0 = IL2CPP|Any CPU
{85432E7B-2023-477C-861E-0141E8974DDC}.IL2CPP|Any CPU.ActiveCfg = Debug|Any CPU
{85432E7B-2023-477C-861E-0141E8974DDC}.IL2CPP|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 9 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
<add key="Samboy" value="https://nuget.samboy.dev/v3/index.json" />
<add key="PolyMod" value="https://polymod.dev/nuget/v3/index.json" />
</packageSources>
</configuration>
30 changes: 15 additions & 15 deletions src/Api/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ public Config(string modName, ConfigTypes configType)
switch (configType)
{
case ConfigTypes.PerMod:
{
if (!File.Exists(perModConfigPath))
{
return;
if (!File.Exists(perModConfigPath))
{
return;
}
var jsonText = File.ReadAllText(perModConfigPath);
currentConfig = JsonSerializer.Deserialize<T>(jsonText);
break;
}
var jsonText = File.ReadAllText(perModConfigPath);
currentConfig = JsonSerializer.Deserialize<T>(jsonText);
break;
}
case ConfigTypes.Exposed:
{
if (!File.Exists(ExposedConfigPath))
{
return;
if (!File.Exists(ExposedConfigPath))
{
return;
}
var jsonText = File.ReadAllText(ExposedConfigPath);
currentConfig = JsonNode.Parse(jsonText)![modName]?.Deserialize<T>();
break;
}
var jsonText = File.ReadAllText(ExposedConfigPath);
currentConfig = JsonNode.Parse(jsonText)![modName]?.Deserialize<T>();
break;
}
default:
throw new ArgumentOutOfRangeException();
}
Expand All @@ -60,7 +60,7 @@ public void SetDefaultConfig(T defaultValue)
Write(defaultConfig);
SaveChanges();
}

/// <summary>
/// Writes the **entire** config. Usage not recommended, use Edit() instead
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions src/Api/GLDConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace PolyMod.Api;
public class GldConfigTemplate
{
private static readonly string ConfigPath = Path.Combine(Plugin.BASE_PATH, "mods.json");

private readonly string templateText;
private JsonObject currentConfig = new();
private string modName;
Expand All @@ -24,8 +24,8 @@ private void Load()
if (File.Exists(ConfigPath))
{
var json = File.ReadAllText(ConfigPath);
if (JsonNode.Parse(json) is JsonObject modsConfig
&& modsConfig.TryGetPropertyValue(modName, out var modConfigNode)
if (JsonNode.Parse(json) is JsonObject modsConfig
&& modsConfig.TryGetPropertyValue(modName, out var modConfigNode)
&& modConfigNode is JsonObject modConfig)
{
currentConfig = modConfig;
Expand All @@ -41,9 +41,9 @@ private void Load()
var template = Template.Parse(templateText);
var context = new TemplateContext();
var scriptObject = new ScriptObject();

bool changedConfig = false;
scriptObject.Import("config",
scriptObject.Import("config",
new Func<string, string, string>((key, defaultValue) =>
{
if (currentConfig.TryGetPropertyValue(key, out var token) && token != null)
Expand All @@ -53,7 +53,7 @@ private void Load()

changedConfig = true;
currentConfig[key] = defaultValue;

return defaultValue;
})
);
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PolyScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class PolyScriptBase
/// <param name="mod">The mod instance.</param>
/// <param name="logger">The logger instance.</param>
internal abstract void Initialize(Mod mod, ManualLogSource logger);

/// <summary>>
/// Called when the mod is loaded.
/// </summary>
Expand Down Expand Up @@ -41,7 +41,7 @@ internal override void Initialize(Mod mod, ManualLogSource logger)
return Registry.mods[Mod.id].files.FirstOrDefault(f => f.name == fileName)?.bytes;
}

public override void Unload() {}
public override void Unload() { }

public Mod Mod { get; private set; } = null!;
protected Config<TConfig> Config { get; private set; } = null!;
Expand Down
4 changes: 2 additions & 2 deletions src/Json/JsonMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ private static JArray MergeArrays(JArray original, JArray patch, bool isSkins)
result.Remove(rem);
hasCustomValues = true;
}
else if(isSkins)
else if (isSkins)
{
result.Add(str);
hasCustomValues = true;
}
}
if(!hasCustomValues)
if (!hasCustomValues)
{
result = new JArray(patch);
}
Expand Down
Loading
Loading