mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3-gc-refactor
This commit is contained in:
commit
992245e744
|
@ -1,4 +1,4 @@
|
|||
cocos2d-x-3.2beta0 Jul.2 2014
|
||||
cocos2d-x-3.2rc0 ??
|
||||
[NEW] FastTMXTiledMap: added fast tmx, which is much more faster for static tiled map
|
||||
[NEW] GLProgramState: can use uniform location to get/set uniform values
|
||||
[NEW] HttpClient: added sendImmediate()
|
||||
|
|
|
@ -53,23 +53,7 @@ def check_environment_variables_sdk():
|
|||
return SDK_ROOT
|
||||
|
||||
def select_toolchain_version():
|
||||
'''Because ndk-r8e uses gcc4.6 as default. gcc4.6 doesn't support c++11. So we should select gcc4.7 when
|
||||
using ndk-r8e. But gcc4.7 is removed in ndk-r9, so we should determine whether gcc4.7 exist.
|
||||
Conclution:
|
||||
ndk-r8e -> use gcc4.7
|
||||
ndk-r9 -> use gcc4.8
|
||||
'''
|
||||
|
||||
ndk_root = check_environment_variables()
|
||||
if os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.8")):
|
||||
os.environ['NDK_TOOLCHAIN_VERSION'] = '4.8'
|
||||
print "The Selected NDK toolchain version was 4.8 !"
|
||||
elif os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.7")):
|
||||
os.environ['NDK_TOOLCHAIN_VERSION'] = '4.7'
|
||||
print "The Selected NDK toolchain version was 4.7 !"
|
||||
else:
|
||||
print "Couldn't find the gcc toolchain."
|
||||
exit(1)
|
||||
pass
|
||||
|
||||
def caculate_built_samples(args):
|
||||
''' Compute the sampels to be built
|
||||
|
|
|
@ -237,7 +237,7 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
|
|||
else
|
||||
{
|
||||
//do nothing, do not support
|
||||
CCASSERT(0, "TMX invalid value");
|
||||
//CCASSERT(0, "TMX invalid value");
|
||||
}
|
||||
|
||||
_indicesVertexZNumber.clear();
|
||||
|
@ -264,9 +264,8 @@ void FastTMXLayer::updateTiles(const Rect& culledRect)
|
|||
int offset = iter->second;
|
||||
iter->second++;
|
||||
|
||||
//CC_ASSERT(_tileToQuadIndex.find(tileIndex) != _tileToQuadIndex.end() && _tileToQuadIndex[tileIndex] <= _totalQuads.size()-1);
|
||||
int quadIndex = (int)_tileToQuadIndex[tileIndex];
|
||||
|
||||
int quadIndex = _tileToQuadIndex[tileIndex];
|
||||
CC_ASSERT(-1 != quadIndex);
|
||||
_indices[6 * offset + 0] = quadIndex * 4 + 0;
|
||||
_indices[6 * offset + 1] = quadIndex * 4 + 1;
|
||||
_indices[6 * offset + 2] = quadIndex * 4 + 2;
|
||||
|
@ -387,7 +386,13 @@ Mat4 FastTMXLayer::tileToNodeTransform()
|
|||
}
|
||||
case FAST_TMX_ORIENTATION_HEX:
|
||||
{
|
||||
_tileToNodeTransform = Mat4::IDENTITY;
|
||||
_tileToNodeTransform = Mat4
|
||||
(
|
||||
h * sqrtf(0.75), 0, 0, 0,
|
||||
-h/2, -h, 0, offY,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
return _tileToNodeTransform;
|
||||
}
|
||||
default:
|
||||
|
@ -408,6 +413,7 @@ void FastTMXLayer::updateTotalQuads()
|
|||
_tileToQuadIndex.clear();
|
||||
_totalQuads.resize(int(_layerSize.width * _layerSize.height));
|
||||
_indices.resize(6 * int(_layerSize.width * _layerSize.height));
|
||||
_tileToQuadIndex.resize(int(_layerSize.width * _layerSize.height),-1);
|
||||
_indicesVertexZOffsets.clear();
|
||||
|
||||
int quadIndex = 0;
|
||||
|
@ -617,7 +623,7 @@ int FastTMXLayer::getVertexZForPos(const Vec2& pos)
|
|||
ret = static_cast<int>(-(_layerSize.height-pos.y));
|
||||
break;
|
||||
case FAST_TMX_ORIENTATION_HEX:
|
||||
CCASSERT(0, "TMX Hexa zOrder not supported");
|
||||
CCASSERT(0, "TMX Hexa vertexZ not supported");
|
||||
break;
|
||||
default:
|
||||
CCASSERT(0, "TMX invalid value");
|
||||
|
|
|
@ -239,7 +239,7 @@ protected:
|
|||
Mat4 _tileToNodeTransform;
|
||||
/** data for rendering */
|
||||
bool _quadsDirty;
|
||||
std::unordered_map<ssize_t, ssize_t> _tileToQuadIndex;
|
||||
std::vector<int> _tileToQuadIndex;
|
||||
std::vector<V3F_C4B_T2F_Quad> _totalQuads;
|
||||
std::vector<int> _indices;
|
||||
std::map<int/*vertexZ*/, int/*offset to _indices by quads*/> _indicesVertexZOffsets;
|
||||
|
|
|
@ -861,25 +861,24 @@ void Node::enumerateChildren(const std::string &name, std::function<bool (Node *
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: support ends with '/..'
|
||||
// End with '/..'?
|
||||
// bool searchFromParent = false;
|
||||
// if (length > 3 &&
|
||||
// name[length-3] == '/' &&
|
||||
// name[length-2] == '.' &&
|
||||
// name[length-1] == '.')
|
||||
// {
|
||||
// searchFromParent = true;
|
||||
// subStrlength -= 3;
|
||||
// }
|
||||
bool searchFromParent = false;
|
||||
if (length > 3 &&
|
||||
name[length-3] == '/' &&
|
||||
name[length-2] == '.' &&
|
||||
name[length-1] == '.')
|
||||
{
|
||||
searchFromParent = true;
|
||||
subStrlength -= 3;
|
||||
}
|
||||
|
||||
// Remove '/', '//' if exist
|
||||
// Remove '/', '//', '/..' if exist
|
||||
std::string newName = name.substr(subStrStartPos, subStrlength);
|
||||
// If search from parent, then add * at first to make it match its children, which will do make
|
||||
// if (searchFromParent)
|
||||
// {
|
||||
// newName.insert(0, "[[:alnum:]]+/");
|
||||
// }
|
||||
|
||||
if (searchFromParent)
|
||||
{
|
||||
newName.insert(0, "[[:alnum:]]+/");
|
||||
}
|
||||
|
||||
if (searchFromRoot)
|
||||
{
|
||||
|
@ -944,14 +943,10 @@ bool Node::doEnumerate(std::string name, std::function<bool (Node *)> callback)
|
|||
needRecursive = true;
|
||||
}
|
||||
|
||||
std::hash<std::string> h;
|
||||
size_t hashOfName = h(searchName);
|
||||
bool ret = false;
|
||||
for (const auto& child : _children)
|
||||
{
|
||||
// TODO: regular expression support
|
||||
// Android doesn't support c++ 11 regular expression well, may use external lib
|
||||
if (hashOfName == child->_hashOfName && searchName.compare(child->_name) == 0)
|
||||
if (std::regex_match(child->_name, std::regex(searchName)))
|
||||
{
|
||||
if (!needRecursive)
|
||||
{
|
||||
|
|
|
@ -714,17 +714,20 @@ public:
|
|||
virtual Node* getChildByName(const std::string& name) const;
|
||||
/** Search the children of the receiving node to perform processing for nodes which share a name.
|
||||
*
|
||||
* @param name The name to search for
|
||||
* @param name The name to search for, supports c++11 regular expression
|
||||
* Search syntax options:
|
||||
* `/` : When placed at the start of the search string, this indicates that the search should be performed on the tree's node.
|
||||
* `//`: Can only be placed at the begin of the search string. This indicates that the search should be performed on the tree's node
|
||||
* and be performed recursively across the entire node tree.
|
||||
* `..`: The search should move up to the node's parent. Can only be placed at the end of string
|
||||
* `/` : When placed anywhere but the start of the search string, this indicates that the search should move to the node's children
|
||||
*
|
||||
* @code
|
||||
* enumerateChildren("/MyName", ...): This searches the root's children and matches any node with the name `MyName`.
|
||||
* enumerateChildren("//MyName", ...): This searches the root's children recursively and matches any node with the name `MyName`.
|
||||
* enumerateChildren("[[:alnum:]]+", ...): This search string matches every node of its children.
|
||||
* enumerateChildren("/MyName", ...): This searches the node tree and matches the parent node of every node named `MyName`.
|
||||
* enumerateChildren("A[[:digit:]]", ...): This searches the node's children and returns any child named `A0`, `A1`, ..., `A9`
|
||||
* enumerateChildren("Abby/Normal", ...): This searches the node's grandchildren and returns any node whose name is `Normal`
|
||||
* and whose parent is named `Abby`.
|
||||
* enumerateChildren("//Abby/Normal", ...): This searches the node tree and returns any node whose name is `Normal` and whose
|
||||
|
|
|
@ -221,10 +221,10 @@ LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static
|
|||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static
|
||||
|
||||
# define the macro to compile through support/zip_support/ioapi.c
|
||||
LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API
|
||||
LOCAL_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations
|
||||
LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API
|
||||
LOCAL_EXPORT_CPPFLAGS := -Wno-literal-suffix -Wno-deprecated-declarations
|
||||
LOCAL_CFLAGS := -DUSE_FILE32API
|
||||
LOCAL_CPPFLAGS := -Wno-deprecated-declarations
|
||||
LOCAL_EXPORT_CFLAGS := -DUSE_FILE32API
|
||||
LOCAL_EXPORT_CPPFLAGS := -Wno-deprecated-declarations
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
|
|
@ -15,7 +15,4 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
|
|||
$(LOCAL_PATH)/../.. \
|
||||
$(LOCAL_PATH)/../../platform/android
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
|
|
@ -35,8 +35,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../2d \
|
|||
$(LOCAL_PATH) \
|
||||
$(LOCAL_PATH)/../../..
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_extension_static
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ static const char* ClassName_Button = "Button";
|
|||
static const char* ClassName_CheckBox = "CheckBox";
|
||||
static const char* ClassName_ImageView = "ImageView";
|
||||
static const char* ClassName_TextAtlas = "TextAtlas";
|
||||
static const char* ClassName_LabelAtlas = "LabelAtlas";
|
||||
static const char* ClassName_LabelBMFont= "LabelBMFont";
|
||||
static const char* ClassName_TextBMFont = "TextBMFont";
|
||||
static const char* ClassName_Text = "Text";
|
||||
static const char* ClassName_LoadingBar = "LoadingBar";
|
||||
|
@ -132,7 +134,8 @@ void NodeReader::init()
|
|||
_funcs.insert(Pair(ClassName_SubGraph, std::bind(&NodeReader::loadSubGraph, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Sprite, std::bind(&NodeReader::loadSprite, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Particle, std::bind(&NodeReader::loadParticle, this, _1)));
|
||||
|
||||
_funcs.insert(Pair(ClassName_LabelAtlas,std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_LabelBMFont,std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Panel, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_Button, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
_funcs.insert(Pair(ClassName_CheckBox, std::bind(&NodeReader::loadWidget, this, _1)));
|
||||
|
|
|
@ -68,8 +68,8 @@ $(LOCAL_PATH)/../../../external \
|
|||
$(LOCAL_PATH)/.. \
|
||||
$(LOCAL_PATH)/../..
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi -fexceptions
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
LOCAL_CFLAGS += -fexceptions
|
||||
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
|
||||
|
|
|
@ -83,7 +83,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
|||
CCLOG("filename == %s",fileName.c_str());
|
||||
cocos2d::Vector<ActionObject*> actionList;
|
||||
|
||||
stExpCocoNode *stChildArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = pCocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode *actionNode = nullptr;
|
||||
for (int i=0; i < pCocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
|
@ -99,7 +99,7 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
|||
ActionObject* action = new ActionObject();
|
||||
action->autorelease();
|
||||
|
||||
action->initWithBinary(cocoLoader, actionNode->GetChildArray(), root);
|
||||
action->initWithBinary(cocoLoader, actionNode->GetChildArray(cocoLoader), root);
|
||||
|
||||
actionList.pushBack(action);
|
||||
}
|
||||
|
|
|
@ -195,11 +195,11 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
stExpCocoNode *stChildNode = cocoNode;
|
||||
|
||||
int actionNodeCount = stChildNode->GetChildNum();
|
||||
stChildNode = stChildNode[0].GetChildArray();
|
||||
stChildNode = stChildNode[0].GetChildArray(cocoLoader);
|
||||
stExpCocoNode *frameListNode = nullptr;
|
||||
for (int i = 0; i < actionNodeCount; ++i) {
|
||||
std::string key = stChildNode[i].GetName(cocoLoader);
|
||||
std::string value = stChildNode[i].GetValue();
|
||||
std::string value = stChildNode[i].GetValue(cocoLoader);
|
||||
if (key == "ActionTag") {
|
||||
setActionTag(valueToInt(value));
|
||||
}else if (key == "actionframelist"){
|
||||
|
@ -208,7 +208,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
}
|
||||
|
||||
int actionFrameCount = frameListNode->GetChildNum();
|
||||
stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray();
|
||||
stExpCocoNode *stFrameChildNode = frameListNode->GetChildArray(cocoLoader);
|
||||
for (int i=0; i<actionFrameCount; i++) {
|
||||
|
||||
int frameIndex;
|
||||
|
@ -225,10 +225,10 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
std::vector<float> frameTweenParameter;
|
||||
|
||||
int framesCount = stFrameChildNode[i].GetChildNum();
|
||||
stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray();
|
||||
stExpCocoNode *innerFrameNode = stFrameChildNode[i].GetChildArray(cocoLoader);
|
||||
for (int j = 0; j < framesCount; j++) {
|
||||
std::string key = innerFrameNode[j].GetName(cocoLoader);
|
||||
std::string value = innerFrameNode[j].GetValue();
|
||||
std::string value = innerFrameNode[j].GetValue(cocoLoader);
|
||||
|
||||
if (key == "frameid") {
|
||||
frameIndex = valueToInt(value);
|
||||
|
@ -237,10 +237,10 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
}else if (key == "tweenParameter"){
|
||||
// There are no tweenParameter args in the json file
|
||||
int tweenParameterCount = innerFrameNode[j].GetChildNum();
|
||||
stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray();
|
||||
stExpCocoNode *tweenParameterArray = innerFrameNode[j].GetChildArray(cocoLoader);
|
||||
for (int k = 0; k < tweenParameterCount; ++k) {
|
||||
std::string t_key = tweenParameterArray[j].GetName(cocoLoader);
|
||||
std::string t_value = tweenParameterArray[j].GetValue();
|
||||
std::string t_value = tweenParameterArray[j].GetValue(cocoLoader);
|
||||
frameTweenParameter.push_back(valueToFloat(t_value));
|
||||
}
|
||||
}else if (key == "positionx"){
|
||||
|
|
|
@ -132,12 +132,12 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader,
|
|||
stExpCocoNode *cocoNode,
|
||||
cocos2d::Ref *root)
|
||||
{
|
||||
stExpCocoNode *stChildNode = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildNode = cocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode *actionNodeList = nullptr;
|
||||
int count = cocoNode->GetChildNum();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
std::string key = stChildNode[i].GetName(cocoLoader);
|
||||
std::string value = stChildNode[i].GetValue();
|
||||
std::string value = stChildNode[i].GetValue(cocoLoader);
|
||||
if (key == "name") {
|
||||
setName(value.c_str());
|
||||
}else if (key == "loop"){
|
||||
|
@ -152,7 +152,7 @@ void ActionObject::initWithBinary(CocoLoader *cocoLoader,
|
|||
if(nullptr != actionNodeList)
|
||||
{
|
||||
int actionNodeCount = actionNodeList->GetChildNum();
|
||||
stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray();
|
||||
stExpCocoNode *actionNodeArray = actionNodeList->GetChildArray(cocoLoader);
|
||||
int maxLength = 0;
|
||||
for (int i=0; i<actionNodeCount; i++) {
|
||||
ActionNode* actionNode = new ActionNode();
|
||||
|
|
|
@ -151,6 +151,7 @@ bool ComAttribute::serialize(void* r)
|
|||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
CocoLoader *cocoLoader = serData->_cocoLoader;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
|
@ -170,14 +171,14 @@ bool ComAttribute::serialize(void* r)
|
|||
}
|
||||
else if (cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
className = cocoNode[1].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *fileData = cocoNode[3].GetChildArray();
|
||||
comName = cocoNode[2].GetValue(cocoLoader);
|
||||
stExpCocoNode *fileData = cocoNode[3].GetChildArray(cocoLoader);
|
||||
CC_BREAK_IF(!fileData);
|
||||
file = fileData[0].GetValue();
|
||||
file = fileData[0].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = atoi(fileData[2].GetValue());
|
||||
resType = atoi(fileData[2].GetValue(cocoLoader));
|
||||
CC_BREAK_IF(resType != 0);
|
||||
}
|
||||
if (comName != nullptr)
|
||||
|
|
|
@ -76,6 +76,7 @@ bool ComAudio::serialize(void* r)
|
|||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
CocoLoader *cocoLoader = serData->_cocoLoader;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
|
@ -97,16 +98,16 @@ bool ComAudio::serialize(void* r)
|
|||
}
|
||||
else if (cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
className = cocoNode[1].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
|
||||
comName = cocoNode[2].GetValue(cocoLoader);
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
|
||||
CC_BREAK_IF(!pfileData);
|
||||
file = pfileData[0].GetValue();
|
||||
file = pfileData[0].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(file == nullptr);
|
||||
resType = atoi(pfileData[2].GetValue());
|
||||
resType = atoi(pfileData[2].GetValue(cocoLoader));
|
||||
CC_BREAK_IF(resType != 0);
|
||||
loop = atoi(cocoNode[5].GetValue()) != 0? true:false;
|
||||
loop = atoi(cocoNode[5].GetValue(cocoLoader)) != 0? true:false;
|
||||
ret = true;
|
||||
}
|
||||
if (comName != nullptr)
|
||||
|
|
|
@ -50,10 +50,12 @@ struct SerData
|
|||
{
|
||||
const rapidjson::Value *_rData;
|
||||
cocostudio::stExpCocoNode *_cocoNode;
|
||||
cocostudio::CocoLoader *_cocoLoader;
|
||||
SerData()
|
||||
{
|
||||
_rData = NULL;
|
||||
_cocoNode = NULL;
|
||||
_cocoLoader = NULL;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -97,6 +97,7 @@ bool ComRender::serialize(void* r)
|
|||
SerData *serData = (SerData *)(r);
|
||||
const rapidjson::Value *v = serData->_rData;
|
||||
stExpCocoNode *cocoNode = serData->_cocoNode;
|
||||
CocoLoader *cocoLoader = serData->_cocoLoader;
|
||||
const char *className = nullptr;
|
||||
const char *comName = nullptr;
|
||||
const char *file = nullptr;
|
||||
|
@ -118,15 +119,15 @@ bool ComRender::serialize(void* r)
|
|||
}
|
||||
else if(cocoNode != nullptr)
|
||||
{
|
||||
className = cocoNode[1].GetValue();
|
||||
className = cocoNode[1].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(className == nullptr);
|
||||
comName = cocoNode[2].GetValue();
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray();
|
||||
comName = cocoNode[2].GetValue(cocoLoader);
|
||||
stExpCocoNode *pfileData = cocoNode[4].GetChildArray(cocoLoader);
|
||||
CC_BREAK_IF(!pfileData);
|
||||
file = pfileData[0].GetValue();
|
||||
plist = pfileData[1].GetValue();
|
||||
file = pfileData[0].GetValue(cocoLoader);
|
||||
plist = pfileData[1].GetValue(cocoLoader);
|
||||
CC_BREAK_IF(file == nullptr && plist == nullptr);
|
||||
resType = atoi(pfileData[2].GetValue());
|
||||
resType = atoi(pfileData[2].GetValue(cocoLoader));
|
||||
}
|
||||
if (comName != nullptr)
|
||||
{
|
||||
|
@ -195,7 +196,7 @@ bool ComRender::serialize(void* r)
|
|||
const char *actionName = nullptr;
|
||||
if (cocoNode != nullptr)
|
||||
{
|
||||
actionName = cocoNode[6].GetValue();//DICTOOL->getStringValue_json(*v, "selectedactionname");
|
||||
actionName = cocoNode[6].GetValue(cocoLoader);//DICTOOL->getStringValue_json(*v, "selectedactionname");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -222,25 +223,25 @@ bool ComRender::serialize(void* r)
|
|||
if (rapidjson::kObjectType == tType)
|
||||
{
|
||||
int count = tpRootCocoNode->GetChildNum();
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
std::string key = tpChildArray[i].GetName(&tCocoLoader);
|
||||
if (key.compare("armature_data") == 0)
|
||||
{
|
||||
int length = tpChildArray[i].GetChildNum();
|
||||
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray();
|
||||
stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
|
||||
if (length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
length = armature_dataArray[0].GetChildNum();
|
||||
stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray();
|
||||
stExpCocoNode *armature_data = armature_dataArray[0].GetChildArray(&tCocoLoader);
|
||||
for (int j = 0; j < length; ++j)
|
||||
{
|
||||
std::string key1 = armature_data[j].GetName(&tCocoLoader);
|
||||
const char *str1 = armature_data[j].GetValue();
|
||||
const char *str1 = armature_data[j].GetValue(&tCocoLoader);
|
||||
if (key.compare("name") == 0)
|
||||
{
|
||||
if (str1 != nullptr)
|
||||
|
@ -252,7 +253,7 @@ bool ComRender::serialize(void* r)
|
|||
const char *actionName = nullptr;
|
||||
if (cocoNode != nullptr)
|
||||
{
|
||||
actionName = cocoNode[6].GetValue();
|
||||
actionName = cocoNode[6].GetValue(&tCocoLoader);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -301,9 +301,9 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)
|
|||
|
||||
// Read content from file
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
bool isbinarysrc = str==".csb";
|
||||
bool isbinaryfilesrc = str==".csb";
|
||||
std::string filemode("r");
|
||||
if(isbinarysrc)
|
||||
if(isbinaryfilesrc)
|
||||
filemode += "b";
|
||||
ssize_t filesize;
|
||||
|
||||
|
@ -324,7 +324,7 @@ void DataReaderHelper::addDataFromFile(const std::string& filePath)
|
|||
{
|
||||
DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo);
|
||||
}
|
||||
else if(str == ".csb")
|
||||
else if(isbinaryfilesrc)
|
||||
{
|
||||
DataReaderHelper::addDataFromBinaryCache(contentStr.c_str(),&dataInfo);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const
|
|||
{
|
||||
data->configType = CocoStudio_JSON;
|
||||
}
|
||||
else if(str == ".csb")
|
||||
else if(isbinaryfilesrc)
|
||||
{
|
||||
data->configType = CocoStudio_Binary;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
|
|||
if (pAsyncStruct->imagePath != "" && pAsyncStruct->plistPath != "")
|
||||
{
|
||||
_getFileMutex.lock();
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str());
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile(pAsyncStruct->plistPath.c_str(), pAsyncStruct->imagePath.c_str(), pDataInfo->filename.c_str());
|
||||
_getFileMutex.unlock();
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
|
|||
{
|
||||
std::string configPath = pDataInfo->configFileQueue.front();
|
||||
_getFileMutex.lock();
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str());
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((pAsyncStruct->baseFilePath + configPath + ".plist").c_str(), (pAsyncStruct->baseFilePath + configPath + ".png").c_str(),pDataInfo->filename.c_str());
|
||||
_getFileMutex.unlock();
|
||||
pDataInfo->configFileQueue.pop();
|
||||
}
|
||||
|
@ -1258,7 +1258,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
|
|||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData);
|
||||
ArmatureDataManager::getInstance()->addArmatureData(armatureData->name.c_str(), armatureData, dataInfo->filename.c_str());
|
||||
armatureData->release();
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
|
@ -1277,7 +1277,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
|
|||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData);
|
||||
ArmatureDataManager::getInstance()->addAnimationData(animationData->name.c_str(), animationData, dataInfo->filename.c_str());
|
||||
animationData->release();
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
|
@ -1296,7 +1296,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
|
|||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
}
|
||||
ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData);
|
||||
ArmatureDataManager::getInstance()->addTextureData(textureData->name.c_str(), textureData, dataInfo->filename.c_str());
|
||||
textureData->release();
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
|
@ -1330,7 +1330,7 @@ void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, Data
|
|||
std::string plistPath = filePath + ".plist";
|
||||
std::string pngPath = filePath + ".png";
|
||||
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str());
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str(), dataInfo->filename.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1750,7 +1750,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
|
||||
if (rapidjson::kObjectType == tType)
|
||||
{
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
|
||||
int nCount = tpRootCocoNode->GetChildNum();
|
||||
|
||||
dataInfo->contentScale = 1.0f;
|
||||
|
@ -1762,12 +1762,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
key = tpChildArray[i].GetName(&tCocoLoader);
|
||||
if (key.compare(CONTENT_SCALE) == 0)
|
||||
{
|
||||
std::string value = tpChildArray[i].GetValue();
|
||||
std::string value = tpChildArray[i].GetValue(&tCocoLoader);
|
||||
dataInfo->contentScale = atof(value.c_str());
|
||||
}
|
||||
else if ( 0 == key.compare(ARMATURE_DATA))
|
||||
{
|
||||
pDataArray = tpChildArray[i].GetChildArray();
|
||||
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
|
||||
length = tpChildArray[i].GetChildNum();
|
||||
ArmatureData * armatureData;
|
||||
for (int ii = 0; ii < length; ++ii)
|
||||
|
@ -1787,7 +1787,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
}
|
||||
else if ( 0 == key.compare(ANIMATION_DATA))
|
||||
{
|
||||
pDataArray = tpChildArray[i].GetChildArray();
|
||||
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
|
||||
length = tpChildArray[i].GetChildNum();
|
||||
AnimationData *animationData;
|
||||
for (int ii = 0; ii < length; ++ii)
|
||||
|
@ -1807,7 +1807,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
}
|
||||
else if (key.compare(TEXTURE_DATA) == 0)
|
||||
{
|
||||
pDataArray = tpChildArray[i].GetChildArray();
|
||||
pDataArray = tpChildArray[i].GetChildArray(&tCocoLoader);
|
||||
length = tpChildArray[i].GetChildNum();
|
||||
for (int ii = 0; ii < length; ++ii)
|
||||
{
|
||||
|
@ -1837,10 +1837,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
continue;
|
||||
}
|
||||
length = tpChildArray[i].GetChildNum();
|
||||
stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray();
|
||||
stExpCocoNode *pConfigFilePath = tpChildArray[i].GetChildArray(&tCocoLoader);
|
||||
for (int ii = 0; ii < length; ii++)
|
||||
{
|
||||
const char *path = pConfigFilePath[ii].GetValue();
|
||||
const char *path = pConfigFilePath[ii].GetValue(&tCocoLoader);
|
||||
if (path == nullptr)
|
||||
{
|
||||
CCLOG("load CONFIG_FILE_PATH error.");
|
||||
|
@ -1872,18 +1872,18 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
ArmatureData *armatureData = new ArmatureData();
|
||||
armatureData->init();
|
||||
stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray();
|
||||
const char *name = pAramtureDataArray[2].GetValue(); //DICTOOL->getStringValue_json(json, A_NAME);
|
||||
stExpCocoNode *pAramtureDataArray = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *name = pAramtureDataArray[2].GetValue(cocoLoader); //DICTOOL->getStringValue_json(json, A_NAME);
|
||||
if(name != nullptr)
|
||||
{
|
||||
armatureData->name = name;
|
||||
}
|
||||
|
||||
float version = atof(pAramtureDataArray[1].GetValue());
|
||||
float version = atof(pAramtureDataArray[1].GetValue(cocoLoader));
|
||||
dataInfo->cocoStudioVersion = armatureData->dataVersion = version; //DICTOOL->getFloatValue_json(json, VERSION, 0.1f);
|
||||
|
||||
int length = pAramtureDataArray[3].GetChildNum(); //DICTOOL->getArrayCount_json(json, BONE_DATA, 0);
|
||||
stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray();
|
||||
stExpCocoNode *pBoneChildren = pAramtureDataArray[3].GetChildArray(cocoLoader);
|
||||
stExpCocoNode* child;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
|
@ -1905,7 +1905,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
decodeNode(boneData, cocoLoader, cocoNode, dataInfo);
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pBoneChildren = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pBoneChildren = cocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode* child;
|
||||
const char *str = nullptr;
|
||||
std::string key;
|
||||
|
@ -1913,7 +1913,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
child = &pBoneChildren[i];
|
||||
key = child->GetName(cocoLoader);
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
if (key.compare(A_NAME) == 0)
|
||||
{
|
||||
//DICTOOL->getStringValue_json(json, A_NAME);
|
||||
|
@ -1933,7 +1933,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
else if (key.compare(DISPLAY_DATA) == 0)
|
||||
{
|
||||
int count = child->GetChildNum();
|
||||
stExpCocoNode *pDisplayData = child->GetChildArray();
|
||||
stExpCocoNode *pDisplayData = child->GetChildArray(cocoLoader);
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
DisplayData *displayData = decodeBoneDisplay(cocoLoader, &pDisplayData[ii], dataInfo);
|
||||
|
@ -1950,16 +1950,16 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
|
||||
DisplayData* DataReaderHelper::decodeBoneDisplay(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, DataInfo *dataInfo)
|
||||
{
|
||||
stExpCocoNode* children = cocoNode->GetChildArray();
|
||||
stExpCocoNode* children = cocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode* child = &children[1];
|
||||
const char *str = nullptr;
|
||||
|
||||
std::string key = child->GetName(cocoLoader);
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
DisplayData *displayData = nullptr;
|
||||
if (key.compare(A_DISPLAY_TYPE) == 0)
|
||||
{
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
DisplayType displayType = (DisplayType)(atoi(str));
|
||||
|
||||
int length = 0;
|
||||
|
@ -1969,12 +1969,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
displayData = new SpriteDisplayData();
|
||||
|
||||
const char *name = children[0].GetValue();
|
||||
const char *name = children[0].GetValue(cocoLoader);
|
||||
if(name != nullptr)
|
||||
{
|
||||
((SpriteDisplayData *)displayData)->displayName = name;
|
||||
}
|
||||
stExpCocoNode *pSkinDataArray = children[2].GetChildArray();
|
||||
stExpCocoNode *pSkinDataArray = children[2].GetChildArray(cocoLoader);
|
||||
if (pSkinDataArray != nullptr)
|
||||
{
|
||||
stExpCocoNode *pSkinData = &pSkinDataArray[0];
|
||||
|
@ -1982,11 +1982,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
SpriteDisplayData *sdd = (SpriteDisplayData *)displayData;
|
||||
length = pSkinData->GetChildNum();
|
||||
stExpCocoNode *SkinDataValue = pSkinData->GetChildArray();
|
||||
stExpCocoNode *SkinDataValue = pSkinData->GetChildArray(cocoLoader);
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
key = SkinDataValue[i].GetName(cocoLoader);
|
||||
str = SkinDataValue[i].GetValue();
|
||||
str = SkinDataValue[i].GetValue(cocoLoader);
|
||||
if (key.compare(A_X) == 0)
|
||||
{
|
||||
sdd->skinData.x = atof(str) * s_PositionReadScale;
|
||||
|
@ -2024,7 +2024,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
displayData = new ArmatureDisplayData();
|
||||
|
||||
const char *name = cocoNode[0].GetValue();
|
||||
const char *name = cocoNode[0].GetValue(cocoLoader);
|
||||
if(name != nullptr)
|
||||
{
|
||||
((ArmatureDisplayData *)displayData)->displayName = name;
|
||||
|
@ -2035,11 +2035,11 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
displayData = new ParticleDisplayData();
|
||||
length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pDisplayData = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pDisplayData = cocoNode->GetChildArray(cocoLoader);
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
key = pDisplayData[i].GetName(cocoLoader);
|
||||
str = pDisplayData[i].GetValue();
|
||||
str = pDisplayData[i].GetValue(cocoLoader);
|
||||
if (key.compare(A_PLIST) == 0)
|
||||
{
|
||||
const char *plist = str;
|
||||
|
@ -2073,7 +2073,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
AnimationData *aniData = new AnimationData();
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pAnimationData = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pAnimationData = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *str = nullptr;
|
||||
std::string key;
|
||||
stExpCocoNode* child;
|
||||
|
@ -2082,7 +2082,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
child = &pAnimationData[i];
|
||||
key = child->GetName(cocoLoader);
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
if (key.compare(A_NAME) == 0)
|
||||
{
|
||||
if(str != nullptr)
|
||||
|
@ -2093,7 +2093,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
else if (key.compare(MOVEMENT_DATA) == 0)
|
||||
{
|
||||
int movcount = child->GetChildNum();
|
||||
stExpCocoNode* movArray = child->GetChildArray();
|
||||
stExpCocoNode* movArray = child->GetChildArray(cocoLoader);
|
||||
for( int movnum =0; movnum <movcount; movnum++)
|
||||
{
|
||||
movementData = decodeMovement(cocoLoader, &movArray[movnum], dataInfo);
|
||||
|
@ -2111,7 +2111,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
movementData->scale = 1.0f;
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pMoveDataArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
const char *str = nullptr;
|
||||
std::string key;
|
||||
|
@ -2120,7 +2120,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
child = &pMoveDataArray[i];
|
||||
key = child->GetName(cocoLoader);
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
if (key.compare(A_NAME) == 0)
|
||||
{
|
||||
if(str != nullptr)
|
||||
|
@ -2182,7 +2182,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
else if (key.compare(MOVEMENT_BONE_DATA) == 0)
|
||||
{
|
||||
int count = child->GetChildNum();
|
||||
stExpCocoNode *pMoveBoneData = child->GetChildArray();
|
||||
stExpCocoNode *pMoveBoneData = child->GetChildArray(cocoLoader);
|
||||
MovementBoneData *movementBoneData;
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
|
@ -2201,14 +2201,14 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
movementBoneData->init();
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pMovementBoneDataArray = cocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode* movebonechild;
|
||||
const char *str = nullptr;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
movebonechild = &pMovementBoneDataArray[i];
|
||||
std::string key = movebonechild->GetName(cocoLoader);
|
||||
str = movebonechild->GetValue();
|
||||
str = movebonechild->GetValue(cocoLoader);
|
||||
if (key.compare(A_NAME) == 0)
|
||||
{
|
||||
if(str != nullptr)
|
||||
|
@ -2226,7 +2226,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
else if (key.compare(FRAME_DATA) == 0)
|
||||
{
|
||||
int count =movebonechild->GetChildNum();
|
||||
stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray();
|
||||
stExpCocoNode *pFrameDataArray = movebonechild->GetChildArray(cocoLoader);
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
FrameData *frameData = decodeFrame(cocoLoader, &pFrameDataArray[ii], dataInfo);
|
||||
|
@ -2296,12 +2296,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
decodeNode(frameData, cocoLoader, cocoNode, dataInfo);
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pFrameDataArray = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *str = nullptr;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
std::string key = pFrameDataArray[i].GetName(cocoLoader);
|
||||
str = pFrameDataArray[i].GetValue();
|
||||
str = pFrameDataArray[i].GetValue(cocoLoader);
|
||||
if (key.compare(A_TWEEN_EASING) == 0)
|
||||
{
|
||||
frameData->tweenEasing = cocos2d::tweenfunc::Linear;
|
||||
|
@ -2376,10 +2376,10 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
if (count != 0 )
|
||||
{
|
||||
frameData->easingParams = new float[count];
|
||||
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray();
|
||||
stExpCocoNode *pFrameData = pFrameDataArray[i].GetChildArray(cocoLoader);
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
str = pFrameData[ii].GetValue();
|
||||
str = pFrameData[ii].GetValue(cocoLoader);
|
||||
if (str != nullptr)
|
||||
{
|
||||
frameData->easingParams[ii] = atof(str);
|
||||
|
@ -2404,12 +2404,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
}
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pTextureDataArray = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *str = nullptr;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
std::string key = pTextureDataArray[i].GetName(cocoLoader);
|
||||
str = pTextureDataArray[i].GetValue();
|
||||
str = pTextureDataArray[i].GetValue(cocoLoader);
|
||||
if (key.compare(A_NAME) == 0)
|
||||
{
|
||||
if(str != nullptr)
|
||||
|
@ -2448,7 +2448,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
else if (key.compare(CONTOUR_DATA) == 0)
|
||||
{
|
||||
int count = pTextureDataArray[i].GetChildNum();
|
||||
stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray();
|
||||
stExpCocoNode *pContourArray = pTextureDataArray[i].GetChildArray(cocoLoader);
|
||||
for (int ii = 0; ii < count; ++ii)
|
||||
{
|
||||
ContourData *contourData = decodeContour(cocoLoader, &pContourArray[ii]);
|
||||
|
@ -2466,23 +2466,23 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
contourData->init();
|
||||
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *verTexPointArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *verTexPointArray = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *str = nullptr;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
std::string key = verTexPointArray[i].GetName(cocoLoader);
|
||||
str = verTexPointArray[i].GetValue();
|
||||
str = verTexPointArray[i].GetValue(cocoLoader);
|
||||
if (key.compare(VERTEX_POINT) == 0)
|
||||
{
|
||||
int count = verTexPointArray[i].GetChildNum();
|
||||
stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray();
|
||||
stExpCocoNode *pVerTexPointArray = verTexPointArray[i].GetChildArray(cocoLoader);
|
||||
stExpCocoNode *pVerTexPoint;
|
||||
for (int ii = count - 1; ii >= 0; --ii)
|
||||
{
|
||||
pVerTexPoint = pVerTexPointArray[ii].GetChildArray();
|
||||
pVerTexPoint = pVerTexPointArray[ii].GetChildArray(cocoLoader);
|
||||
Vec2 vertex;
|
||||
vertex.x = atof(pVerTexPoint[0].GetValue());
|
||||
vertex.y = atof(pVerTexPoint[1].GetValue());
|
||||
vertex.x = atof(pVerTexPoint[0].GetValue(cocoLoader));
|
||||
vertex.y = atof(pVerTexPoint[1].GetValue(cocoLoader));
|
||||
contourData->vertexList.push_back(vertex); }
|
||||
break;
|
||||
}
|
||||
|
@ -2493,7 +2493,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
void DataReaderHelper::decodeNode(BaseData *node, CocoLoader *cocoLoader, stExpCocoNode* cocoNode, DataInfo *dataInfo)
|
||||
{
|
||||
int length = cocoNode->GetChildNum();
|
||||
stExpCocoNode *NodeArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *NodeArray = cocoNode->GetChildArray(cocoLoader);
|
||||
const char *str = nullptr;
|
||||
|
||||
bool isVersionL = dataInfo->cocoStudioVersion < VERSION_COLOR_READING;
|
||||
|
@ -2502,7 +2502,7 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
child = &NodeArray[i];
|
||||
std::string key = child->GetName(cocoLoader);
|
||||
str = child->GetValue();
|
||||
str = child->GetValue(cocoLoader);
|
||||
if (key.compare(A_X) == 0)
|
||||
{
|
||||
node->x = atof(str) * dataInfo->contentScale;
|
||||
|
@ -2539,12 +2539,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
if(child->GetChildNum() == 4)
|
||||
{
|
||||
stExpCocoNode *ChildArray = child->GetChildArray();
|
||||
stExpCocoNode *ChildArray = child->GetChildArray(cocoLoader);
|
||||
|
||||
node->a = atoi(ChildArray[0].GetValue());
|
||||
node->r = atoi(ChildArray[1].GetValue());
|
||||
node->g = atoi(ChildArray[2].GetValue());
|
||||
node->b = atoi(ChildArray[3].GetValue());
|
||||
node->a = atoi(ChildArray[0].GetValue(cocoLoader));
|
||||
node->r = atoi(ChildArray[1].GetValue(cocoLoader));
|
||||
node->g = atoi(ChildArray[2].GetValue(cocoLoader));
|
||||
node->b = atoi(ChildArray[3].GetValue(cocoLoader));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2566,12 +2566,12 @@ void DataReaderHelper::decodeNode(BaseData *node, const rapidjson::Value& json,
|
|||
{
|
||||
if(NodeArray[0].GetChildNum() == 4)
|
||||
{
|
||||
stExpCocoNode *ChildArray = NodeArray[0].GetChildArray();
|
||||
stExpCocoNode *ChildArray = NodeArray[0].GetChildArray(cocoLoader);
|
||||
|
||||
node->a = atoi(ChildArray[0].GetValue());
|
||||
node->r = atoi(ChildArray[1].GetValue());
|
||||
node->g = atoi(ChildArray[2].GetValue());
|
||||
node->b = atoi(ChildArray[3].GetValue());
|
||||
node->a = atoi(ChildArray[0].GetValue(cocoLoader));
|
||||
node->r = atoi(ChildArray[1].GetValue(cocoLoader));
|
||||
node->g = atoi(ChildArray[2].GetValue(cocoLoader));
|
||||
node->b = atoi(ChildArray[3].GetValue(cocoLoader));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -361,13 +361,13 @@ Widget* GUIReader::widgetFromBinaryFile(const char *fileName)
|
|||
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
|
||||
if (rapidjson::kObjectType == tType || rapidjson::kArrayType == tType)
|
||||
{
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
|
||||
|
||||
|
||||
for (int i = 0; i < tpRootCocoNode->GetChildNum(); ++i) {
|
||||
std::string key = tpChildArray[i].GetName(&tCocoLoader);
|
||||
if (key == "version") {
|
||||
fileVersion = tpChildArray[i].GetValue();
|
||||
fileVersion = tpChildArray[i].GetValue(&tCocoLoader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1222,7 +1222,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
|
|||
cocos2d::ui::Widget* WidgetPropertiesReader0300::createWidgetFromBinary(CocoLoader* cocoLoader,stExpCocoNode* cocoNode, const char* fileName)
|
||||
{
|
||||
|
||||
stExpCocoNode *tpChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *tpChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
float fileDesignWidth;
|
||||
float fileDesignHeight;
|
||||
|
||||
|
@ -1236,14 +1236,14 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
|
|||
for (int j=0; j<texturesCount; j++)
|
||||
{
|
||||
std::string file;
|
||||
stExpCocoNode *textureCountsArray = tpChildArray[i].GetChildArray();
|
||||
file = textureCountsArray[j].GetValue();
|
||||
stExpCocoNode *textureCountsArray = tpChildArray[i].GetChildArray(cocoLoader);
|
||||
file = textureCountsArray[j].GetValue(cocoLoader);
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(file);
|
||||
}
|
||||
}else if (key == "designWidth"){
|
||||
fileDesignWidth = atof(tpChildArray[i].GetValue());
|
||||
fileDesignWidth = atof(tpChildArray[i].GetValue(cocoLoader));
|
||||
}else if (key == "designHeight"){
|
||||
fileDesignHeight = atof(tpChildArray[i].GetValue());
|
||||
fileDesignHeight = atof(tpChildArray[i].GetValue(cocoLoader));
|
||||
}else if (key == "widgetTree"){
|
||||
|
||||
if (fileDesignWidth <= 0 || fileDesignHeight <= 0) {
|
||||
|
@ -1275,7 +1275,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
|
|||
|
||||
/* ********************** */
|
||||
/* ********************** */
|
||||
stExpCocoNode *optionChildNode = cocoNode->GetChildArray();
|
||||
stExpCocoNode *optionChildNode = cocoNode->GetChildArray(cocoLoader);
|
||||
for (int k = 0; k < cocoNode->GetChildNum(); ++k) {
|
||||
std::string key = optionChildNode[k].GetName(cocoLoader);
|
||||
if (key == "animation") {
|
||||
|
@ -1291,7 +1291,7 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
|
|||
Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, stExpCocoNode* cocoNode)
|
||||
{
|
||||
Widget* widget = nullptr;
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
stExpCocoNode *optionsNode = nullptr;
|
||||
stExpCocoNode *childrenNode = nullptr;
|
||||
int elementCount = cocoNode->GetChildNum();
|
||||
|
@ -1299,7 +1299,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
|
|||
|
||||
for (int i = 0; i < elementCount; ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
if (key == "classname" )
|
||||
{
|
||||
|
@ -1341,11 +1341,11 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
|
|||
// 2nd., custom widget parse with custom reader
|
||||
//2nd. parse custom property
|
||||
const char* customProperty = NULL;
|
||||
stExpCocoNode *optionChildNode = optionsNode->GetChildArray();
|
||||
stExpCocoNode *optionChildNode = optionsNode->GetChildArray(cocoLoader);
|
||||
for (int k = 0; k < optionsNode->GetChildNum(); ++k) {
|
||||
std::string key = optionChildNode[k].GetName(cocoLoader);
|
||||
if (key == "customProperty") {
|
||||
customProperty = optionChildNode[k].GetValue();
|
||||
customProperty = optionChildNode[k].GetValue(cocoLoader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1369,7 +1369,7 @@ Widget* WidgetPropertiesReader0300::widgetFromBinary(CocoLoader* cocoLoader, st
|
|||
if (tType22 == rapidjson::kArrayType) {
|
||||
|
||||
int childrenCount = childrenNode->GetChildNum();
|
||||
stExpCocoNode* innerChildArray = childrenNode->GetChildArray();
|
||||
stExpCocoNode* innerChildArray = childrenNode->GetChildArray(cocoLoader);
|
||||
for (int i=0; i < childrenCount; ++i) {
|
||||
rapidjson::Type tType = innerChildArray[i].GetType(cocoLoader);
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
|
||||
if (rapidjson::kObjectType == tType)
|
||||
{
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
|
||||
stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray(&tCocoLoader);
|
||||
CC_BREAK_IF(tpRootCocoNode->GetChildNum() == 0);
|
||||
_node = Node::create();
|
||||
int nCount = 0;
|
||||
|
@ -102,19 +102,19 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
{
|
||||
nCount = tpChildArray[15].GetChildNum();
|
||||
}
|
||||
stExpCocoNode *pComponents = tpChildArray[15].GetChildArray();
|
||||
stExpCocoNode *pComponents = tpChildArray[15].GetChildArray(&tCocoLoader);
|
||||
SerData *data = new SerData();
|
||||
for (int i = 0; i < nCount; i++)
|
||||
{
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray();
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray(&tCocoLoader);
|
||||
if (subDict == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::string key = subDict[1].GetName(&tCocoLoader);
|
||||
const char *comName = subDict[1].GetValue();
|
||||
std::string key1 = subDict[1].GetName(&tCocoLoader);
|
||||
const char *comName = subDict[1].GetValue(&tCocoLoader);
|
||||
Component *pCom = nullptr;
|
||||
if (key == "classname" && comName != nullptr)
|
||||
if (key1 == "classname" && comName != nullptr)
|
||||
{
|
||||
pCom = createComponent(comName);
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
{
|
||||
data->_rData = nullptr;
|
||||
data->_cocoNode = subDict;
|
||||
data->_cocoLoader = &tCocoLoader;
|
||||
if (pCom->serialize(data))
|
||||
{
|
||||
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
|
||||
|
@ -152,7 +153,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName,
|
|||
_node->addComponent(*iter);
|
||||
}
|
||||
|
||||
stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray();
|
||||
stExpCocoNode *pGameObjects = tpChildArray[11].GetChildArray(&tCocoLoader);
|
||||
int length = tpChildArray[11].GetChildNum();
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
|
@ -283,6 +284,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
|||
{
|
||||
data->_rData = &subDict;
|
||||
data->_cocoNode = nullptr;
|
||||
data->_cocoLoader = nullptr;
|
||||
if (com->serialize(data))
|
||||
{
|
||||
ComRender *tRender = dynamic_cast<ComRender*>(com);
|
||||
|
@ -349,11 +351,11 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
|||
cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node* parent, AttachComponentType attachComponent)
|
||||
{
|
||||
const char *className = nullptr;
|
||||
stExpCocoNode *pNodeArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *pNodeArray = cocoNode->GetChildArray(cocoLoader);
|
||||
std::string Key = pNodeArray[1].GetName(cocoLoader);
|
||||
if (Key == "classname")
|
||||
{
|
||||
className = pNodeArray[1].GetValue();
|
||||
className = pNodeArray[1].GetValue(cocoLoader);
|
||||
}
|
||||
if(strcmp(className, "CCNode") == 0)
|
||||
{
|
||||
|
@ -366,19 +368,19 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
{
|
||||
count = pNodeArray[13].GetChildNum();
|
||||
}
|
||||
stExpCocoNode *pComponents = pNodeArray[13].GetChildArray();
|
||||
stExpCocoNode *pComponents = pNodeArray[13].GetChildArray(cocoLoader);
|
||||
SerData *data = new SerData();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray();
|
||||
stExpCocoNode *subDict = pComponents[i].GetChildArray(cocoLoader);
|
||||
if (subDict == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::string key = subDict[1].GetName(cocoLoader);
|
||||
const char *comName = subDict[1].GetValue();//DICTOOL->getStringValue_json(subDict, "classname");
|
||||
std::string key1 = subDict[1].GetName(cocoLoader);
|
||||
const char *comName = subDict[1].GetValue(cocoLoader);
|
||||
Component *pCom = nullptr;
|
||||
if (key == "classname" && comName != nullptr)
|
||||
if (key1 == "classname" && comName != nullptr)
|
||||
{
|
||||
pCom = createComponent(comName);
|
||||
}
|
||||
|
@ -387,6 +389,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
{
|
||||
data->_rData = nullptr;
|
||||
data->_cocoNode = subDict;
|
||||
data->_cocoLoader = cocoLoader;
|
||||
if (pCom->serialize(data))
|
||||
{
|
||||
ComRender *pTRender = dynamic_cast<ComRender*>(pCom);
|
||||
|
@ -436,7 +439,7 @@ cocos2d::Node* SceneReader::createObject(CocoLoader *cocoLoader, stExpCocoNode *
|
|||
gb->addComponent(*iter);
|
||||
}
|
||||
|
||||
stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray();
|
||||
stExpCocoNode *pGameObjects = pNodeArray[12].GetChildArray(cocoLoader);
|
||||
if (pGameObjects != nullptr)
|
||||
{
|
||||
int length = pNodeArray[12].GetChildNum();
|
||||
|
@ -495,7 +498,7 @@ void SceneReader::setPropertyFromJsonDict(const rapidjson::Value &root, cocos2d:
|
|||
|
||||
void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::Node *node)
|
||||
{
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
float x = 0.0f, y = 0.0f, fScaleX = 1.0f, fScaleY = 1.0f, fRotationZ = 1.0f;
|
||||
bool bVisible = false;
|
||||
int nTag = 0, nZorder = -1;
|
||||
|
@ -503,7 +506,7 @@ void SceneReader::setPropertyFromJsonDict(CocoLoader *cocoLoader, stExpCocoNode
|
|||
for (int i = 0; i < cocoNode->GetChildNum(); ++i)
|
||||
{
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
if (key == "x")
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "CocoLoader.h"
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace rapidjson;
|
||||
|
@ -7,190 +7,222 @@ using namespace rapidjson;
|
|||
namespace cocostudio{
|
||||
|
||||
|
||||
char cTypeName[] = {'N','F','T','O','A','S','V'};
|
||||
const char* kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" };
|
||||
const char* kObjKeyName[] = { "__type" , "classname" };
|
||||
char g_Buff[2048];
|
||||
|
||||
Type stExpCocoNode::GetType(CocoLoader* pCoco)
|
||||
char* stExpCocoAttribDesc::GetName(CocoLoader* pCoco)
|
||||
{
|
||||
Type tType = kObjectType;
|
||||
if(m_ObjIndex >= 0)
|
||||
{
|
||||
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
|
||||
if( m_AttribIndex >= 0 )
|
||||
{
|
||||
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray;
|
||||
tType = tpAttribDescArray[m_AttribIndex].m_Type;
|
||||
|
||||
if(kFalseType == tType || kTrueType == tType)
|
||||
{
|
||||
char* szValue = (char*)m_szValue;
|
||||
if(szValue[0] == '0')
|
||||
{
|
||||
return kFalseType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kTrueType;
|
||||
}
|
||||
}
|
||||
return ( pCoco->GetMemoryAddr_String() + m_szName );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tType = kObjectType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_AttribIndex >= 0)
|
||||
{
|
||||
tType = (Type)m_ChildNum;
|
||||
char* stExpCocoObjectDesc::GetName(CocoLoader* pCoco)
|
||||
{
|
||||
return ( pCoco->GetMemoryAddr_String() + m_szName );
|
||||
}
|
||||
|
||||
if(kFalseType == tType || kTrueType == tType)
|
||||
{
|
||||
char* szValue = (char*)m_szValue;
|
||||
if(szValue[0] == '0')
|
||||
{
|
||||
return kFalseType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kTrueType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tType = kArrayType;
|
||||
}
|
||||
}
|
||||
return tType;
|
||||
int stExpCocoObjectDesc::GetAttribNum()
|
||||
{
|
||||
return m_cAttribNum;
|
||||
}
|
||||
|
||||
stExpCocoAttribDesc* stExpCocoObjectDesc::GetAttribDescArray(CocoLoader* pCoco)
|
||||
{
|
||||
return (stExpCocoAttribDesc*)( pCoco->GetMemoryAddr_AttribDesc() + m_pAttribDescArray );
|
||||
}
|
||||
|
||||
Type stExpCocoNode::GetType(CocoLoader* pCoco)
|
||||
{
|
||||
|
||||
Type tType = kObjectType;
|
||||
if(m_ObjIndex >= 0)
|
||||
{
|
||||
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray() ;
|
||||
if( m_AttribIndex >= 0 )
|
||||
{
|
||||
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco);
|
||||
tType = Type(tpAttribDescArray[m_AttribIndex].m_cTypeName - 'N' + kNullType);
|
||||
|
||||
if(kFalseType == tType || kTrueType == tType)
|
||||
{
|
||||
char* szValue = (char*)GetValue(pCoco);
|
||||
if(szValue[0] == '0')
|
||||
{
|
||||
return kFalseType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kTrueType;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tType = kObjectType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_AttribIndex >= 0)
|
||||
{
|
||||
tType = (Type)m_ChildNum;
|
||||
|
||||
if(kFalseType == tType || kTrueType == tType)
|
||||
{
|
||||
char* szValue = (char*)GetValue(pCoco);
|
||||
if(szValue[0] == '0')
|
||||
{
|
||||
return kFalseType;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kTrueType;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tType = kArrayType;
|
||||
}
|
||||
}
|
||||
return tType;
|
||||
}
|
||||
|
||||
char* stExpCocoNode::GetName(CocoLoader* pCoco)
|
||||
{
|
||||
char* szName = NULL ;
|
||||
if(m_ObjIndex >= 0)
|
||||
{
|
||||
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
|
||||
if( m_AttribIndex >= 0 )
|
||||
{
|
||||
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].m_pAttribDescArray;
|
||||
szName = (char*)tpAttribDescArray[m_AttribIndex].m_szName;
|
||||
}
|
||||
else
|
||||
{
|
||||
char* szValue = (char*)m_szValue;
|
||||
if(szValue[0])
|
||||
{
|
||||
szName = (char*)m_szValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
szName = (char*)tpCocoObjectDesc[m_ObjIndex].m_szName;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_AttribIndex >= 0)
|
||||
{
|
||||
char* pStringAddr = (char*)pCoco->GetCocoObjectDescArray() + pCoco->GetFileHeader()->m_lStringMemAddr ;
|
||||
szName = m_ChildArray + pStringAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
szName = (char*)m_szValue;
|
||||
}
|
||||
}
|
||||
return szName ;
|
||||
char* szName = NULL ;
|
||||
if(m_ObjIndex >= 0)
|
||||
{
|
||||
stExpCocoObjectDesc* tpCocoObjectDesc = pCoco->GetCocoObjectDescArray();
|
||||
if( m_AttribIndex >= 0 )
|
||||
{
|
||||
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*) tpCocoObjectDesc[m_ObjIndex].GetAttribDescArray(pCoco);
|
||||
szName = tpAttribDescArray[m_AttribIndex].GetName(pCoco);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* szValue = GetValue(pCoco);
|
||||
if(szValue[0])
|
||||
{
|
||||
szName = GetValue(pCoco);
|
||||
}
|
||||
else
|
||||
{
|
||||
szName = tpCocoObjectDesc[m_ObjIndex].GetName(pCoco);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_AttribIndex >= 0)
|
||||
{
|
||||
char* pStringAddr = (char*)pCoco->GetCocoObjectDescArray() + pCoco->GetFileHeader()->m_lStringMemAddr ;
|
||||
szName = m_ChildArray + pStringAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
szName = (char*)GetValue(pCoco);
|
||||
}
|
||||
}
|
||||
return szName ;
|
||||
|
||||
}
|
||||
|
||||
char* stExpCocoNode::GetValue()
|
||||
char* stExpCocoNode::GetValue(CocoLoader* pCoco)
|
||||
{
|
||||
return (char*)m_szValue;
|
||||
return ( pCoco->GetMemoryAddr_String() + m_szValue );
|
||||
}
|
||||
|
||||
int stExpCocoNode::GetChildNum()
|
||||
{
|
||||
return m_ChildNum;
|
||||
return m_ChildNum;
|
||||
}
|
||||
|
||||
stExpCocoNode* stExpCocoNode::GetChildArray()
|
||||
stExpCocoNode* stExpCocoNode::GetChildArray(CocoLoader* pCoco)
|
||||
{
|
||||
return (stExpCocoNode*)m_ChildArray;
|
||||
}
|
||||
|
||||
void stExpCocoNode::ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr)
|
||||
{
|
||||
m_szValue = m_szValue + (uint64_t)pStringMemoryAddr;
|
||||
if( -1 == m_AttribIndex )
|
||||
{
|
||||
if(m_ChildNum > 0)
|
||||
{
|
||||
m_ChildArray = m_ChildArray + (uint64_t)cocoNodeAddr;
|
||||
|
||||
stExpCocoNode* tpChildArray = (stExpCocoNode*)m_ChildArray;
|
||||
for(int i = 0 ; i < m_ChildNum ; i++)
|
||||
{
|
||||
tpChildArray[i].ReBuild(cocoNodeAddr,pStringMemoryAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (stExpCocoNode*)( pCoco->GetMemoryAddr_CocoNode() + m_ChildArray );
|
||||
}
|
||||
|
||||
CocoLoader::CocoLoader()
|
||||
{
|
||||
m_pRootNode = NULL;
|
||||
m_pObjectDescArray = NULL;
|
||||
m_pRootNode = NULL;
|
||||
m_pObjectDescArray = NULL;
|
||||
m_pMemoryBuff = NULL;
|
||||
}
|
||||
|
||||
CocoLoader::~CocoLoader()
|
||||
{
|
||||
|
||||
if(m_pMemoryBuff)
|
||||
{
|
||||
delete[] m_pMemoryBuff;
|
||||
m_pMemoryBuff = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
|
||||
bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
|
||||
{
|
||||
if(m_pMemoryBuff)return true;
|
||||
char* pTempBuff = pBinBuff;
|
||||
|
||||
|
||||
m_pFileHeader = (stCocoFileHeader*)pTempBuff;
|
||||
pTempBuff += sizeof(stCocoFileHeader);
|
||||
|
||||
char* pStartAddr = pTempBuff;
|
||||
m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr;
|
||||
|
||||
char* pAttrAddr = pStartAddr + m_pFileHeader->m_lAttribMemAddr ;
|
||||
char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr;
|
||||
char* pStringAddr = pStartAddr + m_pFileHeader->m_lStringMemAddr ;
|
||||
|
||||
m_pRootNode = (stExpCocoNode*)pCocoMemAddr;
|
||||
|
||||
if(1 == m_pFileHeader->m_nFirstUsed)
|
||||
{
|
||||
for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++)
|
||||
{
|
||||
m_pObjectDescArray[i].ReBuild(pAttrAddr,pStringAddr) ;
|
||||
}
|
||||
m_pRootNode->ReBuild(pCocoMemAddr,pStringAddr);
|
||||
|
||||
m_pFileHeader->m_nFirstUsed = 0;
|
||||
char* pStartAddr = m_pMemoryBuff = pTempBuff;
|
||||
|
||||
if( m_pFileHeader->m_nCompressSize > 0 )
|
||||
{
|
||||
char* pDestBuff = new char[m_pFileHeader->m_nDataSize];
|
||||
uLongf dwSrcSize = m_pFileHeader->m_nCompressSize;
|
||||
uLongf dwDestSize = m_pFileHeader->m_nDataSize;
|
||||
int nRes = uncompress((Bytef*)pDestBuff,&dwDestSize,(Bytef*)m_pMemoryBuff,dwSrcSize);
|
||||
pStartAddr = m_pMemoryBuff = pDestBuff;
|
||||
}
|
||||
|
||||
|
||||
m_pObjectDescArray = (stExpCocoObjectDesc*)pStartAddr;
|
||||
|
||||
char* pCocoMemAddr = pStartAddr + m_pFileHeader->m_CocoNodeMemAddr;
|
||||
|
||||
m_pRootNode = (stExpCocoNode*)pCocoMemAddr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc)
|
||||
{
|
||||
for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++)
|
||||
{
|
||||
if(0 == strcmp((char*)m_pObjectDescArray[i].m_szName,szObjDesc))
|
||||
{
|
||||
return &m_pObjectDescArray[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++)
|
||||
{
|
||||
if(0 == strcmp((char*)m_pObjectDescArray[i].m_szName,szObjDesc))
|
||||
{
|
||||
return &m_pObjectDescArray[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
|
||||
{
|
||||
if(vIndex >= 0 && vIndex < m_pFileHeader->m_ObjectCount)
|
||||
{
|
||||
return &m_pObjectDescArray[vIndex];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* CocoLoader::GetMemoryAddr_AttribDesc()
|
||||
{
|
||||
return m_pMemoryBuff + m_pFileHeader->m_lAttribMemAddr ;
|
||||
}
|
||||
|
||||
char* CocoLoader::GetMemoryAddr_CocoNode()
|
||||
{
|
||||
return m_pMemoryBuff + m_pFileHeader->m_CocoNodeMemAddr;
|
||||
}
|
||||
|
||||
char* CocoLoader::GetMemoryAddr_String()
|
||||
{
|
||||
return m_pMemoryBuff + m_pFileHeader->m_lStringMemAddr ;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,101 +36,80 @@
|
|||
|
||||
namespace cocostudio{
|
||||
|
||||
|
||||
class CocoLoader;
|
||||
|
||||
struct stExpCocoAttribDesc
|
||||
{
|
||||
rapidjson::Type m_Type;
|
||||
uint64_t m_szName;
|
||||
uint64_t m_szDefaultValue;
|
||||
char m_cTypeName;
|
||||
uint32_t m_szName;
|
||||
public:
|
||||
|
||||
void ReBuild(char* pStringMemoryAddr)
|
||||
{
|
||||
m_szName = m_szName + (uint64_t)pStringMemoryAddr;
|
||||
m_szDefaultValue = m_szDefaultValue + (uint64_t)pStringMemoryAddr;
|
||||
}
|
||||
char* GetName(CocoLoader* pCoco);
|
||||
};
|
||||
|
||||
struct stExpCocoObjectDesc
|
||||
{
|
||||
uint32_t m_nAttribNum;
|
||||
uint64_t m_szName;
|
||||
uint64_t m_pAttribDescArray;
|
||||
|
||||
unsigned char m_cAttribNum;
|
||||
uint32_t m_szName;
|
||||
uint32_t m_pAttribDescArray;
|
||||
public:
|
||||
stExpCocoObjectDesc()
|
||||
{
|
||||
m_nAttribNum = 0;
|
||||
m_szName = 0;
|
||||
m_pAttribDescArray = 0;
|
||||
}
|
||||
void ReBuild(char* pAttribMemoryAddr,char* pStringMemoryAddr)
|
||||
{
|
||||
m_szName = m_szName + (uint64_t)pStringMemoryAddr;
|
||||
m_pAttribDescArray = m_pAttribDescArray + (uint64_t)pAttribMemoryAddr;
|
||||
stExpCocoAttribDesc* tpAttribDescArray = (stExpCocoAttribDesc*)m_pAttribDescArray;
|
||||
for(uint32_t i = 0 ; i < m_nAttribNum ; i++)
|
||||
{
|
||||
tpAttribDescArray[i].ReBuild(pStringMemoryAddr);
|
||||
}
|
||||
}
|
||||
|
||||
char* GetName(CocoLoader* pCoco);
|
||||
int GetAttribNum();
|
||||
stExpCocoAttribDesc* GetAttribDescArray(CocoLoader* pCoco);
|
||||
};
|
||||
|
||||
class CocoLoader;
|
||||
|
||||
struct stExpCocoNode
|
||||
struct stExpCocoNode
|
||||
{
|
||||
protected:
|
||||
int32_t m_ObjIndex;
|
||||
int32_t m_AttribIndex;
|
||||
uint32_t m_ChildNum;
|
||||
uint64_t m_szValue;
|
||||
uint64_t m_ChildArray;
|
||||
|
||||
public:
|
||||
rapidjson::Type GetType(CocoLoader* pCoco);
|
||||
char* GetName(CocoLoader* pCoco);
|
||||
char* GetValue();
|
||||
int GetChildNum();
|
||||
stExpCocoNode* GetChildArray();
|
||||
|
||||
int16_t m_ObjIndex;
|
||||
int16_t m_AttribIndex;
|
||||
unsigned char m_ChildNum;
|
||||
uint32_t m_szValue;
|
||||
uint32_t m_ChildArray;
|
||||
public:
|
||||
inline void ReBuild(char* cocoNodeAddr,char* pStringMemoryAddr);
|
||||
void WriteJson(CocoLoader* pCoco, void* pFileName = NULL, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false);
|
||||
rapidjson::Type GetType(CocoLoader* pCoco);
|
||||
char* GetName(CocoLoader* pCoco);
|
||||
char* GetValue(CocoLoader* pCoco);
|
||||
int GetChildNum();
|
||||
stExpCocoNode* GetChildArray(CocoLoader* pCoco);
|
||||
public:
|
||||
void WriteJson(CocoLoader* pCoco,void* pFileName = nullptr, int vLayer = 0, bool bEndNode = false, bool bParentNodeIsArray = false);
|
||||
};
|
||||
|
||||
|
||||
struct stCocoFileHeader
|
||||
{
|
||||
char m_FileDesc[32];
|
||||
char m_Version[32];
|
||||
uint32_t m_nFirstUsed;
|
||||
uint32_t m_ObjectCount;
|
||||
uint64_t m_lAttribMemAddr;
|
||||
uint64_t m_CocoNodeMemAddr;
|
||||
uint64_t m_lStringMemAddr;
|
||||
|
||||
char m_FileDesc[32];
|
||||
char m_Version[32];
|
||||
uint32_t m_nDataSize;
|
||||
uint32_t m_nCompressSize;
|
||||
uint32_t m_ObjectCount;
|
||||
uint32_t m_lAttribMemAddr;
|
||||
uint32_t m_CocoNodeMemAddr;
|
||||
uint32_t m_lStringMemAddr;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CocoLoader
|
||||
{
|
||||
private:
|
||||
stCocoFileHeader* m_pFileHeader;
|
||||
stExpCocoNode* m_pRootNode;
|
||||
stExpCocoObjectDesc* m_pObjectDescArray;
|
||||
|
||||
stCocoFileHeader* m_pFileHeader;
|
||||
stExpCocoNode* m_pRootNode;
|
||||
stExpCocoObjectDesc* m_pObjectDescArray;
|
||||
char* m_pMemoryBuff;
|
||||
|
||||
public:
|
||||
CocoLoader();
|
||||
~CocoLoader();
|
||||
|
||||
CocoLoader();
|
||||
~CocoLoader();
|
||||
public:
|
||||
bool ReadCocoBinBuff(char* pBinBuff);
|
||||
stCocoFileHeader* GetFileHeader(){return m_pFileHeader;}
|
||||
stExpCocoNode* GetRootCocoNode(){return m_pRootNode;}
|
||||
stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;}
|
||||
stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc);
|
||||
|
||||
bool ReadCocoBinBuff(char* pBinBuff);
|
||||
stCocoFileHeader* GetFileHeader(){return m_pFileHeader;}
|
||||
stExpCocoNode* GetRootCocoNode(){return m_pRootNode;}
|
||||
stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;}
|
||||
stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc);
|
||||
stExpCocoObjectDesc* GetCocoObjectDesc(int vIndex);
|
||||
char* GetMemoryAddr_AttribDesc();
|
||||
char* GetMemoryAddr_CocoNode();
|
||||
char* GetMemoryAddr_String();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ void TriggerMng::parse(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCoc
|
|||
CCLOG("%s", triggerMngVersion());
|
||||
|
||||
int count = pCocoNode[13].GetChildNum();
|
||||
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray();
|
||||
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader);
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
|
@ -199,79 +199,78 @@ bool TriggerMng::isEmpty(void) const
|
|||
int size = 0;
|
||||
int extent = 0;
|
||||
int border = 0;
|
||||
std::string key;
|
||||
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray();
|
||||
std::string key0;
|
||||
stExpCocoNode *pTriggersArray = pCocoNode[13].GetChildArray(pCocoLoader);
|
||||
|
||||
document.SetArray();
|
||||
|
||||
rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i0 = 0; i0 < count; ++i0)
|
||||
{
|
||||
rapidjson::Value vElemItem(rapidjson::kObjectType);
|
||||
|
||||
border = pTriggersArray[i].GetChildNum();
|
||||
stExpCocoNode *pTriggerArray = pTriggersArray[i].GetChildArray();
|
||||
for (int i = 0; i < border; ++i)
|
||||
border = pTriggersArray[i0].GetChildNum();
|
||||
stExpCocoNode *pTriggerArray = pTriggersArray[i0].GetChildArray(pCocoLoader);
|
||||
for (int i1 = 0; i1 < border; ++i1)
|
||||
{
|
||||
std::string key = pTriggerArray[i].GetName(pCocoLoader);
|
||||
const char *str = pTriggerArray[i].GetValue();
|
||||
rapidjson::Type type = pTriggerArray[i].GetType(pCocoLoader);
|
||||
std::string key1 = pTriggerArray[i1].GetName(pCocoLoader);
|
||||
const char *str1 = pTriggerArray[i1].GetValue(pCocoLoader);
|
||||
|
||||
if (key.compare("actions") == 0)
|
||||
if (key1.compare("actions") == 0)
|
||||
{
|
||||
rapidjson::Value actionsItem(rapidjson::kArrayType);
|
||||
|
||||
length = pTriggerArray[i].GetChildNum();
|
||||
stExpCocoNode *pActionsArray = pTriggerArray[i].GetChildArray();
|
||||
for (int i = 0; i < length; ++i)
|
||||
length = pTriggerArray[i1].GetChildNum();
|
||||
stExpCocoNode *pActionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
|
||||
for (int i2 = 0; i2 < length; ++i2)
|
||||
{
|
||||
rapidjson::Value action(rapidjson::kObjectType);
|
||||
|
||||
num = pActionsArray[i].GetChildNum();
|
||||
stExpCocoNode *pActionArray = pActionsArray[i].GetChildArray();
|
||||
for (int i = 0; i < num; ++i)
|
||||
num = pActionsArray[i2].GetChildNum();
|
||||
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader);
|
||||
for (int i3 = 0; i3 < num; ++i3)
|
||||
{
|
||||
std::string key = pActionArray[i].GetName(pCocoLoader);
|
||||
const char *str = pActionArray[i].GetValue();
|
||||
if (key.compare("classname") == 0)
|
||||
std::string key2 = pActionArray[i3].GetName(pCocoLoader);
|
||||
const char *str2 = pActionArray[i3].GetValue(pCocoLoader);
|
||||
if (key2.compare("classname") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str2 != NULL)
|
||||
{
|
||||
action.AddMember("classname", str, allocator);
|
||||
action.AddMember("classname", str2, allocator);
|
||||
}
|
||||
}
|
||||
else if (key.compare("dataitems") == 0)
|
||||
else if (key2.compare("dataitems") == 0)
|
||||
{
|
||||
rapidjson::Value dataitems(rapidjson::kArrayType);
|
||||
size = pActionArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemsArray = pActionArray[i].GetChildArray();
|
||||
for (int i = 0; i < size; ++i)
|
||||
size = pActionArray[i3].GetChildNum();
|
||||
stExpCocoNode *pDataItemsArray = pActionArray[i3].GetChildArray(pCocoLoader);
|
||||
for (int i4 = 0; i4 < size; ++i4)
|
||||
{
|
||||
rapidjson::Value dataitem(rapidjson::kObjectType);
|
||||
extent = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
for (int i = 0; i < extent; ++i)
|
||||
extent = pDataItemsArray[i4].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i4].GetChildArray(pCocoLoader);
|
||||
for (int i5 = 0; i5 < extent; ++i5)
|
||||
{
|
||||
std::string key = pDataItemArray[i].GetName(pCocoLoader);
|
||||
const char *str = pDataItemArray[i].GetValue();
|
||||
if (key.compare("key") == 0)
|
||||
std::string key3 = pDataItemArray[i5].GetName(pCocoLoader);
|
||||
const char *str3 = pDataItemArray[i5].GetValue(pCocoLoader);
|
||||
if (key3.compare("key") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str3 != NULL)
|
||||
{
|
||||
dataitem.AddMember("key", str, allocator);
|
||||
dataitem.AddMember("key", str3, allocator);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rapidjson::Type type = pDataItemArray[i].GetType(pCocoLoader);
|
||||
rapidjson::Type type = pDataItemArray[i4].GetType(pCocoLoader);
|
||||
if (type == rapidjson::kStringType)
|
||||
{
|
||||
dataitem.AddMember("value", str, allocator);
|
||||
dataitem.AddMember("value", str3, allocator);
|
||||
}
|
||||
else if(type == rapidjson::kNumberType)
|
||||
{
|
||||
int nV = atoi(str);
|
||||
float fV = atof(str);
|
||||
int nV = atoi(str3);
|
||||
float fV = atof(str3);
|
||||
if (fabs(nV - fV) < 0.0000001)
|
||||
{
|
||||
dataitem.AddMember("value", nV, allocator);
|
||||
|
@ -293,61 +292,61 @@ bool TriggerMng::isEmpty(void) const
|
|||
|
||||
vElemItem.AddMember("actions", actionsItem, allocator);
|
||||
}
|
||||
else if (key.compare("conditions") == 0)
|
||||
else if (key1.compare("conditions") == 0)
|
||||
{
|
||||
rapidjson::Value condsItem(rapidjson::kArrayType);
|
||||
|
||||
length = pTriggerArray[i].GetChildNum();
|
||||
stExpCocoNode *pConditionsArray = pTriggerArray[i].GetChildArray();
|
||||
for (int i = 0; i < length; ++i)
|
||||
length = pTriggerArray[i1].GetChildNum();
|
||||
stExpCocoNode *pConditionsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
|
||||
for (int i6 = 0; i6 < length; ++i6)
|
||||
{
|
||||
rapidjson::Value cond(rapidjson::kObjectType);
|
||||
|
||||
num = pConditionsArray[i].GetChildNum();
|
||||
stExpCocoNode *pConditionArray = pConditionsArray[i].GetChildArray();
|
||||
for (int i = 0; i < num; ++i)
|
||||
num = pConditionsArray[i6].GetChildNum();
|
||||
stExpCocoNode *pConditionArray = pConditionsArray[i6].GetChildArray(pCocoLoader);
|
||||
for (int i7 = 0; i7 < num; ++i7)
|
||||
{
|
||||
std::string key = pConditionArray[i].GetName(pCocoLoader);
|
||||
const char *str = pConditionArray[i].GetValue();
|
||||
if (key.compare("classname") == 0)
|
||||
std::string key4 = pConditionArray[i7].GetName(pCocoLoader);
|
||||
const char *str4 = pConditionArray[i7].GetValue(pCocoLoader);
|
||||
if (key4.compare("classname") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str4 != NULL)
|
||||
{
|
||||
cond.AddMember("classname", str, allocator);
|
||||
cond.AddMember("classname", str4, allocator);
|
||||
}
|
||||
}
|
||||
else if (key.compare("dataitems") == 0)
|
||||
else if (key4.compare("dataitems") == 0)
|
||||
{
|
||||
rapidjson::Value dataitems(rapidjson::kArrayType);
|
||||
size = pConditionArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemsArray = pConditionArray[i].GetChildArray();
|
||||
for (int i = 0; i < size; ++i)
|
||||
size = pConditionArray[i7].GetChildNum();
|
||||
stExpCocoNode *pDataItemsArray = pConditionArray[i7].GetChildArray(pCocoLoader);
|
||||
for (int i8 = 0; i8 < size; ++i8)
|
||||
{
|
||||
rapidjson::Value dataitem(rapidjson::kObjectType);
|
||||
extent = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
for (int i = 0; i < extent; ++i)
|
||||
extent = pDataItemsArray[i8].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i8].GetChildArray(pCocoLoader);
|
||||
for (int i9 = 0; i9 < extent; ++i9)
|
||||
{
|
||||
std::string key = pDataItemArray[i].GetName(pCocoLoader);
|
||||
const char *str = pDataItemArray[i].GetValue();
|
||||
if (key.compare("key") == 0)
|
||||
std::string key5 = pDataItemArray[i9].GetName(pCocoLoader);
|
||||
const char *str5 = pDataItemArray[i9].GetValue(pCocoLoader);
|
||||
if (key5.compare("key") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str5 != NULL)
|
||||
{
|
||||
dataitem.AddMember("key", str, allocator);
|
||||
dataitem.AddMember("key", str5, allocator);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rapidjson::Type type = pDataItemArray[i].GetType(pCocoLoader);
|
||||
rapidjson::Type type = pDataItemArray[i9].GetType(pCocoLoader);
|
||||
if (type == rapidjson::kStringType)
|
||||
{
|
||||
dataitem.AddMember("value", str, allocator);
|
||||
dataitem.AddMember("value", str5, allocator);
|
||||
}
|
||||
else if(type == rapidjson::kNumberType)
|
||||
{
|
||||
int nV = atoi(str);
|
||||
float fV = atof(str);
|
||||
int nV = atoi(str5);
|
||||
float fV = atof(str5);
|
||||
if (fabs(nV - fV) < 0.0000001)
|
||||
{
|
||||
dataitem.AddMember("value", nV, allocator);
|
||||
|
@ -369,31 +368,31 @@ bool TriggerMng::isEmpty(void) const
|
|||
|
||||
vElemItem.AddMember("conditions", condsItem, allocator);
|
||||
}
|
||||
else if (key.compare("events") == 0)
|
||||
else if (key1.compare("events") == 0)
|
||||
{
|
||||
rapidjson::Value eventsItem(rapidjson::kArrayType);
|
||||
|
||||
length = pTriggerArray[i].GetChildNum();
|
||||
stExpCocoNode *pEventsArray = pTriggerArray[i].GetChildArray();
|
||||
for (int i = 0; i < length; ++i)
|
||||
length = pTriggerArray[i1].GetChildNum();
|
||||
stExpCocoNode *pEventsArray = pTriggerArray[i1].GetChildArray(pCocoLoader);
|
||||
for (int i10 = 0; i10 < length; ++i10)
|
||||
{
|
||||
rapidjson::Value event(rapidjson::kObjectType);
|
||||
stExpCocoNode *pEventArray = pEventsArray->GetChildArray();
|
||||
std::string key = pEventArray[0].GetName(pCocoLoader);
|
||||
const char *str = pEventArray[0].GetValue();
|
||||
if (key.compare("id") == 0 && str != NULL)
|
||||
stExpCocoNode *pEventArray = pEventsArray->GetChildArray(pCocoLoader);
|
||||
std::string key6 = pEventArray[0].GetName(pCocoLoader);
|
||||
const char *str6 = pEventArray[0].GetValue(pCocoLoader);
|
||||
if (key6.compare("id") == 0 && str6 != NULL)
|
||||
{
|
||||
event.AddMember("id", atoi(str), allocator);
|
||||
event.AddMember("id", atoi(str6), allocator);
|
||||
eventsItem.PushBack(event, allocator);
|
||||
}
|
||||
}
|
||||
vElemItem.AddMember("events", eventsItem, allocator);
|
||||
}
|
||||
else if (key.compare("id") == 0)
|
||||
else if (key1.compare("id") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str1 != NULL)
|
||||
{
|
||||
vElemItem.AddMember("id", atoi(str), allocator);
|
||||
vElemItem.AddMember("id", atoi(str1), allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,33 +246,33 @@ void TriggerObj::serialize(const rapidjson::Value &val)
|
|||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
int num = 0;
|
||||
stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray();
|
||||
for (int i = 0; i < length; ++i)
|
||||
stExpCocoNode *pTriggerObjArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
for (int i0 = 0; i0 < length; ++i0)
|
||||
{
|
||||
std::string key = pTriggerObjArray[i].GetName(pCocoLoader);
|
||||
const char* str = pTriggerObjArray[i].GetValue();
|
||||
std::string key = pTriggerObjArray[i0].GetName(pCocoLoader);
|
||||
const char* str0 = pTriggerObjArray[i0].GetValue(pCocoLoader);
|
||||
if (key.compare("id") == 0)
|
||||
{
|
||||
if (str != NULL)
|
||||
if (str0 != NULL)
|
||||
{
|
||||
_id = atoi(str); //(unsigned int)(DICTOOL->getIntValue_json(val, "id"));
|
||||
_id = atoi(str0); //(unsigned int)(DICTOOL->getIntValue_json(val, "id"));
|
||||
}
|
||||
}
|
||||
else if (key.compare("conditions") == 0)
|
||||
{
|
||||
count = pTriggerObjArray[i].GetChildNum();
|
||||
stExpCocoNode *pConditionsArray = pTriggerObjArray[i].GetChildArray();
|
||||
for (int i = 0; i < count; ++i)
|
||||
count = pTriggerObjArray[i0].GetChildNum();
|
||||
stExpCocoNode *pConditionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
|
||||
for (int i1 = 0; i1 < count; ++i1)
|
||||
{
|
||||
num = pConditionsArray[i].GetChildNum();
|
||||
stExpCocoNode *pConditionArray = pConditionsArray[i].GetChildArray();
|
||||
const char *classname = pConditionArray[0].GetValue();
|
||||
if (classname == NULL)
|
||||
num = pConditionsArray[i1].GetChildNum();
|
||||
stExpCocoNode *pConditionArray = pConditionsArray[i1].GetChildArray(pCocoLoader);
|
||||
const char *classname = pConditionArray[0].GetValue(pCocoLoader);
|
||||
if (classname == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BaseTriggerCondition *con = dynamic_cast<BaseTriggerCondition*>(ObjectFactory::getInstance()->createObject(classname));
|
||||
CCAssert(con != NULL, "class named classname can not implement!");
|
||||
CCAssert(con != nullptr, "class named classname can not implement!");
|
||||
con->serialize(pCocoLoader, &pConditionArray[1]);
|
||||
con->init();
|
||||
_cons.pushBack(con);
|
||||
|
@ -280,14 +280,14 @@ void TriggerObj::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key.compare("actions") == 0)
|
||||
{
|
||||
count = pTriggerObjArray[i].GetChildNum();
|
||||
stExpCocoNode *pActionsArray = pTriggerObjArray[i].GetChildArray();
|
||||
for (int i = 0; i < count; ++i)
|
||||
count = pTriggerObjArray[i0].GetChildNum();
|
||||
stExpCocoNode *pActionsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
|
||||
for (int i2 = 0; i2 < count; ++i2)
|
||||
{
|
||||
num = pActionsArray[i].GetChildNum();
|
||||
stExpCocoNode *pActionArray = pActionsArray[i].GetChildArray();
|
||||
const char *classname = pActionArray[0].GetValue();
|
||||
if (classname == NULL)
|
||||
num = pActionsArray[i2].GetChildNum();
|
||||
stExpCocoNode *pActionArray = pActionsArray[i2].GetChildArray(pCocoLoader);
|
||||
const char *classname = pActionArray[0].GetValue(pCocoLoader);
|
||||
if (classname == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -300,18 +300,18 @@ void TriggerObj::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key.compare("events") == 0)
|
||||
{
|
||||
count = pTriggerObjArray[i].GetChildNum();
|
||||
stExpCocoNode *pEventsArray = pTriggerObjArray[i].GetChildArray();
|
||||
for (int i = 0; i < count; ++i)
|
||||
count = pTriggerObjArray[i0].GetChildNum();
|
||||
stExpCocoNode *pEventsArray = pTriggerObjArray[i0].GetChildArray(pCocoLoader);
|
||||
for (int i3 = 0; i3 < count; ++i3)
|
||||
{
|
||||
num = pEventsArray[i].GetChildNum();
|
||||
stExpCocoNode *pEventArray = pEventsArray[i].GetChildArray();
|
||||
const char *str = pEventArray[0].GetValue();
|
||||
if (str == NULL)
|
||||
num = pEventsArray[i3].GetChildNum();
|
||||
stExpCocoNode *pEventArray = pEventsArray[i3].GetChildArray(pCocoLoader);
|
||||
const char *str1 = pEventArray[0].GetValue(pCocoLoader);
|
||||
if (str1 == nullptr)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int event = atoi(str);
|
||||
int event = atoi(str1);
|
||||
if (event < 0)
|
||||
{
|
||||
continue;
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace cocostudio
|
|||
|
||||
Button *button = static_cast<Button*>(widget);
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
this->beginSetBasicProperties(widget);
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace cocostudio
|
|||
float scale9Width = 0.0f, scale9Height = 0.0f;
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
// CCLOG("Button: key = %s, value = %d", key.c_str(), i);
|
||||
|
||||
//read all basic properties of widget
|
||||
|
@ -86,8 +86,8 @@ namespace cocostudio
|
|||
}
|
||||
else if (key == P_NormalData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -98,8 +98,8 @@ namespace cocostudio
|
|||
}
|
||||
else if (key == P_PressedData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -110,8 +110,8 @@ namespace cocostudio
|
|||
}
|
||||
else if (key == P_DisabledData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -216,23 +216,18 @@ namespace cocostudio
|
|||
}
|
||||
}
|
||||
|
||||
bool cr = DICTOOL->checkObjectExist_json(options, P_TextColorR);
|
||||
bool cg = DICTOOL->checkObjectExist_json(options, P_TextColorG);
|
||||
bool cb = DICTOOL->checkObjectExist_json(options, P_TextColorB);
|
||||
int cri = cr?DICTOOL->getIntValue_json(options, P_TextColorR):255;
|
||||
int cgi = cg?DICTOOL->getIntValue_json(options, P_TextColorG):255;
|
||||
int cbi = cb?DICTOOL->getIntValue_json(options, P_TextColorB):255;
|
||||
|
||||
int cri = DICTOOL->getIntValue_json(options, P_TextColorR,255);
|
||||
int cgi = DICTOOL->getIntValue_json(options, P_TextColorG,255);
|
||||
int cbi = DICTOOL->getIntValue_json(options, P_TextColorB,255);
|
||||
button->setTitleColor(Color3B(cri,cgi,cbi));
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
|
||||
if (fs)
|
||||
{
|
||||
button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
|
||||
}
|
||||
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
|
||||
if (fn)
|
||||
{
|
||||
button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName));
|
||||
}
|
||||
|
||||
|
||||
button->setTitleFontSize(DICTOOL->getIntValue_json(options, P_FontSize,14));
|
||||
|
||||
|
||||
button->setTitleFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑"));
|
||||
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
|
|
|
@ -43,11 +43,11 @@ namespace cocostudio
|
|||
|
||||
CheckBox *checkBox = static_cast<CheckBox*>(widget);
|
||||
this->beginSetBasicProperties(widget);
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
// CCLOG("key = %s, index : %d", key.c_str(), i);
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -56,8 +56,8 @@ namespace cocostudio
|
|||
|
||||
else if (key == P_BackGroundBoxData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -65,8 +65,8 @@ namespace cocostudio
|
|||
|
||||
checkBox->loadTextureBackGround(backgroundValue, imageFileNameType);
|
||||
}else if(key == P_BackGroundBoxSelectedData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -74,8 +74,8 @@ namespace cocostudio
|
|||
|
||||
checkBox->loadTextureBackGroundSelected(backgroundValue, imageFileNameType);
|
||||
}else if(key == P_FrontCrossData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -83,8 +83,8 @@ namespace cocostudio
|
|||
|
||||
checkBox->loadTextureFrontCross(backgroundValue, imageFileNameType);
|
||||
}else if(key == P_BackGroundBoxDisabledData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -92,8 +92,8 @@ namespace cocostudio
|
|||
|
||||
checkBox->loadTextureBackGroundDisabled(backgroundValue, imageFileNameType);
|
||||
}else if (key == P_FrontCrossDisabledData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ namespace cocostudio
|
|||
this->beginSetBasicProperties(widget);
|
||||
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -65,8 +65,8 @@ namespace cocostudio
|
|||
imageView->setScale9Enabled(valueToBool(value));
|
||||
}
|
||||
else if (key == P_FileNameData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -125,19 +125,16 @@ namespace cocostudio
|
|||
|
||||
if (scale9Enable)
|
||||
{
|
||||
bool sw = DICTOOL->checkObjectExist_json(options, P_Scale9Width);
|
||||
bool sh = DICTOOL->checkObjectExist_json(options, P_Scale9Height);
|
||||
if (sw && sh)
|
||||
{
|
||||
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width);
|
||||
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height);
|
||||
imageView->setSize(Size(swf, shf));
|
||||
}
|
||||
|
||||
float swf = DICTOOL->getFloatValue_json(options, P_Scale9Width,80.0f);
|
||||
float shf = DICTOOL->getFloatValue_json(options, P_Scale9Height,80.0f);
|
||||
imageView->setSize(Size(swf, shf));
|
||||
|
||||
|
||||
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
||||
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1.0f);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1.0f);
|
||||
|
||||
imageView->setCapInsets(Rect(cx, cy, cw, ch));
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include "LayoutReader.h"
|
||||
#include "ui/UILayout.h"
|
||||
#include "cocostudio/CocoLoader.h"
|
||||
#include "ui/UIScrollView.h"
|
||||
#include "ui/UIPageView.h"
|
||||
#include "ui/UIListView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace ui;
|
||||
|
@ -61,7 +64,7 @@ namespace cocostudio
|
|||
Layout* panel = static_cast<Layout*>(widget);
|
||||
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
this->beginSetBasicProperties(widget);
|
||||
|
||||
int cr=0, cg = 0, cb = 0;
|
||||
|
@ -69,12 +72,12 @@ namespace cocostudio
|
|||
int ecr=0, ecg=0, ecb= 0;
|
||||
float bgcv1 = 0.0f, bgcv2= 0.0f;
|
||||
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
|
||||
Layout::Type layoutType;
|
||||
Layout::Type layoutType = Layout::Type::ABSOLUTE;
|
||||
int bgColorOpacity = panel->getBackGroundColorOpacity();
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -120,9 +123,9 @@ namespace cocostudio
|
|||
panel->setBackGroundColorType(Layout::BackGroundColorType(valueToInt(value)));
|
||||
}else if (key == P_BackGroundImageData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
if (backGroundChildren) {
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -194,26 +197,77 @@ namespace cocostudio
|
|||
|
||||
bool backGroundScale9Enable = DICTOOL->getBooleanValue_json(options, P_BackGroundScale9Enable);
|
||||
panel->setBackGroundImageScale9Enabled(backGroundScale9Enable);
|
||||
int cr = DICTOOL->getIntValue_json(options, P_BgColorR);
|
||||
int cg = DICTOOL->getIntValue_json(options, P_BgColorG);
|
||||
int cb = DICTOOL->getIntValue_json(options, P_BgColorB);
|
||||
|
||||
int scr = DICTOOL->getIntValue_json(options, P_BgStartColorR);
|
||||
int scg = DICTOOL->getIntValue_json(options, P_BgStartColorG);
|
||||
int scb = DICTOOL->getIntValue_json(options, P_BgStartColorB);
|
||||
|
||||
int ecr = DICTOOL->getIntValue_json(options, P_BgEndColorR);
|
||||
int ecg = DICTOOL->getIntValue_json(options, P_BgEndColorG);
|
||||
int ecb = DICTOOL->getIntValue_json(options, P_BgEndColorB);
|
||||
int cr;
|
||||
int cg;
|
||||
int cb;
|
||||
int scr;
|
||||
int scg;
|
||||
int scb;
|
||||
int ecr;
|
||||
int ecg;
|
||||
int ecb;
|
||||
|
||||
if (dynamic_cast<ui::PageView*>(widget)) {
|
||||
cr = DICTOOL->getIntValue_json(options, "bgColorR",150);
|
||||
cg = DICTOOL->getIntValue_json(options, "bgColorG",150);
|
||||
cb = DICTOOL->getIntValue_json(options, "bgColorB",100);
|
||||
|
||||
scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255);
|
||||
scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255);
|
||||
scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255);
|
||||
|
||||
ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",255);
|
||||
ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150);
|
||||
ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",100);
|
||||
}else if(dynamic_cast<ui::ListView*>(widget)){
|
||||
cr = DICTOOL->getIntValue_json(options, "bgColorR",150);
|
||||
cg = DICTOOL->getIntValue_json(options, "bgColorG",150);
|
||||
cb = DICTOOL->getIntValue_json(options, "bgColorB",255);
|
||||
|
||||
scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255);
|
||||
scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255);
|
||||
scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255);
|
||||
|
||||
ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",150);
|
||||
ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150);
|
||||
ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",255);
|
||||
}else if(dynamic_cast<ui::ScrollView*>(widget)){
|
||||
cr = DICTOOL->getIntValue_json(options, "bgColorR",255);
|
||||
cg = DICTOOL->getIntValue_json(options, "bgColorG",150);
|
||||
cb = DICTOOL->getIntValue_json(options, "bgColorB",100);
|
||||
|
||||
scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255);
|
||||
scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255);
|
||||
scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255);
|
||||
|
||||
ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",255);
|
||||
ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",150);
|
||||
ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",100);
|
||||
}else{
|
||||
cr = DICTOOL->getIntValue_json(options, "bgColorR",150);
|
||||
cg = DICTOOL->getIntValue_json(options, "bgColorG",200);
|
||||
cb = DICTOOL->getIntValue_json(options, "bgColorB",255);
|
||||
|
||||
scr = DICTOOL->getIntValue_json(options, "bgStartColorR",255);
|
||||
scg = DICTOOL->getIntValue_json(options, "bgStartColorG",255);
|
||||
scb = DICTOOL->getIntValue_json(options, "bgStartColorB",255);
|
||||
|
||||
ecr = DICTOOL->getIntValue_json(options, "bgEndColorR",150);
|
||||
ecg = DICTOOL->getIntValue_json(options, "bgEndColorG",200);
|
||||
ecb = DICTOOL->getIntValue_json(options, "bgEndColorB",255);
|
||||
}
|
||||
|
||||
float bgcv1 = DICTOOL->getFloatValue_json(options, P_VectorX);
|
||||
float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY);
|
||||
float bgcv2 = DICTOOL->getFloatValue_json(options, P_VectorY,-0.5);
|
||||
panel->setBackGroundColorVector(Vec2(bgcv1, bgcv2));
|
||||
|
||||
int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity);
|
||||
int co = DICTOOL->getIntValue_json(options, P_BgColorOpacity,100);
|
||||
|
||||
int colorType = DICTOOL->getIntValue_json(options, P_ColorType);
|
||||
int colorType = DICTOOL->getIntValue_json(options, P_ColorType,1);
|
||||
panel->setBackGroundColorType(Layout::BackGroundColorType(colorType));
|
||||
|
||||
panel->setBackGroundColor(Color3B(scr, scg, scb),Color3B(ecr, ecg, ecb));
|
||||
panel->setBackGroundColor(Color3B(cr, cg, cb));
|
||||
panel->setBackGroundColorOpacity(co);
|
||||
|
@ -229,18 +283,21 @@ namespace cocostudio
|
|||
{
|
||||
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
||||
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
|
||||
panel->setBackGroundImageCapInsets(Rect(cx, cy, cw, ch));
|
||||
}
|
||||
|
||||
panel->setLayoutType((Layout::Type)DICTOOL->getIntValue_json(options, P_LayoutType));
|
||||
|
||||
int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR);
|
||||
int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG);
|
||||
int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB);
|
||||
int bgimgcr = DICTOOL->getIntValue_json(options, P_ColorR,255);
|
||||
int bgimgcg = DICTOOL->getIntValue_json(options, P_ColorG,255);
|
||||
int bgimgcb = DICTOOL->getIntValue_json(options, P_ColorB,255);
|
||||
panel->setBackGroundImageColor(Color3B(bgimgcr, bgimgcg, bgimgcb));
|
||||
|
||||
int bgimgopacity = DICTOOL->getIntValue_json(options, "opacity",255);
|
||||
panel->setBackGroundImageOpacity(bgimgopacity);
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ namespace cocostudio
|
|||
|
||||
ListView* listView = static_cast<ListView*>(widget);
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
if (key == P_Direction) {
|
||||
listView->setDirection((ScrollView::Direction)valueToInt(value));
|
||||
|
@ -66,10 +66,10 @@ namespace cocostudio
|
|||
|
||||
ListView* listView = static_cast<ListView*>(widget);
|
||||
|
||||
int direction = DICTOOL->getFloatValue_json(options, P_Direction);
|
||||
int direction = DICTOOL->getFloatValue_json(options, P_Direction,2);
|
||||
listView->setDirection((ScrollView::Direction)direction);
|
||||
|
||||
ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity);
|
||||
ListView::Gravity gravity = (ListView::Gravity)DICTOOL->getIntValue_json(options, P_Gravity,3);
|
||||
listView->setGravity(gravity);
|
||||
|
||||
float itemMargin = DICTOOL->getFloatValue_json(options, P_ItemMargin);
|
||||
|
|
|
@ -51,11 +51,11 @@ namespace cocostudio
|
|||
float capsx = 0.0f, capsy = 0.0, capsWidth = 0.0, capsHeight = 0.0f;
|
||||
int percent = loadingBar->getPercent();
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -67,8 +67,8 @@ namespace cocostudio
|
|||
}
|
||||
else if (key == P_TextureData){
|
||||
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -117,23 +117,25 @@ namespace cocostudio
|
|||
bool scale9Enable = DICTOOL->getBooleanValue_json(options, P_Scale9Enable);
|
||||
loadingBar->setScale9Enabled(scale9Enable);
|
||||
|
||||
if (scale9Enable)
|
||||
{
|
||||
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
||||
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight);
|
||||
|
||||
|
||||
float cx = DICTOOL->getFloatValue_json(options, P_CapInsetsX);
|
||||
float cy = DICTOOL->getFloatValue_json(options, P_CapInsetsY);
|
||||
float cw = DICTOOL->getFloatValue_json(options, P_CapInsetsWidth,1);
|
||||
float ch = DICTOOL->getFloatValue_json(options, P_CapInsetsHeight,1);
|
||||
|
||||
if (scale9Enable) {
|
||||
loadingBar->setCapInsets(Rect(cx, cy, cw, ch));
|
||||
|
||||
float width = DICTOOL->getFloatValue_json(options, P_Width);
|
||||
float height = DICTOOL->getFloatValue_json(options, P_Height);
|
||||
loadingBar->setSize(Size(width, height));
|
||||
|
||||
}
|
||||
|
||||
float width = DICTOOL->getFloatValue_json(options, P_Width);
|
||||
float height = DICTOOL->getFloatValue_json(options, P_Height);
|
||||
loadingBar->setSize(Size(width, height));
|
||||
|
||||
/**/
|
||||
|
||||
loadingBar->setDirection(LoadingBar::Direction(DICTOOL->getIntValue_json(options, P_Direction)));
|
||||
loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
|
||||
loadingBar->setPercent(DICTOOL->getIntValue_json(options, P_Percent,100));
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
|
|
|
@ -44,12 +44,12 @@ namespace cocostudio
|
|||
|
||||
ScrollView* scrollView = static_cast<ScrollView*>(widget);
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
float innerWidth;
|
||||
float innerHeight;
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
if (key == P_InnerWidth) {
|
||||
innerWidth = valueToFloat(value);
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ namespace cocostudio
|
|||
|
||||
|
||||
ScrollView* scrollView = static_cast<ScrollView*>(widget);
|
||||
float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth);
|
||||
float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight);
|
||||
float innerWidth = DICTOOL->getFloatValue_json(options, P_InnerWidth,200);
|
||||
float innerHeight = DICTOOL->getFloatValue_json(options, P_InnerHeight,200);
|
||||
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
||||
int direction = DICTOOL->getFloatValue_json(options, P_Direction);
|
||||
int direction = DICTOOL->getFloatValue_json(options, P_Direction,1);
|
||||
scrollView->setDirection((ScrollView::Direction)direction);
|
||||
scrollView->setBounceEnabled(DICTOOL->getBooleanValue_json(options, P_BounceEnable));
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ namespace cocostudio
|
|||
|
||||
float barLength = 0.0f;
|
||||
int percent = slider->getPercent();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -69,8 +69,8 @@ namespace cocostudio
|
|||
else if(key == P_Percent){
|
||||
percent = valueToInt(value);
|
||||
}else if(key == P_BarFileNameData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -81,8 +81,8 @@ namespace cocostudio
|
|||
}else if(key == P_Length){
|
||||
barLength = valueToFloat(value);
|
||||
}else if(key == P_BallNormalData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -91,8 +91,8 @@ namespace cocostudio
|
|||
slider->loadSlidBallTextureNormal(backgroundValue, imageFileNameType);
|
||||
|
||||
}else if(key == P_BallPressedData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -101,8 +101,8 @@ namespace cocostudio
|
|||
slider->loadSlidBallTexturePressed(backgroundValue, imageFileNameType);
|
||||
|
||||
}else if(key == P_BallDisabledData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -111,8 +111,8 @@ namespace cocostudio
|
|||
slider->loadSlidBallTextureDisabled(backgroundValue, imageFileNameType);
|
||||
|
||||
}else if(key == P_ProgressBarData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -145,25 +145,24 @@ namespace cocostudio
|
|||
slider->setPercent(DICTOOL->getIntValue_json(options, P_Percent));
|
||||
|
||||
|
||||
bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
|
||||
float barLength = DICTOOL->getFloatValue_json(options, P_Length);
|
||||
if (bt)
|
||||
{
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
|
||||
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
// bool bt = DICTOOL->checkObjectExist_json(options, P_BarFileName);
|
||||
float barLength = DICTOOL->getFloatValue_json(options, P_Length,290);
|
||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, P_BarFileNameData);
|
||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, P_ResourceType);
|
||||
std::string imageFileName = this->getResourcePath(imageFileNameDic, P_Path, (Widget::TextureResType)imageFileNameType);
|
||||
slider->loadBarTexture(imageFileName, (Widget::TextureResType)imageFileNameType);
|
||||
|
||||
if (barTextureScale9Enable)
|
||||
{
|
||||
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
||||
}
|
||||
|
||||
|
||||
if (barTextureScale9Enable)
|
||||
{
|
||||
slider->setContentSize(Size(barLength, slider->getContentSize().height));
|
||||
}
|
||||
|
||||
//loading normal slider ball texture
|
||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, P_BallNormalData);
|
||||
int normalType = DICTOOL->getIntValue_json(normalDic, P_ResourceType);
|
||||
std::string imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
|
||||
imageFileName = this->getResourcePath(normalDic, P_Path, (Widget::TextureResType)normalType);
|
||||
slider->loadSlidBallTextureNormal(imageFileName, (Widget::TextureResType)normalType);
|
||||
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace cocostudio
|
|||
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
|
||||
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
Widget::TextureResType type;
|
||||
std::string charMapFileName;
|
||||
std::string stringValue;
|
||||
|
@ -57,7 +57,7 @@ namespace cocostudio
|
|||
float itemHeight;
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -68,8 +68,8 @@ namespace cocostudio
|
|||
stringValue = value;
|
||||
}
|
||||
else if(key == P_CharMapFileData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -101,34 +101,37 @@ namespace cocostudio
|
|||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
|
||||
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
|
||||
bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
|
||||
bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
|
||||
bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
|
||||
bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
|
||||
bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
|
||||
if (sv && cmf && iw && ih && scm)
|
||||
// bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
|
||||
// bool cmf = DICTOOL->checkObjectExist_json(options, P_CharMapFile);
|
||||
// bool iw = DICTOOL->checkObjectExist_json(options, P_ItemWidth);
|
||||
// bool ih = DICTOOL->checkObjectExist_json(options, P_ItemHeight);
|
||||
// bool scm = DICTOOL->checkObjectExist_json(options, P_StartCharMap);
|
||||
|
||||
const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData);
|
||||
int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType);
|
||||
switch (cmfType)
|
||||
{
|
||||
const rapidjson::Value& cmftDic = DICTOOL->getSubDictionary_json(options, P_CharMapFileData);
|
||||
int cmfType = DICTOOL->getIntValue_json(cmftDic, P_ResourceType);
|
||||
switch (cmfType)
|
||||
case 0:
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
std::string tp_c = jsonPath;
|
||||
const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path);
|
||||
const char* cmf_tp = tp_c.append(cmfPath).c_str();
|
||||
labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue),cmf_tp,DICTOOL->getIntValue_json(options, P_ItemWidth),DICTOOL->getIntValue_json(options,P_ItemHeight), DICTOOL->getStringValue_json(options, P_StartCharMap));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
CCLOG("Wrong res type of LabelAtlas!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
std::string tp_c = jsonPath;
|
||||
const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path);
|
||||
const char* cmf_tp = tp_c.append(cmfPath).c_str();
|
||||
labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue,"12345678"),
|
||||
cmf_tp,
|
||||
DICTOOL->getIntValue_json(options, P_ItemWidth,24),
|
||||
DICTOOL->getIntValue_json(options,P_ItemHeight,32),
|
||||
DICTOOL->getStringValue_json(options, P_StartCharMap));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
CCLOG("Wrong res type of LabelAtlas!");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,19 +42,19 @@ namespace cocostudio
|
|||
TextBMFont* labelBMFont = static_cast<TextBMFont*>(widget);
|
||||
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
//read all color related properties of widget
|
||||
CC_COLOR_PROPERTY_BINARY_READER
|
||||
|
||||
else if(key == P_FileNameData){
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray();
|
||||
std::string resType = backGroundChildren[2].GetValue();;
|
||||
stExpCocoNode *backGroundChildren = stChildArray[i].GetChildArray(cocoLoader);
|
||||
std::string resType = backGroundChildren[2].GetValue(cocoLoader);;
|
||||
|
||||
Widget::TextureResType imageFileNameType = (Widget::TextureResType)valueToInt(resType);
|
||||
|
||||
|
@ -98,7 +98,7 @@ namespace cocostudio
|
|||
break;
|
||||
}
|
||||
|
||||
const char* text = DICTOOL->getStringValue_json(options, P_Text);
|
||||
const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label");
|
||||
labelBMFont->setString(text);
|
||||
|
||||
|
||||
|
|
|
@ -49,11 +49,11 @@ namespace cocostudio
|
|||
|
||||
TextField* textField = static_cast<TextField*>(widget);
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
|
@ -94,19 +94,15 @@ namespace cocostudio
|
|||
bool ph = DICTOOL->checkObjectExist_json(options, P_PlaceHolder);
|
||||
if (ph)
|
||||
{
|
||||
textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder));
|
||||
}
|
||||
textField->setText(DICTOOL->getStringValue_json(options, P_Text));
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
|
||||
if (fs)
|
||||
{
|
||||
textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
|
||||
}
|
||||
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
|
||||
if (fn)
|
||||
{
|
||||
textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName));
|
||||
textField->setPlaceHolder(DICTOOL->getStringValue_json(options, P_PlaceHolder,"input words here"));
|
||||
}
|
||||
textField->setText(DICTOOL->getStringValue_json(options, P_Text,"Text Tield"));
|
||||
|
||||
textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
|
||||
|
||||
|
||||
textField->setFontName(DICTOOL->getStringValue_json(options, P_FontName,"微软雅黑"));
|
||||
|
||||
bool tsw = DICTOOL->checkObjectExist_json(options, P_TouchSizeWidth);
|
||||
bool tsh = DICTOOL->checkObjectExist_json(options, P_TouchSizeHeight);
|
||||
if (tsw && tsh)
|
||||
|
@ -125,14 +121,14 @@ namespace cocostudio
|
|||
|
||||
if (maxLengthEnable)
|
||||
{
|
||||
int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength);
|
||||
int maxLength = DICTOOL->getIntValue_json(options, P_MaxLength,10);
|
||||
textField->setMaxLength(maxLength);
|
||||
}
|
||||
bool passwordEnable = DICTOOL->getBooleanValue_json(options, P_PasswordEnable);
|
||||
textField->setPasswordEnabled(passwordEnable);
|
||||
if (passwordEnable)
|
||||
{
|
||||
textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText));
|
||||
textField->setPasswordStyleText(DICTOOL->getStringValue_json(options, P_PasswordStyleText,"*"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace cocostudio
|
|||
{
|
||||
this->beginSetBasicProperties(widget);
|
||||
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
Text* label = static_cast<Text*>(widget);
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace cocostudio
|
|||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
//read all basic properties of widget
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
//read all color related properties of widget
|
||||
|
@ -69,7 +69,12 @@ namespace cocostudio
|
|||
}else if(key == P_FontSize){
|
||||
label->setFontSize(valueToInt(value));
|
||||
}else if(key == P_FontName){
|
||||
std::string fontFilePath = jsonPath.append(value);
|
||||
std::string fontFilePath;
|
||||
if(FileUtils::getInstance()->isFileExist(value)){
|
||||
fontFilePath = jsonPath.append(value);
|
||||
}else{
|
||||
fontFilePath = value;
|
||||
}
|
||||
label->setFontName(fontFilePath);
|
||||
}else if(key == P_AreaWidth){
|
||||
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));
|
||||
|
@ -95,20 +100,15 @@ namespace cocostudio
|
|||
Text* label = static_cast<Text*>(widget);
|
||||
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, P_TouchScaleEnable);
|
||||
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
|
||||
const char* text = DICTOOL->getStringValue_json(options, P_Text);
|
||||
const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label");
|
||||
label->setString(text);
|
||||
bool fs = DICTOOL->checkObjectExist_json(options, P_FontSize);
|
||||
if (fs)
|
||||
{
|
||||
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize));
|
||||
}
|
||||
bool fn = DICTOOL->checkObjectExist_json(options, P_FontName);
|
||||
if (fn)
|
||||
{
|
||||
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName);
|
||||
std::string fontFilePath = jsonPath.append(fontName);
|
||||
label->setFontName(fontFilePath);
|
||||
}
|
||||
|
||||
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
|
||||
|
||||
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
|
||||
std::string fontFilePath = jsonPath.append(fontName);
|
||||
label->setFontName(fontFilePath);
|
||||
|
||||
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
|
||||
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);
|
||||
if (aw && ah)
|
||||
|
|
|
@ -113,11 +113,9 @@ namespace cocostudio
|
|||
|
||||
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
||||
{
|
||||
bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
|
||||
if (ignoreSizeExsit)
|
||||
{
|
||||
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
|
||||
}
|
||||
|
||||
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
|
||||
|
||||
|
||||
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
|
||||
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
|
||||
|
@ -151,21 +149,15 @@ namespace cocostudio
|
|||
float x = DICTOOL->getFloatValue_json(options, P_X);
|
||||
float y = DICTOOL->getFloatValue_json(options, P_Y);
|
||||
widget->setPosition(Vec2(x,y));
|
||||
bool sx = DICTOOL->checkObjectExist_json(options, P_ScaleX);
|
||||
if (sx)
|
||||
{
|
||||
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX));
|
||||
}
|
||||
bool sy = DICTOOL->checkObjectExist_json(options, P_ScaleY);
|
||||
if (sy)
|
||||
{
|
||||
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY));
|
||||
}
|
||||
bool rt = DICTOOL->checkObjectExist_json(options, P_Rotation);
|
||||
if (rt)
|
||||
{
|
||||
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation));
|
||||
}
|
||||
|
||||
widget->setScaleX(DICTOOL->getFloatValue_json(options, P_ScaleX,1.0));
|
||||
|
||||
|
||||
widget->setScaleY(DICTOOL->getFloatValue_json(options, P_ScaleY,1.0));
|
||||
|
||||
|
||||
widget->setRotation(DICTOOL->getFloatValue_json(options, P_Rotation,0));
|
||||
|
||||
bool vb = DICTOOL->checkObjectExist_json(options, P_Visbile);
|
||||
if (vb)
|
||||
{
|
||||
|
@ -295,8 +287,8 @@ namespace cocostudio
|
|||
|
||||
std::string WidgetReader::getResourcePath(CocoLoader *cocoLoader, stExpCocoNode *cocoNode, cocos2d::ui::Widget::TextureResType texType)
|
||||
{
|
||||
stExpCocoNode *backGroundChildren = cocoNode->GetChildArray();
|
||||
std::string backgroundValue = backGroundChildren[0].GetValue();
|
||||
stExpCocoNode *backGroundChildren = cocoNode->GetChildArray(cocoLoader);
|
||||
std::string backgroundValue = backGroundChildren[0].GetValue(cocoLoader);
|
||||
|
||||
if (backgroundValue.size() < 3) {
|
||||
return "";
|
||||
|
@ -346,13 +338,13 @@ namespace cocostudio
|
|||
|
||||
void WidgetReader::setPropsFromBinary(cocos2d::ui::Widget *widget, cocostudio::CocoLoader *cocoLoader, cocostudio::stExpCocoNode *cocoNode)
|
||||
{
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray();
|
||||
stExpCocoNode *stChildArray = cocoNode->GetChildArray(cocoLoader);
|
||||
|
||||
this->beginSetBasicProperties(widget);
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||
std::string key = stChildArray[i].GetName(cocoLoader);
|
||||
std::string value = stChildArray[i].GetValue();
|
||||
std::string value = stChildArray[i].GetValue(cocoLoader);
|
||||
|
||||
CC_BASIC_PROPERTY_BINARY_READER
|
||||
}
|
||||
|
|
|
@ -176,14 +176,14 @@ namespace cocostudio
|
|||
}else if(key == P_ZOrder){ \
|
||||
widget->setZOrder(valueToInt(value)); \
|
||||
}else if(key == P_LayoutParameter){ \
|
||||
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(); \
|
||||
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(cocoLoader); \
|
||||
ui::LinearLayoutParameter *linearParameter = ui::LinearLayoutParameter::create(); \
|
||||
ui::RelativeLayoutParameter *relativeParameter = ui::RelativeLayoutParameter::create(); \
|
||||
ui::Margin mg; \
|
||||
int paramType = -1; \
|
||||
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) { \
|
||||
std::string innerKey = layoutCocosNode[j].GetName(cocoLoader); \
|
||||
std::string innerValue = layoutCocosNode[j].GetValue(); \
|
||||
std::string innerValue = layoutCocosNode[j].GetValue(cocoLoader); \
|
||||
if (innerKey == P_Type) { \
|
||||
paramType = valueToInt(innerValue); \
|
||||
}else if(innerKey == P_Gravity){ \
|
||||
|
|
|
@ -188,7 +188,7 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;$(EngineRoot)external\win32-specific\zlib\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
|
||||
|
|
|
@ -36,9 +36,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..
|
|||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \
|
||||
$(LOCAL_PATH)/..
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
|
|
@ -15,8 +15,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..
|
|||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../.. \
|
||||
$(LOCAL_PATH)/..
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_curl_static
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>libControllerAutoAdapter</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,4 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.cocos2dx.lib"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-sdk android:minSdkVersion="10"/>
|
||||
|
||||
</manifest>
|
|
@ -1,17 +0,0 @@
|
|||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="androidControllerAutoAdapter" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="NewApi">
|
||||
<ignore path="src/org/cocos2dx/lib/GameControllerHelper.java" />
|
||||
</issue>
|
||||
</lint>
|
|
@ -1,20 +0,0 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -1,16 +0,0 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
android.library=true
|
||||
# Project target.
|
||||
target=android-16
|
||||
android.library.reference.1=../java
|
|
@ -1,284 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2013 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import org.cocos2dx.lib.GameControllerDelegate.ControllerEventListener;
|
||||
import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat;
|
||||
import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListener;
|
||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.util.Log;
|
||||
|
||||
public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener {
|
||||
// ===========================================================
|
||||
// Constants
|
||||
// ===========================================================
|
||||
|
||||
private final static String TAG = GameControllerActivity.class.getSimpleName();
|
||||
|
||||
public static final int DRIVERTYPE_NIBIRU = 0;
|
||||
public static final int DRIVERTYPE_MOGA = 1;
|
||||
public static final int DRIVERTYPE_OUYA = 2;
|
||||
public static final int DRIVERTYPE_STANDARD = 3;
|
||||
public static final int DRIVERTYPE_UNKNOWN = 4;
|
||||
|
||||
// ===========================================================
|
||||
// Fields
|
||||
// ===========================================================
|
||||
private static GameControllerActivity sGameControllerActivity;
|
||||
private InputManagerCompat mInputManager = null;
|
||||
|
||||
protected GameControllerHelper mControllerHelper = null;
|
||||
|
||||
protected GameControllerDelegate mControllerNibiru = null;
|
||||
protected GameControllerDelegate mControllerMoga = null;
|
||||
protected GameControllerDelegate mControllerOuya = null;
|
||||
|
||||
public void connectController(){
|
||||
mControllerHelper.connectController();
|
||||
}
|
||||
|
||||
public void setGameControllerInstance(GameControllerDelegate controllerDelegate, int driveType) {
|
||||
if (driveType == DRIVERTYPE_NIBIRU) {
|
||||
mControllerNibiru = controllerDelegate;
|
||||
}else if (driveType == DRIVERTYPE_MOGA) {
|
||||
mControllerMoga = controllerDelegate;
|
||||
}
|
||||
else if (driveType == DRIVERTYPE_OUYA) {
|
||||
mControllerOuya = controllerDelegate;
|
||||
}
|
||||
controllerDelegate.setControllerEventListener(mControllerEventListener);
|
||||
controllerDelegate.onCreate(sGameControllerActivity);
|
||||
}
|
||||
|
||||
public GameControllerDelegate getGameControllerDelegate(int driveType){
|
||||
if (driveType == DRIVERTYPE_NIBIRU) {
|
||||
return mControllerNibiru;
|
||||
}else if (driveType == DRIVERTYPE_MOGA) {
|
||||
return mControllerMoga;
|
||||
}
|
||||
else if (driveType == DRIVERTYPE_OUYA) {
|
||||
return mControllerOuya;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
ControllerEventListener mControllerEventListener = new ControllerEventListener() {
|
||||
|
||||
@Override
|
||||
public void onButtonEvent(String vendorName, int controller, int button,
|
||||
boolean isPressed, float value, boolean isAnalog) {
|
||||
GameControllerAdapter.onButtonEvent(vendorName, controller, button, isPressed, value, isAnalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAxisEvent(String vendorName, int controller, int axisID,
|
||||
float value, boolean isAnalog) {
|
||||
GameControllerAdapter.onAxisEvent(vendorName, controller, axisID, value, isAnalog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected(String vendorName, int controller) {
|
||||
GameControllerAdapter.onConnected(vendorName, controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected(String vendorName, int controller) {
|
||||
GameControllerAdapter.onDisconnected(vendorName, controller);
|
||||
}
|
||||
};
|
||||
|
||||
// ===========================================================
|
||||
// Constructors
|
||||
// ===========================================================
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
sGameControllerActivity = this;
|
||||
mInputManager = InputManagerCompat.Factory.getInputManager(this);
|
||||
mInputManager.registerInputDeviceListener(this, null);
|
||||
|
||||
if (mControllerNibiru != null) {
|
||||
mControllerNibiru.onCreate(this);
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
mControllerMoga.onCreate(this);
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
mControllerOuya.onCreate(this);
|
||||
}
|
||||
if (mControllerHelper == null) {
|
||||
mControllerHelper = new GameControllerHelper(this);
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
// Getter & Setter
|
||||
// ===========================================================
|
||||
|
||||
// ===========================================================
|
||||
// Methods for/from SuperClass/Interfaces
|
||||
// ===========================================================
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
boolean handled = false;
|
||||
if (mControllerNibiru != null) {
|
||||
handled |= mControllerNibiru.dispatchKeyEvent(event);
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
handled |= mControllerMoga.dispatchKeyEvent(event);
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
handled |= mControllerOuya.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
handled |= mControllerHelper.dispatchKeyEvent(event);
|
||||
Log.d(TAG, "dispatchKeyEvent:" + handled);
|
||||
|
||||
return handled || super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent event) {
|
||||
boolean handled = false;
|
||||
if (mControllerNibiru != null) {
|
||||
handled |= mControllerNibiru.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
handled |= mControllerMoga.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
handled |= mControllerOuya.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
handled |= mControllerHelper.dispatchGenericMotionEvent(event);
|
||||
|
||||
return handled || super.dispatchGenericMotionEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceAdded(int deviceId) {
|
||||
|
||||
Log.d(TAG,"onInputDeviceAdded:" + deviceId);
|
||||
|
||||
InputDevice device = InputDevice.getDevice(deviceId);
|
||||
int deviceSource = device.getSources();
|
||||
|
||||
if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
|| ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||
{
|
||||
GameControllerAdapter.onConnected("Standard", deviceId);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This is an unusual case. Input devices don't typically change, but they
|
||||
* certainly can --- for example a device may have different modes. We use
|
||||
* this to make sure that the ship has an up-to-date InputDevice.
|
||||
*
|
||||
* @see
|
||||
* com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener
|
||||
* #onInputDeviceChanged(int)
|
||||
*/
|
||||
@Override
|
||||
public void onInputDeviceChanged(int deviceId) {
|
||||
Log.d(TAG,"onInputDeviceChanged:" + deviceId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove any ship associated with the ID.
|
||||
*
|
||||
* @see
|
||||
* com.example.inputmanagercompat.InputManagerCompat.InputDeviceListener
|
||||
* #onInputDeviceRemoved(int)
|
||||
*/
|
||||
@Override
|
||||
public void onInputDeviceRemoved(int deviceId) {
|
||||
Log.d(TAG,"onInputDeviceRemoved:" + deviceId);
|
||||
|
||||
InputDevice device = InputDevice.getDevice(deviceId);
|
||||
int deviceSource = device.getSources();
|
||||
|
||||
if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
|| ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||
{
|
||||
GameControllerAdapter.onDisconnected("Standard", deviceId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (mControllerNibiru != null) {
|
||||
mControllerNibiru.onResume();
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
mControllerMoga.onResume();
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
mControllerOuya.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (mControllerNibiru != null) {
|
||||
mControllerNibiru.onPause();
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
mControllerMoga.onPause();
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
mControllerOuya.onPause();
|
||||
}
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mControllerNibiru != null) {
|
||||
mControllerNibiru.onDestroy();
|
||||
}
|
||||
if (mControllerMoga != null) {
|
||||
mControllerMoga.onDestroy();
|
||||
}
|
||||
if (mControllerOuya != null) {
|
||||
mControllerOuya.onDestroy();
|
||||
}
|
||||
|
||||
mControllerHelper.destrory();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,856 +0,0 @@
|
|||
package org.cocos2dx.lib;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.apache.http.Header;
|
||||
|
||||
import com.loopj.android.http.AsyncHttpClient;
|
||||
import com.loopj.android.http.FileAsyncHttpResponseHandler;
|
||||
import com.loopj.android.http.JsonHttpResponseHandler;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class GameControllerHelper {
|
||||
|
||||
private final static String TAG = GameControllerHelper.class.getSimpleName();
|
||||
|
||||
public static final String StandardControllerName = "Standard";
|
||||
public static final String[] DRIVERS_NAME = {"nibiru","moga","ouya",StandardControllerName};
|
||||
|
||||
public static final String SPP_UUID = "00001101-0000-1000-8000-00805F9B34FB";
|
||||
|
||||
SparseIntArray ControllerKeyMap;
|
||||
|
||||
private static final String COCOS_CONTROLLER_URL = "http://115.28.134.83:9000/download/cocoscontroller/";
|
||||
private static final String COCOS_CONTROLLER_CONFIG = "controller.json";
|
||||
|
||||
private static final String NIBIRU_DEP_PACKAGE = "com.nibiru";
|
||||
private static final String MOGA__DEP_PACKAGE = "com.bda.pivot.mogapgp";
|
||||
|
||||
private static GameControllerActivity sGameControllerActivity;
|
||||
private static GameControllerHelper sControllerHelper;
|
||||
|
||||
private String mLibAdapterFileName;
|
||||
private int mLibAdapterFileSize;
|
||||
|
||||
private List<String> mNibiruSupportedDrives;
|
||||
private String mNibiruDepFileName;
|
||||
private int mNibiruDepFileSize;
|
||||
|
||||
private List<String> mMogaSupportedDrives;
|
||||
private String mMogaDepFileName;
|
||||
private int mMogaDepFileSize;
|
||||
|
||||
private List<String> mOuyaSupportedDrives;
|
||||
|
||||
private AsyncHttpClient mDownDepsHttpClient = null;
|
||||
|
||||
private BluetoothAdapter mBluetoothAdapter = null;
|
||||
private ArrayList<BluetoothDevice> mBluetoothDevices = null;
|
||||
private SparseIntArray mDevicesDriver;
|
||||
private int mClearDevices = 0;
|
||||
|
||||
private String mConfigFilePath;
|
||||
private String mLocalSavePath = null;
|
||||
|
||||
private boolean mLazyInit = true;
|
||||
private boolean mLazyConfigInit = true;
|
||||
private static ControllerListener mControllerListener = null;
|
||||
|
||||
public static interface ControllerListener{
|
||||
void onDownloadConfigStarted();
|
||||
void onDownloadConfigFinished(boolean isSuccess);
|
||||
|
||||
void onControllerDiscoveryStarted();
|
||||
//
|
||||
void onControllerDiscoveryFinish(ArrayList<BluetoothDevice> devices);
|
||||
|
||||
void onDownloadDepsStarted();
|
||||
void onDownloadDepsProgress(int bytesWritten, int totalSize);
|
||||
void onDownloadDepsFinished(boolean isSuccess);
|
||||
|
||||
void onInstallDriver(String filePath);
|
||||
void onConnectController();
|
||||
}
|
||||
|
||||
public void setControllerListener(ControllerListener listener){
|
||||
mControllerListener = listener;
|
||||
}
|
||||
|
||||
private static final int AXIS_X = 0;
|
||||
private static final int AXIS_Y = 1;
|
||||
private static final int AXIS_Z = 11;
|
||||
private static final int AXIS_RZ = 14;
|
||||
public static final int AXIS_LTRIGGER = 17;
|
||||
public static final int AXIS_RTRIGGER = 18;
|
||||
public static final int AXIS_BRAKE = 23;
|
||||
public static final int AXIS_THROTTLE = 19;
|
||||
|
||||
public GameControllerHelper(GameControllerActivity activity){
|
||||
sGameControllerActivity = activity;
|
||||
sControllerHelper = this;
|
||||
|
||||
ControllerKeyMap = new SparseIntArray(25);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_A, GameControllerDelegate.BUTTON_A);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_B, GameControllerDelegate.BUTTON_B);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_C, GameControllerDelegate.BUTTON_C);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_X, GameControllerDelegate.BUTTON_X);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_Y, GameControllerDelegate.BUTTON_Y);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_Z, GameControllerDelegate.BUTTON_Z);
|
||||
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_UP, GameControllerDelegate.BUTTON_DPAD_UP);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_DOWN, GameControllerDelegate.BUTTON_DPAD_DOWN);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_LEFT, GameControllerDelegate.BUTTON_DPAD_LEFT);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_RIGHT, GameControllerDelegate.BUTTON_DPAD_RIGHT);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_DPAD_CENTER, GameControllerDelegate.BUTTON_DPAD_CENTER);
|
||||
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_THUMBL, GameControllerDelegate.BUTTON_LEFT_THUMBSTICK);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_THUMBR, GameControllerDelegate.BUTTON_RIGHT_THUMBSTICK);
|
||||
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_L1, GameControllerDelegate.BUTTON_LEFT_SHOULDER);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_R1, GameControllerDelegate.BUTTON_RIGHT_SHOULDER);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_L2, GameControllerDelegate.BUTTON_LEFT_TRIGGER);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_R2, GameControllerDelegate.BUTTON_RIGHT_TRIGGER);
|
||||
|
||||
ControllerKeyMap.put(AXIS_X, GameControllerDelegate.THUMBSTICK_LEFT_X);
|
||||
ControllerKeyMap.put(AXIS_Y, GameControllerDelegate.THUMBSTICK_LEFT_Y);
|
||||
ControllerKeyMap.put(AXIS_Z, GameControllerDelegate.THUMBSTICK_RIGHT_X);
|
||||
ControllerKeyMap.put(AXIS_RZ, GameControllerDelegate.THUMBSTICK_RIGHT_Y);
|
||||
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_START, GameControllerDelegate.BUTTON_START);
|
||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GameControllerDelegate.BUTTON_SELECT);
|
||||
//KEYCODE_BUTTON_MODE
|
||||
mDownDepsHttpClient = new AsyncHttpClient();
|
||||
mDownDepsHttpClient.setTimeout(360 * 1000);
|
||||
}
|
||||
|
||||
public void connectController(){
|
||||
if (mLazyInit) {
|
||||
mLazyInit = false;
|
||||
mNibiruSupportedDrives = new ArrayList<String>(30);
|
||||
mMogaSupportedDrives = new ArrayList<String>(5);
|
||||
mOuyaSupportedDrives = new ArrayList<String>(5);
|
||||
|
||||
mLocalSavePath = Environment.getExternalStorageDirectory() + File.separator + "CocosGameController" + File.separator;
|
||||
Log.i(TAG, "mLocalSavePath:" + mLocalSavePath);
|
||||
mConfigFilePath = sGameControllerActivity.getFilesDir().getAbsolutePath() + File.separator + COCOS_CONTROLLER_CONFIG;
|
||||
Log.i(TAG, "mConfigFilePath:" + mConfigFilePath);
|
||||
|
||||
}
|
||||
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadConfigStarted();
|
||||
}
|
||||
if (mLazyConfigInit) {
|
||||
//if (mDownDepsHttpClient != null) {
|
||||
// mDownDepsHttpClient.cancelRequests(sGameControllerActivity, true);
|
||||
//}
|
||||
requestControllerConfig();
|
||||
}
|
||||
else {
|
||||
scanBluetoothDrive();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<BluetoothDevice> getBondedDevices(){
|
||||
if (mBluetoothAdapter == null) {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (mBluetoothAdapter == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return mBluetoothAdapter.getBondedDevices();
|
||||
}
|
||||
|
||||
public void destrory(){
|
||||
if (mDownDepsHttpClient != null) {
|
||||
mDownDepsHttpClient.cancelRequests(sGameControllerActivity, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean scanBluetoothDrive(){
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadConfigFinished(true);
|
||||
}
|
||||
|
||||
if (mBluetoothAdapter == null) {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (mBluetoothAdapter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mBluetoothDevices == null) {
|
||||
mBluetoothDevices = new ArrayList<BluetoothDevice>(5);
|
||||
mDevicesDriver = new SparseIntArray();
|
||||
}
|
||||
|
||||
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
|
||||
//filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
|
||||
//filter.addAction(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED);
|
||||
//filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
||||
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
|
||||
sGameControllerActivity.registerReceiver(mBluetoothReceiver, filter);
|
||||
|
||||
IntentFilter appFilter = new IntentFilter();
|
||||
appFilter.addAction("android.intent.action.PACKAGE_ADDED");
|
||||
appFilter.addDataScheme("package");
|
||||
sGameControllerActivity.registerReceiver(mAppReceiver, appFilter);
|
||||
}
|
||||
|
||||
if (!mBluetoothAdapter.isEnabled()) {
|
||||
mBluetoothAdapter.enable();
|
||||
}
|
||||
|
||||
if (mBluetoothAdapter.isDiscovering()) {
|
||||
mBluetoothAdapter.cancelDiscovery();
|
||||
}
|
||||
|
||||
mBluetoothAdapter.startDiscovery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int checkDriverType(BluetoothDevice device){
|
||||
String deviceName = device.getName();
|
||||
|
||||
if (mNibiruSupportedDrives.contains(deviceName)) {
|
||||
return GameControllerActivity.DRIVERTYPE_NIBIRU;
|
||||
}
|
||||
else if (mMogaSupportedDrives.contains(deviceName)) {
|
||||
return GameControllerActivity.DRIVERTYPE_MOGA;
|
||||
}
|
||||
else if (mOuyaSupportedDrives.contains(deviceName)) {
|
||||
return GameControllerActivity.DRIVERTYPE_OUYA;
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
return GameControllerActivity.DRIVERTYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
public static void installApplication(String filePath){
|
||||
if (sGameControllerActivity != null) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.android.package-archive");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
sGameControllerActivity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkApplication(String packName){
|
||||
try {
|
||||
ApplicationInfo applicationInfo = sGameControllerActivity.getPackageManager().getApplicationInfo(packName, PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
Log.d(TAG, applicationInfo.toString());
|
||||
return true;
|
||||
} catch (NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private BroadcastReceiver mBluetoothReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
if (mBluetoothDevices.contains(device)) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "Remote device discovered :" + device.getName());
|
||||
//We can't ensure non-controller can be filtered out.Some game controller marked with computer class.
|
||||
/*String deviceName = device.getName();
|
||||
|
||||
if(device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.COMPUTER
|
||||
|| device.getBluetoothClass().getMajorDeviceClass() == BluetoothClass.Device.Major.PHONE)
|
||||
{
|
||||
Log.w(TAG, "Remote device discovered :" + deviceName + " is computer or phone." + device.getBluetoothClass().getMajorDeviceClass());
|
||||
return;
|
||||
}*/
|
||||
|
||||
mBluetoothDevices.add(device);
|
||||
int type = checkDriverType(device);
|
||||
if (type != GameControllerActivity.DRIVERTYPE_UNKNOWN) {
|
||||
mTargetDriverType = type;
|
||||
mClearDevices += 1;
|
||||
}
|
||||
mDevicesDriver.append(mBluetoothDevices.size() - 1, type);
|
||||
}
|
||||
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
|
||||
Log.d(TAG, "The local Bluetooth adapter has finished the device discovery process.");
|
||||
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onControllerDiscoveryFinish(mBluetoothDevices);
|
||||
}
|
||||
else {
|
||||
if (mBluetoothDevices.size() == 0) {
|
||||
if (checkApplication(NIBIRU_DEP_PACKAGE)) {
|
||||
downControllerDeps(GameControllerActivity.DRIVERTYPE_NIBIRU);
|
||||
}
|
||||
Log.w(TAG, "Not found any supported bluetooth game controller!");
|
||||
}else {
|
||||
if (mClearDevices == 1 ) {
|
||||
downControllerDeps(mTargetDriverType);
|
||||
}
|
||||
else {
|
||||
Log.i(TAG, "Not clear target!");
|
||||
if (checkApplication(NIBIRU_DEP_PACKAGE)) {
|
||||
downControllerDeps(GameControllerActivity.DRIVERTYPE_NIBIRU);
|
||||
}
|
||||
//todo:show sel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
|
||||
Log.d(TAG, "The local Bluetooth adapter has started the remote device discovery process.");
|
||||
if(mControllerListener != null){
|
||||
mControllerListener.onControllerDiscoveryStarted();
|
||||
}
|
||||
|
||||
mBluetoothDevices.clear();
|
||||
mDevicesDriver.clear();
|
||||
mClearDevices = 0;
|
||||
mTargetDriverType = GameControllerActivity.DRIVERTYPE_UNKNOWN;
|
||||
|
||||
//check moga controller
|
||||
Iterator<BluetoothDevice> it = mBluetoothAdapter.getBondedDevices().iterator();
|
||||
while (it.hasNext()) {
|
||||
BluetoothDevice device = it.next();
|
||||
//if(device.getBluetoothClass().getMajorDeviceClass() != BluetoothClass.Device.Major.COMPUTER
|
||||
// && device.getBluetoothClass().getMajorDeviceClass() != BluetoothClass.Device.Major.PHONE)
|
||||
{
|
||||
if (!mBluetoothDevices.contains(device)) {
|
||||
mBluetoothDevices.add(device);
|
||||
int type = checkDriverType(device);
|
||||
Log.d(TAG, "BluetoothDevice objects that are bonded (paired) to the local adapter :" + device.getName());
|
||||
if (type != GameControllerActivity.DRIVERTYPE_UNKNOWN) {
|
||||
mClearDevices += 1;
|
||||
mTargetDriverType = type;
|
||||
}
|
||||
mDevicesDriver.append(mBluetoothDevices.size() - 1, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static int depsCount = 0;
|
||||
private static int mTargetDriverType = GameControllerActivity.DRIVERTYPE_UNKNOWN;
|
||||
|
||||
private static int mDownloadTotalSize;
|
||||
private static int mDownloadLibSize;
|
||||
private static int mLibDownloadCompletedSize;
|
||||
private static int mDepDownloadCompletedSize;
|
||||
|
||||
public void downControllerDeps(int driverType){
|
||||
if (driverType != GameControllerActivity.DRIVERTYPE_NIBIRU
|
||||
&& driverType != GameControllerActivity.DRIVERTYPE_MOGA
|
||||
&& driverType != GameControllerActivity.DRIVERTYPE_OUYA) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadDepsStarted();
|
||||
}
|
||||
|
||||
mDownloadTotalSize = 0;
|
||||
mLibDownloadCompletedSize = 0;
|
||||
mDepDownloadCompletedSize = 0;
|
||||
|
||||
mTargetDriverType = driverType;
|
||||
depsCount = 1;
|
||||
|
||||
GameControllerUtils.ensureDirectoryExist(mLocalSavePath);
|
||||
|
||||
String remoteDir = COCOS_CONTROLLER_URL + DRIVERS_NAME[driverType] + File.separator;
|
||||
|
||||
if (driverType == GameControllerActivity.DRIVERTYPE_NIBIRU) {
|
||||
if (!checkApplication(NIBIRU_DEP_PACKAGE)) {
|
||||
depsCount += 1;
|
||||
mDownloadTotalSize += mNibiruDepFileSize;
|
||||
mDownDepsHttpClient.get(remoteDir + mNibiruDepFileName, new MyDepsAsyncHandler(
|
||||
new File(mLocalSavePath + mNibiruDepFileName), MyDepsAsyncHandler.FILETYPE_DEP_APK));
|
||||
}
|
||||
}
|
||||
else if (driverType == GameControllerActivity.DRIVERTYPE_MOGA) {
|
||||
if (!checkApplication(MOGA__DEP_PACKAGE)) {
|
||||
mDownloadTotalSize += mMogaDepFileSize;
|
||||
depsCount += 1;
|
||||
mDownDepsHttpClient.get(remoteDir + mMogaDepFileName, new MyDepsAsyncHandler(
|
||||
new File(mLocalSavePath + mMogaDepFileName), MyDepsAsyncHandler.FILETYPE_DEP_APK));
|
||||
}
|
||||
}
|
||||
else if(driverType == GameControllerActivity.DRIVERTYPE_OUYA){
|
||||
|
||||
}
|
||||
|
||||
File libFile = new File(mLocalSavePath + mLibAdapterFileName);
|
||||
if (libFile.exists() && libFile.length() == mLibAdapterFileSize) {
|
||||
depsCount -= 1;
|
||||
if (depsCount == 0) {
|
||||
onDepsReady();
|
||||
}
|
||||
}else {
|
||||
mDownloadLibSize = mLibAdapterFileSize;
|
||||
mDownloadTotalSize += mDownloadLibSize;
|
||||
mDownDepsHttpClient.get(COCOS_CONTROLLER_URL + mLibAdapterFileName, new MyDepsAsyncHandler(
|
||||
new File(mLocalSavePath + mLibAdapterFileName), MyDepsAsyncHandler.FILETYPE_JAR));
|
||||
}
|
||||
}
|
||||
|
||||
static class MyDepsAsyncHandler extends FileAsyncHttpResponseHandler{
|
||||
|
||||
public static final int FILETYPE_DEP_APK = 0;
|
||||
public static final int FILETYPE_JAR = 1;
|
||||
|
||||
private int mFileType = FILETYPE_DEP_APK;
|
||||
|
||||
public MyDepsAsyncHandler(File file, int fileType) {
|
||||
super(file);
|
||||
mFileType = fileType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers,
|
||||
Throwable e, File file) {
|
||||
if (mFileType == FILETYPE_JAR) {
|
||||
if (file.exists() && file.length() == mDownloadLibSize) {
|
||||
depsCount -= 1;
|
||||
if (depsCount == 0) {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadDepsFinished(true);
|
||||
}
|
||||
sControllerHelper.onDepsReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mFileType == FILETYPE_DEP_APK) {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadDepsFinished(false);
|
||||
}
|
||||
}
|
||||
|
||||
Log.e(TAG,"Failed to download:" + file.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int bytesWritten, int totalSize) {
|
||||
if (mFileType == FILETYPE_JAR) {
|
||||
mLibDownloadCompletedSize = bytesWritten;
|
||||
} else {
|
||||
mDepDownloadCompletedSize = bytesWritten;
|
||||
}
|
||||
if (mControllerListener != null) {
|
||||
|
||||
mControllerListener.onDownloadDepsProgress(mLibDownloadCompletedSize + mDepDownloadCompletedSize, mDownloadTotalSize);
|
||||
}
|
||||
Log.d(TAG, "totalSize:" + totalSize + ", bytesWritten:" + bytesWritten);
|
||||
}
|
||||
|
||||
|
||||
public void onSuccess(File file) {
|
||||
Log.d(TAG, "11Down file success:" + file.getName());
|
||||
|
||||
depsCount -= 1;
|
||||
if (depsCount == 0) {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadDepsFinished(true);
|
||||
}
|
||||
sControllerHelper.onDepsReady();
|
||||
}
|
||||
super.onSuccess(file);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onSuccess(int arg0, Header[] arg1, File file) {
|
||||
Log.d(TAG, "22Down file success:" + file.getName());
|
||||
|
||||
depsCount -= 1;
|
||||
if (depsCount == 0) {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadDepsFinished(true);
|
||||
}
|
||||
sControllerHelper.onDepsReady();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void onDepsReady(){
|
||||
Log.d(TAG, "onDepsReady:" + mTargetDriverType);
|
||||
|
||||
if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_NIBIRU) {
|
||||
if (checkApplication(NIBIRU_DEP_PACKAGE)) {
|
||||
createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType);
|
||||
}
|
||||
else {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onInstallDriver(mLocalSavePath + mMogaDepFileName);
|
||||
}
|
||||
installApplication(mLocalSavePath + mNibiruDepFileName);
|
||||
}
|
||||
}
|
||||
else if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_MOGA) {
|
||||
if (checkApplication(MOGA__DEP_PACKAGE)) {
|
||||
createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType);
|
||||
}
|
||||
else {
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onInstallDriver(mLocalSavePath + mMogaDepFileName);
|
||||
}
|
||||
installApplication(mLocalSavePath + mMogaDepFileName);
|
||||
}
|
||||
}
|
||||
else if (mTargetDriverType == GameControllerActivity.DRIVERTYPE_OUYA) {
|
||||
createControllerInstance(mLocalSavePath + mLibAdapterFileName, mTargetDriverType);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CONFIGKEY_DRIVES = "drives";
|
||||
private static final String CONFIGKEY_LIBADAPTER_FILENAME = "adapter-file";
|
||||
private static final String CONFIGKEY_LIBADAPTER_FILESIZE = "adapter-filesize";
|
||||
private static final String CONFIGKEY_DEP_FILENAME = "dep-apk";
|
||||
private static final String CONFIGKEY_DEP_FILESIZE = "dep-size";
|
||||
|
||||
private boolean parseConfig(String jsonString){
|
||||
mMogaSupportedDrives.clear();
|
||||
mNibiruSupportedDrives.clear();
|
||||
mOuyaSupportedDrives.clear();
|
||||
|
||||
try {
|
||||
int tint = 9879;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("intvalue",tint);
|
||||
Log.w(TAG, "intJson:" + jsonObject);
|
||||
|
||||
JSONObject configObject = new JSONObject(jsonString);
|
||||
mLibAdapterFileName = configObject.getString(CONFIGKEY_LIBADAPTER_FILENAME);
|
||||
mLibAdapterFileSize = configObject.getInt(CONFIGKEY_LIBADAPTER_FILESIZE);
|
||||
|
||||
JSONObject nibiruObject = configObject.getJSONObject("nibiru");
|
||||
JSONArray drives = nibiruObject.getJSONArray(CONFIGKEY_DRIVES);
|
||||
int count = drives.length();
|
||||
for (int i = 0; i < count; i++) {
|
||||
mNibiruSupportedDrives.add(drives.getString(i));
|
||||
}
|
||||
mNibiruDepFileName = nibiruObject.getString(CONFIGKEY_DEP_FILENAME);
|
||||
mNibiruDepFileSize = nibiruObject.getInt(CONFIGKEY_DEP_FILESIZE);
|
||||
|
||||
JSONObject mogaObject = configObject.getJSONObject("moga");
|
||||
drives = mogaObject.getJSONArray(CONFIGKEY_DRIVES);
|
||||
count = drives.length();
|
||||
for (int i = 0; i < count; i++) {
|
||||
mMogaSupportedDrives.add(drives.getString(i));
|
||||
}
|
||||
mMogaDepFileName = mogaObject.getString(CONFIGKEY_DEP_FILENAME);
|
||||
mMogaDepFileSize = mogaObject.getInt(CONFIGKEY_DEP_FILESIZE);
|
||||
|
||||
JSONObject ouyaObject = configObject.getJSONObject("ouya");
|
||||
drives = ouyaObject.getJSONArray(CONFIGKEY_DRIVES);
|
||||
count = drives.length();
|
||||
for (int i = 0; i < count; i++) {
|
||||
mOuyaSupportedDrives.add(drives.getString(i));
|
||||
}
|
||||
|
||||
mLazyConfigInit = false;
|
||||
return true;
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void requestControllerConfig() {
|
||||
|
||||
final JsonHttpResponseHandler configResponseHandler = new JsonHttpResponseHandler() {
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers,
|
||||
String responseBody, Throwable e) {
|
||||
|
||||
Log.e(TAG, "Failed to download game controller config!");
|
||||
|
||||
String configJSON = GameControllerUtils.readJsonFile(mConfigFilePath);
|
||||
if (configJSON != null) {
|
||||
if (parseConfig(configJSON)) {
|
||||
scanBluetoothDrive();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadConfigFinished(false);
|
||||
}
|
||||
/*new AlertDialog.Builder(sCocos2dxActivity)
|
||||
.setTitle("Loading controller config failed!")
|
||||
.setMessage(
|
||||
"Please make sure internet connection works ok!")
|
||||
.setPositiveButton("Retry",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
dialog.dismiss();
|
||||
requestControllerConfig();
|
||||
}
|
||||
}).setCancelable(false).show();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers,
|
||||
String responseBody) {
|
||||
|
||||
String jsonString = responseBody.trim();
|
||||
|
||||
try {
|
||||
if (parseConfig(jsonString)) {
|
||||
scanBluetoothDrive();
|
||||
showToast("Get controller config succeed!");
|
||||
|
||||
File configFile = new File(mConfigFilePath);
|
||||
FileOutputStream outputStream = new FileOutputStream(configFile);
|
||||
byte[] contentString = jsonString.getBytes();
|
||||
outputStream.write(contentString, 0, contentString.length);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
String jsonStr = GameControllerUtils.readJsonFile(mConfigFilePath);
|
||||
if (jsonStr != null) {
|
||||
if (parseConfig(jsonStr)) {
|
||||
scanBluetoothDrive();
|
||||
showToast("Get controller config succeed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onDownloadConfigFinished(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mDownDepsHttpClient.get(COCOS_CONTROLLER_URL + COCOS_CONTROLLER_CONFIG, configResponseHandler);
|
||||
}
|
||||
|
||||
private static void showToast(String message){
|
||||
Toast.makeText(sGameControllerActivity, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private static void createControllerInstance(String libFilePath,int driveType) {
|
||||
//if (sGameControllerActivity.getGameControllerDelegate(driveType) != null) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
File libFile = new File(libFilePath);
|
||||
if (! libFile.exists()) {
|
||||
Log.w(TAG, libFile.toString() + "not exist!");
|
||||
return;
|
||||
}
|
||||
|
||||
DexClassLoader classLoader = null;
|
||||
|
||||
try {
|
||||
File dexOutputDir = sGameControllerActivity.getDir("dex", Context.MODE_PRIVATE);
|
||||
classLoader = new DexClassLoader(libFile.getCanonicalPath(), dexOutputDir.getCanonicalPath(),
|
||||
null, sGameControllerActivity.getClassLoader());
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> controllerDelegate = null;
|
||||
if (driveType == GameControllerActivity.DRIVERTYPE_MOGA) {
|
||||
controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerMoga");
|
||||
} else if (driveType == GameControllerActivity.DRIVERTYPE_NIBIRU) {
|
||||
controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerNibiru");
|
||||
} else if (driveType == GameControllerActivity.DRIVERTYPE_OUYA) {
|
||||
controllerDelegate = classLoader.loadClass("org.cocos2dx.lib.GameControllerOuya");
|
||||
}
|
||||
|
||||
GameControllerDelegate instance = (GameControllerDelegate)controllerDelegate.newInstance();
|
||||
|
||||
if (mControllerListener != null) {
|
||||
mControllerListener.onConnectController();
|
||||
}
|
||||
sGameControllerActivity.setGameControllerInstance(instance, driveType);
|
||||
if (driveType == GameControllerActivity.DRIVERTYPE_NIBIRU) {
|
||||
Method method = controllerDelegate.getDeclaredMethod("onResume");
|
||||
method.invoke(instance);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BroadcastReceiver mAppReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String packageName = intent.getDataString();
|
||||
Log.d(TAG, "mAppReceiver:" + intent);
|
||||
if (packageName.contains(NIBIRU_DEP_PACKAGE)) {
|
||||
createControllerInstance(mLocalSavePath + mLibAdapterFileName, GameControllerActivity.DRIVERTYPE_NIBIRU);
|
||||
}
|
||||
else if (packageName.contains(MOGA__DEP_PACKAGE)) {
|
||||
createControllerInstance(mLocalSavePath + mLibAdapterFileName, GameControllerActivity.DRIVERTYPE_MOGA);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private float mOldLeftThumbstickX = 0.0f;
|
||||
private float mOldLeftThumbstickY = 0.0f;
|
||||
private float mOldRightThumbstickX = 0.0f;
|
||||
private float mOldRightThumbstickY = 0.0f;
|
||||
|
||||
private float mOldLeftTrigger = 0.0f;
|
||||
private float mOldRightTrigger = 0.0f;
|
||||
private float mOldThrottle = 0.0f;
|
||||
private float mOldBrake = 0.0f;
|
||||
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent event) {
|
||||
boolean handled = false;
|
||||
|
||||
int eventSource = event.getSource();
|
||||
|
||||
if ( ((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||
{
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
int devicedId = event.getDeviceId();
|
||||
|
||||
float newAXIS_LX = event.getAxisValue(AXIS_X);
|
||||
if (Float.compare(newAXIS_LX , mOldLeftThumbstickX) != 0) {
|
||||
GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true);
|
||||
mOldLeftThumbstickX = newAXIS_LX;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_LY = event.getAxisValue(AXIS_Y);
|
||||
if (Float.compare(newAXIS_LY , mOldLeftThumbstickY) != 0) {
|
||||
GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true);
|
||||
mOldLeftThumbstickY = newAXIS_LY;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_RX = event.getAxisValue(AXIS_Z);
|
||||
if (Float.compare(newAXIS_RX , mOldRightThumbstickX) != 0) {
|
||||
GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true);
|
||||
mOldRightThumbstickX = newAXIS_RX;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_RY = event.getAxisValue(AXIS_RZ);
|
||||
if (Float.compare(newAXIS_RY , mOldRightThumbstickY) != 0) {
|
||||
GameControllerAdapter.onAxisEvent(StandardControllerName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true);
|
||||
mOldRightThumbstickY = newAXIS_RY;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER);
|
||||
if (Float.compare(newAXIS_LTRIGGER , mOldLeftTrigger) != 0) {
|
||||
if (Float.compare(newAXIS_LTRIGGER, 0.0f) == 0) {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, false, 0.0f, true);
|
||||
}else {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, true, newAXIS_LTRIGGER, true);
|
||||
}
|
||||
mOldLeftTrigger = newAXIS_LTRIGGER;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER);
|
||||
if (Float.compare(newAXIS_RTRIGGER , mOldRightTrigger) != 0) {
|
||||
if (Float.compare(newAXIS_RTRIGGER, 0.0f) == 0) {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, false, 0.0f, true);
|
||||
}else {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, true, newAXIS_RTRIGGER, true);
|
||||
}
|
||||
mOldRightTrigger = newAXIS_RTRIGGER;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE);
|
||||
if (Float.compare(newAXIS_BRAKE , mOldBrake) != 0) {
|
||||
if (Float.compare(newAXIS_BRAKE, 0.0f) == 0) {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, false, 0.0f, true);
|
||||
}else {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, true, newAXIS_BRAKE, true);
|
||||
}
|
||||
mOldBrake = newAXIS_BRAKE;
|
||||
handled = true;
|
||||
}
|
||||
|
||||
float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE);
|
||||
if (Float.compare(newAXIS_THROTTLE , mOldThrottle) != 0) {
|
||||
if (Float.compare(newAXIS_THROTTLE, 0.0f) == 0) {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, false, 0.0f, true);
|
||||
}else {
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, true, newAXIS_THROTTLE, true);
|
||||
}
|
||||
mOldThrottle = newAXIS_THROTTLE;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
boolean handled = false;
|
||||
|
||||
int eventSource = event.getSource();
|
||||
int controllerKey = ControllerKeyMap.get(event.getKeyCode());
|
||||
|
||||
if (controllerKey != 0 && (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK)
|
||||
|| ((eventSource & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD)))
|
||||
{
|
||||
int action = event.getAction();
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
handled = true;
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName,event.getDeviceId(), controllerKey,true, 1.0f, false);
|
||||
}else if (action == KeyEvent.ACTION_UP) {
|
||||
handled = true;
|
||||
GameControllerAdapter.onButtonEvent(StandardControllerName,event.getDeviceId(), controllerKey,false, 0.0f, false);
|
||||
}
|
||||
}
|
||||
|
||||
return handled;
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.lib.inputmanagercompat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public interface InputManagerCompat {
|
||||
/**
|
||||
* Gets information about the input device with the specified id.
|
||||
*
|
||||
* @param id The device id
|
||||
* @return The input device or null if not found
|
||||
*/
|
||||
public InputDevice getInputDevice(int id);
|
||||
|
||||
/**
|
||||
* Gets the ids of all input devices in the system.
|
||||
*
|
||||
* @return The input device ids.
|
||||
*/
|
||||
public int[] getInputDeviceIds();
|
||||
|
||||
/**
|
||||
* Registers an input device listener to receive notifications about when
|
||||
* input devices are added, removed or changed.
|
||||
*
|
||||
* @param listener The listener to register.
|
||||
* @param handler The handler on which the listener should be invoked, or
|
||||
* null if the listener should be invoked on the calling thread's
|
||||
* looper.
|
||||
*/
|
||||
public void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener,
|
||||
Handler handler);
|
||||
|
||||
/**
|
||||
* Unregisters an input device listener.
|
||||
*
|
||||
* @param listener The listener to unregister.
|
||||
*/
|
||||
public void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener);
|
||||
|
||||
/*
|
||||
* The following three calls are to simulate V16 behavior on pre-Jellybean
|
||||
* devices. If you don't call them, your callback will never be called
|
||||
* pre-API 16.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pass the motion events to the InputManagerCompat. This is used to
|
||||
* optimize for polling for controllers. If you do not pass these events in,
|
||||
* polling will cause regular object creation.
|
||||
*
|
||||
* @param event the motion event from the app
|
||||
*/
|
||||
public void onGenericMotionEvent(MotionEvent event);
|
||||
|
||||
/**
|
||||
* Tell the V9 input manager that it should stop polling for disconnected
|
||||
* devices. You can call this during onPause in your activity, although you
|
||||
* might want to call it whenever your game is not active (or whenever you
|
||||
* don't care about being notified of new input devices)
|
||||
*/
|
||||
public void onPause();
|
||||
|
||||
/**
|
||||
* Tell the V9 input manager that it should start polling for disconnected
|
||||
* devices. You can call this during onResume in your activity, although you
|
||||
* might want to call it less often (only when the gameplay is actually
|
||||
* active)
|
||||
*/
|
||||
public void onResume();
|
||||
|
||||
public interface InputDeviceListener {
|
||||
/**
|
||||
* Called whenever the input manager detects that a device has been
|
||||
* added. This will only be called in the V9 version when a motion event
|
||||
* is detected.
|
||||
*
|
||||
* @param deviceId The id of the input device that was added.
|
||||
*/
|
||||
void onInputDeviceAdded(int deviceId);
|
||||
|
||||
/**
|
||||
* Called whenever the properties of an input device have changed since
|
||||
* they were last queried. This will not be called for the V9 version of
|
||||
* the API.
|
||||
*
|
||||
* @param deviceId The id of the input device that changed.
|
||||
*/
|
||||
void onInputDeviceChanged(int deviceId);
|
||||
|
||||
/**
|
||||
* Called whenever the input manager detects that a device has been
|
||||
* removed. For the V9 version, this can take some time depending on the
|
||||
* poll rate.
|
||||
*
|
||||
* @param deviceId The id of the input device that was removed.
|
||||
*/
|
||||
void onInputDeviceRemoved(int deviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to construct a compatible InputManager.
|
||||
*/
|
||||
public static class Factory {
|
||||
|
||||
/**
|
||||
* Constructs and returns a compatible InputManger
|
||||
*
|
||||
* @param context the Context that will be used to get the system
|
||||
* service from
|
||||
* @return a compatible implementation of InputManager
|
||||
*/
|
||||
public static InputManagerCompat getInputManager(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return new InputManagerV16(context);
|
||||
} else {
|
||||
return new InputManagerV9();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.lib.inputmanagercompat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.hardware.input.InputManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
public class InputManagerV16 implements InputManagerCompat {
|
||||
|
||||
private final InputManager mInputManager;
|
||||
private final Map<InputManagerCompat.InputDeviceListener, V16InputDeviceListener> mListeners;
|
||||
|
||||
public InputManagerV16(Context context) {
|
||||
mInputManager = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
||||
mListeners = new HashMap<InputManagerCompat.InputDeviceListener, V16InputDeviceListener>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputDevice getInputDevice(int id) {
|
||||
return mInputManager.getInputDevice(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInputDeviceIds() {
|
||||
return mInputManager.getInputDeviceIds();
|
||||
}
|
||||
|
||||
static class V16InputDeviceListener implements InputManager.InputDeviceListener {
|
||||
final InputManagerCompat.InputDeviceListener mIDL;
|
||||
|
||||
public V16InputDeviceListener(InputDeviceListener idl) {
|
||||
mIDL = idl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceAdded(int deviceId) {
|
||||
mIDL.onInputDeviceAdded(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceChanged(int deviceId) {
|
||||
mIDL.onInputDeviceChanged(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputDeviceRemoved(int deviceId) {
|
||||
mIDL.onInputDeviceRemoved(deviceId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
|
||||
V16InputDeviceListener v16Listener = new V16InputDeviceListener(listener);
|
||||
mInputManager.registerInputDeviceListener(v16Listener, handler);
|
||||
mListeners.put(listener, v16Listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterInputDeviceListener(InputDeviceListener listener) {
|
||||
V16InputDeviceListener curListener = mListeners.remove(listener);
|
||||
if (null != curListener)
|
||||
{
|
||||
mInputManager.unregisterInputDeviceListener(curListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGenericMotionEvent(MotionEvent event) {
|
||||
// unused in V16
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
// unused in V16
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
// unused in V16
|
||||
}
|
||||
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.lib.inputmanagercompat;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
public class InputManagerV9 implements InputManagerCompat {
|
||||
private static final String LOG_TAG = "InputManagerV9";
|
||||
private static final int MESSAGE_TEST_FOR_DISCONNECT = 101;
|
||||
private static final long CHECK_ELAPSED_TIME = 3000L;
|
||||
|
||||
private static final int ON_DEVICE_ADDED = 0;
|
||||
private static final int ON_DEVICE_CHANGED = 1;
|
||||
private static final int ON_DEVICE_REMOVED = 2;
|
||||
|
||||
private final SparseArray<long[]> mDevices;
|
||||
private final Map<InputDeviceListener, Handler> mListeners;
|
||||
private final Handler mDefaultHandler;
|
||||
|
||||
private static class PollingMessageHandler extends Handler {
|
||||
private final WeakReference<InputManagerV9> mInputManager;
|
||||
|
||||
PollingMessageHandler(InputManagerV9 im) {
|
||||
mInputManager = new WeakReference<InputManagerV9>(im);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case MESSAGE_TEST_FOR_DISCONNECT:
|
||||
InputManagerV9 imv = mInputManager.get();
|
||||
if (null != imv) {
|
||||
long time = SystemClock.elapsedRealtime();
|
||||
int size = imv.mDevices.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
long[] lastContact = imv.mDevices.valueAt(i);
|
||||
if (null != lastContact) {
|
||||
if (time - lastContact[0] > CHECK_ELAPSED_TIME) {
|
||||
// check to see if the device has been
|
||||
// disconnected
|
||||
int id = imv.mDevices.keyAt(i);
|
||||
if (null == InputDevice.getDevice(id)) {
|
||||
// disconnected!
|
||||
imv.notifyListeners(ON_DEVICE_REMOVED, id);
|
||||
imv.mDevices.remove(id);
|
||||
} else {
|
||||
lastContact[0] = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sendEmptyMessageDelayed(MESSAGE_TEST_FOR_DISCONNECT,
|
||||
CHECK_ELAPSED_TIME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public InputManagerV9() {
|
||||
mDevices = new SparseArray<long[]>();
|
||||
mListeners = new HashMap<InputDeviceListener, Handler>();
|
||||
mDefaultHandler = new PollingMessageHandler(this);
|
||||
// as a side-effect, populates our collection of watched
|
||||
// input devices
|
||||
getInputDeviceIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputDevice getInputDevice(int id) {
|
||||
return InputDevice.getDevice(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInputDeviceIds() {
|
||||
// add any hitherto unknown devices to our
|
||||
// collection of watched input devices
|
||||
int[] activeDevices = InputDevice.getDeviceIds();
|
||||
long time = SystemClock.elapsedRealtime();
|
||||
for ( int id : activeDevices ) {
|
||||
long[] lastContact = mDevices.get(id);
|
||||
if ( null == lastContact ) {
|
||||
// we have a new device
|
||||
mDevices.put(id, new long[] { time });
|
||||
}
|
||||
}
|
||||
return activeDevices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
|
||||
mListeners.remove(listener);
|
||||
if (handler == null) {
|
||||
handler = mDefaultHandler;
|
||||
}
|
||||
mListeners.put(listener, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterInputDeviceListener(InputDeviceListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
private void notifyListeners(int why, int deviceId) {
|
||||
// the state of some device has changed
|
||||
if (!mListeners.isEmpty()) {
|
||||
// yes... this will cause an object to get created... hopefully
|
||||
// it won't happen very often
|
||||
for (InputDeviceListener listener : mListeners.keySet()) {
|
||||
Handler handler = mListeners.get(listener);
|
||||
DeviceEvent odc = DeviceEvent.getDeviceEvent(why, deviceId, listener);
|
||||
handler.post(odc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeviceEvent implements Runnable {
|
||||
private int mMessageType;
|
||||
private int mId;
|
||||
private InputDeviceListener mListener;
|
||||
private static Queue<DeviceEvent> sEventQueue = new ArrayDeque<DeviceEvent>();
|
||||
|
||||
private DeviceEvent() {
|
||||
}
|
||||
|
||||
static DeviceEvent getDeviceEvent(int messageType, int id,
|
||||
InputDeviceListener listener) {
|
||||
DeviceEvent curChanged = sEventQueue.poll();
|
||||
if (null == curChanged) {
|
||||
curChanged = new DeviceEvent();
|
||||
}
|
||||
curChanged.mMessageType = messageType;
|
||||
curChanged.mId = id;
|
||||
curChanged.mListener = listener;
|
||||
return curChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
switch (mMessageType) {
|
||||
case ON_DEVICE_ADDED:
|
||||
mListener.onInputDeviceAdded(mId);
|
||||
break;
|
||||
case ON_DEVICE_CHANGED:
|
||||
mListener.onInputDeviceChanged(mId);
|
||||
break;
|
||||
case ON_DEVICE_REMOVED:
|
||||
mListener.onInputDeviceRemoved(mId);
|
||||
break;
|
||||
default:
|
||||
Log.e(LOG_TAG, "Unknown Message Type");
|
||||
break;
|
||||
}
|
||||
// dump this runnable back in the queue
|
||||
sEventQueue.offer(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGenericMotionEvent(MotionEvent event) {
|
||||
// detect new devices
|
||||
int id = event.getDeviceId();
|
||||
long[] timeArray = mDevices.get(id);
|
||||
if (null == timeArray) {
|
||||
notifyListeners(ON_DEVICE_ADDED, id);
|
||||
timeArray = new long[1];
|
||||
mDevices.put(id, timeArray);
|
||||
}
|
||||
long time = SystemClock.elapsedRealtime();
|
||||
timeArray[0] = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mDefaultHandler.removeMessages(MESSAGE_TEST_FOR_DISCONNECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
mDefaultHandler.sendEmptyMessage(MESSAGE_TEST_FOR_DISCONNECT);
|
||||
}
|
||||
|
||||
}
|
|
@ -945,6 +945,7 @@
|
|||
);
|
||||
"OTHER_LDFLAGS[arch=arm64]" = "-llua";
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../platform/ios";
|
||||
|
@ -970,6 +971,7 @@
|
|||
);
|
||||
"OTHER_LDFLAGS[arch=arm64]" = "-llua";
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
|
||||
"OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../../platform/ios";
|
||||
|
|
|
@ -41,8 +41,6 @@ $(LOCAL_PATH)/.. \
|
|||
$(LOCAL_PATH)/../.. \
|
||||
$(LOCAL_PATH)/../editor-support
|
||||
|
||||
LOCAL_CFLAGS += -Wno-psabi
|
||||
LOCAL_EXPORT_CFLAGS += -Wno-psabi
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
|
||||
|
|
|
@ -623,7 +623,6 @@ bool TextField::isPasswordEnabled()const
|
|||
void TextField::setPasswordStyleText(const char *styleText)
|
||||
{
|
||||
_textFieldRenderer->setPasswordStyleText(styleText);
|
||||
|
||||
_passwordStyleText = styleText;
|
||||
|
||||
setText(getStringValue());
|
||||
|
|
|
@ -747,20 +747,6 @@
|
|||
"cocos/platform/android/CCGLView.h",
|
||||
"cocos/platform/android/CCPlatformDefine.h",
|
||||
"cocos/platform/android/CCStdC.h",
|
||||
"cocos/platform/android/ControllerAutoAdapter/.classpath",
|
||||
"cocos/platform/android/ControllerAutoAdapter/.project",
|
||||
"cocos/platform/android/ControllerAutoAdapter/.settings/org.eclipse.jdt.core.prefs",
|
||||
"cocos/platform/android/ControllerAutoAdapter/AndroidManifest.xml",
|
||||
"cocos/platform/android/ControllerAutoAdapter/ant.properties",
|
||||
"cocos/platform/android/ControllerAutoAdapter/build.xml",
|
||||
"cocos/platform/android/ControllerAutoAdapter/lint.xml",
|
||||
"cocos/platform/android/ControllerAutoAdapter/proguard-project.txt",
|
||||
"cocos/platform/android/ControllerAutoAdapter/project.properties",
|
||||
"cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerActivity.java",
|
||||
"cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/GameControllerHelper.java",
|
||||
"cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerCompat.java",
|
||||
"cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV16.java",
|
||||
"cocos/platform/android/ControllerAutoAdapter/src/org/cocos2dx/lib/inputmanagercompat/InputManagerV9.java",
|
||||
"cocos/platform/android/ControllerManualAdapter/.classpath",
|
||||
"cocos/platform/android/ControllerManualAdapter/.project",
|
||||
"cocos/platform/android/ControllerManualAdapter/.settings/org.eclipse.jdt.core.prefs",
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -1,5 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -1,5 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -8,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -1,8 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
|
||||
# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9
|
||||
APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -33,13 +33,13 @@ void CurlTest::onTouchesEnded(const std::vector<Touch*>& touches, Event *event)
|
|||
curl = curl_easy_init();
|
||||
if (curl)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "baidu.com");
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "http://webtest.cocos2d-x.org/curltest");
|
||||
res = curl_easy_perform(curl);
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
if (res == 0)
|
||||
{
|
||||
_label->setString("0 response");
|
||||
_label->setString("Connect successfully!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -69,15 +69,15 @@ void PlayMusic::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -169,15 +169,15 @@ void TMoveTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -291,15 +291,15 @@ void TMoveBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -404,15 +404,15 @@ void TRotateTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -517,15 +517,15 @@ void TRotateBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExp
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -627,15 +627,15 @@ void TScaleTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -751,15 +751,15 @@ void TScaleBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpC
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -869,15 +869,15 @@ void TSkewTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -992,15 +992,15 @@ void TSkewBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCo
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -1106,15 +1106,15 @@ void TriggerState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::st
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "ID")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -1195,15 +1195,15 @@ void ArmaturePlayAction::serialize(cocostudio::CocoLoader *pCocoLoader, cocostud
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
|
|
@ -51,15 +51,15 @@ void TimeElapsed::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "TotalTime")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -151,15 +151,15 @@ void ArmatureActionState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostu
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -279,15 +279,15 @@ void NodeInRect::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stEx
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
@ -381,15 +381,15 @@ void NodeVisible::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stE
|
|||
{
|
||||
int length = pCocoNode->GetChildNum();
|
||||
int count = 0;
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray();
|
||||
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
|
||||
std::string key;
|
||||
const char *str = NULL;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count = pDataItemsArray[i].GetChildNum();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray();
|
||||
key = pDataItemArray[0].GetValue();
|
||||
str = pDataItemArray[1].GetValue();
|
||||
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
|
||||
key = pDataItemArray[0].GetValue(pCocoLoader);
|
||||
str = pDataItemArray[1].GetValue(pCocoLoader);
|
||||
if (key == "Tag")
|
||||
{
|
||||
if (str != NULL)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "NodeTest.h"
|
||||
#include <regex>
|
||||
#include "../testResource.h"
|
||||
|
||||
enum
|
||||
|
@ -1274,28 +1275,28 @@ void NodeNameTest::test(float dt)
|
|||
// enumerateChildren()
|
||||
// name = regular expression
|
||||
int i = 0;
|
||||
// parent = Node::create();
|
||||
// for (int i = 0; i < 100; ++i)
|
||||
// {
|
||||
// auto node = Node::create();
|
||||
// sprintf(name, "node%d", i);
|
||||
// node->setName(name);
|
||||
// parent->addChild(node);
|
||||
// }
|
||||
//
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 100, "");
|
||||
//
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return true;
|
||||
// });
|
||||
// CCAssert(i == 1, "");
|
||||
parent = Node::create();
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
sprintf(name, "node%d", i);
|
||||
node->setName(name);
|
||||
parent->addChild(node);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 100, "");
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
CCAssert(i == 1, "");
|
||||
|
||||
|
||||
// enumerateChildren
|
||||
|
@ -1332,118 +1333,105 @@ void NodeNameTest::test(float dt)
|
|||
CCAssert(i == 1, "");
|
||||
|
||||
// search from root
|
||||
parent = getScene();
|
||||
parent = Node::create();
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
auto node = Node::create();
|
||||
node->setName("node");
|
||||
sprintf(name, "node%d", i);
|
||||
node->setName(name);
|
||||
parent->addChild(node);
|
||||
|
||||
for (int j = 0; j < 100; ++j)
|
||||
{
|
||||
auto child = Node::create();
|
||||
child->setName("child");
|
||||
child->setName("node");
|
||||
node->addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("/node", [&i](Node* node) -> bool {
|
||||
parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 10000, "");
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
CCAssert(i == 1, "");
|
||||
|
||||
// search from parent
|
||||
// name is xxx/..
|
||||
i = 0;
|
||||
parent->enumerateChildren("node/..", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
CCAssert(i == 1, "");
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("node/..", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 10000, "");
|
||||
|
||||
// name = /xxx : search from root
|
||||
parent = getScene();
|
||||
for (int j = 0; j < 100; j++)
|
||||
{
|
||||
auto node = Node::create();
|
||||
sprintf(name, "node%d", j);
|
||||
node->setName(name);
|
||||
parent->addChild(node);
|
||||
|
||||
for (int k = 0; k < 100; ++k)
|
||||
{
|
||||
auto child = Node::create();
|
||||
sprintf(name, "node%d", k);
|
||||
child->setName(name);
|
||||
node->addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 100, "");
|
||||
|
||||
i = 0;
|
||||
parent->enumerateChildren("//child", [&i](Node* node) -> bool {
|
||||
enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
CCAssert(i == 1, "");
|
||||
|
||||
i = 0;
|
||||
enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 10100, ""); // 10000(children) + 100(parent)
|
||||
|
||||
i = 0;
|
||||
enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return true;
|
||||
});
|
||||
CCAssert(i == 1, "");
|
||||
|
||||
i = 0;
|
||||
enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool {
|
||||
++i;
|
||||
return false;
|
||||
});
|
||||
CCAssert(i == 10000, "");
|
||||
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 10000, "");
|
||||
//
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node[[:digit:]]+/node", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return true;
|
||||
// });
|
||||
// CCAssert(i == 1, "");
|
||||
|
||||
// search from parent
|
||||
// name is xxx/..
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node/..", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return true;
|
||||
// });
|
||||
// CCAssert(i == 1, "");
|
||||
//
|
||||
// i = 0;
|
||||
// parent->enumerateChildren("node/..", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 10000, "");
|
||||
|
||||
// name = /xxx : search from root
|
||||
// parent = getScene();
|
||||
// for (int j = 0; j < 100; j++)
|
||||
// {
|
||||
// auto node = Node::create();
|
||||
// sprintf(name, "node%d", j);
|
||||
// node->setName(name);
|
||||
// parent->addChild(node);
|
||||
//
|
||||
// for (int k = 0; k < 100; ++k)
|
||||
// {
|
||||
// auto child = Node::create();
|
||||
// sprintf(name, "node%d", k);
|
||||
// child->setName(name);
|
||||
// node->addChild(child);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// i = 0;
|
||||
// enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 100, "");
|
||||
|
||||
// i = 0;
|
||||
// enumerateChildren("/node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return true;
|
||||
// });
|
||||
// CCAssert(i == 1, "");
|
||||
//
|
||||
// i = 0;
|
||||
// enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 10100, ""); // 10000(children) + 100(parent)
|
||||
//
|
||||
// i = 0;
|
||||
// enumerateChildren("//node[[:digit:]]+", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return true;
|
||||
// });
|
||||
// CCAssert(i == 1, "");
|
||||
//
|
||||
// i = 0;
|
||||
// enumerateChildren("//node[[:digit:]]+/..", [&i](Node* node) -> bool {
|
||||
// ++i;
|
||||
// return false;
|
||||
// });
|
||||
// CCAssert(i == 10000, "");
|
||||
|
||||
// utils::findChildren()
|
||||
|
||||
parent = Node::create();
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace
|
|||
CLN(TMXIsoTest1New),
|
||||
CLN(TMXIsoTest2New),
|
||||
CLN(TMXUncompressedTestNew),
|
||||
//CLN(TMXHexTestNew),
|
||||
CLN(TMXHexTestNew),
|
||||
CLN(TMXReadWriteTestNew),
|
||||
CLN(TMXTilesetTestNew),
|
||||
CLN(TMXOrthoObjectsTestNew),
|
||||
|
@ -55,8 +55,8 @@ namespace
|
|||
CLN(TMXOrthoFlipRunTimeTestNew),
|
||||
CLN(TMXOrthoFromXMLTestNew),
|
||||
CLN(TMXOrthoXMLFormatTestNew),
|
||||
// CLN(TileMapTestNew),
|
||||
// CLN(TileMapEditTestNew),
|
||||
CLN(TileMapTestNew),
|
||||
CLN(TileMapEditTestNew),
|
||||
CLN(TMXBug987New),
|
||||
CLN(TMXBug787New),
|
||||
CLN(TMXGIDObjectsTestNew),
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
// UILoadingBarTest_Editor
|
||||
|
||||
UILoadingBarTest_Editor::UILoadingBarTest_Editor()
|
||||
:_count(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2173b0b479e0e7be62df9ded754b20e75e74b0f2
|
||||
Subproject commit 6b28e948482ca7ed44c31daf3fef2e42ad6b59fb
|
|
@ -1,8 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
|
||||
# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -Wno-literal-suffix -fsigned-char
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
|
||||
# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9
|
||||
APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
|
||||
# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9
|
||||
APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -1,8 +1,9 @@
|
|||
APP_STL := gnustl_static
|
||||
APP_STL := c++_static
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
# add -Wno-literal-suffix to avoid warning: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]
|
||||
# in NDK_ROOT/arch-arm/usr/include/sys/cdefs_elf.h:35:28: when using ndk-r9
|
||||
APP_CPPFLAGS := -frtti -std=c++11 -Wno-literal-suffix -fsigned-char
|
||||
|
||||
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||
ifeq ($(APP_DEBUG),1)
|
||||
|
@ -11,4 +12,4 @@ ifeq ($(APP_DEBUG),1)
|
|||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
endif
|
|
@ -1,4 +1,5 @@
|
|||
local size = cc.Director:getInstance():getWinSize()
|
||||
local scheduler = cc.Director:getInstance():getScheduler()
|
||||
|
||||
----------------------------------------
|
||||
----Sprite3DBasicTest
|
||||
|
@ -72,12 +73,13 @@ function Sprite3DWithSkinTest.onTouchesEnd(touches, event)
|
|||
end
|
||||
|
||||
function Sprite3DWithSkinTest.addNewSpriteWithCoords(parent,x,y)
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/girl.c3t")
|
||||
sprite:setRotation3D({x = -90.0, y = 0.0, z = 0.0})
|
||||
local sprite = cc.Sprite3D:create("Sprite3DTest/orc.c3b")
|
||||
sprite:setScale(3)
|
||||
sprite:setRotation3D({x = 0, y = 180, z = 0})
|
||||
sprite:setPosition(cc.p(x, y))
|
||||
parent:addChild(sprite)
|
||||
|
||||
local animation = cc.Animation3D:getOrCreate("Sprite3DTest/girl.c3t")
|
||||
local animation = cc.Animation3D:getOrCreate("Sprite3DTest/orc.c3b")
|
||||
if nil ~= animation then
|
||||
local animate = cc.Animate3D:create(animation)
|
||||
if math.random() < (1/3) then
|
||||
|
@ -112,6 +114,171 @@ function Sprite3DWithSkinTest.create()
|
|||
end
|
||||
|
||||
|
||||
----------------------------------------
|
||||
----Animate3DTest
|
||||
----------------------------------------
|
||||
local State =
|
||||
{
|
||||
SWIMMING = 0,
|
||||
SWIMMING_TO_HURT = 1,
|
||||
HURT = 2,
|
||||
HURT_TO_SWIMMING = 3,
|
||||
}
|
||||
|
||||
local Animate3DTest = {}
|
||||
Animate3DTest.__index = Animate3DTest
|
||||
|
||||
function Animate3DTest.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, Animate3DTest)
|
||||
return target
|
||||
end
|
||||
|
||||
|
||||
|
||||
function Animate3DTest:onEnter()
|
||||
|
||||
self._hurt = nil
|
||||
self._swim = nil
|
||||
self._sprite = nil
|
||||
self._moveAction = nil
|
||||
self._transTime = 0.1
|
||||
self._elapseTransTime = 0.0
|
||||
|
||||
local function renewCallBack()
|
||||
self._sprite:stopActionByTag(101)
|
||||
self._state = State.HURT_TO_SWIMMING
|
||||
end
|
||||
local function onTouchesEnd(touches, event )
|
||||
for i = 1,table.getn(touches) do
|
||||
local location = touches[i]:getLocation()
|
||||
if self._sprite ~= nil then
|
||||
local len = cc.pGetLength(cc.pSub(cc.p(self._sprite:getPosition()), location))
|
||||
if len < 40 then
|
||||
if self._state == State.SWIMMING then
|
||||
self._sprite:runAction(self._hurt)
|
||||
local delay = cc.DelayTime:create(self._hurt:getDuration() - 0.1)
|
||||
local seq = cc.Sequence:create(delay, cc.CallFunc:create(renewCallBack))
|
||||
seq:setTag(101)
|
||||
self._sprite:runAction(seq)
|
||||
self._state = State.SWIMMING_TO_HURT
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self:addSprite3D()
|
||||
|
||||
local listener = cc.EventListenerTouchAllAtOnce:create()
|
||||
listener:registerScriptHandler(onTouchesEnd,cc.Handler.EVENT_TOUCHES_ENDED )
|
||||
|
||||
local eventDispatcher = self:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
|
||||
|
||||
local function update(dt)
|
||||
if self._state == State.HURT_TO_SWIMMING then
|
||||
self._elapseTransTime = self._elapseTransTime + dt
|
||||
local t = self._elapseTransTime / self._transTime
|
||||
|
||||
if t >= 1.0 then
|
||||
t = 1.0
|
||||
self._sprite:stopAction(self._hurt)
|
||||
self._state = State.SWIMMING
|
||||
end
|
||||
self._swim:setWeight(t)
|
||||
self._hurt:setWeight(1.0 - t)
|
||||
elseif self._state == State.SWIMMING_TO_HURT then
|
||||
self._elapseTransTime = self._elapseTransTime + dt
|
||||
local t = self._elapseTransTime / self._transTime
|
||||
if t >= 1.0 then
|
||||
t = 1.0
|
||||
self._state = State.HURT
|
||||
end
|
||||
self._swim:setWeight(1.0 - t)
|
||||
self._hurt:setWeight(t)
|
||||
end
|
||||
end
|
||||
|
||||
self:scheduleUpdateWithPriorityLua(update,0)
|
||||
end
|
||||
|
||||
function Animate3DTest:onExit()
|
||||
self._moveAction:release()
|
||||
self._hurt:release()
|
||||
self._swim:release()
|
||||
self:unscheduleUpdate()
|
||||
end
|
||||
|
||||
function Animate3DTest:addSprite3D()
|
||||
-- body
|
||||
local fileName = "Sprite3DTest/tortoise.c3b"
|
||||
local sprite = cc.Sprite3D:create(fileName)
|
||||
sprite:setScale(0.1)
|
||||
local winSize = cc.Director:getInstance():getWinSize()
|
||||
sprite:setPosition(cc.p(winSize.width * 4.0 / 5.0, winSize.height / 2.0))
|
||||
self:addChild(sprite)
|
||||
|
||||
self._sprite = sprite
|
||||
|
||||
local animation = cc.Animation3D:getOrCreate(fileName)
|
||||
if nil ~= animation then
|
||||
local animate = cc.Animate3D:create(animation, 0.0, 1.933)
|
||||
sprite:runAction(cc.RepeatForever:create(animate))
|
||||
self._swim = animate
|
||||
self._swim:retain()
|
||||
self._hurt = cc.Animate3D:create(animation, 1.933, 2.8)
|
||||
self._hurt:retain()
|
||||
self._state = State.SWIMMING
|
||||
end
|
||||
|
||||
self._moveAction = cc.MoveTo:create(4.0, cc.p(winSize.width / 5.0, winSize.height / 2.0))
|
||||
self._moveAction:retain()
|
||||
|
||||
local function reachEndCallBack()
|
||||
self._sprite:stopActionByTag(100)
|
||||
local inverse = self._moveAction:reverse()
|
||||
inverse:retain()
|
||||
self._moveAction:release()
|
||||
self._moveAction = inverse
|
||||
local rot = cc.RotateBy:create(1.0, { x = 0.0, y = 180.0, z = 0.0})
|
||||
local seq = cc.Sequence:create(rot, self._moveAction, cc.CallFunc:create(reachEndCallBack))
|
||||
seq:setTag(100)
|
||||
self._sprite:runAction(seq)
|
||||
end
|
||||
|
||||
local seq = cc.Sequence:create(self._moveAction, cc.CallFunc:create(reachEndCallBack))
|
||||
seq:setTag(100)
|
||||
sprite:runAction(seq)
|
||||
end
|
||||
|
||||
function Animate3DTest.create()
|
||||
local layer = Animate3DTest.extend(cc.Layer:create())
|
||||
|
||||
if nil ~= layer then
|
||||
Helper.initWithLayer(layer)
|
||||
Helper.titleLabel:setString("Testing Animate3D")
|
||||
Helper.subtitleLabel:setString("Touch to beat the tortoise")
|
||||
|
||||
local function onNodeEvent(event)
|
||||
if "enter" == event then
|
||||
layer:onEnter()
|
||||
elseif "exit" == event then
|
||||
layer:onExit()
|
||||
end
|
||||
end
|
||||
layer:registerScriptHandler(onNodeEvent)
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
|
||||
function Sprite3DTest()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
|
@ -119,6 +286,7 @@ function Sprite3DTest()
|
|||
{
|
||||
Sprite3DBasicTest.create,
|
||||
Sprite3DWithSkinTest.create,
|
||||
Animate3DTest.create,
|
||||
}
|
||||
|
||||
scene:addChild(Sprite3DBasicTest.create())
|
||||
|
|
|
@ -7,7 +7,7 @@ prefix = cocos2dx
|
|||
# all classes will be embedded in that namespace
|
||||
target_namespace = cc
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -7,7 +7,7 @@ prefix = cocos2dx_extension
|
|||
# all classes will be embedded in that namespace
|
||||
target_namespace = cc
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -7,7 +7,7 @@ prefix = cocos2dx_physics
|
|||
# all classes will be embedded in that namespace
|
||||
target_namespace = cc
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -7,7 +7,7 @@ prefix = cocos2dx_spine
|
|||
# all classes will be embedded in that namespace
|
||||
target_namespace = sp
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -10,7 +10,7 @@ target_namespace = ccs
|
|||
# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label".
|
||||
cpp_namespace = cocostudio
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -10,7 +10,7 @@ target_namespace = ccui
|
|||
# the native namespace in which this module locates, this parameter is used for avoid conflict of the same class name in different modules, as "cocos2d::Label" <-> "cocos2d::ui::Label".
|
||||
cpp_namespace = cocos2d::ui
|
||||
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include
|
||||
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||
android_flags = -D_SIZE_T_DEFINED_
|
||||
|
||||
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||
|
|
|
@ -22,12 +22,12 @@ install_android_ndk()
|
|||
else
|
||||
HOST_NAME="linux"
|
||||
fi
|
||||
echo "Download android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 ..."
|
||||
curl -O http://dl.google.com/android/ndk/android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2
|
||||
echo "Decompress android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2 ..."
|
||||
tar xjf android-ndk-r9b-${HOST_NAME}-x86_64.tar.bz2
|
||||
echo "Download android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..."
|
||||
curl -O http://dl.google.com/android/ndk/android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2
|
||||
echo "Decompress android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2 ..."
|
||||
tar xjf android-ndk-r9d-${HOST_NAME}-x86_64.tar.bz2
|
||||
# Rename ndk
|
||||
mv android-ndk-r9b android-ndk
|
||||
mv android-ndk-r9d android-ndk
|
||||
}
|
||||
|
||||
install_nacl_sdk()
|
||||
|
|
Loading…
Reference in New Issue