Army::Troop::Troop(const Maps::Tiles & t) : army(NULL), battle(NULL) { id = Monster::FromInt(t.GetQuantity3()); count = t.GetCountMonster(); }
void Dialog::QuickInfo(const Maps::Tiles & tile) { Display & display = Display::Get(); Cursor & cursor = Cursor::Get(); cursor.Hide(); // preload const ICN::icn_t qwikinfo = ICN::QWIKINFO; AGG::PreloadObject(qwikinfo); // image box const Sprite &box = AGG::GetICN(qwikinfo, 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 pos; 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) pos = 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) pos = 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) pos = Rect(mx + TILEWIDTH, my - box.h(), box.w(), box.h()); else // bottom right pos = Rect(mx - box.w(), my - box.h(), box.w(), box.h()); Background back(pos); back.Save(); display.Blit(box, pos.x, pos.y); std::string name_object; const Settings & settings = Settings::Get(); const Heroes* hero = (Game::Focus::HEROES == Game::Focus::Get().Type() ? &Game::Focus::Get().GetHeroes() : NULL); const Kingdom & kingdom = world.GetKingdom(settings.MyColor()); if(tile.isFog(settings.MyColor())) name_object = _("Unchartered Territory"); else // check guardians mine if(MP2::OBJ_ABANDONEDMINE == tile.GetObject() || tile.CheckEnemyGuardians(0)) { const Army::Troop troop(tile); if(MP2::OBJ_MINES == tile.GetObject()) name_object = Maps::GetMinesName(tile.GetMinesType()); else name_object = MP2::StringObject(tile.GetObject()); name_object.append("\n"); name_object.append(_("guarded by %{count} of %{monster}")); std::string name = troop.GetMultiName(); if(!settings.Unicode()) String::Lower(name); String::Replace(name_object, "%{monster}", name); if(settings.MyColor() == world.ColorCapturedObject(tile.GetIndex())) { name.clear(); String::AddInt(name, troop.GetCount()); } else { name = Army::String(troop.GetCount()); if(!settings.Unicode()) String::Lower(name); } String::Replace(name_object, "%{count}", name); } else switch(tile.GetObject()) { case MP2::OBJ_MONSTER: { const Army::Troop troop(tile); name_object = ArmyGetSizeString(troop.GetCount()); std::string name = troop.GetMultiName(); if(!settings.Unicode()) String::Lower(name); String::Replace(name_object, "%{monster}", name); } break; case MP2::OBJ_EVENT: case MP2::OBJ_ZERO: name_object = Maps::Ground::String(tile.GetGround()); break; case MP2::OBJ_DERELICTSHIP: case MP2::OBJ_SHIPWRECK: case MP2::OBJ_GRAVEYARD: case MP2::OBJ_DAEMONCAVE: case MP2::OBJ_PYRAMID: case MP2::OBJ_WAGON: case MP2::OBJ_SKELETON: case MP2::OBJ_WINDMILL: case MP2::OBJ_WATERWHEEL: case MP2::OBJ_LEANTO: case MP2::OBJ_MAGICGARDEN: name_object = MP2::StringObject(tile.GetObject()); // check visited if(settings.ExtShowVisitedContent() && kingdom.isVisited(tile)) { name_object.append("\n"); name_object.append(_("(already visited)")); } break; case MP2::OBJ_RESOURCE: name_object = MP2::StringObject(tile.GetObject()); // check visited if(settings.ExtShowVisitedContent()) { name_object.append("\n("); name_object.append(Resource::String(tile.GetQuantity1())); name_object.append(")"); } break; case MP2::OBJ_ARTIFACT: name_object = MP2::StringObject(tile.GetObject()); // check visited if(settings.ExtShowVisitedContent()) { name_object.append("\n("); name_object.append( Artifact::GetName(Artifact::FromInt(tile.GetQuantity1()))); name_object.append(")"); } break; case MP2::OBJ_MINES: name_object = Maps::GetMinesName(tile.GetMinesType()); break; // join army case MP2::OBJ_WATCHTOWER: case MP2::OBJ_EXCAVATION: case MP2::OBJ_CAVE: case MP2::OBJ_TREEHOUSE: case MP2::OBJ_ARCHERHOUSE: case MP2::OBJ_GOBLINHUT: case MP2::OBJ_DWARFCOTT: case MP2::OBJ_HALFLINGHOLE: case MP2::OBJ_PEASANTHUT: case MP2::OBJ_THATCHEDHUT: // recruit army case MP2::OBJ_RUINS: case MP2::OBJ_TREECITY: case MP2::OBJ_WAGONCAMP: case MP2::OBJ_DESERTTENT: // battle and recruit army case MP2::OBJ_DRAGONCITY: case MP2::OBJ_CITYDEAD: case MP2::OBJ_TROLLBRIDGE: name_object = MP2::StringObject(tile.GetObject()); if(settings.ExtShowVisitedContent() && kingdom.isVisited(tile)) { name_object.append("\n"); if(tile.GetCountMonster()) { name_object.append(_("(available: %{count})")); String::Replace(name_object, "%{count}", tile.GetCountMonster()); } else { name_object.append("(empty)"); } } break; case MP2::OBJ_GAZEBO: case MP2::OBJ_FORT: case MP2::OBJ_XANADU: case MP2::OBJ_MERCENARYCAMP: case MP2::OBJ_DOCTORHUT: case MP2::OBJ_STANDINGSTONES: case MP2::OBJ_ARTESIANSPRING: case MP2::OBJ_TREEKNOWLEDGE: name_object = MP2::StringObject(tile.GetObject()); // check visited if(hero) { name_object.append("\n"); name_object.append(hero->isVisited(tile) ? _("(already visited)") : _("(not visited)")); } break; case MP2::OBJ_MAGICWELL: case MP2::OBJ_FOUNTAIN: case MP2::OBJ_FAERIERING: case MP2::OBJ_IDOL: case MP2::OBJ_OASIS: case MP2::OBJ_TEMPLE: case MP2::OBJ_BUOY: case MP2::OBJ_WATERINGHOLE: case MP2::OBJ_ARENA: case MP2::OBJ_STABLES: name_object = MP2::StringObject(tile.GetObject()); // check visited if(hero) { name_object.append("\n"); name_object.append(hero->isVisited(tile.GetObject()) ? _("(already visited)") : _("(not visited)")); } break; case MP2::OBJ_SHRINE1: case MP2::OBJ_SHRINE2: case MP2::OBJ_SHRINE3: name_object = MP2::StringObject(tile.GetObject()); // addons pack if(settings.ExtShowVisitedContent() && kingdom.isVisited(tile)) { name_object.append("\n("); name_object.append(Spell::GetName(Spell::FromInt(tile.GetQuantity1()))); name_object.append(")"); if(hero && hero->HaveSpell(Spell::FromInt(tile.GetQuantity1()))) { name_object.append("\n("); name_object.append(_("already learned")); name_object.append(")"); } } break; case MP2::OBJ_WITCHSHUT: name_object = MP2::StringObject(tile.GetObject()); // addons pack if(settings.ExtShowVisitedContent() && kingdom.isVisited(tile)) { const Skill::Secondary::skill_t skill = Skill::Secondary::Skill(tile.GetQuantity1()); name_object.append("\n("); name_object.append(Skill::Secondary::String(skill)); name_object.append(")"); if(hero) { if(hero->HasSecondarySkill(skill)) { name_object.append("\n("); name_object.append(_("already knows this skill")); name_object.append(")"); } else if(hero->HasMaxSecondarySkill()) { name_object.append("\n("); name_object.append(_("already has max skills")); name_object.append(")"); } } } break; case MP2::OBJ_OBELISK: name_object = MP2::StringObject(tile.GetObject()); // check visited name_object.append("\n"); name_object.append(kingdom.isVisited(tile) ? _("(already visited)") : _("(not visited)")); break; case MP2::OBJ_BARRIER: case MP2::OBJ_TRAVELLERTENT: name_object = Barrier::Color(tile.GetQuantity1()); name_object.append(" "); name_object.append(MP2::StringObject(tile.GetObject())); if(MP2::OBJ_TRAVELLERTENT == tile.GetObject() && kingdom.IsVisitTravelersTent(tile.GetQuantity1())) { name_object.append("\n"); name_object.append(_("(already visited)")); } break; case MP2::OBJ_TREASURECHEST: if(Maps::Ground::WATER == tile.GetGround()) name_object = _("Sea Chest"); else name_object = MP2::StringObject(tile.GetObject()); break; default: name_object = MP2::StringObject(tile.GetObject()); break; } TextBox text(name_object, Font::SMALL, 118); text.Blit(pos.x + BORDERWIDTH + (pos.w - BORDERWIDTH - text.w()) / 2, pos.y + (pos.h - BORDERWIDTH - text.h()) / 2); cursor.Show(); display.Flip(); // quick info loop while(le.HandleEvents() && le.MousePressRight()); // restore background cursor.Hide(); back.Restore(); cursor.Show(); display.Flip(); }