void PopupMessageBox::draw( GfxEngine& painter ) { if( !isVisible() ) return; painter.drawPicture( *_d->background, getScreenLeft(), getScreenTop() ); Widget::draw( painter ); }
void AdvisorFinanceWindow::draw( GfxEngine& painter ) { if( !isVisible() ) return; painter.drawPicture( *_d->background, getScreenLeft(), getScreenTop() ); Widget::draw( painter ); }
//! draws the element and its children void GroupBox::draw( GfxEngine& painter ) { if (!isVisible()) return; painter.drawPicture( *_d->texture, getScreenLeft(), getScreenTop(), &getAbsoluteClippingRectRef() ); Widget::draw( painter ); }
void CB_Room::addBound(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, CB_CollisionEnum tileEnum) { if(tileEnum != CB_COLLISION_NONE) { CB_CollisionBound * bound = new CB_CollisionBound(); bound->setBound((double)x1 * tileSize - getScreenLeft(), getScreenHeight() + getScreenTop() - (double)y1 * tileSize, (double)x2 * tileSize - getScreenLeft(), getScreenHeight() + getScreenTop() - (double)y2 * tileSize); bound->type = tileEnum; boundList.push_back(bound); } }
void InfoBoxWarehouse::showSpecialOrdersWindow() { Point pos; if( getTop() > (int)getParent()->getHeight() / 2 ) { pos = Point( getScreenLeft(), getScreenBottom() - 450 ); } else { pos = getAbsoluteRect().UpperLeftCorner; } new WarehouseSpecialOrdersWindow( getParent(), pos, _warehouse ); }
void GuiInfoGranary::showSpecialOrdersWindow() { Point pos; if( getTop() > (int)getParent()->getHeight() / 2 ) { pos = Point( getScreenLeft(), getScreenBottom() - 450 ); } else { pos = getAbsoluteRect().UpperLeftCorner; } new GranarySpecialOrdersWindow( getParent(), pos, _gd->building ); }
//! int ScrollBar::_getPosFromMousePos(const Point& pos) const { float w, p; if (_horizontal) { w = getWidth() - float(getHeight())*3.0f; p = pos.getX() - getScreenLeft() - getHeight()*1.5f; } else { w = getHeight() - float(getWidth())*3.0f; p = pos.getY() - getScreenTop() - getWidth()*1.5f; } return (int) ( p/w * getRange() ) + _minValue; }
void Minimap::draw(GfxEngine& painter) { if( !isVisible() ) return; if( DateTime::getElapsedTime() - _d->lastTimeUpdate > 500 ) { _d->updateImage(); _d->lastTimeUpdate = DateTime::getElapsedTime(); } painter.drawPicture( *_d->minimap, getScreenLeft(), getScreenTop() ); // 152, 145 Widget::draw( painter ); }
void CB_Room::prepareRender() { CB_Tile * tile; for(uint32_t i = 0; i < width * height; i++) { SDL_mutexP(roomMutex); tile = tileMap[i]; SDL_mutexV(roomMutex); if(tile == 0) { continue; } uint32_t x = i % width; uint32_t y = i / width; double xStart = (double)x * tileSize - getScreenLeft(); double yStart = getScreenHeight() + getScreenTop() - (double)y * tileSize; tile->prepareRender(xStart, yStart, tileSize); } vector<CB_RenderDataRel>::iterator it; for(it = propsList.begin(); it < propsList.end(); it++) { CB_Renderer::listRender(*it); } }
void ScrollBar::beforeDraw( GfxEngine& painter ) { if( !isVisible() ) return; bool needRecalculateSliderParams = (_sliderPos != _lastSliderPos); if( !(_d->needRecalculateParams || needRecalculateSliderParams) ) return; if( _d->needRecalculateParams ) { _d->backgroundRect = getAbsoluteRect(); if( _horizontal ) { if( _d->upButton && _d->upButton->isVisible() ) _d->backgroundRect.UpperLeftCorner += Point( _d->upButton->getWidth(), 0 ); if( _d->downButton && _d->downButton->isVisible() ) _d->backgroundRect.LowerRightCorner -= Point( _d->downButton->getWidth(), 0 ); } else { if( _d->upButton && _d->upButton->isVisible() ) _d->backgroundRect.UpperLeftCorner += Point( 0, _d->upButton->getHeight() ); if( _d->downButton && _d->downButton->isVisible() ) _d->backgroundRect.LowerRightCorner -= Point( 0, _d->downButton->getHeight() ); } } _isSliderHovered = _d->sliderRect.isPointInside( _d->cursorPos ); ElementState st = _dragging && _draggedBySlider ? stPressed : (_lastSliderHovered ? stHovered : stNormal); _d->sliderTexture = (st == stPressed) ? _d->sliderPictureDown : _d->sliderPictureUp; if( needRecalculateSliderParams ) { _lastSliderPos = _sliderPos; _d->sliderRect = getAbsoluteRect(); if( !math::isEqual( getRange(), 0.f ) ) { // recalculate slider rectangle if( _horizontal ) { _d->sliderRect.UpperLeftCorner.setX( getScreenLeft() + _lastSliderPos - _drawLenght/2 ); if( _d->upButton && _d->upButton->isVisible() ) _d->sliderRect.UpperLeftCorner += Point( _d->upButton->getWidth(), 0 ); _d->sliderRect.LowerRightCorner.setX( _d->sliderRect.UpperLeftCorner.getX() + _drawLenght ); } else { _d->sliderRect.UpperLeftCorner.setY( getScreenTop() + _lastSliderPos - _drawLenght/2 ); if( _d->upButton && _d->upButton->isVisible() ) _d->sliderRect.UpperLeftCorner += Point( 0, _d->upButton->getHeight() ); _d->sliderRect.LowerRightCorner.setY( _d->sliderRect.UpperLeftCorner.getY() + _drawLenght ); } } } Widget::beforeDraw( painter ); }
void CB_Room::optimize(bool force) { if(isOptimized && !force) { return; } boundList.clear(); CB_CollisionEnum bTop[width * height]; CB_CollisionEnum bBottom[width * height]; CB_CollisionEnum bLeft[width * height]; CB_CollisionEnum bRight[width * height]; for(uint32_t i = 0; i < width * height; i++) { bTop[i] = CB_COLLISION_NONE; bBottom[i] = CB_COLLISION_NONE; bLeft[i] = CB_COLLISION_NONE; bRight[i] = CB_COLLISION_NONE; } uint8_t tW; uint8_t tH; CB_Tile * tile; for(uint32_t i = 0; i < width * height; i++) { uint32_t x = i % width; uint32_t y = i / width; SDL_mutexP(roomMutex); tile = tileMap[i]; SDL_mutexV(roomMutex); if(tile == 0 || tile == CB_Tile::BLANK_TILE) { continue; } bTop[i] = tile->getSide(0); bBottom[i] = tile->getSide(1); bLeft[i] = tile->getSide(2); bRight[i] = tile->getSide(3); tW = tile->getWidth(tileSize); tH = tile->getHeight(tileSize); if(tW > width - x) { tW = width - x; } if(tH > height - y) { tH = height - y; } if(bLeft[i] == CB_COLLISION_DROPTHROUGH) { bLeft[i] = CB_COLLISION_NONE; } if(bRight[i] == CB_COLLISION_DROPTHROUGH) { bRight[i] = CB_COLLISION_NONE; } if(tW > 1 || tH > 1) { CB_CollisionEnum eXL = bLeft[i]; CB_CollisionEnum eXR = bRight[i]; CB_CollisionEnum eYT = bTop[i]; CB_CollisionEnum eYB = bBottom[i]; bRight[i] = CB_COLLISION_NONE; bBottom[i] = CB_COLLISION_NONE; for(uint32_t iY = 0; iY < tH; iY++) { uint32_t iX1 = i + iY * width; uint32_t iX2 = i + tW - 1 + iY * width; bLeft[iX1] = eXL; bRight[iX2] = eXR; if(x > 0 && bLeft[iX1] != CB_COLLISION_NONE) { if(bRight[iX1 - 1] == bLeft[iX1]) { bLeft[iX1] = CB_COLLISION_NONE; bRight[iX1 - 1] = CB_COLLISION_NONE; } } if(x < width - 1 && bRight[iX2] != CB_COLLISION_NONE) { if(bLeft[iX2 + 1] == bRight[iX2]) { bRight[iX2] = CB_COLLISION_NONE; bLeft[iX2 + 1] = CB_COLLISION_NONE; } } } for(uint32_t iX = 0; iX < tW; iX++) { uint32_t iY = i + iX; bTop[iY] = eYT; bBottom[i + iX + (tH - 1) * width] = eYB; if(y > 0 && bTop[iY] != CB_COLLISION_NONE) { if(bBottom[iY - width] == bTop[iY] && bTop[i] != CB_COLLISION_DROPTHROUGH) { bTop[iY] = CB_COLLISION_NONE; bBottom[iY - width] = CB_COLLISION_NONE; } else if(bBottom[iY - width] == CB_COLLISION_DROPTHROUGH) { bBottom[iY - width] = CB_COLLISION_NONE; } else if(bTop[iY] == CB_COLLISION_DROPTHROUGH && bBottom[iY - width] != CB_COLLISION_NONE) { bTop[iY] = CB_COLLISION_NONE; } } } SDL_mutexP(roomMutex); for(uint32_t iY = 0; iY < tH; iY++) { for(uint32_t iX = 0; iX < tW; iX++) { uint32_t iC = i + iX + iY * width; if(tileMap[iC] == 0) { tileMap[iC] = CB_Tile::BLANK_TILE; } } } SDL_mutexV(roomMutex); } else { if(y > 0 && bTop[i] != CB_COLLISION_NONE) { if(bBottom[i - width] == bTop[i] && bTop[i] != CB_COLLISION_DROPTHROUGH) { bTop[i] = CB_COLLISION_NONE; bBottom[i - width] = CB_COLLISION_NONE; } else if(bBottom[i - width] == CB_COLLISION_DROPTHROUGH) { bBottom[i - width] = CB_COLLISION_NONE; } else if(bTop[i] == CB_COLLISION_DROPTHROUGH && bBottom[i - width] != CB_COLLISION_NONE) { bTop[i] = CB_COLLISION_NONE; } } if(x > 0 && bLeft[i] != CB_COLLISION_NONE) { if(bRight[i - 1] == bLeft[i]) { bLeft[i] = CB_COLLISION_NONE; bRight[i - 1] = CB_COLLISION_NONE; } } if(x < width - 1 && bRight[i] != CB_COLLISION_NONE) { if(bLeft[i + 1] == bRight[i]) { bRight[i] = CB_COLLISION_NONE; bLeft[i + 1] = CB_COLLISION_NONE; } } } tile->putCustomCollision(&boundList, x * tileSize - getScreenLeft(), getScreenHeight() + getScreenTop() - y * tileSize); } for(uint32_t y = 0; y < height; y++) { CB_CollisionEnum cTop = CB_COLLISION_NONE; CB_CollisionEnum cBottom = CB_COLLISION_NONE; uint32_t pTop = 0; uint32_t pBottom = 0; for(uint32_t x = 0; x < width; x++) { uint32_t pos = x + y * width; if(bTop[pos] != cTop) { addBound(pTop, y, x, y, cTop); cTop = bTop[pos]; pTop = x; } if(bBottom[pos] != cBottom) { addBound(x, y + 1, pBottom, y + 1, cBottom); cBottom = bBottom[pos]; pBottom = x; } } addBound(pTop, y, width, y, cTop); addBound(width, y + 1, pBottom, y + 1, cBottom); } for(uint32_t x = 0; x < width; x++) { CB_CollisionEnum cLeft = CB_COLLISION_NONE; CB_CollisionEnum cRight = CB_COLLISION_NONE; uint32_t pLeft = 0; uint32_t pRight = 0; for(uint32_t y = 0; y < height; y++) { uint32_t pos = x + y * width; if(bLeft[pos] != cLeft) { addBound(x, pLeft, x, y, cLeft); cLeft = bLeft[pos]; pLeft = y; } if(bRight[pos] != cRight) { addBound(x + 1, y, x + 1, pRight, cRight); cRight = bRight[pos]; pRight = y; } } addBound(x, pLeft, x, height, cLeft); addBound(x + 1, height, x + 1, pRight, cRight); } isOptimized = true; }
void GuiInfoBox::draw( GfxEngine& engine ) { engine.drawPicture( getBgPicture(), getScreenLeft(), getScreenTop() ); Widget::draw( engine ); }
void BaseSpecialOrdersWindow::draw( GfxEngine& engine ) { engine.drawPicture( *_d->bgPicture, getScreenLeft(), getScreenTop() ); Widget::draw( engine ); }