Skip to content

Commit

Permalink
v4.3.7 (#98)
Browse files Browse the repository at this point in the history
* PerSave Settings were not initialized on new game

* Use Trace for default logging

* Workflow fix, NuGet is being weird on WIndows workers

* Build fix
  • Loading branch information
Aragas authored Apr 11, 2021
1 parent 8633b3e commit 1903aab
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jobs:
with:
nuget-version: 'latest'

- name: Ensure NuGet Source
uses: fabriciomurta/ensure-nuget-source@v1
with:
name: 'nuget.org'
url: 'https://api.nuget.org/v3/index.json'

- name: Generating Newtonsoft.Json xref maps
run: >-
dotnet run -p build/SandcastleXrefGenerator -- `
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ jobs:
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Ensure NuGet Source
uses: fabriciomurta/ensure-nuget-source@v1
with:
name: 'nuget.org'
url: 'https://api.nuget.org/v3/index.json'

- name: Download DepotDownloader_2.3.6
uses: i3h/download-release-asset@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<Project>

<PropertyGroup>
<Version>4.3.6</Version>
<Version>4.3.7</Version>
<GameVersion>1.4.3</GameVersion>
<HarmonyVersion>2.0.2</HarmonyVersion>
<ButterLibVersion>1.0.21</ButterLibVersion>
<UIExtenderExVersion>2.1.1</UIExtenderExVersion>
<BuildResourcesVersion>1.0.0.33</BuildResourcesVersion>
<BUTRSharedVersion>1.6.1.30</BUTRSharedVersion>
<HarmonyExtensionsVersion>2.0.0.8</HarmonyExtensionsVersion>
<BUTRSharedVersion>1.6.1.31</BUTRSharedVersion>
<HarmonyExtensionsVersion>2.0.0.10</HarmonyExtensionsVersion>
<TargetFramework>net472</TargetFramework>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 4.3.7
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9
* PerSave Settings were not initialized on new game
---------------------------------------------------------------------------------------------------
Version: 4.3.6
Game Versions: e1.4.3,e1.5.0,e1.5.1,e1.5.2,e1.5.3,e1.5.4,e1.5.5,e1.5.6,e1.5.7,e1.5.8,e1.5.9
* Fixed PerSave Settings loading issue
Expand Down
4 changes: 2 additions & 2 deletions src/MCM/DependencyInjection/LightInjectServiceContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public IGenericServiceProvider Build()
{
if (_serviceContainer.AvailableServices.All(s => s.ServiceType != typeof(IMCMLogger)))
{
_serviceContainer.RegisterTransient<IMCMLogger, NullMCMLogger>();
_serviceContainer.RegisterTransient<IMCMLogger, DefaultMCMLogger>();
}
if (_serviceContainer.AvailableServices.All(s => s.ServiceType != typeof(IMCMLogger<>)))
{
_serviceContainer.RegisterTransient(typeof(IMCMLogger<>), typeof(NullMCMLogger<>));
_serviceContainer.RegisterTransient(typeof(IMCMLogger<>), typeof(DefaultMCMLogger<>));
}

_serviceContainer.Compile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ public override void SyncData(IDataStore dataStore)
}
}

public override void RegisterEvents() { }
public override void RegisterEvents()
{
CampaignEvents.OnNewGameCreatedEvent.AddNonSerializedListener(this, OnNewGameCreatedEvent);
}

private void OnNewGameCreatedEvent(CampaignGameStarter campaignGameStarter)
{
_settings = new Dictionary<string, string>();
var perSaveSettingsContainer = GenericServiceProvider.GetService<MCMPerSaveSettingsContainer>();
perSaveSettingsContainer?.LoadSettings();
}

public bool SaveSettings(PerSaveSettings perSaveSettings)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
using System;
using System.Diagnostics;

namespace MCM.Logger
{
internal class NullMCMLogger<T> : IMCMLogger<T>
internal class DefaultMCMLogger<T> : IMCMLogger<T>
{
public void LogTrace(string message, params object[] args) { }
public void LogInformation(string message, params object[] args) { }
public void LogWarning(string message, params object[] args) { }
public void LogError(Exception exception, string message, params object[] args) { }
public void LogTrace(string message, params object[] args) => Trace.WriteLine(string.Format(message, args));
public void LogInformation(string message, params object[] args) => Trace.TraceInformation(message, args);
public void LogWarning(string message, params object[] args) => Trace.TraceWarning(message, args);
public void LogError(Exception exception, string message, params object[] args) => Trace.TraceError(message, args);
}

internal class NullMCMLogger : IMCMLogger
internal class DefaultMCMLogger : IMCMLogger
{
public void LogTrace(string message, params object[] args) { }
public void LogInformation(string message, params object[] args) { }
public void LogWarning(string message, params object[] args) { }
public void LogError(Exception exception, string message, params object[] args) { }
public void LogTrace(string message, params object[] args) => Trace.WriteLine(string.Format(message, args));
public void LogInformation(string message, params object[] args) => Trace.TraceInformation(message, args);
public void LogWarning(string message, params object[] args) => Trace.TraceWarning(message, args);
public void LogError(Exception exception, string message, params object[] args) => Trace.TraceError(message, args);
}
}
2 changes: 1 addition & 1 deletion tests/MCM.Tests/SettingsFormat/JsonSettingsFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class JsonSettingsFormatTests : BaseSettingsFormatTests
[OneTimeSetUp]
public void OneTimeSetUp1()
{
Format = new JsonSettingsFormat(new NullMCMLogger<JsonSettingsFormat>());
Format = new JsonSettingsFormat(new DefaultMCMLogger<JsonSettingsFormat>());

Settings = BaseSettingsBuilder.Create("Testing_Global_v1", "Testing Fluent Settings")!
.SetFormat("json")
Expand Down
2 changes: 1 addition & 1 deletion tests/MCM.Tests/SettingsFormat/XmlSettingsFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class XmlSettingsFormatTests : BaseSettingsFormatTests
[OneTimeSetUp]
public void OneTimeSetUp1()
{
Format = new XmlSettingsFormat(new NullMCMLogger<XmlSettingsFormat>());
Format = new XmlSettingsFormat(new DefaultMCMLogger<XmlSettingsFormat>());

Settings = BaseSettingsBuilder.Create("Testing_Global_v1", "Testing Fluent Settings")!
.SetFormat("xml")
Expand Down

0 comments on commit 1903aab

Please sign in to comment.