Skip to content

Commit

Permalink
Merge pull request #490 from ow-mods/dev
Browse files Browse the repository at this point in the history
2.7.2
  • Loading branch information
misternebula authored Sep 27, 2022
2 parents 789e548 + 30783b2 commit 6c07dd2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/OWML.Launcher/OWML.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="xcopy /i /y &quot;$(SolutionDir)src\OWML.ModHelper.Events\bin\Debug\net48\0Harmony.dll&quot; $(TargetDir)&#xD;&#xA;xcopy /i /y &quot;$(SolutionDir)src\OWML.ModHelper.Assets\bin\Debug\net48\NAudio-Unity.dll&quot; $(TargetDir)&#xD;&#xA;xcopy /i /y &quot;$(SolutionDir)src\OWML.Temp\bin\Debug\net48\Newtonsoft.Json.dll&quot; $(TargetDir)" />
<Exec Command="xcopy /i /y &quot;$(SolutionDir)src\OWML.ModHelper.Events\bin\Debug\net48\0Harmony.dll&quot; &quot;$(TargetDir)&quot;&#xD;&#xA;xcopy /i /y &quot;$(SolutionDir)src\OWML.ModHelper.Assets\bin\Debug\net48\NAudio-Unity.dll&quot; &quot;$(TargetDir)&quot;&#xD;&#xA;xcopy /i /y &quot;$(SolutionDir)src\OWML.Temp\bin\Debug\net48\Newtonsoft.Json.dll&quot; &quot;$(TargetDir)&quot;" />
</Target>

</Project>
2 changes: 1 addition & 1 deletion src/OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Alek",
"name": "OWML",
"uniqueName": "Alek.OWML",
"version": "2.7.1",
"version": "2.7.2",
"minGameVersion": "1.1.10.47",
"maxGameVersion": "1.1.13.393"
}
36 changes: 28 additions & 8 deletions src/OWML.ModLoader/Owo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using Newtonsoft.Json;
using HarmonyLib;
using OWML.Common;
using OWML.Common.Enums;
using OWML.Common.Interfaces;
Expand All @@ -15,9 +9,16 @@
using OWML.ModHelper.Events;
using OWML.ModHelper.Interaction;
using OWML.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine.UI;

namespace OWML.ModLoader
{
[HarmonyPatch]
public class Owo
{
private readonly IModFinder _modFinder;
Expand Down Expand Up @@ -85,7 +86,7 @@ public void LoadMods()

EnumUtils.Initialize(_console, _harmonyHelper);

_harmonyHelper.AddPrefix<TabbedMenu>(nameof(TabbedMenu.OnUpdateInputDevice), typeof(Owo), nameof(TabbedMenu_OnUpdateInputDevice));
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());

var mods = _modFinder.GetMods();

Expand Down Expand Up @@ -268,6 +269,8 @@ private IModBehaviour InitializeMod(Type modType, IModHelper helper)
}
}

[HarmonyPrefix]
[HarmonyPatch(typeof(TabbedMenu), nameof(TabbedMenu.OnUpdateInputDevice))]
private static bool TabbedMenu_OnUpdateInputDevice(TabbedMenu __instance)
{
if ((object)__instance == null) return false;
Expand All @@ -276,5 +279,22 @@ private static bool TabbedMenu_OnUpdateInputDevice(TabbedMenu __instance)
if (Utils.TypeExtensions.GetValue<UnityEngine.UI.Image>(__instance, "_tabLeftButtonImg") == null || Utils.TypeExtensions.GetValue<UnityEngine.UI.Image>(__instance, "_tabRightButtonImg") == null) return false;
return true;
}

[HarmonyReversePatch]
[HarmonyPatch(typeof(Menu), nameof(Menu.Deactivate))]
private static void Menu_Deactivate(Menu __instance, bool remainVisible = false) { }

[HarmonyPrefix]
[HarmonyPatch(typeof(TabbedMenu), nameof(TabbedMenu.Deactivate))]
private static bool TabbedMenu_Deactivate(TabbedMenu __instance, bool keepPreviousMenuVisible = false)
{
if (Locator.GetEventSystem().currentSelectedGameObject)
Utils.TypeExtensions.SetValue(__instance, "_lastSelectableOnDeactivate", Locator.GetEventSystem().currentSelectedGameObject.GetComponent<Selectable>());
foreach (var tabSelectablePair in Utils.TypeExtensions.GetValue<TabbedMenu.TabSelectablePair[]>(__instance, "_tabSelectablePairs"))
tabSelectablePair.tabButton.Enable(false);
Menu_Deactivate(__instance, keepPreviousMenuVisible);
Locator.GetMenuInputModule().OnInputModuleTab -= __instance.OnInputModuleTabEvent;
return false;
}
}
}

0 comments on commit 6c07dd2

Please sign in to comment.