From f48408ced02c0df847dcc93f7b7c2397e0df9754 Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Sun, 13 Feb 2022 04:36:49 +0700 Subject: [PATCH] Only load Alderis.framework when needed --- Natives/CMakeLists.txt | 1 - Natives/CustomControlsViewController.m | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Natives/CMakeLists.txt b/Natives/CMakeLists.txt index 39c182bc..50acf0ee 100644 --- a/Natives/CMakeLists.txt +++ b/Natives/CMakeLists.txt @@ -82,7 +82,6 @@ add_executable(PojavLauncher target_link_libraries(PojavLauncher "-F'${CMAKE_CURRENT_LIST_DIR}/build'" "-F'${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks'" - "-framework Alderis" "-framework AuthenticationServices" "-framework CoreGraphics" "-framework GameController" diff --git a/Natives/CustomControlsViewController.m b/Natives/CustomControlsViewController.m index 8a8bdf6f..92e61145 100644 --- a/Natives/CustomControlsViewController.m +++ b/Natives/CustomControlsViewController.m @@ -9,6 +9,8 @@ #import "customcontrols/ControlDrawer.h" #import "customcontrols/CustomControlsUtils.h" +#include + #include "glfw_keycodes.h" #include "utils.h" @@ -665,7 +667,11 @@ CGFloat currentY; self.colorWellINTBackground.selectedColor = self.targetButton.backgroundColor; [self.scrollView addSubview:self.colorWellINTBackground]; } else { - self.colorWellEXTBackground = [[HBColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)]; + if (!dlopen("Alderis.framework/Alderis", RTLD_NOW)) { + NSLog(@"Cannot load Alderis framework: %s", dlerror()); + } + + self.colorWellEXTBackground = [[NSClassFromString(@"HBColorWell") alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)]; self.colorWellEXTBackground.color = self.targetButton.backgroundColor; self.colorWellEXTBackground.isDragInteractionEnabled = YES; self.colorWellEXTBackground.isDropInteractionEnabled = YES; @@ -694,7 +700,7 @@ CGFloat currentY; self.colorWellINTStroke.selectedColor = [[UIColor alloc] initWithCGColor:self.targetButton.layer.borderColor]; self.colorWellINTStroke.supportsAlpha = NO; } else { - self.colorWellEXTStroke = [[HBColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)]; + self.colorWellEXTStroke = [[NSClassFromString(@"HBColorWell") alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)]; self.colorWellEXTStroke.color = [[UIColor alloc] initWithCGColor:self.targetButton.layer.borderColor]; [self.colorWellEXTStroke addTarget:self action:@selector(presentColorPicker:) forControlEvents:UIControlEventTouchUpInside]; [self.scrollView addSubview:self.colorWellEXTStroke]; @@ -766,10 +772,10 @@ CGFloat currentY; #pragma mark - Alderis functions // HBColorWell - (void)presentColorPicker:(HBColorWell *)sender { - HBColorPickerViewController *vc = [[HBColorPickerViewController alloc] init]; + HBColorPickerViewController *vc = [[NSClassFromString(@"HBColorPickerViewController") alloc] init]; vc.delegate = self; vc.popoverPresentationController.sourceView = sender; - vc.configuration = [[HBColorPickerConfiguration alloc] initWithColor:sender.color]; + vc.configuration = [[NSClassFromString(@"HBColorPickerConfiguration") alloc] initWithColor:sender.color]; if (sender == self.colorWellEXTBackground) { vc.configuration.title = @"Background color"; vc.configuration.supportsAlpha = YES;