void Sentiment::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { HousePtr house = tile->overlay().as<House>(); if( house.isValid() ) { int happiness = math::clamp<int>( house->state( pr::happiness ) / maxSentimentLevel, 0, maxSentimentLevel-1 ); text = sentimentLevelName[ happiness ]; } } _setTooltipText( text ); } break; default: break; } } Layer::handleEvent( event ); }
void Religion::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { auto house = tile->overlay<House>(); if( house.isValid() ) { int templeAccess = house->spec().computeReligionLevel( house ); bool oracleAccess = house->hasServiceAccess( Service::oracle ); text = (templeAccess == 5 && oracleAccess ) ? "##religion_access_full##" : utils::format( 0xff, "##religion_access_%d_temple##", templeAccess ); } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void MarketAccess::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { HousePtr house = tile->overlay<House>(); if( house.isValid() ) { int accessLevel = house->getServiceValue( Service::market ); accessLevel = math::clamp<int>( accessLevel / maxAccessLevel, 0, maxAccessLevel-1 ); text = marketLevelName[ accessLevel ]; } } _setTooltipText( text ); } break; default: break; } } Layer::handleEvent( event ); }
void Fire::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { ConstructionPtr constr = ptr_cast<Construction>( tile->overlay() ); if( constr != 0 ) { int fireLevel = math::clamp<int>( constr->state( pr::fire ), 0, 100 ); text = fireLevelName[ math::clamp<int>( fireLevel / 10, 0, 9 ) ]; } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void Crime::onEvent( const NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case NEvent::Mouse::moved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { auto house = tile->overlay<House>(); if( house != 0 ) { int crime = (int)house->getServiceValue( Service::crime ); text = crimeDesc[ math::clamp<int>( crime / 11, 0, 7 ) ]; } } _setTooltipText( _(text) ); } break; default: break; } } Layer::onEvent( event ); }
void Water::onEvent( const NEvent& event) { if( event.EventType == sEventKeyboard ) { if( event.keyboard.control && !event.keyboard.pressed && event.keyboard.key == KEY_KEY_E ) { _d->showWaterValue = !_d->showWaterValue; } } if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case NEvent::Mouse::moved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { bool isWater = tile->getFlag( Tile::tlWater ) || tile->getFlag( Tile::tlDeepWater ); if( !isWater ) { int wtrSrvc = (tile->param( Tile::pWellWater ) > 0 ? 1 : 0); wtrSrvc |= (tile->param( Tile::pFountainWater ) > 0 ? 2 : 0); wtrSrvc |= (tile->param( Tile::pReservoirWater ) > 0 ? 4 : 0); switch( wtrSrvc ) { case 0: /*text = "##water_srvc_no_water##";*/ break; case 1: text = "##water_srvc_well##"; break; case 2: case 6: text = "##water_srvc_fountain##"; break; case 3: text = "##water_srvc_fountain_and_well##"; break; case 7: text = "##water_srvc_fountain_and_reservoir##"; break; case 4: case 5: text = "##water_srvc_reservoir##"; break; } } _d->overlay.underMouse = tile->overlay(); } _setTooltipText( _(text) ); } break; case NEvent::Mouse::btnLeftPressed: { _d->overlay.selected = _d->overlay.underMouse; _updatePaths(); } break; default: break; } } Layer::onEvent( event ); }
void Health::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { HousePtr house = ptr_cast<House>( tile->overlay() ); if( house != 0 ) { std::string typeName; switch( _type ) { case citylayer::health: typeName = "health"; break; case citylayer::doctor: typeName = "doctor"; break; case citylayer::hospital: typeName = "hospital"; break; case citylayer::barber: typeName = "barber"; break; case citylayer::baths: typeName = "baths"; break; } int lvlValue = _getLevelValue( house ); std::string levelName; if( lvlValue > 0 ) { if( lvlValue < 20 ) { levelName = "##warning_"; } else if( lvlValue < 40 ) { levelName = "##bad_"; } else if( lvlValue < 60 ) { levelName = "##simple_"; } else if( lvlValue < 80 ) { levelName = "##good_"; } else { levelName = "##awesome_"; } text = levelName + typeName + "_access##"; } } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void Unemployed::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { HousePtr house = tile->overlay().as<House>(); WorkingBuildingPtr workBuilding = tile->overlay().as<WorkingBuilding>(); if( house.isValid() ) { int workless = house->getServiceValue( Service::recruter ); if( workless > 0 ) text = utils::format( 0xff, "%s %d %s", _("##this_house_have##"), workless, _("##unemployers##") ); else text = "##this_house_haveno_unemployers##"; } else if( workBuilding.isValid() ) { int need = workBuilding->needWorkers(); if( need > 0 ) text = utils::format( 0xff, "%s %d %s", _("##this_building_need##"), need, _("##workers##") ); else text = "##this_building_have_all_workers##"; } } _setTooltipText( text ); } break; default: break; } } Layer::handleEvent( event ); }
void Tax::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { BuildingPtr bld = ptr_cast<Building>( tile->overlay() ); if( bld.isNull() ) { text = "##no_people_in_this_locality##"; } else { HousePtr house = ptr_cast<House>( tile->overlay() ); if( house.isValid() ) { int taxAccess = house->hasServiceAccess( Service::forum ); if( taxAccess < 25 ) text = "##house_not_registered_for_taxes##"; } } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void Tax::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { auto building = tile->overlay<Building>(); if( building.isNull() ) { text = "##no_people_in_this_locality##"; } else { auto house = tile->overlay<House>(); if( house.isValid() ) { bool lastTaxationTooOld = house->lastTaxationDate().monthsTo( game::Date::current() ) > DateTime::monthsInYear / 2; if( lastTaxationTooOld ) text = "##house_not_registered_for_taxes##"; } } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void Aborigens::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { } _setTooltipText( text ); } break; default: break; } } Layer::handleEvent( event ); }
void Entertainment::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; if( tile != 0 ) { HousePtr house = tile->overlay<House>(); if( house != 0 ) { std::string typeName; switch( _type ) { case citylayer::entertainment: typeName = "entertainment"; break; case citylayer::theater: typeName = "theater"; break; case citylayer::amphitheater: typeName = "amphitheater"; break; case citylayer::colloseum: typeName = "colloseum"; break; case citylayer::hippodrome: typeName = "hippodrome"; break; } int lvlValue = _getLevelValue( house ); if( _type == citylayer::entertainment ) { text = utils::format( 0xff, "##%d_entertainment_access##", lvlValue / 10 ); } else { std::string levelName; if( lvlValue > 0 ) { if( lvlValue < 20 ) { levelName = "##warning_"; } else if( lvlValue < 40 ) { levelName = "##bad_"; } else if( lvlValue < 60 ) { levelName = "##simple_"; } else if( lvlValue < 80 ) { levelName = "##good_"; } else { levelName = "##awesome_"; } text = levelName + typeName + "_access##"; } else { text = levelName + "_no_access"; } } } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }
void Education::handleEvent(NEvent& event) { if( event.EventType == sEventMouse ) { switch( event.mouse.type ) { case mouseMoved: { Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL) std::string text = ""; std::string levelName = ""; if( tile != 0 ) { auto house = tile->overlay<House>(); if( house != 0 ) { std::string typeName; int lvlValue = _getLevelValue( house ); switch( _type ) { case citylayer::education: { bool schoolAccess = house->hasServiceAccess( Service::school ); bool libraryAccess = house->hasServiceAccess( Service::library ); bool academyAccess = house->hasServiceAccess( Service::academy ); if( schoolAccess && libraryAccess && academyAccess ) { text = "##education_full_access##"; } else { if( schoolAccess && libraryAccess ) { text = "##education_have_school_library_access##"; } else if( schoolAccess || libraryAccess ) { text = "##education_have_school_or_library_access##"; } else if( academyAccess ) { text = "##education_have_academy_access##"; } else { text = "##education_have_no_access##"; } } } break; case citylayer::school: typeName = "school"; break; case citylayer::library: typeName = "library"; break; case citylayer::academy: typeName = "academy"; break; } if( text.empty() ) { levelName = _getAccessLevel( lvlValue ); text = levelName + typeName + "_access##"; } } } _setTooltipText( _(text) ); } break; default: break; } } Layer::handleEvent( event ); }