Use SI prefixes as suffixes for shortening item quantities shown in slots, to prevent the quantity associated with large stacks from overflowing into adjacent grid cells.

This commit is contained in:
Avi Weinstock 2023-07-14 10:50:27 -04:00
parent 7f06607899
commit 2c7a9d1a7a

View File

@ -698,7 +698,12 @@ where
// Draw amount
if let Some(amount) = amount {
let amount = format!("{}", &amount);
let amount = match amount {
amount if amount > 1_000_000_000 => format!("{}G", amount / 1_000_000_000),
amount if amount > 1_000_000 => format!("{}M", amount / 1_000_000),
amount if amount > 1_000 => format!("{}K", amount / 1_000),
amount => format!("{}", amount),
};
// Text shadow
Text::new(&amount)
.font_id(amount_font)