Skip to content

Commit

Permalink
pleas work
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowCat98 committed May 11, 2024
1 parent 736477b commit 65a1db9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ using namespace geode::prelude;

class $modify(MenuLayer) {
void onMoreGames(CCObject*) {
showAlert("Hi", "hello");
pickImage();
}
};
3 changes: 2 additions & 1 deletion src/main.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pragma once

void showAlert(const char *title, const char *message);
void showAlert(const char *title, const char *message);
void pickImage();
22 changes: 22 additions & 0 deletions src/mainobj.mm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <UIKit/UIKit.h>
#import <Cocoa/Cocoa.h>
#include "main.hpp"

void showAlert(const char *title, const char *message) {
Expand All @@ -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<UIImagePickerControllerInfoKey, id> *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];
}

0 comments on commit 65a1db9

Please sign in to comment.