void OutfitInfoDisplay::UpdateRequirements(const Outfit &outfit) { requirementLabels.clear(); requirementValues.clear(); requirementsHeight = 20; requirementLabels.push_back("cost:"); requirementValues.push_back(Format::Number(outfit.Cost())); requirementsHeight += 20; static const string names[] = { "outfit space needed:", "outfit space", "weapon capacity needed:", "weapon capacity", "engine capacity needed:", "engine capacity", "gun ports needed:", "gun ports", "turret mounts needed:", "turret mounts" }; static const int NAMES = sizeof(names) / sizeof(names[0]); for(int i = 0; i + 1 < NAMES; i += 2) if(outfit.Get(names[i + 1])) { requirementLabels.push_back(string()); requirementValues.push_back(string()); requirementsHeight += 10; requirementLabels.push_back(names[i]); requirementValues.push_back(Format::Number(-outfit.Get(names[i + 1]))); requirementsHeight += 20; } }
void OutfitInfoDisplay::UpdateRequirements(const Outfit &outfit, const PlayerInfo &player, bool canSell) { requirementLabels.clear(); requirementValues.clear(); requirementsHeight = 20; int day = player.GetDate().DaysSinceEpoch(); int64_t cost = outfit.Cost(); int64_t buyValue = player.StockDepreciation().Value(&outfit, day); int64_t sellValue = player.FleetDepreciation().Value(&outfit, day); if(buyValue == cost) requirementLabels.push_back("cost:"); else { ostringstream out; out << "cost (" << (100 * buyValue) / cost << "%):"; requirementLabels.push_back(out.str()); } requirementValues.push_back(Format::Number(buyValue)); requirementsHeight += 20; if(canSell && sellValue != buyValue) { if(sellValue == cost) requirementLabels.push_back("sells for:"); else { ostringstream out; out << "sells for (" << (100 * sellValue) / cost << "%):"; requirementLabels.push_back(out.str()); } requirementValues.push_back(Format::Number(sellValue)); requirementsHeight += 20; } static const string names[] = { "outfit space needed:", "outfit space", "weapon capacity needed:", "weapon capacity", "engine capacity needed:", "engine capacity", "gun ports needed:", "gun ports", "turret mounts needed:", "turret mounts" }; static const int NAMES = sizeof(names) / sizeof(names[0]); for(int i = 0; i + 1 < NAMES; i += 2) if(outfit.Get(names[i + 1])) { requirementLabels.push_back(string()); requirementValues.push_back(string()); requirementsHeight += 10; requirementLabels.push_back(names[i]); requirementValues.push_back(Format::Number(-outfit.Get(names[i + 1]))); requirementsHeight += 20; } }