void ShipInfoDisplay::UpdateDescription(const Ship &ship, const Government *systemGovernment) { description.SetAlignment(WrappedText::JUSTIFIED); description.SetWrapWidth(WIDTH - 20); description.SetFont(FontSet::Get(14)); const vector<string> &licenses = ship.Licenses(); if(licenses.empty()) description.Wrap(ship.Description()); else { string text = ship.Description() + "\tTo purchase this ship you must have "; for(unsigned i = 0; i < licenses.size(); ++i) { if(i) { if(licenses.size() > 2) text += ", "; else text += " "; } if(i && i == licenses.size() - 1) text += "and "; text += "a " + licenses[i] + " License"; } text += "."; description.Wrap(text); } // Pad by 10 pixels on the top and bottom. descriptionHeight = description.Height() + 20; }
void ShipInfoDisplay::UpdateDescription(const Ship &ship) { const vector<string> &licenses = ship.Licenses(); if(licenses.empty()) ItemInfoDisplay::UpdateDescription(ship.Description()); else { string text = ship.Description() + "\tTo purchase this ship you must have "; for(unsigned i = 0; i < licenses.size(); ++i) { if(i) { if(licenses.size() > 2) text += ", "; else text += " "; } if(i && i == licenses.size() - 1) text += "and "; text += "a " + licenses[i] + " License"; } text += "."; ItemInfoDisplay::UpdateDescription(text); } }