ToyStaticActionParser.cpp
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// ToyStaticActionParser.cpp
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 21.05.2017.
//
//
#include <stdio.h>
#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<ToySceneWithUtils*>(cocos2d::Director::getInstance()->getRunningScene());
currentScene->dismissCurrentDialog();
}
}
}