void CastleRedrawTownName(const Castle & castle, const Point & dst) { const Sprite & ramka = AGG::GetICN(ICN::TOWNNAME, 0); Point dst_pt(dst.x + 320 - ramka.w() / 2, dst.y + 248); ramka.Blit(dst_pt); Text text(castle.GetName(), Font::SMALL); dst_pt.x = dst.x + 320 - text.w() / 2; dst_pt.y = dst.y + 248; text.Blit(dst_pt); }
void Dialog::QuickInfo(const Castle & castle) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); const ICN::icn_t qwiktown = ICN::QWIKTOWN; AGG::PreloadObject(qwiktown); // image box const Sprite &box = AGG::GetICN(qwiktown, 0); const Interface::GameArea & gamearea = Interface::GameArea::Get(); const Rect ar(BORDERWIDTH, BORDERWIDTH, gamearea.GetArea().w, gamearea.GetArea().h); LocalEvent & le = LocalEvent::Get(); const Point & mp = le.GetMouseCursor(); Rect cur_rt; u16 mx = (mp.x - BORDERWIDTH) / TILEWIDTH; mx *= TILEWIDTH; u16 my = (mp.y - BORDERWIDTH) / TILEWIDTH; my *= TILEWIDTH; // top left if(mx <= ar.x + ar.w / 2 && my <= ar.y + ar.h / 2) cur_rt = Rect(mx + TILEWIDTH, my + TILEWIDTH, box.w(), box.h()); else // top right if(mx > ar.x + ar.w / 2 && my <= ar.y + ar.h / 2) cur_rt = Rect(mx - box.w(), my + TILEWIDTH, box.w(), box.h()); else // bottom left if(mx <= ar.x + ar.w / 2 && my > ar.y + ar.h / 2) cur_rt = Rect(mx + TILEWIDTH, my - box.h(), box.w(), box.h()); else // bottom right cur_rt = Rect(mx - box.w(), my - box.h(), box.w(), box.h()); if(Settings::Get().QVGA()) { cur_rt = Rect((display.w() - box.w()) / 2, (display.h() - box.h()) / 2, box.w(), box.h()); } Background back(cur_rt); back.Save(); display.Blit(box, cur_rt.x, cur_rt.y); cur_rt = Rect(back.GetRect().x + 28 , back.GetRect().y + 12, 178, 140); Point dst_pt; Text text; // castle name text.Set(castle.GetName(), Font::SMALL); dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2; dst_pt.y = cur_rt.y + 5; text.Blit(dst_pt); u8 index = 0; switch(castle.GetRace()) { case Race::KNGT: index = (castle.isCastle() ? 9 : 15); break; case Race::BARB: index = (castle.isCastle() ? 10 : 16); break; case Race::SORC: index = (castle.isCastle() ? 11 : 17); break; case Race::WRLK: index = (castle.isCastle() ? 12 : 18); break; case Race::WZRD: index = (castle.isCastle() ? 13 : 19); break; case Race::NECR: index = (castle.isCastle() ? 14 : 20); break; default: DEBUG(DBG_GAME , DBG_WARN, "Dialog::QuickInfo: unknown race."); return; } // castle icon const Sprite & sprite = AGG::GetICN(ICN::LOCATORS, index); dst_pt.x = cur_rt.x + (cur_rt.w - sprite.w()) / 2; dst_pt.y += 18; display.Blit(sprite, dst_pt); // color flags switch(castle.GetColor()) { case Color::BLUE: index = 0; break; case Color::GREEN: index = 2; break; case Color::RED: index = 4; break; case Color::YELLOW: index = 6; break; case Color::ORANGE: index = 8; break; case Color::PURPLE: index = 10; break; case Color::GRAY: index = 12; break; } const Sprite & l_flag = AGG::GetICN(ICN::FLAG32, index); dst_pt.x = cur_rt.x + (cur_rt.w - 60) / 2 - l_flag.w(); display.Blit(l_flag, dst_pt); const Sprite & r_flag = AGG::GetICN(ICN::FLAG32, index + 1); dst_pt.x = cur_rt.x + (cur_rt.w + 60) / 2; display.Blit(r_flag, dst_pt); // info text.Set(_("Defenders:")); dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2; dst_pt.y += sprite.h() + 5; text.Blit(dst_pt); u8 count = castle.GetArmy().GetCount(); if(! count) { text.Set(_("None")); dst_pt.x = cur_rt.x + (cur_rt.w - text.w()) / 2; dst_pt.y += 45; text.Blit(dst_pt); } else castle.GetArmy().DrawMons32Line(cur_rt.x - 5, cur_rt.y + 100, 192, 0, 0, (Settings::Get().MyColor() != castle.GetColor())); cursor.Show(); display.Flip(); // quick info loop while(le.HandleEvents() && le.MousePressRight()); // restore background cursor.Hide(); back.Restore(); cursor.Show(); display.Flip(); }