Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into execDev

This commit is contained in:
samuele3hu 2013-07-04 09:52:28 +08:00
commit c5e5c49332
37 changed files with 653 additions and 58 deletions

View File

@ -46,6 +46,8 @@ Developers:
DarraghCoy
Fix a potential crash SimpleAudioEngineOpenSL::playEffect
Fix some bugs with Set class
Add ccDrawSolidCircle
Add Rect::unionWithRect
silverscania
Pass correct parameter to glPixelStorei when creating a texture
@ -435,6 +437,7 @@ Developers:
Fix for broken of ccArrayGetIndexOfObject after merging this commit(076f38c).
Explicitly initialising CCAcceleration structure.
Add support to save/retrieve CCData into/from CCUserDefault.
Text Shadows fix
MarcelBloemendaal
Adding secureTextEntry property to CCTextFieldTTF.

View File

@ -271,4 +271,44 @@ bool Rect::intersectsRect(const Rect& rect) const
rect.getMaxY() < getMinY());
}
Rect Rect::unionWithRect(const Rect & rect) const
{
float thisLeftX = origin.x;
float thisRightX = origin.x + size.width;
float thisTopY = origin.y + size.height;
float thisBottomY = origin.y;
if (thisRightX < thisLeftX)
{
std::swap(thisRightX, thisLeftX); // This rect has negative width
}
if (thisTopY < thisBottomY)
{
std::swap(thisTopY, thisBottomY); // This rect has negative height
}
float otherLeftX = rect.origin.x;
float otherRightX = rect.origin.x + rect.size.width;
float otherTopY = rect.origin.y + rect.size.height;
float otherBottomY = rect.origin.y;
if (otherRightX < otherLeftX)
{
std::swap(otherRightX, otherLeftX); // Other rect has negative width
}
if (otherTopY < otherBottomY)
{
std::swap(otherTopY, otherBottomY); // Other rect has negative height
}
float combinedLeftX = std::min(thisLeftX, otherLeftX);
float combinedRightX = std::max(thisRightX, otherRightX);
float combinedTopY = std::max(thisTopY, otherTopY);
float combinedBottomY = std::min(thisBottomY, otherBottomY);
return Rect(combinedLeftX, combinedBottomY, combinedRightX - combinedLeftX, combinedTopY - combinedBottomY);
}
NS_CC_END

View File

@ -245,6 +245,7 @@ public:
bool equals(const Rect& rect) const;
bool containsPoint(const Point& point) const;
bool intersectsRect(const Rect& rect) const;
Rect unionWithRect(const Rect & rect) const;
};

View File

@ -100,14 +100,14 @@ typedef void (Object::*SEL_MenuHandler)(Object*);
typedef void (Object::*SEL_EventHandler)(Event*);
typedef int (Object::*SEL_Compare)(Object*);
#define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(&_SELECTOR)
#define callfunc_selector(_SELECTOR) (SEL_CallFunc)(&_SELECTOR)
#define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(&_SELECTOR)
#define callfuncND_selector(_SELECTOR) (SEL_CallFuncND)(&_SELECTOR)
#define callfuncO_selector(_SELECTOR) (SEL_CallFuncO)(&_SELECTOR)
#define menu_selector(_SELECTOR) (SEL_MenuHandler)(&_SELECTOR)
#define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR)
#define compare_selector(_SELECTOR) (SEL_Compare)(&_SELECTOR)
#define schedule_selector(_SELECTOR) static_cast<SEL_SCHEDULE>(&_SELECTOR)
#define callfunc_selector(_SELECTOR) static_cast<SEL_CallFunc>(&_SELECTOR)
#define callfuncN_selector(_SELECTOR) static_cast<SEL_CallFuncN>(&_SELECTOR)
#define callfuncND_selector(_SELECTOR) static_cast<SEL_CallFuncND>(&_SELECTOR)
#define callfuncO_selector(_SELECTOR) static_cast<SEL_CallFuncO>(&_SELECTOR)
#define menu_selector(_SELECTOR) static_cast<SEL_MenuHandler>(&_SELECTOR)
#define event_selector(_SELECTOR) static_cast<SEL_EventHandler>(&_SELECTOR)
#define compare_selector(_SELECTOR) static_cast<SEL_Compare>(&_SELECTOR)
// new callbacks based on C++11
#define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__)

View File

@ -109,15 +109,20 @@ void Set::removeObject(Object *pObject)
void Set::removeAllObjects()
{
for (SetIterator it = _set->begin(); it != _set->end(); )
SetIterator it = _set->begin();
SetIterator tmp;
while (it != _set->end())
{
if (!(*it))
{
break;
}
(*it)->release();
_set->erase(it++);
tmp = it;
++tmp;
_set->erase(it);
it = tmp;
}
}

View File

@ -383,6 +383,52 @@ void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsign
ccDrawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f);
}
void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
{
lazy_init();
const float coef = 2.0f * (float)M_PI/segments;
GLfloat *vertices = (GLfloat*)calloc( sizeof(GLfloat)*2*(segments+2), 1);
if( ! vertices )
return;
for(unsigned int i = 0;i <= segments; i++) {
float rads = i*coef;
GLfloat j = radius * cosf(rads + angle) * scaleX + center.x;
GLfloat k = radius * sinf(rads + angle) * scaleY + center.y;
vertices[i*2] = j;
vertices[i*2+1] = k;
}
vertices[(segments+1)*2] = center.x;
vertices[(segments+1)*2+1] = center.y;
s_pShader->use();
s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
#ifdef EMSCRIPTEN
setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1);
free( vertices );
CC_INCREMENT_GL_DRAWS(1);
}
void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments)
{
ccDrawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f);
}
void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments)
{
lazy_init();

View File

@ -113,6 +113,10 @@ void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, ccC
void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
/** draws a solid circle given the center, radius and number of segments. */
void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments);
/** draws a quad bezier path
@warning This function could be pretty slow. Use it only for debugging purposes.
@since v0.8

View File

@ -65,7 +65,7 @@ MotionStreak::~MotionStreak()
CC_SAFE_FREE(_texCoords);
}
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, const char* path)
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path)
{
MotionStreak *pRet = new MotionStreak();
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path))
@ -78,7 +78,7 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, ccCol
return NULL;
}
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, Texture2D* texture)
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture)
{
MotionStreak *pRet = new MotionStreak();
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture))
@ -91,7 +91,7 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, ccCol
return NULL;
}
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path)
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path)
{
CCAssert(path != NULL, "Invalid filename");
@ -99,7 +99,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColor3
return initWithFade(fade, minSeg, stroke, color, texture);
}
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColor3B color, Texture2D* texture)
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture)
{
Node::setPosition(PointZero);
setAnchorPoint(PointZero);
@ -143,7 +143,7 @@ void MotionStreak::setPosition(const Point& position)
_positionR = position;
}
void MotionStreak::tintWithColor(ccColor3B colors)
void MotionStreak::tintWithColor(const ccColor3B& colors)
{
setColor(colors);

View File

@ -53,17 +53,17 @@ public:
virtual ~MotionStreak();
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
static MotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, const char* path);
static MotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
static MotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, Texture2D* texture);
static MotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
bool initWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path);
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
bool initWithFade(float fade, float minSeg, float stroke, ccColor3B color, Texture2D* texture);
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture);
/** color used for the tint */
void tintWithColor(ccColor3B colors);
void tintWithColor(const ccColor3B& colors);
/** Remove all living segments of the ribbon */
void reset();

View File

@ -128,7 +128,7 @@ public class Cocos2dxBitmap {
if ( shadow ) {
int shadowColor = 0xff7d7d7d;
int shadowColor = 0x54000000;
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor);
bitmapPaddingX = Math.abs(shadowDX);

View File

@ -365,10 +365,14 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
textOrigingY = startH - shadowStrokePaddingY;
}
CGRect rect = CGRectMake(textOriginX, textOrigingY, textWidth, textHeight);
CGContextBeginTransparencyLayerWithRect(context, rect, NULL);
// actually draw the text in the context
// XXX: ios7 casting
[str drawInRect:CGRectMake(textOriginX, textOrigingY, textWidth, textHeight) withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)align];
CGContextEndTransparencyLayer(context);
// pop the context
UIGraphicsPopContext();

View File

@ -182,6 +182,9 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated
_quad.tl.colors = tmpColor;
_quad.tr.colors = tmpColor;
// shader program
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
// update texture (calls updateBlendFunc)
setTexture(pTexture);
setTextureRect(rect, rotated, rect.size);
@ -547,17 +550,22 @@ void Sprite::draw(void)
CCAssert(!_batchNode, "If Sprite is being rendered by SpriteBatchNode, Sprite#draw SHOULD NOT be called");
CC_NODE_DRAW_SETUP();
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
if (_texture != NULL)
{
CC_NODE_DRAW_SETUP();
ccGLBindTexture2D( _texture->getName() );
ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex );
}
else
{
// If the texture is invalid, uses the PositionColor shader instead.
// TODO: PostionTextureColor shader should support empty texture. In that way, we could get rid of next three lines.
GLProgram* prog = ShaderCache::sharedShaderCache()->programForKey(kShader_PositionColor);
prog->use();
prog->setUniformsForBuiltins();
ccGLBindTexture2D(0);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_Color );
}
@ -1081,16 +1089,6 @@ void Sprite::setTexture(Texture2D *texture)
CCAssert(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode");
// accept texture==nil as argument
CCAssert( !texture || dynamic_cast<Texture2D*>(texture), "setTexture expects a Texture2D. Invalid argument");
// shader program
if (texture)
{
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
}
else
{
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionColor));
}
if (!_batchNode && _texture != texture)
{

View File

@ -226,7 +226,11 @@ void TMXLayer::parseInternalProperties()
GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kUniformAlphaTestValue);
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
// use shader program to set uniform
getShaderProgram()->use();
getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue);
CHECK_GL_ERROR_DEBUG();
}
else
{

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="sdk/alipay_msp.jar"/>
<classpathentry exported="true" kind="lib" path="sdk/UCGameSDK.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>libPluginUC</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.plugin"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
</manifest>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifestConfig xmlns:android="http://schemas.android.com/apk/res/android">
<applicationCfg keyword="cn.uc.gamesdk.view.SdkWebActivity">
<activity
android:name="cn.uc.gamesdk.view.SdkWebActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Translucent"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="cn.uc.gamesdk.sdkweb" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</applicationCfg>
<permissionCfg>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
</permissionCfg>
</manifestConfig>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="libPluginUC" default="plugin-publish">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${plugin.dir}/tools/android/build_common.xml" />
</project>

View File

@ -0,0 +1,16 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-17
android.library=true
android.library.reference.1=../../../protocols/proj.android

View File

View File

@ -0,0 +1 @@
ba5cc5fb902013d53136f6b198055643d5d8a045

Binary file not shown.

View File

@ -0,0 +1,232 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
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.
****************************************************************************/
package org.cocos2dx.plugin;
import java.util.Hashtable;
import cn.uc.gamesdk.UCCallbackListener;
import cn.uc.gamesdk.UCGameSDK;
import cn.uc.gamesdk.UCGameSDKStatusCode;
import cn.uc.gamesdk.UCLogLevel;
import cn.uc.gamesdk.UCOrientation;
import cn.uc.gamesdk.info.GameParamInfo;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.util.Log;
public class UserUC implements InterfaceUser {
private static Context mContext = null;
protected static String TAG = "UserUC";
private static InterfaceUser mAdapter = null;
private boolean mLogined = false;
protected static void LogE(String msg, Exception e) {
Log.e(TAG, msg, e);
e.printStackTrace();
}
private static boolean isDebug = false;
private boolean isInited = false;
protected static void LogD(String msg) {
if (isDebug) {
Log.d(TAG, msg);
}
}
public UserUC(Context context) {
mContext = context;
mAdapter = this;
}
@Override
public void configDeveloperInfo(Hashtable<String, String> cpInfo) {
final Hashtable<String, String> curInfo = cpInfo;
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
String strCpId = curInfo.get("UCCpId");
String strGameId = curInfo.get("UCGameId");
String strServerId = curInfo.get("UCServerId");
int cpId = Integer.parseInt(strCpId);
int gameId = Integer.parseInt(strGameId);
int serverId = Integer.parseInt(strServerId);
GameParamInfo gpi = new GameParamInfo();
gpi.setCpId(cpId);
gpi.setGameId(gameId);
gpi.setServerId(serverId);
UCGameSDK.defaultSDK().setLogoutNotifyListener(new UCCallbackListener<String>() {
@Override
public void callback(int statuscode, String data) {
switch (statuscode) {
case UCGameSDKStatusCode.SUCCESS:
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGOUT_SUCCEED, "User Logout!");
mLogined = false;
break;
default:
break;
}
}
});
if (isLandscape()) {
UCGameSDK.defaultSDK().setOrientation(UCOrientation.LANDSCAPE);
}
UCGameSDK.defaultSDK().initSDK(mContext, UCLogLevel.ERROR, isDebug, gpi, new UCCallbackListener<String>() {
@Override
public void callback(int code, String msg) {
System.out.println("msg:" + msg);
switch (code) {
case UCGameSDKStatusCode.SUCCESS:
isInited = true;
break;
case UCGameSDKStatusCode.INIT_FAIL:
default:
isInited = false;
break;
}
}
});
} catch(Exception e) {
isInited = false;
LogE("Init SDK failed", e);
}
}
});
}
private static boolean waitHandle = true;
@Override
public void login() {
if (! isInited) {
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGIN_FAILED, "SDK init failed");
return;
}
if (isLogined()) {
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGIN_SUCCEED, "Already logined!");
return;
}
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
waitHandle = true;
UCGameSDK.defaultSDK().login(mContext, new UCCallbackListener<String>() {
@Override
public void callback(int code, String msg) {
LogD("login ret : " + code + " , msg : " + msg);
if (! waitHandle) {
return;
}
switch(code) {
case UCGameSDKStatusCode.SUCCESS:
mLogined = true;
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGIN_SUCCEED, msg);
break;
default:
mLogined = false;
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGIN_FAILED, msg);
break;
}
waitHandle = false;
}
});
} catch (Exception e) {
mLogined = false;
LogE("Login failed", e);
UserWrapper.onActionResult(mAdapter, UserWrapper.ACTION_RET_LOGIN_FAILED, "Login Failed!");
}
}
});
}
@Override
public void logout() {
if (! isLogined()) {
LogD("User not logined!");
return;
}
PluginWrapper.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
UCGameSDK.defaultSDK().logout();
} catch (Exception e) {
LogE("User logout failed", e);
}
}
});
}
@Override
public boolean isLogined() {
return mLogined;
}
@Override
public String getSessionID() {
LogD("getSessionID() invoked!");
return UCGameSDK.defaultSDK().getSid();
}
@Override
public void setDebugMode(boolean debug) {
isDebug = debug;
}
@Override
public String getPluginVersion() {
return "0.2.0";
}
@Override
public String getSDKVersion() {
return "2.3.4";
}
private static boolean isLandscape()
{
Configuration config = mContext.getResources().getConfiguration();
int orientation = config.orientation;
if (orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ||
orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
{
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
}
return (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}

View File

@ -34,6 +34,7 @@ MyUserManager::MyUserManager()
: _retListener(NULL)
, _qh360(NULL)
, _nd91(NULL)
, _uc(NULL)
{
}
@ -101,6 +102,27 @@ void MyUserManager::loadPlugin()
_nd91->setActionListener(_retListener);
}
}
#if TEST_UC
{
_uc = dynamic_cast<ProtocolUser*>(PluginManager::getInstance()->loadPlugin("UserUC"));
if (NULL != _uc)
{
TUserDeveloperInfo pUCInfo;
pUCInfo["UCCpId"] = "20087";
pUCInfo["UCGameId"] = "119474";
pUCInfo["UCServerId"] = "1333";
if (pUCInfo.empty()) {
char msg[256] = { 0 };
sprintf(msg, "Developer info is empty. PLZ fill your UC info in %s(nearby line %d)", __FILE__, __LINE__);
MessageBox(msg, "UC Warning");
}
_uc->setDebugMode(true);
_uc->configDeveloperInfo(pUCInfo);
_uc->setActionListener(_retListener);
}
}
#endif
}
void MyUserManager::unloadPlugin()
@ -116,6 +138,12 @@ void MyUserManager::unloadPlugin()
PluginManager::getInstance()->unloadPlugin("UserNd91");
_nd91 = NULL;
}
if (_uc)
{
PluginManager::getInstance()->unloadPlugin("UserUC");
_uc = NULL;
}
}
void MyUserManager::loginByMode(MyUserMode mode)
@ -129,6 +157,11 @@ void MyUserManager::loginByMode(MyUserMode mode)
case kND91:
pUser = _nd91;
break;
#if TEST_UC
case kUC:
pUser = _uc;
break;
#endif
default:
break;
}
@ -149,6 +182,11 @@ void MyUserManager::logoutByMode(MyUserMode mode)
case kND91:
pUser = _nd91;
break;
#if TEST_UC
case kUC:
pUser = _uc;
break;
#endif
default:
break;
}

View File

@ -26,6 +26,13 @@ THE SOFTWARE.
#include "ProtocolUser.h"
/** @warning
* The file UCGameSDK.jar conflicts with weiboSDK.jar
* if you want test the login/logout of UC,
* modify the android project config: remove the weiboSDK.jar, and add UCGameSDK.jar
*/
#define TEST_UC 0
class MyUserActionResult : public cocos2d::plugin::UserActionListener
{
public:
@ -42,6 +49,9 @@ public:
kNoneMode = 0,
kQH360,
kND91,
#if TEST_UC
kUC,
#endif
} MyUserMode;
void unloadPlugin();
@ -57,6 +67,7 @@ private:
cocos2d::plugin::ProtocolUser* _qh360;
cocos2d::plugin::ProtocolUser* _nd91;
cocos2d::plugin::ProtocolUser* _uc;
MyUserActionResult* _retListener;
};

View File

@ -7,6 +7,9 @@ USING_NS_CC;
const std::string s_aTestCases[] = {
"QH360",
"ND91",
#if TEST_UC
"UC",
#endif
};
Scene* TestUser::scene()

View File

@ -24,5 +24,6 @@
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/weibo/android/weibosdk.jar"/>
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/qh360/android/360SDK.jar"/>
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/qh360/android/libPluginQH360.jar"/>
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/uc/android/libPluginUC.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -36,6 +36,16 @@
<meta-data android:name="QHOPENSDK_APPKEY" android:value="Your app_key" />
<meta-data android:name="QHOPENSDK_PRIVATEKEY" android:value="Your app_private_key" />
<meta-data android:name="QHOPENSDK_CHANNEL" android:value="Your channel or delete this line" />
<activity
android:name="cn.uc.gamesdk.view.SdkWebActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Translucent"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="cn.uc.gamesdk.sdkweb" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" />

View File

@ -3,7 +3,7 @@ export ALL_PLUGINS=("flurry" "umeng" \
"alipay" "nd91" \
"admob" \
"twitter" "weibo" \
"qh360")
"qh360" "uc")
# define the plugin root directory & publish target directory
export TARGET_DIR_NAME="publish"

View File

@ -172,6 +172,13 @@ void DrawPrimitivesTest::draw()
CHECK_GL_ERROR_DEBUG();
// draw a pink solid circle with 50 segments
glLineWidth(2);
ccDrawColor4B(255, 0, 255, 255);
ccDrawSolidCircle( VisibleRect::center() + ccp(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 1.0f, 1.0f);
CHECK_GL_ERROR_DEBUG();
// open yellow poly
ccDrawColor4B(255, 255, 0, 255);
glLineWidth(10);

@ -1 +1 @@
Subproject commit 38374930ae707c70611ad1fcb3a5af91d50d72d0
Subproject commit e4b1b15b70075dee1f20afff4741eb0be88b0a8b

View File

@ -10,6 +10,7 @@
15A3D5631682F20C002FB0C5 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4621682F14C002FB0C5 /* main.js */; };
15A3D5651682F20C002FB0C5 /* tests_resources-jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */; };
15A3D5681682F20C002FB0C5 /* tests-main.js in Resources */ = {isa = PBXBuildFile; fileRef = 15A3D4741682F14C002FB0C5 /* tests-main.js */; };
1A42C7A81782CEA100F738F6 /* MotionStreakTest in Resources */ = {isa = PBXBuildFile; fileRef = 1A42C7A71782CEA100F738F6 /* MotionStreakTest */; };
1A4C3F1317784B6000EDFB3B /* libchipmunk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F0E17784B6000EDFB3B /* libchipmunk.a */; };
1A4C3F1417784B6000EDFB3B /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F0F17784B6000EDFB3B /* libcocos2dx.a */; };
1A4C3F1517784B6000EDFB3B /* libCocosDenshion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A4C3F1017784B6000EDFB3B /* libCocosDenshion.a */; };
@ -117,6 +118,7 @@
15A3D4621682F14C002FB0C5 /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ../../Shared/tests/main.js; sourceTree = "<group>"; };
15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "tests_resources-jsb.js"; path = "../../Shared/tests/tests_resources-jsb.js"; sourceTree = "<group>"; };
15A3D4741682F14C002FB0C5 /* tests-main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "tests-main.js"; path = "../../Shared/tests/tests-main.js"; sourceTree = "<group>"; };
1A42C7A71782CEA100F738F6 /* MotionStreakTest */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MotionStreakTest; path = ../../Shared/tests/MotionStreakTest; sourceTree = "<group>"; };
1A4C3F0E17784B6000EDFB3B /* libchipmunk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libchipmunk.a; sourceTree = BUILT_PRODUCTS_DIR; };
1A4C3F0F17784B6000EDFB3B /* libcocos2dx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libcocos2dx.a; sourceTree = BUILT_PRODUCTS_DIR; };
1A4C3F1017784B6000EDFB3B /* libCocosDenshion.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libCocosDenshion.a; sourceTree = BUILT_PRODUCTS_DIR; };
@ -333,14 +335,13 @@
D401B5FC16FB169100F2529D /* js_src_raw */ = {
isa = PBXGroup;
children = (
A22656EE1743DCBB00598A2C /* ClippingNodeTest */,
A218F7DB1743D97E00F65883 /* XHRTest */,
1AA51A7816F708FA000FDF05 /* ActionManagerTest */,
1AA51A7916F708FA000FDF05 /* ActionsTest */,
1AA51A7A16F708FA000FDF05 /* BaseTestLayer */,
1AA51A7B16F708FA000FDF05 /* Box2dTest */,
1AA51A7C16F708FA000FDF05 /* ChipmunkTest */,
1AA51A7D16F708FA000FDF05 /* ClickAndMoveTest */,
A22656EE1743DCBB00598A2C /* ClippingNodeTest */,
1AA51A7E16F708FA000FDF05 /* CocosDenshionTest */,
1AA51A7F16F708FA000FDF05 /* CocosNodeTest */,
1AA51A8016F708FA000FDF05 /* CurrentLanguageTest */,
@ -355,7 +356,9 @@
1AA51A8816F708FA000FDF05 /* IntervalTest */,
1AA51A8916F708FA000FDF05 /* LabelTest */,
1AA51A8A16F708FA000FDF05 /* LayerTest */,
15A3D4621682F14C002FB0C5 /* main.js */,
1AA51A8B16F708FA000FDF05 /* MenuTest */,
1A42C7A71782CEA100F738F6 /* MotionStreakTest */,
1AA51A8C16F708FA000FDF05 /* OpenGLTest */,
1AA51A8D16F708FA000FDF05 /* ParallaxTest */,
1AA51A8E16F708FA000FDF05 /* ParticleTest */,
@ -368,16 +371,16 @@
1AA51A9616F708FA000FDF05 /* SchedulerTest */,
1AA51A9716F708FA000FDF05 /* SpriteTest */,
1AA51A9816F708FA000FDF05 /* SysTest */,
D401B6DE16FC071100F2529D /* tests-boot-jsb.js */,
15A3D4741682F14C002FB0C5 /* tests-main.js */,
15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */,
1AA51A9916F708FA000FDF05 /* TextInputTest */,
1AA51A9A16F708FA000FDF05 /* TextureCacheTest */,
1AA51A9B16F708FA000FDF05 /* TileMapTest */,
1AA51A9C16F708FA000FDF05 /* TouchesTest */,
1AA51A9D16F708FA000FDF05 /* TransitionsTest */,
1AA51A9E16F708FA000FDF05 /* UnitTest */,
15A3D4621682F14C002FB0C5 /* main.js */,
D401B6DE16FC071100F2529D /* tests-boot-jsb.js */,
15A3D4741682F14C002FB0C5 /* tests-main.js */,
15A3D4711682F14C002FB0C5 /* tests_resources-jsb.js */,
A218F7DB1743D97E00F65883 /* XHRTest */,
);
name = js_src_raw;
sourceTree = "<group>";
@ -549,6 +552,7 @@
1A80332C1728F1FB00240CC3 /* res in Resources */,
A218F7DC1743D97E00F65883 /* XHRTest in Resources */,
A22656EF1743DCBB00598A2C /* ClippingNodeTest in Resources */,
1A42C7A81782CEA100F738F6 /* MotionStreakTest in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -1 +1 @@
b30514e90b5ed9a70853c63f20e9204052679459
2fe7237c56cf52c3ca577e33fc39aa5c9e2469ba

View File

@ -101,9 +101,9 @@ public:
const jsval& getJSCallbackThis() const;
const jsval& getJSExtraData() const;
protected:
jsval jsCallback;
jsval jsThisObj;
jsval extraData;
jsval _jsCallback;
jsval _jsThisObj;
jsval _extraData;
};
@ -112,13 +112,13 @@ public:
JSCCBAnimationWrapper() {}
virtual ~JSCCBAnimationWrapper() {}
void animationCompleteCallback() const {
void animationCompleteCallback() {
JSContext *cx = ScriptingCore::getInstance()->getGlobalContext();
jsval retval = JSVAL_NULL;
if(!JSVAL_IS_VOID(jsCallback) && !JSVAL_IS_VOID(jsThisObj)) {
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(jsThisObj), jsCallback, 0, NULL, &retval);
if(!JSVAL_IS_VOID(_jsCallback) && !JSVAL_IS_VOID(_jsThisObj)) {
JS_CallFunctionValue(cx, JSVAL_TO_OBJECT(_jsThisObj), _jsCallback, 0, NULL, &retval);
}
}
@ -135,7 +135,7 @@ public:
static void setTargetForNativeNode(Node *pNode, JSCallFuncWrapper *target);
static Array * getTargetForNativeNode(Node *pNode);
void callbackFunc(Node *node) const;
void callbackFunc(Node *node);
};
@ -162,7 +162,7 @@ public:
void pause();
void scheduleFunc(float dt) const;
void scheduleFunc(float dt);
virtual void update(float dt);
Object* getTarget();

@ -1 +1 @@
Subproject commit 1aef083d3959574072f234cd31c5a53ac52b58a9
Subproject commit 5df9199315b9e9972da23e478808a2e9152e9980

@ -1 +1 @@
Subproject commit 6a45a0770c4e6075f20d5049c88e3cb5f8aa83eb
Subproject commit b09d920cdb2523ba7ee1a5ee4419fe11f1bc5e7b

View File

@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos2dx/include/cocos2d.h %(cocosdir)s/CocosDenshion/inc
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode
classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Data SimpleAudioEngine Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
@ -35,17 +35,17 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.*
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = Node::[convertToWindowSpace ^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .*UserData getGLServerState .*schedule],
Sprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
SpriteBatchNode::[getBlendFunc setBlendFunc],
MotionStreak::[getBlendFunc setBlendFunc],
MotionStreak::[getBlendFunc setBlendFunc draw update],
AtlasNode::[getBlendFunc setBlendFunc],
ParticleBatchNode::[getBlendFunc setBlendFunc],
LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo],
Layer.*::[didAccelerate (g|s)etBlendFunc],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased unregisterScriptKeypadHandler],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
MenuItem.*::[create setCallback initWithCallback],
Copying::[*],