////////////////////////////////////////////////////////////////////////// // handle get current language ////////////////////////////////////////////////////////////////////////// const char* getCurrentLanguageJNI() { JniMethodInfo t; if (JniHelper::getStaticMethodInfo(t , "org/cocos2dx/lib/Cocos2dxActivity" , "getCurrentLanguage" , "()Ljava/lang/String;")) { jstring str = (jstring)t.env->CallStaticObjectMethod(t.classID, t.methodID); t.env->DeleteLocalRef(t.classID); CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); ret->autorelease(); t.env->DeleteLocalRef(str); LOGD("language name %s", ret.c_str()); return ret->m_sString.c_str(); } return 0; }
void GetCCObjectValue(CCObject * pValueObject, std::string & rValue) { assert(pValueObject && pValueObject->isOfClass(CCObject::ClassOfCCString)); CCString * pValue = (CCString *)pValueObject; rValue = ConvertToAString(pValue->c_str()); }
void GetCCObjectValue(CCObject * pValueObject, wchar_t * rValue) { assert(pValueObject && pValueObject->isOfClass(CCObject::ClassOfCCString)); CCString * pValue = (CCString *)pValueObject; wcscpy(rValue, pValue->c_str()); }
void GetCCObjectValue(CCObject * pValueObject, char * rValue) { assert(pValueObject && pValueObject->isOfClass(CCObject::ClassOfCCString)); CCString * pValue = (CCString *)pValueObject; strcpy(rValue, ConvertToAString(pValue->c_str()).c_str()); }
void RecurseSave(TiXmlNode * pParentNode, CCObject * pParentObj) { if (pParentObj->isOfClass(CCObject::ClassOfCCDictionary)) { TiXmlElement * pDictElement = new TiXmlElement("dict"); pParentNode->LinkEndChild(pDictElement); CCDictionary * pDict = (CCDictionary *)pParentObj; for (CCDictionary::iterator it = pDict->begin(); it != pDict->end(); it++) { TiXmlElement * pKeyElement = new TiXmlElement("key"); { TiXmlText * pKeyText = new TiXmlText(it->first.c_str()); pKeyElement->LinkEndChild(pKeyText); } pDictElement->LinkEndChild(pKeyElement); CCObject * pObject = it->second; RecurseSave(pDictElement, pObject); } } else if (pParentObj->isOfClass(CCObject::ClassOfCCArray)) { TiXmlElement * pArrayElement = new TiXmlElement("array"); pParentNode->LinkEndChild(pArrayElement); CCArray * pValue = (CCArray *)pParentObj; for (CCArray::iterator it = pValue->begin(); it != pValue->end(); it++) { CCObject * pObject = *it; RecurseSave(pArrayElement, pObject); } } else if (pParentObj->isOfClass(CCObject::ClassOfCCString)) { CCString * pValue = (CCString *)pParentObj; TiXmlElement * pValueElement = new TiXmlElement("string"); { TiXmlText * pValueText = new TiXmlText(ConvertToAString(pValue->c_str()).c_str()); pValueElement->LinkEndChild(pValueText); } pParentNode->LinkEndChild(pValueElement); } else if (pParentObj->isOfClass(CCObject::ClassOfCCBool)) { CCBool * pValue = (CCBool *)pParentObj; TiXmlElement * pValueElement = new TiXmlElement(*pValue ? "true" : "false"); pParentNode->LinkEndChild(pValueElement); } else if (pParentObj->isOfClass(CCObject::ClassOfCCInteger)) { CCInteger * pValue = (CCInteger *)pParentObj; TiXmlElement * pValueElement = new TiXmlElement("integer"); { char szBuf[64] = {0}; sprintf(szBuf, "%d", (int)(*pValue)); TiXmlText * pValueText = new TiXmlText(szBuf); pValueElement->LinkEndChild(pValueText); } pParentNode->LinkEndChild(pValueElement); } else if (pParentObj->isOfClass(CCObject::ClassOfCCReal)) { CCReal * pValue = (CCReal *)pParentObj; TiXmlElement * pValueElement = new TiXmlElement("real"); { TiXmlText * pValueText = new TiXmlText(FloatToString((double)(*pValue))); pValueElement->LinkEndChild(pValueText); } pParentNode->LinkEndChild(pValueElement); } else if (pParentObj->isOfClass(CCObject::ClassOfCCDate)) { CCDate * pValue = (CCDate *)pParentObj; TiXmlElement * pValueElement = new TiXmlElement("date"); { char szBuf[64] = {0}; getTimeString(*pValue, szBuf); TiXmlText * pValueText = new TiXmlText(szBuf); pValueElement->LinkEndChild(pValueText); } pParentNode->LinkEndChild(pValueElement); } }