Skip to content

Commit

Permalink
ok i am NOW gonna make it a library!
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowCat98 committed May 12, 2024
1 parent e83a158 commit 1a16c6c
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 79 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ if(${GEODE_TARGET_PLATFORM} STREQUAL "iOS")
endif()

add_library(${PROJECT_NAME} SHARED
src/main.mm
src/mainobj.mm
src/main.hpp
src/iGeodeLib.mm
src/test.cpp
src/iGeodeLib.hpp
)

if (NOT DEFINED ENV{GEODE_SDK})
Expand Down
11 changes: 3 additions & 8 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
"geode": "2.0.0-beta.25",
"gd": "2.205",
"version": "v1.0.0",
"id": "yellowcat98.ifpshack",
"name": "iFPSHack",
"id": "yellowcat98.igeodelib",
"name": "iGeodeLib",
"developer": "YellowCat98",
"description": "This mod lets you change your fps on iOS!",
"resources": {
"files": [
"resources/geode-logo.png"
]
}
"description": "This mod lets you change your fps on iOS!"
}
Binary file removed resources/geode-logo.png
Binary file not shown.
5 changes: 5 additions & 0 deletions src/iGeodeLib.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

void showAlert(const char *title, const char *message, const char *Btn);
void iOSVersion();
void CShowAlert(const char *title, const char *message, const char *Btn);
92 changes: 92 additions & 0 deletions src/iGeodeLib.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#import <UIKit/UIKit.h>
#include <functional>
#include "main.hpp"

/*
shows a system level alert.
usage:
showAlert("Insert title here", "insert message here...", "insert button here.");
you cannot create a callback with this, use the showAlertWithCallback() function for callbacks.
*/
void showAlert(const char *title, const char *message, const char *Btn) {
NSString *titleString = [NSString stringWithUTF8String:title];
NSString *messageString = [NSString stringWithUTF8String:message];
NSString *btnString = [NSString stringWithUTF8String:Btn];

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:titleString
message:messageString
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *okAction = [UIAlertAction actionWithTitle:btnString
style:UIAlertActionStyleDefault
handler:nil];

[alertController addAction:okAction];

UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

[rootViewController presentViewController:alertController animated:YES completion:nil];
}

/*
ShowAlert but with a function callback.
usage:
CShowAlert("Title", "Message", "go away", MyCoolFunction());
- this function allows you to add 2 buttons!!!
usage: (again)
CShowAlert("Title", "Message", "go away", nullptr, "go away again");
this should give you an alert with 2 buttons and no callback at al!!!!;
*/

void CShowAlert(const char *title, const char *message, const char *Btn, std::function<void()> callback = nullptr, const char *Btn2 = nullptr, std::function<void()> callback2 = nullptr) {
NSString *titleString = [NSString stringWithUTF8String:title];
NSString *messageString = [NSString stringWithUTF8String:message];
NSString *btnString = [NSString stringWithUTF8String:Btn];

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:titleString
message:messageString
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *ButtonAction = [UIAlertAction actionWithTitle:btnString
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
if (callback != nullptr) {
callback();
}
}];


[alertController addAction:ButtonAction];

if (Btn2 != nullptr) {
NSString *btnString2 = [NSString stringWithUTF8String:Btn2];
UIAlertAction *ButtonAction2 = [UIAlertAction ActionWithTitle:btnString2
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
if (callback2 != nullptr) {
callback2();
}
}];
[alertController addAction:ButtonAction2];
}

UIViewController *rootViewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];

[rootViewController presentViewController:alertController animated:YES completion:nil];
}

/* self explanatory, get the ios version.
usage: iOSVersion();
you can also do something like this
if (iOSVersion == "17.4") {
showAlert("iOS 17.4", "You are on iOS 17.4", "go away");
} else {
showAlert("Update Required", "Update to iOS 17.4", "shut up");
}
*/
void iOSVersion() {
UIDevice *device = [UIDevice currentDevice];
NSString *iOSVersion = [device systemVersion];
return iOSVersion;
}
4 changes: 0 additions & 4 deletions src/main.hpp

This file was deleted.

18 changes: 0 additions & 18 deletions src/main.mm

This file was deleted.

46 changes: 0 additions & 46 deletions src/mainobj.mm

This file was deleted.

11 changes: 11 additions & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <Geode/Geode.hpp>
#include <Geode/Modify/MenuLayer.hpp>
#include "iGeodeLib.hpp"

using namespace geode::prelude;

class $modify(MenuLayer) {
void onMoreGames(CCObject*) {
CShowAlert("Hello", "hi", "go away", nullptr, "hi");
}
};

0 comments on commit 1a16c6c

Please sign in to comment.