| 352 | } |
| 353 | |
| 354 | NewQuestInterface::NewQuestInterface(QuestManagerPtr const& manager, QuestPtr const& quest, PlayerPtr player) |
| 355 | : QuestPane(quest, std::move(player)), m_manager(manager), m_decision(QuestDecision::Cancelled) { |
| 356 | auto assets = Root::singleton().assets(); |
| 357 | |
| 358 | List<Drawable> objectivePortrait = m_quest->portrait("Objective").value({}); |
| 359 | bool shortDialog = objectivePortrait.size() == 0; |
| 360 | |
| 361 | String configFile; |
| 362 | if (shortDialog) |
| 363 | configFile = m_quest->getTemplate()->newQuestGuiConfig.value(assets->json("/quests/quests.config:defaultGuiConfigs.newQuest").toString()); |
| 364 | else |
| 365 | configFile = m_quest->getTemplate()->newQuestGuiConfig.value(assets->json("/quests/quests.config:defaultGuiConfigs.newQuestPortrait").toString()); |
| 366 | |
| 367 | Json config = assets->json(configFile); |
| 368 | |
| 369 | commonSetup(config, m_quest->text(), "QuestStarted"); |
| 370 | |
| 371 | if (!m_quest->canBeAbandoned()) { |
| 372 | if (auto declineButton = fetchChild<ButtonWidget>("btnDecline")) |
| 373 | declineButton->disable(); |
| 374 | } |
| 375 | |
| 376 | if (!shortDialog) { |
| 377 | if (auto objectivePortraitImage = fetchChild<ImageWidget>("objectivePortraitImage")) { |
| 378 | Drawable::scaleAll(objectivePortrait, Vec2F(-1, 1)); |
| 379 | objectivePortraitImage->setDrawables(objectivePortrait); |
| 380 | |
| 381 | String objectivePortraitTitle = m_quest->portraitTitle("Objective").value(""); |
| 382 | auto portraitLabel = fetchChild<LabelWidget>("objectivePortraitTitle"); |
| 383 | portraitLabel->setText(objectivePortraitTitle); |
| 384 | portraitLabel->setVisibility(objectivePortrait.size() > 0); |
| 385 | |
| 386 | fetchChild<ImageWidget>("imgPolaroid")->setVisibility(objectivePortrait.size() > 0); |
| 387 | fetchChild<ImageWidget>("imgPolaroidBack")->setVisibility(objectivePortrait.size() > 0); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | if (auto rewardItemsWidget = fetchChild<ItemGridWidget>("rewardItems")) |
| 392 | rewardItemsWidget->setVisibility(m_quest->rewards().size() > 0); |
| 393 | if (auto rewardsLabel = fetchChild<LabelWidget>("lblRewards")) |
| 394 | rewardsLabel->setVisibility(m_quest->rewards().size() > 0); |
| 395 | } |
| 396 | |
| 397 | void NewQuestInterface::close() { |
| 398 | m_decision = QuestDecision::Cancelled; |
nothing calls this directly
no test coverage detected