コード例 #1
0
void InfoBoxManager::showHelp( const Tile& tile )
{
  LandOverlayPtr overlay = tile.getTerrain().getOverlay();
  BuildingType type;

  if( _d->showDebugInfo )
  {
    StringHelper::debug( 0xff, "Tile debug info: dsrbl=%d", tile.getTerrain().getDesirability() ); 
  }

  type = overlay.isNull() ? B_NONE : overlay->getType();

  Impl::InfoboxCreators::iterator findConstructor = _d->constructors.find( type );

  GuiInfoBox* infoBox = findConstructor != _d->constructors.end() 
                                  ? findConstructor->second->create( _d->gui->getRootWidget(), tile )
                                  : 0;
  
  if( infoBox && infoBox->isAutoPosition() )
  {
    Size rSize = _d->gui->getRootWidget()->getSize();
    int y = ( _d->gui->getCursorPos().getY() < rSize.getHeight() / 2 ) 
                ? rSize.getHeight() - infoBox->getHeight() - 5
                : 30;
    Point pos( ( rSize.getWidth() - infoBox->getWidth() ) / 2, y );

    infoBox->setPosition( pos );
  }
}