CityServiceProsperity::CityServiceProsperity( CityPtr city )
  : CityService( getDefaultName() ), _d( new Impl )
{
  _d->city = city;
  _d->lastDate = GameDate::current();
  _d->prosperity = 0;
  _d->houseCapTrand = 0;
  _d->prosperityExtend = 0;
  _d->makeProfit = false;
  _d->lastYearBalance = city->getFunds().getValue();
  _d->worklessPercent = 0;
  _d->workersSalary = city->getFunds().getWorkerSalary();
  _d->lastYearProsperity = 0;
  _d->percentPlebs = 0;
}
  void drawReportRow( const Point& pos, const std::string& title, CityFunds::IssueType type )
  {
    Font font = Font::create( FONT_1 );

    int lyvalue = city->getFunds().getIssueValue( type, CityFunds::lastYear );
    int tyvalue = city->getFunds().getIssueValue( type, CityFunds::thisYear );

    font.draw( *background, title, pos, false );
    font.draw( *background, StringHelper::format( 0xff, "%d", lyvalue ), pos + Point( 215, 0), false );
    font.draw( *background, StringHelper::format( 0xff, "%d", tyvalue ), pos + Point( 355, 0), false );
  }
AdvisorFinanceWindow::AdvisorFinanceWindow( CityPtr city, Widget* parent, int id ) 
: Widget( parent, id, Rect( 0, 0, 1, 1 ) ), _d( new Impl )
{
  _d->city = city;
  setGeometry( Rect( Point( (parent->getWidth() - 640 )/2, parent->getHeight() / 2 - 242 ),
               Size( 640, 420 ) ) );

  Label* title = new Label( this, Rect( 60, 10, 60 + 210, 10 + 40) );
  title->setText( _("##Finance advisor##") );
  title->setFont( Font::create( FONT_3 ) );
  title->setTextAlignment( alignUpperLeft, alignCenter );

  _d->background.reset( Picture::create( getSize() ) );

  //main _d->_d->background
  GuiPaneling::instance().draw_white_frame(*_d->background, 0, 0, getWidth(), getHeight() );
  Picture& icon = Picture::load( ResourceGroup::panelBackground, 265 );
  _d->background->draw( icon, Point( 11, 11 ) );

  //buttons _d->_d->background
  Font fontWhite = Font::create( FONT_1_WHITE );
  GuiPaneling::instance().draw_black_frame( *_d->background, 70, 50, getWidth() - 86, 70 );
  std::string moneyStr = StringHelper::format( 0xff, "%s %d %s", _("##city_have##"), city->getFunds().getValue(), _("##denaries##") );
  fontWhite.draw( *_d->background, moneyStr, 70, 55, false );
  fontWhite.draw( *_d->background, _("##tax_rate##"), 65, 75, false );

  _d->lbTaxRateNow = new Label( this, Rect( 245, 75, 245 + 350, 75 + 20 ), "" );
  _d->lbTaxRateNow->setFont( fontWhite );
  _d->updateTaxRateNowLabel();

  std::string strRegPaeyrs = StringHelper::format( 0xff, "%d%% %s", 0, _("##population_registered_as_taxpayers##") );
  fontWhite.draw( *_d->background, strRegPaeyrs, 70, 95, false );

  Font font = Font::create( FONT_1 );
  font.draw( *_d->background, _("##Last year##"), 265, 130, false );
  font.draw( *_d->background, _("##This year##"), 400, 130, false );

  Point startPoint( 75, 145 );
  Point offset( 0, 17 );

  _d->drawReportRow( startPoint, _("##Taxes##"), 0, 0 );
  _d->drawReportRow( startPoint + offset, _("##Trade##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 2, _("##Donations"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 3, _("##Debet##"), 0, 0 );
  _d->background->fill( 0xff000000, Rect( startPoint + offset * 3 + Point( 200, 0 ), Size( 72, 1) ) );
  _d->background->fill( 0xff000000, Rect( startPoint + offset * 3 + Point( 340, 0 ), Size( 72, 1) ) );
  
  startPoint += Point( 0, 6 );
  _d->drawReportRow( startPoint + offset * 4, _("##Import##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 5, _("##Salaries##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 6, _("##Buildings##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 7, _("##Percents##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 8, _("##Self salary##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 9, _("##Other##"), 0, 0 );
  _d->drawReportRow( startPoint + offset * 10, _("##Empire tax##"), 0, 0 );
  _d->background->fill( 0xff000000, Rect( startPoint + offset * 10 + Point( 200, 0 ), Size( 72, 1) ) );
  _d->background->fill( 0xff000000, Rect( startPoint + offset * 10 + Point( 340, 0 ), Size( 72, 1) ) );

  _d->drawReportRow( startPoint + offset * 11, _("##Credit##"), 0, 0 );

  startPoint += Point( 0, 6 );
  _d->drawReportRow( startPoint + offset * 12, _("##Profit##"), 0, 0 );
  
  startPoint += Point( 0, 6 );
  _d->drawReportRow( startPoint + offset * 13, _("##Balance##"), 0, 0 );

  _d->btnHelp = new TexturedButton( this, Point( 12, getHeight() - 39), Size( 24 ), -1, ResourceMenu::helpInfBtnPicId );

  Picture pic = Picture::load( ResourceGroup::advisorwindow, 1 );
  PushButton* btn = new PushButton( this, Rect( Point( 185, 70 ), Size( 24 ) ), "", -1 );
  btn->setPicture( &pic, stNormal );
  btn->setPicture( &pic, stHovered );
  btn->setPicture( &pic, stPressed );

  pic = Picture::load( ResourceGroup::advisorwindow, 2 );
  btn = new PushButton( this, Rect( Point( 185+24, 70 ), Size( 24 ) ), "", -1 );
  btn->setPicture( &pic, stNormal );
  btn->setPicture( &pic, stHovered );
  btn->setPicture( &pic, stPressed );
}
Пример #4
0
void ScreenGame::initialize( GfxEngine& engine, GuiEnv& gui )
{
  _d->gui = &gui;
  _d->engine = &engine;
  _d->infoBoxMgr = InfoBoxManager::create( &gui );

  CityPtr city = _d->scenario->getCity();

  _d->gui->clear();

  /*new PopupMessageBox( _d->gui->getRootWidget(), "Test title", "This is test string for popup message box", 
                       "Sen 351 BC", "For New player" ); */

  const int topMenuHeight = 23;
  const Picture& rPanelPic = Picture::load( ResourceGroup::panelBackground, 14 );
  Rect rPanelRect( engine.getScreenWidth() - rPanelPic.getWidth(), topMenuHeight,
                   engine.getScreenWidth(), engine.getScreenHeight() );

  _d->rightPanel = MenuRigthPanel::create( gui.getRootWidget(), rPanelRect, rPanelPic);

  _d->topMenu = TopMenu::create( gui.getRootWidget(), topMenuHeight );
  _d->topMenu->setPopulation( city->getPopulation() );
  _d->topMenu->setFunds( city->getFunds().getValue() );
  _d->topMenu->setDate( GameDate::current() );

  _d->menu = Menu::create( gui.getRootWidget(), -1, _d->scenario->getCity() );
  _d->menu->setPosition( Point( engine.getScreenWidth() - _d->menu->getWidth() - _d->rightPanel->getWidth(), 
                                 _d->topMenu->getHeight() ) );

  _d->extMenu = ExtentMenu::create( gui.getRootWidget(), _d->mapRenderer, -1, _d->scenario->getCity() );
  _d->extMenu->setPosition( Point( engine.getScreenWidth() - _d->extMenu->getWidth() - _d->rightPanel->getWidth(), 
                                     _d->topMenu->getHeight() ) );

  _d->wndStackMsgs = WindowMessageStack::create( gui.getRootWidget(), -1 );
  _d->wndStackMsgs->setPosition( Point( gui.getRootWidget()->getWidth() / 4, 33 ) );
  _d->wndStackMsgs->sendToBack();
    
  _d->rightPanel->bringToFront();

  // 8*30: used for high buildings (granary...), visible even when not in tilemap_area.
  getMapArea().setViewSize( engine.getScreenSize() + Size( 180 ) );
        
  // here move camera to start position of map
  getMapArea().setCenterIJ( _d->scenario->getCity()->getCameraPos() ); 

  new SenatePopupInfo( _d->gui->getRootWidget(), _d->mapRenderer );

  //connect elements
  CONNECT( _d->topMenu, onSave(), _d.data(), Impl::showSaveDialog );
  CONNECT( _d->topMenu, onExit(), this, ScreenGame::resolveExitGame );
  CONNECT( _d->topMenu, onEnd(), this, ScreenGame::resolveEndGame );
  CONNECT( _d->topMenu, onRequestAdvisor(), _d.data(), Impl::showAdvisorsWindow );

  CONNECT( _d->menu, onCreateConstruction(), _d.data(), Impl::resolveCreateConstruction );
  CONNECT( _d->menu, onRemoveTool(), _d.data(), Impl::resolveRemoveTool );
  CONNECT( _d->menu, onMaximize(), _d->extMenu, ExtentMenu::maximize );

  CONNECT( _d->extMenu, onCreateConstruction(), _d.data(), Impl::resolveCreateConstruction );
  CONNECT( _d->extMenu, onRemoveTool(), _d.data(), Impl::resolveRemoveTool );

  CONNECT( city, onPopulationChanged(), _d->topMenu, TopMenu::setPopulation );
  CONNECT( city, onFundsChanged(), _d->topMenu, TopMenu::setFunds );
  CONNECT( &GameDate::instance(), onMonthChanged(), _d->topMenu, TopMenu::setDate );

  CONNECT( &_d->mapRenderer, onShowTileInfo(), _d.data(), Impl::showTileInfo );

  CONNECT( city, onWarningMessage(), _d->wndStackMsgs, WindowMessageStack::addMessage );
  CONNECT( &_d->mapRenderer, onWarningMessage(), _d->wndStackMsgs, WindowMessageStack::addMessage );
  CONNECT( _d->extMenu, onSelectOverlayType(), _d.data(), Impl::resolveSelectOverlayView );
  CONNECT( _d->extMenu, onEmpireMapShow(), _d.data(), Impl::showEmpireMapWindow );
  CONNECT( _d->extMenu, onAdvisorsWindowShow(), _d.data(), Impl::showAdvisorsWindow );
  CONNECT( _d->extMenu, onMissionTargetsWindowShow(), _d.data(), Impl::showMissionTaretsWindow );

  CONNECT( city, onDisasterEvent(), &_d->alarmsHolder, AlarmEventHolder::add );
  CONNECT( _d->extMenu, onSwitchAlarm(), &_d->alarmsHolder, AlarmEventHolder::next );
  CONNECT( &_d->alarmsHolder, onMoveToAlarm(), &_d->mapArea, TilemapArea::setCenterIJ );
  CONNECT( &_d->alarmsHolder, onAlarmChange(), _d->extMenu, ExtentMenu::setAlarmEnabled );
}