void CastleRedrawCurrentBuilding(const Castle & castle, const Point & dst_pt, const CastleDialog::CacheBuildings & orders, u32 build, u32 flash) { u32 & frame = Game::CastleAnimationFrame(); Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); Sprite townbkg; // before redraw switch(castle.GetRace()) { case Race::KNGT: townbkg = AGG::GetICN(ICN::TOWNBKG0, 0); break; case Race::BARB: townbkg = AGG::GetICN(ICN::TOWNBKG1, 0); break; case Race::SORC: townbkg = AGG::GetICN(ICN::TOWNBKG2, 0); break; case Race::WRLK: townbkg = AGG::GetICN(ICN::TOWNBKG3, 0); break; case Race::WZRD: townbkg = AGG::GetICN(ICN::TOWNBKG4, 0); break; case Race::NECR: townbkg = AGG::GetICN(ICN::TOWNBKG5, 0); break; default: break; } const Rect max = CastleGetMaxArea(castle, dst_pt); if(townbkg.isValid()) townbkg.Blit(dst_pt.x, dst_pt.y); if(Race::BARB == castle.GetRace()) { const Sprite & sprite0 = AGG::GetICN(ICN::TWNBEXT1, 1 + frame % 5); sprite0.Blit(dst_pt.x + sprite0.x(), dst_pt.y + sprite0.y()); } // sea anime if(Race::WZRD == castle.GetRace() || (!castle.isBuild(BUILD_SHIPYARD) && castle.HaveNearlySea())) { Sprite sprite50, sprite51; switch(castle.GetRace()) { case Race::KNGT: sprite50 = AGG::GetICN(ICN::TWNKEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNKEXT0, 1 + frame % 5); break; case Race::BARB: sprite50 = AGG::GetICN(ICN::TWNBEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNBEXT0, 1 + frame % 5); break; case Race::SORC: sprite50 = AGG::GetICN(ICN::TWNSEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNSEXT0, 1 + frame % 5); break; case Race::NECR: sprite50 = AGG::GetICN(ICN::TWNNEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNNEXT0, 1 + frame % 5); break; case Race::WRLK: sprite50 = AGG::GetICN(ICN::TWNWEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNWEXT0, 1 + frame % 5); break; case Race::WZRD: sprite50 = AGG::GetICN(ICN::TWNZEXT0, 0); sprite51 = AGG::GetICN(ICN::TWNZEXT0, 1 + frame % 5); break; default: break; } if(sprite50.isValid()) CastleDialog::RedrawBuildingSpriteToArea(sprite50, dst_pt.x + sprite50.x(), dst_pt.y + sprite50.y(), max); if(sprite51.isValid()) CastleDialog::RedrawBuildingSpriteToArea(sprite51, dst_pt.x + sprite51.x(), dst_pt.y + sprite51.y(), max); } // redraw all builds if(BUILD_NOTHING == build) { for(CastleDialog::CacheBuildings::const_iterator it = orders.begin(); it != orders.end(); ++it) { if(castle.isBuild((*it).id)) { CastleRedrawBuilding(castle, dst_pt, (*it).id, frame, 0); if(flash == (*it).id) { CastleDialog::RedrawBuildingSpriteToArea((*it).contour, dst_pt.x + (*it).contour.x(), dst_pt.y + (*it).contour.y(), max); } CastleRedrawBuildingExtended(castle, dst_pt, (*it).id, frame); } } } // redraw build with alpha else if(orders.end() != std::find(orders.begin(), orders.end(), build)) { LocalEvent & le = LocalEvent::Get(); int alpha = 1; while(le.HandleEvents() && alpha < 250) { if(Game::AnimateInfrequentDelay(Game::CASTLE_BUILD_DELAY)) { cursor.Hide(); for(CastleDialog::CacheBuildings::const_iterator it = orders.begin(); it != orders.end(); ++it) { const u32 & build2 = (*it).id; if(castle.isBuild(build2)) { CastleRedrawBuilding(castle, dst_pt, build2, frame, 0); CastleRedrawBuildingExtended(castle, dst_pt, build2, frame); } else if(build2 == build) { CastleRedrawBuilding(castle, dst_pt, build2, frame, alpha); CastleRedrawTownName(castle, dst_pt); alpha += 10; } } CastleRedrawTownName(castle, dst_pt); cursor.Show(); display.Flip(); } ++frame; } cursor.Hide(); } ++frame; }
void CastleDialog::RedrawBuildingSpriteToArea(const Sprite & sprite, s32 dst_x, s32 dst_y, const Rect & max) { std::pair<Rect, Point> res = Rect::Fixed4Blit(Rect(dst_x, dst_y, sprite.w(), sprite.h()), max); sprite.Blit(res.first, res.second); }