diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-05-25 17:30:36 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-05-25 17:33:40 +0200 |
commit | 50f152575d3a5206ce97db935b551ca7729242f4 (patch) | |
tree | 47b1d0d261f08c89120980997526002acc40a4b9 /platform | |
parent | 9fa4f1c54c6d528192e7ed04354d5ce2c733d99a (diff) |
Implement OS.alert() for iOS
Diffstat (limited to 'platform')
-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 bc25afabea..ea229e64da 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -405,6 +405,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 754dea073f..bf7e897efe 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -154,6 +154,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; |