Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4407 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 31, 2005, 12:04:15 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: event management now runs with new event-handler: no chance to kill current game without killall…

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r4405 r4407  
    964964{
    965965  // localinput
    966   CommandNode* cn = Orxonox::getInstance()->getLocalInput();
    967   cn->process();
     966  //CommandNode* cn = Orxonox::getInstance()->getLocalInput();
     967  //cn->process();
     968
     969  EventHandler::getInstance()->process();
     970
    968971  // remoteinput
    969972}
  • orxonox/trunk/src/util/event/event_handler.cc

    r4406 r4407  
    4747        }
    4848    }
    49 }
     49  this->state = ES_GAME;
     50}
     51
    5052
    5153/**
     
    5355*/
    5456EventHandler* EventHandler::singletonRef = NULL;
     57
    5558
    5659/**
     
    6467}
    6568
     69
    6670/**
    6771   \brief standard deconstructor
     
    7175{
    7276  EventHandler::singletonRef = NULL;
     77  delete this->keyMapper;
     78}
     79
     80
     81
     82void EventHandler::init()
     83{
     84  this->keyMapper = new KeyMapper();
     85  this->keyMapper->loadKeyBindings();
    7386}
    7487
     
    8093}
    8194
     95
    8296void EventHandler::subscribe(EventListener* el, elState state, int eventType)
    8397{
    8498  PRINTF(0)("Subscribing event type: %i\n", eventType);
    85   if( likely(this->listeners[state][eventType] == NULL))
    86     this->listeners[state][eventType] = el;
    87   else
    88     PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state);
     99  if( state == ES_ALL )
     100    {
     101      for(int i = 0; i < ES_NUMBER; ++i)
     102        if( likely(this->listeners[state][eventType] == NULL))
     103          this->listeners[i][eventType] = el;
     104        else
     105          PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state);
     106    }
     107  else
     108    if( likely(this->listeners[state][eventType] == NULL))
     109      {
     110        this->listeners[state][eventType] = el;
     111      }
     112    else
     113      PRINTF(0)("Someone tried to subscribe to event %i @ state %i but this event has already been subscribed\n", eventType, state);
    89114}
    90115
     
    123148  SDL_Event event;
    124149  Event ev;
    125   EventListener* listener;
     150  EventListener* listener = NULL;
    126151  while( SDL_PollEvent (&event))
    127152    {
     
    178203      /* small debug routine: shows alle events dispatched by the event handler */
    179204      PRINT(0)("\n==========================| EventHandler::process () |===\n");
    180       PRINT(0)("=  Got Event nr%i\n, for state %i", event.type, this->state); 
     205      PRINT(0)("=  Got Event nr %i, for state %i", ev.type, this->state); 
    181206     
    182       listener = this->listeners[this->state][event.key.keysym.sym];
     207      listener = this->listeners[this->state][ev.type];
    183208      if( listener != NULL)
    184209        {
     210          PRINTF(0)("=  Event dispatcher msg: This event has been consumed\n");
    185211          listener->process(ev);
    186           PRINTF(0)("=  Event dispatcher msg: This event has been consumed\n");
    187212        }
    188213      else
  • orxonox/trunk/src/util/event/event_handler.h

    r4405 r4407  
    2222  virtual ~EventHandler(void);
    2323
     24  void init();
     25
    2426  void setState(elState state);
    2527
     
    4143  EventListener*** listeners;                         //!< a list of registered listeners
    4244  elState state;
    43 
     45  KeyMapper* keyMapper;
    4446};
    4547
Note: See TracChangeset for help on using the changeset viewer.