Skip to content

Commit

Permalink
Bugfix: Fix bugs commit message locale missing and optimize localizat…
Browse files Browse the repository at this point in the history
…ion loading
  • Loading branch information
inmny committed Jan 27, 2024
1 parent 5fe3744 commit fb6c7d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
26 changes: 14 additions & 12 deletions WorldBoxMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using NeoModLoader.constants;
using NeoModLoader.General;
using NeoModLoader.General.Event;
using NeoModLoader.General.UI.Prefabs;
using NeoModLoader.General.UI.Tab;
using NeoModLoader.ncms_compatible_layer;
using NeoModLoader.services;
Expand All @@ -13,6 +12,7 @@
using UnityEngine;

namespace NeoModLoader;

/// <summary>
/// Main class
/// </summary>
Expand All @@ -22,12 +22,13 @@ public class WorldBoxMod : MonoBehaviour
/// All successfully loaded mods.
/// </summary>
public static List<IMod> LoadedMods = new();

internal static Dictionary<ModDeclare, ModState> AllRecognizedMods = new();
internal static Transform Transform;
internal static Transform InactiveTransform;
internal static Assembly NeoModLoaderAssembly = Assembly.GetExecutingAssembly();
private bool initialized = false;
private bool initialized_successfully = false;
internal static Transform Transform;
internal static Transform InactiveTransform;
internal static Assembly NeoModLoaderAssembly = Assembly.GetExecutingAssembly();
private bool initialized = false;
private bool initialized_successfully = false;

private void Start()
{
Expand Down Expand Up @@ -58,7 +59,7 @@ private void Update()

initialized = true;
ModUploadAuthenticationService.AutoAuth();
Harmony.CreateAndPatchAll(typeof(LM), Others.harmony_id);
Harmony.CreateAndPatchAll(typeof(LM), Others.harmony_id);
Harmony.CreateAndPatchAll(typeof(ResourcesPatch), Others.harmony_id);

SmoothLoader.add(() =>
Expand Down Expand Up @@ -111,11 +112,11 @@ private void Update()
if (mods_to_load.Contains(mod.mod_decl))
{
ResourcesPatch.LoadResourceFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.ModResourceFolderName));
Paths.ModResourceFolderName));
ResourcesPatch.LoadResourceFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.NCMSAdditionModResourceFolderName));
Paths.NCMSAdditionModResourceFolderName));
ResourcesPatch.LoadAssetBundlesFromFolder(Path.Combine(mod.mod_decl.FolderPath,
Paths.ModAssetBundleFolderName));
Paths.ModAssetBundleFolderName));
}
}, "Load Resources From Mod " + mod.mod_decl.Name);
}
Expand All @@ -135,6 +136,7 @@ private void Update()

ModInfoUtils.DealWithBepInExModLinkRequests();

LM.ApplyLocale();
initialized_successfully = true;

try
Expand Down Expand Up @@ -166,7 +168,7 @@ private void LoadLocales()
if (!resource_path.StartsWith(locale_path)) continue;

LM.LoadLocale(resource_path.Replace(locale_path, "").Replace(".json", ""),
NeoModLoaderAssembly.GetManifestResourceStream(resource_path));
NeoModLoaderAssembly.GetManifestResourceStream(resource_path));
}
}

Expand Down Expand Up @@ -292,7 +294,7 @@ void extractAssemblies()
continue;
}

LogService.LogError($"" +
LogService.LogError($"" +
$"BadImageFormatException: " +
$"The file {file_full_path} is not a valid assembly.");
}
Expand Down
2 changes: 1 addition & 1 deletion services/ModCompileLoadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ void auto_localize(object mod_component)
}
}

LM.ApplyLocale();
LM.ApplyLocale(false);
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions ui/ModListWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NeoModLoader.utils;
using UnityEngine;
using UnityEngine.UI;

namespace NeoModLoader.ui;

/// <summary>
Expand All @@ -13,10 +14,10 @@ namespace NeoModLoader.ui;
public class ModListWindow : AbstractListWindow<ModListWindow, IMod>
{
private ModDeclare clickedMod;
private int clickTimes;
private float lastClickTime;
private bool needRefresh = false;
private List<IMod> to_add = new();
private int clickTimes;
private float lastClickTime;
private bool needRefresh = false;
private List<IMod> to_add = new();

private void Update()
{
Expand Down Expand Up @@ -68,7 +69,9 @@ protected override void Init()
modloaderButtonImage.sprite = InternalResourcesGetter.GetIcon();
TipButton modloaderButtonTipButton = modloaderButton.GetComponent<TipButton>();
modloaderButtonTipButton.textOnClick = "NeoModLoader-v" + WorldBoxMod.NeoModLoaderAssembly.GetName().Version;
modloaderButtonTipButton.text_description_2 = "commit\n" + InternalResourcesGetter.GetCommit();
foreach (var lang in LocalizedTextManager.getAllLanguages())
LM.Add(lang, "NMLCommit", $"commit\n{InternalResourcesGetter.GetCommit()}");
modloaderButtonTipButton.text_description_2 = "NMLCommit";
modloaderButtonTipButton.textOnClickDescription = "NeoModLoader Report";
Button modloaderButtonButton = modloaderButton.GetComponent<Button>();
modloaderButtonButton.onClick.AddListener(() => { Application.OpenURL(CoreConstants.RepoURL); });
Expand Down

0 comments on commit fb6c7d6

Please sign in to comment.