Skip to content

Commit

Permalink
Bugfix: Better support of ncms mods
Browse files Browse the repository at this point in the history
  • Loading branch information
inmny committed Dec 12, 2023
1 parent 3fe91f7 commit 08856fd
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 8 deletions.
63 changes: 63 additions & 0 deletions ncms_compatible_layer/NCMS/Extensions/DictionaryRange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace NCMS.Extensions;

public static class DictionaryRange
{
// Token: 0x060000A1 RID: 161 RVA: 0x00008098 File Offset: 0x00006298
public static void AddRangeOverride<TKey, TValue>(this IDictionary<TKey, TValue> dic,
IDictionary<TKey, TValue> dicToAdd)
{
dicToAdd.ForEach(delegate(KeyValuePair<TKey, TValue> x) { dic[x.Key] = x.Value; });
}

// Token: 0x060000A2 RID: 162 RVA: 0x000080C8 File Offset: 0x000062C8
public static void AddRangeNewOnly<TKey, TValue>(this IDictionary<TKey, TValue> dic,
IDictionary<TKey, TValue> dicToAdd)
{
dicToAdd.ForEach(delegate(KeyValuePair<TKey, TValue> x)
{
if (!dic.ContainsKey(x.Key))
{
dic.Add(x.Key, x.Value);
}
});
}

// Token: 0x060000A3 RID: 163 RVA: 0x000080F8 File Offset: 0x000062F8
public static void AddRange<TKey, TValue>(this IDictionary<TKey, TValue> dic, IDictionary<TKey, TValue> dicToAdd)
{
dicToAdd.ForEach(delegate(KeyValuePair<TKey, TValue> x) { dic.Add(x.Key, x.Value); });
}

// Token: 0x060000A4 RID: 164 RVA: 0x00008128 File Offset: 0x00006328
public static bool ContainsKeys<TKey, TValue>(this IDictionary<TKey, TValue> dic, IEnumerable<TKey> keys)
{
bool result = false;
keys.ForEachOrBreak(delegate(TKey x)
{
result = dic.ContainsKey(x);
return result;
});
return result;
}

// Token: 0x060000A5 RID: 165 RVA: 0x00008168 File Offset: 0x00006368
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
foreach (T t in source)
{
action(t);
}
}

// Token: 0x060000A6 RID: 166 RVA: 0x000081B8 File Offset: 0x000063B8
public static void ForEachOrBreak<T>(this IEnumerable<T> source, Func<T, bool> func)
{
foreach (T t in source)
{
if (func(t))
{
break;
}
}
}
}
11 changes: 3 additions & 8 deletions ncms_compatible_layer/NCMS/Utils/Localization.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NeoModLoader.General;
using NeoModLoader.General;

namespace NCMS.Utils
{
Expand Down Expand Up @@ -39,7 +34,7 @@ public static void AddOrSet(string key, string value)

public static string Get(string key)
{
return LM.Get(key);
return LocalizedTextManager.instance.localizedText[key];
}

[Obsolete("Localization.getLocalization is deprecated, please use Localization.Get instead")]
Expand All @@ -48,4 +43,4 @@ public static string getLocalization(string key)
return Get(key);
}
}
}
}

0 comments on commit 08856fd

Please sign in to comment.