This commit is contained in:
lihex 2014-03-04 16:54:15 +08:00
Родитель a5e0c08583 76961b799a
Коммит c3d7d1f1bc
12 изменённых файлов: 215 добавлений и 61 удалений

Просмотреть файл

@ -26,7 +26,7 @@
NS_CC_BEGIN NS_CC_BEGIN
EventAcceleration::EventAcceleration(Acceleration acc) EventAcceleration::EventAcceleration(const Acceleration& acc)
: Event(Type::ACCELERATION) : Event(Type::ACCELERATION)
, _acc(acc) , _acc(acc)
{ {

Просмотреть файл

@ -33,8 +33,7 @@ NS_CC_BEGIN
class EventAcceleration : public Event class EventAcceleration : public Event
{ {
public: public:
EventAcceleration(const Acceleration& acc);
EventAcceleration(Acceleration acc);
private: private:
Acceleration _acc; Acceleration _acc;

Просмотреть файл

@ -1017,6 +1017,10 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener
if (listeners == nullptr) if (listeners == nullptr)
return; return;
auto sceneGraphListeners = listeners->getSceneGraphPriorityListeners();
if (sceneGraphListeners == nullptr)
return;
Node* rootNode = (Node*)Director::getInstance()->getRunningScene(); Node* rootNode = (Node*)Director::getInstance()->getRunningScene();
// Reset priority index // Reset priority index
@ -1026,7 +1030,7 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener
visitTarget(rootNode, true); visitTarget(rootNode, true);
// After sort: priority < 0, > 0 // After sort: priority < 0, > 0
auto sceneGraphListeners = listeners->getSceneGraphPriorityListeners();
std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) { std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) {
return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()]; return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()];
}); });
@ -1047,8 +1051,11 @@ void EventDispatcher::sortEventListenersOfFixedPriority(const EventListener::Lis
if (listeners == nullptr) if (listeners == nullptr)
return; return;
// After sort: priority < 0, > 0
auto fixedListeners = listeners->getFixedPriorityListeners(); auto fixedListeners = listeners->getFixedPriorityListeners();
if (fixedListeners == nullptr)
return;
// After sort: priority < 0, > 0
std::sort(fixedListeners->begin(), fixedListeners->end(), [](const EventListener* l1, const EventListener* l2) { std::sort(fixedListeners->begin(), fixedListeners->end(), [](const EventListener* l1, const EventListener* l2) {
return l1->getFixedPriority() < l2->getFixedPriority(); return l1->getFixedPriority() < l2->getFixedPriority();
}); });

Просмотреть файл

@ -99,28 +99,28 @@ Layer *Layer::create()
} }
} }
int Layer::executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch) int Layer::executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch, Event* event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
TouchScriptData data(eventType, this, touch); TouchScriptData data(eventType, this, touch, event);
ScriptEvent event(kTouchEvent, &data); ScriptEvent scriptEvent(kTouchEvent, &data);
return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
} }
#endif #endif
//can not reach it //can not reach it
return 0; return 0;
} }
int Layer::executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches) int Layer::executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, Event* event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
TouchesScriptData data(eventType, this, touches); TouchesScriptData data(eventType, this, touches, event);
ScriptEvent event(kTouchesEvent, &data); ScriptEvent scriptEvent(kTouchesEvent, &data);
return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); return ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&scriptEvent);
} }
#endif #endif
return 0; return 0;
@ -325,105 +325,105 @@ void Layer::setKeypadEnabled(bool enabled)
} }
/// Callbacks /// Callbacks
bool Layer::onTouchBegan(Touch *touch, Event *unused_event) bool Layer::onTouchBegan(Touch *touch, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
return executeScriptTouchHandler(EventTouch::EventCode::BEGAN, touch) == 0 ? false : true; return executeScriptTouchHandler(EventTouch::EventCode::BEGAN, touch, event) == 0 ? false : true;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
CCASSERT(false, "Layer#ccTouchBegan override me"); CCASSERT(false, "Layer#ccTouchBegan override me");
return true; return true;
} }
void Layer::onTouchMoved(Touch *touch, Event *unused_event) void Layer::onTouchMoved(Touch *touch, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchHandler(EventTouch::EventCode::MOVED, touch); executeScriptTouchHandler(EventTouch::EventCode::MOVED, touch, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchEnded(Touch *touch, Event *unused_event) void Layer::onTouchEnded(Touch *touch, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchHandler(EventTouch::EventCode::ENDED, touch); executeScriptTouchHandler(EventTouch::EventCode::ENDED, touch, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchCancelled(Touch *touch, Event *unused_event) void Layer::onTouchCancelled(Touch *touch, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchHandler(EventTouch::EventCode::CANCELLED, touch); executeScriptTouchHandler(EventTouch::EventCode::CANCELLED, touch, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event *unused_event) void Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchesHandler(EventTouch::EventCode::BEGAN, touches); executeScriptTouchesHandler(EventTouch::EventCode::BEGAN, touches, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchesMoved(const std::vector<Touch*>& touches, Event *unused_event) void Layer::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchesHandler(EventTouch::EventCode::MOVED, touches); executeScriptTouchesHandler(EventTouch::EventCode::MOVED, touches, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchesEnded(const std::vector<Touch*>& touches, Event *unused_event) void Layer::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchesHandler(EventTouch::EventCode::ENDED, touches); executeScriptTouchesHandler(EventTouch::EventCode::ENDED, touches, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
void Layer::onTouchesCancelled(const std::vector<Touch*>& touches, Event *unused_event) void Layer::onTouchesCancelled(const std::vector<Touch*>& touches, Event *event)
{ {
#if CC_ENABLE_SCRIPT_BINDING #if CC_ENABLE_SCRIPT_BINDING
if (kScriptTypeNone != _scriptType) if (kScriptTypeLua == _scriptType)
{ {
executeScriptTouchesHandler(EventTouch::EventCode::CANCELLED, touches); executeScriptTouchesHandler(EventTouch::EventCode::CANCELLED, touches, event);
return; return;
} }
#endif #endif
CC_UNUSED_PARAM(unused_event); CC_UNUSED_PARAM(event);
} }
std::string Layer::getDescription() const std::string Layer::getDescription() const

Просмотреть файл

@ -171,8 +171,8 @@ protected:
void _addTouchListener(); void _addTouchListener();
CC_DEPRECATED_ATTRIBUTE void addTouchListener() { _addTouchListener();}; CC_DEPRECATED_ATTRIBUTE void addTouchListener() { _addTouchListener();};
CC_DEPRECATED_ATTRIBUTE int executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch); CC_DEPRECATED_ATTRIBUTE int executeScriptTouchHandler(EventTouch::EventCode eventType, Touch* touch, Event* event);
CC_DEPRECATED_ATTRIBUTE int executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches); CC_DEPRECATED_ATTRIBUTE int executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches, Event* event);
bool _touchEnabled; bool _touchEnabled;
bool _accelerometerEnabled; bool _accelerometerEnabled;

Просмотреть файл

@ -258,16 +258,18 @@ struct TouchesScriptData
EventTouch::EventCode actionType; EventTouch::EventCode actionType;
void* nativeObject; void* nativeObject;
const std::vector<Touch*>& touches; const std::vector<Touch*>& touches;
Event* event;
// Constructor // Constructor
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
TouchesScriptData(EventTouch::EventCode inActionType, void* inNativeObject, const std::vector<Touch*>& inTouches) TouchesScriptData(EventTouch::EventCode inActionType, void* inNativeObject, const std::vector<Touch*>& inTouches, Event* evt)
: actionType(inActionType), : actionType(inActionType),
nativeObject(inNativeObject), nativeObject(inNativeObject),
touches(inTouches) touches(inTouches),
event(evt)
{ {
} }
}; };
@ -277,16 +279,18 @@ struct TouchScriptData
EventTouch::EventCode actionType; EventTouch::EventCode actionType;
void* nativeObject; void* nativeObject;
Touch* touch; Touch* touch;
Event* event;
// Constructor // Constructor
/** /**
* @js NA * @js NA
* @lua NA * @lua NA
*/ */
TouchScriptData(EventTouch::EventCode inActionType, void* inNativeObject, Touch* inTouch) TouchScriptData(EventTouch::EventCode inActionType, void* inNativeObject, Touch* inTouch, Event* evt)
: actionType(inActionType), : actionType(inActionType),
nativeObject(inNativeObject), nativeObject(inNativeObject),
touch(inTouch) touch(inTouch),
event(evt)
{ {
} }
}; };

Просмотреть файл

@ -580,6 +580,11 @@ void Layout::setBackGroundImageScale9Enabled(bool able)
setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType); setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType);
setBackGroundImageCapInsets(_backGroundImageCapInsets); setBackGroundImageCapInsets(_backGroundImageCapInsets);
} }
bool Layout::isBackGroundImageScale9Enabled()
{
return _backGroundScale9Enabled;
}
void Layout::setBackGroundImage(const char* fileName,TextureResType texType) void Layout::setBackGroundImage(const char* fileName,TextureResType texType)
{ {

Просмотреть файл

@ -41,9 +41,14 @@
- [Bind the classes with namespace to lua](#bind-the-classes-with-namespace-to-lua) - [Bind the classes with namespace to lua](#bind-the-classes-with-namespace-to-lua)
- [Use ScriptHandlerMgr to manage the register and unregister of Lua function](#use-scripthandlermgr-to-manage-the-register-and-unregister-of-lua-function) - [Use ScriptHandlerMgr to manage the register and unregister of Lua function](#use-scripthandlermgr-to-manage-the-register-and-unregister-of-lua-function)
- [Misc API changes](#misc-api-changes-1) - [Misc API changes](#misc-api-changes-1)
- [Use cc、ccs、ccui and sp as module name](#use-ccccsccui-and-sp-as-module-name) - [Use cc、ccs、ccui、gl and sp as module name](#use-ccccsccuigl-and-sp-as-module-name)
- [Modified functions](#modified-functions) - [Modified functions](#modified-functions)
- [Add some modules](#add-some-modules) - [Add some modules](#add-some-modules)
- [Add more lua bindings](#add-more-lua-bindings)
- [Replace some lua-bindings of Class or Struct with lua table](#replace-the-lua-bindings-of-class-or-struct-with-lua-table)
- [Other Changes](#other-changes)
- [Support lua script codes call Obeject-C codes and Java codes](#support-lua-script-codes-call-OC-codes-and-Java-codes)
- [Add some lua files to store the constants of different modules](#add-some-lua-files-to-store-the-constants-of-different-modules)
# Misc Information # Misc Information
@ -607,7 +612,7 @@ ScriptHandlerMgr:getInstance():registerScriptHandler(menuItem, luafunction,cc.HA
## Misc API changes ## Misc API changes
### Use `cc`、`ccs`、`ccui` and `sp` as module name ### Use `cc`、`ccs`、`ccui` `gl` and `sp` as module name
Now classes are binded into different modules instead of using global module. This will avoid conflicts with other codes. Now classes are binded into different modules instead of using global module. This will avoid conflicts with other codes.
@ -616,6 +621,7 @@ Now classes are binded into different modules instead of using global module. Th
* classes in `spine` were bound to `sp` module * classes in `spine` were bound to `sp` module
* classes in `cocostudio` were bound to `ccs` module * classes in `cocostudio` were bound to `ccs` module
* global variables are binded to corresponding modules * global variables are binded to corresponding modules
* all funcionts and constants about `openGl` were bound to `gl` module
Examples: Examples:
@ -628,12 +634,14 @@ Examples:
Some global function names are renamed: Some global function names are renamed:
Examples:
| v2.1 | v3.0 | | v2.1 | v3.0 |
| CCPoint/ccp | cc.p | | CCPoint/ccp | cc.p |
| CCRect | cc.rect | | CCRect | cc.rect |
| CCColor3B | cc.c3b | | CCColor3B | cc.c3b |
| CCColor4B | cc.c4b | | CCColor4B | cc.c4b |
| TODO: add others | CCColor4F | cc.c4f |
### Add some modules ### Add some modules
@ -642,9 +650,45 @@ In the version 3.0, more modules were bound to lua, specific as follows:
* physics * physics
* spine * spine
* XMLHttpRequest * XMLHttpRequest
* OpenGL
The `XMLHttpRequest` and `physics` are in the `cc` module, and the `spine` is in the `sp` module. Related test cases located in: The `XMLHttpRequest` and `physics` are in the `cc` module, the `spine` is in the `sp` module, and the `OpenGl` is in the `gl` module. Related test cases located in:
* physics ---> TestLua/PhysicsTest * physics ---> TestLua/PhysicsTest
* spine ---> TestLua/SpineTest * spine ---> TestLua/SpineTest
* XMLHttpRequest ---> TestLua/XMLHttpRequestTest * XMLHttpRequest ---> TestLua/XMLHttpRequestTest
* openGL ---> TestLua/OpenGLTest
### Add more lua bindings
Such as: New Label、New EventDispatcher and AssetsManager,etc.Related test cases located in:
* New Lable ---> TestLua/LabelTestNew
* New EventDispatcher --->TestLua/NewEventDispatcherTest
* AssetsManager ---> TestLua/AssetsManagerTest
### Replace some lua-bindings of Class or Struct with lua table
In the version 3.0, all the lua-binding of Struct type were replaced with the lua table
Examples:
| v2.1 | v3.0 |
| CCPoint | lua table |
| CCRect | lua table |
| CCColor3B | lua table |
| CCColor4B | lua table |
| CCColor4F | lua table |
| CCAffineTransform | lua table |
| CCArray | lua table |
| CCDictionary | lua table |
| CCPointArray | lua table |
### Support lua script codes call Object-C codes and Java codes
`LuaObjcBridge` and `LuaJavaBridge` bound to lua surpported lua script codes calls Object-C codes and java codes.
### Add some lua files to store the constants of different modules
* Cocos2DConstants.lua store the constants of `cc` moudle
* StudioConstants.lua store the constants of `ccs` moudle
* GuiConstants.lua store the constants of `ccui` moudle
* OpenglConstants.lua store the constants of `gl` moudle

Просмотреть файл

@ -29,7 +29,7 @@ import sys
from optparse import OptionParser from optparse import OptionParser
COCOS_CONSOLE_ROOT = 'COCOS_CONSOLE_ROOT' COCOS_CONSOLE_ROOT = 'COCOS_CONSOLE_ROOT'
NDK_ROOT = 'NDK_ROOT1' NDK_ROOT = 'NDK_ROOT'
class SetEnvVar: class SetEnvVar:

2
plugin

@ -1 +1 @@
Subproject commit a914bd4ca3416e0a91f88a0ad906559a5140a5bb Subproject commit 3c325c4198e0e65764602a60c807d7e07e26f066

@ -1 +1 @@
Subproject commit 22610d69034bc7d858bdd2cc759c2cd9237c70eb Subproject commit 2ee95f1cc0a874d690659409923b2f017a1336cc

Просмотреть файл

@ -0,0 +1,95 @@
#Github pull reqest builder for Jenkins
import json
import re
import os
import requests
import sys
import traceback
import urllib2
def main():
#get payload from os env
payload_str = os.environ['payload']
#parse to json obj
payload = json.loads(payload_str)
comment = payload['comment']
#get comment body
comment_body = comment['body']
print comment_body
pattern = re.compile("\[ci(\s+)rebuild\]", re.I)
result = pattern.search(comment_body)
if result is None:
print 'skip build for pull request #' + str(pr_num)
return(0)
issue = payload['issue']
#get pull number
pr_num = issue['number']
print 'pr_num:' + str(pr_num)
payload_forword = {"number":pr_num}
#build for pull request action 'open' and 'synchronize', skip 'close'
action = issue['state']
print 'action: ' + action
payload_forword['action'] = action
pr = issue['pull_request']
url = pr['html_url']
print "url:" + url
payload_forword['html_url'] = url
#get pull request info
req = 'https://api.github.com/repos/cocos2d/cocos2d-x/pulls/' + str(pr_num)
pr_payload = ''
try:
pr_payload = urllib2.urlopen(req).read()
except:
traceback.print_exc()
repository = json.loads(pr_payload)
#get statuses url
statuses_url = repository['statuses_url']
payload_forword['statuses_url'] = statuses_url
print 'statuses_url: ' + statuses_url
#get pr target branch
branch = repository['base']['ref']
payload_forword['branch'] = branch
print 'branch: ' + branch
#set commit status to pending
target_url = os.environ['JOB_PULL_REQUEST_BUILD_URL']
if(action == 'closed'):
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
return(0)
data = {"state":"pending", "target_url":target_url}
access_token = os.environ['GITHUB_ACCESS_TOKEN']
Headers = {"Authorization":"token " + access_token}
try:
requests.post(statuses_url, data=json.dumps(data), headers=Headers)
except:
traceback.print_exc()
job_trigger_url = os.environ['JOB_TRIGGER_URL']
#send trigger and payload
post_data = {'payload':""}
post_data['payload']= json.dumps(payload_forword)
requests.post(job_trigger_url, data=post_data)
return(0)
# -------------- main --------------
if __name__ == '__main__':
sys_ret = 0
try:
sys_ret = main()
except:
traceback.print_exc()
sys_ret = 1
finally:
sys.exit(sys_ret)