Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8717 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 22, 2006, 2:04:28 PM (18 years ago)
Author:
bensch
Message:

merged the gui back

Location:
trunk/src
Files:
32 edited
5 copied

Legend:

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

    r8711 r8717  
    146146  CL_MOVIE_LOADER               =    0x00000109,
    147147
     148  CL_GAME_MENU                  =    0x00000110,
     149  CL_GAME_MENU_DATA             =    0x00000111,
     150
     151
    148152  CL_MULTIPLAYER_TEAM_DEATHMATCH=    0x00000121,
    149153  CL_SINGLEPLAYER_SHOOTEMUP     =    0x00000122,
  • trunk/src/defs/error.h

    r5039 r8717  
    11
    22
    3 /* 
     3/*
    44   orxonox - the future of 3D-vertical-scrollers
    55
     
    1717
    1818
    19 /*! 
     19/*!
    2020 * @file error.h
    2121  *  A compendium of Error codes used in the program
    22 */ 
     22*/
    2323
    2424
     
    5454*/
    5555
    56 typedef struct
     56struct ErrorMessage
    5757{
     58  ErrorMessage(int code = 0, char* message = NULL, char* location = NULL)
     59    : code(code), message(message), location(location) {};
    5860  int code;
    5961  char* message;
    6062  char* location;
    61 } ErrorMessage;
     63};
    6264
    6365#endif /* _ERROR_H */
  • trunk/src/lib/data/data_tank.h

    r7370 r8717  
    2323
    2424    /** initializes the DataTank to be able to load the data */
    25     virtual ErrorMessage init() {}
     25    virtual ErrorMessage init() { return ErrorMessage(); }
    2626    /** loads the data into the DataTank @param root is the xml root parameter for for loadParams() connection */
    27     virtual ErrorMessage loadData(const TiXmlElement* root = NULL) {}
     27    virtual ErrorMessage loadData(const TiXmlElement* root = NULL) { return ErrorMessage(); }
    2828    /** unloads the data again from the DataTank */
    29     virtual ErrorMessage unloadData() {}
     29    virtual ErrorMessage unloadData() { return ErrorMessage(); }
    3030};
    3131
  • trunk/src/lib/event/event_handler.cc

    r8623 r8717  
    355355  else
    356356  {
    357     //SDL_WM_GrabInput(SDL_GRAB_ON);
     357    SDL_WM_GrabInput(SDL_GRAB_ON);
    358358    SDL_ShowCursor(SDL_DISABLE);
    359359  }
  • trunk/src/lib/gui/gl/Makefile.am

    r8619 r8717  
    6060                specials/glgui_notifier.h
    6161
    62 
    63 
    64 
    65 
    6662EXTRA_DIST =
    67 
  • trunk/src/lib/gui/gl/glgui_box.cc

    r8619 r8717  
    125125      height += borderBottom(); /* *2 done further up */
    126126
    127       printf("%f %f\n", width, height);
    128127      this->setSize2D(width, height);
    129128    }
     
    145144      height += borderBottom(); /* *2 done further up */
    146145
    147       printf("%f %f\n", width, height);
    148146      this->setSize2D(width, height);
    149147    }
  • trunk/src/lib/gui/gl/glgui_button.cc

    r8619 r8717  
    5151  {
    5252    this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton");
     53
     54    this->setSelectable(true);
    5355    this->setFocusable(true);
    5456    this->setClickable(true);
     
    7981    emit(clicked());
    8082  }
    81   void GLGuiButton::releasing(const Vector2D& pos)
     83  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
    8284  {
    83     GLGuiWidget::releasing(pos);
     85    GLGuiWidget::releasing(pos, focused);
    8486    emit(released());
    8587  }
     
    9698
    9799
     100  bool GLGuiButton::processEvent(const Event& event)
     101  {
     102    if (event.type == SDLK_SPACE && !event.bPressed)
     103    {
     104      emit(released());
     105      return true;
     106    }
     107    return false;
     108  }
     109
     110
    98111  /**
    99112   * @brief draws the GLGuiButton
  • trunk/src/lib/gui/gl/glgui_button.h

    r8619 r8717  
    4040
    4141      virtual void draw() const;
     42      virtual bool processEvent(const Event& event);
    4243
    4344      DeclareSignal0(clicked);
    4445      DeclareSignal0(released);
     46
    4547
    4648    protected:
     
    4850
    4951      virtual void clicking(const Vector2D& pos);
    50       virtual void releasing(const Vector2D& pos);
     52      virtual void releasing(const Vector2D& pos, bool focused);
    5153      virtual void hiding();
    5254      virtual void showing();
  • trunk/src/lib/gui/gl/glgui_checkbutton.cc

    r8619 r8717  
    7878
    7979
    80   void GLGuiCheckButton::releasing(const Vector2D& pos)
     80  void GLGuiCheckButton::releasing(const Vector2D& pos, bool focused)
    8181  {
    82     GLGuiButton::releasing(pos);
    83     this->toggleActiveState();
     82    GLGuiButton::releasing(pos, focused);
     83    if (focused)
     84      this->toggleActiveState();
    8485  }
    8586
  • trunk/src/lib/gui/gl/glgui_checkbutton.h

    r8448 r8717  
    3838  protected:
    3939    virtual void resize();
    40     virtual void releasing(const Vector2D& pos);
     40    virtual void releasing(const Vector2D& pos, bool focused);
    4141
    4242  private:
  • trunk/src/lib/gui/gl/glgui_handler.cc

    r8711 r8717  
    2525#include <cassert>
    2626
     27#include "debug.h"
     28
    2729#include <cassert>
    2830
     
    99101  }
    100102
     103  void GLGuiHandler::selectNext()
     104  {
     105    // retrieve Objects.
     106    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
     107
     108    if (objects)
     109    {
     110      std::list<BaseObject*>::const_iterator it ;
     111      std::list<BaseObject*>::const_iterator currentIt = objects->end();
     112
     113      if (GLGuiWidget::selected() != NULL)
     114      {
     115        it = std::find(objects->begin(), objects->end(), GLGuiWidget::selected());
     116        if (it != objects->end())
     117        {
     118          currentIt = it;
     119          it++;
     120        }
     121      }
     122      else
     123      {
     124        it = objects->begin();
     125      }
     126
     127      bool cycledOnce = false;
     128
     129      for (; it != currentIt; ++it)
     130      {
     131        if (it == objects->end() && !cycledOnce)
     132        {
     133          it = objects->begin();
     134          cycledOnce = true;
     135        }
     136
     137        if (dynamic_cast<GLGuiWidget*>(*it)->selectable())
     138        {
     139          dynamic_cast<GLGuiWidget*>(*it)->select();
     140          return;
     141        }
     142      }
     143
     144    }
     145    else
     146    {
     147      PRINTF(0)("NO GUI-ELEMENTS EXISTING\n");
     148    }
     149  }
     150
     151  void GLGuiHandler::selectPrevious()
     152  {
     153    // retrieve Objects.
     154    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
     155
     156    if (objects)
     157    {
     158      std::list<BaseObject*>::const_iterator it ;
     159      std::list<BaseObject*>::const_iterator currentIt = objects->begin();
     160
     161      if (GLGuiWidget::selected() != NULL)
     162      {
     163        it = std::find(objects->begin(), objects->end(), GLGuiWidget::selected());
     164        if (it != objects->end())
     165        {
     166          currentIt = it;
     167          it--;
     168        }
     169      }
     170      else
     171      {
     172        it = objects->end();
     173      }
     174
     175      bool cycledOnce = false;
     176
     177      for (; it != currentIt; --it)
     178      {
     179        if (it == objects->end() && !cycledOnce)
     180        {
     181          --it ;
     182          cycledOnce = true;
     183        }
     184
     185        if (dynamic_cast<GLGuiWidget*>(*it)->selectable())
     186        {
     187          dynamic_cast<GLGuiWidget*>(*it)->select();
     188          return;
     189        }
     190      }
     191
     192    }
     193    else
     194    {
     195      PRINTF(0)("NO GUI-ELEMENTS EXISTING\n");
     196    }
     197  }
     198
     199
    101200
    102201  void GLGuiHandler::process(const Event &event)
     
    105204    {
    106205      case  EV_MOUSE_BUTTON_LEFT:
    107         if (GLGuiWidget::focused() != NULL)
    108         {
    109           if (event.bPressed)
     206        if (GLGuiWidget::mouseFocused() != NULL && event.bPressed)
     207        {
     208          // if clickable select the Widget.
     209          if (GLGuiWidget::mouseFocused()->clickable())
    110210          {
    111             if (GLGuiWidget::focused()->clickable())
    112             {
    113               Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
    114               GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
    115             }
     211            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     212            GLGuiWidget::mouseFocused()->select();
     213            GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
    116214          }
    117           else
     215        }
     216        else if (GLGuiWidget::selected() != NULL && !event.bPressed)
     217        {
     218          if (GLGuiWidget::selected()->clickable())
    118219          {
    119             if (GLGuiWidget::focused()->clickable())
    120             {
    121               Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
    122               GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
    123             }
     220            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     221            GLGuiWidget::selected()->release(cursorPos - GLGuiWidget::selected()->getAbsCoor2D());
    124222          }
    125223        }
     224
    126225        break;
    127226      case EV_LEAVE_STATE:
    128         if (GLGuiWidget::focused() != NULL)
    129           GLGuiWidget::focused()->breakFocus();
     227        if (GLGuiWidget::selected() != NULL)
     228          GLGuiWidget::selected()->unselect();
     229
     230        if (GLGuiWidget::mouseFocused() != NULL)
     231          GLGuiWidget::mouseFocused()->breakMouseFocus();
    130232        break;
    131233
     
    134236          this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
    135237        break;
    136     }
    137 
    138 
    139 
    140     if (GLGuiWidget::focused())
    141     {
    142       GLGuiWidget::focused()->processEvent(event);
     238      case SDLK_TAB:
     239        if (event.bPressed)
     240          this->selectNext();
     241        break;
     242    }
     243
     244    if (GLGuiWidget::selected() != NULL)
     245    {
     246      GLGuiWidget::selected()->processEvent(event);
    143247    }
    144248
     
    160264      return Vector2D::nullVector();
    161265  }
     266
    162267  Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const
    163268  {
     
    170275
    171276
    172   void GLGuiHandler::draw()
    173   {
    174     //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
    175   }
    176 
    177 
    178   void GLGuiHandler::tick(float dt)
    179   {
    180 
    181     // CHECK THE COLLISIONS.
     277  void GLGuiHandler::checkFocus()
     278  {
     279   // CHECK THE COLLISIONS.
    182280    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
    183281
     
    193291        {
    194292          // receiving Focus
    195           if (GLGuiWidget::focused() != widget)
     293          if (GLGuiWidget::mouseFocused() != widget)
    196294          {
    197             widget->giveFocus();
     295            widget->giveMouseFocus();
    198296          }
    199297          return ;
    200298        }
    201299      }
    202       if (GLGuiWidget::focused() != NULL)
    203         GLGuiWidget::focused()->breakFocus();
    204     }
     300      if (GLGuiWidget::mouseFocused() != NULL)
     301        GLGuiWidget::mouseFocused()->breakMouseFocus();
     302    }
     303  }
     304
     305  void GLGuiHandler::draw()
     306  {
     307    //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
     308  }
     309
     310
     311  void GLGuiHandler::tick(float dt)
     312  {
     313    // do not change if we already clicked into a Widget.
     314    // if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->pushed())
     315    //      return ;
     316
     317    this->checkFocus();
    205318  }
    206319}
  • trunk/src/lib/gui/gl/glgui_handler.h

    r8324 r8717  
    3434    Vector2D cursorPositionRel(const GLGuiWidget* const widget) const;
    3535
     36    void selectNext();
     37    void selectPrevious();
     38
    3639    void activate();
    3740    void deactivate();
    3841
     42    void checkFocus();
    3943
    4044    virtual void process(const Event &event);
  • trunk/src/lib/gui/gl/glgui_inputline.cc

    r8619 r8717  
    4747
    4848    this->setFocusable(true);
     49    this->setClickable(true);
     50    this->setSelectable(true);
    4951
    5052    this->_clearOnEnter = false;
  • trunk/src/lib/gui/gl/glgui_pushbutton.cc

    r8448 r8717  
    6363  void GLGuiPushButton::receivedFocus()
    6464  {
    65     printf("%s received focus\n", this->label().c_str());
    6665    GLGuiWidget::receivedFocus();
    6766  }
     
    6968  void GLGuiPushButton::removedFocus()
    7069  {
    71     printf("%s removed focus\n", this->label().c_str());
    7270    GLGuiWidget::removedFocus();
    7371
     
    7674  void GLGuiPushButton::clicking(const Vector2D& pos)
    7775  {
    78     printf("%s clicked\n", this->label().c_str());
    7976    GLGuiButton::clicking(pos);
    8077  }
    8178
    8279
    83   void GLGuiPushButton::releasing(const Vector2D& pos)
     80  void GLGuiPushButton::releasing(const Vector2D& pos, bool focused)
    8481  {
    85     printf("%s released\n", this->label().c_str());
    86     GLGuiButton::releasing(pos);
     82    if (focused)
     83      GLGuiButton::releasing(pos, focused);
    8784  }
    8885
  • trunk/src/lib/gui/gl/glgui_pushbutton.h

    r8145 r8717  
    3131    virtual void draw() const;
    3232    virtual void update();
     33
    3334  protected:
    3435    virtual void resize();
    3536    virtual void clicking(const Vector2D& pos);
    36     virtual void releasing(const Vector2D& pos);
     37    virtual void releasing(const Vector2D& pos, bool focused);
    3738    virtual void receivedFocus();
    3839    virtual void removedFocus();
  • trunk/src/lib/gui/gl/glgui_slider.cc

    r8619 r8717  
    4848    this->setClassID(CL_GLGUI_SLIDER, "GLGuiSlider");
    4949
    50     this->setClickable( );
    51     this->setFocusable( );
     50    this->setClickable(true);
     51    this->setFocusable(true);
     52    this->setSelectable(true);
    5253
    5354    this->_value = 0.0;
     
    193194  }
    194195
    195   void GLGuiSlider::releasing(const Vector2D& pos)
    196   {
    197     GLGuiWidget::releasing(pos);
     196  void GLGuiSlider::releasing(const Vector2D& pos, bool focused)
     197  {
     198    GLGuiWidget::releasing(pos, focused);
    198199    this->grabbed = false;
    199200  }
     
    202203  {
    203204    GLGuiWidget::removedFocus();
    204     this->grabbed = false;
    205205  }
    206206
  • trunk/src/lib/gui/gl/glgui_slider.h

    r8448 r8717  
    5959
    6060    virtual void clicking(const Vector2D& pos);
    61     virtual void releasing(const Vector2D& pos);
     61    virtual void releasing(const Vector2D& pos, bool focused);
    6262    virtual void removedFocus();
    6363
  • trunk/src/lib/gui/gl/glgui_table.cc

    r8619 r8717  
    1919#include "debug.h"
    2020
     21#include "glgui_handler.h"
     22
    2123namespace OrxGui
    2224{
     
    2527   */
    2628  GLGuiTable::GLGuiTable (unsigned int rows, unsigned int columns)
     29  : _selected(-1, -1), _focused(-1, -1)
    2730  {
    2831    this->init();
     32
    2933    this->setRowCount(rows);
    3034    this->setColumnCount(columns);
     
    4549    this->setClassID(CL_GLGUI_TABLE, "GLGuiTable");
    4650
     51    this->setBorderTop(10);
     52
    4753    this->setFocusable(true);
    4854    this->setClickable(true);
    4955
    50     this->resize();
    5156  }
    5257
     
    5661
    5762    unsigned int currentRowCount = this->rowCount();
     63
     64    this->_rowHeights.resize(rowCount, 20);
     65
    5866    this->_entries.resize(rowCount);
    5967    for (unsigned int i = currentRowCount; i < this->rowCount(); ++i)
     
    6573
    6674    assert(this->checkIntegrity());
    67     this->debug();
     75    this->repositionText(currentRowCount, 0);
     76
     77
     78    this->resize();
    6879
    6980    if (!this->isVisible())
     
    7586    unsigned int i;
    7687    unsigned int currentColumnCount = this->columnCount();
     88
     89    this->_columnWidths.resize(columnCount, 100);
    7790
    7891    // setup Headers.
     
    89102    }
    90103    assert(this->checkIntegrity());
    91     this->debug();
    92 
     104
     105    this->repositionText(0, currentColumnCount);
     106
     107    this->resize();
    93108    if (!this->isVisible())
    94109      this->hiding();
     
    111126  }
    112127
    113   void GLGuiTable::setEntry(unsigned int column, unsigned int row, const std::string& name)
     128  void GLGuiTable::setEntry(unsigned int row, unsigned int column, const std::string& name)
    114129  {
    115130    if (column >= this->columnCount() )
     
    125140    for (unsigned int i = 0; i < this->rowCount(); ++i)
    126141      this->_entries[i][column].setLineWidth(size);
    127 
    128   }
     142  }
     143
     144
    129145
    130146  /// TODO.
     
    144160
    145161
    146 
    147162  /**
    148163   * @brief Processes an Event.
     
    152167  bool GLGuiTable::processEvent(const Event& event)
    153168  {
     169    if (event.type == EV_MOUSE_MOTION)
     170    {
     171      this->pixelPositionToElement((OrxGui::GLGuiHandler::getInstance()->cursorPositionRel(this)), &this->_focused.row, &this->_focused.column);
     172      return true;
     173    }
     174
    154175    return false;
    155176  }
     
    161182  void GLGuiTable::resize()
    162183  {
     184    Vector2D size;
     185    unsigned int i;
     186    for(i = 0; i < this->columnCount(); ++i)
     187      size.x += this->_columnWidths[i];
     188
     189    for(i = 0; i < this->rowCount(); ++i)
     190      size.y += this->_rowHeights[i];
     191
     192    this->setSize2D(size);
     193    this->setSize2D( size + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
     194
    163195    GLGuiWidget::resize();
    164196  }
     
    172204        this->_entries[j][i].setColor(this->foregroundColor());
    173205    }
     206
    174207  }
    175208
     
    196229
    197230  /**
    198    * @brief ticks the Table
    199    * @param dt the time passed.
    200    */
    201   void GLGuiTable::tick(float dt)
    202 {}
    203 
    204   /**
    205231   * @brief draws the GLGuiTable
    206232   */
     
    210236    GLGuiWidget::draw();
    211237
    212     //     this->frontMaterial().select();
    213     //     GLGuiWidget::drawRect(this->frontRect());
     238    float columnPos = this->borderLeft();
     239    float rowPos = this->borderTop();
     240
     241    unsigned int i;
     242    glColor4fv(&this->foregroundColor()[0]);
     243    glLineWidth(1.5);
     244    glBegin(GL_LINES);
     245
     246    glVertex2f(columnPos, this->borderTop());
     247    glVertex2f(columnPos, this->getSizeY2D());
     248    for (i = 0; i < this->columnCount(); ++i)
     249    {
     250      columnPos +=this->_columnWidths[i];
     251      glVertex2f(columnPos, this->borderTop());
     252      glVertex2f(columnPos, this->getSizeY2D());
     253    }
     254
     255    glVertex2f(this->borderLeft(), rowPos);
     256    glVertex2f(this->getSizeX2D(), rowPos);
     257    for (i = 0; i < this->rowCount(); ++i)
     258    {
     259      rowPos +=this->_rowHeights[i];
     260      glVertex2f(this->borderLeft(), rowPos);
     261      glVertex2f(this->getSizeX2D(), rowPos);
     262    }
     263
     264
     265    glEnd();
     266
     267
    214268
    215269    this->endDraw();
    216270  }
    217271
     272
     273  void GLGuiTable::pixelPositionToElement(const Vector2D& pixelPosition, int* row, int* column)
     274  {
     275    *row = 0;
     276    *column = 0;
     277    float columnPos = this->borderLeft();
     278    float rowPos = this->borderTop();
     279
     280    for (*row = 0; *row < (int)this->rowCount(); (*row)++)
     281    {
     282      if (pixelPosition.y > rowPos  && pixelPosition.y  < (rowPos += _rowHeights[*row]))
     283        break;
     284    }
     285    for (*column = 0; *column < (int)this->columnCount(); (*column)++)
     286    {
     287      if (pixelPosition.x > columnPos && pixelPosition.x  < (columnPos += _columnWidths[*column]))
     288        break;
     289    }
     290
     291    PRINTF(3)("Mouse Over row:%d Column:%d\n", *row, *column);
     292  }
     293
     294
     295  void GLGuiTable::repositionText(unsigned int fromLeft, unsigned int fromTop)
     296  {
     297    float columnPos = this->borderLeft();
     298    float rowPos = this->borderTop();
     299    unsigned int i, j;
     300    for (i = 0; i< fromLeft; ++i)
     301      columnPos+=this->_columnWidths[i];
     302    for (i = 0; i < fromTop; ++i)
     303      rowPos += this->_rowHeights[i];
     304
     305    for (i = fromLeft; i < this->columnCount(); ++i)
     306    {
     307      this->_headers[i].setRelCoor2D(columnPos, rowPos);
     308
     309      // not required, but a good idea :)
     310      this->_headers[i].setLineWidth(_columnWidths[i]);
     311
     312      float rowPosI = rowPos;
     313      for (j = fromTop; j < this->rowCount(); ++j)
     314      {
     315        this->_entries[j][i].setRelCoor2D(columnPos, rowPosI);
     316        this->_entries[j][i].setLineWidth(_columnWidths[i]);
     317        rowPosI += _rowHeights[j];
     318      }
     319      columnPos+=this->_columnWidths[i];
     320    }
     321  }
    218322
    219323  /**
     
    224328  {
    225329    text->setSize(this->textSize());
    226     //text->setLineWidth( );
     330    text->setLineWidth( this->_columnWidths[column] );
    227331    text->setFont("fonts/final_frontier.ttf", (int)this->textSize());
     332    text->setColor(this->foregroundColor());
    228333
    229334    text->setColor(this->foregroundColor());
     
    257362    for (unsigned int i = 0; i < this->rowCount(); ++i)
    258363      if (this->_entries[i].size() != this->columnCount())
    259     {
    260       PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount());
    261       retVal = false;
    262     }
     364      {
     365        PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount());
     366        retVal = false;
     367      }
    263368    return retVal;
    264369  }
  • trunk/src/lib/gui/gl/glgui_table.h

    r8619 r8717  
    3939    void setHeader(const std::vector<std::string>& headerNames);
    4040
    41     void setEntry(unsigned int column, unsigned int row, const std::string& name);
     41    void setEntry(unsigned int row, unsigned int column, const std::string& name);
    4242
    4343    void setColumnWidth(unsigned int column, float size);
    4444    void setRowHeight(unsigned int row, unsigned int size);
    4545
    46     virtual void tick(float dt);
    4746    virtual void draw() const;
    4847
     
    6059    virtual bool processEvent(const Event& event);
    6160
    62 
    6361  private:
    6462    void init();
    6563
     64    void pixelPositionToElement(const Vector2D& pixelPosition, int* row, int* column);
     65    void repositionText(unsigned int fromLeft, unsigned int fromTop);
    6666    void applyTextSettings(unsigned int row, unsigned int column, LimitedWidthText* text);
    6767    bool checkIntegrity() const;
    6868
    6969  private:
     70    typedef struct Entry {
     71      Entry(int row, int column) :row(row), column(column) {};
     72      int  row;
     73      int  column;
     74    };
     75
    7076    typedef std::vector<LimitedWidthText> TableTextList;
    7177    TableTextList                _headers;
     78    std::vector<float>           _columnWidths;
     79    std::vector<float>           _rowHeights;
     80
    7281    std::vector<TableTextList>   _entries;     //!< inner is by column, outer is by row.
     82
     83    Entry                        _selected;
     84    Entry                        _focused;
    7385
    7486
  • trunk/src/lib/gui/gl/glgui_widget.cc

    r8619 r8717  
    7272  GLGuiWidget::~GLGuiWidget()
    7373  {
    74     if (this == GLGuiWidget::_focused)
    75       GLGuiWidget::_focused = NULL;
     74    if (this == GLGuiWidget::_mouseFocused)
     75      GLGuiWidget::_mouseFocused = NULL;
     76    if (this == GLGuiWidget::selected())
     77      this->unselect();
    7678  }
    7779
    7880  GLGuiWidget* GLGuiWidget::_selected = NULL;
    79   GLGuiWidget* GLGuiWidget::_focused = NULL;
     81  GLGuiWidget* GLGuiWidget::_mouseFocused = NULL;
    8082  GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
    8183
     
    9193    this->_focusable = false;
    9294    this->_clickable = false;
     95    this->_selectable = false;
    9396    this->_pushed = false;
    9497    this->_state = OrxGui::Normal;
     
    133136  }
    134137
     138
     139  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
     140  {
     141    this->_currentStyle._foreground.setDiffuseColor(frontColor);
     142    this->animateBack();
     143  };
     144
     145
     146  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
     147  {
     148    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
     149        this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
     150  }
     151
     152  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
     153  {
     154    return this->focusOverWidget(cursor->getAbsCoor2D());
     155  }
     156
     157
     158
    135159  /** @brief gives focus to this widget */
    136   void GLGuiWidget::giveFocus()
    137   {
    138     if (GLGuiWidget::focused() != NULL)
    139       GLGuiWidget::focused()->breakFocus();
    140     GLGuiWidget::_focused = this;
     160  void GLGuiWidget::giveMouseFocus()
     161  {
     162    if (this->_state == OrxGui::Insensitive)
     163      return ;
     164
     165    if (GLGuiWidget::mouseFocused() != NULL)
     166      GLGuiWidget::mouseFocused()->breakMouseFocus();
     167    GLGuiWidget::_mouseFocused = this;
     168
     169    this->switchState(OrxGui::Focused);
     170
    141171    this->receivedFocus();
    142172  };
    143173
    144   void GLGuiWidget::breakFocus()
    145   {
    146     if (GLGuiWidget::_focused == this)
     174  void GLGuiWidget::breakMouseFocus()
     175  {
     176    if (GLGuiWidget::_mouseFocused == this)
    147177    {
    148       GLGuiWidget::_focused = NULL;
    149       this->_pushed = false;
     178      GLGuiWidget::_mouseFocused = NULL;
     179
     180      if (GLGuiWidget::_selected != this)
     181        this->switchState(OrxGui::Normal);
     182      else
     183        this->switchState(OrxGui::Selected);
     184
    150185      this->removedFocus();
    151186    }
    152187  };
    153188
    154 
    155   bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
    156   {
    157     return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
    158             this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
    159   }
    160 
    161   bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
    162   {
    163     return this->focusOverWidget(cursor->getAbsCoor2D());
    164   }
    165 
    166 
    167 
    168   void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
    169   {
    170     this->_currentStyle._foreground.setDiffuseColor(frontColor);
    171     this->animateBack();
    172   };
     189  /**
     190   * @brief selects the Widget, unselecting the old one (if existing)
     191   */
     192  void GLGuiWidget::select()
     193  {
     194    if (GLGuiWidget::_selected != NULL)
     195      GLGuiWidget::selected()->unselect();
     196    GLGuiWidget::_selected = this;
     197
     198    this->switchState(OrxGui::Selected);
     199  }
     200
     201  /**
     202   * @brief unselects the current Widget.
     203   *
     204   * if the current Widget is not selected, nothing is done here.
     205   */
     206  void GLGuiWidget::unselect()
     207  {
     208    if (GLGuiWidget::_selected != this)
     209      return;
     210
     211    if (GLGuiWidget::_mouseFocused == this)
     212      this->switchState(OrxGui::Focused);
     213    else
     214      this->switchState(OrxGui::Normal);
     215
     216    GLGuiWidget::_selected = NULL;
     217  }
    173218
    174219
     
    193238    if (this->_pushed)
    194239    {
    195       this->releasing(pos);
     240      this->releasing(pos, GLGuiWidget::_mouseFocused == this);
    196241      this->_pushed = false;
    197242    }
     
    200245
    201246  void GLGuiWidget::clicking(const Vector2D& pos)
    202   {
    203     this->switchState(OrxGui::Selected);
    204   }
    205 
    206   void GLGuiWidget::releasing(const Vector2D& pos)
    207   {
    208     this->switchState(OrxGui::Normal);
    209   }
     247  {}
     248
     249  void GLGuiWidget::releasing(const Vector2D& pos, bool focused)
     250  {}
    210251
    211252  void GLGuiWidget::receivedFocus()
    212253  {
    213     this->switchState(OrxGui::Focused);
    214254  }
    215255
    216256  void GLGuiWidget::removedFocus()
    217257  {
    218     this->switchState(OrxGui::Normal);
    219 
    220   }
    221 
    222   void GLGuiWidget::destroyed()
    223   {}
    224   ;
     258
     259  }
     260
     261  void GLGuiWidget::selecting()
     262  {
     263  }
     264
     265  void GLGuiWidget::unselecting()
     266  {
     267  }
     268
     269
     270  void GLGuiWidget::destroying()
     271  {
     272  }
    225273
    226274
     
    706754    //this->_currentStyle = this->_style[state];
    707755    this->_state = state;
    708     PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
     756    PRINTF(3)("%s::%s Switches to state %s\n", this->getClassName(), this->getName(), OrxGui::StateString[state].c_str());
    709757
    710758    this->animateBack();
     
    762810    for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
    763811      if (stateName == OrxGui::StateString[i])
    764     {
    765       *state = (OrxGui::State)i;
    766       return true;
    767     }
     812      {
     813        *state = (OrxGui::State)i;
     814        return true;
     815      }
    768816    return false;
    769817  }
     
    772820   * @brief print out some nice debug output about the Widget.
    773821   */
    774   void GLGuiWidget::debug() const
     822  void GLGuiWidget::debug(unsigned int level) const
    775823  {
    776824    PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
  • trunk/src/lib/gui/gl/glgui_widget.h

    r8619 r8717  
    4242
    4343    /// FOCUS
    44     /** @brief gives focus to this widget */
    45     void giveFocus();
    46     void breakFocus();
     44    /** @brief gives mouse - focus to this widget */
     45    void giveMouseFocus();
     46    void breakMouseFocus();
     47
    4748    /** @returns true if the widget is focusable */
    4849    bool focusable() const { return this->_focusable; };
    49     /** @param focusable sets if the Widget should be focusable */
    50     void setFocusable(bool focusable = true) { this->_focusable = focusable; };
    5150    /** @returns true if the position is inside of the Widget. @param position the position to check */
    5251    bool focusOverWidget(const Vector2D& position) const;
     
    5453    bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const;
    5554
    56     /** @returns the currently focused Widget (NULL if none is selected) */
    57     static GLGuiWidget* focused() { return GLGuiWidget::_focused; };
    58 
     55    /** @returns the currently mouse - focused Widget (NULL if none is focused). */
     56    static GLGuiWidget* mouseFocused() { return GLGuiWidget::_mouseFocused; };
     57
     58    /// SELECT
     59    void select();
     60    void unselect();
     61    /** @returns true if the Widget is selectable */
     62    bool selectable() const { return this->_selectable; }
     63
     64    /** @returns the currently Selected Widget (NULL if none is selected). */
     65    static GLGuiWidget* selected() { return GLGuiWidget::_selected; };
    5966
    6067    /// CLICK
     68    bool pushed() { return _pushed; };
    6169    void click(const Vector2D& pos);
    6270    void release(const Vector2D& pos);
    6371    bool clickable() const { return this->_clickable; };
    64     void setClickable(bool clickable = true) { this->_clickable = clickable; };
    6572
    6673    static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor);
     
    8188    void animateBack();
    8289
    83     /// STYLE
     90    ///////////////////////////////////////////////////////////////////////////////////
     91    /// STYLE /////////////////////////////////////////////////////////////////////////
    8492    ////////////////////////////////
    8593    /// Retrieve Current Values. ///
     
    201209    void setAnimatedStateChanges(bool animated);
    202210    void switchState(OrxGui::State state);
    203 
     211    ///////////////////////////////////////////////////////////////////////////////////
    204212
    205213
     
    225233
    226234  protected:
     235    /** @param focusable sets if the Widget should be focusable */
     236    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
     237    /** @param selectable true if the widget should be selectable */
     238    void setSelectable(bool selectable) { this->_selectable = selectable; }
     239    /** @param focusable true if the widget should be focusable */
     240    void setClickable(bool clickable = true) { this->_clickable = clickable; };
     241
     242
     243    /// RENDERING
     244    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
     245    inline void endDraw() const { glPopMatrix(); };
     246
     247
    227248    /// LOOKS
    228249    virtual void resize();
     
    230251    virtual void hiding() {};
    231252    virtual void showing() {};
     253
    232254    virtual void updateFrontColor() {};
    233255
    234     inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
    235     inline void endDraw() const { glPopMatrix(); };
    236256
    237257    /// EVENTS
    238     // if something was clickt on the GUI-widget.
     258    // mouse clicking
    239259    virtual void clicking(const Vector2D& pos);
    240     virtual void releasing(const Vector2D& pos);
     260    virtual void releasing(const Vector2D& pos, bool focused);
     261    // mouse focusing
    241262    virtual void receivedFocus();
    242263    virtual void removedFocus();
    243 
    244     virtual void destroyed();
    245 
    246     virtual void debug() const;
     264    // selecting either with the mouse by clicking, or by the keybord traversing to it.
     265    virtual void selecting();
     266    virtual void unselecting();
     267    // destroying the Widget.
     268    virtual void destroying();
     269
     270
     271    virtual void debug(unsigned int level) const;
    247272
    248273  private:
     
    251276  private:
    252277    static GLGuiWidget*            _selected;         //!< The currently selected Widget.
    253     static GLGuiWidget*            _focused;          //!< The currently Focused Widget.
    254     static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input.
     278    static GLGuiWidget*            _mouseFocused;     //!< The currently Focused Widget (mouse-focus).
     279    static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input (keyboard-focus).
    255280
    256281
     
    265290    /// EVENTS
    266291    OrxGui::State                  _state;
     292    bool                           _pushed;
    267293
    268294    bool                           _focusable;        //!< If this widget can receive focus.
    269295    bool                           _clickable;        //!< if this widget can be clicked upon.
    270 
    271     bool                           _pushed;
     296    bool                           _selectable;       //!< If this widget can be selected.
     297
    272298
    273299
     
    276302    typedef struct
    277303    {
    278       float             _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
    279       float             _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
    280       float             _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
    281       float             _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
    282 
    283       float             _textSize;             //!< The TextSize of the Widget.
    284 
    285       Material          _background;           //!< The Background Material of the Widget.
    286 
    287       Material          _foreground;           //!< The foreground Material of the Widget.
     304      float                        _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
     305      float                        _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
     306      float                        _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
     307      float                        _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
     308
     309      float                        _textSize;             //!< The TextSize of the Widget.
     310
     311      Material                     _background;           //!< The Background Material of the Widget.
     312
     313      Material                     _foreground;           //!< The foreground Material of the Widget.
    288314    }
    289315    StatedStyle;
    290316
    291317
    292     StatedStyle         _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States
    293 
    294     FeaturePosition     _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
    295     Font*               _font;                 //!< The Font used in the current Widget.
     318    StatedStyle                    _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States
     319
     320    FeaturePosition                _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
     321    Font*                          _font;                 //!< The Font used in the current Widget.
    296322
    297323
    298324    /// ANIMATION STUFF:
    299     bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
    300 
    301     bool                _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
    302     float               _animationCycle;
    303     float               _animationDuration;
    304     StatedStyle         _currentStyle;
     325    bool                           _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
     326
     327    bool                           _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
     328    float                          _animationCycle;
     329    float                          _animationDuration;
     330    StatedStyle                    _currentStyle;
    305331
    306332  };
  • trunk/src/lib/util/loading/game_loader.cc

    r7868 r8717  
    7373  this->subscribeEvent(ES_GAME, KeyMapper::PEV_NEXT_WORLD);
    7474  this->subscribeEvent(ES_GAME, KeyMapper::PEV_PREVIOUS_WORLD);
     75
     76  return ErrorMessage();
    7577}
    7678
     
    9193    this->currentCampaign = this->fileToCampaign(campaignName);
    9294  }
     95
     96  return ErrorMessage();
    9397}
    9498
     
    109113    this->currentCampaign = this->fileToCampaign(campaignName);
    110114  }
     115
     116  return ErrorMessage();
    111117}
    112118
     
    147153      }
    148154  }
     155
     156  return ErrorMessage();
    149157}
    150158
     
    160168    this->currentCampaign->start();
    161169  }
     170
     171  return ErrorMessage();
    162172}
    163173
     
    191201  if(this->currentCampaign != NULL)
    192202    this->currentCampaign->pause();
     203
     204  return ErrorMessage();
    193205}
    194206
     
    205217  if(this->currentCampaign != NULL)
    206218    this->currentCampaign->resume();
     219
     220  return ErrorMessage();
    207221}
    208222
  • trunk/src/story_entities/Makefile.am

    r6634 r8717  
    1313                story_entities/multi_player_world_data.cc \
    1414                story_entities/movie_loader.cc \
    15                 story_entities/simple_game_menu.cc
     15                story_entities/simple_game_menu.cc \
     16                \
     17                story_entities/menu/game_menu.cc \
     18                story_entities/menu/glgui_imagebutton.cc
    1619
    1720StoryEntities_HEADERS_ = \
     
    2730                story_entities/multi_player_world_data.h \
    2831                story_entities/movie_loader.h \
    29                 story_entities/simple_game_menu.h
     32                story_entities/simple_game_menu.h \
     33                \
     34                story_entities/menu/game_menu.h \
     35                story_entities/menu/glgui_imagebutton.h
     36
  • trunk/src/story_entities/campaign.cc

    r7283 r8717  
    8282  this->bReturnToMenu = false;
    8383  this->run();
     84
     85  return true;
    8486}
    8587
     
    9092bool Campaign::pause()
    9193{
    92   this->bPaused = true;
     94  return (this->bPaused = true);
    9395}
    9496
     
    100102{
    101103  PRINTF(4)("Resuming the current Campaign\n");
    102   this->bPaused = false;
     104  return (this->bPaused = false);
    103105}
    104106
     
    118120    this->currentEntity->stop();
    119121  }
     122
     123  return true;
    120124}
    121125
     
    127131{
    128132  ErrorMessage       errorCode;
    129   int                storyID = WORLD_ID_0;
     133//  int                storyID = WORLD_ID_0;
    130134
    131135  for( this->currentEntity = this->campaignData->getFirstLevel(), this->bRunning = true;
  • trunk/src/story_entities/game_world.cc

    r8711 r8717  
    140140  State::setScriptManager(&this->scriptManager);
    141141
     142  return ErrorMessage();
    142143}
    143144
     
    153154
    154155  PRINTF(3)("> Loading world: '%s'\n", getLoadFile().c_str());
    155   TiXmlElement* element;
    156   GameLoader* loader = GameLoader::getInstance();
     156//  TiXmlElement* element;
     157//  GameLoader* loader = GameLoader::getInstance();
    157158
    158159  if( getLoadFile().empty())
    159160  {
    160161    PRINTF(1)("GameWorld has no path specified for loading\n");
    161     return (ErrorMessage){213,"Path not specified","GameWorld::load()"};
     162    return (ErrorMessage(213,"Path not specified","GameWorld::load()"));
    162163  }
    163164
     
    168169    PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol());
    169170    delete XMLDoc;
    170     return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};
     171    return ErrorMessage(213,"XML File parsing error","GameWorld::load()");
    171172  }
    172173  // check basic validity
     
    178179    PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n");
    179180    delete XMLDoc;
    180     return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"};
     181    return ErrorMessage(213,"Path not a WorldDataFile","GameWorld::load()");
    181182  }
    182183  /* the whole loading process for the GameWorld */
     
    191192  //Account *b = new Account(30);
    192193  //b->setName("b");
     194
    193195 
    194196  LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams);
     
    196198  delete XMLDoc;
    197199  this->releaseLoadScreen();
     200
     201  return ErrorMessage();
    198202}
    199203
     
    220224  if (this->dataXML)
    221225    delete this->dataXML;
     226
     227  return ErrorMessage();
    222228}
    223229
     
    232238  State::setScriptManager(&this->scriptManager); //make sure we have the right script manager
    233239  this->run();
     240
     241  return true;
    234242}
    235243
     
    242250  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    243251  State::setScriptManager(NULL);
    244   this->bRunning = false;
     252  return (this->bRunning = false);
    245253}
    246254
     
    251259bool GameWorld::pause()
    252260{
    253   this->bPaused = true;
     261  return (this->bPaused = true);
    254262}
    255263
     
    260268bool GameWorld::resume()
    261269{
    262   this->bPaused = false;
     270  return(this->bPaused = false);
    263271}
    264272
     
    410418    if( likely(this->dataTank->gameRule != NULL))
    411419      this->dataTank->gameRule->tick(this->dtS);
    412      
     420
    413421  }
    414422}
  • trunk/src/story_entities/game_world_data.cc

    r8490 r8717  
    108108
    109109  GraphicsEngine::getInstance()->displayFPS(true);
     110
     111  return ErrorMessage();
    110112}
    111113
     
    131133  this->loadWorldEntities(root);
    132134  this->loadScene(root);
     135
     136  return ErrorMessage();
    133137}
    134138
     
    142146  this->unloadWorldEntities();
    143147  this->unloadScene();
     148
     149  return ErrorMessage();
    144150}
    145151
     
    166172  }
    167173  this->glmis->draw();
     174
     175  return ErrorMessage();
    168176}
    169177
     
    175183{
    176184  delete this->glmis;
     185
     186  return ErrorMessage();
    177187}
    178188
     
    250260  /* init the pnode tree */
    251261  PNode::getNullParent()->init();
     262
     263  return ErrorMessage();
    252264}
    253265
     
    312324
    313325  this->glmis = NULL;
     326
     327  return ErrorMessage();
    314328}
    315329
     
    337351    this->localCamera->addChild(this->sky);
    338352  OrxSound::SoundEngine::getInstance()->setListener(this->localCamera);
     353
     354  return ErrorMessage();
    339355}
    340356
     
    357373
    358374  State::setGameRules(NULL);
     375
     376  return ErrorMessage();
    359377}
    360378
  • trunk/src/story_entities/menu/game_menu.cc

    r8713 r8717  
    178178      image->setWidgetSize( 250, 200);
    179179      image->setAbsCoor2D(400, 150);
     180      image->setForegroundColor(Color(1,1,1,.6));
    180181
    181182      const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY);
  • trunk/src/story_entities/multi_player_world.cc

    r8228 r8717  
    123123/**
    124124 * cleanup
    125  * @return 
     125 * @return
    126126 */
    127127ErrorMessage MultiPlayerWorld::unloadData( )
    128128{
    129    
     129
    130130  GameWorld::unloadData();
    131  
     131
    132132  delete NetworkManager::getInstance();
    133133  delete NetworkGameManager::getInstance();
    134134
     135  return ErrorMessage();
    135136}
  • trunk/src/story_entities/multi_player_world_data.cc

    r8490 r8717  
    7878{
    7979  /* call underlying function */
    80   GameWorldData::init();
     80  return GameWorldData::init();
    8181}
    8282
     
    8989{
    9090  /* call underlying function */
    91   GameWorldData::loadGUI(root);
     91  return GameWorldData::loadGUI(root);
    9292}
    9393
     
    9999{
    100100  /* call underlying function */
    101   GameWorldData::unloadGUI();
     101  return GameWorldData::unloadGUI();
    102102}
    103103
     
    245245  this->drawLists.push_back(OM_GROUP_01);
    246246  this->drawLists.push_back(OM_GROUP_01_PROJ);
    247  
     247
    248248  State::setPlayer(this->localPlayer);
    249  
     249
     250  return ErrorMessage();
    250251}
    251252
     
    257258{
    258259  /* call underlying function */
    259   GameWorldData::unloadWorldEntities();
     260  return GameWorldData::unloadWorldEntities();
    260261}
    261262
     
    269270  /* call underlying function */
    270271  GameWorldData::loadScene(root);
    271  
     272
    272273  // create server playable
    273274  if ( NetworkManager::getInstance()->isGameServer() )
     
    276277    State::getPlayer()->setPlayable( PlayerStats::getStats( 0 )->getPlayable() );
    277278  }
     279
     280  return ErrorMessage();
    278281}
    279282
     
    285288{
    286289  /* call underlying function */
    287   GameWorldData::unloadScene();
     290  return GameWorldData::unloadScene();
    288291}
    289292
  • trunk/src/story_entities/simple_game_menu.cc

    r8619 r8717  
    131131    headers.push_back("3");
    132132    table->setHeader(headers);
     133    table->setEntry(1, 2, "Test");
     134    table->setEntry(2, 1, "MultiLine SuperTest to see how it works");
    133135
    134136
  • trunk/src/story_entities/single_player_world_data.cc

    r7370 r8717  
    4545{
    4646  /* call underlying function */
    47   GameWorldData::init();
     47  return GameWorldData::init();
    4848}
    4949
     
    5656{
    5757  /* call underlying function */
    58   GameWorldData::loadGUI(root);
     58  return GameWorldData::loadGUI(root);
    5959}
    6060
     
    6666{
    6767  /* call underlying function */
    68   GameWorldData::unloadGUI();
     68  return GameWorldData::unloadGUI();
    6969}
    7070
     
    7777{
    7878  /* call underlying function */
    79   GameWorldData::loadWorldEntities(root);
     79  return GameWorldData::loadWorldEntities(root);
    8080}
    8181
     
    8787{
    8888  /* call underlying function */
    89   GameWorldData::unloadWorldEntities();
     89  return GameWorldData::unloadWorldEntities();
    9090}
    9191
     
    9898{
    9999  /* call underlying function */
    100   GameWorldData::loadScene(root);
     100  return GameWorldData::loadScene(root);
    101101}
    102102
     
    108108{
    109109  /* call underlying function */
    110   GameWorldData::unloadScene();
     110  return GameWorldData::unloadScene();
    111111}
    112112
  • trunk/src/story_entities/story_entity.h

    r7283 r8717  
    3535  /* initialisation and loading */
    3636  /** initializes a Story Entity to the needed values */
    37   virtual ErrorMessage init() {};
     37  virtual ErrorMessage init() { return ErrorMessage(); };
    3838  /** called to load the data into the StoryEntity*/
    39   virtual ErrorMessage loadData() {};
     39  virtual ErrorMessage loadData() { return ErrorMessage(); };
    4040  /** function that unloads the data from the StoryEntity */
    41   virtual ErrorMessage unloadData() {};
     41  virtual ErrorMessage unloadData() { return ErrorMessage(); };
    4242
    4343  /* running, stopping and pausing */
  • trunk/src/util/multiplayer_team_deathmatch.cc

    r8708 r8717  
    6868  this->gameStateTimer = 10.0f;
    6969  this->bShowTeamChange = false;
    70  
     70
    7171  this->box = NULL;
    7272
     
    8080  if( root != NULL)
    8181    this->loadParams(root);
    82  
     82
    8383  subscribeEvent( ES_GAME, SDLK_o );
    8484  subscribeEvent( ES_GAME, SDLK_TAB );
    85  
     85
    8686  this->notifier = new OrxGui::GLGuiNotifier();
    8787  this->notifier->show();
     
    101101  if( this->deathScreen)
    102102    delete this->deathScreen;
    103  
     103
    104104  unsubscribeEvent( ES_GAME, SDLK_o );
    105105  unsubscribeEvent( ES_GAME, SDLK_TAB );
    106  
     106
    107107  if ( this->notifier )
    108108  {
     
    110110    this->notifier = NULL;
    111111  }
    112  
     112
    113113  if ( this->input )
    114114  {
     
    132132  LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen)
    133133      .describe("sets the death screen image");
    134  
     134
    135135  LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams)
    136136      .describe("sets number of teams");
     
    179179  if ( SharedNetworkData::getInstance()->getHostID() < 0 )
    180180    return;
    181  
     181
    182182  if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME )
    183183  {
    184184    if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    185185         && box == NULL
    186          &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 
     186         &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
    187187         || bShowTeamChange )
    188          
     188
    189189       )
    190190    {
    191191      EventHandler::getInstance()->pushState( ES_MENU );
    192      
     192
    193193      OrxGui::GLGuiHandler::getInstance()->activateCursor();
    194      
     194
    195195      box = new OrxGui::GLGuiBox();
    196196      box->setAbsCoor2D( 300, 100 );
    197      
     197
    198198      OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator");
    199199      box->pack( buttonSpectator );
    200200      buttonSpectator->connect(SIGNAL(buttonSpectator, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonSpectator));
    201      
     201
    202202      OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random");
    203203      box->pack( buttonRandom );
    204204      buttonRandom->connect(SIGNAL(buttonRandom, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonRandom));
    205      
     205
    206206      OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team");
    207207      box->pack( buttonTeam0 );
    208208      buttonTeam0->connect(SIGNAL(buttonTeam0, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam0));
    209      
     209
    210210      OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team");
    211211      box->pack( buttonTeam1 );
    212212      buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1));
    213      
     213
    214214      if ( bShowTeamChange )
    215215      {
     
    218218        buttonCancel->connect(SIGNAL(buttonCancel, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonCancel));
    219219      }
    220      
     220
    221221      OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit");
    222222      box->pack( buttonExit );
    223223      buttonExit->connect(SIGNAL(buttonExit, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonExit));
    224      
     224
    225225      box->showAll();
    226226    }
     
    229229  if ( box != NULL
    230230       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    231        && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 
     231       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM
    232232       && !bShowTeamChange
    233233     )
     
    235235    delete box;
    236236    box = NULL;
    237      
     237
    238238    OrxGui::GLGuiHandler::getInstance()->deactivateCursor( true );
    239      
     239
    240240    EventHandler::getInstance()->popState();
    241241  }
    242  
     242
    243243  if ( box != NULL )
    244244  {
    245245    OrxGui::GLGuiHandler::getInstance()->tick( dt );
    246246  }
    247  
     247
    248248  assignPlayable();
    249  
     249
    250250  if ( !SharedNetworkData::getInstance()->isGameServer() )
    251251    return;
    252  
     252
    253253  gameStateTimer -= dt;
    254254  //PRINTF(0)("TICK %f\n", gameStateTimer);
    255  
     255
    256256  if ( currentGameState != GAMESTATE_GAME && gameStateTimer < 0 )
    257257    nextGameState();
    258  
     258
    259259  this->currentGameState = NetworkGameManager::getInstance()->getGameState();
    260  
     260
    261261  if ( currentGameState == GAMESTATE_GAME )
    262262  {
    263263    handleTeamChanges();
    264264  }
    265  
     265
    266266  this->calculateTeamScore();
    267  
     267
    268268  this->checkGameRules();
    269269
     
    304304  if ( !SharedNetworkData::getInstance()->isGameServer() )
    305305    return;
    306  
     306
    307307  // check for max killing count
    308308  for ( int i = 0; i<numTeams; i++ )
     
    329329  if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR )
    330330    return CL_SPECTATOR;
    331  
     331
    332332  if ( team == 0 || team == 1 )
    333333    return CL_SPACE_SHIP;
    334  
     334
    335335  assert( false );
    336336}
     
    352352{
    353353  teamScore.clear();
    354  
     354
    355355  for ( int i = 0; i<numTeams; i++ )
    356356    teamScore[i] = 0;
    357  
    358    
     357
     358
    359359  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    360  
     360
    361361  if ( !list )
    362362    return;
    363  
     363
    364364  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    365365  {
     
    380380{
    381381  std::map<int,int> playersInTeam;
    382  
     382
    383383  for ( int i = 0; i<numTeams; i++ )
    384384    playersInTeam[i] = 0;
    385  
     385
    386386  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    387  
     387
    388388  if ( !list )
    389389    return 0;
    390  
     390
    391391  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
    392392  {
     
    398398    }
    399399  }
    400  
    401  
     400
     401
    402402  int minPlayers = 0xFFFF;
    403403  int minTeam = -1;
    404  
     404
    405405  for ( int i = 0; i<numTeams; i++ )
    406406  {
     
    411411    }
    412412  }
    413  
     413
    414414  assert( minTeam != -1 );
    415  
     415
    416416  return minTeam;
    417417}
     
    422422  {
    423423    NetworkGameManager::getInstance()->setGameState( GAMESTATE_GAME );
    424    
    425     return;
    426   }
    427  
     424
     425    return;
     426  }
     427
    428428  if ( currentGameState == GAMESTATE_GAME )
    429429  {
    430430    NetworkGameManager::getInstance()->setGameState( GAMESTATE_POST_GAME );
    431    
    432     return;
    433   }
    434  
     431
     432    return;
     433  }
     434
    435435  if ( currentGameState == GAMESTATE_POST_GAME )
    436436  {
    437437    //TODO end game
    438    
     438
    439439    return;
    440440  }
     
    444444{
    445445  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
    446  
     446
    447447  if ( !list )
    448448    return;
    449  
     449
    450450  //first server players with choices
    451451  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    461461    }
    462462  }
    463  
     463
    464464  //now serve player who want join a random team
    465465  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
     
    482482  assert( PlayerStats::getStats( userId ) );
    483483  PlayerStats & stats = *(PlayerStats::getStats( userId ));
    484  
     484
    485485  stats.setTeamId( stats.getPreferedTeamId() );
    486  
     486
    487487  Playable * oldPlayable = stats.getPlayable();
    488  
    489  
     488
     489
    490490  ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
    491491  std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
    492  
     492
    493493  BaseObject * bo = Factory::fabricate( playableClassId );
    494  
     494
    495495  assert( bo != NULL );
    496496  assert( bo->isA( CL_PLAYABLE ) );
    497  
     497
    498498  Playable & playable = *(dynamic_cast<Playable*>(bo));
    499  
     499
    500500  playable.loadModel( playableModel );
    501501  playable.setOwner( userId );
    502502  playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
    503503  playable.setSynchronized( true );
    504  
     504
    505505  stats.setTeamId( stats.getPreferedTeamId() );
    506506  stats.setPlayableClassId( playableClassId );
    507507  stats.setPlayableUniqueId( playable.getUniqueID() );
    508508  stats.setModelFileName( playableModel );
    509  
     509
    510510  if ( oldPlayable )
    511511  {
     
    572572      OrxGui::GLGuiHandler::getInstance()->deactivateCursor();
    573573      input->show();
    574       input->giveFocus();
     574      input->giveMouseFocus();
    575575      input->setText("say ");
    576576    }
     
    594594{
    595595  std::string name = "unknown";
    596  
     596
    597597  if ( PlayerStats::getStats( userId ) )
    598598  {
    599599    name = PlayerStats::getStats( userId )->getNickName();
    600600  }
    601  
     601
    602602  PRINTF(0)("CHATMESSAGE %s (%d): %s\n", name.c_str(), userId, message.c_str() );
    603603  notifier->pushNotifyMessage(name + ": " + message);
     
    607607{
    608608  EventHandler::getInstance()->popState();
    609   input->breakFocus();
     609  input->breakMouseFocus();
    610610  input->hide();
    611611  input->setText("");
    612612
    613613  std::string command = text;
    614  
     614
    615615  //HACK insert " in say commands so user doesn't have to type them
    616616  if ( command.length() >= 4 && command[0] == 's' && command[1] == 'a' && command[2] == 'y' && command[3] == ' ' )
Note: See TracChangeset for help on using the changeset viewer.