Пример #1
0
WinMissionWindow::WinMissionWindow(Widget* p, const std::string& newTitle, const std::string& winText, bool mayContinue )
  : Window( p, Rect( 0, 0, 540, 240 ), "" ), _d( new Impl )
{
  setupUI( ":/gui/winmission.gui" );

  Logger::warning( "WinMissionWindow: show" );
  _d->locker.activate();

  setCenter( p->center() );

  Label* lbNewTitle;
  GET_WIDGET_FROM_UI( lbNewTitle )
  if( lbNewTitle ) lbNewTitle->setText( _( newTitle ) );

  PushButton* btnAccept;
  GET_WIDGET_FROM_UI( btnAccept )

  CONNECT( btnAccept, onClicked(), &_d->onNextMissionSignal, Signal0<>::_emit );
  CONNECT( btnAccept, onClicked(), this, WinMissionWindow::deleteLater );

  if( !winText.empty() )
  {
    Label* lbWin = new Label( this, Rect( 30, 30, width()-30, height()-30 ), _(winText), false, Label::bgWhiteFrame );
    lbWin->setTextAlignment( align::center, align::center );
    lbWin->setWordwrap( true );
    WidgetDeleter::assignTo( lbWin, 3000 );
  }
}
Пример #2
0
AboutWarehouse::AboutWarehouse(Widget* parent, PlayerCityPtr city, const Tile& tile )
  : AboutConstruction( parent, Rect( 0, 0, 510, 360 ), Rect( 16, 225, 510 - 16, 225 + 62 ) )
{
  setupUI( ":/gui/warehouseinfo.gui" );

  _warehouse = ptr_cast<Warehouse>( tile.overlay() );

  setBase( ptr_cast<Construction>( _warehouse ) );
  _setWorkingVisible( true );

  /*StringArray warnings;
  if( _warehouse->onlyDispatchGoods() )  { warnings << "##warehouse_low_personal_warning##";  }
  if( _warehouse->getGoodStore().freeQty() == 0 ) { warnings << "##warehouse_full_warning##";  }

  if( !warnings.empty() )
  {
    Label* lb = new Label( this, Rect( 20, height() - 54, width() - 20, height() - 34 ), _(warnings.rand()) );
    lb->setTextAlignment( alignCenter, alignCenter );
  }*/

  PushButton* btnOrders;
  GET_WIDGET_FROM_UI( btnOrders );
  CONNECT( btnOrders, onClicked(), this, AboutWarehouse::showSpecialOrdersWindow );

  std::string title = MetaDataHolder::findPrettyName( _warehouse->type() );
  setTitle( _(title) );

  // summary: total stock, free capacity
  int _paintY = _lbTitleRef() ? _lbTitleRef()->bottom() : 50;

  drawGood(good::wheat,     0, _paintY+0);
  drawGood(good::vegetable, 0, _paintY+25);
  drawGood(good::fruit,     0, _paintY+50);
  drawGood(good::olive,     0, _paintY+75);
  drawGood(good::grape,     0, _paintY+100);
  drawGood(good::fish,      0, _paintY+125);

  drawGood(good::meat,      1, _paintY+0);
  drawGood(good::wine,      1, _paintY+25);
  drawGood(good::oil,       1, _paintY+50);
  drawGood(good::iron,      1, _paintY+75);
  drawGood(good::timber,    1, _paintY+100);

  drawGood(good::clay,      2, _paintY+0);
  drawGood(good::marble,    2, _paintY+25);
  drawGood(good::weapon,    2, _paintY+50);
  drawGood(good::furniture, 2, _paintY+75);
  drawGood(good::pottery,   2, _paintY+100);

  _updateWorkersLabel( Point( 20, 10 ), 542, _warehouse->maximumWorkers(), _warehouse->numberWorkers() );
}
Пример #3
0
AboutGranary::AboutGranary(Widget* parent, PlayerCityPtr city, const Tile& tile )
  : AboutConstruction( parent, Rect( 0, 0, 510, 280 ), Rect( 16, 130, 510 - 16, 130 + 62) )
{
  setupUI( ":/gui/granaryinfo.gui" );

  _granary = ptr_cast<Granary>( tile.overlay() );

  setBase( ptr_cast<Construction>( _granary ) );
  _setWorkingVisible( true );

  PushButton* btnOrders;
  Label* lbUnits;
  GET_WIDGET_FROM_UI( btnOrders )
  GET_WIDGET_FROM_UI( lbUnits )

  CONNECT( btnOrders, onClicked(), this, AboutGranary::showSpecialOrdersWindow );

  std::string title = MetaDataHolder::findPrettyName( _granary->type() );
  setTitle( _(title) ); 

  if( lbUnits )
  {
    // summary: total stock, free capacity
    std::string desc = utils::format( 0xff, "%d %s, %s %d",
                                             _granary->store().qty(),
                                             _("##units_in_stock##"), _("##freespace_for##"),
                                             _granary->store().freeQty() );
    lbUnits->setPosition( _lbTitleRef()->leftbottom() + Point( 0, 5 ) );
    lbUnits->setText( desc );

    drawGood(good::wheat, 0, lbUnits->bottom() );
    drawGood(good::meat, 0, lbUnits->bottom() + 25);
    drawGood(good::fruit, 1, lbUnits->bottom() );
    drawGood(good::vegetable, 1, lbUnits->bottom() + 25);
  }

  _updateWorkersLabel( Point( 32, lbUnits->bottom() + 60 ), 542, _granary->maximumWorkers(), _granary->numberWorkers() );
}