void gkScene::_destroyPhysicsObject(gkGameObject* obj) { GK_ASSERT(obj && m_physicsWorld); if (obj->getPhysicsController()) { gkPhysicsController* phyCon = obj->getPhysicsController(); obj->attachRigidBody(0); obj->attachCharacter(0); if (!isBeingDestroyed()) { bool isStatic = phyCon->isStaticObject(); if (isStatic) m_staticControllers.erase(phyCon); m_physicsWorld->destroyObject(phyCon); if (isStatic) { // Re-merge the static Aabb. calculateLimits(); } } } }
void Console::resizeMessages() //! resize the message count { unsigned int lineHeight = 0; int fontHeight = 0; unsigned int maxLines; bool isOk = calculateLimits(maxLines, lineHeight, fontHeight); console_messages_.resize(isOk ? maxLines : 10); }
void Console::calculatePrintRects( Rect& textRect, Rect& shellRect) //! calculate the messages rect and prompt / shell rect { unsigned int maxLines, lineHeight; int fontHeight; if (calculateLimits(maxLines,lineHeight,fontHeight) ) { shellRect = Rect(Point(), size()); shellRect.setTop(shellRect.bottom() - lineHeight); textRect = Rect(Point(), size()); textRect.setBottom(textRect.top() + lineHeight ); } else { textRect = Rect(0,0,0,0); shellRect = Rect(0,0,0,0); } }
void Console::draw( gfx::Engine& painter ) { if( !font().isValid() ) { Widget::draw( painter ); return; } if( visible() ) // render only if the console is visible { if( toggle_visible_ != NONE ) { if( toggle_visible_ == DOWNLIGTH ) { if (_opacity > 5) _opacity -= 9; else setVisible(false); _d->dirty = true; } else { if (_opacity < 0xff) _opacity += 3; else toggle_visible_ = NONE; _d->dirty = true; } } Rect textRect, shellRect; //we calculate where the message log shall be printed and where the prompt shall be printed calculatePrintRects(textRect,shellRect); if(_d->dirty) { Decorator::drawLines(_d->bg, ColorList::red, relativeRect().lines()); _d->bg.fill(ColorList::blue); unsigned int maxLines, lineHeight; //now, render the messages int fontHeight=0; if (!calculateLimits(maxLines,lineHeight,fontHeight)) { return; } Rect lineRect( textRect.left(), //calculate the line rectangle textRect.top(), textRect.right(), textRect.bottom() + lineHeight); for (unsigned int index = 0; index < console_messages_.size(); index++) { unsigned int rindex = (_d->curIndex + index) % console_messages_.size(); const std::string& line = console_messages_[rindex]; font().draw(_d->bg, line, lineRect.lefttop(), false, false); lineRect += Point(0, lineHeight); //update line rectangle } std::string shellText = "$>" + currentCommand_; font().draw( _d->bg, shellText, shellRect.lefttop(), false, false); //draw the prompt string _d->dirty = false; _d->bg.update(); _d->bg.setAlpha(_opacity/3*2); } painter.draw( _d->bg, absoluteRect().lefttop() ); if( DateTime::elapsedTime() % 700 < 350 ) { NColor color = ColorList::white; color.setAlpha(_opacity/2); painter.fillRect( color, Rect(0, 0, _d->commandCursorWidth,shellRect.height()*0.8) +absoluteRect().leftbottom() + Point(_d->commandTextSize.width(), -shellRect.height()) ); } } Widget::draw( painter ); }