diff --git a/src/main.cpp b/src/main.cpp index 7cc1958..7501a01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,6 @@ using namespace geode::prelude; class $modify(MenuLayer) { void onMoreGames(CCObject*) { - showAlert("Hi", "hello"); + pickImage(); } }; \ No newline at end of file diff --git a/src/main.hpp b/src/main.hpp index 283c218..0c589b4 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -1,3 +1,4 @@ #pragma once -void showAlert(const char *title, const char *message); \ No newline at end of file +void showAlert(const char *title, const char *message); +void pickImage(); \ No newline at end of file diff --git a/src/mainobj.mm b/src/mainobj.mm index 398c5de..c25c219 100644 --- a/src/mainobj.mm +++ b/src/mainobj.mm @@ -1,4 +1,5 @@ #import +#import #include "main.hpp" void showAlert(const char *title, const char *message) { @@ -21,3 +22,24 @@ void showAlert(const char *title, const char *message) { // Present the alert [rootViewController presentViewController:alertController animated:YES completion:nil]; } + +void pickImage() { + UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + + UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; + + imagePicker.delegate = ^(UIImagePickerController *picker, NSDictionary *info) { + NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; + if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { + UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; + NSURL *imageURL = [info objectForKey:UIImagePickerControllerImageURL]; + NSString *imageName = [[imageURL path] lastPathComponent]; + + showAlert("Selected Image", [imageName UTF8String]); + } + + [picker dismissViewControllerAnimated:YES completion:nil]; + }; + [rootViewController presentViewController:imagePicker animated:YES completion:nil]; +} \ No newline at end of file