Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4866 in orxonox.OLD


Ignore:
Timestamp:
Jul 14, 2005, 10:38:21 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Iniparser is passed on to the EvenetHandler over orxonox

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/event/event_handler.cc

    r4838 r4866  
    6363EventHandler::~EventHandler ()
    6464{
    65   EventHandler::singletonRef = NULL;
    66   delete this->keyMapper;
    67 
    6865  for(int i = 0; i < ES_NUMBER; ++i)
    6966  {
    70     for(int j = 0; j < SDLK_LAST; ++j)
     67    for(int j = 0; j < EV_NUMBER; ++j)
    7168    {
    7269      if( this->listeners[i][j] != NULL)
     
    7673    }
    7774  }
     75  delete this->keyMapper;
     76  EventHandler::singletonRef = NULL;
    7877}
    7978
     
    8483   this has to be called before the use of the event handler
    8584*/
    86 void EventHandler::init()
     85void EventHandler::init(IniParser* iniParser)
    8786{
    8887  this->keyMapper = new KeyMapper();
    89   this->keyMapper->loadKeyBindings();
     88  this->keyMapper->loadKeyBindings(iniParser);
    9089}
    9190
  • orxonox/trunk/src/lib/event/event_handler.h

    r4836 r4866  
    1515class EventListener;
    1616template <class T> class tList;
     17class IniParser;
    1718
    1819//! The one Event Handler from Orxonox
     
    2324  /** @returns a Pointer to the only object of this Class */
    2425  inline static EventHandler* getInstance() { if (!singletonRef) singletonRef = new EventHandler();  return singletonRef; };
    25   void init();
     26  void init(IniParser* iniParser);
    2627
    2728  void setState(elState state);
  • orxonox/trunk/src/lib/event/event_listener.cc

    r4836 r4866  
    3737{
    3838  /* unsubscribes itself from the event listener */
    39   EventHandler::getInstance()->unsubscribe(this);
     39  EventHandler::getInstance()->unsubscribe(this, ES_ALL);
    4040}
  • orxonox/trunk/src/lib/event/key_mapper.cc

    r4864 r4866  
    115115void KeyMapper::loadKeyBindings (const char* fileName)
    116116{
    117   FILE* stream;
    118 
    119   PRINTF(4)("Loading key bindings from %s\n", fileName);
    120 
    121   // create parser
    122117  IniParser parser(fileName);
    123   if( parser.getSection (CONFIG_SECTION_PLAYER "1") == -1)
    124     {
    125       PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1 in %s\n", fileName);
    126       return;
    127     }
     118  this->loadKeyBindings(&parser);
     119}
     120
     121void KeyMapper::loadKeyBindings(IniParser* iniParser)
     122{
     123  if( iniParser->getSection (CONFIG_SECTION_PLAYER "1") == -1)
     124  {
     125    PRINTF(1)("Could not find key bindings " CONFIG_SECTION_PLAYER"1\n");
     126    return;
     127  }
    128128  // allocate empty lookup table
    129129
     
    134134  int* index;
    135135
    136   while( parser.nextVar (namebuf, valuebuf) != -1)
    137     {
    138       PRINTF(3)("Keys: Parsing %s, %s now.\n", namebuf, valuebuf);
    139       index = nameToIndex (valuebuf);
    140       this->mapKeys(namebuf, index[1]);
     136  while( iniParser->nextVar (namebuf, valuebuf) != -1)
     137  {
     138    PRINTF(3)("Keys: Parsing %s, %s now.\n", namebuf, valuebuf);
     139    index = nameToIndex (valuebuf);
     140    this->mapKeys(namebuf, index[1]);
    141141
    142142      /*
    143       switch( index[0])
    144         {
    145         case 0:
    146           this->mapKeys(namebuf, index[1]);
    147           break;
    148         case 1:
    149           this->mapKeys(namebuf, index[1]);
    150           break;
    151         default:
    152           break;
    153         }
     143    switch( index[0])
     144    {
     145    case 0:
     146    this->mapKeys(namebuf, index[1]);
     147    break;
     148    case 1:
     149    this->mapKeys(namebuf, index[1]);
     150    break;
     151    default:
     152    break;
     153  }
    154154      */
    155       memset (namebuf, 0, 256);
    156       memset (valuebuf, 0, 256);
    157     }
     155    memset (namebuf, 0, 256);
     156    memset (valuebuf, 0, 256);
     157  }
    158158
    159159
    160160  // PARSE MISC SECTION
    161   if( parser.getSection (CONFIG_SECTION_MISC_KEYS) == -1)
    162     {
    163       PRINTF(1)("Could not find key bindings in %s\n", fileName);
    164       return;
    165     }
    166 
    167   while( parser.nextVar (namebuf, valuebuf) != -1)
    168     {
    169       PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf);
    170       index = nameToIndex (valuebuf);
    171       this->mapKeys(namebuf, index[1]);
     161  if( iniParser->getSection (CONFIG_SECTION_MISC_KEYS) == -1)
     162  {
     163    PRINTF(1)("Could not find key bindings\n");
     164    return;
     165  }
     166
     167  while( iniParser->nextVar (namebuf, valuebuf) != -1)
     168  {
     169    PRINTF(3)("MISC: Parsing %s, %s now.\n", namebuf, valuebuf);
     170    index = nameToIndex (valuebuf);
     171    this->mapKeys(namebuf, index[1]);
    172172      /*
    173       switch( index[0])
    174         {
    175         case 0:
    176           this->mapKeys(namebuf, index[1]);
    177           break;
    178         case 1:
    179         this->mapKeys(namebuf, index[1]);
    180           break;
    181         default:
    182           break;
    183         }
     173    switch( index[0])
     174    {
     175    case 0:
     176    this->mapKeys(namebuf, index[1]);
     177    break;
     178    case 1:
     179    this->mapKeys(namebuf, index[1]);
     180    break;
     181    default:
     182    break;
     183  }
    184184      */
    185       memset (namebuf, 0, 256);
    186       memset (valuebuf, 0, 256);
    187     }
    188 }
    189 
     185    memset (namebuf, 0, 256);
     186    memset (valuebuf, 0, 256);
     187  }
     188}
    190189
    191190/**
  • orxonox/trunk/src/lib/event/key_mapper.h

    r4836 r4866  
    1 /*! 
     1/*!
    22    \file key_mapper.h
    33  *  a construct to map player defined keys to SDL keys
     
    1212#include "event_def.h"
    1313
     14class IniParser;
    1415
    1516//! A mapping from key-name to key-id
     
    2930
    3031  void loadKeyBindings(const char* fileName = DEFAULT_CONFIG_FILE);
     32  void loadKeyBindings(IniParser* iniParser);
    3133
    3234  void debug();
     
    4143  static int PEV_LEFT;              //!< left button
    4244  static int PEV_RIGHT;             //!< right button
    43  
     45
    4446  static int PEV_STRAFE_LEFT;       //!< strafe left button
    4547  static int PEV_STRAFE_RIGHT;      //!< strafe right button
    46  
     48
    4749  static int PEV_FIRE1;             //!< fire button 1
    4850  static int PEV_FIRE2;             //!< fire button 2
  • orxonox/trunk/src/orxonox.cc

    r4837 r4866  
    4343#include "garbage_collector.h"
    4444
    45 #include "event.h"
    4645#include "factory.h"
    4746#include "benchmark.h"
     
    185184  PRINT(3)("> Initializing input\n");
    186185
    187   EventHandler::getInstance()->init();
     186  EventHandler::getInstance()->init(this->iniParser);
    188187  EventHandler::getInstance()->subscribe(GraphicsEngine::getInstance(), ES_ALL, EV_VIDEO_RESIZE);
    189188
  • orxonox/trunk/src/orxonox.h

    r4836 r4866  
    1111class WorldEntity;
    1212class GameLoader;
    13 class Event;
    1413class IniParser;
    1514
Note: See TracChangeset for help on using the changeset viewer.