- Timestamp:
- Jun 22, 2006, 2:04:28 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 32 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/class_id.h
r8711 r8717 146 146 CL_MOVIE_LOADER = 0x00000109, 147 147 148 CL_GAME_MENU = 0x00000110, 149 CL_GAME_MENU_DATA = 0x00000111, 150 151 148 152 CL_MULTIPLAYER_TEAM_DEATHMATCH= 0x00000121, 149 153 CL_SINGLEPLAYER_SHOOTEMUP = 0x00000122, -
trunk/src/defs/error.h
r5039 r8717 1 1 2 2 3 /* 3 /* 4 4 orxonox - the future of 3D-vertical-scrollers 5 5 … … 17 17 18 18 19 /*! 19 /*! 20 20 * @file error.h 21 21 * A compendium of Error codes used in the program 22 */ 22 */ 23 23 24 24 … … 54 54 */ 55 55 56 typedef struct 56 struct ErrorMessage 57 57 { 58 ErrorMessage(int code = 0, char* message = NULL, char* location = NULL) 59 : code(code), message(message), location(location) {}; 58 60 int code; 59 61 char* message; 60 62 char* location; 61 } ErrorMessage;63 }; 62 64 63 65 #endif /* _ERROR_H */ -
trunk/src/lib/data/data_tank.h
r7370 r8717 23 23 24 24 /** initializes the DataTank to be able to load the data */ 25 virtual ErrorMessage init() { }25 virtual ErrorMessage init() { return ErrorMessage(); } 26 26 /** 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(); } 28 28 /** unloads the data again from the DataTank */ 29 virtual ErrorMessage unloadData() { }29 virtual ErrorMessage unloadData() { return ErrorMessage(); } 30 30 }; 31 31 -
trunk/src/lib/event/event_handler.cc
r8623 r8717 355 355 else 356 356 { 357 //SDL_WM_GrabInput(SDL_GRAB_ON);357 SDL_WM_GrabInput(SDL_GRAB_ON); 358 358 SDL_ShowCursor(SDL_DISABLE); 359 359 } -
trunk/src/lib/gui/gl/Makefile.am
r8619 r8717 60 60 specials/glgui_notifier.h 61 61 62 63 64 65 66 62 EXTRA_DIST = 67 -
trunk/src/lib/gui/gl/glgui_box.cc
r8619 r8717 125 125 height += borderBottom(); /* *2 done further up */ 126 126 127 printf("%f %f\n", width, height);128 127 this->setSize2D(width, height); 129 128 } … … 145 144 height += borderBottom(); /* *2 done further up */ 146 145 147 printf("%f %f\n", width, height);148 146 this->setSize2D(width, height); 149 147 } -
trunk/src/lib/gui/gl/glgui_button.cc
r8619 r8717 51 51 { 52 52 this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton"); 53 54 this->setSelectable(true); 53 55 this->setFocusable(true); 54 56 this->setClickable(true); … … 79 81 emit(clicked()); 80 82 } 81 void GLGuiButton::releasing(const Vector2D& pos )83 void GLGuiButton::releasing(const Vector2D& pos, bool focused) 82 84 { 83 GLGuiWidget::releasing(pos );85 GLGuiWidget::releasing(pos, focused); 84 86 emit(released()); 85 87 } … … 96 98 97 99 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 98 111 /** 99 112 * @brief draws the GLGuiButton -
trunk/src/lib/gui/gl/glgui_button.h
r8619 r8717 40 40 41 41 virtual void draw() const; 42 virtual bool processEvent(const Event& event); 42 43 43 44 DeclareSignal0(clicked); 44 45 DeclareSignal0(released); 46 45 47 46 48 protected: … … 48 50 49 51 virtual void clicking(const Vector2D& pos); 50 virtual void releasing(const Vector2D& pos );52 virtual void releasing(const Vector2D& pos, bool focused); 51 53 virtual void hiding(); 52 54 virtual void showing(); -
trunk/src/lib/gui/gl/glgui_checkbutton.cc
r8619 r8717 78 78 79 79 80 void GLGuiCheckButton::releasing(const Vector2D& pos )80 void GLGuiCheckButton::releasing(const Vector2D& pos, bool focused) 81 81 { 82 GLGuiButton::releasing(pos); 83 this->toggleActiveState(); 82 GLGuiButton::releasing(pos, focused); 83 if (focused) 84 this->toggleActiveState(); 84 85 } 85 86 -
trunk/src/lib/gui/gl/glgui_checkbutton.h
r8448 r8717 38 38 protected: 39 39 virtual void resize(); 40 virtual void releasing(const Vector2D& pos );40 virtual void releasing(const Vector2D& pos, bool focused); 41 41 42 42 private: -
trunk/src/lib/gui/gl/glgui_handler.cc
r8711 r8717 25 25 #include <cassert> 26 26 27 #include "debug.h" 28 27 29 #include <cassert> 28 30 … … 99 101 } 100 102 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 101 200 102 201 void GLGuiHandler::process(const Event &event) … … 105 204 { 106 205 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()) 110 210 { 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()); 116 214 } 117 else 215 } 216 else if (GLGuiWidget::selected() != NULL && !event.bPressed) 217 { 218 if (GLGuiWidget::selected()->clickable()) 118 219 { 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()); 124 222 } 125 223 } 224 126 225 break; 127 226 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(); 130 232 break; 131 233 … … 134 236 this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h)); 135 237 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); 143 247 } 144 248 … … 160 264 return Vector2D::nullVector(); 161 265 } 266 162 267 Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const 163 268 { … … 170 275 171 276 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. 182 280 const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET); 183 281 … … 193 291 { 194 292 // receiving Focus 195 if (GLGuiWidget:: focused() != widget)293 if (GLGuiWidget::mouseFocused() != widget) 196 294 { 197 widget->give Focus();295 widget->giveMouseFocus(); 198 296 } 199 297 return ; 200 298 } 201 299 } 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(); 205 318 } 206 319 } -
trunk/src/lib/gui/gl/glgui_handler.h
r8324 r8717 34 34 Vector2D cursorPositionRel(const GLGuiWidget* const widget) const; 35 35 36 void selectNext(); 37 void selectPrevious(); 38 36 39 void activate(); 37 40 void deactivate(); 38 41 42 void checkFocus(); 39 43 40 44 virtual void process(const Event &event); -
trunk/src/lib/gui/gl/glgui_inputline.cc
r8619 r8717 47 47 48 48 this->setFocusable(true); 49 this->setClickable(true); 50 this->setSelectable(true); 49 51 50 52 this->_clearOnEnter = false; -
trunk/src/lib/gui/gl/glgui_pushbutton.cc
r8448 r8717 63 63 void GLGuiPushButton::receivedFocus() 64 64 { 65 printf("%s received focus\n", this->label().c_str());66 65 GLGuiWidget::receivedFocus(); 67 66 } … … 69 68 void GLGuiPushButton::removedFocus() 70 69 { 71 printf("%s removed focus\n", this->label().c_str());72 70 GLGuiWidget::removedFocus(); 73 71 … … 76 74 void GLGuiPushButton::clicking(const Vector2D& pos) 77 75 { 78 printf("%s clicked\n", this->label().c_str());79 76 GLGuiButton::clicking(pos); 80 77 } 81 78 82 79 83 void GLGuiPushButton::releasing(const Vector2D& pos )80 void GLGuiPushButton::releasing(const Vector2D& pos, bool focused) 84 81 { 85 printf("%s released\n", this->label().c_str());86 GLGuiButton::releasing(pos);82 if (focused) 83 GLGuiButton::releasing(pos, focused); 87 84 } 88 85 -
trunk/src/lib/gui/gl/glgui_pushbutton.h
r8145 r8717 31 31 virtual void draw() const; 32 32 virtual void update(); 33 33 34 protected: 34 35 virtual void resize(); 35 36 virtual void clicking(const Vector2D& pos); 36 virtual void releasing(const Vector2D& pos );37 virtual void releasing(const Vector2D& pos, bool focused); 37 38 virtual void receivedFocus(); 38 39 virtual void removedFocus(); -
trunk/src/lib/gui/gl/glgui_slider.cc
r8619 r8717 48 48 this->setClassID(CL_GLGUI_SLIDER, "GLGuiSlider"); 49 49 50 this->setClickable( ); 51 this->setFocusable( ); 50 this->setClickable(true); 51 this->setFocusable(true); 52 this->setSelectable(true); 52 53 53 54 this->_value = 0.0; … … 193 194 } 194 195 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); 198 199 this->grabbed = false; 199 200 } … … 202 203 { 203 204 GLGuiWidget::removedFocus(); 204 this->grabbed = false;205 205 } 206 206 -
trunk/src/lib/gui/gl/glgui_slider.h
r8448 r8717 59 59 60 60 virtual void clicking(const Vector2D& pos); 61 virtual void releasing(const Vector2D& pos );61 virtual void releasing(const Vector2D& pos, bool focused); 62 62 virtual void removedFocus(); 63 63 -
trunk/src/lib/gui/gl/glgui_table.cc
r8619 r8717 19 19 #include "debug.h" 20 20 21 #include "glgui_handler.h" 22 21 23 namespace OrxGui 22 24 { … … 25 27 */ 26 28 GLGuiTable::GLGuiTable (unsigned int rows, unsigned int columns) 29 : _selected(-1, -1), _focused(-1, -1) 27 30 { 28 31 this->init(); 32 29 33 this->setRowCount(rows); 30 34 this->setColumnCount(columns); … … 45 49 this->setClassID(CL_GLGUI_TABLE, "GLGuiTable"); 46 50 51 this->setBorderTop(10); 52 47 53 this->setFocusable(true); 48 54 this->setClickable(true); 49 55 50 this->resize();51 56 } 52 57 … … 56 61 57 62 unsigned int currentRowCount = this->rowCount(); 63 64 this->_rowHeights.resize(rowCount, 20); 65 58 66 this->_entries.resize(rowCount); 59 67 for (unsigned int i = currentRowCount; i < this->rowCount(); ++i) … … 65 73 66 74 assert(this->checkIntegrity()); 67 this->debug(); 75 this->repositionText(currentRowCount, 0); 76 77 78 this->resize(); 68 79 69 80 if (!this->isVisible()) … … 75 86 unsigned int i; 76 87 unsigned int currentColumnCount = this->columnCount(); 88 89 this->_columnWidths.resize(columnCount, 100); 77 90 78 91 // setup Headers. … … 89 102 } 90 103 assert(this->checkIntegrity()); 91 this->debug(); 92 104 105 this->repositionText(0, currentColumnCount); 106 107 this->resize(); 93 108 if (!this->isVisible()) 94 109 this->hiding(); … … 111 126 } 112 127 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) 114 129 { 115 130 if (column >= this->columnCount() ) … … 125 140 for (unsigned int i = 0; i < this->rowCount(); ++i) 126 141 this->_entries[i][column].setLineWidth(size); 127 128 } 142 } 143 144 129 145 130 146 /// TODO. … … 144 160 145 161 146 147 162 /** 148 163 * @brief Processes an Event. … … 152 167 bool GLGuiTable::processEvent(const Event& event) 153 168 { 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 154 175 return false; 155 176 } … … 161 182 void GLGuiTable::resize() 162 183 { 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 163 195 GLGuiWidget::resize(); 164 196 } … … 172 204 this->_entries[j][i].setColor(this->foregroundColor()); 173 205 } 206 174 207 } 175 208 … … 196 229 197 230 /** 198 * @brief ticks the Table199 * @param dt the time passed.200 */201 void GLGuiTable::tick(float dt)202 {}203 204 /**205 231 * @brief draws the GLGuiTable 206 232 */ … … 210 236 GLGuiWidget::draw(); 211 237 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 214 268 215 269 this->endDraw(); 216 270 } 217 271 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 } 218 322 219 323 /** … … 224 328 { 225 329 text->setSize(this->textSize()); 226 //text->setLineWidth();330 text->setLineWidth( this->_columnWidths[column] ); 227 331 text->setFont("fonts/final_frontier.ttf", (int)this->textSize()); 332 text->setColor(this->foregroundColor()); 228 333 229 334 text->setColor(this->foregroundColor()); … … 257 362 for (unsigned int i = 0; i < this->rowCount(); ++i) 258 363 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 } 263 368 return retVal; 264 369 } -
trunk/src/lib/gui/gl/glgui_table.h
r8619 r8717 39 39 void setHeader(const std::vector<std::string>& headerNames); 40 40 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); 42 42 43 43 void setColumnWidth(unsigned int column, float size); 44 44 void setRowHeight(unsigned int row, unsigned int size); 45 45 46 virtual void tick(float dt);47 46 virtual void draw() const; 48 47 … … 60 59 virtual bool processEvent(const Event& event); 61 60 62 63 61 private: 64 62 void init(); 65 63 64 void pixelPositionToElement(const Vector2D& pixelPosition, int* row, int* column); 65 void repositionText(unsigned int fromLeft, unsigned int fromTop); 66 66 void applyTextSettings(unsigned int row, unsigned int column, LimitedWidthText* text); 67 67 bool checkIntegrity() const; 68 68 69 69 private: 70 typedef struct Entry { 71 Entry(int row, int column) :row(row), column(column) {}; 72 int row; 73 int column; 74 }; 75 70 76 typedef std::vector<LimitedWidthText> TableTextList; 71 77 TableTextList _headers; 78 std::vector<float> _columnWidths; 79 std::vector<float> _rowHeights; 80 72 81 std::vector<TableTextList> _entries; //!< inner is by column, outer is by row. 82 83 Entry _selected; 84 Entry _focused; 73 85 74 86 -
trunk/src/lib/gui/gl/glgui_widget.cc
r8619 r8717 72 72 GLGuiWidget::~GLGuiWidget() 73 73 { 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(); 76 78 } 77 79 78 80 GLGuiWidget* GLGuiWidget::_selected = NULL; 79 GLGuiWidget* GLGuiWidget::_ focused = NULL;81 GLGuiWidget* GLGuiWidget::_mouseFocused = NULL; 80 82 GLGuiWidget* GLGuiWidget::_inputGrabber = NULL; 81 83 … … 91 93 this->_focusable = false; 92 94 this->_clickable = false; 95 this->_selectable = false; 93 96 this->_pushed = false; 94 97 this->_state = OrxGui::Normal; … … 133 136 } 134 137 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 135 159 /** @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 141 171 this->receivedFocus(); 142 172 }; 143 173 144 void GLGuiWidget::break Focus()145 { 146 if (GLGuiWidget::_ focused == this)174 void GLGuiWidget::breakMouseFocus() 175 { 176 if (GLGuiWidget::_mouseFocused == this) 147 177 { 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 150 185 this->removedFocus(); 151 186 } 152 187 }; 153 188 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 } 173 218 174 219 … … 193 238 if (this->_pushed) 194 239 { 195 this->releasing(pos );240 this->releasing(pos, GLGuiWidget::_mouseFocused == this); 196 241 this->_pushed = false; 197 242 } … … 200 245 201 246 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 {} 210 251 211 252 void GLGuiWidget::receivedFocus() 212 253 { 213 this->switchState(OrxGui::Focused);214 254 } 215 255 216 256 void GLGuiWidget::removedFocus() 217 257 { 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 } 225 273 226 274 … … 706 754 //this->_currentStyle = this->_style[state]; 707 755 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()); 709 757 710 758 this->animateBack(); … … 762 810 for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i) 763 811 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 } 768 816 return false; 769 817 } … … 772 820 * @brief print out some nice debug output about the Widget. 773 821 */ 774 void GLGuiWidget::debug( ) const822 void GLGuiWidget::debug(unsigned int level) const 775 823 { 776 824 PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName()); -
trunk/src/lib/gui/gl/glgui_widget.h
r8619 r8717 42 42 43 43 /// 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 47 48 /** @returns true if the widget is focusable */ 48 49 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; };51 50 /** @returns true if the position is inside of the Widget. @param position the position to check */ 52 51 bool focusOverWidget(const Vector2D& position) const; … … 54 53 bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const; 55 54 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; }; 59 66 60 67 /// CLICK 68 bool pushed() { return _pushed; }; 61 69 void click(const Vector2D& pos); 62 70 void release(const Vector2D& pos); 63 71 bool clickable() const { return this->_clickable; }; 64 void setClickable(bool clickable = true) { this->_clickable = clickable; };65 72 66 73 static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor); … … 81 88 void animateBack(); 82 89 83 /// STYLE 90 /////////////////////////////////////////////////////////////////////////////////// 91 /// STYLE ///////////////////////////////////////////////////////////////////////// 84 92 //////////////////////////////// 85 93 /// Retrieve Current Values. /// … … 201 209 void setAnimatedStateChanges(bool animated); 202 210 void switchState(OrxGui::State state); 203 211 /////////////////////////////////////////////////////////////////////////////////// 204 212 205 213 … … 225 233 226 234 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 227 248 /// LOOKS 228 249 virtual void resize(); … … 230 251 virtual void hiding() {}; 231 252 virtual void showing() {}; 253 232 254 virtual void updateFrontColor() {}; 233 255 234 inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };235 inline void endDraw() const { glPopMatrix(); };236 256 237 257 /// EVENTS 238 // if something was clickt on the GUI-widget.258 // mouse clicking 239 259 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 241 262 virtual void receivedFocus(); 242 263 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; 247 272 248 273 private: … … 251 276 private: 252 277 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). 255 280 256 281 … … 265 290 /// EVENTS 266 291 OrxGui::State _state; 292 bool _pushed; 267 293 268 294 bool _focusable; //!< If this widget can receive focus. 269 295 bool _clickable; //!< if this widget can be clicked upon. 270 271 bool _pushed; 296 bool _selectable; //!< If this widget can be selected. 297 272 298 273 299 … … 276 302 typedef struct 277 303 { 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 starts281 float _borderBottom; //!< The Distance to the bottom Border of the widget, before any internal Element starts282 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. 288 314 } 289 315 StatedStyle; 290 316 291 317 292 StatedStyle _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States293 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. 296 322 297 323 298 324 /// 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; 305 331 306 332 }; -
trunk/src/lib/util/loading/game_loader.cc
r7868 r8717 73 73 this->subscribeEvent(ES_GAME, KeyMapper::PEV_NEXT_WORLD); 74 74 this->subscribeEvent(ES_GAME, KeyMapper::PEV_PREVIOUS_WORLD); 75 76 return ErrorMessage(); 75 77 } 76 78 … … 91 93 this->currentCampaign = this->fileToCampaign(campaignName); 92 94 } 95 96 return ErrorMessage(); 93 97 } 94 98 … … 109 113 this->currentCampaign = this->fileToCampaign(campaignName); 110 114 } 115 116 return ErrorMessage(); 111 117 } 112 118 … … 147 153 } 148 154 } 155 156 return ErrorMessage(); 149 157 } 150 158 … … 160 168 this->currentCampaign->start(); 161 169 } 170 171 return ErrorMessage(); 162 172 } 163 173 … … 191 201 if(this->currentCampaign != NULL) 192 202 this->currentCampaign->pause(); 203 204 return ErrorMessage(); 193 205 } 194 206 … … 205 217 if(this->currentCampaign != NULL) 206 218 this->currentCampaign->resume(); 219 220 return ErrorMessage(); 207 221 } 208 222 -
trunk/src/story_entities/Makefile.am
r6634 r8717 13 13 story_entities/multi_player_world_data.cc \ 14 14 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 16 19 17 20 StoryEntities_HEADERS_ = \ … … 27 30 story_entities/multi_player_world_data.h \ 28 31 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 82 82 this->bReturnToMenu = false; 83 83 this->run(); 84 85 return true; 84 86 } 85 87 … … 90 92 bool Campaign::pause() 91 93 { 92 this->bPaused = true;94 return (this->bPaused = true); 93 95 } 94 96 … … 100 102 { 101 103 PRINTF(4)("Resuming the current Campaign\n"); 102 this->bPaused = false;104 return (this->bPaused = false); 103 105 } 104 106 … … 118 120 this->currentEntity->stop(); 119 121 } 122 123 return true; 120 124 } 121 125 … … 127 131 { 128 132 ErrorMessage errorCode; 129 int storyID = WORLD_ID_0;133 // int storyID = WORLD_ID_0; 130 134 131 135 for( this->currentEntity = this->campaignData->getFirstLevel(), this->bRunning = true; -
trunk/src/story_entities/game_world.cc
r8711 r8717 140 140 State::setScriptManager(&this->scriptManager); 141 141 142 return ErrorMessage(); 142 143 } 143 144 … … 153 154 154 155 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(); 157 158 158 159 if( getLoadFile().empty()) 159 160 { 160 161 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()")); 162 163 } 163 164 … … 168 169 PRINTF(1)("loading XML File: %s @ %s:l%d:c%d\n", XMLDoc->ErrorDesc(), this->getLoadFile().c_str(), XMLDoc->ErrorRow(), XMLDoc->ErrorCol()); 169 170 delete XMLDoc; 170 return (ErrorMessage){213,"XML File parsing error","GameWorld::load()"};171 return ErrorMessage(213,"XML File parsing error","GameWorld::load()"); 171 172 } 172 173 // check basic validity … … 178 179 PRINTF(1)("Specified XML File is not an orxonox world data file (WorldDataFile element missing)\n"); 179 180 delete XMLDoc; 180 return (ErrorMessage){213,"Path not a WorldDataFile","GameWorld::load()"};181 return ErrorMessage(213,"Path not a WorldDataFile","GameWorld::load()"); 181 182 } 182 183 /* the whole loading process for the GameWorld */ … … 191 192 //Account *b = new Account(30); 192 193 //b->setName("b"); 194 193 195 194 196 LoadParamXML(root, "ScriptManager", &this->scriptManager, ScriptManager, loadParams); … … 196 198 delete XMLDoc; 197 199 this->releaseLoadScreen(); 200 201 return ErrorMessage(); 198 202 } 199 203 … … 220 224 if (this->dataXML) 221 225 delete this->dataXML; 226 227 return ErrorMessage(); 222 228 } 223 229 … … 232 238 State::setScriptManager(&this->scriptManager); //make sure we have the right script manager 233 239 this->run(); 240 241 return true; 234 242 } 235 243 … … 242 250 PRINTF(3)("GameWorld::stop() - got stop signal\n"); 243 251 State::setScriptManager(NULL); 244 this->bRunning = false;252 return (this->bRunning = false); 245 253 } 246 254 … … 251 259 bool GameWorld::pause() 252 260 { 253 this->bPaused = true;261 return (this->bPaused = true); 254 262 } 255 263 … … 260 268 bool GameWorld::resume() 261 269 { 262 this->bPaused = false;270 return(this->bPaused = false); 263 271 } 264 272 … … 410 418 if( likely(this->dataTank->gameRule != NULL)) 411 419 this->dataTank->gameRule->tick(this->dtS); 412 420 413 421 } 414 422 } -
trunk/src/story_entities/game_world_data.cc
r8490 r8717 108 108 109 109 GraphicsEngine::getInstance()->displayFPS(true); 110 111 return ErrorMessage(); 110 112 } 111 113 … … 131 133 this->loadWorldEntities(root); 132 134 this->loadScene(root); 135 136 return ErrorMessage(); 133 137 } 134 138 … … 142 146 this->unloadWorldEntities(); 143 147 this->unloadScene(); 148 149 return ErrorMessage(); 144 150 } 145 151 … … 166 172 } 167 173 this->glmis->draw(); 174 175 return ErrorMessage(); 168 176 } 169 177 … … 175 183 { 176 184 delete this->glmis; 185 186 return ErrorMessage(); 177 187 } 178 188 … … 250 260 /* init the pnode tree */ 251 261 PNode::getNullParent()->init(); 262 263 return ErrorMessage(); 252 264 } 253 265 … … 312 324 313 325 this->glmis = NULL; 326 327 return ErrorMessage(); 314 328 } 315 329 … … 337 351 this->localCamera->addChild(this->sky); 338 352 OrxSound::SoundEngine::getInstance()->setListener(this->localCamera); 353 354 return ErrorMessage(); 339 355 } 340 356 … … 357 373 358 374 State::setGameRules(NULL); 375 376 return ErrorMessage(); 359 377 } 360 378 -
trunk/src/story_entities/menu/game_menu.cc
r8713 r8717 178 178 image->setWidgetSize( 250, 200); 179 179 image->setAbsCoor2D(400, 150); 180 image->setForegroundColor(Color(1,1,1,.6)); 180 181 181 182 const std::list<BaseObject*>* storyEntities = ClassList::getList(CL_STORY_ENTITY); -
trunk/src/story_entities/multi_player_world.cc
r8228 r8717 123 123 /** 124 124 * cleanup 125 * @return 125 * @return 126 126 */ 127 127 ErrorMessage MultiPlayerWorld::unloadData( ) 128 128 { 129 129 130 130 GameWorld::unloadData(); 131 131 132 132 delete NetworkManager::getInstance(); 133 133 delete NetworkGameManager::getInstance(); 134 134 135 return ErrorMessage(); 135 136 } -
trunk/src/story_entities/multi_player_world_data.cc
r8490 r8717 78 78 { 79 79 /* call underlying function */ 80 GameWorldData::init();80 return GameWorldData::init(); 81 81 } 82 82 … … 89 89 { 90 90 /* call underlying function */ 91 GameWorldData::loadGUI(root);91 return GameWorldData::loadGUI(root); 92 92 } 93 93 … … 99 99 { 100 100 /* call underlying function */ 101 GameWorldData::unloadGUI();101 return GameWorldData::unloadGUI(); 102 102 } 103 103 … … 245 245 this->drawLists.push_back(OM_GROUP_01); 246 246 this->drawLists.push_back(OM_GROUP_01_PROJ); 247 247 248 248 State::setPlayer(this->localPlayer); 249 249 250 return ErrorMessage(); 250 251 } 251 252 … … 257 258 { 258 259 /* call underlying function */ 259 GameWorldData::unloadWorldEntities();260 return GameWorldData::unloadWorldEntities(); 260 261 } 261 262 … … 269 270 /* call underlying function */ 270 271 GameWorldData::loadScene(root); 271 272 272 273 // create server playable 273 274 if ( NetworkManager::getInstance()->isGameServer() ) … … 276 277 State::getPlayer()->setPlayable( PlayerStats::getStats( 0 )->getPlayable() ); 277 278 } 279 280 return ErrorMessage(); 278 281 } 279 282 … … 285 288 { 286 289 /* call underlying function */ 287 GameWorldData::unloadScene();290 return GameWorldData::unloadScene(); 288 291 } 289 292 -
trunk/src/story_entities/simple_game_menu.cc
r8619 r8717 131 131 headers.push_back("3"); 132 132 table->setHeader(headers); 133 table->setEntry(1, 2, "Test"); 134 table->setEntry(2, 1, "MultiLine SuperTest to see how it works"); 133 135 134 136 -
trunk/src/story_entities/single_player_world_data.cc
r7370 r8717 45 45 { 46 46 /* call underlying function */ 47 GameWorldData::init();47 return GameWorldData::init(); 48 48 } 49 49 … … 56 56 { 57 57 /* call underlying function */ 58 GameWorldData::loadGUI(root);58 return GameWorldData::loadGUI(root); 59 59 } 60 60 … … 66 66 { 67 67 /* call underlying function */ 68 GameWorldData::unloadGUI();68 return GameWorldData::unloadGUI(); 69 69 } 70 70 … … 77 77 { 78 78 /* call underlying function */ 79 GameWorldData::loadWorldEntities(root);79 return GameWorldData::loadWorldEntities(root); 80 80 } 81 81 … … 87 87 { 88 88 /* call underlying function */ 89 GameWorldData::unloadWorldEntities();89 return GameWorldData::unloadWorldEntities(); 90 90 } 91 91 … … 98 98 { 99 99 /* call underlying function */ 100 GameWorldData::loadScene(root);100 return GameWorldData::loadScene(root); 101 101 } 102 102 … … 108 108 { 109 109 /* call underlying function */ 110 GameWorldData::unloadScene();110 return GameWorldData::unloadScene(); 111 111 } 112 112 -
trunk/src/story_entities/story_entity.h
r7283 r8717 35 35 /* initialisation and loading */ 36 36 /** initializes a Story Entity to the needed values */ 37 virtual ErrorMessage init() { };37 virtual ErrorMessage init() { return ErrorMessage(); }; 38 38 /** called to load the data into the StoryEntity*/ 39 virtual ErrorMessage loadData() { };39 virtual ErrorMessage loadData() { return ErrorMessage(); }; 40 40 /** function that unloads the data from the StoryEntity */ 41 virtual ErrorMessage unloadData() { };41 virtual ErrorMessage unloadData() { return ErrorMessage(); }; 42 42 43 43 /* running, stopping and pausing */ -
trunk/src/util/multiplayer_team_deathmatch.cc
r8708 r8717 68 68 this->gameStateTimer = 10.0f; 69 69 this->bShowTeamChange = false; 70 70 71 71 this->box = NULL; 72 72 … … 80 80 if( root != NULL) 81 81 this->loadParams(root); 82 82 83 83 subscribeEvent( ES_GAME, SDLK_o ); 84 84 subscribeEvent( ES_GAME, SDLK_TAB ); 85 85 86 86 this->notifier = new OrxGui::GLGuiNotifier(); 87 87 this->notifier->show(); … … 101 101 if( this->deathScreen) 102 102 delete this->deathScreen; 103 103 104 104 unsubscribeEvent( ES_GAME, SDLK_o ); 105 105 unsubscribeEvent( ES_GAME, SDLK_TAB ); 106 106 107 107 if ( this->notifier ) 108 108 { … … 110 110 this->notifier = NULL; 111 111 } 112 112 113 113 if ( this->input ) 114 114 { … … 132 132 LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen) 133 133 .describe("sets the death screen image"); 134 134 135 135 LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams) 136 136 .describe("sets number of teams"); … … 179 179 if ( SharedNetworkData::getInstance()->getHostID() < 0 ) 180 180 return; 181 181 182 182 if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME ) 183 183 { 184 184 if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 185 185 && box == NULL 186 && (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 186 && (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 187 187 || bShowTeamChange ) 188 188 189 189 ) 190 190 { 191 191 EventHandler::getInstance()->pushState( ES_MENU ); 192 192 193 193 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 194 194 195 195 box = new OrxGui::GLGuiBox(); 196 196 box->setAbsCoor2D( 300, 100 ); 197 197 198 198 OrxGui::GLGuiPushButton * buttonSpectator = new OrxGui::GLGuiPushButton("Spectator"); 199 199 box->pack( buttonSpectator ); 200 200 buttonSpectator->connect(SIGNAL(buttonSpectator, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonSpectator)); 201 201 202 202 OrxGui::GLGuiPushButton * buttonRandom = new OrxGui::GLGuiPushButton("Random"); 203 203 box->pack( buttonRandom ); 204 204 buttonRandom->connect(SIGNAL(buttonRandom, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonRandom)); 205 205 206 206 OrxGui::GLGuiPushButton * buttonTeam0 = new OrxGui::GLGuiPushButton("Blue Team"); 207 207 box->pack( buttonTeam0 ); 208 208 buttonTeam0->connect(SIGNAL(buttonTeam0, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam0)); 209 209 210 210 OrxGui::GLGuiPushButton * buttonTeam1 = new OrxGui::GLGuiPushButton("Red Team"); 211 211 box->pack( buttonTeam1 ); 212 212 buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1)); 213 213 214 214 if ( bShowTeamChange ) 215 215 { … … 218 218 buttonCancel->connect(SIGNAL(buttonCancel, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonCancel)); 219 219 } 220 220 221 221 OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit"); 222 222 box->pack( buttonExit ); 223 223 buttonExit->connect(SIGNAL(buttonExit, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonExit)); 224 224 225 225 box->showAll(); 226 226 } … … 229 229 if ( box != NULL 230 230 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 231 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 231 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 232 232 && !bShowTeamChange 233 233 ) … … 235 235 delete box; 236 236 box = NULL; 237 237 238 238 OrxGui::GLGuiHandler::getInstance()->deactivateCursor( true ); 239 239 240 240 EventHandler::getInstance()->popState(); 241 241 } 242 242 243 243 if ( box != NULL ) 244 244 { 245 245 OrxGui::GLGuiHandler::getInstance()->tick( dt ); 246 246 } 247 247 248 248 assignPlayable(); 249 249 250 250 if ( !SharedNetworkData::getInstance()->isGameServer() ) 251 251 return; 252 252 253 253 gameStateTimer -= dt; 254 254 //PRINTF(0)("TICK %f\n", gameStateTimer); 255 255 256 256 if ( currentGameState != GAMESTATE_GAME && gameStateTimer < 0 ) 257 257 nextGameState(); 258 258 259 259 this->currentGameState = NetworkGameManager::getInstance()->getGameState(); 260 260 261 261 if ( currentGameState == GAMESTATE_GAME ) 262 262 { 263 263 handleTeamChanges(); 264 264 } 265 265 266 266 this->calculateTeamScore(); 267 267 268 268 this->checkGameRules(); 269 269 … … 304 304 if ( !SharedNetworkData::getInstance()->isGameServer() ) 305 305 return; 306 306 307 307 // check for max killing count 308 308 for ( int i = 0; i<numTeams; i++ ) … … 329 329 if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR ) 330 330 return CL_SPECTATOR; 331 331 332 332 if ( team == 0 || team == 1 ) 333 333 return CL_SPACE_SHIP; 334 334 335 335 assert( false ); 336 336 } … … 352 352 { 353 353 teamScore.clear(); 354 354 355 355 for ( int i = 0; i<numTeams; i++ ) 356 356 teamScore[i] = 0; 357 358 357 358 359 359 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 360 360 361 361 if ( !list ) 362 362 return; 363 363 364 364 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 365 365 { … … 380 380 { 381 381 std::map<int,int> playersInTeam; 382 382 383 383 for ( int i = 0; i<numTeams; i++ ) 384 384 playersInTeam[i] = 0; 385 385 386 386 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 387 387 388 388 if ( !list ) 389 389 return 0; 390 390 391 391 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 392 392 { … … 398 398 } 399 399 } 400 401 400 401 402 402 int minPlayers = 0xFFFF; 403 403 int minTeam = -1; 404 404 405 405 for ( int i = 0; i<numTeams; i++ ) 406 406 { … … 411 411 } 412 412 } 413 413 414 414 assert( minTeam != -1 ); 415 415 416 416 return minTeam; 417 417 } … … 422 422 { 423 423 NetworkGameManager::getInstance()->setGameState( GAMESTATE_GAME ); 424 425 return; 426 } 427 424 425 return; 426 } 427 428 428 if ( currentGameState == GAMESTATE_GAME ) 429 429 { 430 430 NetworkGameManager::getInstance()->setGameState( GAMESTATE_POST_GAME ); 431 432 return; 433 } 434 431 432 return; 433 } 434 435 435 if ( currentGameState == GAMESTATE_POST_GAME ) 436 436 { 437 437 //TODO end game 438 438 439 439 return; 440 440 } … … 444 444 { 445 445 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 446 446 447 447 if ( !list ) 448 448 return; 449 449 450 450 //first server players with choices 451 451 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 461 461 } 462 462 } 463 463 464 464 //now serve player who want join a random team 465 465 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) … … 482 482 assert( PlayerStats::getStats( userId ) ); 483 483 PlayerStats & stats = *(PlayerStats::getStats( userId )); 484 484 485 485 stats.setTeamId( stats.getPreferedTeamId() ); 486 486 487 487 Playable * oldPlayable = stats.getPlayable(); 488 489 488 489 490 490 ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() ); 491 491 std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId ); 492 492 493 493 BaseObject * bo = Factory::fabricate( playableClassId ); 494 494 495 495 assert( bo != NULL ); 496 496 assert( bo->isA( CL_PLAYABLE ) ); 497 497 498 498 Playable & playable = *(dynamic_cast<Playable*>(bo)); 499 499 500 500 playable.loadModel( playableModel ); 501 501 playable.setOwner( userId ); 502 502 playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 503 503 playable.setSynchronized( true ); 504 504 505 505 stats.setTeamId( stats.getPreferedTeamId() ); 506 506 stats.setPlayableClassId( playableClassId ); 507 507 stats.setPlayableUniqueId( playable.getUniqueID() ); 508 508 stats.setModelFileName( playableModel ); 509 509 510 510 if ( oldPlayable ) 511 511 { … … 572 572 OrxGui::GLGuiHandler::getInstance()->deactivateCursor(); 573 573 input->show(); 574 input->give Focus();574 input->giveMouseFocus(); 575 575 input->setText("say "); 576 576 } … … 594 594 { 595 595 std::string name = "unknown"; 596 596 597 597 if ( PlayerStats::getStats( userId ) ) 598 598 { 599 599 name = PlayerStats::getStats( userId )->getNickName(); 600 600 } 601 601 602 602 PRINTF(0)("CHATMESSAGE %s (%d): %s\n", name.c_str(), userId, message.c_str() ); 603 603 notifier->pushNotifyMessage(name + ": " + message); … … 607 607 { 608 608 EventHandler::getInstance()->popState(); 609 input->break Focus();609 input->breakMouseFocus(); 610 610 input->hide(); 611 611 input->setText(""); 612 612 613 613 std::string command = text; 614 614 615 615 //HACK insert " in say commands so user doesn't have to type them 616 616 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.