Skip to content

Commit

Permalink
feat: inspect helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Feb 14, 2022
1 parent b6b4345 commit e1af860
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions GodSeekerPlus/Modules/Misc/InspectHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace GodSeekerPlus.Modules.Misc;

[Hidden]
internal sealed class InspectHelper : Module {
private static readonly string GO_NAME = $"{nameof(GodSeekerPlus)} Inspect Helper";

private protected override void Load() =>
ModHooks.FinishedLoadingModsHook += CreateGameObject;

private static void CreateGameObject() {
if (ModHooks.GetMod("Unity Explorer", true) == null) {
return;
}

if (GameObject.Find(GO_NAME) is not null and {
scene.name: "DontDestroyOnLoad"
}) {
Logger.LogError("Inspect Helper GameObject already existed!");

return;
}

Logger.Log("Creating Inspect Helper GameObject");
var go = new GameObject(GO_NAME, typeof(Inspector));
UObject.DontDestroyOnLoad(go);
}

private sealed class Inspector : MonoBehaviour {
public GodSeekerPlus Instance => GodSeekerPlus.UnsafeInstance;

public Dictionary<string, Module> Modules => ModuleManager.Modules;

public GlobalSettings GlobalSettings => GodSeekerPlus.GlobalSettings;
public LocalSettings LocalSettings => GodSeekerPlus.LocalSettings;

public Dictionary<string, Dictionary<string, string>> Dict => L11nUtil.Dict.Value;

public Dictionary<string, string>? GetL11n(string lang) =>
L11nUtil.Dict.Value.TryGetValue(lang, out Dictionary<string, string>? dict) ? dict : null;

public string Localize(string key) => L11nUtil.Localize(key);
}
}
2 changes: 1 addition & 1 deletion GodSeekerPlus/Util/L11nUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static string ToIdentifier(this LanguageCode code) =>
Lang.CurrentLanguage().ToIdentifier();


private static readonly Lazy<Dictionary<string, Dictionary<string, string>>> Dict = new(() => Assembly
internal static readonly Lazy<Dictionary<string, Dictionary<string, string>>> Dict = new(() => Assembly
.GetExecutingAssembly()
.GetManifestResourceNames()
.Filter(name => name.EnclosedWith(resPrefix, resPostfix))
Expand Down

0 comments on commit e1af860

Please sign in to comment.