diff --git a/CMakeLists.txt b/CMakeLists.txt index cd3f3cf..ccf099f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ if(${GEODE_TARGET_PLATFORM} STREQUAL "iOS") endif() add_library(${PROJECT_NAME} SHARED - src/main.cpp + src/main.mm src/mainobj.mm src/main.hpp ) diff --git a/mod.json b/mod.json index 000c6a4..6495150 100644 --- a/mod.json +++ b/mod.json @@ -5,5 +5,10 @@ "id": "yellowcat98.ifpshack", "name": "iFPSHack", "developer": "YellowCat98", - "description": "This mod lets you change your fps on iOS!" + "description": "This mod lets you change your fps on iOS!", + "resources": { + "sprites": [ + "geode-logo.png" + ] + } } \ No newline at end of file diff --git a/resources/geode-logo.png b/resources/geode-logo.png new file mode 100644 index 0000000..0b86185 Binary files /dev/null and b/resources/geode-logo.png differ diff --git a/src/main.hpp b/src/main.hpp index 0c589b4..283c218 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -1,4 +1,3 @@ #pragma once -void showAlert(const char *title, const char *message); -void pickImage(); \ No newline at end of file +void showAlert(const char *title, const char *message); \ No newline at end of file diff --git a/src/main.cpp b/src/main.mm similarity index 58% rename from src/main.cpp rename to src/main.mm index 7501a01..00043c1 100644 --- a/src/main.cpp +++ b/src/main.mm @@ -1,11 +1,11 @@ -#include -#include +#import +#import #include "main.hpp" using namespace geode::prelude; class $modify(MenuLayer) { void onMoreGames(CCObject*) { - pickImage(); + log::info("Hello"); } }; \ No newline at end of file diff --git a/src/mainobj.mm b/src/mainobj.mm index 8fd8072..2f3c244 100644 --- a/src/mainobj.mm +++ b/src/mainobj.mm @@ -1,5 +1,4 @@ #import -#import #include "main.hpp" void showAlert(const char *title, const char *message) { @@ -23,44 +22,24 @@ void showAlert(const char *title, const char *message) { [rootViewController presentViewController:alertController animated:YES completion:nil]; } - - -// Custom delegate class for image picker -@interface ImagePickerDelegate : NSObject -@end - -@implementation ImagePickerDelegate - -// Delegate method called when an image is picked -- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - NSString *mediaType = info[UIImagePickerControllerMediaType]; - if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { - UIImage *selectedImage = info[UIImagePickerControllerOriginalImage]; - NSURL *imageURL = info[UIImagePickerControllerImageURL]; - NSString *imageName = [imageURL lastPathComponent]; - - showAlert("Selected Image", [imageName UTF8String]); +void setAppIcon(NSString *iconPath) { + if (@available(iOS 10.3, *)) { + if ([[UIApplication sharedApplication] supportsAlternativeIcons]) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + UIImage *iconImage = [UIImage imageWithContentsOfFile:iconPath]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication] setAlternateIconImage:iconImage completionHandler:^(NSError * _Nullable error) { + if (error) { + showAlert("Error", "There has been an error setting the app icon."); + } + }]; + }); + }); + } else { + showAlert("Unsupported.", "Setting app icons is not supported"); } - - [picker dismissViewControllerAnimated:YES completion:nil]; -} - -// Delegate method called when the image picker is canceled -- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { - [picker dismissViewControllerAnimated:YES completion:nil]; -} - -@end - -void pickImage() { - UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; - imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - - // Create an instance of our custom delegate class - ImagePickerDelegate *imagePickerDelegate = [[ImagePickerDelegate alloc] init]; - imagePicker.delegate = imagePickerDelegate; - - // Get the root view controller to present the image picker - UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - [rootViewController presentViewController:imagePicker animated:YES completion:nil]; + } else { + showAlert("Unsupported Version", "Your iOS version does not support alternative app icons."); + } } \ No newline at end of file