added firebase and rudimentary leaderboard support
This commit is contained in:
17
ios_plugins/godot_svc/src/godot_svc.gdip
Normal file
17
ios_plugins/godot_svc/src/godot_svc.gdip
Normal file
@@ -0,0 +1,17 @@
|
||||
[config]
|
||||
name="GodotSVC"
|
||||
binary="godot_svc.xcframework"
|
||||
|
||||
initialization="register_godot_svc_plugin"
|
||||
deinitialization="unregister_godot_svc_plugin"
|
||||
|
||||
[dependencies]
|
||||
linked=[]
|
||||
embedded=[]
|
||||
system=[]
|
||||
|
||||
capabilities=[]
|
||||
|
||||
files=[]
|
||||
|
||||
[plist]
|
||||
30
ios_plugins/godot_svc/src/godot_svc.h
Normal file
30
ios_plugins/godot_svc/src/godot_svc.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*************************************************************************/
|
||||
/* godot_svc.h */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOTSVC_H
|
||||
#define GODOTSVC_H
|
||||
|
||||
#include "core/version.h"
|
||||
#if VERSION_MAJOR == 4
|
||||
#include "core/object/class_db.h"
|
||||
#else
|
||||
#include "core/object.h"
|
||||
#endif
|
||||
|
||||
class GodotSvc : public Object {
|
||||
|
||||
GDCLASS(GodotSvc, Object);
|
||||
|
||||
static GodotSvc *instance;
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static GodotSvc *get_singleton();
|
||||
void popup(String url);
|
||||
void close();
|
||||
GodotSvc();
|
||||
~GodotSvc();
|
||||
};
|
||||
|
||||
#endif
|
||||
41
ios_plugins/godot_svc/src/godot_svc.mm
Normal file
41
ios_plugins/godot_svc/src/godot_svc.mm
Normal file
@@ -0,0 +1,41 @@
|
||||
/*************************************************************************/
|
||||
/* godot_svc.mm */
|
||||
/*************************************************************************/
|
||||
#include "godot_svc.h"
|
||||
|
||||
#import "platform/iphone/app_delegate.h"
|
||||
#import "platform/iphone/view_controller.h"
|
||||
#import "godot_svc_delegate.mm"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
GodotSvc *GodotSvc::instance = NULL;
|
||||
GodotSvcDelegate *godot_svc_delegate = nil;
|
||||
void GodotSvc::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("popup"), &GodotSvc::popup);
|
||||
ClassDB::bind_method(D_METHOD("close"), &GodotSvc::close);
|
||||
}
|
||||
|
||||
GodotSvc::GodotSvc() {
|
||||
ERR_FAIL_COND(instance != NULL);
|
||||
instance = this;
|
||||
godot_svc_delegate = [[GodotSvcDelegate alloc] init];
|
||||
}
|
||||
|
||||
void GodotSvc::popup(String url){
|
||||
NSString *nsURL = [[NSString alloc] initWithUTF8String:url.utf8().get_data()];
|
||||
[godot_svc_delegate loadSvc:nsURL];
|
||||
}
|
||||
|
||||
void GodotSvc::close(){
|
||||
[godot_svc_delegate closeSvc];
|
||||
}
|
||||
|
||||
GodotSvc *GodotSvc::get_singleton() {
|
||||
return instance;
|
||||
};
|
||||
|
||||
GodotSvc::~GodotSvc() {
|
||||
if (godot_svc_delegate) {
|
||||
godot_svc_delegate = nil;
|
||||
}
|
||||
}
|
||||
36
ios_plugins/godot_svc/src/godot_svc_delegate.mm
Normal file
36
ios_plugins/godot_svc/src/godot_svc_delegate.mm
Normal file
@@ -0,0 +1,36 @@
|
||||
/*************************************************************************/
|
||||
/* godot_svc_delegate.mm */
|
||||
/*************************************************************************/
|
||||
#import "platform/iphone/view_controller.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WebKit/WebKit.h"
|
||||
#import <SafariServices/SafariServices.h>
|
||||
|
||||
@interface GodotSvcDelegate : NSObject
|
||||
- (void)loadSvc:(NSString *)url;
|
||||
- (void)closeSvc;
|
||||
@end
|
||||
|
||||
@implementation GodotSvcDelegate
|
||||
- (void)loadSvc:(NSString *)url {
|
||||
// Parses String Into URL Request
|
||||
NSURL *nsurl=[NSURL URLWithString:url];
|
||||
// Gets root controller to present the safari view controller
|
||||
UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController;
|
||||
// add svc
|
||||
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:nsurl];
|
||||
svc.delegate = (id) self;
|
||||
[root_controller presentViewController:svc animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)closeSvc {
|
||||
UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController;
|
||||
[root_controller dismissViewControllerAnimated:true completion:nil];
|
||||
|
||||
}
|
||||
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
|
||||
UIViewController *root_controller = [[UIApplication sharedApplication] delegate].window.rootViewController;
|
||||
[root_controller dismissViewControllerAnimated:true completion:nil];
|
||||
}
|
||||
@end
|
||||
|
||||
23
ios_plugins/godot_svc/src/godot_svc_module.cpp
Normal file
23
ios_plugins/godot_svc/src/godot_svc_module.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/*************************************************************************/
|
||||
/* godot_svc_module.cpp */
|
||||
/*************************************************************************/
|
||||
#include "godot_svc_module.h"
|
||||
#include "core/version.h"
|
||||
#if VERSION_MAJOR == 4
|
||||
#include "core/config/engine.h"
|
||||
#else
|
||||
#include "core/engine.h"
|
||||
#endif
|
||||
#include "godot_svc.h"
|
||||
|
||||
GodotSvc *godot_svc;
|
||||
void register_godot_svc_plugin() {
|
||||
godot_svc = memnew(GodotSvc);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("GodotSvc", godot_svc));
|
||||
}
|
||||
|
||||
void unregister_godot_svc_plugin() {
|
||||
if (godot_svc) {
|
||||
memdelete(godot_svc);
|
||||
}
|
||||
}
|
||||
6
ios_plugins/godot_svc/src/godot_svc_module.h
Normal file
6
ios_plugins/godot_svc/src/godot_svc_module.h
Normal file
@@ -0,0 +1,6 @@
|
||||
/*************************************************************************/
|
||||
/* godot_svc_module.h */
|
||||
/*************************************************************************/
|
||||
|
||||
void register_godot_svc_plugin();
|
||||
void unregister_godot_svc_plugin();
|
||||
Reference in New Issue
Block a user