Changeset 8324 in orxonox.OLD for trunk/src/lib/gui/gl
- Timestamp:
- Jun 12, 2006, 12:40:57 AM (18 years ago)
- Location:
- trunk/src/lib/gui/gl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/glgui_cursor.cc
r8312 r8324 20 20 #include "glgui_handler.h" 21 21 #include "color.h" 22 #include "texture_sequence.h"23 #include "loading/resource_manager.h" // HACK24 22 25 23 namespace OrxGui … … 67 65 this->color = 0.0f; 68 66 69 this-> seq = new TextureSequence();70 this->seq->loadImageSeries(ResourceManager::getInstance()->getDataDir() + "/maps/reap_mouse/reap_mouse_##.tif", 0, 49);67 this->resize(); 68 } 71 69 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); 73 83 } 74 84 75 85 void GLGuiCursor::tick(float dt) 76 86 { 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 } 87 101 //if (this->movement != Vector2D()) 88 102 { … … 110 124 { 111 125 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)); 119 130 this->drawRect(this->backRect()); 120 131 … … 123 134 } 124 135 136 /** 137 * @brief processes Events from the EventHandler. 138 * @param event the Event to process. 139 */ 125 140 void GLGuiCursor::process(const Event& event) 126 141 { -
trunk/src/lib/gui/gl/glgui_cursor.h
r8299 r8324 11 11 #include "event_listener.h" 12 12 #include "vector2D.h" 13 14 #include "texture_sequence.h" 13 15 14 16 class TextureSequence; … … 29 31 virtual ~GLGuiCursor(); 30 32 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; }; 31 40 static void setMouseSensitivity(float mouseSensitivity); 32 41 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(); }38 42 39 43 … … 41 45 virtual void draw() const; 42 46 virtual void process(const Event& event); 47 48 private: 49 void init(); 50 43 51 private: 44 52 … … 50 58 float color; // so f****ing temporary... ... .... 51 59 52 static float _mouseSensitivity;53 TextureSequence *seq;54 float frameNumber;60 static float _mouseSensitivity; 61 TextureSequence seq; 62 float frameNumber; 55 63 56 64 }; -
trunk/src/lib/gui/gl/glgui_handler.cc
r8312 r8324 42 42 EventHandler::getInstance()->withUNICODE(ES_ALL, true ); 43 43 44 this-> cursor = NULL;44 this->_cursor = NULL; 45 45 for (unsigned int i = 0; i < EV_NUMBER; i++) 46 46 { … … 64 64 void GLGuiHandler::activateCursor() 65 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()));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 70 } 71 71 72 72 void GLGuiHandler::deactivateCursor(bool deleteCursor) 73 73 { 74 if (this-> cursor)74 if (this->_cursor) 75 75 { 76 76 if (deleteCursor) 77 delete this-> cursor;78 this-> cursor = NULL;77 delete this->_cursor; 78 this->_cursor = NULL; 79 79 } 80 80 } … … 108 108 if (GLGuiWidget::focused()->clickable()) 109 109 { 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); 111 111 GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D()); 112 112 } … … 116 116 if (GLGuiWidget::focused()->clickable()) 117 117 { 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); 119 119 GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D()); 120 120 } … … 128 128 129 129 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)); 132 132 break; 133 133 } … … 147 147 Vector2D GLGuiHandler::cursorPositionOverFocusedWidget() const 148 148 { 149 return (this-> cursor != NULL) ? this->cursor->getAbsCoor2D() : Vector2D(0,0);149 return (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(0,0); 150 150 } 151 151 152 152 const Vector2D& GLGuiHandler::cursorPositionAbs() const 153 153 { 154 if (this-> cursor)155 return this-> cursor->getAbsCoor2D();154 if (this->_cursor) 155 return this->_cursor->getAbsCoor2D(); 156 156 else 157 157 return Vector2D::nullVector(); … … 160 160 { 161 161 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(); 164 164 else 165 165 return Vector2D::nullVector(); … … 179 179 const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET); 180 180 181 if (objects != NULL && this-> cursor != NULL)181 if (objects != NULL && this->_cursor != NULL) 182 182 { 183 183 for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++) … … 187 187 if (widget->isVisible() && 188 188 widget->focusable() && 189 widget->focusOverWidget(this-> cursor))189 widget->focusOverWidget(this->_cursor)) 190 190 { 191 191 // receiving Focus -
trunk/src/lib/gui/gl/glgui_handler.h
r8145 r8324 28 28 void activateCursor(); 29 29 void deactivateCursor(/** ignore param */ bool deleteCursor = true); 30 GLGuiCursor* getCursor() const { return this->cursor; }30 GLGuiCursor* cursor() const { return this->_cursor; } 31 31 32 32 Vector2D cursorPositionOverFocusedWidget() const; … … 48 48 49 49 bool isActive; 50 GLGuiCursor* cursor;50 GLGuiCursor* _cursor; 51 51 52 52 };
Note: See TracChangeset
for help on using the changeset viewer.