void Level::initialize() { PlayerCityPtr city = _d->game->city(); _d->initRender(); _d->initMainUI(); _d->installHandlers( this ); _d->initSound(); _d->initTabletUI( this ); _d->undoStack.init( city ); //connect elements //city->tilemap().setFlag( Tilemap::fSvkGround, !KILLSWITCH(oldgfx) ); CONNECT( city, onWarningMessage(), _d.data(), Impl::resolveWarningMessage ) //CONNECT( _d->extMenu, onSelectOverlayType(), _d.data(), Impl::resolveSelectLayer ) CONNECT( city, onDisasterEvent(), &_d->alarmsHolder, AlarmEventHolder::add ) CONNECT( &_d->alarmsHolder, onMoveToAlarm(), _d->renderer.camera(), Camera::setCenter ) CONNECT( &_d->alarmsHolder, onAlarmChange(), _d.data(), Impl::setAlarmEnabled ) CONNECT( _d->renderer.camera(), onPositionChanged(), _d.data(), Impl::saveCameraPos ) CONNECT( _d->renderer.camera(), onDirectionChanged(), _d.data(), Impl::handleDirectionChange ) CONNECT( &_d->renderer, onLayerSwitch(), _d.data(), Impl::layerChangedOut ) CONNECT( &_d->undoStack, onUndoChange(), _d.data(), Impl::resolveUndoChange ) _d->renderer.camera()->setCenter(city->cameraPos()); _d->dhandler.insertTo(_d->game, _d->topMenu); _d->dhandler.setVisible(false); events::dispatch<events::ScriptFunc>("OnMissionStart"); }
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 ); }