Author Topic: [Answered] Showing dots for research costs in the tech tree viewer  (Read 801 times)

Offline plainer

  • Sergeant
  • **
  • Posts: 18
    • View Profile
Does not show dots (..) for research whose costs are greater than 10 and not divisible by 5. Example (XPiratez):
  - name: STR_BANDIT_RATMAN_STORMRAT
    cost: 12

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [Answered] Showing dots for research costs in the tech tree viewer
« Reply #1 on: April 26, 2024, 09:01:37 am »
Yes, that's intentional.

Code: [Select]
// Cost indicator
{
std::ostringstream ss;
int cost = rule->getCost();
std::vector<std::pair<int, std::string>> symbol_values
({{100, "#"}, {20, "="}, {5, "-"}});

for (const auto& sym : symbol_values)
{
while (cost >= std::get<0>(sym))
{
cost -= std::get<0>(sym);
ss << std::get<1>(sym);
}
}
if (rule->getCost() < 10)
{
while (cost >= 1)
{
cost -= 1;
ss << ".";
}
}
_txtCostIndicator->setText(ss.str());
}