Merge pull request #1676 from cocos-creator/v2.0-release

sync branch
This commit is contained in:
Jare Guo
2019-02-12 14:58:58 +08:00
committed by GitHub
25 changed files with 257 additions and 106 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ NS_CC_BEGIN
CC_DLL const char* cocos2dVersion()
{
return "2.1.0";
return "2.0.x";
}
NS_CC_END
+2
View File
@@ -179,6 +179,8 @@ public:
*/
bool openURL(const std::string &url);
void copyTextToClipboard(const std::string &text);
std::string getSystemVersion();
protected:
@@ -257,6 +257,11 @@ bool Application::openURL(const std::string &url)
return openURLJNI(url);
}
void Application::copyTextToClipboard(const std::string &text)
{
copyTextToClipboardJNI(text);
}
std::string Application::getSystemVersion()
{
return getSystemVersionJNI();
@@ -25,6 +25,8 @@ THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.lib;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -378,6 +380,18 @@ public class Cocos2dxHelper {
}
return ret;
}
// 复制文本到剪切板
public static void copyTextToClipboard(final String text){
sActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
ClipboardManager myClipboard = (ClipboardManager)sActivity.getSystemService(Context.CLIPBOARD_SERVICE);
ClipData myClip = ClipData.newPlainText("text", text);
myClipboard.setPrimaryClip(myClip);
}
});
}
public static long[] getObbAssetFileDescriptor(final String path) {
long[] array = new long[3];
@@ -589,6 +589,11 @@ bool openURLJNI(const std::string& url)
return JniHelper::callStaticBooleanMethod(JCLS_HELPER, "openURL", url);
}
void copyTextToClipboardJNI(const std::string& text)
{
JniHelper::callStaticVoidMethod(JCLS_HELPER, "copyTextToClipboard", text);
}
void setPreferredFramesPerSecondJNI(int fps)
{
JniHelper::callStaticVoidMethod(JCLS_RENDERER, "setPreferredFramesPerSecond", fps);
@@ -42,6 +42,7 @@ extern int getDeviceAudioBufferSizeInFramesJNI();
extern std::string getCurrentLanguageJNI();
extern std::string getSystemVersionJNI();
extern bool openURLJNI(const std::string& url);
extern void copyTextToClipboardJNI(const std::string& text);
extern void setPreferredFramesPerSecondJNI(int fps);
extern void setGameInfoDebugViewTextJNI(int index, const std::string& text);
extern void setJSBInvocationCountJNI(int count);
@@ -352,6 +352,12 @@ bool Application::openURL(const std::string &url)
return [[UIApplication sharedApplication] openURL:nsUrl];
}
void Application::copyTextToClipboard(const std::string &text)
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
}
bool Application::applicationDidFinishLaunching()
{
return true;
@@ -268,6 +268,14 @@ bool Application::openURL(const std::string &url)
return [[NSWorkspace sharedWorkspace] openURL:nsUrl];
}
void Application::copyTextToClipboard(const std::string &text)
{
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
[pasteboard clearContents];
NSString* tmp = [NSString stringWithCString:text.c_str() encoding:NSUTF8StringEncoding];
[pasteboard setString:tmp forType:NSStringPboardType];
}
bool Application::applicationDidFinishLaunching()
{
return true;
@@ -373,6 +373,11 @@ bool Application::openURL(const std::string &url)
return (size_t)r>32;
}
void Application::copyTextToClipboard(const std::string &text)
{
//TODO
}
bool Application::applicationDidFinishLaunching()
{
return true;
@@ -723,6 +723,39 @@ namespace
bool freeData = false;
};
uint8_t* cvRGB2RGBA (uint32_t length, uint8_t* src) {
uint8_t* dst = new uint8_t[length];
for (uint32_t i = 0; i < length; i += 4) {
dst[i] = *src++;
dst[i + 1] = *src++;
dst[i + 2] = *src++;
dst[i + 3] = 255;
}
return dst;
}
uint8_t* cvIA2RGBA (uint32_t length, uint8_t* src) {
uint8_t* dst = new uint8_t[length];
for (uint32_t i = 0; i < length; i += 4) {
dst[i] = *src;
dst[i + 1] = *src;
dst[i + 2] = *src++;
dst[i + 3] = *src;
}
return dst;
}
uint8_t* cvI2RGBA (uint32_t length, uint8_t* src) {
uint8_t* dst = new uint8_t[length];
for (uint32_t i = 0; i < length; i += 4) {
dst[i] = *src;
dst[i + 1] = *src;
dst[i + 2] = *src++;
dst[i + 3] = 255;
}
return dst;
}
struct ImageInfo* createImageInfo(const Image* img)
{
struct ImageInfo* imgInfo = new struct ImageInfo();
@@ -741,24 +774,33 @@ namespace
imgInfo->hasAlpha = img->hasAlpha();
imgInfo->hasPremultipliedAlpha = img->hasPremultipliedAlpha();
imgInfo->compressed = img->isCompressed();
imgInfo->length = img->getWidth() * img->getHeight() * 4;
// Convert to RGBA888 because standard web api will return only RGBA888.
// If not, then it may have issue in glTexSubImage. For example, engine
// will create a big texture, and update its content with small pictures.
// The big texture is RGBA888, then the small picture should be the same
// format, or it will cause 0x502 error on OpenGL ES 2.
if (GL_RGB == imgInfo->glFormat)
{
imgInfo->length = img->getWidth() * img->getHeight() * 4;
uint8_t* dst = new uint8_t[imgInfo->length];
uint8_t* src = imgInfo->data;
for (uint32_t i = 0, length = imgInfo->length; i < length; i += 4)
{
dst[i] = *src++;
dst[i + 1] = *src++;
dst[i + 2] = *src++;
dst[i + 3] = 255;
}
uint8_t* dst = nullptr;
uint32_t length = imgInfo->length;
uint8_t* src = imgInfo->data;
switch(imgInfo->glFormat) {
case GL_RGBA: break;
case GL_LUMINANCE_ALPHA:
dst = cvIA2RGBA(length, src);
break;
case GL_ALPHA:
case GL_LUMINANCE:
dst = cvI2RGBA(length, src);
break;
case GL_RGB:
dst = cvRGB2RGBA(length, src);
break;
default:
SE_LOGE("unknown image format");
}
if (imgInfo->glFormat != GL_RGBA) {
imgInfo->data = dst;
imgInfo->hasAlpha = true;
imgInfo->bpp = 32;
@@ -1009,6 +1051,24 @@ static bool JSB_openURL(se::State& s)
}
SE_BIND_FUNC(JSB_openURL)
static bool JSB_copyTextToClipboard(se::State& s)
{
const auto& args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc > 0) {
std::string text;
ok = seval_to_std_string(args[0], &text);
SE_PRECONDITION2(ok, false, "text is invalid!");
Application::getInstance()->copyTextToClipboard(text);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_copyTextToClipboard)
static bool JSB_setPreferredFramesPerSecond(se::State& s)
{
const auto& args = s.args();
@@ -1146,6 +1206,8 @@ bool jsb_register_global_variables(se::Object* global)
__jsbObj->defineFunction("openDebugView", _SE(js_openDebugView));
__jsbObj->defineFunction("disableBatchGLCommandsToNative", _SE(js_disableBatchGLCommandsToNative));
__jsbObj->defineFunction("openURL", _SE(JSB_openURL));
__jsbObj->defineFunction("copyTextToClipboard", _SE(JSB_copyTextToClipboard));
__jsbObj->defineFunction("setPreferredFramesPerSecond", _SE(JSB_setPreferredFramesPerSecond));
__jsbObj->defineFunction("showInputBox", _SE(JSB_showInputBox));
__jsbObj->defineFunction("hideInputBox", _SE(JSB_hideInputBox));
@@ -99,28 +99,30 @@ android {
android.applicationVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
variant.mergeAssets.doLast {
def sourceDir = "${buildDir}/../../../../.."
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
from "${sourceDir}/res"
into "${outputDir}/res"
}
copy {
from "${buildDir}/../../../../../src"
into "${buildDir}/intermediates/assets/${variant.dirName}/src"
from "${sourceDir}/src"
into "${outputDir}/src"
}
copy {
from "${buildDir}/../../../../../jsb-adapter"
into "${buildDir}/intermediates/assets/${variant.dirName}/jsb-adapter"
from "${sourceDir}/jsb-adapter"
into "${outputDir}/jsb-adapter"
}
copy {
from "${buildDir}/../../../../../main.js"
from "${buildDir}/../../../../../project.json"
into "${buildDir}/intermediates/assets/${variant.dirName}"
from "${sourceDir}/main.js"
from "${sourceDir}/project.json"
into outputDir
}
}
}
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
@@ -91,28 +91,30 @@ android {
android.featureVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
variant.mergeAssets.doLast {
def sourceDir = "${buildDir}/../../../../.."
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
from "${sourceDir}/res"
into "${outputDir}/res"
}
copy {
from "${buildDir}/../../../../../src"
into "${buildDir}/intermediates/assets/${variant.dirName}/src"
from "${sourceDir}/src"
into "${outputDir}/src"
}
copy {
from "${buildDir}/../../../../../jsb-adapter"
into "${buildDir}/intermediates/assets/${variant.dirName}/jsb-adapter"
from "${sourceDir}/jsb-adapter"
into "${outputDir}/jsb-adapter"
}
copy {
from "${buildDir}/../../../../../main.js"
from "${buildDir}/../../../../../project.json"
into "${buildDir}/intermediates/assets/${variant.dirName}"
from "${sourceDir}/main.js"
from "${sourceDir}/project.json"
into outputDir
}
}
}
@@ -27,7 +27,7 @@ PROP_MIN_SDK_VERSION=16
PROP_TARGET_SDK_VERSION=27
# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=27.0.3
PROP_BUILD_TOOLS_VERSION=28.0.3
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
@@ -99,28 +99,30 @@ android {
android.applicationVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
variant.mergeAssets.doLast {
def sourceDir = "${buildDir}/../../../../.."
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
from "${sourceDir}/res"
into "${outputDir}/res"
}
copy {
from "${buildDir}/../../../../../src"
into "${buildDir}/intermediates/assets/${variant.dirName}/src"
from "${sourceDir}/src"
into "${outputDir}/src"
}
copy {
from "${buildDir}/../../../../../jsb-adapter"
into "${buildDir}/intermediates/assets/${variant.dirName}/jsb-adapter"
from "${sourceDir}/jsb-adapter"
into "${outputDir}/jsb-adapter"
}
copy {
from "${buildDir}/../../../../../main.js"
from "${buildDir}/../../../../../project.json"
into "${buildDir}/intermediates/assets/${variant.dirName}"
from "${sourceDir}/main.js"
from "${sourceDir}/project.json"
into outputDir
}
}
}
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
@@ -27,7 +27,7 @@ PROP_MIN_SDK_VERSION=16
PROP_TARGET_SDK_VERSION=27
# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=27.0.3
PROP_BUILD_TOOLS_VERSION=28.0.3
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
@@ -99,28 +99,30 @@ android {
android.applicationVariants.all { variant ->
// delete previous files first
delete "${buildDir}/intermediates/assets/${variant.dirName}"
delete "${buildDir}/intermediates/merged_assets/${variant.dirName}"
variant.mergeAssets.doLast {
def sourceDir = "${buildDir}/../../../../.."
copy {
from "${buildDir}/../../../../../res"
into "${buildDir}/intermediates/assets/${variant.dirName}/res"
from "${sourceDir}/res"
into "${outputDir}/res"
}
copy {
from "${buildDir}/../../../../../src"
into "${buildDir}/intermediates/assets/${variant.dirName}/src"
}
copy {
from "${buildDir}/../../../../../jsb-adapter"
into "${buildDir}/intermediates/assets/${variant.dirName}/jsb-adapter"
from "${sourceDir}/src"
into "${outputDir}/src"
}
copy {
from "${buildDir}/../../../../../main.js"
from "${buildDir}/../../../../../project.json"
into "${buildDir}/intermediates/assets/${variant.dirName}"
from "${sourceDir}/jsb-adapter"
into "${outputDir}/jsb-adapter"
}
copy {
from "${sourceDir}/main.js"
from "${sourceDir}/project.json"
into outputDir
}
}
}
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
@@ -27,7 +27,7 @@ PROP_MIN_SDK_VERSION=16
PROP_TARGET_SDK_VERSION=27
# Android Build Tools version that will be used as the compile project
PROP_BUILD_TOOLS_VERSION=27.0.3
PROP_BUILD_TOOLS_VERSION=28.0.3
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
+57 -27
View File
@@ -13,54 +13,84 @@
},
"simulator_screen_size": [
{
"title": "iPhone 3Gs (480x320)",
"width": 480,
"height": 320
"title": "Apple iPhone 5 (640x1136)",
"width": 640,
"height": 1136
},
{
"title": "iPhone 4 (960x640)",
"width": 960,
"height": 640
"title": "Apple iPhone 6 (750x1334)",
"width": 750,
"height": 1334
},
{
"title": "iPhone 5 (1136x640)",
"width": 1136,
"height": 640
"title": "Apple iPhone 6Plus (1242x2208)",
"width": 1242,
"height": 2208
},
{
"title": "iPhone 6 (1334x750)",
"width": 1334,
"height": 750
"title": "Apple iPhone 7 (750x1334)",
"width": 750,
"height": 1334
},
{
"title": "iPhone 6 Plus (1920x1080)",
"width": 1920,
"height": 1080
"title": "Apple iPhone 7Plus (1242x2208)",
"width": 1242,
"height": 2208
},
{
"title": "iPad (1024x768)",
"width": 1024,
"height": 768
"title": "Apple iPhone X (750x2436)",
"width": 750,
"height": 2436
},
{
"title": "iPad Retina (2048x1536)",
"title": "Apple iPad (2048x1536)",
"width": 2048,
"height": 1536
},
{
"title": "Android (800x480)",
"width": 800,
"height": 480
"title": "Apple iPad Air 2 (1536x2048)",
"width": 1536,
"height": 2048
},
{
"title": "Android (854x480)",
"width": 854,
"height": 480
"title": "Apple iPad Pro 10.5-inch (1668x2224)",
"width": 1668,
"height": 2224
},
{
"title": "Android (1280x720)",
"title": "Apple iPad Pro 12.9-inch (2048x2732)",
"width": 1280,
"height": 720
"height": 2732
},
{
"title": "Huawei P9 (1080x1920)",
"width": 1080,
"height": 1920
},
{
"title": "Huawei Mate9 Pro (1440x2560)",
"width": 1440,
"height": 2560
},
{
"title": "Goolge Nexus 5 (1080x2880)",
"width": 1080,
"height": 2880
},
{
"title": "Goolge Nexus 5X (1079x1919)",
"width": 1079,
"height": 1919
},
{
"title": "Goolge Nexus 6 (1442x2562)",
"width": 1442,
"height": 2562
},
{
"title": "Goolge Nexus 7 (1920x1200)",
"width": 1920,
"height": 1200
}
]
}
@@ -40,20 +40,25 @@ SimulatorConfig *SimulatorConfig::getInstance()
SimulatorConfig::SimulatorConfig()
{
_screenSizeArray.push_back(SimulatorScreenSize("iPhone 3Gs (320x480)", 320, 480));
_screenSizeArray.push_back(SimulatorScreenSize("iPhone 4 (640x960)", 640, 960));
_screenSizeArray.push_back(SimulatorScreenSize("iPhone 5 (640x1136)", 640, 1136));
_screenSizeArray.push_back(SimulatorScreenSize("iPhone 6 (750x1334)", 750, 1334));
_screenSizeArray.push_back(SimulatorScreenSize("iPhone 6Plus (1242x2208)", 1242, 2208));
_screenSizeArray.push_back(SimulatorScreenSize("iPad (768x1024)", 768, 1024));
_screenSizeArray.push_back(SimulatorScreenSize("iPad Retina (1536x2048)", 1536, 2048));
_screenSizeArray.push_back(SimulatorScreenSize("Android (480x800)", 480, 800));
_screenSizeArray.push_back(SimulatorScreenSize("Android (480x854)", 480, 854));
_screenSizeArray.push_back(SimulatorScreenSize("Android (540x960)", 540, 960));
_screenSizeArray.push_back(SimulatorScreenSize("Android (600x1024)", 600, 1024));
_screenSizeArray.push_back(SimulatorScreenSize("Android (720x1280)", 720, 1280));
_screenSizeArray.push_back(SimulatorScreenSize("Android (800x1280)", 800, 1280));
_screenSizeArray.push_back(SimulatorScreenSize("Android (1080x1920)", 1080, 1920));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone 5 (640x1136)", 640, 1136));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone 6 (750x1334)", 750, 1334));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone 6Plus (1242x2208)", 1242, 2208));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone 7 (750x1334)", 750, 1334));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone 7Plus (1242x2208)", 1242, 2208));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPhone X (750x2436)", 750, 2436));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPad (2048x1536)", 2048, 1536));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPad Air 2 (1536x2048)", 1536, 2048));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPad Pro 10.5-inch (1668x2224)", 1668, 2224));
_screenSizeArray.push_back(SimulatorScreenSize("Apple iPad Pro 12.9-inch (2048x2732)", 2048, 2732));
_screenSizeArray.push_back(SimulatorScreenSize("Huawei P9 (1080x1920)", 1080, 1920));
_screenSizeArray.push_back(SimulatorScreenSize("Huawei Mate9 Pro (1440x2560)", 1440, 2560));
_screenSizeArray.push_back(SimulatorScreenSize("Goolge Nexus 5 (1080x2880)", 1080, 2880));
_screenSizeArray.push_back(SimulatorScreenSize("Goolge Nexus 5X (1079x1919)", 1079, 1919));
_screenSizeArray.push_back(SimulatorScreenSize("Goolge Nexus 6 (1442x2562)", 1442, 2562));
_screenSizeArray.push_back(SimulatorScreenSize("Goolge Nexus 7 (1920x1200)", 1920, 1200));
}
int SimulatorConfig::getScreenSizeCount() const