Skip to content

Commit 9d58e34

Browse files
authored
Merge pull request #59 from Depal1/fixRegression
Change behaviour of the _UIMenuBuilder swizzle
2 parents e0bbef0 + 13cd62b commit 9d58e34

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,9 @@ + (void) load
5454
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_bounds)];
5555
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_size)];
5656
}
57-
58-
[objc_getClass("_UIMenuBuilder") swizzleInstanceMethod:sel_getUid("initWithRootMenu:") withMethod:@selector(initWithRootMenuHook:)];
5957

6058
[objc_getClass("IOSViewController") swizzleInstanceMethod:@selector(prefersPointerLocked) withMethod:@selector(hook_prefersPointerLocked)];
61-
}
62-
63-
bool menuWasCreated = false;
64-
- (id) initWithRootMenuHook:(id)rootMenu {
65-
self = [self initWithRootMenuHook:rootMenu];
66-
if (!menuWasCreated) {
67-
[PlayCover initMenuWithMenu: self];
68-
menuWasCreated = TRUE;
69-
}
70-
71-
return self;
59+
[self swizzleInstanceMethod:@selector(init) withMethod:@selector(hook_init)];
7260
}
7361

7462
- (BOOL) hook_prefersPointerLocked {
@@ -87,4 +75,16 @@ - (CGSize) hook_size {
8775
return [PlayScreen sizeAspectRatio:[self hook_size]];
8876
}
8977

78+
bool menuWasCreated = false;
79+
80+
-(id) hook_init {
81+
if (!menuWasCreated) {
82+
if ([[self class] isEqual: NSClassFromString(@"_UIMenuBuilder")]) {
83+
[PlayCover initMenuWithMenu: self];
84+
menuWasCreated = TRUE;
85+
}
86+
}
87+
88+
return self;
89+
}
9090
@end

0 commit comments

Comments
 (0)