Skip to content

Commit

Permalink
hmmm
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowCat98 committed May 11, 2024
1 parent 9d590a8 commit 8e2ce20
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 47 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
7 changes: 6 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
Binary file added resources/geode-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/main.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once

void showAlert(const char *title, const char *message);
void pickImage();
void showAlert(const char *title, const char *message);
6 changes: 3 additions & 3 deletions src/main.cpp → src/main.mm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify/MenuLayer.hpp>
#import <Geode/Geode.hpp>
#import <Geode/Modify/MenuLayer.hpp>
#include "main.hpp"

using namespace geode::prelude;

class $modify(MenuLayer) {
void onMoreGames(CCObject*) {
pickImage();
log::info("Hello");
}
};
59 changes: 19 additions & 40 deletions src/mainobj.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import <UIKit/UIKit.h>
#import <MobileCoreServices/MobileCoreServices.h>
#include "main.hpp"

void showAlert(const char *title, const char *message) {
Expand All @@ -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 <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@end

@implementation ImagePickerDelegate

// Delegate method called when an image is picked
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id> *)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.");
}
}

0 comments on commit 8e2ce20

Please sign in to comment.