Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4817 in orxonox.OLD


Ignore:
Timestamp:
Jul 7, 2005, 5:12:45 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: orxonox is now baseobject, graphicsengine handles events itself and is therefore eventlistener now

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

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

    r4816 r4817  
    6565  EventHandler::singletonRef = NULL;
    6666  delete this->keyMapper;
     67
     68  for(int i = 0; i < ES_NUMBER; ++i)
     69  {
     70    for(int j = 0; j < SDLK_LAST; ++j)
     71    {
     72      if( this->listeners[i][j] != NULL)
     73      {
     74        PRINTF(2)("Someone forgot to unsubscribe an EventListener!\n");
     75      }
     76    }
     77  }
    6778}
    6879
  • orxonox/trunk/src/lib/event/event_listener.cc

    r4457 r4817  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1717
    1818#include "event_listener.h"
     19#include "event_handler.h"
    1920
    2021using namespace std;
     
    2425   \brief standard constructor
    2526*/
    26 EventListener::EventListener () 
     27EventListener::EventListener ()
    2728{
    28    this->setClassID(CL_EVENT_LISTENER, "EventListener"); 
     29   this->setClassID(CL_EVENT_LISTENER, "EventListener");
    2930}
    3031
     
    3435
    3536*/
    36 EventListener::~EventListener ()
    37 {}
     37EventListener::~EventListener ()
     38{
     39  /* unsubscribes itself from the event listener */
     40  EventHandler::getInstance()->unsubscribe(this);
     41}
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r4784 r4817  
    1818#include "graphics_engine.h"
    1919#include "resource_manager.h"
     20#include "event_handler.h"
    2021
    2122#include "debug.h"
     
    4647
    4748//  this->listModes();
     49
     50  // subscribe the resolutionChanged-event
     51  EventHandler::getInstance()->subscribe(this, ES_GAME, EV_VIDEO_RESIZE);
     52
    4853}
    4954
     
    5964{
    6065  // delete what has to be deleted here
     66  EventHandler::getInstance()->unsubscribe(this);
    6167}
    6268
     
    389395
    390396
     397/**
     398  \brief processes the events for orxonox main class
     399  \param the event to handle
     400 */
     401void GraphicsEngine::process(const Event &event)
     402{
     403  switch (event.type)
     404  {
     405    case EV_VIDEO_RESIZE:
     406      this->resolutionChanged(event.resize);
     407      break;
     408  }
     409
     410}
     411
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r4784 r4817  
    55
    66    handles graphical SDL-initialisation, textures, resolutions, and so on
    7 */
     7 */
    88
    99#ifndef _GRAPHICS_ENGINE_H
    1010#define _GRAPHICS_ENGINE_H
    1111
    12 #include "base_object.h"
     12#include "event_listener.h"
    1313
    1414#include "sdlincl.h"
     
    2323   handles graphical SDL-initialisation, textures, resolutions, and so on
    2424 */
    25 class GraphicsEngine : public BaseObject
     25class GraphicsEngine : public EventListener
    2626{
    2727  public:
     
    6464    static void swapBuffers() { SDL_GL_SwapBuffers(); };
    6565
     66    void process(const Event  &event);
    6667
    6768  private:
  • orxonox/trunk/src/orxonox.cc

    r4815 r4817  
    9090  delete ObjectManager::getInstance();
    9191  delete TextEngine::getInstance();
    92   delete EventHandler::getInstance();
    9392  delete Factory::getFirst();
    9493  delete GameLoader::getInstance();
     
    9796  delete CDEngine::getInstance();
    9897  delete GarbageCollector::getInstance();
     98
     99  delete EventHandler::getInstance();
    99100
    100101  ClassList::debug(0);
     
    148149  if( initNetworking () == -1) return -1;
    149150
    150   // subscribe the resolutionChanged-event
    151   EventHandler::getInstance()->subscribe(this, ES_GAME, EV_VIDEO_RESIZE);
    152151  return 0;
    153152}
     
    291290   \param event: an event not handled by the CommandNode
    292291*/
    293 void Orxonox::graphicsHandler(SDL_Event* event)
    294 {
    295   // Handle special events such as reshape, quit, focus changes
    296   switch (event->type)
    297     {
    298     case SDL_VIDEORESIZE:
    299       GraphicsEngine* tmpGEngine = GraphicsEngine::getInstance();
    300       tmpGEngine->resolutionChanged(event->resize);
    301       break;
    302     }
    303 }
    304 
    305 
    306 /**
    307   \brief processes the events for orxonox main class
    308   \param the event to handle
    309 */
    310 void Orxonox::process(const Event &event)
    311 {
    312   switch (event.type)
    313   {
    314     case EV_VIDEO_RESIZE:
    315       GraphicsEngine::getInstance()->resolutionChanged(event.resize);
    316       break;
    317   }
    318 
    319 }
     292// void Orxonox::graphicsHandler(SDL_Event* event)
     293// {
     294//   // Handle special events such as reshape, quit, focus changes
     295//   switch (event->type)
     296//     {
     297//     case SDL_VIDEORESIZE:
     298//       GraphicsEngine* tmpGEngine = GraphicsEngine::getInstance();
     299//       tmpGEngine->resolutionChanged(event->resize);
     300//       break;
     301//     }
     302// }
     303
     304
     305
    320306
    321307
  • orxonox/trunk/src/orxonox.h

    r4768 r4817  
    77#define _ORXONOX_H
    88
    9 #include "event_listener.h"
     9#include "base_object.h"
    1010
    1111class WorldEntity;
     
    2020/**
    2121*/
    22 class Orxonox : public EventListener {
     22class Orxonox : public BaseObject {
    2323
    2424 public:
     
    3131  void start();
    3232
    33   void graphicsHandler (SDL_Event* event);
    34   void process(const Event  &event);
     33  //void graphicsHandler (SDL_Event* event);
    3534
    3635 private:
  • orxonox/trunk/src/util/loading/game_loader.cc

    r4816 r4817  
    5454    delete this->currentCampaign;
    5555  this->currentCampaign = NULL;
     56  this->eventHandler->unsubscribe(this, ES_ALL);
    5657}
    5758
Note: See TracChangeset for help on using the changeset viewer.