Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8148 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 5, 2006, 12:46:02 PM (19 years ago)
Author:
bensch
Message:

trunk: output of EventListener Nicer

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/event/event_def.h

    r7919 r8148  
    4242//! this is an enumeration of all states of the event_handler/game
    4343typedef enum elState
    44   {
    45     ES_NULL         = -1,
    46     ES_GAME         = 0,       //!< the state during the game plays
    47     ES_GAME_MENU    = 1,       //!< state when the menu is called during game
    48     ES_MENU         = 2,       //!< orxonox menu state
    49     ES_SHELL        = 3,       //!< if we are in shell Modus
     44{
     45  ES_NULL         = -1,
     46  ES_GAME         = 0,       //!< the state during the game plays
     47  ES_GAME_MENU    = 1,       //!< state when the menu is called during game
     48  ES_MENU         = 2,       //!< orxonox menu state
     49  ES_SHELL        = 3,       //!< if we are in shell Modus
    5050
    51     ES_ALL          = 4,       //!< you want to register events for all states
     51  ES_ALL          = 4,       //!< you want to register events for all states
    5252
    53     ES_NUMBER       = 5,       //!< the number of states
    54   };
     53  ES_NUMBER       = 5,       //!< the number of states
     54};
     55
     56
    5557
    5658
  • trunk/src/lib/event/event_handler.cc

    r8145 r8148  
    2121#include "event.h"
    2222#include "key_mapper.h"
     23#include "key_names.h"
    2324
    2425#include "compiler.h"
     
    6263EventHandler::~EventHandler ()
    6364{
     65  bool forgotToUnsubscribe = false;
     66
    6467  for(int i = 0; i < ES_NUMBER; ++i)
    6568  {
     
    6871      if(!this->listeners[i][j].empty())
    6972      {
    70         PRINTF(2)("forgot to unsubscribe an EventListener!\n");// %s!\n", this->listeners[i][j]->getName());
     73        if (!forgotToUnsubscribe)
     74        {
     75          forgotToUnsubscribe = true;
     76          PRINTF(2)("forgot to unsubscribe an EventListener!\n");// %s!\n", this->listeners[i][j]->getName());
     77        }
    7178      }
    7279    }
    7380  }
     81
     82  if (forgotToUnsubscribe)
     83  {
     84    PRINTF(2)("Listing still subscribed EventListeners\n");
     85    PRINTF(2)("========================================\n");
     86    this->debug();
     87    PRINTF(2)("========================================\n");
     88  }
     89
    7490  SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
    7591
     
    485501}
    486502
     503
     504/**
     505 * @param state The State to get the Name of.
     506 * @returns the Name of the State.
     507 */
     508const std::string& EventHandler::ELStateToString(elState state)
     509{
     510  if (state < ES_NUMBER)
     511    return EventHandler::stateNames[state];
     512  else
     513    return EventHandler::stateNames[5];
     514}
     515
     516/**
     517 * @param stateName the Name of the State to retrieve.
     518 * @return the State given by the name
     519 */
     520elState EventHandler::StringToELState(const std::string& stateName)
     521{
     522  for (unsigned int i = 0 ; i < ES_NUMBER; i++)
     523    if (stateName == EventHandler::stateNames[i])
     524      return (elState)i;
     525  return ES_NULL;
     526}
     527
     528const std::string  EventHandler::stateNames[] =
     529{
     530  "game",
     531  "game_menu",
     532  "menu",
     533  "shell",
     534  "all",
     535  "unknown",
     536};
     537
     538
    487539/**
    488540 * @brief outputs some nice information about the EventHandler
     
    497549    for(int j = 0; j < EV_NUMBER; ++j)
    498550      for (unsigned int evl = 0; evl < this->listeners[i][j].size(); evl++)
    499         PRINT(0)("Event %d of State %d subscribed to %s (%p)\n", j, i, this->listeners[i][j][evl]->getName(), this->listeners[i][j][evl]);
     551        PRINT(0)("Event %s(%d) of State %s(%d) subscribed to %s (%p)\n",
     552        EVToKeyName(j).c_str(), j,
     553        ELStateToString((elState)i).c_str(), i,
     554        this->listeners[i][j][evl]->getName(), this->listeners[i][j][evl]);
    500555  }
    501556  PRINT(0)("============================EH=\n");
  • trunk/src/lib/event/event_handler.h

    r7919 r8148  
    1919
    2020//! The one Event Handler from Orxonox
    21 class EventHandler : public BaseObject {
     21class EventHandler : public BaseObject
     22{
    2223
    23  public:
     24public:
    2425  virtual ~EventHandler();
    2526  /** @returns a Pointer to the only object of this Class */
     
    2930  void setState(elState state);
    3031  /** @returns the current state */
    31   inline elState getState() const { return this->state; };
     32inline elState getState() const { return this->state; };
    3233
    3334  void pushState(elState state);
     
    5253  void debug() const;
    5354
    54  private:
     55  static const std::string& ELStateToString(elState state);
     56  static elState StringToELState(const std::string& stateName);
     57
     58private:
    5559  EventHandler();
    5660
    5761  bool findListener(std::vector<EventListener*>::iterator* it, elState state, int eventType, EventListener* listener);
    5862
    59  private:
     63public:
     64  static const std::string     stateNames[];
     65
     66private:
    6067  static EventHandler*         singletonRef;                    //!< the singleton reference
    6168
  • trunk/src/lib/event/key_names.h

    r7661 r8148  
    5252std::string SDLKToKeyname( int key);
    5353
     54
    5455#endif /* _KEY_NAMES_H */
  • trunk/src/lib/graphics/graphics_engine.cc

    r7919 r8148  
    414414  this->setResolution(resizeInfo.w, resizeInfo.h, this->bitsPerPixel);
    415415}
    416 
    417 /**
    418416
    419417/**
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8145 r8148  
    131131
    132132    /** @param the Event to process. @returns true if the Event has been consumed*/
    133     virtual bool processEvent(const Event& event) { };
     133    virtual bool processEvent(const Event& event) { return false; };
    134134
    135135  protected:
  • trunk/src/lib/math/vector2D.h

    r8035 r8148  
    7676  inline const Vector2D& operator= (const Vector2D& v) { this->x = v.x; this->y = v.y; return *this; };
    7777  /** copy constructor* @param v the sVec3D to assign to this vector. @returns the vector v */
    78   inline const Vector2D& operator= (const sVec2D& v) { this->x = v[0]; this->y = v[1]; }
     78  inline const Vector2D& operator= (const sVec2D& v) { this->x = v[0]; this->y = v[1]; return *this; }
    7979  /** @param v: the other vector \return the dot product of the vectors */
    8080  float dot (const Vector2D& v) const { return x*v.x+y*v.y; };
    8181  /** @param v multipy each entry with each other @returns this reference */
    82   const Vector2D& internalMultipy(const Vector2D& v) { this->x *= v.x; this->y *= y; };
     82  const Vector2D& internalMultipy(const Vector2D& v) { this->x *= v.x; this->y *= y; return *this; };
    8383  /** scales the this vector with v* @param v the vector to scale this with */
    8484  void scale(const Vector2D& v) {   x *= v.x;  y *= v.y; };
  • trunk/src/lib/particles/quick_animation.h

    r7336 r8148  
    7070    //! compares this->position with position @param position pos to compare, @returns true on match.
    7171    bool operator==(float position) { return this->position == position; };
     72    float            position;          //!< The position of thies KeyFrame
    7273    float            value;             //!< The value of this KeyFrame
    73     float            position;          //!< The position of thies KeyFrame
    7474
    7575    static bool sortPositionPredicate(const QuickKeyFrame& key1, const QuickKeyFrame& key2);
  • trunk/src/lib/util/file.h

    r7661 r8148  
    2828  File(const std::string& fileName);
    2929  File(const File& file);
    30   ~File();
     30  virtual ~File();
    3131  void setFileName(const std::string& fileName);
    3232  File& operator=(const std::string& fileName);
  • trunk/src/lib/util/loading/factory.cc

    r7676 r8148  
    2929 */
    3030Factory::Factory (const std::string& factoryName, ClassID classID)
    31   : className(factoryName), classID(classID)
     31  : classID(classID), className(factoryName)
    3232{
    3333  this->setClassID(CL_FACTORY, "Factory");
  • trunk/src/lib/util/loading/factory.h

    r7221 r8148  
    3636#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
    3737    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
    38 
    39 // #define CREATE_DYNAMIC_FACTORY(CLASS_NAME, CLASS_ID) \
    40 //     tFactory<CLASS_NAME>* global_##CLASS_NAME##_Dynamic_Factory = new DynamicLoader<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
    4138
    4239//! The Factory is a loadable object handler
  • trunk/src/util/state.h

    r7039 r8148  
    4747  static inline SkyBox* getSkyBox() { return State::skyBox; };
    4848  /** @param skyBox the SkyBox */
    49   static inline SkyBox* setSkyBox(SkyBox* skyBox) { State::skyBox = skyBox; };
     49  static inline void setSkyBox(SkyBox* skyBox) { State::skyBox = skyBox; };
    5050
    5151  //////////////////////
Note: See TracChangeset for help on using the changeset viewer.