void Unit::addNameReplacement(MetaString & text, const boost::logic::tribool & plural) const { if(boost::logic::indeterminate(plural)) text.addCreReplacement(creatureId(), getCount()); else if(plural) text.addReplacement(MetaString::CRE_PL_NAMES, creatureIndex()); else text.addReplacement(MetaString::CRE_SING_NAMES, creatureIndex()); }
void CQuest::addReplacements(MetaString &out, const std::string &base) const { switch(missionType) { case MISSION_KILL_CREATURE: out.addReplacement(stackToKill); if (std::count(base.begin(), base.end(), '%') == 2) //say where is placed monster { out.addReplacement(VLC->generaltexth->arraytxt[147+stackDirection]); } break; case MISSION_KILL_HERO: out.addReplacement(heroName); break; } }
void IBoatGenerator::getProblemText(MetaString &out, const CGHeroInstance *visitor) const { switch(shipyardStatus()) { case BOAT_ALREADY_BUILT: out.addTxt(MetaString::GENERAL_TXT, 51); break; case TILE_BLOCKED: if(visitor) { out.addTxt(MetaString::GENERAL_TXT, 134); out.addReplacement(visitor->name); } else out.addTxt(MetaString::ADVOB_TXT, 189); break; case NO_WATER: logGlobal->error("Shipyard without water! %s \t %d", o->pos.toString(), o->id.getNum()); return; } }
void CQuestLog::init() { minimap = new CQuestMinimap (Rect (47, 33, 144, 144)); description = new CTextBox ("", Rect(245, 33, 350, 355), 1, FONT_MEDIUM, TOPLEFT, Colors::WHITE); ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CQuestLog::close,this), 547, 401, "IOKAY.DEF", SDLK_RETURN); if (quests.size() > QUEST_COUNT) slider = new CSlider(203, 199, 230, boost::bind (&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, quests.size(), false, 0); for (int i = 0; i < quests.size(); ++i) { MetaString text; quests[i].quest->getRolloverText (text, false); if (quests[i].obj) text.addReplacement (quests[i].obj->getHoverText()); //get name of the object CQuestLabel * label = new CQuestLabel (Rect(28, 199 + i * 24, 172,30), FONT_SMALL, TOPLEFT, Colors::WHITE, text.toString()); label->callback = boost::bind(&CQuestLog::selectQuest, this, i); labels.push_back(label); } recreateQuestList (0); }
void CGSeerHut::getRolloverText (MetaString &text, bool onHover) const { quest->getRolloverText (text, onHover);//TODO: simplify? if (!onHover) text.addReplacement(seerName); }
void CQuest::getCompletionText (MetaString &iwText, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h) const { iwText << completedText; switch (missionType) { case CQuest::MISSION_LEVEL: if (!isCustomComplete) iwText.addReplacement(m13489val); break; case CQuest::MISSION_PRIMARY_STAT: if (vstd::contains (completedText,'%')) //there's one case when there's nothing to replace { MetaString loot; for (int i = 0; i < 4; ++i) { if (m2stats[i]) { loot << "%d %s"; loot.addReplacement(m2stats[i]); loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); } } if (!isCustomComplete) iwText.addReplacement(loot.buildList()); } break; case CQuest::MISSION_ART: { MetaString loot; for (auto & elem : m5arts) { loot << "%s"; loot.addReplacement(MetaString::ART_NAMES, elem); } if (!isCustomComplete) iwText.addReplacement(loot.buildList()); } break; case CQuest::MISSION_ARMY: { MetaString loot; for (auto & elem : m6creatures) { loot << "%s"; loot.addReplacement(elem); } if (!isCustomComplete) iwText.addReplacement(loot.buildList()); } break; case CQuest::MISSION_RESOURCES: { MetaString loot; for (int i = 0; i < 7; ++i) { if (m7resources[i]) { loot << "%d %s"; loot.addReplacement(m7resources[i]); loot.addReplacement(MetaString::RES_NAMES, i); } } if (!isCustomComplete) iwText.addReplacement(loot.buildList()); } break; case MISSION_KILL_HERO: case MISSION_KILL_CREATURE: if (!isCustomComplete) addReplacements(iwText, completedText); break; case MISSION_HERO: if (!isCustomComplete) iwText.addReplacement(VLC->heroh->heroes[m13489val]->name); break; case MISSION_PLAYER: if (!isCustomComplete) iwText.addReplacement(VLC->generaltexth->colors[m13489val]); break; } }
void CQuest::getRolloverText (MetaString &ms, bool onHover) const { if (onHover) ms << "\n\n"; ms << VLC->generaltexth->quests[missionType-1][onHover ? 3 : 4][textOption]; switch (missionType) { case MISSION_LEVEL: ms.addReplacement(m13489val); break; case MISSION_PRIMARY_STAT: { MetaString loot; for (int i = 0; i < 4; ++i) { if (m2stats[i]) { loot << "%d %s"; loot.addReplacement(m2stats[i]); loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); } } ms.addReplacement(loot.buildList()); } break; case MISSION_KILL_HERO: ms.addReplacement(heroName); break; case MISSION_KILL_CREATURE: ms.addReplacement(stackToKill); break; case MISSION_ART: { MetaString loot; for (auto & elem : m5arts) { loot << "%s"; loot.addReplacement(MetaString::ART_NAMES, elem); } ms.addReplacement(loot.buildList()); } break; case MISSION_ARMY: { MetaString loot; for (auto & elem : m6creatures) { loot << "%s"; loot.addReplacement(elem); } ms.addReplacement(loot.buildList()); } break; case MISSION_RESOURCES: { MetaString loot; for (int i = 0; i < 7; ++i) { if (m7resources[i]) { loot << "%d %s"; loot.addReplacement(m7resources[i]); loot.addReplacement(MetaString::RES_NAMES, i); } } ms.addReplacement(loot.buildList()); } break; case MISSION_HERO: ms.addReplacement(VLC->heroh->heroes[m13489val]->name); break; case MISSION_PLAYER: ms.addReplacement(VLC->generaltexth->colors[m13489val]); break; default: break; } }
void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &components, bool isCustom, bool firstVisit, const CGHeroInstance * h) const { std::string text; bool failRequirements = (h ? !checkQuest(h) : true); if (firstVisit) { isCustom = isCustomFirst; iwText << (text = firstVisitText); } else if (failRequirements) { isCustom = isCustomNext; iwText << (text = nextVisitText); } switch (missionType) { case MISSION_LEVEL: components.push_back(Component (Component::EXPERIENCE, 0, m13489val, 0)); if (!isCustom) iwText.addReplacement(m13489val); break; case MISSION_PRIMARY_STAT: { MetaString loot; for (int i = 0; i < 4; ++i) { if (m2stats[i]) { components.push_back(Component (Component::PRIM_SKILL, i, m2stats[i], 0)); loot << "%d %s"; loot.addReplacement(m2stats[i]); loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); } } if (!isCustom) iwText.addReplacement(loot.buildList()); } break; case MISSION_KILL_HERO: components.push_back(Component(Component::HERO_PORTRAIT, heroPortrait, 0, 0)); if (!isCustom) addReplacements(iwText, text); break; case MISSION_HERO: //FIXME: portrait may not match hero, if custom portrait was set in map editor components.push_back(Component (Component::HERO_PORTRAIT, VLC->heroh->heroes[m13489val]->imageIndex, 0, 0)); if (!isCustom) iwText.addReplacement(VLC->heroh->heroes[m13489val]->name); break; case MISSION_KILL_CREATURE: { components.push_back(Component(stackToKill)); if (!isCustom) { addReplacements(iwText, text); } } break; case MISSION_ART: { MetaString loot; for (auto & elem : m5arts) { components.push_back(Component (Component::ARTIFACT, elem, 0, 0)); loot << "%s"; loot.addReplacement(MetaString::ART_NAMES, elem); } if (!isCustom) iwText.addReplacement(loot.buildList()); } break; case MISSION_ARMY: { MetaString loot; for (auto & elem : m6creatures) { components.push_back(Component(elem)); loot << "%s"; loot.addReplacement(elem); } if (!isCustom) iwText.addReplacement(loot.buildList()); } break; case MISSION_RESOURCES: { MetaString loot; for (int i = 0; i < 7; ++i) { if (m7resources[i]) { components.push_back(Component (Component::RESOURCE, i, m7resources[i], 0)); loot << "%d %s"; loot.addReplacement(m7resources[i]); loot.addReplacement(MetaString::RES_NAMES, i); } } if (!isCustom) iwText.addReplacement(loot.buildList()); } break; case MISSION_PLAYER: components.push_back(Component (Component::FLAG, m13489val, 0, 0)); if (!isCustom) iwText.addReplacement(VLC->generaltexth->colors[m13489val]); break; } }