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 bool canDrag() const override { return true; }
46  virtual void drag(QMimeData *) const override;
47 
48  QString name() const;
49  QObject* clone();
50  QObject *head() const;
51  QObject *more() const;
52  QString raw() const;
53  void setRaw(const QString &raw);
54 
55 protected:
56  virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override;
57  bool appearsOnTreasureList() const;
58 
59  std::string myRaw;
60 };
61 
62 #endif // ARCHETYPE_WRAPPER_H
AssetTWrapper< archetype >::myWrappedItem
archetype * myWrappedItem
Definition: AssetWrapper.h:103
global.h
obj::face
const Face * face
Definition: object.h:339
ArchetypeWrapper::canDrag
virtual bool canDrag() const override
Definition: ArchetypeWrapper.h:45
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:220
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:31
ArchetypeWrapper::myRaw
std::string myRaw
Definition: ArchetypeWrapper.h:59
ArchetypeWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: ArchetypeWrapper.cpp:146
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
ArchetypeWrapper::appearsOnTreasureList
bool appearsOnTreasureList() const
Definition: ArchetypeWrapper.cpp:196
archt
Definition: object.h:472
ArchetypeWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override
Definition: ArchetypeWrapper.cpp:46
ArchetypeWrapper::raw
QString raw
Definition: ArchetypeWrapper.h:32
ArchetypeWrapper::head
QObject head
Definition: ArchetypeWrapper.h:30
AssetWrapper
Definition: AssetWrapper.h:25
AssetWrapper::ChangeType
ChangeType
Definition: AssetWrapper.h:32
ArchetypeWrapper::clone
QObject clone
Definition: ArchetypeWrapper.h:29
ArchetypeWrapper::childrenCount
virtual int childrenCount() const override
Definition: ArchetypeWrapper.cpp:67
archt::clone
object clone
Definition: object.h:476
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:92
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
archt::name
sstring name
Definition: object.h:473
ArchetypeWrapper::child
virtual AssetWrapper * child(int index) override
Definition: ArchetypeWrapper.cpp:80
ArchetypeWrapper::drag
virtual void drag(QMimeData *) const override
Definition: ArchetypeWrapper.cpp:192
CREPixmap.h
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25