contracted itemcount string

This commit is contained in:
minjaesong
2019-05-30 21:36:02 +09:00
parent c8df0fc9fd
commit 2b35e547da
7 changed files with 28 additions and 7 deletions

View File

@@ -66,6 +66,8 @@ open class FixtureBase(blockBox0: BlockBox, val blockBoxProps: BlockBoxProps = B
return true // TODO for the tests' sake, just get fucking spawned
// FIXME has "roundworld anomaly"
}
/**

View File

@@ -88,7 +88,7 @@ object PlayerBuilderSigrid {
inventory.add(8449) // iron pick
inventory.add(8450) // steel pick
inventory.add(8466, 9995) // wire piece
inventory.add(8467, 9995) // test tiki torch
inventory.add(8467, 385930603) // test tiki torch
inventory.add(9000) // TEST water bucket
inventory.add(9001) // TEST lava bucket
}

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.GdxColorMap
import net.torvald.terrarum.abs
import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.ui.UIItem
import kotlin.math.roundToInt
@@ -45,6 +46,17 @@ object UIItemInventoryCellCommonRes {
meterColourMap[scale.times(meterColourMap.width - 1).roundToInt()]
}
}
fun getHealthMeterColour(value: Int, start: Int, end: Int) = getHealthMeterColour(value.toFloat(), start.toFloat(), end.toFloat())
fun Int.toItemCountText() = (if (this < 0) "-" else "") + when (this.abs()) {
in 0..999999 -> "$this"
in 1_000_000..999_999_999 -> "${this / 1_000_000}.${this.rem(1_000_000) / 10_000}M"
else -> "${this / 1_000_000_000}.${this.rem(1_000_000_000) / 10_000_000}B"
// 1 000 000 000
// 2 147 483 647
// -2.14B
}
}