1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3 // --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5 // --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6
7
8 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9
10 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11
12 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] BEGIN
13
14 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15
16 /**
17 *
18 Definition of the event KEYEVENT.
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Asynchronous message. Response to key event (key press, key release...) when previous SETSENDKEYS command turned this sending on.
25
26 */
27 public class KeyEvent
28 extends InfoMessage
29 implements IWorldEvent, IWorldChangeEvent
30
31 {
32
33 /** Example how the message looks like - used during parser tests. */
34 public static final String PROTOTYPE =
35 "KEYEVENT {Player text} {PlayerId unreal_id} {PlayerName text} {ViewTarget unreal_id} {Action text} {Key text} ";
36
37
38
39 /**
40 * Parameter-less contructor for the message.
41 */
42 public KeyEvent()
43 {
44 }
45
46
47
48
49 /**
50 * Creates new instance of the message KeyEvent.
51 *
52 Asynchronous message. Response to key event (key press, key release...) when previous SETSENDKEYS command turned this sending on.
53
54 * Corresponding GameBots message
55 *
56 * is
57 * KEYEVENT.
58 *
59 *
60 *
61 * @param Player
62 Name of player who has triggered the key event.
63
64 *
65 *
66 *
67 * @param PlayerId
68 Id of player who has triggered the key event.
69
70 *
71 *
72 *
73 * @param PlayerName
74 Name of player who has triggered the key event.
75
76 *
77 *
78 *
79 * @param ViewTarget
80 If the player that triggered the key event is observing another player in the game, then the id of that observed player will be exported here.
81
82 *
83 *
84 *
85 * @param Action
86 Action that happened with the key. Possible are: PRESS, HOLD, RELEASE.
87
88 *
89 *
90 *
91 * @param Key
92 Key that has been pressed, released or held. See Interactions.EInputKey for choices - these are without the "IK_" prefix with original case.
93
94 *
95 *
96 */
97 public KeyEvent(
98 String Player, UnrealId PlayerId, String PlayerName, UnrealId ViewTarget, String Action, String Key
99 ) {
100
101 this.Player = Player;
102
103 this.PlayerId = PlayerId;
104
105 this.PlayerName = PlayerName;
106
107 this.ViewTarget = ViewTarget;
108
109 this.Action = Action;
110
111 this.Key = Key;
112
113 }
114
115 /**
116 * Cloning constructor from the full message.
117 *
118 * @param original
119 */
120 public KeyEvent(KeyEvent original) {
121
122 this.Player = original.getPlayer()
123 ;
124
125 this.PlayerId = original.getPlayerId()
126 ;
127
128 this.PlayerName = original.getPlayerName()
129 ;
130
131 this.ViewTarget = original.getViewTarget()
132 ;
133
134 this.Action = original.getAction()
135 ;
136
137 this.Key = original.getKey()
138 ;
139
140 this.SimTime = original.getSimTime();
141 }
142
143
144 protected long SimTime;
145
146 /**
147 * Simulation time in MILLI SECONDS !!!
148 */
149 @Override
150 public long getSimTime() {
151 return SimTime;
152 }
153
154 /**
155 * Used by Yylex to slip correct time of the object or programmatically.
156 */
157 protected void setSimTime(long SimTime) {
158 this.SimTime = SimTime;
159 }
160
161
162 /**
163 *
164 Name of player who has triggered the key event.
165
166 */
167 protected
168 String Player =
169 null;
170
171 /**
172 *
173 Name of player who has triggered the key event.
174
175 */
176 public String getPlayer()
177 {
178 return Player;
179 }
180
181
182 /**
183 *
184 Id of player who has triggered the key event.
185
186 */
187 protected
188 UnrealId PlayerId =
189 null;
190
191 /**
192 *
193 Id of player who has triggered the key event.
194
195 */
196 public UnrealId getPlayerId()
197 {
198 return PlayerId;
199 }
200
201
202 /**
203 *
204 Name of player who has triggered the key event.
205
206 */
207 protected
208 String PlayerName =
209 null;
210
211 /**
212 *
213 Name of player who has triggered the key event.
214
215 */
216 public String getPlayerName()
217 {
218 return PlayerName;
219 }
220
221
222 /**
223 *
224 If the player that triggered the key event is observing another player in the game, then the id of that observed player will be exported here.
225
226 */
227 protected
228 UnrealId ViewTarget =
229 null;
230
231 /**
232 *
233 If the player that triggered the key event is observing another player in the game, then the id of that observed player will be exported here.
234
235 */
236 public UnrealId getViewTarget()
237 {
238 return ViewTarget;
239 }
240
241
242 /**
243 *
244 Action that happened with the key. Possible are: PRESS, HOLD, RELEASE.
245
246 */
247 protected
248 String Action =
249 null;
250
251 /**
252 *
253 Action that happened with the key. Possible are: PRESS, HOLD, RELEASE.
254
255 */
256 public String getAction()
257 {
258 return Action;
259 }
260
261
262 /**
263 *
264 Key that has been pressed, released or held. See Interactions.EInputKey for choices - these are without the "IK_" prefix with original case.
265
266 */
267 protected
268 String Key =
269 null;
270
271 /**
272 *
273 Key that has been pressed, released or held. See Interactions.EInputKey for choices - these are without the "IK_" prefix with original case.
274
275 */
276 public String getKey()
277 {
278 return Key;
279 }
280
281
282 public String toString() {
283 return
284 super.toString() + "[" +
285
286 "Player = " + String.valueOf(getPlayer()
287 ) + " | " +
288
289 "PlayerId = " + String.valueOf(getPlayerId()
290 ) + " | " +
291
292 "PlayerName = " + String.valueOf(getPlayerName()
293 ) + " | " +
294
295 "ViewTarget = " + String.valueOf(getViewTarget()
296 ) + " | " +
297
298 "Action = " + String.valueOf(getAction()
299 ) + " | " +
300
301 "Key = " + String.valueOf(getKey()
302 ) + " | " +
303
304 "]";
305 }
306
307
308 public String toHtmlString() {
309 return super.toString() + "[<br/>" +
310
311 "<b>Player</b> = " + String.valueOf(getPlayer()
312 ) + " <br/> " +
313
314 "<b>PlayerId</b> = " + String.valueOf(getPlayerId()
315 ) + " <br/> " +
316
317 "<b>PlayerName</b> = " + String.valueOf(getPlayerName()
318 ) + " <br/> " +
319
320 "<b>ViewTarget</b> = " + String.valueOf(getViewTarget()
321 ) + " <br/> " +
322
323 "<b>Action</b> = " + String.valueOf(getAction()
324 ) + " <br/> " +
325
326 "<b>Key</b> = " + String.valueOf(getKey()
327 ) + " <br/> " +
328
329 "<br/>]";
330 }
331
332 public String toJsonLiteral() {
333 return "KeyEvent(null, "
334
335 + ")";
336 }
337
338
339 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
340
341 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
342
343 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
344
345 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
346
347 }
348