Ejemplo n.º 1
0
void GoodOrderManageWindow::updateIndustryState()
{
  int workFactoryCount=0, idleFactoryCount=0;
  FactoryList factories = _d->city->statistic().objects.producers<Factory>( _d->type );
  for( auto factory : factories )
  {
    ( factory->standIdle() ? idleFactoryCount : workFactoryCount ) += 1;
  }

  //bool industryActive = _d->city->tradeOptions().isVendor( _d->type );
  if( factories.empty() )
  {
    _d->btnIndustryState->setEnabled( false );
    _d->btnIndustryState->setBackgroundStyle( PushButton::noBackground );
    _d->btnIndustryState->setText( _("##no_industries_in_city##" ) );
    return;
  }  

  std::string postfixWork = (workFactoryCount%10 == 1) ? "##working_industry##" : "##working_industries##";
  std::string postfixIdle = (workFactoryCount%10 == 1) ? "##idle_factory_in_city##" : "##idle_factories_in_city##";

  std::string text = utils::format( 0xff, "%d %s\n%d %s", workFactoryCount, _(postfixWork),
                                           idleFactoryCount, _(postfixIdle) );
  _d->lbIndustryInfo->setText( text );

  bool industryEnabled = isIndustryEnabled();
  _d->btnIndustryState->setText( industryEnabled ? _("##industry_enabled##") : _("##industry_disabled##") );
}
Ejemplo n.º 2
0
bool Trade::Impl::getWorkState(good::Product gtype )
{
    bool industryActive = false;
    FactoryList producers = city->statistic().objects.producers<Factory>( gtype );

    for( auto factory : producers ) {
        industryActive |= factory->isActive();
    }

    return producers.empty() ? true : industryActive;
}
Ejemplo n.º 3
0
bool GoodOrderManageWindow::isIndustryEnabled()
{
  //if any factory work in city, that industry work too
  bool anyFactoryWork = false;
  FactoryList factories = _d->city->statistic().objects.producers<Factory>( _d->type );
  for( auto factory : factories )
  {
    anyFactoryWork |= factory->isActive();
  }

  return factories.empty() ? true : anyFactoryWork;
}
Ejemplo n.º 4
0
bool
dlgTaskTypeShowModal(SingleWindow &parent, OrderedTask** task)
{
    ordered_task = *task;
    parent_window = &parent;
    task_modified = false;

    factory_types = ordered_task->get_factory_types(true);

    wf = NULL;

    if (Layout::landscape) {
        wf = LoadDialog(CallBackTable,
                        parent,
                        _T("IDR_XML_TASKTYPE_L"));
    } else {
        wf = LoadDialog(CallBackTable,
                        parent,
                        _T("IDR_XML_TASKTYPE"));
    }

    wTaskTypes = (WndListFrame*)wf->FindByName(_T("frmTaskTypes"));
    assert(wTaskTypes!=NULL);

    wTaskTypes->SetActivateCallback(OnTaskListEnter);
    wTaskTypes->SetPaintItemCallback(OnTaskPaintListItem);
    wTaskTypes->SetCursorCallback(OnTaskCursorCallback);

    wTaskTypes->SetLength(factory_types.size());

    for (unsigned i=0; i<factory_types.size(); i++) {
        if (factory_types[i] == ordered_task->get_factory_type()) {
            wTaskTypes->SetCursorIndex(i);
        }
    }

    RefreshView();

    if (!wf) return false;
    assert(wf!=NULL);

    if (wf->ShowModal()== mrOK) {
        if (*task != ordered_task) {
            *task = ordered_task;
        }
    }

    delete wf;
    wf = NULL;

    return task_modified;
}
Ejemplo n.º 5
0
static void
OnTaskPaintListItem(Canvas &canvas, const RECT rc, unsigned DrawListIndex)
{
    assert(DrawListIndex < factory_types.size());

    TCHAR sTmp[120];

    const TCHAR* text = OrderedTaskFactoryName(factory_types[DrawListIndex]);

    if (factory_types[DrawListIndex] == ordered_task->get_factory_type()) {
        _stprintf(sTmp, _T("*%s"), text);
    } else {
        _stprintf(sTmp, _T(" %s"), text);
    }
    canvas.text(rc.left + Layout::FastScale(2), rc.top + Layout::FastScale(2),
                sTmp);
}
Ejemplo n.º 6
0
bool Statistic::_Goods::canProduce(good::Product type) const
{
  FactoryList buildings = _parent.objects.producers<Factory>( type );
  return !buildings.empty();
}