Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/shadows/src/command_node.h @ 4225

Last change on this file since 4225 was 3236, checked in by patrick, 20 years ago

/orxonox/trunk: unstable - problems getting collision to compile

File size: 2.0 KB
Line 
1/*!
2    \file command_node.h
3    \brief Parses keyboard, mouse and remote input
4   
5    Contains methods to parse remote and local input and handles sending of input to remote CommandNodes
6*/
7
8#ifndef _COMMAND_NODE_H
9#define _COMMAND_NODE_H
10
11#include "stdincl.h"
12
13class WorldEntity;
14class World;
15
16#define N_STD_KEYS SDLK_LAST
17#define N_BUTTONS 6
18#define DEFAULT_KEYBIND_FILE "default.ini"
19
20//! Key aliasing structure
21/**
22   This structure contains the key aliasing information, e.g. the command strings that
23   have been bound to the keys.
24*/
25typedef struct
26{
27  char keys[N_STD_KEYS][CMD_LENGHT];
28  char buttons[N_BUTTONS][CMD_LENGHT];
29} KeyBindings;
30
31//! Command Node
32/**
33   This class gathers all incoming SDL_Events and processes them. Keyboard, mouse and joystick input is
34   captured and translated into command messages which are passed down to the bound WorldEntities (via WorldEntity::command()).
35   Other SDL_Events are passed to Orxonox::event_handler() to deal with them. If the CommandNode has been created
36   with bLocalInput set to false, it will query the network class for incoming commands that match his netID and pass
37   them on to it's WorldEntities.
38*/
39class CommandNode {
40 private:
41  bool bLocalInput;     //!< Identifies the CommandNode that processes local input
42  bool bEnabled;
43  int netID;    //!< Unique identifier that is used to determine between remote CommandNodes
44  KeyBindings* aliases;
45  tList<WorldEntity>* bound;    //!< List of WorldEntites that recieve commands from this CommandNode
46  Sint32 coord[2];
47  World* world;
48 
49
50  void relay (Command* cmd);
51  int* nameToIndex (char* name);
52  void processLocal ();
53  void processNetwork ();
54  void sendOverNetwork (Command* cmd);
55 
56 public:
57  CommandNode (int ID);
58  CommandNode (char* filename);
59  ~CommandNode ();
60
61  void reset ();
62  void enable (bool bEnabled);
63  void loadBindings (char* filename);
64  void bind (WorldEntity* entity);
65  void unbind (WorldEntity* entity);
66  void addToWorld (World* world);
67  void process ();
68 
69  void setNetID (int ID);
70};
71
72#endif /* _COMMAND_NODE_H */
Note: See TracBrowser for help on using the repository browser.