Crossfire Resources Editor
QuestsWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include <QtWidgets>
14 
15 #include "QuestsWrapper.h"
16 #include "AssetsManager.h"
18 
19 void QuestsWrapper::fillMenu(QMenu *menu) {
20  connect(menu->addAction(tr("Add quest")), &QAction::triggered, [this] () { addQuest(); });
21 }
22 
24  auto origins = myResources->questFiles();
25  auto keys = getManager()->quests()->keys();
26 
28  if (aqd.exec() != QDialog::Accepted) {
29  return;
30  }
31 
32  quest_definition *qd = quest_create(aqd.code().toStdString().c_str());
33  qd->quest_title = add_string(qd->quest_code);
34  getManager()->quests()->define(qd->quest_code, qd);
35  myResources->assetDefined(qd, aqd.file().toStdString());
38  myAssets.push_back(myResources->wrap(qd, this));
40 }
AssetWrapper::AfterChildAdd
@ AfterChildAdd
Definition: AssetWrapper.h:33
QuestsWrapper::addQuest
void addQuest()
Helper function to add a new quest.
Definition: QuestsWrapper.cpp:23
ResourcesManager::questModified
void questModified(quest_definition *quest)
Definition: ResourcesManager.cpp:221
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:134
ResourcesManager::assetDefined
virtual void assetDefined(const archetype *arch, const std::string &filename) override
Definition: ResourcesManager.h:101
ResourcesManager::questFiles
std::vector< std::string > questFiles() const
Definition: ResourcesManager.h:115
AssetOriginAndCreationDialog::CreateAsset
@ CreateAsset
Definition: AssetOriginAndCreationDialog.h:25
AssetWrapper::BeforeChildAdd
@ BeforeChildAdd
Definition: AssetWrapper.h:33
AssetOriginAndCreationDialog.h
QuestsWrapper::myResources
ResourcesManager * myResources
Resources manager, used in quest creation.
Definition: QuestsWrapper.h:40
AssetOriginAndCreationDialog
Helper dialog to input origin of an asset, and maybe create a new one.
Definition: AssetOriginAndCreationDialog.h:21
QuestsWrapper.h
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:57
AssetsCollectionWrapper< quest_definition >::myAssets
QVector< AssetWrapper * > myAssets
Definition: AssetsCollectionWrapper.h:41
AssetOriginAndCreationDialog::Quest
@ Quest
Definition: AssetOriginAndCreationDialog.h:24
AssetOriginAndCreationDialog::code
QString code() const
Definition: AssetOriginAndCreationDialog.h:37
AssetOriginAndCreationDialog::file
QString file() const
Definition: AssetOriginAndCreationDialog.h:38
QuestsWrapper::fillMenu
virtual void fillMenu(QMenu *menu) override
Definition: QuestsWrapper.cpp:19