Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4089 in orxonox.OLD


Ignore:
Timestamp:
May 6, 2005, 5:42:12 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: behaviour as known

Location:
orxonox/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/command_node.cc

    r4085 r4089  
    159159      memset (valuebuf, 0, 256);
    160160    }
     161
     162
     163  // PARSE MISC SECTION
     164  if( parser.getSection ("miscKeys") == -1)
     165    {
     166      PRINTF(1)("Could not find key bindings in %s\n", filename);
     167      return;
     168    }
     169
     170  while( parser.nextVar (namebuf, valuebuf) != -1)
     171    {
     172      index = nameToIndex (valuebuf);
     173      switch( index[0])
     174        {
     175        case 0:
     176          PRINTF(4)("Key binding %d(%s) set to %s\n", index[1], SDLKToKeyname( index[1]), namebuf);
     177          strcpy (aliases->keys[index[1]], namebuf);
     178          break;
     179        case 1:
     180          PRINTF(4)("Button binding %d(%s) set to %s\n", index[1], SDLBToButtonname( index[1]), namebuf);
     181          strcpy (aliases->buttons[index[1]], namebuf);
     182          break;
     183        default:
     184          break;
     185        }
     186      memset (namebuf, 0, 256);
     187      memset (valuebuf, 0, 256);
     188    }
     189
    161190}
    162191
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.cc

    r4083 r4089  
    10511051   \param buttonName sets the Name of the Button
    10521052*/
    1053 Button::Button(char* buttonName)
     1053Button::Button(const char* buttonName)
    10541054{
    10551055  this->optionType = GUI_NOTHING;
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.h

    r4083 r4089  
    263263{
    264264 public:
    265   Button(char* buttonName = NULL);
     265  Button(const char* buttonName = NULL);
    266266  virtual ~Button(void);
    267267
  • orxonox/trunk/src/lib/gui/gui/gui_keys.cc

    r4088 r4089  
    3737  keysFrame = new Frame("Keyboard-Options:");
    3838  {
    39     Box* keysBox;          //!< The Frame that holds the keyOptions.
     39    Box* keysBox0;          //!< The Frame that holds the keyOptions.
    4040   
    4141    //  keysFrame->setGroupName("Keyboard");
    42     keysBox = new Box('h');
     42    keysBox0 = new Box('v');
    4343    {
    44       Player* player1;       //!< The first Player's keys.
    45       Player* player2;       //!< The seconds Player's keys.
    46       Button* misc;          //!< Other keyboeard options come here. \todo include some like pause, quit and so on.
    47      
    48       player1 = new Player("player1");
    49       player2 = new Player("player2");
    50      
    51       keysBox->fill(player1->getOpenButton());
    52       keysBox->fill(player2->getOpenButton());
     44      Box* keysBox1;
     45      MiscKeys* misc;            //!< The Misc Keys
     46
     47      keysBox1 = new Box('h');
     48      {
     49        PlayerKeys* player1;       //!< The first Player's keys.
     50        PlayerKeys* player2;       //!< The seconds Player's keys.
     51       
     52        player1 = new PlayerKeys("player1");
     53        player2 = new PlayerKeys("player2");
     54       
     55        keysBox1->fill(player1->getOpenButton());
     56        keysBox1->fill(player2->getOpenButton());
     57      }
     58      keysBox0->fill(keysBox1);
     59
     60      misc = new MiscKeys();
     61      keysBox0->fill(misc->getOpenButton());
    5362    }
    54     keysFrame->fill(keysBox);
     63    keysFrame->fill(keysBox0);
    5564  }
    5665 
     
    8089long GuiKeys::keySignal = 0;
    8190
    82 
     91////////////
    8392/* PLAYER */
    84 
     93////////////
    8594/**
    8695   \brief Creates new inputs for a player
    8796   \param player the name of the Player
    8897*/
    89 Player::Player(char* player)
     98PlayerKeys::PlayerKeys(char* player)
    9099{
    91100  Window* pKeyWindow;     //!< The Window for a new Key-setting.
     
    95104  strcat(windowName, player);
    96105  pKeyWindow = new Window(windowName);
    97   delete windowName;
    98106  {
    99107    Frame* pKeyFrame;       //!< The Frame for a new Key-setting.
     
    107115
    108116        pKeysBox->setGroupName(player);
    109         pKeysBox->fill(addKey(UP, "up"));
    110         pKeysBox->fill(addKey(DOWN, "down"));
    111         pKeysBox->fill(addKey(LEFT, "left"));
    112         pKeysBox->fill(addKey(RIGHT, "right"));
    113         pKeysBox->fill(addKey(SHOOT, "fire"));
     117        pKeysBox->fill(addKey("up", "UP"));
     118        pKeysBox->fill(addKey("down", "DOWN"));
     119        pKeysBox->fill(addKey("left", "LEFT"));
     120        pKeysBox->fill(addKey("right", "RIGHT"));
     121        pKeysBox->fill(addKey("fire", "SPACE"));
    114122        closeButton = new Button("close");
    115123#ifdef HAVE_GTK2
     
    123131    pKeyWindow->fill(pKeyFrame);
    124132  }
     133  delete windowName;
    125134  Window::addWindow(pKeyWindow);
    126135#ifdef HAVE_GTK2
     
    138147   \returns the OpenButton of a Player
    139148*/
    140 Button* Player::getOpenButton(void)
     149Button* PlayerKeys::getOpenButton(void)
    141150{
    142151  return this->openButton;
    143152}
    144153
    145 /**
    146    \brief sets a new Key(only output)
    147    \param key the new Key.
    148 */
    149 void Player::setkey(KEYS key)
    150 {
    151   PRINT(4)("setting up Key: %d\n", key);
    152 }
     154//////////////////
     155/* MISC_OPTIONS */
     156//////////////////
     157/**
     158   \brief Creates new inputs for a misc
     159   \param player the name of the Misc
     160*/
     161MiscKeys::MiscKeys()
     162{
     163  Window* keyWindow;     //!< The Window for a new Key-setting.
     164
     165  keyWindow = new Window("misc Keys");
     166  {
     167    Frame* keyFrame;       //!< The Frame for a new Key-setting.
     168
     169    keyFrame = new Frame("misc Keys:");
     170    {
     171      Box* keysBox;          //!< The Box that holds the Key-settings.
     172      keysBox = new Box('v');
     173      {
     174        Button* closeButton;    //!< The CloseButton for this key-settings.
     175
     176        keysBox->setGroupName("miscKeys");
     177        keysBox->fill(addKey( "quit", "ESCAPE"));
     178        keysBox->fill(addKey("pause", "PAUSE"));
     179        keysBox->fill(addKey("up_world", "x"));
     180        keysBox->fill(addKey("down_world", "z"));
     181        keysBox->fill(addKey("view0", "1"));
     182        keysBox->fill(addKey("view1", "2"));
     183        keysBox->fill(addKey("view2", "3"));
     184        keysBox->fill(addKey("view3", "4"));
     185        keysBox->fill(addKey("view4", "5"));
     186        keysBox->fill(addKey("view5", "6"));
     187
     188        closeButton = new Button("close");
     189#ifdef HAVE_GTK2
     190        closeButton->connectSignal("button_press_event", keyWindow, Window::windowClose);
     191#endif /* HAVE_GTK2 */
     192
     193        keysBox->fill(closeButton);
     194      }
     195      keyFrame->fill(keysBox);
     196    }
     197    keyWindow->fill(keyFrame);
     198  }
     199  Window::addWindow(keyWindow);
     200#ifdef HAVE_GTK2
     201  keyWindow->connectSignal("destroy", keyWindow, Window::windowClose);
     202  keyWindow->connectSignal("delete_event", keyWindow, Window::windowClose);
     203#endif /* HAVE_GTK2 */
     204 
     205  this->openButton = new Button("misc");
     206#ifdef HAVE_GTK2
     207  this->openButton->connectSignal("button_press_event", keyWindow, Window::windowOpen);
     208#endif /* HAVE_GTK2 */
     209}
     210
     211/**
     212   \returns the OpenButton of a Misc
     213*/
     214Button* MiscKeys::getOpenButton(void)
     215{
     216  return this->openButton;
     217}
     218
    153219
    154220/**
     
    158224   \returns A widget that has the Key-Box
    159225*/
    160 Widget* addKey(KEYS key, char* name)
     226Widget* addKey(const char* name, const char* defaultVal)
    161227{
    162228  InputKey* inputKey = new InputKey;
    163   inputKey->pKeyBox = new Box();
    164   inputKey->pKeyButton = new Button(name);
    165   inputKey->pKeyOLabel = new OptionLabel(name, name);
    166   inputKey->pKeyOLabel->saveability();
    167 
    168 #ifdef HAVE_GTK2
    169   //inputKey->pKeyButton->connectSignal("key_press_event", inputKey->pKeyButton, key_cb);
    170   inputKey->pKeyButton->connectSignal("button_press_event", inputKey, inputWindowEvent);
    171 #endif /* HAVE_GTK2 */
    172   inputKey->pKeyBox->fill(inputKey->pKeyButton);
    173   inputKey->pKeyBox->fill(inputKey->pKeyOLabel);
    174   return inputKey->pKeyBox;
     229  inputKey->keyBox = new Box();
     230  inputKey->keyButton = new Button(name);
     231  if (defaultVal)
     232    inputKey->keyOLabel = new OptionLabel(name, defaultVal);
     233  else
     234    inputKey->keyOLabel = new OptionLabel(name, name);
     235  inputKey->keyOLabel->saveability();
     236
     237#ifdef HAVE_GTK2
     238  //inputKey->keyButton->connectSignal("key_press_event", inputKey->keyButton, key_cb);
     239  inputKey->keyButton->connectSignal("button_press_event", inputKey, inputWindowEvent);
     240#endif /* HAVE_GTK2 */
     241  inputKey->keyBox->fill(inputKey->keyButton);
     242  inputKey->keyBox->fill(inputKey->keyOLabel);
     243  return inputKey->keyBox;
    175244}
    176245
     
    194263{
    195264  InputKey* inputkey =(InputKey*) inputKey;
    196   char title [20];
    197 
    198   switch(event->keyval) 
     265  char title [50];
     266
     267  switch(event->keyval)
    199268    {
    200269    case GDK_Up:
     
    362431    }
    363432
    364   inputkey->pKeyOLabel->setValue(title);
     433  inputkey->keyOLabel->setValue(title);
    365434  GuiKeys::inputButton->disconnectSignal(GuiKeys::keySignal);
    366435  GuiKeys::inputWindow->close();
  • orxonox/trunk/src/lib/gui/gui/gui_keys.h

    r4088 r4089  
    1515#endif /* HAVE_GTK2 */
    1616
    17 /**
    18    \brief defines the Possible Player Keys
    19 */
    20 enum KEYS {UP, DOWN, LEFT, RIGHT, SHOOT};
    21 
    2217//! One KeyOption has one InputKey
    2318struct InputKey
    2419{
    25   Box* pKeyBox;           //!< One Box that holds the Keys
    26   Button* pKeyButton;     //!< The Button for changing the Key.
    27   OptionLabel* pKeyOLabel;//!< The Label for displaying the Key-setting.
     20  Box* keyBox;           //!< One Box that holds the Keys
     21  Button* keyButton;     //!< The Button for changing the Key.
     22  OptionLabel* keyOLabel;//!< The Label for displaying the Key-setting.
    2823};
    2924
     
    4136
    4237//! Class to hold infos about a Player
    43 class Player
     38class PlayerKeys
    4439{
    4540 private:
     
    4742
    4843 public:
    49   Player(char* player);
    50 
     44  PlayerKeys(char* player);
    5145
    5246  Button* getOpenButton(void);
    53 
    54   void setkey(KEYS key);
    55  
    5647};
    5748
    58 Widget* addKey(KEYS key, char* name);
     49class MiscKeys
     50{
     51 private:
     52  Button* openButton;     //!< The OpenButton for this key-settings.
     53
     54 public:
     55  MiscKeys();
     56
     57  Button* getOpenButton(void); 
     58};
     59
     60Widget* addKey(const char* name, const char* defaultValue = NULL);
    5961#ifdef HAVE_GTK2
    6062gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget);
Note: See TracChangeset for help on using the changeset viewer.