bool CCTexture2D::DoesTextureExist(const char *path, const CCResourceType resourceType) { CCText filename = path; filename.stripDirectory(); filename.toLowerCase(); return JNIDoesTextureExist( filename.buffer, resourceType == Resource_Packaged ); }
bool CCTexturePNG::load(const char *path, const CCResourceType resourceType, const bool generateMipMap) { #if defined PROFILEON CCProfiler profile( "CCTexturePNG::load()" ); #endif CCText filename = path; filename.stripDirectory(); filename.toLowercase(); glName = JniLoad( filename.buffer, resourceType == Resource_Packaged, generateMipMap ); if( glName > 0 ) { allocatedWidth = imageWidth = JniGetImageWidth(); imageHeight = JniGetImageHeight(); allocatedHeight = JniGetAllocatedHeight(); rawWidth = JniGetRawWidth(); rawHeight = JniGetRawHeight(); // TODO: pretend it's always 4 bytes on Android, look into getting actual pixel size data allocatedBytes = allocatedWidth * allocatedHeight * 4; return true; } return false; }
void CCJNI::BillingRequestPurchase(const char *productID, CCLambdaCallback *callback) { if( billingCallback != NULL ) { delete billingCallback; } billingCallback = callback; CCText androidProductID = productID; androidProductID.toLowercase(); // JNI Java call JNIEnv *jEnv = gView->jniEnv; jclass jniClass = jEnv->FindClass( "com/android2c/CCJNI" ); ASSERT_MESSAGE( jniClass != 0, "Could not find Java class." ); // Get the method ID of our method "startVideoView", which takes one parameter of type string, and returns void static jmethodID mid = jEnv->GetStaticMethodID( jniClass, "BillingRequestPurchase", "(Ljava/lang/String;)V" ); ASSERT( mid != 0 ); // Call the function jstring javaURL = jEnv->NewStringUTF( androidProductID.buffer ); jEnv->CallStaticVoidMethod( jniClass, mid, javaURL ); //jEnv->DeleteLocalRef( javaURL ); }
void CCVector3::set(const char *text) { CCText data = text; CCPtrList<char> split; data.split( split, "," ); CCASSERT( split.length == 3 ); if( split.length == 3 ) { x = (float)atof( split.list[0] ); y = (float)atof( split.list[1] ); z = (float)atof( split.list[2] ); if( x != x ) { CCASSERT( false ); x = 0.0f; } if( y != y ) { y = 0.0f; } if( z != z ) { z = 0.0f; } } }
void CCText::SetLastWord(const char *inBuffer, CCText &outText) { CCText nameData = inBuffer; CCList<char> *nameDataSplit = nameData.split( " " ); ASSERT( nameDataSplit->length > 0 ); outText = nameDataSplit->list[nameDataSplit->length-1]; DELETE_POINTER( nameDataSplit ); }
bool CCTextureFontPageFile::load() { CCText textureFile( name ); textureFile += ".png"; CCResourceType resourceType = CCFileManager::FindFile( textureFile.buffer ); if( resourceType != Resource_Unknown ) { texturePageIndex = gEngine->textureManager->assignTextureIndex( textureFile.buffer, resourceType, true, true, true ); CCText csvFile = name; csvFile += ".csv"; // Load the descriptor file CCText textData; CCFileManager::GetFile( csvFile.buffer, textData, resourceType ); CCList<char> lettersSplit; textData.split( lettersSplit, "\n" ); CCText rawLetterData; CCList<char> letterDataSplit; for( int i=0; i<lettersSplit.length; ++i ) { const char *raw = lettersSplit.list[i]; rawLetterData.set( raw ); letterDataSplit.clear(); rawLetterData.split( letterDataSplit, "," ); ASSERT( letterDataSplit.length == 4 ); Letter &letter = letters[i]; const char *x1 = letterDataSplit.list[0]; const char *y1 = letterDataSplit.list[1]; const char *x2 = letterDataSplit.list[2]; const char *y2 = letterDataSplit.list[3]; letter.start.x = (float)atof( x1 ); letter.start.y = (float)atof( y1 ); letter.end.x = (float)atof( x2 ); letter.end.y = (float)atof( y2 ); // 16.0f because there's 16 tiles per font page letter.size.width = ( letter.end.x - letter.start.x ) * 16.0f; letter.size.height = ( letter.end.y - letter.start.y ) * 16.0f; } return true; } return false; }
const bool CCTexturePNG::load(const char *name, const CCResourceType resourceType, const bool generateMipMap) { #if defined PROFILEON CCProfiler profile( "CCTexturePNG::load()" ); #endif CCText filename = name; filename.stripDirectory(); filename.toLowercase(); glName = jniLoad( filename.buffer, generateMipMap, resourceType == Resource_Packaged ); if( glName > 0 ) { allocatedWidth = imageWidth = jniGetWidth(); allocatedHeight = imageHeight = jniGetHeight(); jniReleaseRawData(); return true; } return false; }
const bool CCTextureFontPageFile::load(const char *name, const CCResourceType resourceType, const bool generateMipMap) { CCText textureFilename( name ); textureFilename += ".png"; texturePageIndex = gEngine->textureManager->assignTextureIndex( textureFilename.buffer, resourceType, true, generateMipMap ); CCText filename( name ); filename += ".data"; // Load the descriptor file char *fileData = NULL; CCFileManager::getPackagedFile( filename.buffer, &fileData ); CCText textData( fileData ); FREE_POINTER( fileData ); CCList<char> *lettersSplit = textData.split( "\n" ); CCText rawLetterData; for( int i=0; i<lettersSplit->length; ++i ) { const char *raw = lettersSplit->list[i]; rawLetterData.set( raw ); CCList<char> *letterDataSplit = rawLetterData.split( "," ); ASSERT( letterDataSplit->length == 4 ); Letters &letter = letters[i]; letter.start.x = (float)atof( letterDataSplit->list[0] ); letter.start.y = (float)atof( letterDataSplit->list[1] ); letter.end.x = (float)atof( letterDataSplit->list[2] ); letter.end.y = (float)atof( letterDataSplit->list[3] ); // 16.0f because there's 16 tiles per font page letter.size.width = ( letter.end.x - letter.start.x ) * 16.0f; letter.size.height = ( letter.end.y - letter.start.y ) * 16.0f; DELETE_POINTER( letterDataSplit ); } DELETE_POINTER( lettersSplit ); return true; }
void CCText::splitAfter(CCText source, const char *after) { CCList<char> *list1 = source.split( after, true ); if( list1->length > 1 ) { set( list1->list[1] ); for( int i=2; i<list1->length; ++i ) { *this += after; *this += list1->list[i]; } } DELETE_POINTER( list1 ); }
void CCText::splitBefore(CCText source, const char *before) { CCList<char> *list1 = source.split( before, true ); set( list1->list[0] ); DELETE_POINTER( list1 ); }