Skip to content

Commit

Permalink
Merge pull request #440 from Aragas/dev
Browse files Browse the repository at this point in the history
v5.10.1
  • Loading branch information
Aragas authored Jun 2, 2024
2 parents eb9cea6 + 2941dee commit ef0a019
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<GameVersion>1.0.0</GameVersion>
<GameVersionWithPrefix>v$(GameVersion)</GameVersionWithPrefix>
<Version>5.10.0</Version>
<Version>5.10.1</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<ButterLibVersion>2.8.15</ButterLibVersion>
<UIExtenderExVersion>2.8.1</UIExtenderExVersion>
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: 5.10.1
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x
* Reverted Settings instance cache and cache invalidation
---------------------------------------------------------------------------------------------------
Version: 5.10.0
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x
* Added Settings instance cache and cache invalidation
Expand Down
14 changes: 14 additions & 0 deletions src/MCM.Abstractions/Base/Global/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ namespace MCM.Abstractions.Base.Global
# endif
abstract class GlobalSettings<T> : GlobalSettings where T : GlobalSettings, new()
{
/// <summary>
/// A modder flriendly way to get settings from any place
/// </summary>
public static T? Instance
{
get
{
if (!Cache.ContainsKey(typeof(T)))
Cache.TryAdd(typeof(T), new T().Id);
return BaseSettingsProvider.Instance?.GetSettings(Cache[typeof(T)]) as T;
}
}
/*
/// <summary>
/// A modder flriendly way to get settings from any place
/// We now cache it. Cache is invalidated on game start/end.
Expand All @@ -29,6 +42,7 @@ namespace MCM.Abstractions.Base.Global
{
return new T().Id;
})!);
*/
}

#if !BANNERLORDMCM_INCLUDE_IN_CODE_COVERAGE
Expand Down
15 changes: 15 additions & 0 deletions src/MCM.Abstractions/Base/PerCampaign/PerCampaignSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ namespace MCM.Abstractions.Base.PerCampaign
# endif
abstract class PerCampaignSettings<T> : PerCampaignSettings where T : PerCampaignSettings, new()
{
/// <summary>
/// A modder flriendly way to get settings from any place
/// </summary>
public static T? Instance
{
get
{
if (!Cache.ContainsKey(typeof(T)))
Cache.TryAdd(typeof(T), new T().Id);
return BaseSettingsProvider.Instance?.GetSettings(Cache[typeof(T)]) as T;
}
}

/*
/// <summary>
/// A modder flriendly way to get settings from any place
/// We now cache it. Cache is invalidated on game start/end.
Expand All @@ -29,6 +43,7 @@ namespace MCM.Abstractions.Base.PerCampaign
{
return new T().Id;
})!);
*/
}

#if !BANNERLORDMCM_INCLUDE_IN_CODE_COVERAGE
Expand Down
15 changes: 15 additions & 0 deletions src/MCM.Abstractions/Base/PerSave/PerSaveSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ namespace MCM.Abstractions.Base.PerSave
# endif
abstract class PerSaveSettings<T> : PerSaveSettings where T : PerSaveSettings, new()
{
/// <summary>
/// A modder flriendly way to get settings from any place
/// </summary>
public static T? Instance
{
get
{
if (!Cache.ContainsKey(typeof(T)))
Cache.TryAdd(typeof(T), new T().Id);
return BaseSettingsProvider.Instance?.GetSettings(Cache[typeof(T)]) as T;
}
}

/*
/// <summary>
/// A modder flriendly way to get settings from any place
/// We now cache it. Cache is invalidated on game start/end.
Expand All @@ -29,6 +43,7 @@ namespace MCM.Abstractions.Base.PerSave
{
return new T().Id;
})!);
*/
}

#if !BANNERLORDMCM_INCLUDE_IN_CODE_COVERAGE
Expand Down

0 comments on commit ef0a019

Please sign in to comment.