Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7919 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
May 28, 2006, 3:48:13 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the gui branche back
merged with command:
https://svn.orxonox.net/orxonox/branches/gui
no conflicts

Location:
trunk/src
Files:
47 edited
7 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/class_id.h

    r7836 r7919  
    325325  CL_GLGUI_CHECKBUTTON          =    0x00000b04,
    326326  CL_GLGUI_RADIOBUTTON          =    0x00000b05,
     327  CL_GLGUI_SLIDER               =    0x00000b06,
     328  CL_GLGUI_PROGRESSBAR          =    0x00000b07,
    327329  CL_GLGUI_CONTAINER            =    0x00b04000,
    328   CL_GLGUI_BOX                  =    0x00000b07,
    329   CL_GLGUI_FRAME                =    0x00000b08,
    330   CL_GLGUI_WINDOW               =    0x00000b09,
     330  CL_GLGUI_BOX                  =    0x00000b17,
     331  CL_GLGUI_FRAME                =    0x00000b18,
     332  CL_GLGUI_WINDOW               =    0x00000b19,
    331333  CL_GLMENU_IMAGE_SCREEN        =    0x00000b20,
    332334  CL_GLGUI_BAR                  =    0x00000b30,
     335  CL_GLGUI_CURSOR               =    0x00000b50,
     336  CL_GLGUI_INPUTLINE            =    0x00000b60,
     337  CL_GLGUI_TEXTFIELD            =    0x00000b61,
    333338
    334339  // QT_GUI
  • trunk/src/lib/Makefile.am

    r7819 r7919  
    2828                util/file.cc \
    2929                util/directory.cc \
     30                util/timer.cc \
    3031                \
    3132                data/data_tank.cc
     
    4950                util/file.h \
    5051                util/directory.h \
     52                util/timer.h \
    5153                \
    5254                util/loading/resource_manager.h \
  • trunk/src/lib/event/event_def.h

    r7868 r7919  
    2828  EV_JOY_BUTTON,
    2929
     30  EV_WINDOW_FOCUS,
    3031  EV_VIDEO_RESIZE,
    3132
     33  EV_LEAVE_STATE,
    3234  EV_MAIN_QUIT,
    3335
  • trunk/src/lib/event/event_handler.cc

    r7868 r7919  
    2929
    3030/**
    31  * standard constructor
    32 */
     31 * @brief standard constructor
     32 */
    3333EventHandler::EventHandler ()
    3434{
     
    4242
    4343  /* now initialize them all to zero */
    44   this->withUNICODE(false);
     44  for (unsigned int i = 0; i < ES_NUMBER; i++)
     45    this->bUNICODE[i] = false;
    4546  this->grabEvents(false);
    4647
     
    5152
    5253/**
    53  * the singleton reference to this class
     54 * @brief the singleton reference to this class
    5455*/
    5556EventHandler* EventHandler::singletonRef = NULL;
     
    5758
    5859/**
    59  *  standard deconstructor
    60 
    61 */
     60 * @brief standard deconstructor
     61 */
    6262EventHandler::~EventHandler ()
    6363{
     
    7979
    8080/**
    81  * initializes the event handler
     81 * @brief initializes the event handler
    8282 *
    8383 * this has to be called before the use of the event handler
     
    8989
    9090/**
    91  * pushes the current State in the State-stack, and selects state
     91 * @param state: to which the event handler shall change
     92 */
     93void EventHandler::setState(elState state)
     94{
     95  if (state == this->state)
     96    return;
     97
     98  /// When Changing the State, all the keys will be released.
     99  /// This is done by sending each eventListener, that still
     100  /// has an Event subscribed, a Release Event.
     101  int keyCount;
     102  Uint8 * pressedKeys = SDL_GetKeyState(&keyCount);
     103  for (unsigned int i = 0; i < SDLK_LAST; i++)
     104  {
     105    if (pressedKeys[i])
     106    {
     107      Event ev;
     108      ev.bPressed = false;
     109      ev.type = i;
     110      if (unlikely(this->bUNICODE[this->state]))
     111        ev.x = i;
     112      this->dispachEvent(this->state, ev );
     113    }
     114  }
     115
     116  // switching to the new State.
     117  elState oldState = this->state;
     118  this->state = state;
     119
     120  // in the End the Corresponding handler will be notified.
     121  Event stateSwitchEvent;
     122  stateSwitchEvent.type = EV_LEAVE_STATE;
     123  this->dispachEvent(oldState, stateSwitchEvent);
     124
     125  SDL_EnableUNICODE(this->bUNICODE[state]);
     126};
     127
     128
     129/**
     130 * @brief pushes the current State in the State-stack, and selects state
    92131 * @param state the new State to set
    93132 */
     
    106145
    107146/**
    108  * this removes the topmost stack-entry and select the underlying one
     147 * @brief this removes the topmost stack-entry and select the underlying one
    109148 * @returns the next stack-entry
    110149 */
     
    144183  {
    145184    for(unsigned int i = 0; i < ES_NUMBER; i++)
    146     {
    147       if( !likely(this->listeners[i][eventType].empty()))
     185      if (!this->findListener( NULL, (elState)i, eventType, el))
     186        this->listeners[i][eventType].push_back(el);
     187      else
    148188      {
    149         PRINTF(2)("'%s' of class '%s' tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
     189        PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), i, eventType);
    150190      }
    151       this->listeners[i][eventType].push_back(el);
    152     }
    153   }
    154   else
    155   {
    156     if( likely(!this->listeners[state][eventType].empty()))
    157     {
    158       PRINTF(2)("%s of class %s tried to subscribe to event %i @ state %i but this event has already been subscribed\n", el->getName(), el->getClassName(), eventType, state);
    159     }
    160     this->listeners[state][eventType].push_back(el);
     191  }
     192  else
     193  {
     194    if (!this->findListener( NULL, state, eventType, el))
     195      this->listeners[state][eventType].push_back(el);
     196    else
     197    {
     198      PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), state, eventType);
     199    }
    161200  }
    162201}
     
    167206 * @param state: the stat in which it has been subscribed
    168207 * @param eventType: the event, that shall be unsubscribed
    169 
    170    if you want to unsubscribe an event listener from all subscribed events, just use the
    171    unsubscribe(EventListener* el, elState state) function
    172 */
     208 *
     209 * if you want to unsubscribe an event listener from all subscribed events, just use the
     210 * unsubscribe(EventListener* el, elState state) function
     211 */
    173212void EventHandler::unsubscribe(EventListener* el, elState state, int eventType)
    174213{
     
    177216    for (unsigned int i = 0; i < ES_NUMBER; i++)
    178217    {
    179       std::vector<EventListener*>::iterator listener =
    180          std::find(this->listeners[i][eventType].begin(),
    181                    this->listeners[i][eventType].end(),
    182                    el);
    183       if (listener != this->listeners[i][eventType].end())
     218      std::vector<EventListener*>::iterator listener;
     219      if (this->findListener(&listener, (elState)i, eventType, el))
    184220        this->listeners[i][eventType].erase(listener);
    185221    }
    186222  else
    187223  {
    188     std::vector<EventListener*>::iterator listener =
    189         std::find(this->listeners[state][eventType].begin(),
    190                   this->listeners[state][eventType].end(),
    191                   el);
    192     if (listener != this->listeners[state][eventType].end())
     224    std::vector<EventListener*>::iterator listener;
     225    if (this->findListener(&listener, state, eventType, el))
    193226      this->listeners[state][eventType].erase(listener);
    194227  }
     
    203236void EventHandler::unsubscribe(EventListener* el, elState state)
    204237{
    205   if( el == NULL || state >= ES_NUMBER)
    206     return;
     238  assert( el != NULL && state < ES_NUMBER);
    207239  if( state == ES_ALL)
    208240  {
     
    228260}
    229261
     262/**
     263 * @brief returns true if at state and eventType there is something subscribed.
     264 * @param state the state to check in.
     265 * @param eventType the eventtype to check.
     266 * @returns true if a event is subscibed.
     267 */
    230268bool EventHandler::isSubscribed(elState state, int eventType)
    231269{
     
    236274
    237275/**
    238  * flush all registered events
     276 * @brief flush all registered events
    239277 * @param state: a specific state
    240278*/
     
    261299
    262300
    263 void EventHandler::withUNICODE(bool enableUNICODE)
    264 {
    265   SDL_EnableUNICODE(enableUNICODE);
    266   this->bUNICODE = enableUNICODE;
    267 }
    268 
     301bool EventHandler::findListener(std::vector<EventListener*>::iterator* it, elState state, int eventType, EventListener* listener)
     302{
     303  std::vector<EventListener*>::iterator findIterator =
     304    std::find(this->listeners[state][eventType].begin(), this->listeners[state][eventType].end(), listener);
     305  if (it != NULL)
     306    *it = findIterator;
     307  return ( findIterator != this->listeners[state][eventType].end());
     308
     309}
     310
     311
     312
     313/**
     314 * @brief if the unicode characters should be recorded.
     315 * @param state the State in whitch to set the new Value.
     316 * @param enableUNICODE: enabled, or disabled.
     317 */
     318void EventHandler::withUNICODE(elState state, bool enableUNICODE)
     319{
     320  this->bUNICODE[state] = enableUNICODE;
     321  if (this->state == state)
     322    SDL_EnableUNICODE(enableUNICODE);
     323}
     324
     325/**
     326 * @brief grabs InputEvents.
     327 * @param grabEvents if the Events should be grabbed(true) or released(false)
     328 */
    269329void EventHandler::grabEvents(bool grabEvents)
    270330{
     
    282342}
    283343
    284 /**
    285  *  core function of event handler: receives all events from SDL
    286 
    287    The event from the SDL framework are collected here and distributed to all listeners.
    288 */
    289 void EventHandler::process()
     344
     345
     346/**
     347 * @brief core function of event handler: receives all events from SDL
     348 *
     349 * The event from the SDL framework are collected here and distributed to all listeners.
     350 */
     351void EventHandler::process() const
    290352{
    291353  SDL_Event event;
     
    299361        ev.bPressed = true;
    300362        ev.type = event.key.keysym.sym;
    301         if (unlikely(this->bUNICODE))
     363        if (unlikely(this->bUNICODE[this->state]))
    302364          ev.x = event.key.keysym.unicode;
    303365        break;
     
    305367        ev.bPressed = false;
    306368        ev.type = event.key.keysym.sym;
    307         if (unlikely(this->bUNICODE))
     369        if (unlikely(this->bUNICODE[this->state]))
    308370          ev.x = event.key.keysym.unicode;
    309371        break;
     
    344406        ev.type = EV_JOY_BUTTON;
    345407        break;
     408      case SDL_ACTIVEEVENT:
     409        ev.type = EV_WINDOW_FOCUS;
     410        ev.bPressed = (event.active.gain != 0);
     411        break;
    346412      case SDL_VIDEORESIZE:
    347413        ev.resize = event.resize;
     
    355421        break;
    356422    }
    357 
    358     /* small debug routine: shows all events dispatched by the event handler */
    359     PRINT(4)("\n==========================| EventHandler::process () |===\n");
    360     PRINT(4)("=  Got Event nr %i, for state %i", ev.type, this->state);
    361 
    362 
    363     for (unsigned int i = 0; i < this->listeners[this->state][ev.type].size(); i++)
    364     {
    365       PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
    366       PRINT(4)("=======================================================\n");
    367       listeners[this->state][ev.type][i]->process(ev);
    368     }
    369     /*    else
    370         {
    371           PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
    372           PRINT(4)("=======================================================\n");
    373         }*/
    374   }
    375 }
    376 
    377 
     423    this->dispachEvent(this->state, ev);
     424  }
     425}
     426
     427
     428/**
     429 * @brief dispaches an Event.
     430 * @param event the Event to dispach.
     431 */
     432void EventHandler::dispachEvent(elState state, const Event& event) const
     433{
     434  /* small debug routine: shows all events dispatched by the event handler */
     435  PRINT(4)("\n==========================| EventHandler::process () |===\n");
     436  PRINT(4)("=  Got Event nr %i, for state %i\n", event.type, state);
     437
     438  /// setting a temporary state in case of an EventListener's process changes the state.
     439  for (unsigned int i = 0; i < this->listeners[state][event.type].size(); i++)
     440  {
     441    PRINT(4)("=  Event dispatcher msg: This event has been consumed\n");
     442    PRINT(4)("=  Got Event nr %i, for state %i (%d registered) to %s::%s(%p)\n", event.type, i, state, this->listeners[state][event.type][i]->getClassName(), this->listeners[state][event.type][i]->getName(), this->listeners[state][event.type][i]);
     443    PRINT(4)("=======================================================\n");
     444    this->listeners[state][event.type][i]->process(event);
     445  }
     446  /*    else
     447  {
     448        PRINT(4)("=  Event dispatcher msg: This event has NOT been consumed\n");
     449        PRINT(4)("=======================================================\n");
     450  }*/
     451}
     452
     453
     454
     455/**
     456 * @brief An eventFilter.
     457 * @param event the Event to be filtered.
     458 * @returns 0 on filtered Event. 1 Otherwise.
     459 */
    378460int EventHandler::eventFilter(const SDL_Event *event)
    379461{
     
    400482
    401483/**
    402  * outputs some nice information about the EventHandler
     484 * @brief outputs some nice information about the EventHandler
    403485 */
    404486void EventHandler::debug() const
     
    408490  PRINT(0)("===============================\n");
    409491  for(int i = 0; i < ES_NUMBER; ++i)
     492  {
    410493    for(int j = 0; j < EV_NUMBER; ++j)
    411494      for (unsigned int evl = 0; evl < this->listeners[i][j].size(); evl++)
    412495        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]);
     496  }
    413497  PRINT(0)("============================EH=\n");
    414498}
  • trunk/src/lib/event/event_handler.h

    r7868 r7919  
    1111#include "key_mapper.h"
    1212#include "event_def.h"
     13#include "event.h"
    1314#include <stack>
    1415#include <vector>
     
    2627  void init();
    2728
    28   /** @param state: to which the event handler shall change */
    29   inline void setState(elState state) { this->state = state; };
     29  void setState(elState state);
    3030  /** @returns the current state */
    3131  inline elState getState() const { return this->state; };
     
    4242
    4343
    44   void withUNICODE(bool enableUNICODE);
     44  void withUNICODE(elState state, bool enableUNICODE);
    4545  void grabEvents(bool grabEvents);
    4646  bool grabbedEvents() const { return this->eventsGrabbed; };
    4747
    48   void process();
     48  void process() const;
     49  void dispachEvent(elState state, const Event& event) const;
    4950
    5051  static int eventFilter(const SDL_Event *event);
     
    5354 private:
    5455  EventHandler();
     56
     57  bool findListener(std::vector<EventListener*>::iterator* it, elState state, int eventType, EventListener* listener);
    5558
    5659 private:
     
    6265  KeyMapper                    keyMapper;                       //!< reference to the key mapper.
    6366
    64   bool                         bUNICODE;                        //!< If unicode should be enabled.
     67  bool                         bUNICODE[ES_NUMBER];             //!< If unicode should be enabled.
    6568  bool                         eventsGrabbed;                   //!< If the events should be grabbed
    6669};
  • trunk/src/lib/graphics/graphics_engine.cc

    r7871 r7919  
    286286  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);   //Use at least 16 bits for the depth buffer
    287287  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);  //Enable double buffering
     288
     289  glEnable(GL_CULL_FACE);
     290  glCullFace(GL_FRONT);
    288291}
    289292
     
    576579void GraphicsEngine::drawBackgroundElements() const
    577580{
     581  GraphicsEngine::storeMatrices();
     582
    578583  Render2D::getInstance()->draw(E2D_LAYER_BELOW_ALL, E2D_LAYER_BELOW_ALL);
    579584}
  • trunk/src/lib/graphics/importer/material.cc

    r7848 r7919  
    108108      return true;
    109109
    110 
    111   // setting diffuse color
     110  if (likely(Material::selectedMaterial != NULL))
     111  {
     112    for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     113    {
     114        glActiveTexture(Material::glTextureArbs[i]);
     115        //glBindTexture(GL_TEXTURE_2D, 0);
     116        glDisable(GL_TEXTURE_2D);
     117    }
     118  }
     119
     120    // setting diffuse color
    112121  glColor4f (diffuse[0], diffuse[1], diffuse[2], this->transparency);
    113122  // setting ambient color
     
    118127  glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
    119128
    120 
    121129  // setting the transparency
    122130  if (this->transparency < 1.0 ||       /* This allows alpha blending of 2D textures with the scene */
     
    138146    glShadeModel(GL_SMOOTH);
    139147
    140   if (likely(Material::selectedMaterial != NULL))
    141   {
    142     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
    143     {
    144         glActiveTexture(Material::glTextureArbs[i]);
    145         glBindTexture(GL_TEXTURE_2D, 0);
    146         glDisable(GL_TEXTURE_2D);
    147     }
    148   }
    149148
    150149  for(unsigned int i = 0; i < this->textures.size(); ++i)
     
    159158  }
    160159  Material::selectedMaterial = this;
    161 
    162   /*  if (this->diffuseTexture != NULL)
    163       {
    164         glEnable(GL_TEXTURE_2D);
    165         glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
    166       }
    167     else
    168       {
    169         glDisable(GL_TEXTURE_2D);
    170         glBindTexture(GL_TEXTURE_2D, 0);
    171       }*/
    172160}
    173161
  • trunk/src/lib/graphics/importer/material.h

    r7788 r7919  
    1616
    1717#include <vector>
    18 #include "SDL_image.h"
    19 
    2018#include "texture.h"
    2119
     
    5149    void setTransparency (char* trans);
    5250
     51    void getDiffuseColor(float& r, float& g, float& b) const { r = diffuse[0], g = diffuse[1], b = diffuse[2]; }
    5352
    5453    // MAPPING //
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r7871 r7919  
    6262  this->toCoordinate = NULL;
    6363  this->toDirection = NULL;
     64
     65  this->size = Vector2D(0,0);
    6466  this->toSize = NULL;
    65   this->setSize2D(1, 1);
    6667
    6768
     
    448449  this->relCoordinate += shift;
    449450  this->bRelCoorChanged = true;
    450 
    451451}
    452452
     
    847847    if (unlikely(this->toSize != NULL))
    848848    {
    849       Vector2D shiftSize = (*this->toSize - Vector2D(this->sizeX, this->sizeY)) *fabsf(dt)*bias;
     849      Vector2D shiftSize = (*this->toSize - this->size) *fabsf(dt)*bias;
    850850      if (likely((shiftSize).len() >= .001))//PNODE_ITERATION_DELTA))
    851851      {
    852         this->sizeX += shiftSize.x;
    853         this->sizeY += shiftSize.y;
     852        this->size += shiftSize;
    854853      }
    855854      else
     
    11091108  if (level == 0)
    11101109    glPopAttrib();
    1111 
    11121110}
    11131111
  • trunk/src/lib/graphics/render2D/element_2d.h

    r7843 r7919  
    125125    inline const PNode* getBindNode() const { return this->bindNode; };
    126126
    127     inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; };
     127    inline void setSize2D(float x, float y) { this->size = Vector2D(x, y); };
     128    inline void setSize2D(const Vector2D& size) { this->size = size; };
     129    inline const Vector2D& getSize2D() const { return this->size; };
    128130    void setSizeSoft2D(float x, float y, float bias = 1.0);
    129     inline void setSizeX2D(float x) { this->sizeX = x; };
    130     inline void setSizeY2D(float y) { this->sizeY = y; };
    131     inline float getSizeX2D() const { return this->sizeX; };
    132     inline float getSizeY2D() const { return this->sizeY; };
     131    inline void setSizeX2D(float x) { this->size.x = x; };
     132    inline void setSizeY2D(float y) { this->size.y = y; };
     133    inline float getSizeX2D() const { return this->size.x; };
     134    inline float getSizeY2D() const { return this->size.y; };
    133135
    134136  public:
     
    238240  private:
    239241    const PNode*            bindNode;           //!< a node over which to display this 2D-element
    240     float                   sizeX;              //!< The size of the rendered item in x-direction
    241     float                   sizeY;              //!< The size of the rendered Item in y-direction
     242    Vector2D                size;               //!< The size of the rendered item
    242243    Vector2D*               toSize;             //!< The Size to iterate to.
    243244
  • trunk/src/lib/graphics/text_engine/multi_line_text.cc

    r7758 r7919  
    6464    return;
    6565  glPushMatrix();
     66  glPushAttrib(GL_ENABLE_BIT);
    6667  // transform for alignment.
    6768  // TODO make the Stuff with the alignment
     
    117118  }
    118119  glEnd();
     120  glPopAttrib();
    119121  glPopMatrix();
    120122}
  • trunk/src/lib/graphics/text_engine/text.cc

    r7753 r7919  
    3636  this->font = NULL;
    3737  this->size = textSize;
     38  this->setSizeY2D(size);
    3839  this->blending = TEXT_DEFAULT_BLENDING;
    3940  this->color = TEXT_DEFAULT_COLOR;
     
    127128
    128129/**
     130 * @brief appends one Character to the String.
     131 */
     132void Text::appendCharacter(char character)
     133{
     134  this->text += character;
     135  this->setupTextWidth();
     136}
     137
     138
     139/**
    129140 * @brief append some text to the already existing Text.
    130141 * @param appendText The text to append to this Text.
     
    135146  return this->text;
    136147}
     148
     149/**
     150 * @brief removes char characters from the Text.
     151 *
     152 * @note this function checks, if the count can be removed, and if so does it.
     153 * Otherwise the maximum count of characters will be removed.
     154 */
     155void Text::removeCharacters(unsigned int chars)
     156{
     157  if (text.size() > chars)
     158    this->text.resize(this->text.size()-chars);
     159  else if (!text.empty())
     160    text.clear();
     161  this->setupTextWidth();
     162}
     163
    137164
    138165/**
     
    188215    return;
    189216  glPushMatrix();
     217  glPushAttrib(GL_ENABLE_BIT);
    190218  // transform for alignment.
    191219  if (this->getAlignment() == TEXT_ALIGN_RIGHT)
     
    229257  }
    230258  glEnd();
     259  glPopAttrib();
    231260  glPopMatrix();
    232261}
     
    242271    if(this->font->getGlyphArray()[this->text[i]] != NULL)
    243272      width += this->font->getGlyphArray()[this->text[i]]->advance;
    244   this->setSizeX2D(width *this->getSize());
     273  this->setSizeX2D(width * this->getSize());
    245274}
    246275
  • trunk/src/lib/graphics/text_engine/text.h

    r7753 r7919  
    3737    void setText(const std::string& text);
    3838    void append(const std::string& appendText);
     39    void appendCharacter(char character);
    3940    const std::string& operator<<(const std::string& appendText);
     41    void removeCharacters(unsigned int chars);
    4042
    4143    /// SETUP
  • trunk/src/lib/gui/gl_gui/Makefile.am

    r7855 r7919  
    99
    1010
    11 libORXglgui_a_SOURCES = glmenu/glmenu_imagescreen.cc \
    12                         glgui_handler.cc \
    13                         signal_connector.cc \
    14                         glgui_mainwidget.cc \
    15                         glgui_widget.cc \
    16                         glgui_button.cc \
    17                         glgui_pushbutton.cc \
    18                         glgui_container.cc \
    19                         glgui_bar.cc \
    20                         glgui_box.cc \
    21                         glgui_frame.cc \
    22                         glgui_window.cc
     11libORXglgui_a_SOURCES = \
     12                glmenu/glmenu_imagescreen.cc \
     13                glgui_handler.cc \
     14                signal_connector.cc \
     15                glgui_mainwidget.cc \
     16                glgui_widget.cc \
     17                glgui_button.cc \
     18                glgui_pushbutton.cc \
     19                glgui_checkbutton.cc \
     20                glgui_slider.cc \
     21                glgui_container.cc \
     22                glgui_bar.cc \
     23                glgui_box.cc \
     24                glgui_frame.cc \
     25                glgui_inputline.cc \
     26                glgui_textfield.cc \
     27                glgui_window.cc \
     28                glgui_cursor.cc
    2329
    2430
    25 noinst_HEADERS= glmenu/glmenu_imagescreen.h \
     31noinst_HEADERS= \
     32                glmenu/glmenu_imagescreen.h \
    2633                signal_connector.h \
    2734                glgui.h \
     35                glgui_defs.h \
    2836                glgui_handler.h \
    2937                glgui_mainwidget.h \
     
    3139                glgui_button.h \
    3240                glgui_pushbutton.h \
     41                glgui_checkbutton.h \
     42                glgui_slider.h \
    3343                glgui_container.h \
    3444                glgui_bar.h \
    3545                glgui_box.h \
    3646                glgui_frame.h \
    37                 glgui_window.h
     47                glgui_inputline.h \
     48                glgui_textfield.h \
     49                glgui_window.h \
     50                glgui_cursor.h
    3851
    3952
  • trunk/src/lib/gui/gl_gui/glgui.h

    r7855 r7919  
    66#ifndef _GLGUI_H
    77#define _GLGUI_H
     8
     9#include "glgui_handler.h"
     10
    811#include "glgui_widget.h"
    912
     
    1215#include "glgui_button.h"
    1316#include "glgui_checkbutton.h"
    14 #include "glgui_colorselector.h"
    15 
    16 namespace OrxGui
    17 {
     17//#include "glgui_colorselector.h"
     18#include "glgui_pushbutton.h"
     19#include "glgui_cursor.h"
     20#include "glgui_inputline.h"
     21#include "glgui_textfield.h"
    1822
    1923
    20 };
    21 
    22 
    23 
    24 
    25 
    26 #endif _GLGUI_H
     24#endif /* _GLGUI_H */
  • trunk/src/lib/gui/gl_gui/glgui_bar.cc

    r7779 r7919  
    4646    this->setClassID(CL_GLGUI_BAR, "GLGuiBar");
    4747
    48     this->frontMat.setDiffuse(1,1,1);
     48    this->frontMaterial().setDiffuse(1,1,1);
    4949
    5050    this->setSize2D(50, 10);
     
    6464    GLGuiWidget::draw();
    6565
    66     this->frontMat.select();
     66    this->frontMaterial().select();
    6767    glBegin(GL_QUADS);
    6868
  • trunk/src/lib/gui/gl_gui/glgui_button.cc

    r7779 r7919  
    2626   * standard constructor
    2727  */
    28   GLGuiButton::GLGuiButton ()
     28  GLGuiButton::GLGuiButton (const std::string& label)
    2929  {
    3030    this->init();
    3131
     32    this->label.setText( label );
    3233  }
    3334
     
    4546
    4647  /**
    47    * initializes the GUI-element
     48   * @brief initializes the GUI-element
    4849   */
    4950  void GLGuiButton::init()
    5051  {
    5152    this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton");
     53    this->setFocusable(true);
     54    this->setClickable(true);
    5255
    53     this->label = new Text();
    54     this->label->setParent2D(this);
     56    this->label.setFont("fonts/final_frontier.ttf", 20);
     57    this->frontMaterial().setDiffuse(1, 0, 0);
     58
     59    this->label.setParent2D(this);
    5560  }
     61
    5662
    5763  void GLGuiButton::setLabel(const std::string& label)
    5864  {
    59     this->label->setText(label);
    60     this->label->setRelCoor2D(5, 5);
    61     this->setSize2D(this->label->getSizeX2D()+10, this->label->getSizeY2D()+10);
     65    this->label.setText(label);
     66    this->resize();
    6267  }
    6368
    64 
    6569  /**
    66    * draws the GLGuiButton
     70   * @brief draws the GLGuiButton
    6771   */
    6872  void GLGuiButton::draw() const
  • trunk/src/lib/gui/gl_gui/glgui_button.h

    r7779 r7919  
    1010#include "glgui_widget.h"
    1111
    12 class Text;
     12#include "text.h"
    1313
    1414namespace OrxGui
     
    2727  //! This is part of the openglGUI class
    2828  /**
    29    *
     29   * The Button is an Abstract class, that can be pushed to Toggle its state.
    3030   */
    3131  class GLGuiButton : public GLGuiWidget
     
    3333
    3434  public:
    35     GLGuiButton();
     35    GLGuiButton(const std::string& label);
    3636    virtual ~GLGuiButton();
    3737
    38     void init();
     38    const std::string& getLabel() const { return this->label.getText(); };
    3939    void setLabel(const std::string& label);
     40
     41    virtual void resize() = 0;
    4042
    4143    virtual void draw() const;
    4244
     45    private:
     46      void init();
     47
     48
    4349  protected:
    44     Text*                label;
     50
     51    Text                 label;
    4552
    4653  private:
  • trunk/src/lib/gui/gl_gui/glgui_checkbutton.cc

    r7779 r7919  
    2727   * standard constructor
    2828  */
    29   GLGuiCheckButton::GLGuiCheckButton ()
     29  GLGuiCheckButton::GLGuiCheckButton (const std::string& label, bool active)
     30  : GLGuiButton(label)
    3031  {
    3132    this->init();
     33    this->bActive = active;
    3234
     35    this->resize();
    3336  }
    3437
     
    4447   * initializes the GUI-element
    4548   */
    46   GLGuiCheckButton::init()
     49  void GLGuiCheckButton::init()
    4750  {
    4851    this->setClassID(CL_GLGUI_CHECKBUTTON, "GLGuiCheckButton");
     52  }
    4953
     54
     55  void GLGuiCheckButton::toggleActiveState()
     56  {
     57    this->bActive = !this->bActive;
     58  }
     59
     60  void GLGuiCheckButton::resize()
     61  {
     62    this->label.setRelCoor2D(25, 5);
     63    this->setSize2D(this->label.getSizeX2D() + 30, this->label.getSizeY2D() + 10);
     64  }
     65
     66
     67  void GLGuiCheckButton::released()
     68  {
     69    printf("%s released\n", this->getLabel().c_str());
     70    GLGuiWidget::released();
     71    this->toggleActiveState();
    5072  }
    5173
    5274  /**
    53    * draws the GLGuiCheckButton
     75   * @brief draws the GLGuiPushButton
    5476   */
    5577  void GLGuiCheckButton::draw() const
    5678  {
     79    this->startDraw();
     80    GLGuiButton::draw();
     81
     82    this->frontMaterial().select();
     83    glBegin(GL_QUADS);
     84
     85    glTexCoord2i(0,0); glVertex2d(1, 1);
     86    glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1);
     87    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1);
     88    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1);
     89
     90    if (this->bActive)
     91    {
     92      glColor3f( 1, 1 ,1);
     93      glTexCoord2i(0,0); glVertex2d(8, 8);
     94      glTexCoord2i(0,1); glVertex2d(8, this->getSizeY2D()-8);
     95      glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8, this->getSizeY2D()-8);
     96      glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8, 8);
     97      glEnd();
     98
     99
     100      // DRAW a cross :)
     101      glColor3f(0,0,0);
     102      glLineWidth(3.0);
     103      glBegin(GL_LINE_LOOP);
     104      glVertex2d(8,8);
     105      glVertex2d(this->getSizeY2D()/2, this->getSizeY2D()/2 - 1);
     106
     107      glVertex2d(this->getSizeY2D() -8, 8);
     108      glVertex2d(this->getSizeY2D()/2 +1, this->getSizeY2D()/2);
     109
     110      glVertex2d(this->getSizeY2D() -8, this->getSizeY2D() - 8);
     111      glVertex2d(this->getSizeY2D()/2, this->getSizeY2D()/2+1);
     112
     113      glVertex2d(8, this->getSizeY2D() - 8);
     114      glVertex2d(this->getSizeY2D()/2 -1, this->getSizeY2D()/2);
     115      glEnd();
     116    }
     117    else
     118    {
     119      glColor3f(0, 0, 0);
     120      glTexCoord2i(0,0); glVertex2d(8, 8);
     121      glTexCoord2i(0,1); glVertex2d(8, this->getSizeY2D()-8);
     122      glTexCoord2i(1,1); glVertex2d(this->getSizeY2D()-8, this->getSizeY2D()-8);
     123      glTexCoord2i(1,0); glVertex2d(this->getSizeY2D()-8, 8);
     124      glEnd();
     125    }
     126
     127
     128    this->endDraw();
     129    //   this->label->draw();
     130    //  printf("test");
    57131  }
    58132}
  • trunk/src/lib/gui/gl_gui/glgui_checkbutton.h

    r7779 r7919  
    66
    77#ifndef _GLGUI_CHECKBUTTON_H
    8 #define _GLGUI__H
     8#define _GLGUI_CHECKBUTTON_H
    99
    1010#include "glgui_button.h"
     
    2323
    2424  public:
    25     GLGuiCheckButton();
     25    GLGuiCheckButton(const std::string& label = "", bool active = false);
    2626    virtual ~GLGuiCheckButton();
    2727
    28     void init();
     28    virtual void resize();
     29    virtual void released();
    2930
    3031    bool    isActive() { return this->bActive; };
    3132    void    setActivity(bool bActive);
     33    void    toggleActiveState();
    3234
    3335    virtual void draw() const;
    3436    virtual void update() {};
     37
     38  private:
     39    void init();
     40
    3541
    3642  private:
  • trunk/src/lib/gui/gl_gui/glgui_colorselector.h

    r7779 r7919  
    55 */
    66
    7 #ifndef _GLGUI__H
    8 #define _GLGUI__H
     7#ifndef _GLGUI_COLORSELECTOR_H
     8#define _GLGUI_COLORSELECTOR_H
    99
    10 #include "base_object.h"
     10#include "glgui_widget.h"
    1111
    1212namespace OrxGui
  • trunk/src/lib/gui/gl_gui/glgui_cursor.cc

    r7779 r7919  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
    1717
    18 #include "glgui_.h"
     18#include "glgui_cursor.h"
     19
     20#include "glgui_handler.h"
     21#include "color.h"
     22
    1923
    2024namespace OrxGui
     
    2428   * standard constructor
    2529  */
    26   GLGui::GLGui ()
     30  GLGuiCursor::GLGuiCursor ()
    2731  {
    2832    this->init();
     33
     34    this->subscribeEvent(ES_MENU,  EV_MOUSE_MOTION);
     35    this->subscribeEvent(ES_MENU, EV_WINDOW_FOCUS);
     36
    2937
    3038  }
     
    3240
    3341  /**
    34    * standard deconstructor
    35   */
    36   GLGui::~GLGui()
     42   * @brief standard deconstructor
     43   */
     44  GLGuiCursor::~GLGuiCursor()
    3745  {
     46    GLGuiHandler::getInstance()->deactivateCursor(false);
     47  }
     48
     49  float GLGuiCursor::_mouseSensitivity = 1.0;
     50
     51
     52  /**
     53   * @brief initializes the GUI-element
     54   */
     55  void GLGuiCursor::init()
     56  {
     57    this->setClassID(CL_GLGUI_CURSOR, "GLGuiCursor");
     58
     59    this->backMaterial().setDiffuse(1.0,0.0,0.0);
     60    this->backMaterial().setDiffuseMap("cursor.png");
     61    this->setSize2D(10, 20);
     62    this->setAbsCoor2D(100, 100);
     63    this->setLayer(E2D_LAYER_ABOVE_ALL);
     64    this->color = 0.0f;
     65
     66  }
     67
     68  void GLGuiCursor::tick(float dt)
     69  {
     70    this->color += dt*10.0;
     71    if (this->color > 360.0)
     72      this->color -= 360.0;
     73    Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
     74    this->backMaterial().setDiffuse(color.x, color.y, color.z);
     75
     76    if (this->movement != Vector2D())
     77    {
     78      newPos += movement;
     79      // reposition the cursor.
     80      if (newPos.x < 0.0f )
     81        newPos.x = 0.0f;
     82      if (newPos.x > this->_maxBorders.x)
     83        newPos.x = this->_maxBorders.x;
     84      if (newPos.y < 0.0f )
     85        newPos.y = 0.0f;
     86      if (newPos.y > this->_maxBorders.y)
     87        newPos.y = this->_maxBorders.y;
     88
     89
     90      this->setAbsCoorSoft2D(newPos, 10);
     91      movement = Vector2D();
     92    }
    3893  }
    3994
    4095  /**
    41    * initializes the GUI-element
     96   * @brief draws the GLGuiCursor
    4297   */
    43   GLGui::init()
     98  void GLGuiCursor::draw() const
    4499  {
    45     this->setClassID(CL_GLGUI_, "GLGui");
    46 
     100    this->startDraw();
     101    GLGuiWidget::draw();
     102    this->endDraw();
    47103  }
    48104
    49   /**
    50    * draws the GLGui
    51    */
    52   void GLGui::draw()
     105  void GLGuiCursor::process(const Event& event)
    53106  {
     107    switch (event.type)
     108    {
     109      case EV_WINDOW_FOCUS:
     110        if (event.bPressed)
     111        {
     112          int mouseX, mouseY;
     113          SDL_GetMouseState(&mouseX, &mouseY);
     114          newPos = Vector2D(mouseX, mouseY);
     115        }
     116        break;
     117      case EV_MOUSE_MOTION:
     118        movement += Vector2D((float)event.xRel * _mouseSensitivity, (float)event.yRel * _mouseSensitivity);
     119        break;
     120
     121    }
    54122  }
    55123}
  • trunk/src/lib/gui/gl_gui/glgui_cursor.h

    r7779 r7919  
    11/*!
    2  * @file glgui_.h
    3  * The gl_ widget of th openglGUI
     2 * @file glgui_cursor.h
     3 * The gl_cursor widget of th openglGUI
    44 *
    55 */
    66
    7 #ifndef _GLGUI__H
    8 #define _GLGUI__H
     7#ifndef _GLGUI_CURSOR_H
     8#define _GLGUI_CURSOR_H
    99
    10 #include "base_object.h"
     10#include "glgui_widget.h"
     11#include "event_listener.h"
     12#include "vector2D.h"
    1113
    1214namespace OrxGui
     
    1820   *
    1921   */
    20   class GLGui : public GLGui
     22  class GLGuiCursor : public GLGuiWidget, public EventListener
    2123  {
    2224
    2325  public:
    24     GLGui();
    25     virtual ~GLGui();
     26    GLGuiCursor();
     27    virtual ~GLGuiCursor();
     28
     29    static void setMouseSensitivity(float mouseSensitivity);
     30    static float mouseSensitivity() { return GLGuiCursor::_mouseSensitivity; };
     31
     32    void setMaxBorders(const Vector2D& maxBorders) { this->_maxBorders = maxBorders; };
    2633
    2734    void init();
     35    const Vector2D& position() const { return Element2D::getAbsCoor2D(); }
    2836
    29     virtual void draw();
    3037
     38    virtual void tick(float dt);
     39    virtual void draw() const;
     40    virtual void process(const Event& event);
    3141  private:
     42
     43    Vector2D      _maxBorders;
     44
     45    Vector2D      newPos;
     46    Vector2D      movement;
     47
     48    float         color; // so f****ing temporary... ... ....
     49
     50    static float _mouseSensitivity;
    3251
    3352  };
    3453}
    35 #endif /* _GLGUI__H */
     54#endif /* _GLGUI_CURSOR_H */
  • trunk/src/lib/gui/gl_gui/glgui_handler.cc

    r7868 r7919  
    2020
    2121#include "glgui_mainwidget.h"
     22#include "glgui_cursor.h"
     23
     24#include "class_list.h"
     25
     26
     27/// TAKE THIS OUT OF HERE.
     28#include "graphics_engine.h"
    2229
    2330namespace OrxGui
     
    3239    this->setName("GLGuiHandler");
    3340
    34     //this->subscribeEvent()
    3541
     42    EventHandler::getInstance()->withUNICODE(ES_MENU, true );
     43
     44    this->cursor = NULL;
     45    for (unsigned int i = 0; i < EV_NUMBER; i++)
     46    {
     47      this->subscribeEvent(ES_MENU, i);
     48    }
    3649  }
    3750
     
    4962  }
    5063
     64  void GLGuiHandler::activateCursor()
     65  {
     66    if (this->cursor == NULL)
     67      this->cursor = new GLGuiCursor();
     68    this->cursor->show();
     69    this->cursor->setMaxBorders(Vector2D(GraphicsEngine::getInstance()->getResolutionX(), GraphicsEngine::getInstance()->getResolutionY()));
     70  }
     71
     72  void GLGuiHandler::deactivateCursor(bool deleteCursor)
     73  {
     74    if (this->cursor)
     75    {
     76      if (deleteCursor)
     77        delete this->cursor;
     78      this->cursor = NULL;
     79    }
     80  }
     81
     82
    5183  void GLGuiHandler::activate()
    5284  {
    5385    EventHandler::getInstance()->pushState(ES_MENU);
     86
     87
    5488
    5589  }
     
    5993    EventHandler::getInstance()->popState();
    6094
     95
    6196  }
    6297
     
    6499  void GLGuiHandler::process(const Event &event)
    65100  {
     101    switch (event.type)
     102    {
     103      case  EV_MOUSE_BUTTON_LEFT:
     104        if (GLGuiWidget::focused() != NULL)
     105        {
     106          if (event.bPressed)
     107          {
     108            if (GLGuiWidget::focused()->clickable())
     109              GLGuiWidget::focused()->click();
     110          }
     111          else
     112          {
     113            if (GLGuiWidget::focused()->clickable())
     114              GLGuiWidget::focused()->release();
     115          }
     116        }
     117        break;
     118      case EV_LEAVE_STATE:
     119        if (GLGuiWidget::focused() != NULL)
     120          GLGuiWidget::focused()->breakFocus();
     121        break;
     122
     123      case EV_VIDEO_RESIZE:
     124        if (this->cursor != NULL)
     125          this->cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
     126        break;
     127    }
     128
     129
     130
     131    if (GLGuiWidget::focused())
     132    {
     133      GLGuiWidget::focused()->processEvent(event);
     134    }
     135
    66136
    67137
     
    70140  void GLGuiHandler::draw()
    71141  {
    72 //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
     142    //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
    73143  }
    74144
     
    76146  void GLGuiHandler::tick(float dt)
    77147  {
     148
     149    // CHECK THE COLLISIONS.
     150    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
     151
     152    if (objects != NULL && this->cursor != NULL)
     153    {
     154      for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++)
     155      {
     156        GLGuiWidget* widget = dynamic_cast<GLGuiWidget*>(*it);
     157
     158        if (widget->isVisible() &&
     159            widget->focusable() &&
     160            widget->focusOverWidget(this->cursor))
     161        {
     162          // receiving Focus
     163          if (GLGuiWidget::focused() != widget)
     164          {
     165            widget->giveFocus();
     166          }
     167          return ;
     168        }
     169      }
     170      if (GLGuiWidget::focused() != NULL)
     171        GLGuiWidget::focused()->breakFocus();
     172    }
    78173  }
    79174}
  • trunk/src/lib/gui/gl_gui/glgui_handler.h

    r7779 r7919  
    88
    99#include "event_listener.h"
     10#include "glgui_widget.h"
    1011
    1112namespace OrxGui
    1213{
     14
     15  class GLGuiCursor;
     16
    1317  // FORWARD DECLARATION
    1418
     
    2125    /** @returns a Pointer to the only object of this Class */
    2226    inline static GLGuiHandler* getInstance(void) { if (!GLGuiHandler::singletonRef) GLGuiHandler::singletonRef = new GLGuiHandler();  return GLGuiHandler::singletonRef; };
     27
     28    void activateCursor();
     29    void deactivateCursor(/** ignore param */ bool deleteCursor = true);
     30    GLGuiCursor* getCursor() const { return this->cursor; }
    2331
    2432    void activate();
     
    3644
    3745    bool                 isActive;
     46    GLGuiCursor*         cursor;
     47
    3848  };
    3949}
  • trunk/src/lib/gui/gl_gui/glgui_pushbutton.cc

    r7779 r7919  
    2525
    2626  /**
    27    * standard constructor
    28   */
    29   GLGuiPushButton::GLGuiPushButton ()
     27   * @brief standard constructor
     28   */
     29  GLGuiPushButton::GLGuiPushButton (const std::string& label)
     30  : GLGuiButton(label)
    3031  {
    3132    this->init();
     33
     34    this->resize();
    3235  }
    3336
    3437
    3538  /**
    36    * standard deconstructor
     39   * @brief standard deconstructor
    3740  */
    3841  GLGuiPushButton::~GLGuiPushButton()
    3942  {
     43  }
     44
     45  void GLGuiPushButton::resize()
     46  {
     47    this->label.setRelCoor2D(5, 5);
     48    this->setSize2D(this->label.getSizeX2D() + 10, this->label.getSizeY2D() + 10);
    4049  }
    4150
     
    4655  {
    4756    this->setClassID(CL_GLGUI_PUSHBUTTON, "GLGuiPushButton");
    48     this->frontMat.setDiffuse(1,0,0);
    49     //  this->label->setRelCoor2D(10, 10);
    5057  }
    5158
     59  void GLGuiPushButton::receivedFocus()
     60  {
     61    printf("%s received focus\n", this->getLabel().c_str());
     62    GLGuiWidget::receivedFocus();
     63  }
     64
     65  void GLGuiPushButton::removedFocus()
     66  {
     67    printf("%s removed focus\n", this->getLabel().c_str());
     68    GLGuiWidget::removedFocus();
     69
     70  }
     71
     72  void GLGuiPushButton::clicked()
     73  {
     74    printf("%s clicked\n", this->getLabel().c_str());
     75    GLGuiWidget::clicked();
     76  }
     77
     78
     79  void GLGuiPushButton::released()
     80  {
     81    printf("%s released\n", this->getLabel().c_str());
     82    GLGuiWidget::released();
     83  }
     84
     85
     86
    5287  /**
    53    * draws the GLGuiPushButton
     88   * @brief draws the GLGuiPushButton
    5489   */
    5590  void GLGuiPushButton::draw() const
    5691  {
    5792    this->startDraw();
     93    GLGuiButton::draw();
    5894
    59     //  GLGuiButton::draw();
    60 
    61     this->frontMat.select();
     95    this->frontMaterial().select();
    6296    glBegin(GL_QUADS);
    6397
    64     glVertex2d(0,0);
    65     glVertex2d(0, this->getSizeY2D());
    66     glVertex2d(this->getSizeX2D(), this->getSizeY2D());
    67     glVertex2d(this->getSizeX2D(),0);
     98    glTexCoord2i(0,0); glVertex2d(1, 1);
     99    glTexCoord2i(0,1); glVertex2d(1, this->getSizeY2D() - 1);
     100    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D() - 1, this->getSizeY2D() -1);
     101    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D() - 1, 1);
    68102
    69103    glEnd();
    70 
    71104    this->endDraw();
    72105    //   this->label->draw();
  • trunk/src/lib/gui/gl_gui/glgui_pushbutton.h

    r7779 r7919  
    2323
    2424  public:
    25     GLGuiPushButton();
     25    GLGuiPushButton(const std::string& label = "");
    2626    virtual ~GLGuiPushButton();
    2727
    28     void init();
     28
     29    virtual void resize();
     30
     31    virtual void receivedFocus();
     32    virtual void removedFocus();
     33    virtual void clicked();
     34    virtual void released();
     35
    2936
    3037    virtual void draw() const;
    3138    virtual void update();
    3239  private:
     40    void init();
    3341
    3442  };
  • trunk/src/lib/gui/gl_gui/glgui_slider.cc

    r7779 r7919  
    5050   * draws the GLGuiSlider
    5151   */
    52   void GLGuiSlider::draw()
     52  void GLGuiSlider::draw() const
    5353  {
    5454  }
  • trunk/src/lib/gui/gl_gui/glgui_slider.h

    r7779 r7919  
    88#define _GLGUI_SLIDER_H
    99
    10 #include "base_object.h"
    11 
     10#include "glgui_widget.h"
     11#include "glgui_defs.h"
    1212
    1313namespace OrxGui
     
    1919   *
    2020   */
    21   class GLGuiSlider : public GLGuiSlider
     21  class GLGuiSlider : public GLGuiWidget
    2222  {
    2323
     
    2828    void init();
    2929
    30     virtual void draw();
     30    virtual void draw() const;
    3131
    3232  private:
     33    Orientation      orientation;
     34
     35    float            _maxValue;
     36    float            _minValue;
     37
     38    float            _value;
    3339
    3440  };
  • trunk/src/lib/gui/gl_gui/glgui_textfield.cc

    r7779 r7919  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI
    1717
    18 #include "glgui_textfield_.h"
     18#include "glgui_textfield.h"
    1919namespace OrxGui
    2020{
     
    4242  void GLGuiTextfield::init()
    4343  {
    44     this->setClassID(CL_GLGUI_, "GLGuiTextfield");
     44    this->setClassID(CL_GLGUI_TEXTFIELD, "GLGuiTextfield");
     45
    4546
    4647  }
     
    4950   * draws the GLGuiTextfield
    5051   */
    51   void GLGuiTextfield::draw()
     52  void GLGuiTextfield::draw() const
    5253  {
    5354  }
  • trunk/src/lib/gui/gl_gui/glgui_textfield.h

    r7779 r7919  
    99
    1010#include "glgui_widget.h"
     11
     12#include "text.h"
     13#include <vector>
    1114
    1215// FORWARD DECLARATION
     
    2831    void init();
    2932
    30     virtual void draw();
     33    void process(const Event& event);
     34
     35    virtual void draw() const;
    3136
    3237  private:
    33     std::list<Text*>      textLines;
     38    std::vector<Text>        textLines;
    3439
    3540  };
  • trunk/src/lib/gui/gl_gui/glgui_widget.cc

    r7855 r7919  
    1818#include "glgui_widget.h"
    1919
     20#include "glgui_cursor.h"
     21
    2022#include "material.h"
    2123
     
    3941  GLGuiWidget::~GLGuiWidget()
    4042  {
    41   }
     43    if (this == GLGuiWidget::_focused)
     44      GLGuiWidget::_focused = NULL;
     45  }
     46
     47  GLGuiWidget* GLGuiWidget::_focused = NULL;
     48  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
     49
    4250
    4351
     
    4957    this->setClassID(CL_GLGUI_WIDGET, "GLGuiWidget");
    5058
    51     this->focusable = true;
    52     this->clickable = true;
     59    this->_focusable = false;
     60    this->_clickable = false;
     61    this->_pushed = false;
     62
    5363    this->setVisibility(GLGUI_WIDGET_DEFAULT_VISIBLE);
    54     //  this->setParent2D((Element2D*)NULL);
    5564
    5665    this->backMat.setDiffuse(1.0, 1.0, 1.0);
    57 
    58     this->frontModel = 0;
     66    this->frontMat.setDiffuse(1.0, 0.0, 0.0);
    5967
    6068    this->widgetSignals.resize(SignalCount, SignalConnector());
     
    6270
    6371
    64   bool GLGuiWidget::focusOverWidget(float x, float y)
    65   {
    66     if (this->getAbsCoor2D().x < x && this->getAbsCoor2D().x + this->getSizeX2D() > x &&
    67         this->getAbsCoor2D().y < y && this->getAbsCoor2D().y + this->getSizeY2D() > y)
    68       return true;
    69     else
    70       return false;
    71   }
     72  /** @brief gives focus to this widget */
     73  void GLGuiWidget::giveFocus()
     74  {
     75    if (GLGuiWidget::focused() != NULL)
     76      GLGuiWidget::focused()->breakFocus();
     77    GLGuiWidget::_focused = this;
     78    this->receivedFocus();
     79  };
     80
     81  void GLGuiWidget::breakFocus()
     82  {
     83    if (GLGuiWidget::_focused == this)
     84    {
     85      GLGuiWidget::_focused = NULL;
     86      this->_pushed = false;
     87      this->removedFocus();
     88    }
     89  };
     90
     91
     92  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
     93  {
     94    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
     95        this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
     96  }
     97
     98  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
     99  {
     100    return this->focusOverWidget(cursor->getAbsCoor2D());
     101  }
     102
     103  void GLGuiWidget::click()
     104  {
     105    assert (!this->_pushed);
     106    this->widgetSignals[Signal_click]("none");
     107    this->_pushed = true;
     108
     109    this->clicked();
     110  }
     111
     112  void GLGuiWidget::release()
     113  {
     114    if (this->_pushed)
     115    {
     116      this->widgetSignals[Signal_release]("none");
     117
     118      this->released();
     119      this->_pushed = false;
     120    }
     121  }
     122
     123
     124  void GLGuiWidget::clicked()
     125  {
     126    this->frontMaterial().setDiffuse(0, 0, 1);
     127
     128  }
     129
     130  void GLGuiWidget::released()
     131  {
     132    this->frontMat.setDiffuse(0,1,0);
     133
     134  }
     135
     136  void GLGuiWidget::receivedFocus()
     137  {
     138    this->frontMaterial().setDiffuse(0, 1, 0);
     139  }
     140
     141  void GLGuiWidget::removedFocus()
     142  {
     143    this->frontMaterial().setDiffuse(1, 0, 0);
     144
     145  }
     146
     147  void GLGuiWidget::destroyed()
     148  {
     149  };
     150
     151
     152
    72153
    73154  /**
     
    116197
    117198    glBegin(GL_QUADS);
    118     glTexCoord2i(0,1); glVertex2d(0, 0);
    119     glTexCoord2i(0,0); glVertex2d(0, this->getSizeY2D());
    120     glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
    121     glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), 0);
     199    glTexCoord2i(0,0); glVertex2d(0, 0);
     200    glTexCoord2i(0,1); glVertex2d(0, this->getSizeY2D());
     201    glTexCoord2i(1,1); glVertex2d(this->getSizeX2D(), this->getSizeY2D());
     202    glTexCoord2i(1,0); glVertex2d(this->getSizeX2D(), 0);
    122203    glEnd();
    123204  }
  • trunk/src/lib/gui/gl_gui/glgui_widget.h

    r7868 r7919  
    88
    99#include "element_2d.h"
    10 #include "event.h"
     10#include "rect2D.h"
     11
    1112#include "material.h"
    1213
     14#include "event.h"
     15#include "signal_connector.h"
     16
    1317#include "glincl.h"
    14 #include "signal_connector.h"
     18
     19#include <vector>
    1520
    1621// FORWARD DECLARATION
     
    1924namespace OrxGui
    2025{
    21 
    2226  typedef enum
    2327  {
     
    3438
    3539
     40  class GLGuiCursor;
     41
    3642  //! if the Element should be visible by default.
    3743#define GLGUI_WIDGET_DEFAULT_VISIBLE       false
     
    4349  class GLGuiWidget : public Element2D
    4450  {
     51
    4552  private:
    4653
     
    5259    void hide();
    5360
     61    /// INTERCONNECTIVITY
    5462    void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);
    5563    void disconnectSignal(SignalType signalType);
    56     bool focusOverWidget(float x, float y);
    5764
     65
     66    /// FOCUS
     67    /** @brief gives focus to this widget */
     68    void giveFocus();
     69    void breakFocus();
     70    /** @returns true if the widget is focusable */
     71    bool focusable() const { return this->_focusable; };
     72    /** @param focusable sets if the Widget should be focusable */
     73    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
     74    /** @returns true if the position is inside of the Widget. @param position the position to check */
     75    bool focusOverWidget(const Vector2D& position) const;
     76    /** @brief overloaded function, that returns true if the cursor is on top of the Widget */
     77    bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const;
     78
     79    /** @returns the currently focused Widget (NULL if none is selected) */
     80    static GLGuiWidget* focused() { return GLGuiWidget::_focused; };
     81
     82
     83    /// CLICK
     84    void click();
     85    void release();
     86    bool clickable() const { return this->_clickable; };
     87    void setClickable(bool clickable = true) { this->_clickable = clickable; };
    5888
    5989    virtual void update() {};
    6090    virtual void draw() const;
    6191
     92
     93    /// MATERIAL (looks)
    6294    Material& backMaterial() { return this->backMat; };
    6395    const Material& backMaterial() const { return this->backMat; };
     
    6698    const Material& frontMaterial() const { return this->frontMat; };
    6799
     100    /** @param the Event to process. @returns true if the Event has been consumed*/
     101    virtual bool processEvent(const Event& event) { };
     102
     103
     104    DeclareSignal(testSignal, ());
     105
    68106  protected:
    69107        // if something was clickt on the GUI-widget.
    70     virtual void clicked(const Event& event) {};
    71     virtual void released(const Event& event) {};
     108    virtual void clicked();
     109    virtual void released();
     110    virtual void receivedFocus();
     111    virtual void removedFocus();
    72112
    73     virtual void receivedFocus() {};
    74     virtual void removedFocus() {};
    75 
    76     virtual void destroyed() {};
     113    virtual void destroyed();
    77114
    78115
     
    84121
    85122
     123  private:
     124    /// LOOKS
     125    Material                       backMat;
     126    Rect2D                         backRect;
     127
     128    Material                       frontMat;
     129    Rect2D                         frontRect;
    86130
    87131
    88   protected:
    89     Material               backMat;
    90     GLuint                 backModel;
     132    /// SIGNALS
     133    std::vector<SignalConnector>   widgetSignals;
    91134
    92     Material               frontMat;
    93     GLuint                 frontModel;
     135    /// EVENTS
     136    bool                           _focusable;        //!< If this widget can receive focus.
     137    bool                           _clickable;        //!< if this widget can be clicked upon.
    94138
    95   private:
    96     std::vector<SignalConnector> widgetSignals;
     139    bool                           _pushed;
    97140
    98     bool                   focusable;        //!< If this widget can receive focus.
    99     bool                   clickable;        //!< if this widget can be clicked upon.
     141    static GLGuiWidget*            _focused;
     142    static GLGuiWidget*            _inputGrabber;
    100143  };
    101144}
  • trunk/src/lib/gui/gl_gui/glmenu/glmenu_imagescreen.cc

    r7221 r7919  
    240240  glEnd();
    241241
    242   glDisable(GL_TEXTURE_2D);
    243242  /* draw white border */
    244243  glBegin(GL_LINE_LOOP);
  • trunk/src/lib/gui/gl_gui/signal_connector.h

    r7855 r7919  
    1111namespace OrxGui
    1212{
     13
     14#define DeclareSignal(name, params) \
     15  public: \
     16   void signal_ ##connect ##name(const SignalConnector& connector) { \
     17     name ## connected.push_back(connector); \
     18   }\
     19  private: \
     20   void  signal_ ## name params { \
     21     for (unsigned int i = 0; i < name ## connected . size(); i++) \
     22       name ## connected[i] ("TEST"); \
     23   }\
     24   std::vector<SignalConnector> name ## connected
     25
    1326  //! A class for Conncting Signals to Objects, inside of the GUI
    1427  class SignalConnector
  • trunk/src/lib/math/Makefile.am

    r7033 r7919  
    1313                plane.cc \
    1414                line.cc \
     15                rect2D.cc \
    1516                rotation_OBSOLETE.cc
    1617
     
    2324                plane.h \
    2425                line.h \
     26                rect2D.h \
    2527                rotation_OBSOLETE.h
  • trunk/src/lib/math/vector2D.h

    r6616 r7919  
    2424#define __VECTOR2D_H_
    2525
    26 #include <math.h>
     26#include <cmath>
    2727#include "compiler.h"
    2828
     
    4040
    4141  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
    42   inline bool operator== (const Vector2D& v) const { return (this->x==v.x && this->y==v.y)?true:false; };
     42  inline bool operator== (const Vector2D& v) const { return (this->x==v.x && this->y==v.y); };
     43  /** @param v: the Vector to negative-compare with this one @returns true if the two vectors are different */
     44  inline bool operator!= (const Vector2D& v) const { return (this->x!=v.x && this->y!=v.y); };
    4345  /** @param index The index of the "array" @returns the x/y coordinate */
    4446  inline float operator[] (float index) const { return ( index == 0)? this->x : this->y; }
     
    7779  /** @param v: the other vector \return the dot product of the vectors */
    7880  float dot (const Vector2D& v) const { return x*v.x+y*v.y; };
     81  /** @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; };
    7983  /** scales the this vector with v* @param v the vector to scale this with */
    8084  void scale(const Vector2D& v) {   x *= v.x;  y *= v.y; };
     
    8589  Vector2D getNormalized() const;
    8690  Vector2D abs();
     91
     92  /** @param v the Vector to slerp to @param val 0 = stay 1 = at v */
     93  void slerp(const Vector2D& v, float val) { *this += (*this - v) * val; }
    8794
    8895  void debug() const;
  • trunk/src/lib/shell/shell.cc

    r7868 r7919  
    7070    this->subscribeEvent(ES_SHELL, SDLK_PAGEDOWN);
    7171    this->subscribeEvent(ES_SHELL, EV_VIDEO_RESIZE);
     72    EventHandler::getInstance()->withUNICODE(ES_SHELL, true);
    7273
    7374    // BUFFER
     
    8384    this->textSize = 15;
    8485    this->lineSpacing = 0;
    85     this->bActive = true;
     86    this->bActive = false;
    8687    this->fontFile = SHELL_DEFAULT_FONT;
    8788
     
    121122
    122123    EventHandler::getInstance()->pushState(ES_SHELL);
    123     EventHandler::getInstance()->withUNICODE(true);
    124124
    125125    this->setRelCoorSoft2D(0, 0, 5);
     
    138138        (*text)->setText("");
    139139    }
     140    this->shellInput.setVisibility(true);
    140141    this->updateResolution( GraphicsEngine::getInstance()->getResolutionX());
    141142    this->repositionText();
     
    152153    this->deactivate2D();
    153154
    154     EventHandler::getInstance()->withUNICODE(false);
    155155    EventHandler::getInstance()->popState();
    156156
     
    159159    for (std::list<MultiLineText*>::iterator text = this->bufferText.begin(); text != this->bufferText.end(); ++text)
    160160      (*text)->setVisibility(false);
     161    this->shellInput.setVisibility(false);
     162
    161163    // Go to the End again.
    162164    this->bufferIterator = this->shellBuffer->getBuffer().begin();
  • trunk/src/lib/shell/shell_input.cc

    r7868 r7919  
    305305        this->historyMoveUp();
    306306        this->pressedKey = event.type;
     307        this->pressedEvent = event.type;
    307308      }
    308309      else if (event.type == SDLK_DOWN)
     
    310311        this->historyMoveDown();
    311312        this->pressedKey = event.type;
     313        this->pressedEvent = event.type;
    312314      }
    313315      else if (event.type == SDLK_TAB)
     
    320322        this->delayed = this->repeatDelay;
    321323        this->pressedKey = SDLK_BACKSPACE;
     324        this->pressedEvent = SDLK_BACKSPACE;
    322325        this->removeCharacters(1);
    323326      }
     
    326329        this->executeCommand();
    327330        this->pressedKey = event.type;
     331        this->pressedEvent = event.type;
    328332      }
    329333      // any other keyboard key
  • trunk/src/lib/util/color.cc

    r7195 r7919  
    113113  }
    114114  else {
    115    if(h == 360.)
    116      h = 0.0;
     115   if(h >= 360.)
     116     h = h - (float)((int)(ceilf(h) / 360.0));
    117117    h /= 60.;
    118118    i = (int) h;
  • trunk/src/story_entities/game_world.cc

    r7871 r7919  
    2525
    2626#include "util/loading/game_loader.h"
     27#include "util/timer.h"
    2728
    2829#include "player.h"
     
    259260  this->cycle = 0;
    260261  for (unsigned int i = 0; i < TICK_SMOOTH_VALUE; i++)
    261     this->frameTimes[i] = 100;
     262    this->frameTimes[i] = 0.01f;
    262263  this->dtS = 0.0f;
    263   this->lastFrame = SDL_GetTicks ();
     264  this->lastFrame = Timer::getNow();
    264265
    265266  if (this->dataTank->music != NULL)
     
    356357void GameWorld::tick ()
    357358{
    358   Uint32 currentFrame = SDL_GetTicks();
    359 
    360359  if( !this->bPaused)
    361360  {
    362361    // CALCULATE FRAMERATE
    363362    Uint32 frameTimesIndex;
    364     Uint32 getTicks;
    365363    Uint32 i;
     364    double currentFrame = Timer::getNow();
    366365
    367366    frameTimesIndex = this->cycle % TICK_SMOOTH_VALUE;
    368     getTicks = SDL_GetTicks();
    369     this->frameTimes[frameTimesIndex] = getTicks - this->lastFrame;
    370     this->lastFrame = getTicks;
     367    this->frameTimes[frameTimesIndex] = currentFrame - this->lastFrame;
     368    this->lastFrame = currentFrame;
    371369    ++this->cycle;
    372     this->dtS = 0;
     370    this->dtS = 0.0;
    373371    for (i = 0; i < TICK_SMOOTH_VALUE; i++)
    374372      this->dtS += this->frameTimes[i];
    375     this->dtS = this->dtS / TICK_SMOOTH_VALUE / 1000.0f * speed;
     373    this->dtS = this->dtS / TICK_SMOOTH_VALUE * speed;
    376374
    377375    // TICK everything
     
    390388      this->dataTank->gameRule->tick(this->dtS);
    391389  }
    392   this->lastFrame = currentFrame;
    393390}
    394391
     
    526523  GraphicsEngine* engine = GraphicsEngine::getInstance();
    527524
     525
    528526  AtmosphericEngine::getInstance()->draw();
     527
     528  //glEnable(GL_DEPTH_TEST);
     529  //glEnable(GL_LIGHTING);
    529530
    530531  // set camera
  • trunk/src/story_entities/game_world.h

    r7785 r7919  
    9393
    9494    /* world timing */
    95     Uint32              lastFrame;                    //!< last time of frame (in MiliSeconds)
     95    double              lastFrame;                    //!< last time of frame (in MiliSeconds)
    9696    Uint32              cycle;                        //!< The cycle we are in (starts with 0 and rises with every frame)
    9797    float               dtS;                          //!< The time needed for caluculations in seconds
    9898    float               speed;                        //!< how fast the game flows
    9999    double              gameTime;                     //!< this is where the game time is saved
    100     Uint32              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
     100    double              frameTimes[TICK_SMOOTH_VALUE];//!< The time used for the last TICK_SMOOTH_VALUE's frames.
    101101
    102102    GameRules*          gameRules;                    //!< Pointer to the data structure containig the game rules
  • trunk/src/story_entities/movie_loader.cc

    r7868 r7919  
    115115  GraphicsEngine::enter2DMode();
    116116
     117  glPushAttrib(GL_ENABLE_BIT);
    117118  glEnable(GL_TEXTURE_2D);
    118119  glBindTexture(GL_TEXTURE_2D, movie_player->getTexture());
     
    127128  glEnd();
    128129
     130  glPopAttrib();
    129131  GraphicsEngine::leave2DMode();
    130132
  • trunk/src/story_entities/simple_game_menu.cc

    r7868 r7919  
    2828#include "util/loading/factory.h"
    2929
    30 #include "p_node.h"
    3130#include "world_entity.h"
    3231#include "elements/image_entity.h"
     
    4140#include "cd_engine.h"
    4241
    43 
    44 using namespace std;
    45 
     42#include "glgui.h"
    4643
    4744//! This creates a Factory to fabricate a SimpleGameMenu
     
    5148
    5249SimpleGameMenu::SimpleGameMenu(const TiXmlElement* root)
    53   : GameWorld()
     50    : GameWorld()
    5451{
    5552  this->setClassID(CL_SIMPLE_GAME_MENU, "SimpleGameMenu");
     
    6663  this->selectorSource = NULL;
    6764
     65
     66  /// GUI
     67  ///(this is as modular as it is possible).
     68  OrxGui::GLGuiPushButton* pb = new OrxGui::GLGuiPushButton("PUSH ME");
     69  pb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::enterGui));
     70  pb->show();
     71  pb->setAbsCoor2D(50, 50);
     72
     73  OrxGui::GLGuiHandler::getInstance()->activateCursor();
     74  OrxGui::GLGuiHandler::getInstance()->activate();
     75  /////
     76
    6877  if (root != NULL)
    6978    this->loadParams(root);
     
    7281}
    7382
    74 
    75 /**
    76  *  @brief remove the SimpleGameMenu from memory
    77  *
    78  *  delete everything explicitly, that isn't contained in the parenting tree!
    79  *  things contained in the tree are deleted automaticaly
    80  */
     83/// HACK only for testing.
     84void SimpleGameMenu::enterGui()
     85{
     86  ///
     87  OrxGui::GLGuiButton* dnpb = new OrxGui::GLGuiCheckButton("Push the button");
     88  dnpb->show();
     89  dnpb->setAbsCoor2D(350, 50);
     90  dnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::execURL));
     91
     92  OrxGui::GLGuiPushButton* rdnpb = new OrxGui::GLGuiPushButton("Quit ORXONOX!!");
     93  rdnpb->show();
     94  rdnpb->setAbsCoor2D(200, 180);
     95  rdnpb->connectSignal(OrxGui::Signal_release, this, createExecutor<SimpleGameMenu>(&SimpleGameMenu::quitMenu));
     96
     97  OrxGui::GLGuiInputLine* input = new OrxGui::GLGuiInputLine();
     98  input->setText("input some text here");
     99  input->show();
     100  input->setAbsCoor2D(200, 230);
     101
     102
     103  /////
     104}
     105
     106
     107#include "threading.h"
     108void SimpleGameMenu::execURL() const
     109{
     110  std::string URL = "http://www.orxonox.net";
     111  SDL_CreateThread(startURL, (void*)&URL);
     112}
     113
     114#ifdef __OSX__
     115#include <ApplicationServices/ApplicationServices.h>
     116#elif defined __WIN32__
     117#include <shellapi.h>
     118#endif
     119
     120int SimpleGameMenu::startURL(void* url)
     121{
     122  std::string URL = *(std::string*)url;
     123#ifdef __linux__
     124  system ((std::string("firefox ") + URL).c_str());
     125#elif defined __OSX__
     126    CFURLRef url_handle = CFURLCreateWithBytes (NULL, (UInt8 *)URL.c_str(), URL.size(),
     127                                         kCFStringEncodingASCII, NULL);
     128    LSOpenCFURLRef (url_handle, NULL);
     129    CFRelease (url_handle);
     130#elif defined __WIN32__
     131    ShellExecute(GetActiveWindow(),
     132                 "open", URL.c_str(), NULL, NULL, SW_SHOWNORMAL);
     133  }
     134#endif
     135  PRINTF(3)("loaded external webpage %s\n", URL.c_str());
     136}
     137
     138/**
     139*  @brief remove the SimpleGameMenu from memory
     140*
     141*  delete everything explicitly, that isn't contained in the parenting tree!
     142*  things contained in the tree are deleted automaticaly
     143*/
    81144SimpleGameMenu::~SimpleGameMenu ()
    82145{
     
    85148  if( this->dataTank)
    86149    delete this->dataTank;
    87 }
    88 
    89 
    90 /**
    91  * @brief loads the parameters of a SimpleGameMenu from an XML-element
    92  * @param root the XML-element to load from
    93  */
     150  delete OrxGui::GLGuiHandler::getInstance( );
     151}
     152
     153
     154/**
     155* @brief loads the parameters of a SimpleGameMenu from an XML-element
     156* @param root the XML-element to load from
     157*/
    94158void SimpleGameMenu::loadParams(const TiXmlElement* root)
    95159{
     
    103167
    104168/**
    105  * @brief this is executed just before load
    106  *
    107  * since the load function sometimes needs data, that has been initialized
    108  * before the load and after the proceeding storyentity has finished
    109  */
     169* @brief this is executed just before load
     170*
     171* since the load function sometimes needs data, that has been initialized
     172* before the load and after the proceeding storyentity has finished
     173*/
    110174ErrorMessage SimpleGameMenu::init()
    111175{
     
    129193
    130194/**
    131  * @brief load the data
    132  */
     195* @brief load the data
     196*/
    133197ErrorMessage SimpleGameMenu::loadData()
    134198{
     
    149213    {
    150214      element = element->FirstChildElement();
    151     // load Players/Objects/Whatever
     215      // load Players/Objects/Whatever
    152216      PRINTF(4)("Loading Elements\n");
    153217      while( element != NULL)
     
    196260      this->menuStartMultiplayerGame->setBindNode((const PNode*)NULL);
    197261      this->menuStartMultiplayerGame->setRelCoor2D(State::getResX() / 2.0f,
    198                                                    State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
     262          State::getResY() / 2.0f + ((this->menuLayers[0].menuList.size() -1 ) * 60.0f));
    199263      this->menuLayers[0].menuList.push_back(dynamic_cast<TextElement*>(*entity));
    200264    }
     
    244308
    245309/**
    246  * @brief set the Sound to play when switching menu entry.
    247  * @param selectorSound the sound to load.
    248  */
     310* @brief set the Sound to play when switching menu entry.
     311* @param selectorSound the sound to load.
     312*/
    249313void SimpleGameMenu::setSelectorSound(const std::string& selectorSound)
    250314{
     
    280344
    281345/**
    282  * @brief start the menu
    283  */
     346* @brief start the menu
     347*/
    284348bool SimpleGameMenu::start()
    285349{
     
    293357
    294358/**
    295  * stop the menu
    296  */
     359* stop the menu
     360*/
    297361bool SimpleGameMenu::stop()
    298362{
     
    305369
    306370/**
    307  *  override the standard tick for more functionality
    308  */
     371*  override the standard tick for more functionality
     372*/
    309373void SimpleGameMenu::tick()
    310374{
    311375  GameWorld::tick();
    312376
     377  // Make the GLGui tick.
     378  OrxGui::GLGuiHandler::getInstance()->tick(this->dtS);
     379
    313380  this->animateScene(this->dtS);
    314381}
     
    316383
    317384/**
    318  * @brief no collision detection in the menu
    319  */
     385* @brief no collision detection in the menu
     386*/
    320387void SimpleGameMenu::collide()
    321388{
    322 //   this->dataTank->localCamera->
    323 }
    324 
    325 
    326 /**
    327  * @brief animate the scene
    328  */
     389  //   this->dataTank->localCamera->
     390}
     391
     392
     393/**
     394* @brief animate the scene
     395*/
    329396void SimpleGameMenu::animateScene(float dt)
    330397{
     
    335402}
    336403
    337 
    338 /**
    339  * @brief event dispatcher funciton
    340  * @param event the incoming event
    341  */
     404void SimpleGameMenu::quitMenu()
     405{
     406  this->setNextStoryID(WORLD_ID_GAMEEND);
     407  this->stop();
     408}
     409
     410
     411/**
     412* @brief event dispatcher funciton
     413* @param event the incoming event
     414*/
    342415void SimpleGameMenu::process(const Event &event)
    343416{
     
    422495
    423496/**
    424  * @brief switches to from one meny layer to an other
    425  * @param layer1 from layer
    426  * @param layer2 to layer
    427  */
     497* @brief switches to from one meny layer to an other
     498* @param layer1 from layer
     499* @param layer2 to layer
     500*/
    428501void SimpleGameMenu::switchMenuLayer(int layer1, int layer2)
    429502{
     
    485558
    486559/**********************************************************************************************
    487     SimpleGameMenuData
    488  **********************************************************************************************/
    489 
    490 
    491 /**
    492  * SimpleGameMenuData constructor
    493  */
     560SimpleGameMenuData
     561**********************************************************************************************/
     562
     563
     564/**
     565* SimpleGameMenuData constructor
     566*/
    494567SimpleGameMenuData::SimpleGameMenuData()
    495568{}
    496569
    497570/**
    498  * SimpleGameMenuData decontructor
    499  */
     571* SimpleGameMenuData decontructor
     572*/
    500573SimpleGameMenuData::~SimpleGameMenuData()
    501574{}
     
    503576
    504577/**
    505  *  initialize the GameWorldDataData
    506  */
     578*  initialize the GameWorldDataData
     579*/
    507580ErrorMessage SimpleGameMenuData::init()
    508581{
     
    513586
    514587/**
    515  *  loads the GUI data
    516  * @param root reference to the xml root element
    517  */
     588*  loads the GUI data
     589* @param root reference to the xml root element
     590*/
    518591ErrorMessage SimpleGameMenuData::loadGUI(const TiXmlElement* root)
    519592{
     
    524597
    525598/**
    526  *  unloads the GUI data
    527  */
     599*  unloads the GUI data
     600*/
    528601ErrorMessage SimpleGameMenuData::unloadGUI()
    529602{
     
    534607
    535608/**
    536  *  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
    537  * @param root reference to the xml root parameter
    538  */
     609*  overloads the GameWorld::loadWorldEntities(...) class since the menu WorldEntity loading is different (less loading stuff)
     610* @param root reference to the xml root parameter
     611*/
    539612ErrorMessage SimpleGameMenuData::loadWorldEntities(const TiXmlElement* root)
    540613{
     
    545618  if( element != NULL)
    546619  {
    547     element = element->FirstChildElement();
    548     PRINTF(4)("Loading WorldEntities\n");
    549     while(element != NULL)
    550     {
    551       BaseObject* created = Factory::fabricate(element);
    552       if( created != NULL )
    553         printf("Created a %s: %s\n", created->getClassName(), created->getName());
    554 
    555       if( element->Value() == "SkyBox")
    556         this->sky = dynamic_cast<WorldEntity*>(created);
    557       if( element->Value() == "Terrain")
    558         this->terrain = dynamic_cast<Terrain*>(created);
    559       element = element->NextSiblingElement();
    560     }
    561 
    562     PRINTF(4)("Done loading WorldEntities\n");
     620  element = element->FirstChildElement();
     621  PRINTF(4)("Loading WorldEntities\n");
     622  while(element != NULL)
     623  {
     624  BaseObject* created = Factory::fabricate(element);
     625  if( created != NULL )
     626  printf("Created a %s: %s\n", created->getClassName(), created->getName());
     627
     628  if( element->Value() == "SkyBox")
     629  this->sky = dynamic_cast<WorldEntity*>(created);
     630  if( element->Value() == "Terrain")
     631  this->terrain = dynamic_cast<Terrain*>(created);
     632  element = element->NextSiblingElement();
     633  }
     634
     635  PRINTF(4)("Done loading WorldEntities\n");
    563636  }
    564637
     
    570643
    571644/**
    572  *  unloads the world entities from the xml file
    573  */
     645*  unloads the world entities from the xml file
     646*/
    574647ErrorMessage SimpleGameMenuData::unloadWorldEntities()
    575648{
     
    580653
    581654/**
    582  *  loads the scene data
    583  * @param root reference to the xml root element
    584  */
     655*  loads the scene data
     656* @param root reference to the xml root element
     657*/
    585658ErrorMessage SimpleGameMenuData::loadScene(const TiXmlElement* root)
    586659{
     
    591664
    592665/**
    593  *  unloads the scene data
    594  */
     666*  unloads the scene data
     667*/
    595668ErrorMessage SimpleGameMenuData::unloadScene()
    596669{
  • trunk/src/story_entities/simple_game_menu.h

    r7460 r7919  
    4949    virtual ~SimpleGameMenu();
    5050
     51    /// TODO TAKE THIS OUT
     52    void enterGui();
     53    void execURL() const;
     54    static int startURL(void* data);
     55    ///
    5156    virtual void loadParams(const TiXmlElement* root);
    5257
     
    6065    virtual void process(const Event &event);
    6166
     67
     68    void startLevel(int level);
     69    void quitMenu();
     70
     71    void TEST() { printf("TEST\n"); }
    6272
    6373  protected:
  • trunk/src/world_entities/planet.cc

    r7221 r7919  
    109109void Planet::draw() const
    110110{
    111   glMatrixMode(GL_MODELVIEW);
    112   glPushMatrix();
    113 
    114   glShadeModel(GL_SMOOTH);
    115 
    116   /* translate */
    117   glTranslatef (this->getAbsCoor ().x,
    118                 this->getAbsCoor ().y,
    119                 this->getAbsCoor ().z);
    120   Vector tmpRot = this->getAbsDir().getSpacialAxis();
    121   glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    122 
    123111  this->material.select();
    124112
    125 //   /WorldEntity::draw();
    126   this->getModel(0)->draw();
    127  // static_cast<VertexArrayModel*>(this->getModel(0))->debug();
    128 
    129   glPopMatrix();
     113  WorldEntity::draw();
    130114}
    131115
  • trunk/src/world_entities/skybox.cc

    r7840 r7919  
    227227  glDisable(GL_LIGHTING);
    228228
    229   glPushAttrib(GL_ENABLE_BIT);
    230229  glDisable(GL_FOG);
    231230
    232231  WorldEntity::draw();
    233232
    234   glPopAttrib();
    235233  glPopAttrib();
    236234
Note: See TracChangeset for help on using the changeset viewer.