diff --git a/PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m b/PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m index 3526f0c7..1f4280a1 100644 --- a/PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m +++ b/PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m @@ -56,12 +56,24 @@ + (void) load [objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_bounds)]; [objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_size)]; } + + [objc_getClass("_UIMenuBuilder") swizzleInstanceMethod:sel_getUid("initWithRootMenu:") withMethod:@selector(initWithRootMenuHook:)]; [objc_getClass("IOSViewController") swizzleInstanceMethod:@selector(prefersPointerLocked) withMethod:@selector(hook_prefersPointerLocked)]; - [self swizzleInstanceMethod:@selector(init) withMethod:@selector(hook_init)]; }); } +bool menuWasCreated = false; +- (id) initWithRootMenuHook:(id)rootMenu { + self = [self initWithRootMenuHook:rootMenu]; + if (!menuWasCreated) { + [PlayCover initMenuWithMenu: self]; + menuWasCreated = TRUE; + } + + return self; +} + - (BOOL) hook_prefersPointerLocked { return false; } @@ -78,12 +90,4 @@ - (CGSize) hook_size { return [PlayScreen sizeAspectRatio:[self hook_size]]; } -- (id) hook_init { - if ([[self class] isEqual: NSClassFromString(@"_UIMenuBuilder")]) { - [PlayCover initMenuWithMenu: self]; - } - - return self; -} - @end