void AdvisorsWindow::showAdvisor( const AdvisorType type ) { if( type >= ADV_COUNT ) return; Widget::Widgets children = getChildren(); foreach( Widget* child, children ) { if( PushButton* btn = safety_cast< PushButton* >( child ) ) { btn->setPressed( btn->getID() == type ); } } if( _d->advisorPanel ) { _d->advisorPanel->deleteLater(); _d->advisorPanel = 0; } switch( type ) { case ADV_EMPLOYERS: _d->advisorPanel = new AdvisorEmployerWindow( _d->city, this, ADV_EMPLOYERS ); break; case ADV_LEGION: _d->advisorPanel = new AdvisorLegionWindow( this, ADV_LEGION ); break; case ADV_EMPIRE: { AdvisorEmperorWindow* wnd = new AdvisorEmperorWindow( this, _d->city->getPlayer()->getMoney(), ADV_EMPIRE ); _d->advisorPanel = wnd; CONNECT( wnd, onSendMoney(), _d.data(), Impl::sendMoney2City ); } break; case ADV_RATINGS: _d->advisorPanel = new AdvisorRatingsWindow( this, ADV_RATINGS, _d->city ); break; case ADV_TRADING: { AdvisorTradeWindow* wnd = new AdvisorTradeWindow( _d->city, this, ADV_TRADING ); _d->advisorPanel = wnd; CONNECT( wnd, onEmpireMapRequest(), _d.data(), Impl::showEmpireMapWindow ); } break; case ADV_EDUCATION: _d->advisorPanel = new AdvisorEducationWindow( _d->city, this, -1 ); break; case ADV_HEALTH: _d->advisorPanel = new AdvisorHealthWindow( _d->city, this, -1 ); break; case ADV_ENTERTAINMENT: _d->advisorPanel = new AdvisorEntertainmentWindow( _d->city, this, -1 ); break; case ADV_RELIGION: _d->advisorPanel = new AdvisorReligionWindow( _d->city, this, -1 ); break; case ADV_FINANCE: _d->advisorPanel = new AdvisorFinanceWindow( _d->city, this, -1 ); break; default: break; } }
void ScreenGame::Impl::showAdvisorsWindow( const int advType ) { List<AdvisorsWindow*> wndList = gui->getRootWidget()->findChildren<AdvisorsWindow*>(); if( wndList.size() == 1 ) { wndList.front()->bringToFront(); wndList.front()->showAdvisor( (AdvisorType)advType ); } else { AdvisorsWindow* advWnd = AdvisorsWindow::create( gui->getRootWidget(), -1, (AdvisorType)advType, scenario->getCity() ); CONNECT( advWnd, onEmpireMapRequest(), this, Impl::showEmpireMapWindow ); } }