Crossfire Server, Trunk
MessageFile.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 _MESSAGEFILE_H
14 #define _MESSAGEFILE_H
15 
16 #include <QObject>
17 #include <QStringList>
18 #include "assets/AssetWrapper.h"
19 
20 class CREMapInformation;
21 
25 class MessageRule : public QObject
26 {
27  Q_OBJECT
28 
29  public:
30  MessageRule();
31  MessageRule(const MessageRule& original);
32  virtual ~MessageRule();
33 
34  const QString& comment() const;
35  void setComment(const QString& comment);
36  const QStringList& match() const;
37  QStringList& match();
38  void setMatch(const QStringList& match);
39  const QList<QStringList>& preconditions() const;
40  void setPreconditions(const QList<QStringList>& preconditions);
41  const QList<QStringList>& postconditions() const;
42  void setPostconditions(const QList<QStringList>& postconditions);
43  const QStringList& messages() const;
44  void setMessages(const QStringList& messages);
45  const QStringList& include() const;
46  void setInclude(const QStringList& include);
47  const QList<QStringList>& replies() const;
48  void setReplies(const QList<QStringList>& replies);
49 
50  bool isModified() const;
51  void setModified(bool modified = true);
52 
53  private:
55  QString myComment;
56  QStringList myMatch;
57  QList<QStringList> myPreconditions;
58  QList<QStringList> myPostconditions;
59  QStringList myMessages;
60  QStringList myInclude;
61  QList<QStringList> myReplies;
62 };
63 
68 class MessageFile : public AssetWrapper {
69  Q_OBJECT
70 
71  Q_PROPERTY(QString path READ path WRITE setPath)
72  Q_PROPERTY(QString location READ location WRITE setLocation)
73 
74 public:
80  MessageFile(AssetWrapper *parent, const QString& path);
81  virtual ~MessageFile();
82 
83  virtual QString displayName() const override { return myPath; }
84  virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override;
85 
86  MessageFile* duplicate() const;
87  void copy(const MessageFile* other);
88 
93  bool parseFile();
94 
95  const QString& path() const;
96  void setPath(const QString& path);
97 
98  const QString& location() const;
99  void setLocation(const QString& location);
100 
101  QList<MessageRule*>& rules();
102  QList<CREMapInformation*>& maps();
103 
104  void save();
105 
106  bool isModified() const;
107  void setModified(bool modified = true);
108 
109 private:
111  QString myPath;
112  QString myLocation;
113  QList<MessageRule*> myRules;
114  QList<CREMapInformation*> myMaps;
115 };
116 
117 #endif /* _MESSAGEFILE_H */
MessageFile::path
QString path
Definition: MessageFile.h:71
MessageFile::copy
void copy(const MessageFile *other)
Definition: MessageFile.cpp:147
MessageRule::~MessageRule
virtual ~MessageRule()
Definition: MessageFile.cpp:38
AssetWrapper.h
MessageRule::setPostconditions
void setPostconditions(const QList< QStringList > &postconditions)
Definition: MessageFile.cpp:82
MessageFile::maps
QList< CREMapInformation * > & maps()
Definition: MessageFile.cpp:271
MessageFile::duplicate
MessageFile * duplicate() const
Definition: MessageFile.cpp:137
MessageFile::isModified
bool isModified() const
Definition: MessageFile.cpp:389
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:31
MessageRule::myComment
QString myComment
Definition: MessageFile.h:55
MessageFile::myLocation
QString myLocation
Definition: MessageFile.h:112
MessageFile::save
void save()
Definition: MessageFile.cpp:349
MessageRule::myPostconditions
QList< QStringList > myPostconditions
Definition: MessageFile.h:58
MessageFile
Definition: MessageFile.h:68
MessageFile::myIsModified
bool myIsModified
Definition: MessageFile.h:110
MessageRule::messages
const QStringList & messages() const
Definition: MessageFile.cpp:87
MessageRule::setInclude
void setInclude(const QStringList &include)
Definition: MessageFile.cpp:102
MessageRule::setMatch
void setMatch(const QStringList &match)
Definition: MessageFile.cpp:62
CREMapInformation
Definition: CREMapInformation.h:27
MessageFile::displayName
virtual QString displayName() const override
Definition: MessageFile.h:83
MessageRule::include
const QStringList & include() const
Definition: MessageFile.cpp:97
MessageFile::setLocation
void setLocation(const QString &location)
Definition: MessageFile.cpp:177
AssetWrapper
Definition: AssetWrapper.h:25
MessageRule::MessageRule
MessageRule()
Definition: MessageFile.cpp:23
MessageRule::myPreconditions
QList< QStringList > myPreconditions
Definition: MessageFile.h:57
MessageRule::setModified
void setModified(bool modified=true)
Definition: MessageFile.cpp:122
MessageFile::setPath
void setPath(const QString &path)
Definition: MessageFile.cpp:168
MessageRule::myInclude
QStringList myInclude
Definition: MessageFile.h:60
MessageRule::myMessages
QStringList myMessages
Definition: MessageFile.h:59
MessageRule::setPreconditions
void setPreconditions(const QList< QStringList > &preconditions)
Definition: MessageFile.cpp:72
MessageFile::setModified
void setModified(bool modified=true)
Definition: MessageFile.cpp:394
AssetWrapper::modified
void modified()
MessageFile::rules
QList< MessageRule * > & rules()
Definition: MessageFile.cpp:266
MessageRule::myMatch
QStringList myMatch
Definition: MessageFile.h:56
MessageRule::replies
const QList< QStringList > & replies() const
Definition: MessageFile.cpp:107
MessageRule::setReplies
void setReplies(const QList< QStringList > &replies)
Definition: MessageFile.cpp:112
MessageRule::myReplies
QList< QStringList > myReplies
Definition: MessageFile.h:61
MessageFile::myRules
QList< MessageRule * > myRules
Definition: MessageFile.h:113
MessageFile::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: MessageFile.cpp:399
MessageFile::parseFile
bool parseFile()
Definition: MessageFile.cpp:203
MessageFile::location
QString location
Definition: MessageFile.h:72
MessageRule::match
const QStringList & match() const
Definition: MessageFile.cpp:52
MessageRule::preconditions
const QList< QStringList > & preconditions() const
Definition: MessageFile.cpp:67
MessageFile::myPath
QString myPath
Definition: MessageFile.h:111
MessageRule::myIsModified
bool myIsModified
Definition: MessageFile.h:54
MessageRule::postconditions
const QList< QStringList > & postconditions() const
Definition: MessageFile.cpp:77
MessageRule::isModified
bool isModified() const
Definition: MessageFile.cpp:117
MessageRule::setComment
void setComment(const QString &comment)
Definition: MessageFile.cpp:47
MessageFile::myMaps
QList< CREMapInformation * > myMaps
Definition: MessageFile.h:114
MessageRule
Definition: MessageFile.h:25
MessageRule::setMessages
void setMessages(const QStringList &messages)
Definition: MessageFile.cpp:92
MessageRule::comment
const QString & comment() const
Definition: MessageFile.cpp:42