Crossfire Server, Trunk
ArchetypeWrapper.h
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 #ifndef ARCHETYPE_WRAPPER_H
14 #define ARCHETYPE_WRAPPER_H
15 
16 #include <QObject>
17 
18 #include "global.h"
19 #include "CREPixmap.h"
22 
23 class ResourcesManager;
24 
25 class ArchetypeWrapper : public AssetWithArtifacts<archetype> {
26  Q_OBJECT
27 
28  Q_PROPERTY(QString name READ name)
29  Q_PROPERTY(QObject* clone READ clone)
30  Q_PROPERTY(QObject *head READ head)
31  Q_PROPERTY(QObject *more READ more)
32  Q_PROPERTY(QString raw READ raw WRITE setRaw)
33 
34 public:
35  ArchetypeWrapper(AssetWrapper *parent, archetype* arch, ResourcesManager *resourcesManager);
36 
37  virtual QString displayName() const override { return myWrappedItem->name; }
38  virtual QIcon displayIcon() const override { return CREPixmap::getIcon(myWrappedItem->clone.face); }
39  virtual int childrenCount() const override;
40  virtual AssetWrapper *child(int index) override;
41  virtual int childIndex(AssetWrapper *child) override;
42 
43  virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override;
44 
45  virtual void fillMenu(QMenu *menu) override;
46  virtual bool canDrag() const override { return true; }
47  virtual void drag(QMimeData *) const override;
48 
49  QString name() const;
50  QObject* clone();
51  QObject *head() const;
52  QObject *more() const;
53  QString raw() const;
54  void setRaw(const QString &raw);
55 
56 protected:
57  virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override;
58  bool appearsOnTreasureList() const;
59 
60  std::string myRaw;
61 };
62 
63 #endif // ARCHETYPE_WRAPPER_H
AssetTWrapper< archetype >::myWrappedItem
archetype * myWrappedItem
Definition: AssetWrapper.h:104
global.h
ArchetypeWrapper::canDrag
virtual bool canDrag() const override
Definition: ArchetypeWrapper.h:46
ArchetypeWrapper::more
QObject more
Definition: ArchetypeWrapper.h:31
ResourcesManager
Definition: ResourcesManager.h:80
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
ArchetypeWrapper::setRaw
void setRaw(const QString &raw)
Definition: ArchetypeWrapper.cpp:231
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
ArchetypeWrapper::myRaw
std::string myRaw
Definition: ArchetypeWrapper.h:60
ArchetypeWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: ArchetypeWrapper.cpp:147
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
ArchetypeWrapper::appearsOnTreasureList
bool appearsOnTreasureList() const
Definition: ArchetypeWrapper.cpp:207
ArchetypeWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override
Definition: ArchetypeWrapper.cpp:47
ArchetypeWrapper::raw
QString raw
Definition: ArchetypeWrapper.h:32
ArchetypeWrapper::head
QObject head
Definition: ArchetypeWrapper.h:30
archetype::clone
object clone
Definition: object.h:487
AssetWrapper
Definition: AssetWrapper.h:25
object::face
const Face * face
Definition: object.h:341
AssetWrapper::ChangeType
ChangeType
Definition: AssetWrapper.h:33
ArchetypeWrapper::clone
QObject clone
Definition: ArchetypeWrapper.h:29
archetype
Definition: object.h:483
ArchetypeWrapper::childrenCount
virtual int childrenCount() const override
Definition: ArchetypeWrapper.cpp:68
AssetWithArtifacts.h
ArchetypeWrapper::displayIcon
virtual QIcon displayIcon() const override
Definition: ArchetypeWrapper.h:38
ArchetypeWrapper
Definition: ArchetypeWrapper.h:25
ArchetypeWrapper::name
QString name
Definition: ArchetypeWrapper.h:28
ArchetypeWrapper::childIndex
virtual int childIndex(AssetWrapper *child) override
Definition: ArchetypeWrapper.cpp:93
npc_dialog.index
int index
Definition: npc_dialog.py:102
ArtifactWrapper.h
AssetWithArtifacts
Definition: AssetWithArtifacts.h:26
ArchetypeWrapper::displayName
virtual QString displayName() const override
Definition: ArchetypeWrapper.h:37
archetype::name
sstring name
Definition: object.h:484
ArchetypeWrapper::fillMenu
virtual void fillMenu(QMenu *menu) override
Definition: ArchetypeWrapper.cpp:245
ArchetypeWrapper::child
virtual AssetWrapper * child(int index) override
Definition: ArchetypeWrapper.cpp:81
ArchetypeWrapper::drag
virtual void drag(QMimeData *) const override
Definition: ArchetypeWrapper.cpp:203
CREPixmap.h
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25