Exemplo n.º 1
0
QuestModel* QuestModel::FromJSON(const yi::rapidjson::Value& questJSONObject)
{
    CYIParsingError parsingError;

    CYIString questName;
    CYIString questDescription;

    CYIRapidJSONUtility::GetStringField(&questJSONObject, "Name", questName, parsingError);
    YI_ASSERT(!parsingError.HasError(), "QuestModel::FromJSON", parsingError.GetParsingErrorMessage());

    CYIRapidJSONUtility::GetStringField(&questJSONObject, "Description", questDescription, parsingError);
    YI_ASSERT(!parsingError.HasError(), "QuestModel::FromJSON", parsingError.GetParsingErrorMessage());

    QuestModel* newQuest = new QuestModel(questName, questDescription);

    const yi::rapidjson::Value& objectives = questJSONObject["Objectives"];
    YI_ASSERT(objectives.IsArray(), "QuestModel::FromJSON", "Could not find objectives array in JSON file.");

    for (yi::rapidjson::SizeType i = 0; i < objectives.Size(); ++i)
    {
        const yi::rapidjson::Value& objective = objectives[i];

        newQuest->AddObjective(QuestObjectiveModel::FromJSON(objective), i);
    }

    return newQuest;
}
QuestObjectiveModel* QuestObjectiveModel::FromJSON(const yi::rapidjson::Value& objectiveJSONObject)
{
    CYIParsingError parsingError;

    CYIString name;

    CYIRapidJSONUtility::GetStringField(&objectiveJSONObject, "Name", name, parsingError);
    YI_ASSERT(!parsingError.HasError(), "QuestObjectiveModel::FromJSON", parsingError.GetParsingErrorMessage());

    QuestObjectiveModel *newObjective = new QuestObjectiveModel(name);

    const yi::rapidjson::Value &resolutions = objectiveJSONObject["Resolutions"];
    YI_ASSERT(resolutions.IsArray(), "QuestModel::FromJSON", "Could not find resolutions array in JSON file.");

    std::vector<CYIString> questResolutionList;
    for (yi::rapidjson::SizeType r = 0; r < resolutions.Size(); ++r)
    {
        const yi::rapidjson::Value &resolution = resolutions[r];

        newObjective->AddResolution(QuestObjectiveResolution::FromJSON(resolution), r);
    }

    return newObjective;
}
Exemplo n.º 3
0
void ScreenViewController2::OnInitScreen()
{
    m_pPreviousScreenButton = m_pView->GetNode<CYIPushButtonView>("PreviousButton");
    YI_ASSERT(m_pPreviousScreenButton, LOG_TAG, "Could not find push button 'PreviousButton'");
    m_pPreviousScreenButton->ButtonClicked.Connect(*m_pApplication, &DecodeApp::GoBack);
}