GranarySpecialOrdersWindow::GranarySpecialOrdersWindow( Widget* parent, const Point& pos, GranaryPtr granary )
: BaseSpecialOrdersWindow( parent, pos, defaultHeight ), __INIT_IMPL(GranarySpecialOrdersWindow)
{
  __D_IMPL(d, GranarySpecialOrdersWindow)

  setupUI( ":/gui/granaryspecial.gui" );

  setTitle( _("##granary_orders##") );
  int index=0;
  d->granary = granary;
  for( auto& goodType : good::foods() )
  {
    const good::Orders::Order rule = granary->store().getOrder( goodType );
    
    if( rule != good::Orders::none )
    {
      OrderGoodWidget::create( index, goodType, _ordersArea(), granary->store() );
      index++;
    }
  }

  d->btnToggleDevastation = new PushButton( this, Rect( 80, height() - 45, width() - 80, height() - 25 ),
                                             "", -1, false, PushButton::whiteBorderUp );

  CONNECT( d->btnToggleDevastation, onClicked(), this, GranarySpecialOrdersWindow::toggleDevastation );
  _updateBtnDevastation();
}
示例#2
0
void CartPusher::_reachedPathway()
{
    Walker::_reachedPathway();
    _d->anim = CartAnimation();

    if( _d->consumerBuilding != NULL )
    {
        GranaryPtr granary = ptr_cast<Granary>(_d->consumerBuilding);
        WarehousePtr warehouse = ptr_cast<Warehouse>(_d->consumerBuilding);
        FactoryPtr factory = ptr_cast<Factory>(_d->consumerBuilding);

        good::Store* goodStore = 0;
        if( granary.isValid() ) {
            goodStore = &granary->store();
        }
        else if( warehouse.isValid() ) {
            goodStore = &warehouse->store();
        }
        else if( factory.isValid() ) {
            goodStore = &factory->store();
        }

        if( goodStore )
        {
            int saveQty = _d->stock.qty();
            wait( _d->stock.qty() );
            goodStore->applyStorageReservation(_d->stock, _d->reservationID);
            _d->reservationID = 0;
            _d->cantUnloadGoods = (saveQty == _d->stock.qty());
        }
    }
    //
    if( !_pathway().isReverse() )
    {
        _pathway().toggleDirection();
        _centerTile();
        go();
        _d->consumerBuilding = NULL;
    }
    else
    {
        deleteLater();
    }
}
GranarySpecialOrdersWindow::GranarySpecialOrdersWindow( Widget* parent, const Point& pos, GranaryPtr granary )
: BaseSpecialOrdersWindow( parent, pos, defaultHeight )
{
  setTitle( _("##granary_orders##") );
  int index=0;
  _granary = granary;
  for( int goodType=Good::wheat; goodType <= Good::vegetable; goodType++ )
  {
    const GoodOrders::Order rule = granary->store().getOrder( (Good::Type)goodType );
    
    if( rule != GoodOrders::none )
    {
      addOrderWidget<GranaryPtr>( index, (Good::Type)goodType, _ordersArea(), granary );
      index++;
    }
  }

  _btnToggleDevastation = new PushButton( this, Rect( 80, height() - 45, width() - 80, height() - 25 ),
                                          "", -1, false, PushButton::whiteBorderUp );

  CONNECT( _btnToggleDevastation, onClicked(), this, GranarySpecialOrdersWindow::toggleDevastation );
  _updateBtnDevastation();
}