Skip to content

Commit

Permalink
Merge commit '805726b68b07241499a76b99fe06d035700d4c96' into v2.1.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	assets/res/textures/ui/style2/scrollview_barBg.png.meta
#	assets/scripts/Tips/TipsManager.js
  • Loading branch information
knoxHuang committed May 29, 2019
2 parents ab24724 + 805726b commit 1e21f1c
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ build/
library/
temp/
local/
jsb-default/
jsb-binary/
jsb-link/
web-desktop/
web-mobile/
runtime/
Expand Down
19 changes: 12 additions & 7 deletions assets/cases/native_call/Native_Call/NativeCallCtrl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var tips = null;
let tips = null;
cc.TestNativeCallJS = function () {
tips.string = 'The test was successful...';
};
Expand All @@ -10,16 +10,21 @@ cc.Class({
button: cc.Node
},

onLoad: function () {
start () {
var tipNode = cc.find("Canvas/New Label");
tips = tipNode.getComponent(cc.Label);
tips.string = 'Native Call Test';
},

onClick: function () {
var className = "org/cocos2dx/javascript/AppActivity";
var methodName = "showAlertDialog";
var methodSignature = "(Ljava/lang/String;Ljava/lang/String;)V";
jsb.reflection.callStaticMethod(className, methodName, methodSignature, "Title", "Native Call Test");
onClick () {
if (cc.sys.os === cc.sys.OS_ANDROID) {
let className = "org/cocos2dx/javascript/AppActivity";
let methodName = "showAlertDialog";
let methodSignature = "(Ljava/lang/String;Ljava/lang/String;)V";
jsb.reflection.callStaticMethod(className, methodName, methodSignature, "Title", "Native Call Test");
}
else if (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_OSX) {
jsb.reflection.callStaticMethod('AppController', 'showAlertDialog:withMessage:', "Title", "Native Call Test");
}
}
});
31 changes: 31 additions & 0 deletions assets/res/textures/ui/style2/scrollview_barBg.png.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"ver": "2.2.0",
"uuid": "271269d4-6d55-40c8-b0bc-13b75a920423",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"subMetas": {
"scrollview_barBg": {
"ver": "1.0.4",
"uuid": "169b5aa9-3be1-492b-bf3c-e149fadd5d95",
"rawTextureUuid": "271269d4-6d55-40c8-b0bc-13b75a920423",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 19,
"height": 22,
"rawWidth": 19,
"rawHeight": 22,
"borderTop": 6,
"borderBottom": 8,
"borderLeft": 5,
"borderRight": 5,
"subMetas": {}
}
}
}
7 changes: 4 additions & 3 deletions assets/scripts/Tips/TipsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const isVivo = cc.sys.platform === cc.sys.VIVO_GAME;
const isOPPO = cc.sys.platform === cc.sys.OPPO_GAME;
const isXiaomi = cc.sys.platform === cc.sys.XIAOMI_GAME;
const isHuawei = cc.sys.platform === cc.sys.HUAWEI_GAME;
const isJkw = cc.sys.platform === cc.sys.JKW_GAME;

module.exports = {
tispPrefab: null,
Expand All @@ -32,7 +33,7 @@ module.exports = {
case 'Native_Call': return isMobile && isAndroid && !CC_RUNTIME;
case 'TTFFontLabel': return !isQQPlay;
case 'Subpackages':
return (!CC_PREVIEW && !CC_JSB && !isBrowser && !isQQPlay && !isVivo);
return (!CC_PREVIEW && !CC_JSB && !isBrowser && !isQQPlay && !isVivo && !isJkw);
case 'MousePropagation': return ((isNative && !isMobile && !isWechat && !isQQPlay && !isXiaomi && !isHuawei) || isDesktopBrowser);
case 'downloader-native':
return isNative && !CC_RUNTIME;
Expand Down Expand Up @@ -60,11 +61,11 @@ module.exports = {

// Not support the Simulator, QQ_PLAY, WECHAT_GAME
case 'videoPlayer':
return (isMobile || isBrowser) && !isQQPlay && !isWechat && !isBaidu && !isXiaomi && !CC_RUNTIME;
return (isMobile || isBrowser) && !CC_RUNTIME && !isQQPlay && !isWechat && !isBaidu && !isXiaomi && !isHuawei;

// Not support the VIVO_GAME, OPPO_GAME, WECHAT_GAME, QQ_PLAY, CC_RUNTIME
case 'webview':
return (isMobile || isBrowser) && !CC_RUNTIME && !isQQPlay && !isWechat && !isBaidu && !isXiaomi;
return (isMobile || isBrowser) && !CC_RUNTIME && !isQQPlay && !isWechat && !isBaidu && !isXiaomi && !isHuawei;
case 'mesh':
return !isVivo && !isOPPO;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <UIKit/UIKit.h>

@class RootViewController;

@interface AppController : NSObject <UIApplicationDelegate>
{
}

+(void)showAlertDialog:(NSString *)title withMessage:(NSString *)message;

@property(nonatomic, readonly) RootViewController* viewController;

@end

Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

#import "AppController.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "RootViewController.h"
#import "SDKWrapper.h"
#import "platform/ios/CCEAGLView-ios.h"
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"


using namespace cocos2d;

@implementation AppController

Application* app = nullptr;
static RootViewController* rootViewController = nullptr;
@synthesize window;

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[SDKWrapper getInstance] application:application didFinishLaunchingWithOptions:launchOptions];
// Add the view controller's view to the window and display.
float scale = [[UIScreen mainScreen] scale];
CGRect bounds = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: bounds];

// cocos2d application instance
app = new AppDelegate(bounds.size.width * scale, bounds.size.height * scale);
app->setMultitouch(true);

// Use RootViewController to manage CCEAGLView
_viewController = [[RootViewController alloc]init];
rootViewController = _viewController;
#ifdef NSFoundationVersionNumber_iOS_7_0
_viewController.automaticallyAdjustsScrollViewInsets = NO;
_viewController.extendedLayoutIncludesOpaqueBars = NO;
_viewController.edgesForExtendedLayout = UIRectEdgeAll;
#else
_viewController.wantsFullScreenLayout = YES;
#endif
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:_viewController];
}

[window makeKeyAndVisible];

[[UIApplication sharedApplication] setStatusBarHidden:YES];

//run the cocos2d-x game scene
app->start();

return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
[[SDKWrapper getInstance] applicationWillResignActive:application];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
[[SDKWrapper getInstance] applicationDidBecomeActive:application];
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
[[SDKWrapper getInstance] applicationDidEnterBackground:application];
app->applicationDidEnterBackground();

}

- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
[[SDKWrapper getInstance] applicationWillEnterForeground:application];
app->applicationWillEnterForeground();

}

- (void)applicationWillTerminate:(UIApplication *)application
{
[[SDKWrapper getInstance] applicationWillTerminate:application];
delete app;
app = nil;
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}

+(void)showAlertDialog:(NSString *)title withMessage:(NSString *)message {



UIAlertController* alert = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//响应事件
NSString *execStr = [NSString stringWithFormat:@"cc.TestNativeCallJS()"];
se::ScriptEngine::getInstance()->evalString([execStr UTF8String]);
}];

[alert addAction:defaultAction];
[rootViewController presentViewController:alert animated:NO completion:nil];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#import <UIKit/UIKit.h>

@class RootViewController;

@interface AppController : NSObject <UIApplicationDelegate>
{
}

+(void)showAlertDialog:(NSString *)title withMessage:(NSString *)message;

@property(nonatomic, readonly) RootViewController* viewController;

@end

Loading

0 comments on commit 1e21f1c

Please sign in to comment.