Crossfire Server, Trunk
ArchetypesWrapper.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 "ArchetypesWrapper.h"
14 #include "../ResourcesManager.h"
15 
17 
18 void ArchetypesWrapper::fillMenu(QMenu *menu) {
19  connect(menu->addAction(tr("Add archetype")), &QAction::triggered, [this] () { addArchetype(); });
20 }
21 
23  auto origins = myResources->archetypeFiles();
24  auto keys = getManager()->archetypes()->keys();
25 
27  if (aqd.exec() != QDialog::Accepted) {
28  return;
29  }
30 
31  auto arch = get_archetype_struct();
32  CLEAR_FLAG(&arch->clone, FLAG_REMOVED);
33  arch->name = add_string(aqd.code().toStdString().c_str());
34  arch->clone.name = add_string(arch->name);
35  getManager()->archetypes()->define(arch->name, arch);
36  myResources->assetDefined(arch, aqd.file().toStdString());
39  myAssets.push_back(myResources->wrap(arch, this));
41 }
ArchetypesWrapper::fillMenu
virtual void fillMenu(QMenu *menu) override
Definition: ArchetypesWrapper.cpp:18
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
AssetWrapper::AfterChildAdd
@ AfterChildAdd
Definition: AssetWrapper.h:33
get_archetype_struct
archetype * get_archetype_struct(void)
Definition: arch.cpp:195
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
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
ArchetypesWrapper.h
AssetOriginAndCreationDialog::CreateAsset
@ CreateAsset
Definition: AssetOriginAndCreationDialog.h:25
AssetWrapper::BeforeChildAdd
@ BeforeChildAdd
Definition: AssetWrapper.h:33
ResourcesManager::archetypeFiles
std::vector< std::string > archetypeFiles() const
Definition: ResourcesManager.h:111
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
AssetOriginAndCreationDialog
Definition: AssetOriginAndCreationDialog.h:21
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
ResourcesManager::archetypeModified
void archetypeModified(archetype *arch)
Definition: ResourcesManager.cpp:214
FLAG_REMOVED
#define FLAG_REMOVED
Definition: define.h:232
AssetOriginAndCreationDialog::Archetype
@ Archetype
Definition: AssetOriginAndCreationDialog.h:24
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:55
AssetsCollectionWrapper< archetype >::myAssets
QVector< AssetWrapper * > myAssets
Definition: AssetsCollectionWrapper.h:41
connect
Definition: connect.py:1
AssetOriginAndCreationDialog::code
QString code() const
Definition: AssetOriginAndCreationDialog.h:37
ArchetypesWrapper::addArchetype
void addArchetype()
Definition: ArchetypesWrapper.cpp:22
AssetOriginAndCreationDialog::file
QString file() const
Definition: AssetOriginAndCreationDialog.h:38
ArchetypesWrapper::myResources
ResourcesManager * myResources
Definition: ArchetypesWrapper.h:42