Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2735 in orxonox.OLD for orxonox/trunk/gui


Ignore:
Timestamp:
Nov 6, 2004, 3:18:40 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: added keys, and enabled key_press_event on them

Location:
orxonox/trunk/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/gui/orxonox_gui_keys.cc

    r2733 r2735  
    3636  keysBox = new Box ('v');
    3737  player1 = new Player("player1");
    38   player2 = new Player("player2");
    39  
     38  //  player2 = new Player("player2");
     39
    4040  keysBox->fill(player1->getOpenButton());
    41   player1->getOpenButton()->connectSignal("key_press_event", this, key_cb);
    4241
    4342  keysFrame->fill (keysBox);
     
    5958{
    6059  openButton = new Button (player);
     60  openButton->connectSignal("button_press_event", this, openWindowEvent);
     61
     62  keyWindow = new Window("keys of player");
     63
     64  keyBox = new Box('v');
     65  Keys[UP] = new Button("up");
     66  Keys[DOWN] = new Button("down");
     67  Keys[LEFT] = new Button("left");
     68  Keys[RIGHT] = new Button("right");
     69  Keys[SHOOT] = new Button("shoot");
     70
     71  Keys[UP]->connectSignal("key_press_event", Keys[UP], key_cb);
     72  Keys[DOWN]->connectSignal("key_press_event", Keys[DOWN], key_cb);
     73  Keys[LEFT]->connectSignal("key_press_event", Keys[LEFT], key_cb);
     74  Keys[RIGHT]->connectSignal("key_press_event", Keys[RIGHT], key_cb);
     75  Keys[SHOOT]->connectSignal("key_press_event", Keys[SHOOT], key_cb);
     76
     77  keyBox->fill(Keys[UP]);
     78  keyBox->fill(Keys[DOWN]);
     79  keyBox->fill(Keys[LEFT]);
     80  keyBox->fill(Keys[RIGHT]);
     81  keyBox->fill(Keys[SHOOT]);
     82
     83  keyWindow->fill(keyBox);
     84  windowIsOpen = false;
     85
    6186}
    6287
     
    7398}
    7499
    75 gint WindowOpen (GtkWidget* widget, GdkEvent* event, void* player)
    76 {
    77  
    78 }
    79 
    80 
    81 
    82 gint key_cb(GtkWidget* w, GdkEventKey* event, void* widget)
     100/**
     101   \brief function to display, hide the palyer window
     102   Buggy, segmentation fault on WindowMaker
     103*/
     104void Player::openWindow ()
     105{
     106  if (!windowIsOpen)
     107    keyWindow->showall();
     108  else
     109    keyWindow->hide();
     110  windowIsOpen = !windowIsOpen;
     111}
     112
     113gint Player::openWindowEvent (GtkWidget* widget, GdkEvent* event, void* player)
     114{
     115
     116  static_cast<Player*>(player)->openWindow();
     117}
     118
     119
     120/**
     121   \brief Function which gets keystrokes
     122   \param w the widget that released the Function.
     123   \param event The event that happened.
     124   \param Widget the Widget which will be applied.
     125   \returns Nothing
     126*/
     127gint key_cb(GtkWidget* w, GdkEventKey* event, void* Widget)
    83128{
    84129  switch(event->keyval) {
  • orxonox/trunk/gui/orxonox_gui_keys.h

    r2733 r2735  
    1313 * defines the Possible Player Keys
    1414 */
    15 enum KEYS { UP, DOWN, LEFT, RIGTH, SHOOT };
     15enum KEYS { UP, DOWN, LEFT, RIGHT, SHOOT };
    1616
    17 /**
    18    \brief Class to hold infos about a Player
    19 */
     17//! Class to hold infos about a Player
    2018class Player
    2119{
    2220 private:
    23   char keys[10];
     21  Window* keyWindow;
     22  bool windowIsOpen;
    2423  Button* openButton;
    25   Window* window;
    26  
     24
     25
     26  Box* keyBox;
     27  Button* Keys[10];
     28
     29
    2730 public:
    2831  Player(char* player);
    2932
    3033  Button* getOpenButton();
     34 
     35  void openWindow ();
    3136
     37  static gint openWindowEvent(GtkWidget* widget, GdkEvent* event, void* player);
    3238  void setkey(KEYS key);
    3339 
     
    5258
    5359
    54 gint key_cb(GtkWidget* w, GdkEventKey* event, gpointer data);
     60
     61gint key_cb(GtkWidget* w, GdkEventKey* event, void* Widget);
    5562
    5663#endif /* _ORXONOX_GUI_KEYS_H */
Note: See TracChangeset for help on using the changeset viewer.