diff options
Diffstat (limited to 'platform')
26 files changed, 343 insertions, 159 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 6feeb8b365..834ee58adc 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -62,10 +62,10 @@ pp_baseout.write( manifest ) for x in env.android_source_files: - shutil.copy(x,abspath+"/java/src/com/android/godot") + shutil.copy(x,abspath+"/java/src/com/android/godot") for x in env.android_module_libraries: - shutil.copy(x,abspath+"/java/libs") + shutil.copy(x,abspath+"/java/libs") env_android.SharedLibrary("#bin/libgodot",[android_objects],SHLIBSUFFIX=env["SHLIBSUFFIX"]) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index f8fc03ec61..1deeb3457a 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1123,6 +1123,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d if (file=="lib/armeabi/libgodot_android.so" && !export_arm) { skip=true; } + + if (file.begins_with("META-INF") && _signed) { + skip=true; + } print_line("ADDING: "+file); diff --git a/platform/android/java/res/values-fa/strings.xml b/platform/android/java/res/values-fa/strings.xml new file mode 100644 index 0000000000..450f9fe212 --- /dev/null +++ b/platform/android/java/res/values-fa/strings.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string name="godot_project_name_string">godot-project-name-fa</string> + <string name="testuf8">سلام</string> + <string name="text_paused_cellular">آیا می خواهید بر روی اتصال داده همراه دانلود را شروع کنید؟ بر اساس نوع سطح داده شما این ممکن است برای شما هزینه مالی داشته باشد.</string> + <string name="text_paused_cellular_2">اگر نمی خواهید بر روی اتصال داده همراه دانلود را شروع کنید ، دانلود به صورت خودکار در زمان دسترسی به وای-فای شروع می شود.</string> + <string name="text_button_resume_cellular">ادامه دانلود</string> + <string name="text_button_wifi_settings">تنظیمات وای-فای</string> + <string name="text_verifying_download">درحال تایید دانلود</string> + <string name="text_validation_complete">تایید فایل XAPK تکمیل شد. برای خروج تایید کنید.</string> + <string name="text_validation_failed">اعتبارسنجی فایل XAPK ناموق.</string> + <string name="text_button_pause">توقف دانلود</string> + <string name="text_button_resume">ادامه دانلود</string> + <string name="text_button_cancel">انصراف</string> + <string name="text_button_cancel_verify">انصراف از تایید شدن</string> +</resources> diff --git a/platform/android/java/src/com/android/godot/GodotPaymentV3.java b/platform/android/java/src/com/android/godot/GodotPaymentV3.java index 0fd102ac55..0799e1e83d 100644 --- a/platform/android/java/src/com/android/godot/GodotPaymentV3.java +++ b/platform/android/java/src/com/android/godot/GodotPaymentV3.java @@ -27,7 +27,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase { activity.getPaymentsManager().requestPurchase(sku, transactionId); } }); - }; + } /* public string requestPurchasedTicket(){ activity.getPaymentsManager() @@ -42,7 +42,7 @@ public class GodotPaymentV3 extends Godot.SingletonBase { public GodotPaymentV3(Activity p_activity) { - registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases"}); + registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature", "consumeUnconsumedPurchases", "requestPurchased", "setAutoConsume", "consume"}); activity=(Godot) p_activity; } @@ -54,7 +54,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase { activity.getPaymentsManager().consumeUnconsumedPurchases(); } }); - } private String signature; @@ -63,25 +62,26 @@ public class GodotPaymentV3 extends Godot.SingletonBase { } - public void callbackSuccess(String ticket, String signature){ -// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success"); - GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature}); -// Log.d(this.getClass().getName(), "POST-Send callback to purchase success"); + public void callbackSuccess(String ticket, String signature, String sku){ +// Log.d(this.getClass().getName(), "PRE-Send callback to purchase success"); + GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature, sku}); +// Log.d(this.getClass().getName(), "POST-Send callback to purchase success"); } public void callbackSuccessProductMassConsumed(String ticket, String signature, String sku){ -// Log.d(this.getClass().getName(), "PRE-Send callback to consume success"); - GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku}); -// Log.d(this.getClass().getName(), "POST-Send callback to consume success"); +// Log.d(this.getClass().getName(), "PRE-Send callback to consume success"); + Log.d(this.getClass().getName(), "callbackSuccessProductMassConsumed > "+ticket+","+signature+","+sku); + GodotLib.calldeferred(purchaseCallbackId, "consume_success", new Object[]{ticket, signature, sku}); +// Log.d(this.getClass().getName(), "POST-Send callback to consume success"); } public void callbackSuccessNoUnconsumedPurchases(){ - GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{}); + GodotLib.calldeferred(purchaseCallbackId, "no_validation_required", new Object[]{}); } public void callbackFail(){ - GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{}); -// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{}); + GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{}); +// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{}); } public void callbackCancel(){ @@ -89,6 +89,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase { // GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{}); } + public void callbackAlreadyOwned(String sku){ + GodotLib.calldeferred(purchaseCallbackId, "purchase_owned", new Object[]{sku}); + } + public int getPurchaseCallbackId() { return purchaseCallbackId; } @@ -97,8 +101,6 @@ public class GodotPaymentV3 extends Godot.SingletonBase { this.purchaseCallbackId = purchaseCallbackId; } - - public String getPurchaseValidationUrlPrefix(){ return this.purchaseValidationUrlPrefix ; } @@ -107,12 +109,10 @@ public class GodotPaymentV3 extends Godot.SingletonBase { this.purchaseValidationUrlPrefix = url; } - public String getAccessToken() { return accessToken; } - public void setAccessToken(String accessToken) { this.accessToken = accessToken; } @@ -125,4 +125,30 @@ public class GodotPaymentV3 extends Godot.SingletonBase { return this.transactionId; } + // request purchased items are not consumed + public void requestPurchased(){ + activity.getPaymentsManager().setBaseSingleton(this); + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + activity.getPaymentsManager().requestPurchased(); + } + }); + } + + // callback for requestPurchased() + public void callbackPurchased(String receipt, String signature, String sku){ + GodotLib.calldeferred(purchaseCallbackId, "has_purchased", new Object[]{receipt, signature, sku}); + } + + // consume item automatically after purchase. default is true. + public void setAutoConsume(boolean autoConsume){ + activity.getPaymentsManager().setAutoConsume(autoConsume); + } + + // consume a specific item + public void consume(String sku){ + activity.getPaymentsManager().consume(sku); + } } + diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java index 5bf86d0b69..189f7108c1 100644 --- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java +++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java @@ -25,10 +25,8 @@ import com.android.vending.billing.IInAppBillingService; public class PaymentsManager { public static final int BILLING_RESPONSE_RESULT_OK = 0; - - public static final int REQUEST_CODE_FOR_PURCHASE = 0x1001; - + private static boolean auto_consume = true; private Activity activity; IInAppBillingService mService; @@ -69,13 +67,12 @@ public class PaymentsManager { } @Override - public void onServiceConnected(ComponentName name, - IBinder service) { - mService = IInAppBillingService.Stub.asInterface(service); + public void onServiceConnected(ComponentName name, IBinder service) { + mService = IInAppBillingService.Stub.asInterface(service); } }; - public void requestPurchase(String sku, String transactionId){ + public void requestPurchase(final String sku, String transactionId){ new PurchaseTask(mService, Godot.getInstance()) { @Override @@ -88,6 +85,12 @@ public class PaymentsManager { protected void canceled() { godotPaymentV3.callbackCancel(); } + + @Override + protected void alreadyOwned() { + godotPaymentV3.callbackAlreadyOwned(sku); + } + }.purchase(sku, transactionId); } @@ -114,26 +117,82 @@ public class PaymentsManager { }.consumeItAll(); } + public void requestPurchased(){ + try{ + PaymentsCache pc = new PaymentsCache(Godot.getInstance()); + +// Log.d("godot", "requestPurchased for " + activity.getPackageName()); + Bundle bundle = mService.getPurchases(3, activity.getPackageName(), "inapp",null); + +/* + for (String key : bundle.keySet()) { + Object value = bundle.get(key); + Log.d("godot", String.format("%s %s (%s)", key, value.toString(), value.getClass().getName())); + } +*/ + + if (bundle.getInt("RESPONSE_CODE") == 0){ + + final ArrayList<String> myPurchases = bundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST"); + final ArrayList<String> mySignatures = bundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST"); + + + if (myPurchases == null || myPurchases.size() == 0){ +// Log.d("godot", "No purchases!"); + godotPaymentV3.callbackPurchased("", "", ""); + return; + } + +// Log.d("godot", "# products are purchased:" + myPurchases.size()); + for (int i=0;i<myPurchases.size();i++) + { + + try{ + String receipt = myPurchases.get(i); + JSONObject inappPurchaseData = new JSONObject(receipt); + String sku = inappPurchaseData.getString("productId"); + String token = inappPurchaseData.getString("purchaseToken"); + String signature = mySignatures.get(i); +// Log.d("godot", "purchased item:" + token + "\n" + receipt); + + pc.setConsumableValue("ticket_signautre", sku, signature); + pc.setConsumableValue("ticket", sku, receipt); + pc.setConsumableFlag("block", sku, true); + pc.setConsumableValue("token", sku, token); + + godotPaymentV3.callbackPurchased(receipt, signature, sku); + } catch (JSONException e) { + } + } + + } + }catch(Exception e){ + Log.d("godot", "Error requesting purchased products:" + e.getClass().getName() + ":" + e.getMessage()); + } + } + public void processPurchaseResponse(int resultCode, Intent data) { new HandlePurchaseTask(activity){ @Override protected void success(final String sku, final String signature, final String ticket) { - godotPaymentV3.callbackSuccess(ticket, signature); - new ConsumeTask(mService, activity) { + godotPaymentV3.callbackSuccess(ticket, signature, sku); + + if (auto_consume){ + new ConsumeTask(mService, activity) { - @Override - protected void success(String ticket) { -// godotPaymentV3.callbackSuccess(""); - } + @Override + protected void success(String ticket) { +// godotPaymentV3.callbackSuccess(""); + } - @Override - protected void error(String message) { - godotPaymentV3.callbackFail(); + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); - } - }.consume(sku); - + } + }.consume(sku); + } // godotPaymentV3.callbackSuccess(new PaymentsCache(activity).getConsumableValue("ticket", sku),signature); // godotPaymentV3.callbackSuccess(ticket); @@ -151,7 +210,7 @@ public class PaymentsManager { godotPaymentV3.callbackCancel(); } - }.handlePurchaseRequest(resultCode, data); + }.handlePurchaseRequest(resultCode, data); } public void validatePurchase(String purchaseToken, final String sku){ @@ -165,7 +224,7 @@ public class PaymentsManager { @Override protected void success(String ticket) { - godotPaymentV3.callbackSuccess(ticket, null); + godotPaymentV3.callbackSuccess(ticket, null, sku); } @@ -192,11 +251,31 @@ public class PaymentsManager { }.validatePurchase(sku); } + public void setAutoConsume(boolean autoConsume){ + auto_consume = autoConsume; + } + + public void consume(final String sku){ + new ConsumeTask(mService, activity) { + + @Override + protected void success(String ticket) { + godotPaymentV3.callbackSuccessProductMassConsumed(ticket, "", sku); + + } + + @Override + protected void error(String message) { + godotPaymentV3.callbackFail(); + + } + }.consume(sku); + } + private GodotPaymentV3 godotPaymentV3; public void setBaseSingleton(GodotPaymentV3 godotPaymentV3) { this.godotPaymentV3 = godotPaymentV3; - } } diff --git a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java index 75662a442e..c1f9d164a1 100644 --- a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java +++ b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java @@ -62,7 +62,11 @@ abstract public class PurchaseTask { // Log.d("XXX", "Buy intent response code: " + responseCode); if(responseCode == 1 || responseCode == 3 || responseCode == 4){ canceled(); - return ; + return; + } + if(responseCode == 7){ + alreadyOwned(); + return; } @@ -92,6 +96,6 @@ abstract public class PurchaseTask { abstract protected void error(String message); abstract protected void canceled(); - + abstract protected void alreadyOwned(); } diff --git a/platform/bb10/SCsub b/platform/bb10/SCsub index 24f2b5d242..81f6e726e4 100644 --- a/platform/bb10/SCsub +++ b/platform/bb10/SCsub @@ -19,4 +19,3 @@ if env['bb10_lgles_override'] == "yes": prog = None prog = env_bps.Program('#bin/godot', bb10_lib) - diff --git a/platform/bb10/os_bb10.cpp b/platform/bb10/os_bb10.cpp index d89033b1df..c8e7ae561e 100644 --- a/platform/bb10/os_bb10.cpp +++ b/platform/bb10/os_bb10.cpp @@ -195,9 +195,10 @@ void OSBB10::finalize() { // memdelete(debugger_connection_console); //} + memdelete(sample_manager); + audio_server->finish(); memdelete(audio_server); - memdelete(sample_manager); visual_server->finish(); memdelete(visual_server); diff --git a/platform/flash/SCsub b/platform/flash/SCsub index b7aef3b65d..4e5f26d52a 100644 --- a/platform/flash/SCsub +++ b/platform/flash/SCsub @@ -36,5 +36,3 @@ java -jar $ALCHEMY/usr/lib/asc2.jar -md -strict -optimize -AS3 \ -import ../platform/flash/lib/libGL.abc \ ../platform/flash/Console.as """ - - diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 1edb23d504..ef483657ca 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -137,9 +137,10 @@ void OS_Haiku::finalize() { spatial_sound_2d_server->finish(); memdelete(spatial_sound_2d_server); + memdelete(sample_manager); + audio_server->finish(); memdelete(audio_server); - memdelete(sample_manager); visual_server->finish(); memdelete(visual_server); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index d5764b2b5c..e5bd7a96b4 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -56,6 +56,8 @@ #import "Appirater.h" #endif +Error _shell_open(String); + Error _shell_open(String p_uri) { NSString* url = [[NSString alloc] initWithUTF8String:p_uri.utf8().get_data()]; @@ -236,6 +238,8 @@ static int frame_count = 0; view_controller.view = glView; window.rootViewController = view_controller; + glView.useCADisplayLink = bool(GLOBAL_DEF("display.iOS/use_cadisplaylink",true)) ? YES : NO; + printf("cadisaplylink: %d", glView.useCADisplayLink); glView.animationInterval = 1.0 / kRenderingFrequency; [glView startAnimation]; diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index 79c056776d..4cb7a20a7f 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -30,8 +30,18 @@ #include "game_center.h" +#ifdef __IPHONE_9_0 + +#import <GameKit/GameKit.h> +extern "C" { + +#else + extern "C" { #import <GameKit/GameKit.h> + +#endif + #import "app_delegate.h" }; diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index cda75394db..ca2d1d25ae 100755 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -34,8 +34,6 @@ #import <MediaPlayer/MediaPlayer.h> #import <AVFoundation/AVFoundation.h> -#define USE_CADISPLAYLINK 0 //iOS version 3.1+ is required - @protocol GLViewDelegate; @interface GLView : UIView<UIKeyInput> @@ -53,13 +51,13 @@ // OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) GLuint depthRenderbuffer; -#if USE_CADISPLAYLINK + BOOL useCADisplayLink; // CADisplayLink available on 3.1+ synchronizes the animation timer & drawing with the refresh rate of the display, only supports animation intervals of 1/60 1/30 & 1/15 CADisplayLink *displayLink; -#else + // An animation timer that, when animation is started, will periodically call -drawView at the given rate. + // Only used if CADisplayLink is not NSTimer *animationTimer; -#endif NSTimeInterval animationInterval; @@ -104,6 +102,7 @@ - (void)audioRouteChangeListenerCallback:(NSNotification*)notification; @property NSTimeInterval animationInterval; +@property(nonatomic, assign) BOOL useCADisplayLink; @end diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 4d5d1b81e3..f19e16f3f6 100755 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -54,6 +54,14 @@ static bool video_playing = false; static float video_previous_volume = 0.0f; static CMTime video_current_time; +void _show_keyboard(String); +void _hide_keyboard(); +bool _play_video(String, float, String, String); +bool _is_video_playing(); +void _focus_out_video(); +void _unpause_video(); +void _stop_video(); + void _show_keyboard(String p_existing) { keyboard_text = p_existing; printf("instance on show is %p\n", _instance); @@ -334,13 +342,15 @@ static void clear_touches() { delegateSetup = ![delegate respondsToSelector:@selector(setupView:)]; } +@synthesize useCADisplayLink; + // If our view is resized, we'll be asked to layout subviews. // This is the perfect opportunity to also update the framebuffer so that it is // the same size as our display area. -(void)layoutSubviews { - printf("HERE\n"); + //printf("HERE\n"); [EAGLContext setCurrentContext:context]; [self destroyFramebuffer]; [self createFramebuffer]; @@ -418,19 +428,21 @@ static void clear_touches() { return; active = TRUE; printf("start animation!\n"); -#if USE_CADISPLAYLINK - // Approximate frame rate - // assumes device refreshes at 60 fps - int frameInterval = (int) floor(animationInterval * 60.0f); - - displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)]; - [displayLink setFrameInterval:frameInterval]; - - // Setup DisplayLink in main thread - [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; -#else - animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; -#endif + if (useCADisplayLink) { + + // Approximate frame rate + // assumes device refreshes at 60 fps + int frameInterval = (int) floor(animationInterval * 60.0f); + + displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)]; + [displayLink setFrameInterval:frameInterval]; + + // Setup DisplayLink in main thread + [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + } + else { + animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES]; + } if (video_playing) { @@ -444,13 +456,16 @@ static void clear_touches() { return; active = FALSE; printf("******** stop animation!\n"); -#if USE_CADISPLAYLINK - [displayLink invalidate]; - displayLink = nil; -#else - [animationTimer invalidate]; - animationTimer = nil; -#endif + + if (useCADisplayLink) { + [displayLink invalidate]; + displayLink = nil; + } + else { + [animationTimer invalidate]; + animationTimer = nil; + } + clear_touches(); if (video_playing) @@ -462,13 +477,7 @@ static void clear_touches() { - (void)setAnimationInterval:(NSTimeInterval)interval { animationInterval = interval; - -#if USE_CADISPLAYLINK - if(displayLink) -#else - if(animationTimer) -#endif - { + if ( (useCADisplayLink && displayLink) || ( !useCADisplayLink && animationTimer ) ) { [self stopAnimation]; [self startAnimation]; } @@ -477,16 +486,16 @@ static void clear_touches() { // Updates the OpenGL view when the timer fires - (void)drawView { -#if USE_CADISPLAYLINK - // Pause the CADisplayLink to avoid recursion - [displayLink setPaused: YES]; + if (useCADisplayLink) { + // Pause the CADisplayLink to avoid recursion + [displayLink setPaused: YES]; - // Process all input events - while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource); + // Process all input events + while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource); - // We are good to go, resume the CADisplayLink - [displayLink setPaused: NO]; -#endif + // We are good to go, resume the CADisplayLink + [displayLink setPaused: NO]; + } if (!active) { printf("draw view not active!\n"); @@ -617,7 +626,7 @@ static void clear_touches() { - (void)audioRouteChangeListenerCallback:(NSNotification*)notification { - printf("*********** route changed!%i\n"); + printf("*********** route changed!\n"); NSDictionary *interuptionDict = notification.userInfo; NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue]; @@ -632,7 +641,7 @@ static void clear_touches() { case AVAudioSessionRouteChangeReasonOldDeviceUnavailable: NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable"); NSLog(@"Headphone/Line was pulled. Resuming video play...."); - if (_is_video_playing) { + if (_is_video_playing()) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [_instance.avPlayer play]; // NOTE: change this line according your current player implementation diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp index a4929c57dc..18a51a5b4e 100644..100755 --- a/platform/iphone/globals/global_defaults.cpp +++ b/platform/iphone/globals/global_defaults.cpp @@ -9,4 +9,5 @@ void register_iphone_global_defaults() { GLOBAL_DEF("rasterizer.iOS/fp16_framebuffer",false); GLOBAL_DEF("display.iOS/driver","GLES2"); Globals::get_singleton()->set_custom_property_info("display.iOS/driver",PropertyInfo(Variant::STRING,"display.iOS/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2")); + GLOBAL_DEF("display.iOS/use_cadisplaylink",true); } diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp index b7b9b747b4..f0cb929429 100644 --- a/platform/iphone/godot_iphone.cpp +++ b/platform/iphone/godot_iphone.cpp @@ -40,6 +40,8 @@ int add_path(int p_argc, char** p_args); int add_cmdline(int p_argc, char** p_args); }; +int iphone_main(int, int, int, char**); + int iphone_main(int width, int height, int argc, char** argv) { int len = strlen(argv[0]); diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm index 2dc2f7d9c1..518385992d 100644 --- a/platform/iphone/icloud.mm +++ b/platform/iphone/icloud.mm @@ -30,10 +30,16 @@ #include "icloud.h" +#ifndef __IPHONE_9_0 extern "C" { +#endif + #import <Foundation/Foundation.h> #import "app_delegate.h" + +#ifndef __IPHONE_9_0 }; +#endif ICloud* ICloud::instance = NULL; diff --git a/platform/iphone/sem_iphone.cpp b/platform/iphone/sem_iphone.cpp index 5afaa7b308..36baa40427 100644 --- a/platform/iphone/sem_iphone.cpp +++ b/platform/iphone/sem_iphone.cpp @@ -31,6 +31,11 @@ #include <unistd.h> #include <fcntl.h> +void cgsem_init(cgsem_t*); +void cgsem_post(cgsem_t*); +void cgsem_wait(cgsem_t*); +void cgsem_destroy(cgsem_t*); + void cgsem_init(cgsem_t *cgsem) { int flags, fd, i; diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index 6a9c3ac9ec..f98fb7c355 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -32,6 +32,9 @@ extern "C" { +int add_path(int, char**); +int add_cmdline(int, char**); + int add_path(int p_argc, char** p_args) { NSString* str = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"godot_path"]; diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 75e0878bac..8b831140d6 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -107,9 +107,10 @@ void OS_Server::finalize() { // memdelete(debugger_connection_console); //} + memdelete(sample_manager); + audio_server->finish(); memdelete(audio_server); - memdelete(sample_manager); visual_server->finish(); memdelete(visual_server); diff --git a/platform/windows/SCsub b/platform/windows/SCsub index 1ad32e7989..e7d7285b43 100644 --- a/platform/windows/SCsub +++ b/platform/windows/SCsub @@ -13,7 +13,7 @@ common_win=[ env.Program('#bin/godot',['godot_win.cpp']+common_win,PROGSUFFIX=env["PROGSUFFIX"]) -# Microsoft Visual Studio Project Generation +# Microsoft Visual Studio Project Generation if (env['vsproj'])=="yes": env.vs_srcs = env.vs_srcs + ["platform/windows/godot_win.cpp"] for x in common_win: diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 438a5a6903..baf85937c6 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1350,7 +1350,9 @@ void OS_Windows::finalize() { memdelete(main_loop); main_loop=NULL; - + + memdelete(input); + visual_server->finish(); memdelete(visual_server); #ifdef OPENGL_ENABLED @@ -1373,11 +1375,10 @@ void OS_Windows::finalize() { // memdelete(debugger_connection_console); //} - audio_server->finish(); - memdelete(audio_server); memdelete(sample_manager); - memdelete(input); + audio_server->finish(); + memdelete(audio_server); physics_server->finish(); memdelete(physics_server); @@ -1768,15 +1769,26 @@ void OS_Windows::print_error(const char* p_function,const char* p_file,int p_lin HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE); if (!hCon || hCon==INVALID_HANDLE_VALUE) { - if (p_rationale && p_rationale[0]) { - - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - } else { - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); + const char* err_details; + if (p_rationale && p_rationale[0]) + err_details=p_rationale; + else + err_details=p_code; + switch(p_type) { + case ERR_ERROR: + print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_WARNING: + print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_SCRIPT: + print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m",p_function,err_details); + print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line); + break; } } else { diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index 3e06d9d59b..80ed436b85 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -326,10 +326,11 @@ void OSWinrt::finalize() { //if (debugger_connection_console) { // memdelete(debugger_connection_console); //} + + memdelete(sample_manager); audio_server->finish(); memdelete(audio_server); - memdelete(sample_manager); memdelete(input); @@ -424,15 +425,25 @@ void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) con void OSWinrt::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { - if (p_rationale && p_rationale[0]) { - - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); - - } else { - print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_code); - print("\E[0;31;40m At: %s:%i.\E[0;0;37m\n",p_file,p_line); + const char* err_details; + if (p_rationale && p_rationale[0]) + err_details=p_rationale; + else + err_details=p_code; + switch(p_type) { + case ERR_ERROR: + print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_WARNING: + print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details); + print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line); + break; + case ERR_SCRIPT: + print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m",p_function,err_details); + print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line); + break; } } diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index dc0dc063b9..3db1f6da25 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -46,7 +46,6 @@ struct ContextGL_X11_Private { ::GLXContext glx_context; }; - void ContextGL_X11::release_current() { glXMakeCurrent(x11_display, None, NULL); @@ -56,10 +55,12 @@ void ContextGL_X11::make_current() { glXMakeCurrent(x11_display, x11_window, p->glx_context); } + void ContextGL_X11::swap_buffers() { glXSwapBuffers(x11_display,x11_window); } + /* static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) { @@ -154,6 +155,9 @@ Error ContextGL_X11::initialize() { */ //glXMakeCurrent(x11_display, None, NULL); + XFree( vi ); + XFree( fbc ); + return OK; } @@ -164,12 +168,12 @@ int ContextGL_X11::get_window_width() { return xwa.width; } + int ContextGL_X11::get_window_height() { XWindowAttributes xwa; XGetWindowAttributes(x11_display,x11_window,&xwa); return xwa.height; - } @@ -189,6 +193,8 @@ ContextGL_X11::ContextGL_X11(::Display *p_x11_display,::Window &p_x11_window,con ContextGL_X11::~ContextGL_X11() { + release_current(); + glXDestroyContext( x11_display, p->glx_context ); memdelete( p ); } diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 85928f2815..3218230d0b 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -73,20 +73,18 @@ #undef CursorShape int OS_X11::get_video_driver_count() const { - return 1; } -const char * OS_X11::get_video_driver_name(int p_driver) const { +const char * OS_X11::get_video_driver_name(int p_driver) const { return "GLES2"; } -OS::VideoMode OS_X11::get_default_video_mode() const { +OS::VideoMode OS_X11::get_default_video_mode() const { return OS::VideoMode(800,600,false); } int OS_X11::get_audio_driver_count() const { - return AudioDriverManagerSW::get_driver_count(); } @@ -153,6 +151,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XFree (xim_styles); } + XFree( imvalret ); } /* @@ -256,7 +255,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi } #endif - AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); audio_driver_index=p_audio_driver; @@ -351,6 +349,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi for(int i=0;i<CURSOR_MAX;i++) { cursors[i]=None; + img[i]=NULL; } current_cursor=CURSOR_ARROW; @@ -379,16 +378,15 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi "question_arrow" }; - XcursorImage *img = XcursorLibraryLoadImage(cursor_file[i],cursor_theme,cursor_size); - if (img) { - cursors[i]=XcursorImageLoadCursor(x11_display,img); + img[i] = XcursorLibraryLoadImage(cursor_file[i],cursor_theme,cursor_size); + if (img[i]) { + cursors[i]=XcursorImageLoadCursor(x11_display,img[i]); //print_line("found cursor: "+String(cursor_file[i])+" id "+itos(cursors[i])); } else { if (OS::is_stdout_verbose()) print_line("failed cursor: "+String(cursor_file[i])); } } - } @@ -399,9 +397,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XColor col; Cursor cursor; - cursormask = XCreatePixmap(x11_display, RootWindow(x11_display,DefaultScreen(x11_display)), 1, 1, 1); - xgc.function = GXclear; - gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc); + cursormask = XCreatePixmap(x11_display, RootWindow(x11_display,DefaultScreen(x11_display)), 1, 1, 1); + xgc.function = GXclear; + gc = XCreateGC(x11_display, cursormask, GCFunction, &xgc); XFillRectangle(x11_display, cursormask, gc, 0, 0, 1, 1); col.pixel = 0; col.red = 0; @@ -437,14 +435,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi probe_joystick(); _ensure_data_dir(); - - net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False); - - - - //printf("got map notify\n"); - } + void OS_X11::finalize() { if(main_loop) @@ -460,9 +452,10 @@ void OS_X11::finalize() { // memdelete(debugger_connection_console); //} + memdelete(sample_manager); + audio_server->finish(); memdelete(audio_server); - memdelete(sample_manager); visual_server->finish(); memdelete(visual_server); @@ -476,14 +469,26 @@ void OS_X11::finalize() { memdelete(input); + XUnmapWindow( x11_display, x11_window ); + XDestroyWindow( x11_display, x11_window ); + #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) memdelete(context_gl); #endif - + for(int i=0;i<CURSOR_MAX;i++) { + if( cursors[i] != None ) + XFreeCursor( x11_display, cursors[i] ); + if( img[i] != NULL ) + XcursorImageDestroy( img[i] ); + }; + + XDestroyIC( xic ); + XCloseIM( xim ); XCloseDisplay(x11_display); if (xmbstring) memfree(xmbstring); + args.clear(); } @@ -559,37 +564,29 @@ void OS_X11::warp_mouse_pos(const Point2& p_to) { } OS::MouseMode OS_X11::get_mouse_mode() const { - return mouse_mode; } - - int OS_X11::get_mouse_button_state() const { return last_button_state; } Point2 OS_X11::get_mouse_pos() const { - return last_mouse_pos; } void OS_X11::set_window_title(const String& p_title) { - XStoreName(x11_display,x11_window,p_title.utf8().get_data()); } void OS_X11::set_video_mode(const VideoMode& p_video_mode,int p_screen) { - - } -OS::VideoMode OS_X11::get_video_mode(int p_screen) const { +OS::VideoMode OS_X11::get_video_mode(int p_screen) const { return current_videomode; } -void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { - +void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) const { } //#ifdef NEW_WM_API @@ -672,7 +669,6 @@ void OS_X11::set_current_screen(int p_screen) { } Point2 OS_X11::get_screen_position(int p_screen) const { - // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); @@ -707,7 +703,6 @@ Size2 OS_X11::get_screen_size(int p_screen) const { XFree(xsi); return size; } - Point2 OS_X11::get_window_position() const { int x,y; @@ -896,7 +891,6 @@ void OS_X11::set_window_maximized(bool p_enabled) { current_videomode.height = xwa.height; */ maximized = p_enabled; - } bool OS_X11::is_window_maximized() const { @@ -992,7 +986,6 @@ unsigned int OS_X11::get_mouse_button_state(unsigned int p_x11_state) { } void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { - // X11 functions don't know what const is XKeyEvent *xkeyevent = p_event; @@ -1158,8 +1151,6 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { //printf("key: %x\n",event.key.scancode); input->parse_input_event( event); - - } void OS_X11::process_xevents() { @@ -1861,7 +1852,6 @@ void OS_X11::set_cursor_shape(CursorShape p_shape) { XDefineCursor(x11_display,x11_window,cursors[CURSOR_ARROW]); } - current_cursor=p_shape; } @@ -1894,6 +1884,8 @@ void OS_X11::alert(const String& p_alert,const String& p_title) { } void OS_X11::set_icon(const Image& p_icon) { + Atom net_wm_icon = XInternAtom(x11_display, "_NET_WM_ICON", False); + if (!p_icon.empty()) { Image img=p_icon; img.convert(Image::FORMAT_RGBA); @@ -1926,7 +1918,6 @@ void OS_X11::set_icon(const Image& p_icon) { XDeleteProperty(x11_display, x11_window, net_wm_icon); } XFlush(x11_display); - } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 1566062b9e..ed61df8f0e 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -119,6 +119,7 @@ class OS_X11 : public OS_Unix { const char *cursor_theme; int cursor_size; + XcursorImage *img[CURSOR_MAX]; Cursor cursors[CURSOR_MAX]; Cursor null_cursor; CursorShape current_cursor; @@ -155,12 +156,7 @@ class OS_X11 : public OS_Unix { }; }; }; - - Atom net_wm_icon; - - int joystick_count; - Joystick joysticks[JOYSTICKS_MAX]; int audio_driver_index; |