Debian Codegraph @

plugins/dm.stimresponse/ResponseEffect.h

raw
1 #pragma once
2
3 #include <vector>
4 #include <string>
5 #include "ResponseEffectTypes.h"
6
7 class ResponseEffect
8 {
9 public:
10 struct Argument {
11 // The type string of this property ("e" => entity)
12 std::string type;
13
14 // TRUE, if this argument can be omitted
15 bool optional;
16
17 // The caption of this argument
18 std::string title;
19
20 // The description string
21 std::string desc;
22
23 // The argument value
24 std::string value;
25
26 // The "original" value (a backup) to compare
27 // if an inherited value has been overridden
28 std::string origValue;
29 };
30 typedef std::map<int, Argument> ArgumentList;
31
32 private:
33 // The name of this effect (e.g. "effect_teleport")
34 std::string _effectName;
35 // The (inherited) original name (for comparison during saving)
36 std::string _origName;
37
38 // The state of this response effect
39 bool _state;
40 // The (inherited) original state (for comparison during saving)
41 bool _origState;
42
43 // The list of arguments this effect needs
44 ArgumentList _args;
45
46 // The reference to the entityDef this response effect is basing on
47 IEntityClassPtr _eclass;
48
49 // Stays false until the eclass has been parsed for effect argument types
50 bool _argumentListBuilt;
51
52 // TRUE if this response effect is inherited from the eclass tree
53 bool _inherited;
54
55 public:
56 // Default constructor
57 ResponseEffect();
58
59 // Copy constructor
60 ResponseEffect(const ResponseEffect& other);
61
62 /** greebo: Sets the internal "inherited" flag
63 */
64 void setInherited(bool inherited);
65 bool isInherited() const;
66
67 // Returns the effect name ("effect_damage")
68 std::string getName() const;
69
70 /** greebo: Returns TRUE, if the name has been overridden by
71 * a non-inherited spawnarg (needed to know during saving).
72 */
73 bool nameIsOverridden();
74
75 /** greebo: Updates the name of this object. This triggers
76 * an update of the contained IEntityClassPtr as well.
77 *
78 * @inherited: This indicates the origin of this "set" operation.
79 * It can be used to determine whether this is an
80 * "overrule" of inherited values.
81 */
82 void setName(const std::string& name, bool inherited = false);
83
84 bool isActive() const;
85 void setActive(bool active, bool inherited = false);
86
87 /** greebo: Returns TRUE, if the active state is overridden
88 * by a non-inherited key on the entity
89 */
90 bool activeIsOverridden();
91
92 /** greebo: Retrieves the argument with the given index.
93 */
94 std::string getArgument(unsigned int index) const;
95
96 /** greebo: Returns TRUE if the argument with the given index is overridden
97 */
98 bool argIsOverridden(unsigned int index);
99
100 /** greebo: Sets the argument with the given ID to the given value.
101 *
102 * @inherited: This indicates the origin of this "set" operation.
103 * It can be used to determine whether this is an
104 * "overrule" of inherited values.
105 */
106 void setArgument(unsigned int index, const std::string& value, bool inherited = false);
107
108 /** greebo: Returns a reference to the internal list
109 */
110 ArgumentList& getArguments();
111
112 /** greebo: Returns a "fabricated" argument string
113 * in human-readable format to pack into the effects list
114 */
115 std::string getArgumentStr();
116
117 /** greebo: Returns the "display name" of this effect (e.g. "Damage")
118 */
119 std::string getCaption() const;
120
121 /** greebo: Returns the entity class pointer (as the name states)
122 */
123 IEntityClassPtr getEClass() const;
124
125 /** greebo: Clears and rebuilds the argument list from
126 * the information found in the entity class.
127 */
128 void buildArgumentList();
129
130 /** greebo: Clears the argument list (removes all map entries)
131 */
132 void clearArgumentList();
133
134 private:
135 std::string removeMarkup(const std::string& input);
136 };