Skip to content

Commit

Permalink
Merge pull request #29 from chi-rei-den/squid
Browse files Browse the repository at this point in the history
Fix the display error of mod status
  • Loading branch information
sgkoishi authored Feb 24, 2020
2 parents 6facc8c + 126ea5d commit 890ebec
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 22 deletions.
23 changes: 8 additions & 15 deletions Localizer/Localizer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
Expand Down Expand Up @@ -118,28 +117,22 @@ public override void Load()
var drawSelf = "Terraria.ModLoader.UI.UIModItem".Type().Method("DrawSelf");
Harmony.Patch(drawSelf, postfix: new HarmonyMethod(NoroHelper.MethodInfo(() => DrawSelfPostfix(null, null))));

var saveEnabledMods = "Terraria.ModLoader.Core.ModOrganizer".Type().Method("SaveEnabledMods");
Harmony.Patch(saveEnabledMods, postfix: new HarmonyMethod(NoroHelper.MethodInfo(() => SaveEnabledModsPostfix())));

var refStr = "";
var isEnabledPostfix = "Terraria.ModLoader.ModLoader".Type().Method("IsEnabled");
Harmony.Patch(isEnabledPostfix, postfix: new HarmonyMethod(NoroHelper.MethodInfo(() => IsEnabledPostfix(ref refStr))));
var setEnabledPrefix = "Terraria.ModLoader.ModLoader".Type().Method("SetModEnabled");
Harmony.Patch(setEnabledPrefix, prefix: new HarmonyMethod(NoroHelper.MethodInfo(() => EnabledPrefix(ref refStr))));

var isEnabledPrefix = "Terraria.ModLoader.ModLoader".Type().Method("IsEnabled");
Harmony.Patch(isEnabledPrefix, prefix: new HarmonyMethod(NoroHelper.MethodInfo(() => EnabledPrefix(ref refStr))));
}

private static void IsEnabledPostfix(ref string modName)
private static void EnabledPrefix(ref string modName)
{
if (modName == "!Localizer")
if (modName == "Localizer")
{
modName = "Localizer";
modName = "!Localizer";
}
}

private static void SaveEnabledModsPostfix()
{
var path = Path.Combine(ModLoader.ModPath, "enabled.json");
File.WriteAllText(path, File.ReadAllText(path).Replace("\"Localizer\"", "\"!Localizer\""));
}

private static int frameCounter;
private static void DrawSelfPostfix(object __instance, SpriteBatch spriteBatch)
{
Expand Down
2 changes: 1 addition & 1 deletion Localizer/ModBrowser/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Localizer.ModBrowser
{
public class Patches
public static class Patches
{
public static void Patch()
{
Expand Down
3 changes: 2 additions & 1 deletion Localizer/Package/Export/LdstrFileExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public sealed class LdstrFileExport : IFileExportService
GetMethodBase<ModRecipe>(
"System.Void Terraria.ModLoader.ModRecipe::AddTile(Terraria.ModLoader.Mod,System.String)"),
GetMethodBase<ModTranslation>("System.Void Terraria.ModLoader.ModTranslation::SetDefault(System.String)"),
typeof(ModLoader).FindMethod("Terraria.Mod Terraria.ModLoader.ModLoader::GetMod(System.String)"),
};

private static List<MethodBase> _blackList2 = new List<MethodBase>
Expand Down Expand Up @@ -155,7 +156,7 @@ public void Export(IPackage package, IExportConfig config)

try
{
Utils.LogDebug($"Exporting method: [{method.GetID()}]");
LogDebug($"Exporting method: [{method.GetID()}]");
var entry = GetEntryFromMethod(method);
if (entry != null && !file.LdstrEntries.ContainsKey(method.GetID()))
{
Expand Down
5 changes: 1 addition & 4 deletions Localizer/Package/Import/PackageImportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ public void Dispose()
{
foreach (var importer in _importers.Values)
{
Utils.SafeWrap(() =>
{
importer.Dispose();
});
Utils.SafeWrap(() => importer.Dispose());
}

_importers = null;
Expand Down
2 changes: 1 addition & 1 deletion Localizer/build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = Chireiden Team
version = 1.5.0.3
version = 1.5.0.4
displayName = Localizer
hideCode = true
hideResources = false
Expand Down

0 comments on commit 890ebec

Please sign in to comment.