Crossfire Server, Trunk
GeneralMessageWrapper.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 GENERAL_MESSAGE_WRAPPER_H
14 #define GENERAL_MESSAGE_WRAPPER_H
15 
16 #include <QObject>
17 
18 #include "global.h"
19 #include "assets/AssetWrapper.h"
20 #include "CREPixmap.h"
21 #include "faces/FaceWrapper.h"
23 
24 class ResourcesManager;
25 
26 class GeneralMessageWrapper : public AssetTWrapper<GeneralMessage> {
27  Q_OBJECT
28 
29  Q_PROPERTY(QString title READ title WRITE setTitle)
30  Q_PROPERTY(QString identifier READ identifier)
31  Q_PROPERTY(QString quest READ quest WRITE setQuest)
32  Q_PROPERTY(int chance READ chance WRITE setChance)
33  Q_PROPERTY(const Face *face READ face WRITE setFace)
34  Q_PROPERTY(QString message READ message WRITE setMessage)
35 
36 public:
38  myResources(resources) {
39  }
40 
41  virtual QString displayName() const override { return (myWrappedItem->identifier && myWrappedItem->identifier[0] == '\n') ? tr("General message") : myWrappedItem->title; }
42  virtual QIcon displayIcon() const override { return CREPixmap::getIcon(myWrappedItem->face); }
43 
44  virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override;
45  virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override;
46 
47  QString title() const { return myWrappedItem->title; }
48  void setTitle(const QString &title);
49  QString identifier() const { return (myWrappedItem->identifier && myWrappedItem->identifier[0] != '\n') ? myWrappedItem->identifier : ""; }
50  QString quest() const { return myWrappedItem->quest_code; }
51  void setQuest(const QString &quest);
52  int chance() const { return myWrappedItem->chance; }
53  void setChance(int chance);
54  const Face *face() const { return myWrappedItem->face; }
55  void setFace(const Face *face);
56  QString message() const { return myWrappedItem->message; }
57  void setMessage(const QString &message);
58 
59 protected:
61 };
62 
63 #endif // GENERAL_MESSAGE_WRAPPER_H
AssetTWrapper< GeneralMessage >::myWrappedItem
GeneralMessage * myWrappedItem
Definition: AssetWrapper.h:104
Face
Definition: face.h:14
global.h
GeneralMessage
Definition: book.h:44
AssetWrapper.h
GeneralMessageWrapper::setMessage
void setMessage(const QString &message)
Definition: GeneralMessageWrapper.cpp:63
ResourcesManager
Definition: ResourcesManager.h:80
GeneralMessageWrapper::message
QString message
Definition: GeneralMessageWrapper.h:34
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
GeneralMessage::title
sstring title
Definition: book.h:48
GeneralMessage::identifier
sstring identifier
Definition: book.h:47
GeneralMessageWrapper::displayIcon
virtual QIcon displayIcon() const override
Definition: GeneralMessageWrapper.h:42
GeneralMessageWrapper::chance
int chance() const
Definition: GeneralMessageWrapper.h:52
quest
Definition: quest.py:1
GeneralMessage::chance
int chance
Definition: book.h:45
AssetWrapper
Definition: AssetWrapper.h:25
AssetWrapper::ChangeType
ChangeType
Definition: AssetWrapper.h:33
GeneralMessageWrapper::face
const Face * face() const
Definition: GeneralMessageWrapper.h:54
title
Definition: readable.cpp:108
FaceWrapper.h
GeneralMessageWrapper::myResources
ResourcesManager * myResources
Definition: GeneralMessageWrapper.h:60
GeneralMessage::message
sstring message
Definition: book.h:49
AssetWrapperPanel.h
GeneralMessageWrapper::setFace
void setFace(const Face *face)
Definition: GeneralMessageWrapper.cpp:56
GeneralMessageWrapper::identifier
QString identifier
Definition: GeneralMessageWrapper.h:30
GeneralMessageWrapper::setChance
void setChance(int chance)
Definition: GeneralMessageWrapper.cpp:49
GeneralMessageWrapper::chance
int chance
Definition: GeneralMessageWrapper.h:32
GeneralMessageWrapper::title
QString title() const
Definition: GeneralMessageWrapper.h:47
GeneralMessageWrapper::face
const Face face
Definition: GeneralMessageWrapper.h:33
GeneralMessageWrapper::identifier
QString identifier() const
Definition: GeneralMessageWrapper.h:49
GeneralMessageWrapper::message
QString message() const
Definition: GeneralMessageWrapper.h:56
GeneralMessageWrapper::setQuest
void setQuest(const QString &quest)
Definition: GeneralMessageWrapper.cpp:42
GeneralMessageWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: GeneralMessageWrapper.cpp:16
GeneralMessageWrapper
Definition: GeneralMessageWrapper.h:26
GeneralMessage::face
const Face * face
Definition: book.h:51
GeneralMessageWrapper::setTitle
void setTitle(const QString &title)
Definition: GeneralMessageWrapper.cpp:35
GeneralMessageWrapper::wasModified
virtual void wasModified(AssetWrapper *asset, ChangeType type, int extra) override
Definition: GeneralMessageWrapper.cpp:30
GeneralMessageWrapper::displayName
virtual QString displayName() const override
Definition: GeneralMessageWrapper.h:41
CREPixmap.h
GeneralMessageWrapper::quest
QString quest() const
Definition: GeneralMessageWrapper.h:50
GeneralMessage::quest_code
sstring quest_code
Definition: book.h:50
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
AssetTWrapper
Definition: AssetWrapper.h:94