Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8324 in orxonox.OLD for trunk/src/lib/gui


Ignore:
Timestamp:
Jun 12, 2006, 12:40:57 AM (19 years ago)
Author:
bensch
Message:

trunk: Texture-Sequence is initialized smoothly now in the GLGuiCursor

Location:
trunk/src/lib/gui/gl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/gui/gl/glgui_cursor.cc

    r8312 r8324  
    2020#include "glgui_handler.h"
    2121#include "color.h"
    22 #include "texture_sequence.h"
    23 #include "loading/resource_manager.h" // HACK
    2422
    2523namespace OrxGui
     
    6765    this->color = 0.0f;
    6866
    69     this->seq = new TextureSequence();
    70     this->seq->loadImageSeries(ResourceManager::getInstance()->getDataDir() + "/maps/reap_mouse/reap_mouse_##.tif", 0, 49);
     67    this->resize();
     68  }
    7169
    72     this->resize();
     70  /**
     71   * @brief Loads an Image-Series onto the Cursor.
     72   * @param imageNameSubstitue The Prefix of the Image
     73   * @param from From which image
     74   * @param to To which image
     75   * @return true on success.
     76   *
     77   * @see TextureSequence:: loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
     78   */
     79  bool GLGuiCursor::loadTextureSequence(const std::string& imageNameSubstitue, unsigned int from, unsigned int to)
     80  {
     81    this->backMaterial().setDiffuse(1.0, 1.0, 1.0);
     82    return this->seq.loadImageSeries(imageNameSubstitue, from, to);
    7383  }
    7484
    7585  void GLGuiCursor::tick(float dt)
    7686  {
    77     this->frameNumber += 25.0*dt;
    78     if (frameNumber >= this->seq->getFrameCount())
    79       frameNumber = 0.0;
    80 
    81     this->color += dt*10.0;
    82     if (this->color > 360.0)
    83       this->color -= 360.0;
    84     Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
    85     this->backMaterial().setDiffuse(color.x, color.y, color.z);
    86 
     87    if (!this->seq.empty())
     88    {
     89      this->frameNumber += 25.0*dt;
     90      if (frameNumber >= this->seq.getFrameCount())
     91        frameNumber = 0.0;
     92    }
     93    else
     94    {
     95      this->color += dt*10.0;
     96      if (this->color > 360.0)
     97        this->color -= 360.0;
     98      Vector color =  Color::HSVtoRGB(Vector(this->color, 1.0, 1.0));
     99      this->backMaterial().setDiffuse(color.x, color.y, color.z);
     100    }
    87101    //if (this->movement != Vector2D())
    88102    {
     
    110124  {
    111125    this->beginDraw();
    112     // HACK
    113     glActiveTexture(GL_TEXTURE0);
    114     glEnable(GL_TEXTURE_2D);
    115     glBindTexture(GL_TEXTURE_2D, this->seq->getFrameTexture((int)frameNumber));
    116     glColor3f(1,1,1);
    117     glEnable(GL_BLEND);
    118     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     126
     127    this->backMaterial().select();
     128    if (!this->seq.empty())
     129      glBindTexture(GL_TEXTURE_2D, this->seq.getFrameTexture((int)frameNumber));
    119130    this->drawRect(this->backRect());
    120131
     
    123134  }
    124135
     136  /**
     137   * @brief processes Events from the EventHandler.
     138   * @param event the Event to process.
     139   */
    125140  void GLGuiCursor::process(const Event& event)
    126141  {
  • trunk/src/lib/gui/gl/glgui_cursor.h

    r8299 r8324  
    1111#include "event_listener.h"
    1212#include "vector2D.h"
     13
     14#include "texture_sequence.h"
    1315
    1416class TextureSequence;
     
    2931    virtual ~GLGuiCursor();
    3032
     33
     34    bool loadTextureSequence(const std::string& imagePrefix, unsigned int from, unsigned int to);
     35
     36
     37    const Vector2D& position() const { return Element2D::getAbsCoor2D(); }
     38
     39    void setMaxBorders(const Vector2D& maxBorders) { this->_maxBorders = maxBorders; };
    3140    static void setMouseSensitivity(float mouseSensitivity);
    3241    static float mouseSensitivity() { return GLGuiCursor::_mouseSensitivity; };
    33 
    34     void setMaxBorders(const Vector2D& maxBorders) { this->_maxBorders = maxBorders; };
    35 
    36     void init();
    37     const Vector2D& position() const { return Element2D::getAbsCoor2D(); }
    3842
    3943
     
    4145    virtual void draw() const;
    4246    virtual void process(const Event& event);
     47
     48  private:
     49    void init();
     50
    4351  private:
    4452
     
    5058    float         color; // so f****ing temporary... ... ....
    5159
    52     static float _mouseSensitivity;
    53     TextureSequence* seq;
    54     float frameNumber;
     60    static float        _mouseSensitivity;
     61    TextureSequence    seq;
     62    float               frameNumber;
    5563
    5664  };
  • trunk/src/lib/gui/gl/glgui_handler.cc

    r8312 r8324  
    4242    EventHandler::getInstance()->withUNICODE(ES_ALL, true );
    4343
    44     this->cursor = NULL;
     44    this->_cursor = NULL;
    4545    for (unsigned int i = 0; i < EV_NUMBER; i++)
    4646    {
     
    6464  void GLGuiHandler::activateCursor()
    6565  {
    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()));
     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()));
    7070  }
    7171
    7272  void GLGuiHandler::deactivateCursor(bool deleteCursor)
    7373  {
    74     if (this->cursor)
     74    if (this->_cursor)
    7575    {
    7676      if (deleteCursor)
    77         delete this->cursor;
    78       this->cursor = NULL;
     77        delete this->_cursor;
     78      this->_cursor = NULL;
    7979    }
    8080  }
     
    108108            if (GLGuiWidget::focused()->clickable())
    109109            {
    110               Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     110              Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
    111111              GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
    112112            }
     
    116116            if (GLGuiWidget::focused()->clickable())
    117117            {
    118               Vector2D cursorPos = (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
     118              Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
    119119              GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
    120120            }
     
    128128
    129129      case EV_VIDEO_RESIZE:
    130         if (this->cursor != NULL)
    131           this->cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
     130        if (this->_cursor != NULL)
     131          this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
    132132        break;
    133133    }
     
    147147  Vector2D GLGuiHandler::cursorPositionOverFocusedWidget() const
    148148  {
    149     return (this->cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(0,0);
     149    return (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(0,0);
    150150  }
    151151
    152152  const Vector2D& GLGuiHandler::cursorPositionAbs() const
    153153  {
    154     if (this->cursor)
    155       return this->cursor->getAbsCoor2D();
     154    if (this->_cursor)
     155      return this->_cursor->getAbsCoor2D();
    156156    else
    157157      return Vector2D::nullVector();
     
    160160  {
    161161    assert (widget != NULL);
    162     if (this->cursor)
    163       return  this->cursor->getAbsCoor2D() - widget->getAbsCoor2D();
     162    if (this->_cursor)
     163      return  this->_cursor->getAbsCoor2D() - widget->getAbsCoor2D();
    164164    else
    165165      return Vector2D::nullVector();
     
    179179    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
    180180
    181     if (objects != NULL && this->cursor != NULL)
     181    if (objects != NULL && this->_cursor != NULL)
    182182    {
    183183      for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++)
     
    187187        if (widget->isVisible() &&
    188188            widget->focusable() &&
    189             widget->focusOverWidget(this->cursor))
     189            widget->focusOverWidget(this->_cursor))
    190190        {
    191191          // receiving Focus
  • trunk/src/lib/gui/gl/glgui_handler.h

    r8145 r8324  
    2828    void activateCursor();
    2929    void deactivateCursor(/** ignore param */ bool deleteCursor = true);
    30     GLGuiCursor* getCursor() const { return this->cursor; }
     30    GLGuiCursor* cursor() const { return this->_cursor; }
    3131
    3232    Vector2D cursorPositionOverFocusedWidget() const;
     
    4848
    4949    bool                 isActive;
    50     GLGuiCursor*         cursor;
     50    GLGuiCursor*         _cursor;
    5151
    5252  };
Note: See TracChangeset for help on using the changeset viewer.