mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into newRenderer
This commit is contained in:
commit
3b66d09bf5
|
@ -1 +1 @@
|
|||
14242f6af76d7373ffd38e971257fb430f9e7e49
|
||||
e4898923edd8b218b9dc8b238b747331ad601585
|
|
@ -153,7 +153,7 @@ Vector<Node*> ActionManager::pauseAllRunningActions()
|
|||
}
|
||||
}
|
||||
|
||||
return std::move(idsWithActions);
|
||||
return idsWithActions;
|
||||
}
|
||||
|
||||
void ActionManager::resumeTargets(const Vector<Node*>& targetsToResume)
|
||||
|
|
|
@ -804,7 +804,7 @@ Vector<Object*> Scheduler::pauseAllTargetsWithMinPriority(int minPriority)
|
|||
}
|
||||
}
|
||||
|
||||
return std::move(idsWithSelectors);
|
||||
return idsWithSelectors;
|
||||
}
|
||||
|
||||
void Scheduler::resumeTargets(const Vector<Object*>& targetsToResume)
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
parser.setDelegator(this);
|
||||
|
||||
parser.parse(pFileName);
|
||||
return std::move(_rootDict);
|
||||
return _rootDict;
|
||||
}
|
||||
|
||||
ValueVector arrayWithContentsOfFile(const char* pFileName)
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
parser.setDelegator(this);
|
||||
|
||||
parser.parse(pFileName);
|
||||
return std::move(_rootArray);
|
||||
return _rootArray;
|
||||
}
|
||||
|
||||
void startElement(void *ctx, const char *name, const char **atts)
|
||||
|
@ -307,14 +307,14 @@ ValueMap FileUtils::getValueMapFromFile(const std::string& filename)
|
|||
{
|
||||
std::string fullPath = fullPathForFilename(filename.c_str());
|
||||
DictMaker tMaker;
|
||||
return std::move(tMaker.dictionaryWithContentsOfFile(fullPath.c_str()));
|
||||
return tMaker.dictionaryWithContentsOfFile(fullPath.c_str());
|
||||
}
|
||||
|
||||
ValueVector FileUtils::getValueVectorFromFile(const std::string& filename)
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(filename.c_str());
|
||||
DictMaker tMaker;
|
||||
return std::move(tMaker.arrayWithContentsOfFile(fullPath.c_str()));
|
||||
return tMaker.arrayWithContentsOfFile(fullPath.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ public:
|
|||
Map<K, V>(const Map<K, V>& other)
|
||||
{
|
||||
CCLOGINFO("In the copy constructor of Map!");
|
||||
_data = other;
|
||||
_data = other._data;
|
||||
addRefForAllObjects();
|
||||
}
|
||||
|
||||
Map<K, V>(Map<K, V>&& other)
|
||||
{
|
||||
CCLOGINFO("In the move constructor of Map!");
|
||||
_data = other;
|
||||
_data = std::move(other._data);
|
||||
}
|
||||
|
||||
~Map<K, V>()
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
keys.push_back(iter->first);
|
||||
}
|
||||
}
|
||||
return std::move(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
std::vector<K> keys(V object) const
|
||||
|
@ -120,7 +120,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
return std::move(keys);
|
||||
return keys;
|
||||
}
|
||||
|
||||
V at(const K& key) const
|
||||
|
|
|
@ -36,6 +36,15 @@ Value::Value()
|
|||
|
||||
}
|
||||
|
||||
Value::Value(unsigned char v)
|
||||
: _vectorData(nullptr)
|
||||
, _mapData(nullptr)
|
||||
, _intKeyMapData(nullptr)
|
||||
, _type(Type::BYTE)
|
||||
{
|
||||
_baseData.byteVal = v;
|
||||
}
|
||||
|
||||
Value::Value(int v)
|
||||
: _vectorData(nullptr)
|
||||
, _mapData(nullptr)
|
||||
|
@ -162,14 +171,15 @@ Value::Value(Value&& other)
|
|||
|
||||
Value::~Value()
|
||||
{
|
||||
CC_SAFE_DELETE(_vectorData);
|
||||
CC_SAFE_DELETE(_mapData);
|
||||
CC_SAFE_DELETE(_intKeyMapData);
|
||||
clear();
|
||||
}
|
||||
|
||||
Value& Value::operator= (const Value& other)
|
||||
{
|
||||
switch (other._type) {
|
||||
case Type::BYTE:
|
||||
_baseData.byteVal = other._baseData.byteVal;
|
||||
break;
|
||||
case Type::INTEGER:
|
||||
_baseData.intVal = other._baseData.intVal;
|
||||
break;
|
||||
|
@ -210,6 +220,9 @@ Value& Value::operator= (const Value& other)
|
|||
Value& Value::operator= (Value&& other)
|
||||
{
|
||||
switch (other._type) {
|
||||
case Type::BYTE:
|
||||
_baseData.byteVal = other._baseData.byteVal;
|
||||
break;
|
||||
case Type::INTEGER:
|
||||
_baseData.intVal = other._baseData.intVal;
|
||||
break;
|
||||
|
@ -250,6 +263,154 @@ Value& Value::operator= (Value&& other)
|
|||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (unsigned char v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::BYTE;
|
||||
_baseData.byteVal = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (int v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::INTEGER;
|
||||
_baseData.intVal = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (float v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::FLOAT;
|
||||
_baseData.floatVal = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (double v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::DOUBLE;
|
||||
_baseData.doubleVal = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (bool v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::BOOLEAN;
|
||||
_baseData.boolVal = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (const char* v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::STRING;
|
||||
_strData = v ? v : "";
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (const std::string& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::STRING;
|
||||
_strData = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (const ValueVector& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::VECTOR;
|
||||
_vectorData = new ValueVector();
|
||||
*_vectorData = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (ValueVector&& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::VECTOR;
|
||||
_vectorData = new ValueVector();
|
||||
*_vectorData = std::move(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (const ValueMap& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::MAP;
|
||||
_mapData = new ValueMap();
|
||||
*_mapData = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (ValueMap&& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::MAP;
|
||||
_mapData = new ValueMap();
|
||||
*_mapData = std::move(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (const IntValueMap& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::INT_KEY_MAP;
|
||||
_intKeyMapData = new IntValueMap();
|
||||
*_intKeyMapData = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value& Value::operator= (IntValueMap&& v)
|
||||
{
|
||||
clear();
|
||||
_type = Type::INT_KEY_MAP;
|
||||
_intKeyMapData = new IntValueMap();
|
||||
*_intKeyMapData = std::move(v);
|
||||
return *this;
|
||||
}
|
||||
|
||||
///
|
||||
unsigned char Value::asByte() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP, "");
|
||||
|
||||
if (_type == Type::BYTE)
|
||||
{
|
||||
return _baseData.byteVal;
|
||||
}
|
||||
|
||||
if (_type == Type::INTEGER)
|
||||
{
|
||||
return static_cast<unsigned char>(_baseData.intVal);
|
||||
}
|
||||
|
||||
if (_type == Type::STRING)
|
||||
{
|
||||
return static_cast<unsigned char>(atoi(_strData.c_str()));
|
||||
}
|
||||
|
||||
if (_type == Type::FLOAT)
|
||||
{
|
||||
return static_cast<unsigned char>(_baseData.floatVal);
|
||||
}
|
||||
|
||||
if (_type == Type::DOUBLE)
|
||||
{
|
||||
return static_cast<unsigned char>(_baseData.doubleVal);
|
||||
}
|
||||
|
||||
if (_type == Type::BOOLEAN)
|
||||
{
|
||||
return _baseData.boolVal ? 1 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Value::asInt() const
|
||||
{
|
||||
CCASSERT(_type != Type::VECTOR && _type != Type::MAP, "");
|
||||
|
@ -258,6 +419,11 @@ int Value::asInt() const
|
|||
return _baseData.intVal;
|
||||
}
|
||||
|
||||
if (_type == Type::BYTE)
|
||||
{
|
||||
return _baseData.byteVal;
|
||||
}
|
||||
|
||||
if (_type == Type::STRING)
|
||||
{
|
||||
return atoi(_strData.c_str());
|
||||
|
@ -265,17 +431,17 @@ int Value::asInt() const
|
|||
|
||||
if (_type == Type::FLOAT)
|
||||
{
|
||||
return _baseData.floatVal;
|
||||
return static_cast<int>(_baseData.floatVal);
|
||||
}
|
||||
|
||||
if (_type == Type::DOUBLE)
|
||||
{
|
||||
return _baseData.doubleVal;
|
||||
return static_cast<int>(_baseData.doubleVal);
|
||||
}
|
||||
|
||||
if (_type == Type::BOOLEAN)
|
||||
{
|
||||
return _baseData.boolVal;
|
||||
return _baseData.boolVal ? 1 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -289,6 +455,11 @@ float Value::asFloat() const
|
|||
return _baseData.floatVal;
|
||||
}
|
||||
|
||||
if (_type == Type::BYTE)
|
||||
{
|
||||
return static_cast<float>(_baseData.byteVal);
|
||||
}
|
||||
|
||||
if (_type == Type::STRING)
|
||||
{
|
||||
return atof(_strData.c_str());
|
||||
|
@ -296,17 +467,17 @@ float Value::asFloat() const
|
|||
|
||||
if (_type == Type::INTEGER)
|
||||
{
|
||||
return _baseData.intVal;
|
||||
return static_cast<float>(_baseData.intVal);
|
||||
}
|
||||
|
||||
if (_type == Type::DOUBLE)
|
||||
{
|
||||
return _baseData.doubleVal;
|
||||
return static_cast<float>(_baseData.doubleVal);
|
||||
}
|
||||
|
||||
if (_type == Type::BOOLEAN)
|
||||
{
|
||||
return _baseData.boolVal;
|
||||
return _baseData.boolVal ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
|
@ -320,24 +491,29 @@ double Value::asDouble() const
|
|||
return _baseData.doubleVal;
|
||||
}
|
||||
|
||||
if (_type == Type::BYTE)
|
||||
{
|
||||
return static_cast<double>(_baseData.byteVal);
|
||||
}
|
||||
|
||||
if (_type == Type::STRING)
|
||||
{
|
||||
return (float)atof(_strData.c_str());
|
||||
return static_cast<double>(atof(_strData.c_str()));
|
||||
}
|
||||
|
||||
if (_type == Type::INTEGER)
|
||||
{
|
||||
return _baseData.intVal;
|
||||
return static_cast<double>(_baseData.intVal);
|
||||
}
|
||||
|
||||
if (_type == Type::FLOAT)
|
||||
{
|
||||
return _baseData.floatVal;
|
||||
return static_cast<double>(_baseData.floatVal);
|
||||
}
|
||||
|
||||
if (_type == Type::BOOLEAN)
|
||||
{
|
||||
return _baseData.boolVal;
|
||||
return _baseData.boolVal ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
|
@ -351,6 +527,11 @@ bool Value::asBool() const
|
|||
return _baseData.boolVal;
|
||||
}
|
||||
|
||||
if (_type == Type::BYTE)
|
||||
{
|
||||
return _baseData.byteVal == 0 ? false : true;
|
||||
}
|
||||
|
||||
if (_type == Type::STRING)
|
||||
{
|
||||
return (_strData == "0" || _strData == "false") ? false : true;
|
||||
|
@ -386,6 +567,9 @@ std::string Value::asString() const
|
|||
std::stringstream ret;
|
||||
|
||||
switch (_type) {
|
||||
case Type::BYTE:
|
||||
ret << _baseData.byteVal;
|
||||
break;
|
||||
case Type::INTEGER:
|
||||
ret << _baseData.intVal;
|
||||
break;
|
||||
|
@ -404,4 +588,14 @@ std::string Value::asString() const
|
|||
return ret.str();
|
||||
}
|
||||
|
||||
void Value::clear()
|
||||
{
|
||||
_type = Type::NONE;
|
||||
_baseData.doubleVal = 0.0;
|
||||
_strData.clear();
|
||||
CC_SAFE_DELETE(_vectorData);
|
||||
CC_SAFE_DELETE(_mapData);
|
||||
CC_SAFE_DELETE(_intKeyMapData);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -43,6 +43,7 @@ class Value
|
|||
{
|
||||
public:
|
||||
Value();
|
||||
explicit Value(unsigned char v);
|
||||
explicit Value(int v);
|
||||
explicit Value(float v);
|
||||
explicit Value(double v);
|
||||
|
@ -63,9 +64,28 @@ public:
|
|||
Value(Value&& other);
|
||||
~Value();
|
||||
|
||||
// assignment operator
|
||||
Value& operator= (const Value& other);
|
||||
Value& operator= (Value&& other);
|
||||
|
||||
Value& operator= (unsigned char v);
|
||||
Value& operator= (int v);
|
||||
Value& operator= (float v);
|
||||
Value& operator= (double v);
|
||||
Value& operator= (bool v);
|
||||
Value& operator= (const char* v);
|
||||
Value& operator= (const std::string& v);
|
||||
|
||||
Value& operator= (const ValueVector& v);
|
||||
Value& operator= (ValueVector&& v);
|
||||
|
||||
Value& operator= (const ValueMap& v);
|
||||
Value& operator= (ValueMap&& v);
|
||||
|
||||
Value& operator= (const IntValueMap& v);
|
||||
Value& operator= (IntValueMap&& v);
|
||||
|
||||
unsigned char asByte() const;
|
||||
int asInt() const;
|
||||
float asFloat() const;
|
||||
double asDouble() const;
|
||||
|
@ -86,6 +106,7 @@ public:
|
|||
enum class Type
|
||||
{
|
||||
NONE,
|
||||
BYTE,
|
||||
INTEGER,
|
||||
FLOAT,
|
||||
DOUBLE,
|
||||
|
@ -98,9 +119,13 @@ public:
|
|||
|
||||
inline Type getType() const { return _type; };
|
||||
|
||||
protected:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
unsigned char byteVal;
|
||||
int intVal;
|
||||
float floatVal;
|
||||
double doubleVal;
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
Vector<T>(Vector<T>&& other)
|
||||
{
|
||||
CCLOGINFO("In the move constructor of Vector!");
|
||||
_data = other._data;
|
||||
_data = std::move(other._data);
|
||||
}
|
||||
|
||||
Vector<T>& operator=(const Vector<T>& other)
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
Vector<T>& operator=(Vector<T>&& other)
|
||||
{
|
||||
CCLOGINFO("In the move assignment operator!");
|
||||
_data = other._data;
|
||||
_data = std::move(other._data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ CCBKeyframe.cpp \
|
|||
CCBReader.cpp \
|
||||
CCBSequence.cpp \
|
||||
CCBSequenceProperty.cpp \
|
||||
CCBValue.cpp \
|
||||
CCControlButtonLoader.cpp \
|
||||
CCControlLoader.cpp \
|
||||
CCLabelBMFontLoader.cpp \
|
||||
|
|
|
@ -21,48 +21,18 @@ CCBAnimationManager::CCBAnimationManager()
|
|||
: _jsControlled(false)
|
||||
, _owner(NULL)
|
||||
, _sequences(NULL)
|
||||
, _nodeSequences(NULL)
|
||||
, _baseValues(NULL)
|
||||
, _autoPlaySequenceId(0)
|
||||
, _rootNode(NULL)
|
||||
, _rootContainerSize(Size::ZERO)
|
||||
, _delegate(NULL)
|
||||
, _runningSequence(NULL)
|
||||
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
bool CCBAnimationManager::init()
|
||||
{
|
||||
_sequences = new Array();
|
||||
_sequences->init();
|
||||
_nodeSequences = new Dictionary();
|
||||
_nodeSequences->init();
|
||||
_baseValues = new Dictionary();
|
||||
_baseValues->init();
|
||||
|
||||
_documentOutletNames = new Array();
|
||||
_documentOutletNames->init();
|
||||
|
||||
_documentOutletNodes = new Array();
|
||||
_documentOutletNodes->init();
|
||||
|
||||
_documentCallbackNames = new Array();
|
||||
_documentCallbackNames->init();
|
||||
|
||||
_documentCallbackNodes = new Array();
|
||||
_documentCallbackNodes->init();
|
||||
|
||||
_documentCallbackControlEvents = new Array();
|
||||
_documentCallbackControlEvents->init();
|
||||
|
||||
_keyframeCallbacks = new Array();
|
||||
_keyframeCallbacks->init();
|
||||
|
||||
_keyframeCallFuncs = new Dictionary();
|
||||
_keyframeCallFuncs->init();
|
||||
|
||||
_target = NULL;
|
||||
_animationCompleteCallbackFunc = NULL;
|
||||
|
||||
|
@ -83,30 +53,31 @@ CCBAnimationManager::~CCBAnimationManager()
|
|||
// Node *node = (Node*)pElement->getIntKey();
|
||||
// node->release();
|
||||
// }
|
||||
if (_rootNode)
|
||||
{
|
||||
_rootNode->stopAllActions();
|
||||
}
|
||||
|
||||
_nodeSequences->release();
|
||||
_baseValues->release();
|
||||
_sequences->release();
|
||||
setRootNode(NULL);
|
||||
setDelegate(NULL);
|
||||
|
||||
CC_SAFE_RELEASE(_documentOutletNames);
|
||||
CC_SAFE_RELEASE(_documentOutletNodes);
|
||||
CC_SAFE_RELEASE(_documentCallbackNames);
|
||||
CC_SAFE_RELEASE(_documentCallbackNodes);
|
||||
CC_SAFE_RELEASE(_documentCallbackControlEvents);
|
||||
|
||||
CC_SAFE_RELEASE(_keyframeCallFuncs);
|
||||
CC_SAFE_RELEASE(_keyframeCallbacks);
|
||||
for (auto iter = _objects.begin(); iter != _objects.end(); ++iter)
|
||||
{
|
||||
for (auto iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2)
|
||||
{
|
||||
iter2->second->release();
|
||||
}
|
||||
}
|
||||
|
||||
CC_SAFE_RELEASE(_target);
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getSequences()
|
||||
Vector<CCBSequence*>& CCBAnimationManager::getSequences()
|
||||
{
|
||||
return _sequences;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setSequences(Array* seq)
|
||||
void CCBAnimationManager::setSequences(const Vector<CCBSequence*>& seq)
|
||||
{
|
||||
_sequences = seq;
|
||||
}
|
||||
|
@ -131,63 +102,74 @@ void CCBAnimationManager::setRootNode(Node *pRootNode)
|
|||
_rootNode = pRootNode;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setDocumentControllerName(const std::string &name) {
|
||||
void CCBAnimationManager::setDocumentControllerName(const std::string &name)
|
||||
{
|
||||
_documentControllerName = name;
|
||||
}
|
||||
|
||||
|
||||
std::string CCBAnimationManager::getDocumentControllerName() {
|
||||
std::string CCBAnimationManager::getDocumentControllerName()
|
||||
{
|
||||
return _documentControllerName;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentCallbackNode(Node *node) {
|
||||
_documentCallbackNodes->addObject(node);
|
||||
void CCBAnimationManager::addDocumentCallbackNode(Node *node)
|
||||
{
|
||||
_documentCallbackNodes.pushBack(node);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentCallbackName(std::string name) {
|
||||
String *tmpName = String::create(name);
|
||||
_documentCallbackNames->addObject(tmpName);
|
||||
void CCBAnimationManager::addDocumentCallbackName(std::string name)
|
||||
{
|
||||
_documentCallbackNames.push_back(Value(name));
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentCallbackControlEvents(Control::EventType eventType)
|
||||
{
|
||||
_documentCallbackControlEvents->addObject(Integer::create((int)eventType));
|
||||
_documentCallbackControlEvents.push_back(Value(static_cast<int>(eventType)));
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentCallbackNames() {
|
||||
ValueVector& CCBAnimationManager::getDocumentCallbackNames()
|
||||
{
|
||||
return _documentCallbackNames;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentCallbackNodes() {
|
||||
Vector<Node*>& CCBAnimationManager::getDocumentCallbackNodes()
|
||||
{
|
||||
return _documentCallbackNodes;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentCallbackControlEvents()
|
||||
ValueVector& CCBAnimationManager::getDocumentCallbackControlEvents()
|
||||
{
|
||||
return _documentCallbackControlEvents;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentOutletNode(Node *node) {
|
||||
_documentOutletNodes->addObject(node);
|
||||
void CCBAnimationManager::addDocumentOutletNode(Node *node)
|
||||
{
|
||||
_documentOutletNodes.pushBack(node);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::addDocumentOutletName(std::string name) {
|
||||
_documentOutletNames->addObject(String::create(name));
|
||||
void CCBAnimationManager::addDocumentOutletName(std::string name)
|
||||
{
|
||||
_documentOutletNames.push_back(Value(name));
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentOutletNames() {
|
||||
ValueVector& CCBAnimationManager::getDocumentOutletNames()
|
||||
{
|
||||
return _documentOutletNames;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getDocumentOutletNodes() {
|
||||
Vector<Node*>& CCBAnimationManager::getDocumentOutletNodes()
|
||||
{
|
||||
return _documentOutletNodes;
|
||||
}
|
||||
|
||||
std::string CCBAnimationManager::getLastCompletedSequenceName() {
|
||||
std::string CCBAnimationManager::getLastCompletedSequenceName()
|
||||
{
|
||||
return _lastCompletedSequenceName;
|
||||
}
|
||||
|
||||
Array* CCBAnimationManager::getKeyframeCallbacks() {
|
||||
ValueVector& CCBAnimationManager::getKeyframeCallbacks()
|
||||
{
|
||||
return _keyframeCallbacks;
|
||||
}
|
||||
|
||||
|
@ -235,40 +217,51 @@ const Size& CCBAnimationManager::getContainerSize(Node *pNode)
|
|||
}
|
||||
|
||||
// refer to CCBReader::readNodeGraph() for data structure of pSeq
|
||||
void CCBAnimationManager::addNode(Node *pNode, Dictionary *pSeq)
|
||||
void CCBAnimationManager::addNode(Node *pNode, const std::unordered_map<int, Map<std::string, CCBSequenceProperty*>>& seq)
|
||||
{
|
||||
// pNode->retain();
|
||||
|
||||
_nodeSequences->setObject(pSeq, (intptr_t)pNode);
|
||||
_nodeSequences[pNode] = seq;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setBaseValue(Object *pValue, Node *pNode, const char *propName)
|
||||
void CCBAnimationManager::setBaseValue(const Value& value, Node *pNode, const std::string& propName)
|
||||
{
|
||||
Dictionary *props = (Dictionary*)_baseValues->objectForKey((intptr_t)pNode);
|
||||
if (! props)
|
||||
{
|
||||
props = Dictionary::create();
|
||||
_baseValues->setObject(props, (intptr_t)pNode);
|
||||
// pNode->retain();
|
||||
}
|
||||
|
||||
props->setObject(pValue, propName);
|
||||
auto& props = _baseValues[pNode];
|
||||
props[propName] = value;
|
||||
}
|
||||
|
||||
Object* CCBAnimationManager::getBaseValue(Node *pNode, const char* propName)
|
||||
const Value& CCBAnimationManager::getBaseValue(Node *pNode, const std::string& propName)
|
||||
{
|
||||
Dictionary *props = (Dictionary*)_baseValues->objectForKey((intptr_t)pNode);
|
||||
auto& props = _baseValues[pNode];
|
||||
return props[propName];
|
||||
}
|
||||
|
||||
return props->objectForKey(propName);
|
||||
void CCBAnimationManager::setObject(Object* obj, Node *pNode, const std::string& propName)
|
||||
{
|
||||
auto& props = _objects[pNode];
|
||||
auto iter = props.find(propName);
|
||||
if (iter != props.end())
|
||||
iter->second->release();
|
||||
|
||||
props[propName] = obj;
|
||||
obj->retain();
|
||||
}
|
||||
|
||||
Object* CCBAnimationManager::getObject(Node *pNode, const std::string& propName)
|
||||
{
|
||||
auto& props = _objects[pNode];
|
||||
auto iter = props.find(propName);
|
||||
if (iter != props.end())
|
||||
return iter->second;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CCBAnimationManager::getSequenceId(const char* pSequenceName)
|
||||
{
|
||||
Object *pElement = NULL;
|
||||
string seqName(pSequenceName);
|
||||
CCARRAY_FOREACH(_sequences, pElement)
|
||||
for (auto& seq : _sequences)
|
||||
{
|
||||
CCBSequence *seq = static_cast<CCBSequence*>(pElement);
|
||||
if (seqName.compare(seq->getName()) == 0)
|
||||
{
|
||||
return seq->getSequenceId();
|
||||
|
@ -279,10 +272,8 @@ int CCBAnimationManager::getSequenceId(const char* pSequenceName)
|
|||
|
||||
CCBSequence* CCBAnimationManager::getSequence(int nSequenceId)
|
||||
{
|
||||
Object *pElement = NULL;
|
||||
CCARRAY_FOREACH(_sequences, pElement)
|
||||
for (auto& seq : _sequences)
|
||||
{
|
||||
CCBSequence *seq = static_cast<CCBSequence*>(pElement);
|
||||
if (seq->getSequenceId() == nSequenceId)
|
||||
{
|
||||
return seq;
|
||||
|
@ -300,23 +291,32 @@ float CCBAnimationManager::getSequenceDuration(const char *pSequenceName)
|
|||
}
|
||||
|
||||
|
||||
void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) {
|
||||
|
||||
void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode)
|
||||
{
|
||||
// Move base values
|
||||
Object* baseValue = _baseValues->objectForKey((intptr_t)fromNode);
|
||||
if(baseValue) {
|
||||
_baseValues->setObject(baseValue, (intptr_t)toNode);
|
||||
_baseValues->removeObjectForKey((intptr_t)fromNode);
|
||||
|
||||
auto baseValueIter = _baseValues.find(fromNode);
|
||||
if(baseValueIter != _baseValues.end())
|
||||
{
|
||||
_baseValues.erase(baseValueIter);
|
||||
_baseValues[toNode] = baseValueIter->second;
|
||||
// fromNode->release();
|
||||
// toNode->retain();
|
||||
}
|
||||
|
||||
auto objIter = _objects.find(fromNode);
|
||||
if (objIter != _objects.end())
|
||||
{
|
||||
_objects.erase(objIter);
|
||||
_objects[toNode] = objIter->second;
|
||||
}
|
||||
|
||||
|
||||
// Move seqs
|
||||
Object *seqs = _nodeSequences->objectForKey((intptr_t)fromNode);
|
||||
if(seqs) {
|
||||
_nodeSequences->setObject(seqs, (intptr_t)toNode);
|
||||
_nodeSequences->removeObjectForKey((intptr_t)fromNode);
|
||||
auto seqsIter = _nodeSequences.find(fromNode);
|
||||
if (seqsIter != _nodeSequences.end())
|
||||
{
|
||||
_nodeSequences.erase(seqsIter);
|
||||
_nodeSequences[toNode] = seqsIter->second;
|
||||
|
||||
// fromNode->release();
|
||||
// toNode->retain();
|
||||
|
@ -324,41 +324,37 @@ void CCBAnimationManager::moveAnimationsFromNode(Node* fromNode, Node* toNode) {
|
|||
}
|
||||
|
||||
// Refer to CCBReader::readKeyframe() for the real type of value
|
||||
ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *propName, Node *pNode)
|
||||
ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, Node *pNode)
|
||||
{
|
||||
float duration = pKeyframe1->getTime() - (pKeyframe0 ? pKeyframe0->getTime() : 0);
|
||||
|
||||
if (strcmp(propName, "rotationX") == 0)
|
||||
if (propName == "rotationX")
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateXTo::create(duration, value->getFloatValue());
|
||||
return CCBRotateXTo::create(duration, pKeyframe1->getValue().asFloat());
|
||||
}
|
||||
else if(strcmp(propName, "rotationY") == 0)
|
||||
else if (propName == "rotationY")
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateYTo::create(duration, value->getFloatValue());
|
||||
return CCBRotateYTo::create(duration, pKeyframe1->getValue().asFloat());
|
||||
}
|
||||
else if (strcmp(propName, "rotation") == 0)
|
||||
else if (propName == "rotation")
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return CCBRotateTo::create(duration, value->getFloatValue());
|
||||
return CCBRotateTo::create(duration, pKeyframe1->getValue().asFloat());
|
||||
}
|
||||
else if (strcmp(propName, "opacity") == 0)
|
||||
else if (propName == "opacity")
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
return FadeTo::create(duration, value->getByteValue());
|
||||
return FadeTo::create(duration, pKeyframe1->getValue().asByte());
|
||||
}
|
||||
else if (strcmp(propName, "color") == 0)
|
||||
else if (propName == "color")
|
||||
{
|
||||
Color3BWapper* color = (Color3BWapper*)pKeyframe1->getValue();
|
||||
Color3B c = color->getColor();
|
||||
|
||||
return TintTo::create(duration, c.r, c.g, c.b);
|
||||
auto c = pKeyframe1->getValue().asValueMap();
|
||||
unsigned char r = c["r"].asByte();
|
||||
unsigned char g = c["g"].asByte();
|
||||
unsigned char b = c["b"].asByte();
|
||||
return TintTo::create(duration, r, g, b);
|
||||
}
|
||||
else if (strcmp(propName, "visible") == 0)
|
||||
else if (propName == "visible")
|
||||
{
|
||||
CCBValue *value = (CCBValue*)pKeyframe1->getValue();
|
||||
if (value->getBoolValue())
|
||||
if (pKeyframe1->getValue().asBool())
|
||||
{
|
||||
return Sequence::createWithTwoActions(DelayTime::create(duration), Show::create());
|
||||
}
|
||||
|
@ -367,21 +363,21 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
return Sequence::createWithTwoActions(DelayTime::create(duration), Hide::create());
|
||||
}
|
||||
}
|
||||
else if (strcmp(propName, "displayFrame") == 0)
|
||||
else if (propName == "displayFrame")
|
||||
{
|
||||
return Sequence::createWithTwoActions(DelayTime::create(duration),
|
||||
CCBSetSpriteFrame::create((SpriteFrame *)pKeyframe1->getValue()));
|
||||
CCBSetSpriteFrame::create(static_cast<SpriteFrame*>(pKeyframe1->getObject())));
|
||||
}
|
||||
else if (strcmp(propName, "position") == 0)
|
||||
else if (propName == "position")
|
||||
{
|
||||
// Get position type
|
||||
Array *array = static_cast<Array*>(getBaseValue(pNode, propName));
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue();
|
||||
auto& array = getBaseValue(pNode, propName).asValueVector();
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt();
|
||||
|
||||
// Get relative position
|
||||
Array *value = static_cast<Array*>(pKeyframe1->getValue());
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto value = pKeyframe1->getValue().asValueVector();
|
||||
float x = value[0].asFloat();
|
||||
float y = value[1].asFloat();
|
||||
|
||||
Size containerSize = getContainerSize(pNode->getParent());
|
||||
|
||||
|
@ -389,16 +385,16 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
|
||||
return MoveTo::create(duration, absPos);
|
||||
}
|
||||
else if (strcmp(propName, "scale") == 0)
|
||||
else if (propName == "scale")
|
||||
{
|
||||
// Get position type
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue();
|
||||
auto& array = getBaseValue(pNode, propName).asValueVector();
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt();
|
||||
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pKeyframe1->getValue();
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto value = pKeyframe1->getValue().asValueVector();
|
||||
float x = value[0].asFloat();
|
||||
float y = value[1].asFloat();
|
||||
|
||||
if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION)
|
||||
{
|
||||
|
@ -409,31 +405,33 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
|||
|
||||
return ScaleTo::create(duration, x, y);
|
||||
}
|
||||
else if(strcmp(propName, "skew") == 0)
|
||||
else if (propName == "skew")
|
||||
{
|
||||
// Get relative skew
|
||||
Array *value = (Array*)pKeyframe1->getValue();
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto& value = pKeyframe1->getValue().asValueVector();
|
||||
float x = value[0].asFloat();
|
||||
float y = value[1].asFloat();
|
||||
|
||||
return SkewTo::create(duration, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("CCBReader: Failed to create animation for property: %s", propName);
|
||||
log("CCBReader: Failed to create animation for property: %s", propName.c_str());
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode, Object *pValue, float fTweenDuration)
|
||||
void CCBAnimationManager::setAnimatedProperty(const std::string& propName, Node *pNode, const Value& value, Object* obj, float fTweenDuration)
|
||||
{
|
||||
if (fTweenDuration > 0)
|
||||
{
|
||||
// Create a fake keyframe to generate the action from
|
||||
CCBKeyframe *kf1 = new CCBKeyframe();
|
||||
kf1->autorelease();
|
||||
kf1->setValue(pValue);
|
||||
|
||||
kf1->setObject(obj);
|
||||
kf1->setValue(value);
|
||||
kf1->setTime(fTweenDuration);
|
||||
kf1->setEasingType(CCBKeyframe::EasingType::LINEAR);
|
||||
|
||||
|
@ -445,38 +443,37 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode,
|
|||
{
|
||||
// Just set the value
|
||||
|
||||
if (strcmp(propName, "position") == 0)
|
||||
if (propName == "position")
|
||||
{
|
||||
// Get position type
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue();
|
||||
|
||||
auto& array = getBaseValue(pNode, propName).asValueVector();
|
||||
CCBReader::PositionType type = (CCBReader::PositionType)array[2].asInt();
|
||||
// Get relative position
|
||||
Array *value = (Array*)pValue;
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto& valueVector = value.asValueVector();
|
||||
float x = valueVector[0].asFloat();
|
||||
float y = valueVector[1].asFloat();
|
||||
|
||||
pNode->setPosition(getAbsolutePosition(Point(x,y), type, getContainerSize(pNode->getParent()), propName));
|
||||
}
|
||||
else if (strcmp(propName, "scale") == 0)
|
||||
else if (propName == "scale")
|
||||
{
|
||||
// Get scale type
|
||||
Array *array = (Array*)getBaseValue(pNode, propName);
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)((CCBValue*)array->getObjectAtIndex(2))->getIntValue();
|
||||
auto& array = getBaseValue(pNode, propName).asValueVector();
|
||||
CCBReader::ScaleType type = (CCBReader::ScaleType)array[2].asInt();
|
||||
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pValue;
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto& valueVector = value.asValueVector();
|
||||
float x = valueVector[0].asFloat();
|
||||
float y = valueVector[1].asFloat();
|
||||
|
||||
setRelativeScale(pNode, x, y, type, propName);
|
||||
}
|
||||
else if(strcmp(propName, "skew") == 0)
|
||||
else if(propName == "skew")
|
||||
{
|
||||
// Get relative scale
|
||||
Array *value = (Array*)pValue;
|
||||
float x = ((CCBValue*)value->getObjectAtIndex(0))->getFloatValue();
|
||||
float y = ((CCBValue*)value->getObjectAtIndex(1))->getFloatValue();
|
||||
auto& valueVector = value.asValueVector();
|
||||
float x = valueVector[0].asFloat();
|
||||
float y = valueVector[1].asFloat();
|
||||
|
||||
pNode->setSkewX(x);
|
||||
pNode->setSkewY(y);
|
||||
|
@ -486,41 +483,44 @@ void CCBAnimationManager::setAnimatedProperty(const char *propName, Node *pNode,
|
|||
// [node setValue:value forKey:name];
|
||||
|
||||
// TODO only handle rotation, opacity, displayFrame, color
|
||||
if (strcmp(propName, "rotation") == 0)
|
||||
if (propName == "rotation")
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
float rotate = value.asFloat();
|
||||
pNode->setRotation(rotate);
|
||||
} else if(strcmp(propName, "rotationX") == 0)
|
||||
} else if(propName == "rotationX")
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
float rotate = value.asFloat();
|
||||
pNode->setRotationX(rotate);
|
||||
}else if(strcmp(propName, "rotationY") == 0)
|
||||
}else if(propName == "rotationY")
|
||||
{
|
||||
float rotate = ((CCBValue*)pValue)->getFloatValue();
|
||||
float rotate = value.asFloat();
|
||||
pNode->setRotationY(rotate);
|
||||
}
|
||||
else if (strcmp(propName, "opacity") == 0)
|
||||
else if (propName == "opacity")
|
||||
{
|
||||
int opacity = ((CCBValue*)pValue)->getByteValue();
|
||||
unsigned char opacity = value.asByte();
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setOpacity(opacity);
|
||||
}
|
||||
else if (strcmp(propName, "displayFrame") == 0)
|
||||
else if (propName == "displayFrame")
|
||||
{
|
||||
((Sprite*)pNode)->setDisplayFrame((SpriteFrame*)pValue);
|
||||
static_cast<Sprite*>(pNode)->setDisplayFrame(static_cast<SpriteFrame*>(obj));
|
||||
}
|
||||
else if (strcmp(propName, "color") == 0)
|
||||
else if (propName == "color")
|
||||
{
|
||||
Color3BWapper *color = (Color3BWapper*)pValue;
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(color->getColor());
|
||||
auto c = value.asValueMap();
|
||||
unsigned char r = c["r"].asByte();
|
||||
unsigned char g = c["g"].asByte();
|
||||
unsigned char b = c["b"].asByte();
|
||||
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(Color3B(r, g, b));
|
||||
}
|
||||
else if (strcmp(propName, "visible") == 0)
|
||||
else if (propName == "visible")
|
||||
{
|
||||
bool visible = ((CCBValue*)pValue)->getBoolValue();
|
||||
bool visible = value.asBool();
|
||||
pNode->setVisible(visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("unsupported property name is %s", propName);
|
||||
log("unsupported property name is %s", propName.c_str());
|
||||
CCASSERT(false, "unsupported property now");
|
||||
}
|
||||
}
|
||||
|
@ -534,15 +534,16 @@ void CCBAnimationManager::setFirstFrame(Node *pNode, CCBSequenceProperty *pSeqPr
|
|||
if (keyframes.empty())
|
||||
{
|
||||
// Use base value (no animation)
|
||||
Object *baseValue = getBaseValue(pNode, pSeqProp->getName());
|
||||
CCASSERT(baseValue, "No baseValue found for property");
|
||||
setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, fTweenDuration);
|
||||
auto& baseValue = getBaseValue(pNode, pSeqProp->getName());
|
||||
auto obj = getObject(pNode, pSeqProp->getName());
|
||||
CCASSERT(!baseValue.isNull(), "No baseValue found for property");
|
||||
setAnimatedProperty(pSeqProp->getName(), pNode, baseValue, obj, fTweenDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use first keyframe
|
||||
CCBKeyframe *keyframe = keyframes.at(0);
|
||||
setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), fTweenDuration);
|
||||
setAnimatedProperty(pSeqProp->getName(), pNode, keyframe->getValue(), keyframe->getObject(), fTweenDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,18 +635,22 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
|
|||
actions.pushBack(DelayTime::create(timeSinceLastKeyframe));
|
||||
}
|
||||
|
||||
Array* keyVal = static_cast<Array *>(keyframe->getValue());
|
||||
std::string selectorName = static_cast<String *>(keyVal->getObjectAtIndex(0))->getCString();
|
||||
CCBReader::TargetType selectorTarget = (CCBReader::TargetType)atoi(static_cast<String *>(keyVal->getObjectAtIndex(1))->getCString());
|
||||
auto& keyVal = keyframe->getValue().asValueVector();
|
||||
std::string selectorName = keyVal[0].asString();
|
||||
CCBReader::TargetType selectorTarget = (CCBReader::TargetType)keyVal[1].asInt();
|
||||
|
||||
if(_jsControlled) {
|
||||
String* callbackName = String::createWithFormat("%d:%s", selectorTarget, selectorName.c_str());
|
||||
Object* callback = _keyframeCallFuncs->objectForKey(callbackName->getCString());
|
||||
std::stringstream callbackName;
|
||||
callbackName << static_cast<int>(selectorTarget);
|
||||
callbackName << ":" + selectorName;
|
||||
|
||||
auto callback = _keyframeCallFuncs.at(callbackName.str());
|
||||
if (nullptr != callback)
|
||||
{
|
||||
CallFunc *callbackClone = (static_cast<CallFunc*>(callback))->clone();
|
||||
CallFunc* callbackClone = callback->clone();
|
||||
|
||||
if(callbackClone != NULL) {
|
||||
if (callbackClone != NULL)
|
||||
{
|
||||
actions.pushBack(callbackClone);
|
||||
}
|
||||
}
|
||||
|
@ -678,8 +683,14 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
|
|||
}
|
||||
else
|
||||
{
|
||||
// XXX: how to fix this warning?
|
||||
CallFuncN *callback = CallFuncN::create(target, selCallFunc);
|
||||
auto savedTarget = std::make_shared<Vector<Object*>>();
|
||||
savedTarget->pushBack(target);
|
||||
|
||||
auto callback = CallFuncN::create([savedTarget, selCallFunc](Node* sender){
|
||||
auto t = savedTarget->at(0);
|
||||
(t->*selCallFunc)(sender);
|
||||
});
|
||||
|
||||
actions.pushBack(callback);
|
||||
}
|
||||
}
|
||||
|
@ -713,19 +724,19 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel)
|
|||
}
|
||||
|
||||
stringstream ss (stringstream::in | stringstream::out);
|
||||
Array* keyVal = (Array*)keyframe->getValue();
|
||||
std::string soundFile = ((String *)keyVal->getObjectAtIndex(0))->getCString();
|
||||
auto& keyVal = keyframe->getValue().asValueVector();
|
||||
std::string soundFile = keyVal[0].asString();
|
||||
|
||||
float pitch, pan, gain;
|
||||
ss << ((String *)keyVal->getObjectAtIndex(1))->getCString();
|
||||
ss << keyVal[1].asString();
|
||||
ss >> pitch;
|
||||
ss.flush();
|
||||
|
||||
ss << ((String *)keyVal->getObjectAtIndex(2))->getCString();
|
||||
ss << keyVal[2].asString();
|
||||
ss >> pan;
|
||||
ss.flush();
|
||||
|
||||
ss << ((String *)keyVal->getObjectAtIndex(3))->getCString();
|
||||
ss << keyVal[3].asString();
|
||||
ss >> gain;
|
||||
ss.flush();
|
||||
|
||||
|
@ -798,26 +809,24 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
|
||||
_rootNode->stopAllActions();
|
||||
|
||||
DictElement* pElement = NULL;
|
||||
CCDICT_FOREACH(_nodeSequences, pElement)
|
||||
for (auto nodeSeqIter = _nodeSequences.begin(); nodeSeqIter != _nodeSequences.end(); ++nodeSeqIter)
|
||||
{
|
||||
Node *node = reinterpret_cast<Node*>(pElement->getIntKey());
|
||||
Node *node = nodeSeqIter->first;
|
||||
node->stopAllActions();
|
||||
|
||||
// Refer to CCBReader::readKeyframe() for the real type of value
|
||||
Dictionary *seqs = (Dictionary*)pElement->getObject();
|
||||
Dictionary *seqNodeProps = (Dictionary*)seqs->objectForKey(nSeqId);
|
||||
auto seqs = nodeSeqIter->second;
|
||||
auto seqNodeProps = seqs[nSeqId];
|
||||
|
||||
set<string> seqNodePropNames;
|
||||
std::set<std::string> seqNodePropNames;
|
||||
|
||||
if (seqNodeProps)
|
||||
if (!seqNodeProps.empty())
|
||||
{
|
||||
// Reset nodes that have sequence node properties, and run actions on them
|
||||
DictElement* pElement1 = NULL;
|
||||
CCDICT_FOREACH(seqNodeProps, pElement1)
|
||||
for (auto iter = seqNodeProps.begin(); iter != seqNodeProps.end(); ++iter)
|
||||
{
|
||||
const char *propName = pElement1->getStrKey();
|
||||
CCBSequenceProperty *seqProp = static_cast<CCBSequenceProperty*>(seqNodeProps->objectForKey(propName));
|
||||
const std::string propName = iter->first;
|
||||
CCBSequenceProperty *seqProp = iter->second;
|
||||
seqNodePropNames.insert(propName);
|
||||
|
||||
setFirstFrame(node, seqProp, fTweenDuration);
|
||||
|
@ -826,20 +835,28 @@ void CCBAnimationManager::runAnimationsForSequenceIdTweenDuration(int nSeqId, fl
|
|||
}
|
||||
|
||||
// Reset the nodes that may have been changed by other timelines
|
||||
Dictionary *nodeBaseValues = (Dictionary*)_baseValues->objectForKey(pElement->getIntKey());
|
||||
if (nodeBaseValues)
|
||||
auto& nodeBaseValues = _baseValues[node];
|
||||
|
||||
if (!nodeBaseValues.empty())
|
||||
{
|
||||
DictElement* pElement2 = NULL;
|
||||
CCDICT_FOREACH(nodeBaseValues, pElement2)
|
||||
for (auto iter = nodeBaseValues.begin(); iter != nodeBaseValues.end(); ++iter)
|
||||
{
|
||||
if (seqNodePropNames.find(pElement2->getStrKey()) == seqNodePropNames.end())
|
||||
if (seqNodePropNames.find(iter->first) == seqNodePropNames.end())
|
||||
{
|
||||
Object *value = pElement2->getObject();
|
||||
|
||||
if (value)
|
||||
{
|
||||
setAnimatedProperty(pElement2->getStrKey(), node, value, fTweenDuration);
|
||||
}
|
||||
setAnimatedProperty(iter->first, node, iter->second, nullptr, fTweenDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto& nodeObject = _objects[node];
|
||||
|
||||
if (!nodeObject.empty())
|
||||
{
|
||||
for (auto iter = nodeObject.begin(); iter != nodeObject.end(); ++iter)
|
||||
{
|
||||
if (seqNodePropNames.find(iter->first) == seqNodePropNames.end())
|
||||
{
|
||||
setAnimatedProperty(iter->first, node, Value(), iter->second, fTweenDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -901,8 +918,9 @@ void CCBAnimationManager::setAnimationCompletedCallback(Object *target, SEL_Call
|
|||
_animationCompleteCallbackFunc = callbackFunc;
|
||||
}
|
||||
|
||||
void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed) {
|
||||
_keyframeCallFuncs->setObject((Object*)callFunc, callbackNamed);
|
||||
void CCBAnimationManager::setCallFunc(CallFunc* callFunc, const std::string &callbackNamed)
|
||||
{
|
||||
_keyframeCallFuncs.insert(callbackNamed, callFunc);
|
||||
}
|
||||
|
||||
void CCBAnimationManager::sequenceCompleted()
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "cocos2d.h"
|
||||
#include "extensions/ExtensionMacros.h"
|
||||
#include "CCBSequence.h"
|
||||
#include "CCBValue.h"
|
||||
#include "CCBSequenceProperty.h"
|
||||
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
||||
|
||||
|
@ -36,8 +35,8 @@ public:
|
|||
|
||||
virtual bool init();
|
||||
|
||||
cocos2d::Array* getSequences();
|
||||
void setSequences(cocos2d::Array* seq);
|
||||
cocos2d::Vector<CCBSequence*>& getSequences();
|
||||
void setSequences(const cocos2d::Vector<CCBSequence*>& seq);
|
||||
|
||||
|
||||
int getAutoPlaySequenceId();
|
||||
|
@ -57,15 +56,15 @@ public:
|
|||
void setDocumentControllerName(const std::string &name);
|
||||
|
||||
std::string getDocumentControllerName();
|
||||
cocos2d::Array* getDocumentCallbackNames();
|
||||
cocos2d::Array* getDocumentCallbackNodes();
|
||||
cocos2d::Array* getDocumentCallbackControlEvents();
|
||||
cocos2d::ValueVector& getDocumentCallbackNames();
|
||||
cocos2d::Vector<cocos2d::Node*>& getDocumentCallbackNodes();
|
||||
cocos2d::ValueVector& getDocumentCallbackControlEvents();
|
||||
|
||||
cocos2d::Array* getDocumentOutletNames();
|
||||
cocos2d::Array* getDocumentOutletNodes();
|
||||
cocos2d::ValueVector& getDocumentOutletNames();
|
||||
cocos2d::Vector<cocos2d::Node*>& getDocumentOutletNodes();
|
||||
std::string getLastCompletedSequenceName();
|
||||
|
||||
cocos2d::Array* getKeyframeCallbacks();
|
||||
cocos2d::ValueVector& getKeyframeCallbacks();
|
||||
|
||||
const cocos2d::Size& getRootContainerSize();
|
||||
void setRootContainerSize(const cocos2d::Size &rootContainerSize);
|
||||
|
@ -77,8 +76,10 @@ public:
|
|||
|
||||
const cocos2d::Size& getContainerSize(cocos2d::Node* pNode);
|
||||
|
||||
void addNode(cocos2d::Node *pNode, cocos2d::Dictionary *pSeq);
|
||||
void setBaseValue(cocos2d::Object *pValue, cocos2d::Node *pNode, const char *propName);
|
||||
void addNode(cocos2d::Node *pNode, const std::unordered_map<int, cocos2d::Map<std::string, CCBSequenceProperty*>>& seq);
|
||||
void setBaseValue(const cocos2d::Value& value, cocos2d::Node *pNode, const std::string& propName);
|
||||
void setObject(cocos2d::Object* obj, cocos2d::Node *pNode, const std::string& propName);
|
||||
|
||||
void moveAnimationsFromNode(cocos2d::Node* fromNode, cocos2d::Node* toNode);
|
||||
|
||||
/** @deprecated This interface will be deprecated sooner or later.*/
|
||||
|
@ -113,19 +114,23 @@ public:
|
|||
float getSequenceDuration(const char* pSequenceName);
|
||||
|
||||
private:
|
||||
cocos2d::Object* getBaseValue(cocos2d::Node *pNode, const char* propName);
|
||||
const cocos2d::Value& getBaseValue(cocos2d::Node *pNode, const std::string& propName);
|
||||
Object* getObject(cocos2d::Node *pNode, const std::string& propName);
|
||||
|
||||
CCBSequence* getSequence(int nSequenceId);
|
||||
cocos2d::ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const char *propName, cocos2d::Node *pNode);
|
||||
void setAnimatedProperty(const char *propName,cocos2d::Node *pNode, Object *pValue, float fTweenDuraion);
|
||||
cocos2d::ActionInterval* getAction(CCBKeyframe *pKeyframe0, CCBKeyframe *pKeyframe1, const std::string& propName, cocos2d::Node *pNode);
|
||||
void setAnimatedProperty(const std::string& propName,cocos2d::Node *pNode, const cocos2d::Value& value, Object* obj, float fTweenDuraion);
|
||||
void setFirstFrame(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
||||
cocos2d::ActionInterval* getEaseAction(cocos2d::ActionInterval *pAction, CCBKeyframe::EasingType easingType, float fEasingOpt);
|
||||
void runAction(cocos2d::Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration);
|
||||
void sequenceCompleted();
|
||||
|
||||
private:
|
||||
cocos2d::Array *_sequences;
|
||||
cocos2d::Dictionary *_nodeSequences;
|
||||
cocos2d::Dictionary *_baseValues;
|
||||
cocos2d::Vector<CCBSequence*> _sequences;
|
||||
std::unordered_map<cocos2d::Node*, std::unordered_map<int, cocos2d::Map<std::string, CCBSequenceProperty*>>> _nodeSequences;
|
||||
std::unordered_map<cocos2d::Node*, std::unordered_map<std::string, cocos2d::Value>> _baseValues;
|
||||
std::unordered_map<cocos2d::Node*, std::unordered_map<std::string, cocos2d::Object*>> _objects;
|
||||
|
||||
int _autoPlaySequenceId;
|
||||
|
||||
cocos2d::Node *_rootNode;
|
||||
|
@ -135,13 +140,13 @@ private:
|
|||
CCBAnimationManagerDelegate *_delegate;
|
||||
CCBSequence *_runningSequence;
|
||||
|
||||
cocos2d::Array *_documentOutletNames;
|
||||
cocos2d::Array *_documentOutletNodes;
|
||||
cocos2d::Array *_documentCallbackNames;
|
||||
cocos2d::Array *_documentCallbackNodes;
|
||||
cocos2d::Array *_documentCallbackControlEvents;
|
||||
cocos2d::Array *_keyframeCallbacks;
|
||||
cocos2d::Dictionary *_keyframeCallFuncs;
|
||||
cocos2d::ValueVector _documentOutletNames;
|
||||
cocos2d::Vector<cocos2d::Node*> _documentOutletNodes;
|
||||
cocos2d::ValueVector _documentCallbackNames;
|
||||
cocos2d::Vector<cocos2d::Node*> _documentCallbackNodes;
|
||||
cocos2d::ValueVector _documentCallbackControlEvents;
|
||||
cocos2d::ValueVector _keyframeCallbacks;
|
||||
cocos2d::Map<std::string, cocos2d::CallFunc*> _keyframeCallFuncs;
|
||||
|
||||
std::string _documentControllerName;
|
||||
std::string _lastCompletedSequenceName;
|
||||
|
|
|
@ -5,27 +5,37 @@ using namespace cocos2d;
|
|||
namespace cocosbuilder {
|
||||
|
||||
CCBKeyframe::CCBKeyframe()
|
||||
: _value(NULL)
|
||||
, _time(0.0f)
|
||||
: _time(0.0f)
|
||||
, _easingType(EasingType::INSTANT)
|
||||
, _easingOpt(0.0f)
|
||||
, _object(nullptr)
|
||||
{}
|
||||
|
||||
CCBKeyframe::~CCBKeyframe()
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(_value);
|
||||
CC_SAFE_RELEASE(_object);
|
||||
}
|
||||
|
||||
Object* CCBKeyframe::getValue()
|
||||
const Value& CCBKeyframe::getValue() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setValue(Object *pValue)
|
||||
void CCBKeyframe::setValue(const Value& value)
|
||||
{
|
||||
CC_SAFE_RELEASE(_value);
|
||||
_value = pValue;
|
||||
CC_SAFE_RETAIN(_value);
|
||||
_value = value;
|
||||
}
|
||||
|
||||
Object* CCBKeyframe::getObject() const
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
void CCBKeyframe::setObject(Object* obj)
|
||||
{
|
||||
CC_SAFE_RETAIN(obj);
|
||||
CC_SAFE_RELEASE(_object);
|
||||
_object = obj;
|
||||
}
|
||||
|
||||
float CCBKeyframe::getTime()
|
||||
|
|
|
@ -40,8 +40,11 @@ public:
|
|||
*/
|
||||
~CCBKeyframe();
|
||||
|
||||
cocos2d::Object* getValue();
|
||||
void setValue(cocos2d::Object *pValue); // retain
|
||||
const cocos2d::Value& getValue() const;
|
||||
void setValue(const cocos2d::Value& value);
|
||||
|
||||
cocos2d::Object* getObject() const;
|
||||
void setObject(cocos2d::Object* obj);
|
||||
|
||||
float getTime();
|
||||
void setTime(float fTime);
|
||||
|
@ -53,7 +56,8 @@ public:
|
|||
void setEasingOpt(float fEasingOpt);
|
||||
|
||||
private:
|
||||
cocos2d::Object *_value;
|
||||
cocos2d::Value _value;
|
||||
cocos2d::Object* _object;
|
||||
float _time;
|
||||
EasingType _easingType;
|
||||
float _easingOpt;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define _CCB_CCBMEMBERVARIABLEASSIGNER_H_
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "CCBValue.h"
|
||||
|
||||
namespace cocosbuilder {
|
||||
|
||||
|
@ -51,7 +50,7 @@ class CCBMemberVariableAssigner {
|
|||
* @param value The value of the property.
|
||||
* @return Whether the assignment was successful.
|
||||
*/
|
||||
virtual bool onAssignCCBCustomProperty(cocos2d::Object* target, const char* memberVariableName, CCBValue* value) { return false; };
|
||||
virtual bool onAssignCCBCustomProperty(cocos2d::Object* target, const char* memberVariableName, const cocos2d::Value& value) { return false; };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "CCBAnimationManager.h"
|
||||
#include "CCBSequenceProperty.h"
|
||||
#include "CCBKeyframe.h"
|
||||
#include "CCBValue.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
|
@ -60,7 +59,7 @@ CCBReader::CCBReader(NodeLoaderLibrary * pNodeLoaderLibrary, CCBMemberVariableAs
|
|||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(nullptr)
|
||||
, _actionManager(nullptr)
|
||||
, _animationManager(nullptr)
|
||||
, _animatedProps(nullptr)
|
||||
{
|
||||
this->_nodeLoaderLibrary = pNodeLoaderLibrary;
|
||||
|
@ -77,7 +76,7 @@ CCBReader::CCBReader(CCBReader * ccbReader)
|
|||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(nullptr)
|
||||
, _actionManager(nullptr)
|
||||
, _animationManager(nullptr)
|
||||
, _animatedProps(nullptr)
|
||||
{
|
||||
this->_loadedSpriteSheets = ccbReader->_loadedSpriteSheets;
|
||||
|
@ -99,7 +98,7 @@ CCBReader::CCBReader()
|
|||
, _currentByte(-1)
|
||||
, _currentBit(-1)
|
||||
, _owner(nullptr)
|
||||
, _actionManager(nullptr)
|
||||
, _animationManager(nullptr)
|
||||
, _nodeLoaderLibrary(nullptr)
|
||||
, _nodeLoaderListener(nullptr)
|
||||
, _CCBMemberVariableAssigner(nullptr)
|
||||
|
@ -143,31 +142,31 @@ bool CCBReader::init()
|
|||
pActionManager->release();
|
||||
|
||||
// Setup resolution scale and container size
|
||||
_actionManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
||||
_animationManager->setRootContainerSize(Director::getInstance()->getWinSize());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CCBAnimationManager* CCBReader::getAnimationManager()
|
||||
{
|
||||
return _actionManager;
|
||||
return _animationManager;
|
||||
}
|
||||
|
||||
void CCBReader::setAnimationManager(CCBAnimationManager *pAnimationManager)
|
||||
{
|
||||
CC_SAFE_RELEASE(_actionManager);
|
||||
_actionManager = pAnimationManager;
|
||||
CC_SAFE_RETAIN(_actionManager);
|
||||
CC_SAFE_RELEASE(_animationManager);
|
||||
_animationManager = pAnimationManager;
|
||||
CC_SAFE_RETAIN(_animationManager);
|
||||
}
|
||||
|
||||
Map<Node*, CCBAnimationManager*>& CCBReader::getAnimationManagers()
|
||||
CCBReader::CCBAnimationManagerMapPtr CCBReader::getAnimationManagers()
|
||||
{
|
||||
return _actionManagers;
|
||||
return _animationManagers;
|
||||
}
|
||||
|
||||
void CCBReader::setAnimationManagers(const Map<Node*, CCBAnimationManager*>& x)
|
||||
void CCBReader::setAnimationManagers(CCBAnimationManagerMapPtr x)
|
||||
{
|
||||
_actionManagers = x;
|
||||
_animationManagers = x;
|
||||
}
|
||||
|
||||
CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() {
|
||||
|
@ -242,24 +241,23 @@ Node* CCBReader::readNodeGraphFromData(Data *pData, Object *pOwner, const Size &
|
|||
_owner = pOwner;
|
||||
CC_SAFE_RETAIN(_owner);
|
||||
|
||||
_actionManager->setRootContainerSize(parentSize);
|
||||
_actionManager->_owner = _owner;
|
||||
_animationManager->setRootContainerSize(parentSize);
|
||||
_animationManager->_owner = _owner;
|
||||
|
||||
Map<Node*, CCBAnimationManager*> animationManagers;
|
||||
Node *pNodeGraph = readFileWithCleanUp(true, animationManagers);
|
||||
Node *pNodeGraph = readFileWithCleanUp(true, std::make_shared<CCBAnimationManagerMap>());
|
||||
|
||||
if (pNodeGraph && _actionManager->getAutoPlaySequenceId() != -1)
|
||||
if (pNodeGraph && _animationManager->getAutoPlaySequenceId() != -1)
|
||||
{
|
||||
// Auto play animations
|
||||
_actionManager->runAnimationsForSequenceIdTweenDuration(_actionManager->getAutoPlaySequenceId(), 0);
|
||||
_animationManager->runAnimationsForSequenceIdTweenDuration(_animationManager->getAutoPlaySequenceId(), 0);
|
||||
}
|
||||
|
||||
// Assign actionManagers to userObject
|
||||
|
||||
for (auto iter = _actionManagers.begin(); iter != _actionManagers.end(); ++iter)
|
||||
for (auto iter = _animationManagers->begin(); iter != _animationManagers->end(); ++iter)
|
||||
{
|
||||
Node* pNode = iter->first;
|
||||
CCBAnimationManager* manager = iter->second;
|
||||
|
||||
pNode->setUserObject(manager);
|
||||
|
||||
if (_jsControlled)
|
||||
|
@ -300,7 +298,7 @@ void CCBReader::cleanUpNodeGraph(Node *node)
|
|||
});
|
||||
}
|
||||
|
||||
Node* CCBReader::readFileWithCleanUp(bool bCleanUp, const Map<Node*, CCBAnimationManager*>& am)
|
||||
Node* CCBReader::readFileWithCleanUp(bool bCleanUp, CCBAnimationManagerMapPtr am)
|
||||
{
|
||||
if (! readHeader())
|
||||
{
|
||||
|
@ -321,7 +319,7 @@ Node* CCBReader::readFileWithCleanUp(bool bCleanUp, const Map<Node*, CCBAnimatio
|
|||
|
||||
Node *pNode = readNodeGraph(nullptr);
|
||||
|
||||
_actionManagers.insert(pNode, _actionManager);
|
||||
_animationManagers->insert(pNode, _animationManager);
|
||||
|
||||
if (bCleanUp)
|
||||
{
|
||||
|
@ -365,7 +363,7 @@ bool CCBReader::readHeader()
|
|||
|
||||
// Read JS check
|
||||
_jsControlled = this->readBool();
|
||||
_actionManager->_jsControlled = _jsControlled;
|
||||
_animationManager->_jsControlled = _jsControlled;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -540,26 +538,26 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
Node *node = ccNodeLoader->loadNode(pParent, this);
|
||||
|
||||
// Set root node
|
||||
if (! _actionManager->getRootNode())
|
||||
if (! _animationManager->getRootNode())
|
||||
{
|
||||
_actionManager->setRootNode(node);
|
||||
_animationManager->setRootNode(node);
|
||||
}
|
||||
|
||||
// Assign controller
|
||||
if(_jsControlled && node == _actionManager->getRootNode())
|
||||
if(_jsControlled && node == _animationManager->getRootNode())
|
||||
{
|
||||
_actionManager->setDocumentControllerName(_jsControlledName);
|
||||
_animationManager->setDocumentControllerName(_jsControlledName);
|
||||
}
|
||||
|
||||
// Read animated properties
|
||||
Dictionary *seqs = Dictionary::create();
|
||||
std::unordered_map<int, Map<std::string, CCBSequenceProperty*>> seqs;
|
||||
_animatedProps = new set<string>();
|
||||
|
||||
int numSequence = readInt(false);
|
||||
for (int i = 0; i < numSequence; ++i)
|
||||
{
|
||||
int seqId = readInt(false);
|
||||
Dictionary *seqNodeProps = Dictionary::create();
|
||||
Map<std::string, CCBSequenceProperty*> seqNodeProps;
|
||||
|
||||
int numProps = readInt(false);
|
||||
|
||||
|
@ -581,15 +579,15 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
seqProp->getKeyframes().pushBack(keyframe);
|
||||
}
|
||||
|
||||
seqNodeProps->setObject(seqProp, seqProp->getName());
|
||||
seqNodeProps.insert(seqProp->getName(), seqProp);
|
||||
}
|
||||
|
||||
seqs->setObject(seqNodeProps, seqId);
|
||||
seqs[seqId] = seqNodeProps;
|
||||
}
|
||||
|
||||
if (seqs->count() > 0)
|
||||
if (!seqs.empty())
|
||||
{
|
||||
_actionManager->addNode(node, seqs);
|
||||
_animationManager->addNode(node, seqs);
|
||||
}
|
||||
|
||||
// Read properties
|
||||
|
@ -610,7 +608,7 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
embeddedNode->setVisible(true);
|
||||
//embeddedNode->ignoreAnchorPointForPosition(ccbFileNode->isIgnoreAnchorPointForPosition());
|
||||
|
||||
_actionManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
||||
_animationManager->moveAnimationsFromNode(ccbFileNode, embeddedNode);
|
||||
|
||||
ccbFileNode->setCCBFileNode(nullptr);
|
||||
|
||||
|
@ -631,7 +629,7 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
Object * target = nullptr;
|
||||
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
||||
{
|
||||
target = _actionManager->getRootNode();
|
||||
target = _animationManager->getRootNode();
|
||||
}
|
||||
else if(memberVarAssignmentType == TargetType::OWNER)
|
||||
{
|
||||
|
@ -661,8 +659,8 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
{
|
||||
if(memberVarAssignmentType == TargetType::DOCUMENT_ROOT)
|
||||
{
|
||||
_actionManager->addDocumentOutletName(memberVarAssignmentName);
|
||||
_actionManager->addDocumentOutletNode(node);
|
||||
_animationManager->addDocumentOutletName(memberVarAssignmentName);
|
||||
_animationManager->addDocumentOutletNode(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -673,7 +671,7 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
}
|
||||
|
||||
// Assign custom properties.
|
||||
if (ccNodeLoader->getCustomProperties()->count() > 0)
|
||||
if (!ccNodeLoader->getCustomProperties().empty())
|
||||
{
|
||||
bool customAssigned = false;
|
||||
|
||||
|
@ -685,15 +683,15 @@ Node * CCBReader::readNodeGraph(Node * pParent)
|
|||
CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast<CCBMemberVariableAssigner *>(target);
|
||||
if(targetAsCCBMemberVariableAssigner != nullptr)
|
||||
{
|
||||
Dictionary* pCustomPropeties = ccNodeLoader->getCustomProperties();
|
||||
DictElement* pElement;
|
||||
CCDICT_FOREACH(pCustomPropeties, pElement)
|
||||
auto& customPropeties = ccNodeLoader->getCustomProperties();
|
||||
|
||||
for (auto iter = customPropeties.begin(); iter != customPropeties.end(); ++iter)
|
||||
{
|
||||
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
customAssigned = targetAsCCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second);
|
||||
|
||||
if(!customAssigned && this->_CCBMemberVariableAssigner != nullptr)
|
||||
{
|
||||
customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, pElement->getStrKey(), static_cast<CCBValue*>(pElement->getObject()));
|
||||
customAssigned = this->_CCBMemberVariableAssigner->onAssignCCBCustomProperty(target, iter->first.c_str(), iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +740,7 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
|||
|
||||
CCBKeyframe::EasingType easingType = static_cast<CCBKeyframe::EasingType>(readInt(false));
|
||||
float easingOpt = 0;
|
||||
Object *value = nullptr;
|
||||
Value value;
|
||||
|
||||
if (easingType == CCBKeyframe::EasingType::CUBIC_IN
|
||||
|| easingType == CCBKeyframe::EasingType::CUBIC_OUT
|
||||
|
@ -758,24 +756,28 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
|||
|
||||
if (type == PropertyType::CHECK)
|
||||
{
|
||||
value = CCBValue::create(readBool());
|
||||
value = readBool();
|
||||
}
|
||||
else if (type == PropertyType::BYTE)
|
||||
{
|
||||
value = CCBValue::create(readByte());
|
||||
value = readByte();
|
||||
}
|
||||
else if (type == PropertyType::COLOR3)
|
||||
{
|
||||
int r = readByte();
|
||||
int g = readByte();
|
||||
int b = readByte();
|
||||
unsigned char r = readByte();
|
||||
unsigned char g = readByte();
|
||||
unsigned char b = readByte();
|
||||
|
||||
Color3B c = Color3B(r,g,b);
|
||||
value = Color3BWapper::create(c);
|
||||
ValueMap colorMap;
|
||||
colorMap["r"] = r;
|
||||
colorMap["g"] = g;
|
||||
colorMap["b"] = b;
|
||||
|
||||
value = colorMap;
|
||||
}
|
||||
else if (type == PropertyType::DEGREES)
|
||||
{
|
||||
value = CCBValue::create(readFloat());
|
||||
value = readFloat();
|
||||
}
|
||||
else if (type == PropertyType::SCALE_LOCK || type == PropertyType::POSITION
|
||||
|| type == PropertyType::FLOAT_XY)
|
||||
|
@ -783,9 +785,11 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
|||
float a = readFloat();
|
||||
float b = readFloat();
|
||||
|
||||
value = Array::create(CCBValue::create(a),
|
||||
CCBValue::create(b),
|
||||
nullptr);
|
||||
ValueVector ab;
|
||||
ab.push_back(Value(a));
|
||||
ab.push_back(Value(b));
|
||||
|
||||
value = ab;
|
||||
}
|
||||
else if (type == PropertyType::SPRITEFRAME)
|
||||
{
|
||||
|
@ -817,10 +821,12 @@ CCBKeyframe* CCBReader::readKeyframe(PropertyType type)
|
|||
|
||||
spriteFrame = frameCache->getSpriteFrameByName(spriteFile.c_str());
|
||||
}
|
||||
value = spriteFrame;
|
||||
|
||||
keyframe->setObject(spriteFrame);
|
||||
}
|
||||
|
||||
keyframe->setValue(value);
|
||||
if (!value.isNull())
|
||||
keyframe->setValue(value);
|
||||
|
||||
return keyframe;
|
||||
}
|
||||
|
@ -841,19 +847,21 @@ bool CCBReader::readCallbackKeyframesForSeq(CCBSequence* seq)
|
|||
|
||||
int callbackType = readInt(false);
|
||||
|
||||
Array* value = Array::create();
|
||||
value->addObject(String::create(callbackName));
|
||||
value->addObject(String::createWithFormat("%d", callbackType));
|
||||
ValueVector valueVector;
|
||||
valueVector.push_back(Value(callbackName));
|
||||
valueVector.push_back(Value(callbackType));
|
||||
|
||||
CCBKeyframe* keyframe = new CCBKeyframe();
|
||||
keyframe->autorelease();
|
||||
|
||||
keyframe->setTime(time);
|
||||
keyframe->setValue(value);
|
||||
keyframe->setValue(Value(valueVector));
|
||||
|
||||
if(_jsControlled) {
|
||||
string callbackIdentifier;
|
||||
_actionManager->getKeyframeCallbacks()->addObject(String::createWithFormat("%d:%s",callbackType, callbackName.c_str()));
|
||||
std::stringstream callbackIdentifier;
|
||||
callbackIdentifier << callbackType;
|
||||
callbackIdentifier << ":" + callbackName;
|
||||
_animationManager->getKeyframeCallbacks().push_back(Value(callbackIdentifier.str()));
|
||||
}
|
||||
|
||||
channel->getKeyframes().pushBack(keyframe);
|
||||
|
@ -878,17 +886,16 @@ bool CCBReader::readSoundKeyframesForSeq(CCBSequence* seq) {
|
|||
float pitch = readFloat();
|
||||
float pan = readFloat();
|
||||
float gain = readFloat();
|
||||
|
||||
Array* value = Array::create();
|
||||
|
||||
value->addObject(String::create(soundFile));
|
||||
value->addObject(String::createWithFormat("%f", pitch));
|
||||
value->addObject(String::createWithFormat("%f", pan));
|
||||
value->addObject(String::createWithFormat("%f", gain));
|
||||
ValueVector vec;
|
||||
vec.push_back(Value(soundFile));
|
||||
vec.push_back(Value(pitch));
|
||||
vec.push_back(Value(pan));
|
||||
vec.push_back(Value(gain));
|
||||
|
||||
CCBKeyframe* keyframe = new CCBKeyframe();
|
||||
keyframe->setTime(time);
|
||||
keyframe->setValue(value);
|
||||
keyframe->setValue(Value(vec));
|
||||
channel->getKeyframes().pushBack(keyframe);
|
||||
keyframe->release();
|
||||
}
|
||||
|
@ -905,7 +912,7 @@ Node * CCBReader::readNodeGraph() {
|
|||
|
||||
bool CCBReader::readSequences()
|
||||
{
|
||||
Array *sequences = _actionManager->getSequences();
|
||||
auto& sequences = _animationManager->getSequences();
|
||||
|
||||
int numSeqs = readInt(false);
|
||||
|
||||
|
@ -922,10 +929,10 @@ bool CCBReader::readSequences()
|
|||
if(!readCallbackKeyframesForSeq(seq)) return false;
|
||||
if(!readSoundKeyframesForSeq(seq)) return false;
|
||||
|
||||
sequences->addObject(seq);
|
||||
sequences.pushBack(seq);
|
||||
}
|
||||
|
||||
_actionManager->setAutoPlaySequenceId(readInt(true));
|
||||
_animationManager->setAutoPlaySequenceId(readInt(true));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -985,17 +992,17 @@ void CCBReader::addOwnerCallbackControlEvents(Control::EventType type)
|
|||
|
||||
void CCBReader::addDocumentCallbackName(const std::string& name)
|
||||
{
|
||||
_actionManager->addDocumentCallbackName(name);
|
||||
_animationManager->addDocumentCallbackName(name);
|
||||
}
|
||||
|
||||
void CCBReader::addDocumentCallbackNode(Node *node)
|
||||
{
|
||||
_actionManager->addDocumentCallbackNode(node);
|
||||
_animationManager->addDocumentCallbackNode(node);
|
||||
}
|
||||
|
||||
void CCBReader::addDocumentCallbackControlEvents(Control::EventType eventType)
|
||||
{
|
||||
_actionManager->addDocumentCallbackControlEvents(eventType);
|
||||
_animationManager->addDocumentCallbackControlEvents(eventType);
|
||||
}
|
||||
|
||||
ValueVector CCBReader::getOwnerCallbackNames()
|
||||
|
@ -1009,7 +1016,7 @@ ValueVector CCBReader::getOwnerCallbackNames()
|
|||
ret.push_back(Value(*it));
|
||||
}
|
||||
|
||||
return std::move(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector<Node*>& CCBReader::getOwnerCallbackNodes()
|
||||
|
@ -1031,7 +1038,7 @@ ValueVector CCBReader::getOwnerOutletNames()
|
|||
{
|
||||
ret.push_back(Value(*it));
|
||||
}
|
||||
return std::move(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Vector<Node*>& CCBReader::getOwnerOutletNodes()
|
||||
|
|
|
@ -290,16 +290,20 @@ public:
|
|||
cocos2d::Vector<cocos2d::Node*>& getOwnerOutletNodes();
|
||||
cocos2d::Vector<cocos2d::Node*>& getNodesWithAnimationManagers();
|
||||
cocos2d::Vector<CCBAnimationManager*>& getAnimationManagersForNodes();
|
||||
|
||||
typedef cocos2d::Map<cocos2d::Node*, CCBAnimationManager*> CCBAnimationManagerMap;
|
||||
typedef std::shared_ptr<CCBAnimationManagerMap> CCBAnimationManagerMapPtr;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
cocos2d::Map<cocos2d::Node*, CCBAnimationManager*>& getAnimationManagers();
|
||||
CCBAnimationManagerMapPtr getAnimationManagers();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setAnimationManagers(const cocos2d::Map<cocos2d::Node*, CCBAnimationManager*>& x); // weak reference
|
||||
void setAnimationManagers(CCBAnimationManagerMapPtr x);
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -332,7 +336,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
cocos2d::Node* readFileWithCleanUp(bool bCleanUp, const cocos2d::Map<cocos2d::Node*, CCBAnimationManager*>& am);
|
||||
cocos2d::Node* readFileWithCleanUp(bool bCleanUp, CCBAnimationManagerMapPtr am);
|
||||
|
||||
void addOwnerOutletName(std::string name);
|
||||
void addOwnerOutletNode(cocos2d::Node *node);
|
||||
|
@ -366,8 +370,8 @@ private:
|
|||
|
||||
cocos2d::Object *_owner;
|
||||
|
||||
CCBAnimationManager *_actionManager; //retain
|
||||
cocos2d::Map<cocos2d::Node*, CCBAnimationManager*> _actionManagers;
|
||||
CCBAnimationManager* _animationManager; //retain
|
||||
CCBAnimationManagerMapPtr _animationManagers;
|
||||
|
||||
std::set<std::string> *_animatedProps;
|
||||
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
#include "CCBValue.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocosbuilder {
|
||||
|
||||
// Implementation of Color3BWapper
|
||||
|
||||
Color3BWapper* Color3BWapper::create(const Color3B& color)
|
||||
{
|
||||
Color3BWapper *ret = new Color3BWapper();
|
||||
if (ret)
|
||||
{
|
||||
ret->color.r = color.r;
|
||||
ret->color.g = color.g;
|
||||
ret->color.b = color.b;
|
||||
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Color3B& Color3BWapper::getColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
// Implementation of CCBValue
|
||||
|
||||
CCBValue* CCBValue::create(int nValue)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_value.intValue = nValue;
|
||||
ret->_type = Type::INT;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCBValue* CCBValue::create(float fValue)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_value.floatValue = fValue;
|
||||
ret->_type = Type::FLOAT;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCBValue* CCBValue::create(bool vValue)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_value.intValue = vValue ? 1 : 0;
|
||||
ret->_type = Type::BOOL;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCBValue* CCBValue::create(unsigned char byte)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_value.intValue = byte;
|
||||
ret->_type = Type::UNSIGNED_CHAR;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCBValue* CCBValue::create(const char *pStringValue)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_strValue = pStringValue;
|
||||
ret->_type = Type::STRING;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
CCBValue* CCBValue::create(Array *pArrValue)
|
||||
{
|
||||
CCBValue *ret = new CCBValue();
|
||||
if (ret)
|
||||
{
|
||||
ret->_arrValue = pArrValue;
|
||||
ret->_type = Type::ARRAY;
|
||||
ret->autorelease();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int CCBValue::getIntValue()
|
||||
{
|
||||
CCASSERT(_type == Type::INT, "The type of CCBValue isn't integer.");
|
||||
|
||||
return _value.intValue;
|
||||
}
|
||||
|
||||
float CCBValue::getFloatValue()
|
||||
{
|
||||
CCASSERT(_type == Type::FLOAT, "The type of CCBValue isn't float.");
|
||||
|
||||
return _value.floatValue;
|
||||
}
|
||||
|
||||
bool CCBValue::getBoolValue()
|
||||
{
|
||||
CCASSERT(_type == Type::BOOL, "The type of CCBValue isn't boolean.");
|
||||
|
||||
return _value.intValue == 1 ? true : false;
|
||||
}
|
||||
|
||||
unsigned char CCBValue::getByteValue()
|
||||
{
|
||||
CCASSERT(_type == Type::UNSIGNED_CHAR, "The type of CCBValue isn't unsigned char.");
|
||||
|
||||
return (unsigned char)(_value.intValue);
|
||||
}
|
||||
|
||||
Array* CCBValue::getArrayValue()
|
||||
{
|
||||
CCASSERT(_type == Type::ARRAY, "The type of CCBValue isn't array.");
|
||||
|
||||
return _arrValue;
|
||||
}
|
||||
|
||||
|
||||
const char* CCBValue::getStringValue()
|
||||
{
|
||||
CCASSERT(_type == Type::STRING, "The type of CCBValue isn't string.");
|
||||
|
||||
return _strValue.c_str();
|
||||
}
|
||||
|
||||
CCBValue::Type CCBValue::getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
#ifndef __CCB_VALUE_H__
|
||||
#define __CCB_VALUE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
/*
|
||||
These classes are wrapper of basic types, such as Color3B
|
||||
*/
|
||||
|
||||
namespace cocosbuilder {
|
||||
|
||||
class Color3BWapper : public cocos2d::Object
|
||||
{
|
||||
public:
|
||||
static Color3BWapper* create(const cocos2d::Color3B& color);
|
||||
|
||||
const cocos2d::Color3B& getColor() const;
|
||||
|
||||
private:
|
||||
cocos2d::Color3B color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CCBValue : public cocos2d::Object
|
||||
{
|
||||
public:
|
||||
|
||||
enum class Type
|
||||
{
|
||||
INT,
|
||||
FLOAT,
|
||||
BOOL,
|
||||
UNSIGNED_CHAR,
|
||||
STRING,
|
||||
ARRAY
|
||||
};
|
||||
|
||||
static CCBValue* create(int nValue);
|
||||
static CCBValue* create(bool bValue);
|
||||
static CCBValue* create(float fValue);
|
||||
static CCBValue* create(unsigned char byte);
|
||||
static CCBValue* create(const char* pStr);
|
||||
static CCBValue* create(cocos2d::Array* pArr);
|
||||
|
||||
|
||||
int getIntValue();
|
||||
float getFloatValue();
|
||||
bool getBoolValue();
|
||||
unsigned char getByteValue();
|
||||
const char* getStringValue();
|
||||
cocos2d::Array *getArrayValue();
|
||||
|
||||
Type getType();
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
int intValue;
|
||||
float floatValue;
|
||||
} _value;
|
||||
|
||||
std::string _strValue;
|
||||
cocos2d::Array* _arrValue;
|
||||
Type _type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __CCB_VALUE_H__
|
|
@ -5,7 +5,7 @@ using namespace cocos2d;
|
|||
|
||||
namespace cocosbuilder {
|
||||
|
||||
Point getAbsolutePosition(const Point &pt, CCBReader::PositionType type, const Size &containerSize, const char *propName)
|
||||
Point getAbsolutePosition(const Point &pt, CCBReader::PositionType type, const Size &containerSize, const std::string& propName)
|
||||
{
|
||||
Point absPt = Point(0,0);
|
||||
if (type == CCBReader::PositionType::RELATIVE_BOTTOM_LEFT)
|
||||
|
@ -43,7 +43,7 @@ Point getAbsolutePosition(const Point &pt, CCBReader::PositionType type, const S
|
|||
return absPt;
|
||||
}
|
||||
|
||||
void setRelativeScale(Node *pNode, float scaleX, float scaleY, CCBReader::ScaleType type, const char* propName)
|
||||
void setRelativeScale(Node *pNode, float scaleX, float scaleY, CCBReader::ScaleType type, const std::string& propName)
|
||||
{
|
||||
CCASSERT(pNode, "pNode should not be null");
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
namespace cocosbuilder {
|
||||
|
||||
extern cocos2d::Point getAbsolutePosition(const cocos2d::Point &pt, CCBReader::PositionType type, const cocos2d::Size &containerSize, const char *propName);
|
||||
extern cocos2d::Point getAbsolutePosition(const cocos2d::Point &pt, CCBReader::PositionType type, const cocos2d::Size &containerSize, const std::string&propName);
|
||||
|
||||
extern void setRelativeScale(cocos2d::Node *node, float scaleX, float scaleY, CCBReader::ScaleType type, const char* propName);
|
||||
extern void setRelativeScale(cocos2d::Node *node, float scaleX, float scaleY, CCBReader::ScaleType type, const std::string& propName);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,33 +12,29 @@ namespace cocosbuilder {
|
|||
|
||||
NodeLoader::NodeLoader()
|
||||
{
|
||||
_customProperties = new Dictionary();
|
||||
_customProperties->init();
|
||||
}
|
||||
|
||||
NodeLoader::~NodeLoader()
|
||||
{
|
||||
CC_SAFE_RELEASE(_customProperties);
|
||||
}
|
||||
|
||||
Dictionary* NodeLoader::getCustomProperties()
|
||||
ValueMap& NodeLoader::getCustomProperties()
|
||||
{
|
||||
return _customProperties;
|
||||
}
|
||||
|
||||
Node * NodeLoader::loadNode(Node * pParent, CCBReader * ccbReader) {
|
||||
Node * NodeLoader::loadNode(Node * pParent, CCBReader * ccbReader)
|
||||
{
|
||||
Node * ccNode = this->createNode(pParent, ccbReader);
|
||||
|
||||
//clear _customProperties, ready for load next node.
|
||||
if (_customProperties != nullptr)
|
||||
{
|
||||
_customProperties->removeAllObjects();
|
||||
}
|
||||
_customProperties.clear();
|
||||
|
||||
return ccNode;
|
||||
}
|
||||
|
||||
void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbReader) {
|
||||
void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * ccbReader)
|
||||
{
|
||||
int numRegularProps = ccbReader->readInt(false);
|
||||
int numExturaProps = ccbReader->readInt(false);
|
||||
int propertyCount = numRegularProps + numExturaProps;
|
||||
|
@ -382,11 +378,12 @@ Point NodeLoader::parsePropTypePosition(Node * pNode, Node * pParent, CCBReader
|
|||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
Array *baseValue = Array::create(CCBValue::create(x),
|
||||
CCBValue::create(y),
|
||||
CCBValue::create((int)type),
|
||||
NULL);
|
||||
ccbReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName);
|
||||
ValueVector vec;
|
||||
vec.push_back(Value(x));
|
||||
vec.push_back(Value(y));
|
||||
vec.push_back(Value((int)type));
|
||||
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(vec), pNode, pPropertyName);
|
||||
}
|
||||
|
||||
return pt;
|
||||
|
@ -485,11 +482,12 @@ float * NodeLoader::parsePropTypeScaleLock(Node * pNode, Node * pParent, CCBRead
|
|||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
Array *baseValue = Array::create(CCBValue::create(x),
|
||||
CCBValue::create(y),
|
||||
CCBValue::create((int)type),
|
||||
NULL);
|
||||
ccbReader->getAnimationManager()->setBaseValue(baseValue, pNode, pPropertyName);
|
||||
ValueVector baseValue;
|
||||
baseValue.push_back(Value(x));
|
||||
baseValue.push_back(Value(y));
|
||||
baseValue.push_back(Value((int)type));
|
||||
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(baseValue), pNode, pPropertyName);
|
||||
}
|
||||
|
||||
if (type == CCBReader::ScaleType::MULTIPLY_RESOLUTION)
|
||||
|
@ -513,8 +511,7 @@ float NodeLoader::parsePropTypeDegrees(Node * pNode, Node * pParent, CCBReader *
|
|||
float ret = ccbReader->readFloat();
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
CCBValue *value = CCBValue::create(ret);
|
||||
ccbReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -562,8 +559,7 @@ bool NodeLoader::parsePropTypeCheck(Node * pNode, Node * pParent, CCBReader * cc
|
|||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
CCBValue *value = CCBValue::create(ret);
|
||||
ccbReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -603,7 +599,7 @@ SpriteFrame * NodeLoader::parsePropTypeSpriteFrame(Node * pNode, Node * pParent,
|
|||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
ccbReader->getAnimationManager()->setBaseValue(spriteFrame, pNode, pPropertyName);
|
||||
ccbReader->getAnimationManager()->setObject(spriteFrame, pNode, pPropertyName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -653,22 +649,27 @@ unsigned char NodeLoader::parsePropTypeByte(Node * pNode, Node * pParent, CCBRea
|
|||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
ccbReader->getAnimationManager()->setBaseValue(CCBValue::create(ret), pNode, pPropertyName);
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(ret), pNode, pPropertyName);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Color3B NodeLoader::parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * ccbReader, const char *pPropertyName) {
|
||||
unsigned char red = ccbReader->readByte();
|
||||
unsigned char green = ccbReader->readByte();
|
||||
unsigned char blue = ccbReader->readByte();
|
||||
unsigned char r = ccbReader->readByte();
|
||||
unsigned char g = ccbReader->readByte();
|
||||
unsigned char b = ccbReader->readByte();
|
||||
|
||||
Color3B color(red, green, blue);
|
||||
Color3B color(r, g, b);
|
||||
|
||||
ValueMap colorMap;
|
||||
colorMap["r"] = r;
|
||||
colorMap["g"] = g;
|
||||
colorMap["b"] = b;
|
||||
|
||||
if (ccbReader->getAnimatedProperties()->find(pPropertyName) != ccbReader->getAnimatedProperties()->end())
|
||||
{
|
||||
Color3BWapper *value = Color3BWapper::create(color);
|
||||
ccbReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
||||
ccbReader->getAnimationManager()->setBaseValue(Value(colorMap), pNode, pPropertyName);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
@ -1047,7 +1048,7 @@ void NodeLoader::onHandlePropTypeScaleLock(Node * pNode, Node * pParent, const c
|
|||
void NodeLoader::onHandlePropTypeFloat(Node * pNode, Node * pParent, const char* pPropertyName, float pFloat, CCBReader * ccbReader) {
|
||||
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||
// It may be a custom property, add it to custom property dictionary.
|
||||
_customProperties->setObject(CCBValue::create(pFloat), pPropertyName);
|
||||
_customProperties[pPropertyName] = Value(pFloat);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1074,7 +1075,7 @@ void NodeLoader::onHandlePropTypeInteger(Node * pNode, Node * pParent, const cha
|
|||
} else {
|
||||
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||
// It may be a custom property, add it to custom property dictionary.
|
||||
_customProperties->setObject(CCBValue::create(pInteger), pPropertyName);
|
||||
_customProperties[pPropertyName] = Value(pInteger);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1094,7 +1095,7 @@ void NodeLoader::onHandlePropTypeCheck(Node * pNode, Node * pParent, const char*
|
|||
} else {
|
||||
//ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||
// It may be a custom property, add it to custom property dictionary.
|
||||
_customProperties->setObject(CCBValue::create(pCheck), pPropertyName);
|
||||
_customProperties[pPropertyName] = Value(pCheck);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1138,7 @@ void NodeLoader::onHandlePropTypeFntFile(Node * pNode, Node * pParent, const cha
|
|||
void NodeLoader::onHandlePropTypeString(Node * pNode, Node * pParent, const char* pPropertyName, const char * pString, CCBReader * ccbReader) {
|
||||
// ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||
// It may be a custom property, add it to custom property dictionary.
|
||||
_customProperties->setObject(CCBValue::create(pString), pPropertyName);
|
||||
_customProperties[pPropertyName] = Value(pString);
|
||||
}
|
||||
|
||||
void NodeLoader::onHandlePropTypeText(Node * pNode, Node * pParent, const char* pPropertyName, const char * pText, CCBReader * ccbReader) {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "extensions/GUI/CCControlExtension/CCInvocation.h"
|
||||
#include "cocos2d.h"
|
||||
#include "CCBReader.h"
|
||||
#include "CCBValue.h"
|
||||
#include "extensions/GUI/CCControlExtension/CCControl.h"
|
||||
|
||||
namespace cocosbuilder {
|
||||
|
@ -75,7 +74,7 @@ class NodeLoader : public cocos2d::Object {
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual cocos2d::Dictionary* getCustomProperties();
|
||||
virtual cocos2d::ValueMap& getCustomProperties();
|
||||
|
||||
protected:
|
||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(cocos2d::Node);
|
||||
|
@ -141,7 +140,7 @@ class NodeLoader : public cocos2d::Object {
|
|||
virtual void onHandlePropTypeCCBFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Node * pCCBFileNode, CCBReader * ccbReader);
|
||||
|
||||
protected:
|
||||
cocos2d::Dictionary* _customProperties;
|
||||
cocos2d::ValueMap _customProperties;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ set(CCB_SRC
|
|||
CCBKeyframe.cpp
|
||||
CCBSequence.cpp
|
||||
CCBSequenceProperty.cpp
|
||||
CCBValue.cpp
|
||||
CCNode+CCBRelativePositioning.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "cocosbuilder/CCBSelectorResolver.h"
|
||||
#include "cocosbuilder/CCBSequence.h"
|
||||
#include "cocosbuilder/CCBSequenceProperty.h"
|
||||
#include "cocosbuilder/CCBValue.h"
|
||||
#include "cocosbuilder/CCControlButtonLoader.h"
|
||||
#include "cocosbuilder/CCControlLoader.h"
|
||||
#include "cocosbuilder/CCLabelBMFontLoader.h"
|
||||
|
|
|
@ -92,7 +92,6 @@
|
|||
<ClCompile Include="..\CCBReader.cpp" />
|
||||
<ClCompile Include="..\CCBSequence.cpp" />
|
||||
<ClCompile Include="..\CCBSequenceProperty.cpp" />
|
||||
<ClCompile Include="..\CCBValue.cpp" />
|
||||
<ClCompile Include="..\CCControlButtonLoader.cpp" />
|
||||
<ClCompile Include="..\CCControlLoader.cpp" />
|
||||
<ClCompile Include="..\CCLabelBMFontLoader.cpp" />
|
||||
|
@ -119,7 +118,6 @@
|
|||
<ClInclude Include="..\CCBSelectorResolver.h" />
|
||||
<ClInclude Include="..\CCBSequence.h" />
|
||||
<ClInclude Include="..\CCBSequenceProperty.h" />
|
||||
<ClInclude Include="..\CCBValue.h" />
|
||||
<ClInclude Include="..\CCControlButtonLoader.h" />
|
||||
<ClInclude Include="..\CCControlLoader.h" />
|
||||
<ClInclude Include="..\CCLabelBMFontLoader.h" />
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
<ClCompile Include="..\CCBSequenceProperty.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\CCBValue.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\CCControlButtonLoader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -121,9 +118,6 @@
|
|||
<ClInclude Include="..\CCBSequenceProperty.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\CCBValue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\CCControlButtonLoader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "platform/CCFileUtils.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace network {
|
||||
|
||||
|
@ -42,7 +42,6 @@ static std::mutex s_responseQueueMutex;
|
|||
static std::mutex s_SleepMutex;
|
||||
static std::condition_variable s_SleepCondition;
|
||||
|
||||
static int s_asyncRequestCount = 0;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
typedef int int32_t;
|
||||
|
@ -50,12 +49,12 @@ typedef int int32_t;
|
|||
|
||||
static bool s_need_quit = false;
|
||||
|
||||
static Array* s_requestQueue = NULL;
|
||||
static Array* s_responseQueue = NULL;
|
||||
static Vector<HttpRequest*>* s_requestQueue = nullptr;
|
||||
static Vector<HttpResponse*>* s_responseQueue = nullptr;
|
||||
|
||||
static HttpClient *s_pHttpClient = NULL; // pointer to singleton
|
||||
|
||||
static char s_errorBuffer[CURL_ERROR_SIZE];
|
||||
static char s_errorBuffer[CURL_ERROR_SIZE] = {0};
|
||||
|
||||
typedef size_t (*write_callback)(void *ptr, size_t size, size_t nmemb, void *stream);
|
||||
|
||||
|
@ -96,10 +95,12 @@ static int processDeleteTask(HttpRequest *request, write_callback callback, void
|
|||
|
||||
|
||||
// Worker thread
|
||||
static void networkThread(void)
|
||||
void HttpClient::networkThread()
|
||||
{
|
||||
HttpRequest *request = NULL;
|
||||
|
||||
auto scheduler = Director::getInstance()->getScheduler();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (s_need_quit)
|
||||
|
@ -114,10 +115,10 @@ static void networkThread(void)
|
|||
|
||||
//Get request task from queue
|
||||
|
||||
if (0 != s_requestQueue->count())
|
||||
if (!s_requestQueue->empty())
|
||||
{
|
||||
request = dynamic_cast<HttpRequest*>(s_requestQueue->getObjectAtIndex(0));
|
||||
s_requestQueue->removeObjectAtIndex(0);
|
||||
request = s_requestQueue->at(0);
|
||||
s_requestQueue->remove(0);
|
||||
}
|
||||
|
||||
s_requestQueueMutex.unlock();
|
||||
|
@ -202,26 +203,23 @@ static void networkThread(void)
|
|||
|
||||
// add response packet into queue
|
||||
s_responseQueueMutex.lock();
|
||||
s_responseQueue->addObject(response);
|
||||
s_responseQueue->pushBack(response);
|
||||
s_responseQueueMutex.unlock();
|
||||
|
||||
// resume dispatcher selector
|
||||
Director::getInstance()->getScheduler()->resumeTarget(HttpClient::getInstance());
|
||||
scheduler->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this));
|
||||
}
|
||||
|
||||
// cleanup: if worker thread received quit signal, clean up un-completed request queue
|
||||
s_requestQueueMutex.lock();
|
||||
s_requestQueue->removeAllObjects();
|
||||
s_requestQueue->clear();
|
||||
s_requestQueueMutex.unlock();
|
||||
|
||||
s_asyncRequestCount -= s_requestQueue->count();
|
||||
|
||||
if (s_requestQueue != NULL) {
|
||||
|
||||
s_requestQueue->release();
|
||||
s_requestQueue = NULL;
|
||||
s_responseQueue->release();
|
||||
s_responseQueue = NULL;
|
||||
if (s_requestQueue != nullptr) {
|
||||
delete s_requestQueue;
|
||||
s_requestQueue = nullptr;
|
||||
delete s_responseQueue;
|
||||
s_responseQueue = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -399,7 +397,6 @@ HttpClient* HttpClient::getInstance()
|
|||
void HttpClient::destroyInstance()
|
||||
{
|
||||
CCASSERT(s_pHttpClient, "");
|
||||
Director::getInstance()->getScheduler()->unscheduleSelector(schedule_selector(HttpClient::dispatchResponseCallbacks), s_pHttpClient);
|
||||
s_pHttpClient->release();
|
||||
}
|
||||
|
||||
|
@ -416,9 +413,6 @@ HttpClient::HttpClient()
|
|||
: _timeoutForConnect(30)
|
||||
, _timeoutForRead(60)
|
||||
{
|
||||
Director::getInstance()->getScheduler()->scheduleSelector(
|
||||
schedule_selector(HttpClient::dispatchResponseCallbacks), this, 0, false);
|
||||
Director::getInstance()->getScheduler()->pauseTarget(this);
|
||||
}
|
||||
|
||||
HttpClient::~HttpClient()
|
||||
|
@ -439,14 +433,10 @@ bool HttpClient::lazyInitThreadSemphore()
|
|||
return true;
|
||||
} else {
|
||||
|
||||
s_requestQueue = new Array();
|
||||
s_requestQueue->init();
|
||||
s_requestQueue = new Vector<HttpRequest*>();
|
||||
s_responseQueue = new Vector<HttpResponse*>();
|
||||
|
||||
s_responseQueue = new Array();
|
||||
s_responseQueue->init();
|
||||
|
||||
|
||||
auto t = std::thread(&networkThread);
|
||||
auto t = std::thread(CC_CALLBACK_0(HttpClient::networkThread, this));
|
||||
t.detach();
|
||||
|
||||
s_need_quit = false;
|
||||
|
@ -468,12 +458,10 @@ void HttpClient::send(HttpRequest* request)
|
|||
return;
|
||||
}
|
||||
|
||||
++s_asyncRequestCount;
|
||||
|
||||
request->retain();
|
||||
|
||||
s_requestQueueMutex.lock();
|
||||
s_requestQueue->addObject(request);
|
||||
s_requestQueue->pushBack(request);
|
||||
s_requestQueueMutex.unlock();
|
||||
|
||||
// Notify thread start to work
|
||||
|
@ -481,7 +469,7 @@ void HttpClient::send(HttpRequest* request)
|
|||
}
|
||||
|
||||
// Poll and notify main thread if responses exists in queue
|
||||
void HttpClient::dispatchResponseCallbacks(float delta)
|
||||
void HttpClient::dispatchResponseCallbacks()
|
||||
{
|
||||
// log("CCHttpClient::dispatchResponseCallbacks is running");
|
||||
|
||||
|
@ -489,18 +477,16 @@ void HttpClient::dispatchResponseCallbacks(float delta)
|
|||
|
||||
s_responseQueueMutex.lock();
|
||||
|
||||
if (s_responseQueue->count())
|
||||
if (!s_responseQueue->empty())
|
||||
{
|
||||
response = dynamic_cast<HttpResponse*>(s_responseQueue->getObjectAtIndex(0));
|
||||
s_responseQueue->removeObjectAtIndex(0);
|
||||
response = s_responseQueue->at(0);
|
||||
s_responseQueue->remove(0);
|
||||
}
|
||||
|
||||
s_responseQueueMutex.unlock();
|
||||
|
||||
if (response)
|
||||
{
|
||||
--s_asyncRequestCount;
|
||||
|
||||
HttpRequest *request = response->getHttpRequest();
|
||||
Object *pTarget = request->getTarget();
|
||||
SEL_HttpResponse pSelector = request->getSelector();
|
||||
|
@ -512,12 +498,6 @@ void HttpClient::dispatchResponseCallbacks(float delta)
|
|||
|
||||
response->release();
|
||||
}
|
||||
|
||||
if (0 == s_asyncRequestCount)
|
||||
{
|
||||
Director::getInstance()->getScheduler()->pauseTarget(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -99,8 +99,9 @@ private:
|
|||
* @return bool
|
||||
*/
|
||||
bool lazyInitThreadSemphore();
|
||||
void networkThread();
|
||||
/** Poll function called from main thread to dispatch callbacks when http requests finished **/
|
||||
void dispatchResponseCallbacks(float delta);
|
||||
void dispatchResponseCallbacks();
|
||||
|
||||
private:
|
||||
int _timeoutForConnect;
|
||||
|
|
|
@ -403,7 +403,7 @@ Vector<PhysicsShape*> PhysicsWorld::getShapes(const Point& point) const
|
|||
(cpSpaceNearestPointQueryFunc)PhysicsWorldCallback::getShapesAtPointFunc,
|
||||
&arr);
|
||||
|
||||
return std::move(arr);
|
||||
return arr;
|
||||
}
|
||||
|
||||
PhysicsShape* PhysicsWorld::getShape(const Point& point) const
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4001693a86e1887ab2a9036aa678ad3b14b2f1b2
|
||||
Subproject commit d8bd5f3e890e578deeeeb39889359935da7dc55c
|
|
@ -29,11 +29,7 @@ extern "C" {
|
|||
#include "lua.h"
|
||||
}
|
||||
|
||||
#include "ccTypes.h"
|
||||
#include "CCObject.h"
|
||||
#include "CCTouch.h"
|
||||
#include "CCSet.h"
|
||||
#include "CCNode.h"
|
||||
#include "cocos2d.h"
|
||||
#include "CCScriptSupport.h"
|
||||
#include "CCLuaStack.h"
|
||||
#include "CCLuaValue.h"
|
||||
|
|
|
@ -29,8 +29,7 @@ extern "C" {
|
|||
#include "lua.h"
|
||||
}
|
||||
|
||||
#include "ccTypes.h"
|
||||
#include "CCObject.h"
|
||||
#include "cocos2d.h"
|
||||
#include "CCLuaValue.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
|
|
@ -890,7 +890,7 @@ bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue)
|
|||
}
|
||||
else if(lua_isstring(L, -1))
|
||||
{
|
||||
if(luaval_to_std_string(L, -2, &stringValue))
|
||||
if(luaval_to_std_string(L, -1, &stringValue))
|
||||
{
|
||||
dict->setObject(String::create(stringValue), stringKey);
|
||||
}
|
||||
|
@ -1022,6 +1022,379 @@ bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret)
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, cocos2d::ValueVector* ret)
|
||||
{
|
||||
if (nullptr == L || argc == 0 )
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
if(lua_istable(L, i + 2))
|
||||
{
|
||||
lua_pushnumber(L, 1);
|
||||
lua_gettable(L, i + 2);
|
||||
if (lua_isnil(L, -1) )
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueMap dictVal;
|
||||
if (luaval_to_ccvaluemap(L, i + 2, &dictVal))
|
||||
{
|
||||
ret->push_back(Value(dictVal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueVector arrVal;
|
||||
if(luaval_to_ccvaluevector(L, i + 2, &arrVal))
|
||||
{
|
||||
ret->push_back(Value(arrVal));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(lua_isstring(L, i + 2))
|
||||
{
|
||||
std::string stringValue = "";
|
||||
if(luaval_to_std_string(L, i + 2, &stringValue) )
|
||||
{
|
||||
ret->push_back(Value(stringValue));
|
||||
}
|
||||
}
|
||||
else if(lua_isboolean(L, i + 2))
|
||||
{
|
||||
bool boolVal = false;
|
||||
if (luaval_to_boolean(L, i + 2, &boolVal))
|
||||
{
|
||||
ret->push_back(Value(boolVal));
|
||||
}
|
||||
}
|
||||
else if(lua_isnumber(L, i + 2))
|
||||
{
|
||||
ret->push_back(Value(tolua_tonumber(L, i + 2, 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "not supported type");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool luaval_to_ccvalue(lua_State* L, int lo, cocos2d::Value* ret)
|
||||
{
|
||||
if ( nullptr == L || nullptr == ret)
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
|
||||
if (tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
lua_pushnumber(L,1);
|
||||
lua_gettable(L,lo);
|
||||
|
||||
if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueMap dictVal;
|
||||
if (luaval_to_ccvaluemap(L, lo, &dictVal))
|
||||
{
|
||||
*ret = Value(dictVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueVector arrVal;
|
||||
if (luaval_to_ccvaluevector(L, lo, &arrVal))
|
||||
{
|
||||
*ret = Value(arrVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tolua_isstring(L, lo, 0, &tolua_err))
|
||||
{
|
||||
std::string stringValue = "";
|
||||
if (luaval_to_std_string(L, lo, &stringValue))
|
||||
{
|
||||
*ret = Value(stringValue);
|
||||
}
|
||||
}
|
||||
else if (tolua_isboolean(L, lo, 0, &tolua_err))
|
||||
{
|
||||
bool boolVal = false;
|
||||
if (luaval_to_boolean(L, lo, &boolVal))
|
||||
{
|
||||
*ret = Value(boolVal);
|
||||
}
|
||||
}
|
||||
else if (tolua_isnumber(L, lo, 0, &tolua_err))
|
||||
{
|
||||
*ret = Value(tolua_tonumber(L, lo, 0));
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool luaval_to_ccvaluemap(lua_State* L, int lo, cocos2d::ValueMap* ret)
|
||||
{
|
||||
if ( nullptr == L || nullptr == ret)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
std::string stringKey = "";
|
||||
std::string stringValue = "";
|
||||
bool boolVal = false;
|
||||
ValueMap& dict = *ret;
|
||||
lua_pushnil(L); /* first key L: lotable ..... nil */
|
||||
while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */
|
||||
{
|
||||
if (!lua_isstring(L, -2))
|
||||
{
|
||||
lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/
|
||||
continue;
|
||||
}
|
||||
|
||||
if(luaval_to_std_string(L, -2, &stringKey))
|
||||
{
|
||||
|
||||
if(lua_istable(L, -1))
|
||||
{
|
||||
lua_pushnumber(L,1);
|
||||
lua_gettable(L,-2);
|
||||
|
||||
if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueMap dictVal;
|
||||
if (luaval_to_ccvaluemap(L, -1, &dictVal))
|
||||
{
|
||||
dict[stringKey] = Value(dictVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueVector arrVal;
|
||||
if (luaval_to_ccvaluevector(L, -1, &arrVal))
|
||||
{
|
||||
dict[stringKey] = Value(arrVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(lua_isstring(L, -1))
|
||||
{
|
||||
if(luaval_to_std_string(L, -1, &stringValue))
|
||||
{
|
||||
dict[stringKey] = Value(stringValue);
|
||||
}
|
||||
}
|
||||
else if(lua_isboolean(L, -1))
|
||||
{
|
||||
if (luaval_to_boolean(L, -1, &boolVal))
|
||||
{
|
||||
dict[stringKey] = Value(boolVal);
|
||||
}
|
||||
}
|
||||
else if(lua_isnumber(L, -1))
|
||||
{
|
||||
dict[stringKey] = Value(tolua_tonumber(L, -1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "not supported type");
|
||||
}
|
||||
}
|
||||
|
||||
lua_pop(L, 1); /* L: lotable ..... key */
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool luaval_to_ccintvaluemap(lua_State* L, int lo, cocos2d::IntValueMap* ret)
|
||||
{
|
||||
if (nullptr == L || nullptr == ret)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
std::string stringKey = "";
|
||||
std::string stringValue = "";
|
||||
int intKey = 0;
|
||||
bool boolVal = false;
|
||||
IntValueMap& dict = *ret;
|
||||
lua_pushnil(L); /* first key L: lotable ..... nil */
|
||||
while ( 0 != lua_next(L, lo ) ) /* L: lotable ..... key value */
|
||||
{
|
||||
if (!lua_isstring(L, -2))
|
||||
{
|
||||
lua_pop(L, 1); /* removes 'value'; keep 'key' for next iteration*/
|
||||
continue;
|
||||
}
|
||||
|
||||
if(luaval_to_std_string(L, -2, &stringKey))
|
||||
{
|
||||
intKey = atoi(stringKey.c_str());
|
||||
if(lua_istable(L, -1))
|
||||
{
|
||||
lua_pushnumber(L,1);
|
||||
lua_gettable(L,-2);
|
||||
|
||||
if (lua_isnil(L, -1) ) /** if table[1] = nil,we don't think it is a pure array */
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueMap dictVal;
|
||||
if (luaval_to_ccvaluemap(L, -1, &dictVal))
|
||||
{
|
||||
dict[intKey] = Value(dictVal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueVector arrVal;
|
||||
if (luaval_to_ccvaluevector(L, -1, &arrVal))
|
||||
{
|
||||
dict[intKey] = Value(arrVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(lua_isstring(L, -1))
|
||||
{
|
||||
if(luaval_to_std_string(L, -1, &stringValue))
|
||||
{
|
||||
dict[intKey] = Value(stringValue);
|
||||
}
|
||||
}
|
||||
else if(lua_isboolean(L, -1))
|
||||
{
|
||||
if (luaval_to_boolean(L, -1, &boolVal))
|
||||
{
|
||||
dict[intKey] = Value(boolVal);
|
||||
}
|
||||
}
|
||||
else if(lua_isnumber(L, -1))
|
||||
{
|
||||
dict[intKey] = Value(tolua_tonumber(L, -1, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "not supported type");
|
||||
}
|
||||
}
|
||||
|
||||
lua_pop(L, 1); /* L: lotable ..... key */
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret)
|
||||
{
|
||||
if (nullptr == L || nullptr == ret)
|
||||
return false;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
bool ok = true;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err))
|
||||
{
|
||||
#if COCOS2D_DEBUG >=1
|
||||
luaval_to_native_err(L,"#ferror:",&tolua_err);
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, lo);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L,i + 1);
|
||||
lua_gettable(L,lo);
|
||||
if (lua_isnil(L,-1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(lua_istable(L, -1))
|
||||
{
|
||||
lua_pushnumber(L,1);
|
||||
lua_gettable(L,-2);
|
||||
if (lua_isnil(L, -1) )
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueMap dictVal;
|
||||
if (luaval_to_ccvaluemap(L, -1, &dictVal))
|
||||
{
|
||||
ret->push_back(Value(dictVal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pop(L,1);
|
||||
ValueVector arrVal;
|
||||
if(luaval_to_ccvaluevector(L, -1, &arrVal))
|
||||
{
|
||||
ret->push_back(Value(arrVal));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(lua_isstring(L, -1))
|
||||
{
|
||||
std::string stringValue = "";
|
||||
if(luaval_to_std_string(L, -1, &stringValue) )
|
||||
{
|
||||
ret->push_back(Value(stringValue));
|
||||
}
|
||||
}
|
||||
else if(lua_isboolean(L, -1))
|
||||
{
|
||||
bool boolVal = false;
|
||||
if (luaval_to_boolean(L, -1, &boolVal))
|
||||
{
|
||||
ret->push_back(Value(boolVal));
|
||||
}
|
||||
}
|
||||
else if(lua_isnumber(L, -1))
|
||||
{
|
||||
ret->push_back(Value(tolua_tonumber(L, -1, 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "not supported type");
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void point_to_luaval(lua_State* L,const Point& pt)
|
||||
{
|
||||
if (NULL == L)
|
||||
|
@ -1376,3 +1749,249 @@ void dictionary_to_luaval(lua_State* L, Dictionary* dict)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue)
|
||||
{
|
||||
const Value& obj = inValue;
|
||||
switch (obj.getType())
|
||||
{
|
||||
case Value::Type::BOOLEAN:
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
break;
|
||||
case Value::Type::FLOAT:
|
||||
case Value::Type::DOUBLE:
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
break;
|
||||
case Value::Type::STRING:
|
||||
lua_pushstring(L, obj.asString().c_str());
|
||||
break;
|
||||
case Value::Type::VECTOR:
|
||||
ccvaluevector_to_luaval(L, obj.asValueVector());
|
||||
break;
|
||||
case Value::Type::MAP:
|
||||
ccvaluemap_to_luaval(L, obj.asValueMap());
|
||||
break;
|
||||
case Value::Type::INT_KEY_MAP:
|
||||
ccintvaluemap_to_luaval(L, obj.asIntKeyMap());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
for (auto iter = inValue.begin(); iter != inValue.end(); ++iter)
|
||||
{
|
||||
std::string key = iter->first;
|
||||
const Value& obj = iter->second;
|
||||
switch (obj.getType())
|
||||
{
|
||||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::FLOAT:
|
||||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::STRING:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushstring(L, obj.asString().c_str());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::VECTOR:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccvaluevector_to_luaval(L, obj.asValueVector());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::MAP:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccvaluemap_to_luaval(L, obj.asValueMap());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INT_KEY_MAP:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccintvaluemap_to_luaval(L, obj.asIntKeyMap());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void ccintvaluemap_to_luaval(lua_State* L, const cocos2d::IntValueMap& inValue)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
for (auto iter = inValue.begin(); iter != inValue.end(); ++iter)
|
||||
{
|
||||
std::stringstream keyss;
|
||||
keyss << iter->first;
|
||||
std::string key = keyss.str();
|
||||
|
||||
const Value& obj = iter->second;
|
||||
|
||||
switch (obj.getType())
|
||||
{
|
||||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::FLOAT:
|
||||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushinteger(L, obj.asInt());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::STRING:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
lua_pushstring(L, obj.asString().c_str());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::VECTOR:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccvaluevector_to_luaval(L, obj.asValueVector());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::MAP:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccvaluemap_to_luaval(L, obj.asValueMap());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
case Value::Type::INT_KEY_MAP:
|
||||
{
|
||||
lua_pushstring(L, key.c_str());
|
||||
ccintvaluemap_to_luaval(L, obj.asIntKeyMap());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
int index = 1;
|
||||
for (const auto& obj : inValue)
|
||||
{
|
||||
switch (obj.getType())
|
||||
{
|
||||
case Value::Type::BOOLEAN:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushboolean(L, obj.asBool());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::FLOAT:
|
||||
case Value::Type::DOUBLE:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushnumber(L, obj.asDouble());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::INTEGER:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushnumber(L, obj.asInt());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::STRING:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
lua_pushstring(L, obj.asString().c_str());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::VECTOR:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
ccvaluevector_to_luaval(L, obj.asValueVector());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::MAP:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
ccvaluemap_to_luaval(L, obj.asValueMap());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
case Value::Type::INT_KEY_MAP:
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)index);
|
||||
ccintvaluemap_to_luaval(L, obj.asIntKeyMap());
|
||||
lua_rawset(L, -3);
|
||||
++index;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "tolua++.h"
|
||||
#include "tolua_fix.h"
|
||||
}
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
@ -44,6 +45,78 @@ extern bool luaval_to_array(lua_State* L,int lo, Array** outValue);
|
|||
extern bool luaval_to_dictionary(lua_State* L,int lo, Dictionary** outValue);
|
||||
extern bool luaval_to_array_of_Point(lua_State* L,int lo,Point **points, int *numPoints);
|
||||
extern bool luavals_variadic_to_array(lua_State* L,int argc, Array** ret);
|
||||
extern bool luavals_variadic_to_ccvaluevector(lua_State* L, int argc, cocos2d::ValueVector* ret);
|
||||
|
||||
template <class T>
|
||||
bool luavals_variadic_to_ccvector( lua_State* L, int argc, cocos2d::Vector<T>* ret)
|
||||
{
|
||||
if (nullptr == L || argc == 0 )
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
if (lua_isuserdata(L, i + 2))
|
||||
{
|
||||
tolua_Error err;
|
||||
//Undo check
|
||||
if (!tolua_isusertype(L, i + 2, "Object", 0, &err))
|
||||
{
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
T obj = static_cast<T>(tolua_tousertype(L, i + 2, nullptr));
|
||||
ret->pushBack(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool luaval_to_ccvector(lua_State* L, int lo , cocos2d::Vector<T>* ret)
|
||||
{
|
||||
if (nullptr == L || nullptr == ret)
|
||||
return false;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
tolua_Error tolua_err;
|
||||
if (!tolua_istable(L, lo, 0, &tolua_err) )
|
||||
ok = false;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
size_t len = lua_objlen(L, lo);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_gettable(L, lo);
|
||||
|
||||
if (lua_isnil(L, -1) || !lua_isuserdata(L, -1))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
T cobj = static_cast<T>(tolua_tousertype(L, -1, NULL) );
|
||||
if (NULL != cobj)
|
||||
ret->pushBack(cobj);
|
||||
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
extern bool luaval_to_ccvalue(lua_State* L, int lo, cocos2d::Value* ret);
|
||||
extern bool luaval_to_ccvaluemap(lua_State* L, int lo, cocos2d::ValueMap* ret);
|
||||
extern bool luaval_to_ccintvaluemap(lua_State* L, int lo, cocos2d::IntValueMap* ret);
|
||||
extern bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret);
|
||||
|
||||
|
||||
// from native
|
||||
extern void point_to_luaval(lua_State* L,const Point& pt);
|
||||
|
@ -56,4 +129,42 @@ extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValu
|
|||
extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue);
|
||||
extern void array_to_luaval(lua_State* L,Array* inValue);
|
||||
extern void dictionary_to_luaval(lua_State* L, Dictionary* dict);
|
||||
|
||||
template <class T>
|
||||
void ccvector_to_luaval(lua_State* L,const cocos2d::Vector<T>& inValue)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
||||
if (nullptr == L)
|
||||
return;
|
||||
|
||||
int indexTable = 1;
|
||||
for (const auto& obj : inValue)
|
||||
{
|
||||
if (nullptr == obj)
|
||||
continue;
|
||||
|
||||
|
||||
if (nullptr != dynamic_cast<cocos2d::Object *>(obj))
|
||||
{
|
||||
long typeId = typeid(*obj).hash_code();
|
||||
auto iter = g_luaType.find(typeId);
|
||||
if (g_luaType.end() == iter)
|
||||
{
|
||||
lua_pushnumber(L, (lua_Number)indexTable);
|
||||
int ID = (obj) ? (int)obj->_ID : -1;
|
||||
int* luaID = (obj) ? &obj->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(L, ID, luaID, (void*)obj,iter->second.c_str());
|
||||
lua_rawset(L, -3);
|
||||
obj->retain();
|
||||
++indexTable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue);
|
||||
void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue);
|
||||
void ccintvaluemap_to_luaval(lua_State* L, const cocos2d::IntValueMap& inValue);
|
||||
void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue);
|
||||
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|
||||
|
|
|
@ -17,6 +17,68 @@ extern "C" {
|
|||
USING_NS_CC;
|
||||
USING_NS_CC_EXT;
|
||||
|
||||
template <class T>
|
||||
bool array_to_vector_t_deprecated(Array& array,Vector<T>& vec)
|
||||
{
|
||||
if ( 0 == array.count() )
|
||||
return false;
|
||||
|
||||
vec.clear();
|
||||
|
||||
for (int i = 0; i < array.count() ; i++)
|
||||
{
|
||||
T obj = dynamic_cast<T>(array.getObjectAtIndex(i));
|
||||
if (nullptr != obj)
|
||||
vec.pushBack(obj);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool array_to_valuevector_deprecated(Array& array,ValueVector& valueVec)
|
||||
{
|
||||
if (0 == array.count())
|
||||
return false;
|
||||
|
||||
valueVec.clear();
|
||||
|
||||
String* strVal = nullptr;
|
||||
Double* doubleVal = nullptr;
|
||||
Bool* boolVal = nullptr;
|
||||
Float* floatVal = nullptr;
|
||||
Integer* intVal = nullptr;
|
||||
|
||||
for (int i = 0; i < array.count(); i++)
|
||||
{
|
||||
if( (strVal = dynamic_cast<cocos2d::String *>(array.getObjectAtIndex(i))))
|
||||
{
|
||||
valueVec.push_back(Value(strVal->getCString()));
|
||||
}
|
||||
else if ((doubleVal = dynamic_cast<cocos2d::Double*>(array.getObjectAtIndex(i))))
|
||||
{
|
||||
valueVec.push_back(Value(doubleVal->getValue()));
|
||||
}
|
||||
else if ((floatVal = dynamic_cast<cocos2d::Float*>(array.getObjectAtIndex(i))))
|
||||
{
|
||||
valueVec.push_back(Value(floatVal->getValue()));
|
||||
}
|
||||
else if ((intVal = dynamic_cast<cocos2d::Integer*>(array.getObjectAtIndex(i))))
|
||||
{
|
||||
valueVec.push_back(Value(intVal->getValue()));
|
||||
}
|
||||
else if ((boolVal = dynamic_cast<cocos2d::Bool*>(array.getObjectAtIndex(i))))
|
||||
{
|
||||
valueVec.push_back(Value(boolVal->getValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
CCASSERT(false, "the type isn't suppored.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define deprecatedClassTip(className) CCLOG("%s will be not binded in lua,please use the lua's table instead",className)
|
||||
#define deprecatedFunctionTip(oldFun,newFun) CCLOG("%s was deprecated please use %s instead ",oldFun, newFun)
|
||||
static int tolua_Cocos2d_CCPoint_new00(lua_State* tolua_S)
|
||||
|
@ -1877,13 +1939,14 @@ static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated00(lua_State
|
|||
else
|
||||
{
|
||||
Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
Vector<SpriteFrame*> vec;
|
||||
array_to_vector_t_deprecated(*arrayOfSpriteFrameNames, vec);
|
||||
float delay = ((float) tolua_tonumber(tolua_S,3,0));
|
||||
{
|
||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(arrayOfSpriteFrameNames,delay);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
||||
}
|
||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec,delay);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
||||
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
|
@ -1902,12 +1965,13 @@ static int tolua_cocos2d_Animation_createWithSpriteFrames_deprecated01(lua_State
|
|||
else
|
||||
{
|
||||
Array* arrayOfSpriteFrameNames = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(arrayOfSpriteFrameNames);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
||||
}
|
||||
Vector<SpriteFrame*> vec;
|
||||
array_to_vector_t_deprecated(*arrayOfSpriteFrameNames, vec);
|
||||
cocos2d::Animation* tolua_ret = (cocos2d::Animation*) cocos2d::Animation::createWithSpriteFrames(vec);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Animation");
|
||||
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
|
@ -1973,12 +2037,12 @@ static int tolua_Cocos2d_Sequence_create_deprecated00(lua_State* tolua_S)
|
|||
else
|
||||
{
|
||||
Array* actions = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
Sequence* tolua_ret = (Sequence*) Sequence::create(actions);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence");
|
||||
}
|
||||
Vector<FiniteTimeAction*> vec;
|
||||
array_to_vector_t_deprecated(*actions, vec);
|
||||
Sequence* tolua_ret = (Sequence*) Sequence::create(vec);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Sequence");
|
||||
}
|
||||
return 1;
|
||||
tolua_lerror:
|
||||
|
@ -2113,13 +2177,13 @@ static int tolua_cocos2d_Menu_createWithArray00(lua_State* tolua_S)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
Array* pArrayOfItems = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
Menu* tolua_ret = (Menu*) Menu::createWithArray(pArrayOfItems);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
||||
}
|
||||
Array* arrayOfItems = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
Vector<MenuItem*> vec;
|
||||
array_to_vector_t_deprecated(*arrayOfItems, vec);
|
||||
Menu* tolua_ret = (Menu*) Menu::createWithArray(vec);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"Menu");
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -2147,9 +2211,9 @@ static int tolua_cocos2d_Menu_alignItemsInColumnsWithArray00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInColumnsWithArray'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->alignItemsInColumnsWithArray(rows);
|
||||
}
|
||||
ValueVector valueVector;
|
||||
array_to_valuevector_deprecated(*rows, valueVector);
|
||||
self->alignItemsInColumnsWithArray(valueVector);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -2178,9 +2242,9 @@ static int tolua_cocos2d_Menu_alignItemsInRowsWithArray00(lua_State* tolua_S)
|
|||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'alignItemsInRowsWithArray'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->alignItemsInRowsWithArray(columns);
|
||||
}
|
||||
ValueVector valueVector;
|
||||
array_to_valuevector_deprecated(*columns, valueVector);
|
||||
self->alignItemsInRowsWithArray(valueVector);
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
@ -2218,12 +2282,13 @@ static int tolua_cocos2d_LayerMultiplex_createWithArray00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
Array* arrayOfLayers = ((Array*) tolua_tousertype(tolua_S,2,0));
|
||||
{
|
||||
LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(arrayOfLayers);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex");
|
||||
}
|
||||
Vector<Layer*> vec;
|
||||
array_to_vector_t_deprecated(*arrayOfLayers, vec);
|
||||
LayerMultiplex* tolua_ret = (LayerMultiplex*) LayerMultiplex::createWithArray(vec);
|
||||
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
|
||||
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
|
||||
toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret,"LayerMultiplex");
|
||||
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
|
|
|
@ -1 +1 @@
|
|||
270dc280a6f338f52b0147dc00421c5478941304
|
||||
71bf75a1f1e308193a359970e79f9b939e2541f4
|
|
@ -68,7 +68,7 @@ function cc.pCross(self,other)
|
|||
end
|
||||
|
||||
function cc.pDot(self,other)
|
||||
return self.x * other.x - self.y * other.y
|
||||
return self.x * other.x + self.y * other.y
|
||||
end
|
||||
|
||||
function cc.pToAngleSelf(self)
|
||||
|
@ -139,11 +139,11 @@ end
|
|||
function cc.pUnrotate(pt1, pt2)
|
||||
return { x = pt1.x * pt2.x + pt1.y * pt2.y, pt1.y * pt2.x - pt1.x * pt2.y }
|
||||
end
|
||||
|
||||
--Calculates the square length of pt
|
||||
function cc.pLengthSQ(pt)
|
||||
return cc.pDot(pt)
|
||||
end
|
||||
|
||||
--Calculates the square distance between pt1 and pt2
|
||||
function cc.pDistanceSQ(pt1,pt2)
|
||||
return cc.pLengthSQ(cc.pSub(pt1,pt2))
|
||||
end
|
||||
|
|
|
@ -92,32 +92,32 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(Object * pTarget, const c
|
|||
return false;
|
||||
}
|
||||
|
||||
bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocosbuilder::CCBValue* pCCBValue)
|
||||
bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, const Value& pCCBValue)
|
||||
{
|
||||
bool bRet = false;
|
||||
if (pTarget == this)
|
||||
{
|
||||
if (0 == strcmp(pMemberVariableName, "mCustomPropertyInt"))
|
||||
{
|
||||
this->mCustomPropertyInt = pCCBValue->getIntValue();
|
||||
this->mCustomPropertyInt = pCCBValue.asInt();
|
||||
log("mCustomPropertyInt = %d", mCustomPropertyInt);
|
||||
bRet = true;
|
||||
}
|
||||
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyFloat"))
|
||||
{
|
||||
this->mCustomPropertyFloat = pCCBValue->getFloatValue();
|
||||
this->mCustomPropertyFloat = pCCBValue.asFloat();
|
||||
log("mCustomPropertyFloat = %f", mCustomPropertyFloat);
|
||||
bRet = true;
|
||||
}
|
||||
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyBoolean"))
|
||||
{
|
||||
this->mCustomPropertyBoolean = pCCBValue->getBoolValue();
|
||||
this->mCustomPropertyBoolean = pCCBValue.asBool();
|
||||
log("mCustomPropertyBoolean = %d", mCustomPropertyBoolean);
|
||||
bRet = true;
|
||||
}
|
||||
else if ( 0 == strcmp(pMemberVariableName, "mCustomPropertyString"))
|
||||
{
|
||||
this->mCustomPropertyString = pCCBValue->getStringValue();
|
||||
this->mCustomPropertyString = pCCBValue.asString();
|
||||
log("mCustomPropertyString = %s", mCustomPropertyString.c_str());
|
||||
bRet = true;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class HelloCocosBuilderLayer
|
|||
virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||
virtual cocos2d::extension::Control::Handler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName);
|
||||
virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node);
|
||||
virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocosbuilder::CCBValue* pCCBValue);
|
||||
virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, const cocos2d::Value& pCCBValue);
|
||||
virtual void onNodeLoaded(cocos2d::Node * node, cocosbuilder::NodeLoader * nodeLoader);
|
||||
|
||||
void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::Control::EventType pControlEvent);
|
||||
|
|
|
@ -47,35 +47,28 @@ PongLayer::PongLayer()
|
|||
|
||||
auto paddleTexture = Director::getInstance()->getTextureCache()->addImage(s_Paddle);
|
||||
|
||||
auto paddlesM = Array::createWithCapacity(4);
|
||||
Vector<Paddle*> paddlesM(4);
|
||||
|
||||
Paddle* paddle = Paddle::createWithTexture(paddleTexture);
|
||||
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::bottom().y + 15) );
|
||||
paddlesM->addObject( paddle );
|
||||
paddlesM.pushBack( paddle );
|
||||
|
||||
paddle = Paddle::createWithTexture( paddleTexture );
|
||||
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 15) );
|
||||
paddlesM->addObject( paddle );
|
||||
paddlesM.pushBack( paddle );
|
||||
|
||||
paddle = Paddle::createWithTexture( paddleTexture );
|
||||
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::bottom().y + 100) );
|
||||
paddlesM->addObject( paddle );
|
||||
paddlesM.pushBack( paddle );
|
||||
|
||||
paddle = Paddle::createWithTexture( paddleTexture );
|
||||
paddle->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - kStatusBarHeight - 100) );
|
||||
paddlesM->addObject( paddle );
|
||||
paddlesM.pushBack( paddle );
|
||||
|
||||
_paddles = paddlesM->clone();
|
||||
_paddles->retain();
|
||||
_paddles = paddlesM;
|
||||
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(_paddles, pObj)
|
||||
for (auto& paddle : _paddles)
|
||||
{
|
||||
paddle = static_cast<Paddle*>(pObj);
|
||||
|
||||
if(!paddle)
|
||||
break;
|
||||
|
||||
addChild(paddle);
|
||||
}
|
||||
|
||||
|
@ -85,7 +78,6 @@ PongLayer::PongLayer()
|
|||
PongLayer::~PongLayer()
|
||||
{
|
||||
_ball->release();
|
||||
_paddles->release();
|
||||
}
|
||||
|
||||
void PongLayer::resetAndScoreBallForPlayer(int player)
|
||||
|
@ -101,15 +93,8 @@ void PongLayer::doStep(float delta)
|
|||
{
|
||||
_ball->move(delta);
|
||||
|
||||
Paddle* paddle = NULL;
|
||||
Object* pObj = NULL;
|
||||
CCARRAY_FOREACH(_paddles, pObj)
|
||||
for (auto& paddle : _paddles)
|
||||
{
|
||||
paddle = static_cast<Paddle*>(pObj);
|
||||
|
||||
if(!paddle)
|
||||
break;
|
||||
|
||||
_ball->collideWithPaddle( paddle );
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,12 @@ public:
|
|||
};
|
||||
|
||||
class Ball;
|
||||
class Paddle;
|
||||
class PongLayer : public Layer
|
||||
{
|
||||
private:
|
||||
Ball* _ball;
|
||||
Array* _paddles;
|
||||
Vector<Paddle*> _paddles;
|
||||
Point _ballStartingVelocity;
|
||||
public:
|
||||
PongLayer();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 53cfcb95f4d06af5f484eeda77c9eb5e8b835ec9
|
||||
Subproject commit 59f96e792ab1a1b1a4b01b3ad8a8e7bb1bc281a8
|
|
@ -37,7 +37,7 @@ classes = CCBReader.* CCBAnimationManager.*
|
|||
# functions from all classes.
|
||||
|
||||
skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers],
|
||||
CCBAnimationManager::[setAnimationCompletedCallback],
|
||||
CCBAnimationManager::[setAnimationCompletedCallback addNode],
|
||||
.*Delegate::[*],
|
||||
.*Loader.*::[*],
|
||||
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* onAcc.* onKey.* onRegisterTouchListener]
|
||||
|
|
|
@ -37,7 +37,7 @@ classes = AssetsManager.* CCBReader.* CCBAnimationManager.* Scale9Sprite Control
|
|||
# functions from all classes.
|
||||
|
||||
skip = CCBReader::[^CCBReader$ addOwnerCallbackName isJSControlled readByte getCCBMemberVariableAssigner readFloat getCCBSelectorResolver toLowerCase lastPathComponent deletePathExtension endsWith concat getResolutionScale getAnimatedProperties readBool readInt addOwnerCallbackNode addDocumentCallbackName readCachedString readNodeGraphFromData addDocumentCallbackNode getLoadedSpriteSheet initWithData readFileWithCleanUp getOwner$ readNodeGraphFromFile createSceneWithNodeGraphFromFile getAnimationManagers$ setAnimationManagers],
|
||||
CCBAnimationManager::[setAnimationCompletedCallback setCallFunc],
|
||||
CCBAnimationManager::[setAnimationCompletedCallback setCallFunc addNode],
|
||||
ScrollView::[(g|s)etDelegate$],
|
||||
.*Delegate::[*],
|
||||
.*Loader.*::[*],
|
||||
|
|
|
@ -36,7 +36,7 @@ classes = Armature ArmatureAnimation Skin Bone ArmatureDataManager \w+Data$ UIWi
|
|||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||
# functions from all classes.
|
||||
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc add\w*EventListener],
|
||||
skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*HSV onTouch.* (s|g)etBlendFunc (s|g)etUserObject add\w*EventListener],
|
||||
ArmatureDataManager::[CCArmatureDataManager ~CCArmatureDataManager],
|
||||
Armature::[createBone updateBlendType setBody getShapeList ^getBody$],
|
||||
Skin::[(s|g)etSkinData],
|
||||
|
@ -46,7 +46,6 @@ skip = *::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType .*
|
|||
UILayoutParameter::[(s|g)etMargin],
|
||||
UIHelper::[init],
|
||||
GUIReader::[setPropsForImageButtonFromJsonDictionary],
|
||||
UIWidget::[(s|g)etUserObject],
|
||||
UIImageView::[doubleClickEvent]
|
||||
|
||||
rename_functions = GUIReader::[shareReader=getInstance purgeGUIReader=destroyInstance],
|
||||
|
|
|
@ -50,7 +50,7 @@ elif [ "$PLATFORM"x = "android"x ]; then
|
|||
# Build all samples
|
||||
echo "Building all samples ..."
|
||||
cd $COCOS2DX_ROOT/build
|
||||
./android-build.py -n "NDK_BUG=0 -j10" hellocpp testcpp simplegame testjavascript
|
||||
./android-build.py -n "NDK_BUG=0 -j10" all
|
||||
|
||||
# Build template
|
||||
# echo "Building template ..."
|
||||
|
@ -74,14 +74,14 @@ elif [ "$PLATFORM"x = "linux"x ]; then
|
|||
cd $COCOS2DX_ROOT/build
|
||||
mkdir -p linux-build
|
||||
cd linux-build
|
||||
cmake ../.. -DBUILD_LIBS_LUA=OFF -DBUILD_HelloLua=OFF -DBUILD_TestLua=OFF
|
||||
cmake ../..
|
||||
make -j10
|
||||
cd ../../template/multi-platform-cpp
|
||||
cmake .
|
||||
make -j10
|
||||
# cd ../multi-platform-lua
|
||||
# cmake .
|
||||
# make -j10
|
||||
cd ../multi-platform-lua
|
||||
cmake .
|
||||
make -j10
|
||||
|
||||
elif [ "$PLATFORM"x = "emscripten"x ]; then
|
||||
# Generate binding glue codes
|
||||
|
|
Loading…
Reference in New Issue