1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . IO ;
4
- using System . Linq ;
5
- using System . Net ;
6
- using System . Reflection ;
7
- using Newtonsoft . Json ;
1
+ using HarmonyLib ;
8
2
using OWML . Common ;
9
3
using OWML . Common . Enums ;
10
4
using OWML . Common . Interfaces ;
15
9
using OWML . ModHelper . Events ;
16
10
using OWML . ModHelper . Interaction ;
17
11
using OWML . Utils ;
12
+ using System ;
13
+ using System . Collections . Generic ;
14
+ using System . IO ;
15
+ using System . Linq ;
16
+ using System . Reflection ;
17
+ using UnityEngine . UI ;
18
18
19
19
namespace OWML . ModLoader
20
20
{
21
+ [ HarmonyPatch ]
21
22
public class Owo
22
23
{
23
24
private readonly IModFinder _modFinder ;
@@ -85,7 +86,7 @@ public void LoadMods()
85
86
86
87
EnumUtils . Initialize ( _console , _harmonyHelper ) ;
87
88
88
- _harmonyHelper . AddPrefix < TabbedMenu > ( nameof ( TabbedMenu . OnUpdateInputDevice ) , typeof ( Owo ) , nameof ( TabbedMenu_OnUpdateInputDevice ) ) ;
89
+ Harmony . CreateAndPatchAll ( Assembly . GetExecutingAssembly ( ) ) ;
89
90
90
91
var mods = _modFinder . GetMods ( ) ;
91
92
@@ -268,6 +269,8 @@ private IModBehaviour InitializeMod(Type modType, IModHelper helper)
268
269
}
269
270
}
270
271
272
+ [ HarmonyPrefix ]
273
+ [ HarmonyPatch ( typeof ( TabbedMenu ) , nameof ( TabbedMenu . OnUpdateInputDevice ) ) ]
271
274
private static bool TabbedMenu_OnUpdateInputDevice ( TabbedMenu __instance )
272
275
{
273
276
if ( ( object ) __instance == null ) return false ;
@@ -276,5 +279,22 @@ private static bool TabbedMenu_OnUpdateInputDevice(TabbedMenu __instance)
276
279
if ( Utils . TypeExtensions . GetValue < UnityEngine . UI . Image > ( __instance , "_tabLeftButtonImg" ) == null || Utils . TypeExtensions . GetValue < UnityEngine . UI . Image > ( __instance , "_tabRightButtonImg" ) == null ) return false ;
277
280
return true ;
278
281
}
282
+
283
+ [ HarmonyReversePatch ]
284
+ [ HarmonyPatch ( typeof ( Menu ) , nameof ( Menu . Deactivate ) ) ]
285
+ private static void Menu_Deactivate ( Menu __instance , bool remainVisible = false ) { }
286
+
287
+ [ HarmonyPrefix ]
288
+ [ HarmonyPatch ( typeof ( TabbedMenu ) , nameof ( TabbedMenu . Deactivate ) ) ]
289
+ private static bool TabbedMenu_Deactivate ( TabbedMenu __instance , bool keepPreviousMenuVisible = false )
290
+ {
291
+ if ( Locator . GetEventSystem ( ) . currentSelectedGameObject )
292
+ Utils . TypeExtensions . SetValue ( __instance , "_lastSelectableOnDeactivate" , Locator . GetEventSystem ( ) . currentSelectedGameObject . GetComponent < Selectable > ( ) ) ;
293
+ foreach ( var tabSelectablePair in Utils . TypeExtensions . GetValue < TabbedMenu . TabSelectablePair [ ] > ( __instance , "_tabSelectablePairs" ) )
294
+ tabSelectablePair . tabButton . Enable ( false ) ;
295
+ Menu_Deactivate ( __instance , keepPreviousMenuVisible ) ;
296
+ Locator . GetMenuInputModule ( ) . OnInputModuleTab -= __instance . OnInputModuleTabEvent ;
297
+ return false ;
298
+ }
279
299
}
280
300
}
0 commit comments