Skip to content

Commit

Permalink
Slight refactor
Browse files Browse the repository at this point in the history
Reload language upon Subnautica SetLanguage
  • Loading branch information
DingoDjango committed Mar 16, 2019
1 parent 8fc4ea0 commit 900ad13
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
Binary file modified QMods/StorageInfo/StorageInfo.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion QMods/StorageInfo/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Id": "StorageInfo",
"DisplayName": "Storage Info",
"Author": "Dingo",
"Version": "1.0.2",
"Version": "1.0.3",
"Enable": true,
"Game": "Subnautica",
"AssemblyName": "StorageInfo.dll",
Expand Down
6 changes: 3 additions & 3 deletions Source/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static IEnumerable<CodeInstruction> Patch_StorageContainer_OnHandHover_T
{
CodeInstruction instruction = codes[i];

// HandleReticle::main is the first IL we need
// IL_0033 is the first IL we aim to replace
if (!foundFirstHandReticle)
{
if (instruction.opcode == OpCodes.Ldsfld && instruction.operand == handleReticleMain
Expand All @@ -63,7 +63,7 @@ private static IEnumerable<CodeInstruction> Patch_StorageContainer_OnHandHover_T
}
}

// SetInteractText is the final IL we aim to replace
// IL_0058 is the final IL we aim to replace
else if (instruction.opcode == OpCodes.Ldsfld && instruction.operand == handleReticleMain
&& codes[i - 1].opcode == OpCodes.Callvirt && codes[i - 1].operand == setInteractText)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ private static IEnumerable<CodeInstruction> Patch_StorageContainer_OnHandHover_T

private static void Patch_SetCurrentLanguage_Postfix()
{
Translation.ClearCache();
Translation.ReloadLanguage();
}

internal static void InitializeHarmony()
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
8 changes: 5 additions & 3 deletions Source/Translation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static bool TryTranslate(string candidate, out string translated)

else
{
LoadLanguageData();
ReloadLanguage();

if (languageStrings.TryGetValue(candidate, out translated))
{
Expand Down Expand Up @@ -122,9 +122,11 @@ internal static string FormatSingle(this string source, string arg0)
return basic;
}

internal static void ClearCache()
internal static void ReloadLanguage()
{
languageStrings.Clear();

LoadLanguageData();
}
}
}
}
2 changes: 1 addition & 1 deletion Source/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Id": "StorageInfo",
"DisplayName": "Storage Info",
"Author": "Dingo",
"Version": "1.0.2",
"Version": "1.0.3",
"Enable": true,
"Game": "Subnautica",
"AssemblyName": "StorageInfo.dll",
Expand Down

0 comments on commit 900ad13

Please sign in to comment.