diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-05-26 07:56:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-26 07:56:22 +0200 |
commit | d197cd4705b51c792a65df9f4dc87466375ed21d (patch) | |
tree | d112c0cae0077939f3eab973f3179bcff3b697b8 /platform/iphone | |
parent | dbba433b69985c1629aeb9cbb0ddf85efdada7e0 (diff) | |
parent | 50f152575d3a5206ce97db935b551ca7729242f4 (diff) |
Merge pull request #8912 from RandomShaper/ios-alert
Implement OS.alert() for iOS
Diffstat (limited to 'platform/iphone')
-rw-r--r-- | platform/iphone/ios.h | 2 | ||||
-rw-r--r-- | platform/iphone/ios.mm | 5 | ||||
-rw-r--r-- | platform/iphone/os_iphone.cpp | 7 | ||||
-rw-r--r-- | platform/iphone/os_iphone.h | 2 |
4 files changed, 16 insertions, 0 deletions
diff --git a/platform/iphone/ios.h b/platform/iphone/ios.h index 5329d4f02a..2572d626d2 100644 --- a/platform/iphone/ios.h +++ b/platform/iphone/ios.h @@ -39,6 +39,8 @@ class iOS : public Object { static void _bind_methods(); public: + static void alert(const char *p_alert, const char *p_title); + String get_rate_url(int p_app_id) const; iOS(); diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm index cd64bbfafc..e9c164393b 100644 --- a/platform/iphone/ios.mm +++ b/platform/iphone/ios.mm @@ -36,6 +36,11 @@ void iOS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_rate_url", "app_id"), &iOS::get_rate_url); }; +void iOS::alert(const char* p_alert, const char* p_title) { + UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:[NSString stringWithUTF8String:p_title] message:[NSString stringWithUTF8String:p_alert] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease]; + [alert show]; +} + String iOS::get_rate_url(int p_app_id) const { String templ = "itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID"; String templ_iOS7 = "itms-apps://itunes.apple.com/app/idAPP_ID"; diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 7023021c66..0d7913446e 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -403,6 +403,13 @@ int OSIPhone::get_mouse_button_state() const { void OSIPhone::set_window_title(const String &p_title){}; +void OSIPhone::alert(const String &p_alert, const String &p_title) { + + const CharString utf8_alert = p_alert.utf8(); + const CharString utf8_title = p_title.utf8(); + iOS::alert(utf8_alert.get_data(), utf8_title.get_data()); +} + void OSIPhone::set_video_mode(const VideoMode &p_video_mode, int p_screen) { video_mode = p_video_mode; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 0da7e6d081..4031b7524c 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -159,6 +159,8 @@ public: virtual int get_mouse_button_state() const; virtual void set_window_title(const String &p_title); + virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); + virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0); virtual VideoMode get_video_mode(int p_screen = 0) const; virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const; |