void GenericPlatform::SaveToFile(TString FileName, std::list<TString> Contents, bool ownerOnly) { TString path = FilePath::ExtractFilePath(FileName); if (FilePath::DirectoryExists(path) == false) { FilePath::CreateDirectory(path, ownerOnly); } std::wofstream stream(FileName.data()); FilePath::ChangePermissions(FileName.data(), ownerOnly); #ifdef WINDOWS const std::locale empty_locale = std::locale::empty(); #endif //WINDOWS #ifdef POSIX const std::locale empty_locale = std::locale::classic(); #endif //POSIX #if defined(WINDOWS) const std::locale utf8_locale = std::locale(empty_locale, new std::codecvt_utf8<wchar_t>()); stream.imbue(utf8_locale); #endif //WINDOWS || MAC if (stream.is_open() == true) { for (std::list<TString>::const_iterator iterator = Contents.begin(); iterator != Contents.end(); iterator++) { TString line = *iterator; stream << PlatformString(line).toUnicodeString() << std::endl; } } }
std::list<TString> GenericPlatform::LoadFromFile(TString FileName) { std::list<TString> result; if (FilePath::FileExists(FileName) == true) { std::wifstream stream(FileName.data()); #ifdef WINDOWS const std::locale empty_locale = std::locale::empty(); #endif //WINDOWS #ifdef POSIX const std::locale empty_locale = std::locale::classic(); #endif //POSIX #if defined(WINDOWS) const std::locale utf8_locale = std::locale(empty_locale, new std::codecvt_utf8<wchar_t>()); stream.imbue(utf8_locale); #endif //WINDOWS if (stream.is_open() == true) { while (stream.eof() == false) { std::wstring line; std::getline(stream, line); // # at the first character will comment out the line. if (line.empty() == false && line[0] != '#') { result.push_back(PlatformString(line).toString()); } } } } return result; }
void RoleShow::showBoom(const CCPoint& point) { CCSprite* pBoom = CCSprite::createWithSpriteFrameName("rocketgunbullet1.png"); pBoom->setPosition(point); addChild(pBoom); CCArray *animaArray = CCArray::createWithCapacity(12); for (int j = 1; j <= 12; j++) { TString str; str += "rocketgunboom"; str += j; str += ".png"; CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str.data()); animaArray->addObject(frame); } CCAnimation* animation = CCAnimation::createWithSpriteFrames(animaArray, 0.05f); CCAnimate* animate = CCAnimate::create(animation); CCCallFuncN* funcN = CCCallFuncN::create(this,callfuncN_selector(RoleShow::removeSelf)); CCSequence* seq = CCSequence::createWithTwoActions(animate, funcN); pBoom -> stopAllActions(); pBoom -> runAction(seq); }
void RoleShow::firegunEffect() { pFiregun = CCSprite::createWithSpriteFrameName("fireguneffect1.png"); CCArray *animaArray = CCArray::createWithCapacity(4); for (int j = 3; j <= 6; j++) { TString str; str += "fireguneffect"; str += j; str += ".png"; CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str.data()); animaArray->addObject(frame); } CCAnimation* animation = CCAnimation::createWithSpriteFrames(animaArray, 0.07f); CCAnimate* animate = CCAnimate::create(animation); pFiregun -> runAction(CCRepeatForever::create(animate)); pFiregun->setAnchorPoint(ccp(0.5,0)); pFiregun->setScale(0.5); //pFiregun->setPosition(ccp(-m_size.width*0.07,-m_size.height*0.25)); addChild(pFiregun); //img -> setRotation(touchangle/PI*180); }
JavaStaticMethod JavaClass::GetStaticMethod(TString Name, TString Signature) { jmethodID method = FEnv->GetStaticMethodID(FClass, PlatformString(Name), PlatformString(Signature)); if (method == NULL || FEnv->ExceptionCheck() == JNI_TRUE) { Messages& messages = Messages::GetInstance(); TString message = messages.GetMessage(METHOD_NOT_FOUND); message = PlatformString::Format(message, Name.data(), FClassName.data()); throw JavaException(FEnv, message); } return JavaStaticMethod(FEnv, FClass, method); }
/*1 黑寡妇 2 金刚狼 3 钢铁侠 */ void RoleShow::showHeroAnimation(int currentHero,const CCPoint& offsetPoint) { if(currentHero == k_battle_blackwidow) { firegunEffect(); } m_currentHero = currentHero; m_offsetPoint = offsetPoint; //窗口大小 CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); TString zhujiaoname; zhujiaoname += "hero"; zhujiaoname += currentHero; zhujiaoname += "_middle1.png"; zhujiao = CCSprite::create(); zhujiao->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(zhujiaoname.data())); zhujiao->setAnchorPoint(ccp(0.5f, 0.0f)); //zhujiao->setPosition(ccp(x-20, y-15-offsetY)); zhujiao->setPosition(ccp(0-offsetPoint.x, 0-offsetPoint.y)); addChild(zhujiao, 1004); TString zhujiaolegname; zhujiaolegname += "hero"; zhujiaolegname += currentHero; zhujiaolegname += "_middleleg.png"; zhujiaoleg = CCSprite::createWithSpriteFrameName(zhujiaolegname.data()); // zhujiaoleg -> setPosition(ccp(x, y-offsetY)); zhujiaoleg->setAnchorPoint(ccp(0.5f, 0.0f)); zhujiaoleg -> setPosition(ccp(20-offsetPoint.x, -15-offsetPoint.y)); addChild(zhujiaoleg, 1002); //主角动画 主角 关卡信息都要根据传入的来 TString zhujiaogunname; zhujiaogunname += "hero"; zhujiaogunname += currentHero; zhujiaogunname += "_gun1.png"; zhujiaogun = CCSprite::create(); zhujiaogun->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(zhujiaogunname.data())); float anchorPointY = 20/zhujiaogun -> getContentSize().height; zhujiaogun->setAnchorPoint(ccp(0.5f, -anchorPointY)); zhujiaogun->setPosition(ccp(0-offsetPoint.x, 20-offsetPoint.y)); addChild(zhujiaogun, 1003); moveHero(); }
static TString ProcessCommands(const _TCHAR *file) { FILE *fin; #ifdef UNICODE int err = _wfopen_s(&fin, file, L"r,ccs=unicode"); #else int err = fopen_s(&fin, file, "r"); #endif if (err) return TString(file); FILE *fout; auto output_file = TempFile::Create(TEXT(".txt"), true); #ifdef UNICODE err = _wfopen_s(&fout, output_file.data(), L"w,ccs=unicode"); #else err = fopen_s(&fout, output_file.data(), "w"); #endif if (err) { perror("LinkWrapper:ProcessCommands"); exit(err); } _TINT ch = _gettc(fin); while (ch != _TEOF) { while (ch != _TEOF && _istspace(ch)) { _puttc(ch, fout); ch = _gettc(fin); } // FIXME: input files with spaces in them??? (are they quoted???) TString word; while (ch != _TEOF && !_istspace(ch)) { word.push_back(ch); ch = _gettc(fin); } // FIXME: handle comments (starting with ';') auto comment_pos = word.find(TCHAR(';')); assert(comment_pos == -1 && "Found comment in command file"); if (!word.empty()) { auto new_word = ProcessArg(word.data()); _fputts(new_word.data(), fout); } } fclose(fin); fclose(fout); return output_file; }
void JavaStringArray::Initialize(size_t Size) { JavaClass jstringClass(FEnv, _T("java/lang/String")); if (FEnv->ExceptionCheck() == JNI_TRUE) { Messages& messages = Messages::GetInstance(); TString message = messages.GetMessage(CLASS_NOT_FOUND); message = PlatformString::Format(message, _T("String")); throw JavaException(FEnv, message.data()); } jstring str = PlatformString("").toJString(FEnv); FData = (jobjectArray)FEnv->NewObjectArray((jsize)Size, jstringClass, str); if (FEnv->ExceptionCheck() == JNI_TRUE) { throw JavaException(FEnv, _T("Error")); } }
void RoleShow::wolverineGunAnimation() { CCArray *animaArray = CCArray::createWithCapacity(3); for (int j = 1; j <= 3; j++) { TString str; str += "hero2_gun1"; str += j; str += ".png"; CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str.data()); animaArray->addObject(frame); } CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero2_gun1.png"); animaArray->addObject(frame); CCAnimation* animation = CCAnimation::createWithSpriteFrames(animaArray, 0.07f); CCAnimate* animate = CCAnimate::create(animation); zhujiaogun -> runAction(animate); }
void RoleShow::createLaserBullet(const CCPoint& startPoint) { jiguangGun = CCSprite::createWithSpriteFrameName("jiguangEffect1.png"); CCArray *animaArray = CCArray::createWithCapacity(6); for (int j = 1; j <= 6; j++) { TString str; str += "jiguangEffect"; str += j; str += ".png"; CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str.data()); animaArray->addObject(frame); } CCAnimation* animation = CCAnimation::createWithSpriteFrames(animaArray, 0.07f); CCAnimate* animate = CCAnimate::create(animation); jiguangGun -> runAction(CCSequence::create(animate,CCCallFuncN::create(this,callfuncN_selector(RoleShow::removeSelf)),NULL)); jiguangGun->setAnchorPoint(ccp(0,0)); jiguangGun->setPosition(ccp(startPoint.x - 25, startPoint.y-40)); jiguangGun->setRotation(heroAngle); addChild(jiguangGun); }
bool start_launcher(int argc, TCHAR* argv[]) { bool result = false; bool parentProcess = true; // Platform must be initialize first. Platform& platform = Platform::GetInstance(); try { for (int index = 0; index < argc; index++) { TString argument = argv[index]; if (argument == _T("-Xappcds:generatecache")) { platform.SetAppCDSState(cdsGenCache); } else if (argument == _T("-Xappcds:off")) { platform.SetAppCDSState(cdsDisabled); } else if (argument == _T("-Xapp:child")) { parentProcess = false; } #ifdef DEBUG //TODO There appears to be a compiler bug on Mac overloading ShowResponseMessage. Investigate. else if (argument == _T("-nativedebug")) { if (platform.ShowResponseMessage(_T("Test"), TString(_T("Would you like to debug?\n\nProcessID: ")) + PlatformString(platform.GetProcessID()).toString()) == mrOK) { while (platform.IsNativeDebuggerPresent() == false) { } } } #endif //DEBUG } // Package must be initialized after Platform is fully initialized. Package& package = Package::GetInstance(); Macros::Initialize(); package.SetCommandLineArguments(argc, argv); platform.SetCurrentDirectory(package.GetPackageAppDirectory()); switch (platform.GetAppCDSState()) { case cdsDisabled: case cdsUninitialized: case cdsEnabled: { break; } case cdsGenCache: { TString cacheDirectory = package.GetAppCDSCacheDirectory(); if (FilePath::DirectoryExists(cacheDirectory) == false) { FilePath::CreateDirectory(cacheDirectory, true); } else { TString cacheFileName = package.GetAppCDSCacheFileName(); if (FilePath::FileExists(cacheFileName) == true) { FilePath::DeleteFile(cacheFileName); } } break; } case cdsAuto: { TString cacheFileName = package.GetAppCDSCacheFileName(); if (parentProcess == true && FilePath::FileExists(cacheFileName) == false) { AutoFreePtr<Process> process = platform.CreateProcess(); std::vector<TString> args; args.push_back(_T("-Xappcds:generatecache")); args.push_back(_T("-Xapp:child")); process->Execute(platform.GetModuleFileName(), args, true); if (FilePath::FileExists(cacheFileName) == false) { // Cache does not exist after trying to generate it, // so run without cache. platform.SetAppCDSState(cdsDisabled); package.Clear(); package.Initialize(); } } break; } } // Validation { switch (platform.GetAppCDSState()) { case cdsDisabled: case cdsGenCache: { // Do nothing. break; } case cdsEnabled: case cdsAuto: { TString cacheFileName = package.GetAppCDSCacheFileName(); if (FilePath::FileExists(cacheFileName) == false) { Messages& messages = Messages::GetInstance(); TString message = PlatformString::Format(messages.GetMessage(APPCDS_CACHE_FILE_NOT_FOUND), cacheFileName.data()); throw FileNotFoundException(message); } break; } case cdsUninitialized: { throw Exception(_T("Internal Error")); } } } // Run App result = RunVM(); } catch (FileNotFoundException &e) { platform.ShowMessage(e.GetMessage()); } return result; }
void RoleShow::changeHero(int currentHero,const CCPoint& offsetPoint) { if(m_currentHero == currentHero) return; heroAngle = 2; if(currentHero == k_battle_blackwidow) { firegunEffect(); } else { if(pFiregun) { pFiregun->stopAllActions(); pFiregun->removeFromParent(); pFiregun = NULL; } } m_currentHero = currentHero; m_offsetPoint = offsetPoint; TString zhujiaoname; zhujiaoname += "hero"; zhujiaoname += currentHero; zhujiaoname += "_middle1.png"; zhujiao->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(zhujiaoname.data())); TString zhujiaolegname; zhujiaolegname += "hero"; zhujiaolegname += currentHero; zhujiaolegname += "_middleleg.png"; zhujiaoleg -> setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(zhujiaolegname.data())); zhujiaogun->cleanup(); if (currentHero != 3) { TString zhujiaogunname; zhujiaogunname += "hero"; zhujiaogunname += currentHero; zhujiaogunname += "_gun1.png"; zhujiaogun->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(zhujiaogunname.data())); zhujiaogun -> setVisible(true); zhujiao->setPosition(ccp(5, -offsetPoint.y)); } else { zhujiaogun -> setVisible(false); float pY = zhujiao->getPositionY(); zhujiao->setPosition(ccp(7, -20-offsetPoint.y)); } moveHero(); }
void EnemyData::analyTXT() {//\u2202\u00A1\u00BB\u00B0\u03C0\u00FF\u00F8\u00AE\u00AC\u2211\u0153\uFB02\u201D\u00CE\u00B5\u00FF\u00D5\u00BA\u00A0\u02DD\u00E6\u203A if (sceneID <= 4 && sceneID > 0) { sceneID = 0; } else if (sceneID > 4 && sceneID <= 8) { sceneID = 1; } else if (sceneID > 8 && sceneID <= 12) { sceneID = 2; } TString mapname; mapname += "map"; mapname += sceneID; mapname += ".txt"; string fullPath = CCFileUtils::sharedFileUtils()->fullPathForFilename(mapname.data()); unsigned char* pBuffer = NULL; unsigned long bufferSize = 0; pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullPath.c_str(), "r", &bufferSize); unsigned long index = 14; string str; routeQuantity = stringChangeInt(str += pBuffer[index]); index += 2; ///////////////\u00AA\u00D2\u00BB\u00B0\u00AC\u2211\u0153\uFB02\u00B5\u0192\u2265\u0131\u00A0\u00BA\u0152\u00AA\u00F7\u221A\u00A0\u02DD\u00E6\u203A//////////////////////////////// index += 11; str = ""; CCLOG("%d", pBuffer[index]); short routeStartIndex = -1; short routeStartSpace = 0; //\u00F8\u00FF\u00F7\u2206\u2206\u00B4\u201C\u2206 CCPoint point; while (pBuffer[index] != '\n') { if (pBuffer[index] == '{') { routeStartIndex++; index++; continue; } if (pBuffer[index] == '}') { point.y = stringChangeInt(str); routeStartPoint.push_back(ccp(point.x, point.y)); index++; if (pBuffer[index] == '\n') break; index ++; str = ""; continue; } if (pBuffer[index] == ',') { //point = new CCPoint(); point.x = stringChangeInt(str); str = ""; } else if (pBuffer[index] != ' ' && pBuffer[index] != '=') { str += pBuffer[index]; } index++; } CCLOG("%d", routeStartPoint.size()); //////////////////\u00AA\u00D2\u00B5\u221A\u00B5\u00FF\u00D5\u00BA\u00A0\u02DD\u25CA\u00C8\u00A0\u02DD\u00E6\u203A////////////////////////////// str = ""; index++; short colIndex = 0; //\u2013\u2013\u0153\u00AC\u00B1\u00CD short rowIndex = 0; //\u00A1\u2013\u0153\u00AC\u00B1\u00CD while (pBuffer[index] != 'e') { if (pBuffer[index] == '\n') { colIndex++; rowIndex = 0; index++; continue; } if (pBuffer[index] == '{' || pBuffer[index] == ' ') { index++; continue; } if (pBuffer[index] == ',' || pBuffer[index] == '}') { mapData[colIndex][rowIndex] = stringChangeInt(str); CCLOG("%d, \u884C=%d, \u5217=%d", mapData[colIndex][rowIndex], colIndex, rowIndex); str = ""; rowIndex++; } else if(pBuffer[index] != '\r') { str += pBuffer[index]; } index++; } // for (short i=0; i<mapCol; ++i) { // for (short j=0; j<mapRow; ++i) { // CCLOG("%d", mapData[i][j]); // } // CCLOG("---------------"); // } }