Crossfire Server, Trunk
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());
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
AssetsManager.h
QuestsWrapper::addQuest
void addQuest()
Definition: QuestsWrapper.cpp:23
ResourcesManager::questModified
void questModified(quest_definition *quest)
Definition: ResourcesManager.cpp:222
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
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
hall_of_fame.keys
keys
Definition: hall_of_fame.py:43
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
AssetsCollection::keys
std::vector< Key > keys() const
Definition: AssetsCollection.h:183
quest_definition::quest_title
sstring quest_title
Definition: quest.h:39
AssetOriginAndCreationDialog::CreateAsset
@ CreateAsset
Definition: AssetOriginAndCreationDialog.h:25
AssetWrapper::BeforeChildAdd
@ BeforeChildAdd
Definition: AssetWrapper.h:33
AssetsCollection::define
T * define(const Key &name, T *asset)
Definition: AssetsCollection.h:120
AssetOriginAndCreationDialog.h
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
quest_definition::quest_code
sstring quest_code
Definition: quest.h:38
QuestsWrapper::myResources
ResourcesManager * myResources
Definition: QuestsWrapper.h:40
AssetOriginAndCreationDialog
Definition: AssetOriginAndCreationDialog.h:21
AssetsManager::quests
Quests * quests()
Definition: AssetsManager.h:71
QuestsWrapper.h
quest_definition
Definition: quest.h:37
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
AssetsCollectionWrapper< quest_definition >::myAssets
QVector< AssetWrapper * > myAssets
Definition: AssetsCollectionWrapper.h:41
AssetOriginAndCreationDialog::Quest
@ Quest
Definition: AssetOriginAndCreationDialog.h:24
connect
Definition: connect.py:1
quest_create
quest_definition * quest_create(const char *name)
Definition: Quests.cpp:63
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