// // ToyStaticActionParser.cpp // SteveMaggieCpp // // Created by Katarzyna Kalinowska-Górska on 21.05.2017. // // #include #include "ToyStaticActionParser.h" #include "ToySceneWithUtils.h" #include "ToySoundsRepo.h" #include "ToyResourceUtilities.h" const std::string ToyStaticActionParser::ACTION_TYPE_PLAY_SOUND = "playSound"; const std::string ToyStaticActionParser::ACTION_TYPE_DISMISS_DIALOG = "dismissDialog"; void ToyStaticActionParser::parseStaticAction(const rapidjson::Value& actionJson) { if (actionJson.IsObject() && ToyJSONParseUtils::hasMemberString(actionJson, "actionType")){ const auto& actionType = actionJson["actionType"].GetString(); if(ACTION_TYPE_PLAY_SOUND == actionType) { if(ToyJSONParseUtils::hasMemberString(actionJson, "soundPath")){ // printf(ToyResourceUtilities::getInstance().getFullPathForDownloadedFile(actionJson["soundPath"].GetString(), false).c_str()); auto cancelOtherSounds = ToyJSONParseUtils::checkMemberBool(actionJson, "cancelOtherSounds", true); ToySoundsRepo::playSound(ToyResourceUtilities::getInstance().getFullPathForDownloadedFile(actionJson["soundPath"].GetString(), false).c_str(), cancelOtherSounds); } } else if(ACTION_TYPE_DISMISS_DIALOG == actionType){ auto currentScene = dynamic_cast(cocos2d::Director::getInstance()->getRunningScene()); currentScene->dismissCurrentDialog(); } } }