Debian Codegraph @

plugins/dm.conversation/CommandArgumentItem.h

raw
1 #pragma once
2
3 #include "ConversationCommandInfo.h"
4 #include "Conversation.h"
5 #include <memory>
6
7 class wxWindow;
8 class wxStaticText;
9 class wxTextCtrl;
10 class wxCheckBox;
11 class wxChoice;
12 class wxPanel;
13
14 namespace ui
15 {
16
17 class CommandEditor;
18
19 class CommandArgumentItem
20 {
21 protected:
22 // The reference to the editor instance, some arguments need this
23 // for cross-referencing actors and commands
24 CommandEditor& _owner;
25
26 // The argument this row is referring to
27 const conversation::ArgumentInfo& _argInfo;
28 wxStaticText* _labelBox;
29 wxStaticText* _descBox;
30
31 public:
32 CommandArgumentItem(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo);
33
34 // destructor
35 virtual ~CommandArgumentItem() {}
36
37 /**
38 * greebo: This retrieves the string representation of the current
39 * value of this row. This has to be implemented by the subclasses.
40 */
41 virtual std::string getValue() = 0;
42
43 /**
44 * greebo: Loads the given value into the widgets, passed in string form.
45 */
46 virtual void setValueFromString(const std::string& value) = 0;
47
48 // Retrieve the label widget
49 virtual wxWindow* getLabelWidget();
50
51 // Retrieve the edit widgets (abstract)
52 virtual wxWindow* getEditWidget() = 0;
53
54 // Retrieves the help widget (a question mark with a tooltip)
55 virtual wxWindow* getHelpWidget();
56 };
57 typedef std::shared_ptr<CommandArgumentItem> CommandArgumentItemPtr;
58
59 /**
60 * greebo: This is an item querying a simple string
61 */
62 class StringArgument :
63 public CommandArgumentItem
64 {
65 protected:
66 wxTextCtrl* _entry;
67
68 public:
69 StringArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo);
70
71 virtual wxWindow* getEditWidget();
72 virtual std::string getValue();
73 virtual void setValueFromString(const std::string& value);
74 };
75
76 /**
77 * greebo: This is an item querying a float (derives from string)
78 */
79 class FloatArgument :
80 public StringArgument
81 {
82 public:
83 FloatArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo) :
84 StringArgument(owner, parent, argInfo)
85 {}
86 };
87
88 /**
89 * greebo: This is an item querying a vector (derives from string)
90 */
91 class VectorArgument :
92 public StringArgument
93 {
94 public:
95 VectorArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo) :
96 StringArgument(owner, parent, argInfo)
97 {}
98 };
99
100 class BooleanArgument :
101 public CommandArgumentItem
102 {
103 protected:
104 wxCheckBox* _checkButton;
105 public:
106 BooleanArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo);
107
108 virtual wxWindow* getEditWidget();
109 virtual std::string getValue();
110 virtual void setValueFromString(const std::string& value);
111 };
112
113 /**
114 * greebo: This is an item querying an actor (dropdown combo)
115 */
116 class ActorArgument :
117 public CommandArgumentItem
118 {
119 protected:
120 wxChoice* _comboBox;
121 public:
122 // Pass the reference to the helper class
123 ActorArgument(CommandEditor& owner, wxWindow* parent,
124 const conversation::ArgumentInfo& argInfo,
125 const conversation::Conversation::ActorMap& actors);
126
127 virtual wxWindow* getEditWidget();
128 virtual std::string getValue();
129 virtual void setValueFromString(const std::string& value);
130 };
131
132 /**
133 * greebo: This is an item querying a sound shader
134 */
135 class SoundShaderArgument :
136 public StringArgument
137 {
138 private:
139 wxPanel* _soundShaderPanel;
140
141 public:
142 SoundShaderArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo);
143
144 virtual wxWindow* getEditWidget() override;
145 virtual std::string getValue() override;
146 virtual void setValueFromString(const std::string& value) override;
147
148 private:
149 void pickSoundShader();
150 };
151
152 /**
153 * greebo: This is an item querying an animation
154 */
155 class AnimationArgument :
156 public StringArgument
157 {
158 private:
159 wxPanel* _animPanel;
160
161 public:
162 AnimationArgument(CommandEditor& owner, wxWindow* parent, const conversation::ArgumentInfo& argInfo);
163
164 virtual wxWindow* getEditWidget() override;
165 virtual std::string getValue() override;
166 virtual void setValueFromString(const std::string& value) override;
167
168 private:
169 void pickAnimation();
170 };
171
172 } // namespace ui