mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
replacing min/max usage with kotlin's
This commit is contained in:
@@ -55,14 +55,14 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
|
||||
|
||||
App.batch.inUse { val it = it as FlippingSpriteBatch
|
||||
it.color = Color.WHITE
|
||||
val previewX = (drawWidth - previewWidth).div(2f).round()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
|
||||
val previewX = (drawWidth - previewWidth).div(2f).roundToFloat()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).roundToFloat()
|
||||
Toolkit.drawBoxBorder(it, previewX.toInt() - 1, previewY.toInt() - 1, previewWidth + 2, previewHeight + 2)
|
||||
it.drawFlipped(previewTexture, previewX, previewY)
|
||||
val text = messages.getHeadElem() ?: ""
|
||||
App.fontGame.draw(it,
|
||||
text,
|
||||
(drawWidth - App.fontGame.getWidth(text)).div(2f).round(),
|
||||
(drawWidth - App.fontGame.getWidth(text)).div(2f).roundToFloat(),
|
||||
previewY + previewHeight + 98 - App.fontGame.lineHeight
|
||||
)
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ object IngameRenderer : Disposable {
|
||||
* Camera will be moved so that (newX, newY) would be sit on the top-left edge.
|
||||
*/
|
||||
private fun setCameraPosition(newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
|
||||
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.khelekore.prtree.PRTree
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import java.util.logging.Level
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
@@ -95,7 +96,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
companion object {
|
||||
/** Sets camera position so that (0,0) would be top-left of the screen, (width, height) be bottom-right. */
|
||||
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
|
||||
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
@@ -111,20 +112,20 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
val ACTOR_UPDATE_RANGE = 4096
|
||||
|
||||
fun distToActorSqr(world: GameWorld, a: ActorWithBody, p: ActorWithBody) =
|
||||
minOf(// take min of normal position and wrapped (x < 0) position
|
||||
(a.hitbox.centeredX - p.hitbox.centeredX).sqr() +
|
||||
min(// take min of normal position and wrapped (x < 0) position
|
||||
min((a.hitbox.centeredX - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
((a.hitbox.centeredX + world.width * TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr(),
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr()),
|
||||
((a.hitbox.centeredX - world.width * TILE_SIZE) - p.hitbox.centeredX).sqr() +
|
||||
(a.hitbox.centeredY - p.hitbox.centeredY).sqr()
|
||||
)
|
||||
fun distToCameraSqr(world: GameWorld, a: ActorWithBody) =
|
||||
minOf(
|
||||
(a.hitbox.centeredX - WorldCamera.xCentre).sqr() +
|
||||
min(
|
||||
min((a.hitbox.centeredX - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr(),
|
||||
((a.hitbox.centeredX + world.width * TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr(),
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr()),
|
||||
((a.hitbox.centeredX - world.width * TILE_SIZE) - WorldCamera.xCentre).sqr() +
|
||||
(a.hitbox.centeredY - WorldCamera.yCentre).sqr()
|
||||
)
|
||||
@@ -1035,10 +1036,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
} }
|
||||
|
||||
private fun fillUpWiresBuffer() {
|
||||
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorInt() - LIGHTMAP_OVERRENDER
|
||||
val for_y_start = (WorldCamera.y.toFloat() / TILE_SIZE).floorToInt() - LIGHTMAP_OVERRENDER
|
||||
val for_y_end = for_y_start + BlocksDrawer.tilesInVertical + 2*LIGHTMAP_OVERRENDER
|
||||
|
||||
val for_x_start = (WorldCamera.x.toFloat() / TILE_SIZE).floorInt() - LIGHTMAP_OVERRENDER
|
||||
val for_x_start = (WorldCamera.x.toFloat() / TILE_SIZE).floorToInt() - LIGHTMAP_OVERRENDER
|
||||
val for_x_end = for_x_start + BlocksDrawer.tilesInHorizontal + 2*LIGHTMAP_OVERRENDER
|
||||
|
||||
var wiringCounter = 0
|
||||
@@ -1421,7 +1422,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
// }
|
||||
// else, punch a block
|
||||
else if (canAttackOrDig) {
|
||||
val punchBlockSize = punchSize.div(TILE_SIZED).floorInt()
|
||||
val punchBlockSize = punchSize.div(TILE_SIZED).floorToInt()
|
||||
if (punchBlockSize > 0) {
|
||||
PickaxeCore.startPrimaryUse(actor, delta, null, Terrarum.mouseTileX, Terrarum.mouseTileY, 1.0 / punchBlockSize, punchBlockSize, punchBlockSize)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
val ww = TILE_SIZEF * demoWorld.width
|
||||
val x = px % ww
|
||||
|
||||
val indexThis = ((x / ww * cameraNodes.size).floorInt())
|
||||
val indexThis = ((x / ww * cameraNodes.size).floorToInt())
|
||||
val xwstart: Double = indexThis.toDouble() / cameraNodes.size * ww
|
||||
val xwend: Double = ((indexThis + 1).toDouble() / cameraNodes.size) * ww
|
||||
val xw: Double = xwend - xwstart
|
||||
@@ -182,7 +182,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
// construct camera nodes
|
||||
val nodeCount = demoWorld.width / cameraNodeWidth
|
||||
cameraNodes = kotlin.FloatArray(nodeCount) {
|
||||
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorInt()
|
||||
val tileXPos = (demoWorld.width.toFloat() * it / nodeCount).floorToInt()
|
||||
var travelDownCounter = 0
|
||||
while (travelDownCounter < demoWorld.height &&
|
||||
!BlockCodex[demoWorld.getTileFromTerrain(tileXPos, travelDownCounter)].isSolid
|
||||
|
||||
@@ -70,14 +70,14 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
|
||||
|
||||
App.batch.inUse { val it = it as FlippingSpriteBatch
|
||||
it.color = Color.WHITE
|
||||
val previewX = (drawWidth - previewWidth).div(2f).round()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
|
||||
val previewX = (drawWidth - previewWidth).div(2f).roundToFloat()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).roundToFloat()
|
||||
Toolkit.drawBoxBorder(it, previewX.toInt()-1, previewY.toInt()-1, previewWidth+2, previewHeight+2)
|
||||
it.drawFlipped(previewTexture, previewX, previewY)
|
||||
val text = messages.getHeadElem() ?: ""
|
||||
App.fontGame.draw(it,
|
||||
text,
|
||||
(drawWidth - App.fontGame.getWidth(text)).div(2f).round(),
|
||||
(drawWidth - App.fontGame.getWidth(text)).div(2f).roundToFloat(),
|
||||
previewY + previewHeight + 98 - App.fontGame.lineHeight
|
||||
)
|
||||
}
|
||||
|
||||
@@ -545,7 +545,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
|
||||
if (hasPlatformOnTheFeet) {
|
||||
// equation copied verbatim from the ActorWthBody.forEachFeetTile
|
||||
val y = hitbox.endY.plus(1.0).div(TerrarumAppConfiguration.TILE_SIZE).floorInt()
|
||||
val y = hitbox.endY.plus(1.0).div(TerrarumAppConfiguration.TILE_SIZE).floorToInt()
|
||||
var wxStart = hIntTilewiseHitbox.startX.toInt()
|
||||
var wxEnd = wxStart
|
||||
// scan to the left
|
||||
|
||||
@@ -69,8 +69,8 @@ internal class FixtureTapestry : FixtureBase {
|
||||
Pixmap(ModMgr.getGdxFilesFromEveryMod("tapestries/common/canvas.tga").last().second)
|
||||
} as Pixmap
|
||||
|
||||
tilewiseHitboxWidth = pixmap.width.div(TILE_SIZEF).ceilInt()
|
||||
tilewiseHitboxHeight = pixmap.height.div(TILE_SIZEF).ceilInt()
|
||||
tilewiseHitboxWidth = pixmap.width.div(TILE_SIZEF).ceilToInt()
|
||||
tilewiseHitboxHeight = pixmap.height.div(TILE_SIZEF).ceilToInt()
|
||||
|
||||
// blend canvas texture
|
||||
for (y in 0 until pixmap.height) { for (x in 0 until pixmap.width) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.abs
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.sqr
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -202,9 +204,6 @@ object CollisionSolver {
|
||||
return (t_ax.sqr() + t_ay.sqr()) < actor_dist_t_sqr
|
||||
}
|
||||
|
||||
fun Double.abs() = if (this < 0) -this else this
|
||||
fun Double.sqr() = this * this
|
||||
|
||||
data class CollisionMarkings(
|
||||
val pos: Double,
|
||||
val kind: Int,
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import kotlin.math.max
|
||||
import kotlin.math.pow
|
||||
|
||||
/**
|
||||
@@ -21,7 +22,7 @@ object WeaponMeleeCore {
|
||||
private fun getAttackMomentum(weapon: WeaponMeleeBase, actor: ActorHumanoid) =
|
||||
weapon.mass * weapon.material.density * weapon.velocityMod * actor.scale.pow(SQRT2) // TODO multiply racial strength from RaceCodex
|
||||
fun getAttackPower(weapon: WeaponMeleeBase, actor: ActorHumanoid, actee: ActorHumanoid) =
|
||||
getAttackMomentum(weapon, actor) * randomise() * maxOf(1.0, (actee.hitbox.endY - actor.hitbox.startY) / actee.hitbox.height)
|
||||
getAttackMomentum(weapon, actor) * randomise() * max(1.0, (actee.hitbox.endY - actor.hitbox.startY) / actee.hitbox.height)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.magiccontroller
|
||||
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* "Data Type" describing magical force
|
||||
@@ -33,13 +34,13 @@ class TheMagicLanguage(vm: TheMagicMachine) {
|
||||
if (power >= 0) {
|
||||
// pour out positive power without inversion; result is positive power
|
||||
if (value >= 0) {
|
||||
val value = minOf(power, value)
|
||||
val value = min(power, value)
|
||||
other.pourIn(value)
|
||||
power -= value
|
||||
}
|
||||
// pour out positive power with inversion; result is negative power
|
||||
else {
|
||||
val value = minOf(-power, value)
|
||||
val value = min(-power, value)
|
||||
other.pourIn(value)
|
||||
power += value
|
||||
}
|
||||
@@ -47,12 +48,12 @@ class TheMagicLanguage(vm: TheMagicMachine) {
|
||||
else {
|
||||
// pour out negative power without inversion; result is negative power
|
||||
if (value < 0) {
|
||||
val value = minOf(power, value)
|
||||
val value = min(power, value)
|
||||
other.pourIn(-value)
|
||||
}
|
||||
// pour out negative power with inversion; result is positive power
|
||||
else {
|
||||
val value = minOf(-power, value)
|
||||
val value = min(-power, value)
|
||||
other.pourIn(-value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.blendNormalStraightAlpha
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-23.
|
||||
@@ -56,7 +57,7 @@ class Notification : UICanvas() {
|
||||
App.fontGame.getWidth(message[0])
|
||||
else
|
||||
message.map { App.fontGame.getWidth(it) }.sorted().last()
|
||||
val displayedTextWidth = maxOf(240, realTextWidth)
|
||||
val displayedTextWidth = max(240, realTextWidth)
|
||||
|
||||
// force the UI to the centre of the screen
|
||||
this.posX = (App.scr.width - displayedTextWidth) / 2
|
||||
|
||||
@@ -21,6 +21,8 @@ import net.torvald.terrarum.ui.UIItemSpinner
|
||||
import net.torvald.terrarum.ui.UIItemTextButton
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* This UI has inventory, but it's just there to display all craftable items and should not be serialised.
|
||||
@@ -498,7 +500,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
|
||||
if (full.actor.inventory.capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(UIInventoryCells.weightBarWidth, maxOf(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
min(UIInventoryCells.weightBarWidth, max(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
UIInventoryFull.controlHelpHeight - 6f
|
||||
)
|
||||
// debug text
|
||||
|
||||
@@ -7,10 +7,8 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarum.ceilToInt
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.unicode.TIMES
|
||||
@@ -214,7 +212,7 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
||||
Toolkit.drawBoxBorder(batch, xstart + 1, 1, App.scr.chatWidth - 2, App.scr.height - 2)
|
||||
|
||||
val overlayResTxt = "${(App.scr.chatWidth * App.scr.magn).ceilInt()}$TIMES${App.scr.windowH}"
|
||||
val overlayResTxt = "${(App.scr.chatWidth * App.scr.magn).ceilToInt()}$TIMES${App.scr.windowH}"
|
||||
|
||||
App.fontGame.draw(batch, overlayResTxt,
|
||||
(xstart + (App.scr.chatWidth - App.fontGame.getWidth(overlayResTxt)) / 2).toFloat(),
|
||||
|
||||
@@ -270,7 +270,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
if (actor?.inventory?.capacityMode == CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
||||
min(weightBarWidth, max(1f, weightBarWidth * encumbrancePerc)),
|
||||
controlHelpHeight - 5f
|
||||
)
|
||||
}
|
||||
@@ -347,7 +347,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
}
|
||||
|
||||
|
||||
itemPageCount = maxOf(1, 1 + (inventorySortList.size.minus(1) / items.size))
|
||||
itemPageCount = max(1, 1 + (inventorySortList.size.minus(1) / items.size))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.createInvCellGenericTouchDownFun
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
internal class UIInventoryCells(
|
||||
val full: UIInventoryFull
|
||||
@@ -125,7 +127,7 @@ internal class UIInventoryCells(
|
||||
if (full.actor.inventory.capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
||||
min(weightBarWidth, max(1f, weightBarWidth * encumbrancePerc)),
|
||||
controlHelpHeight - 6f
|
||||
)
|
||||
// debug text
|
||||
|
||||
@@ -109,8 +109,8 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
}
|
||||
if (Gdx.input.isKeyPressed(Input.Keys.NUM_3)) {
|
||||
minimapZoom = 1f
|
||||
minimapPanX = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredX?.round()?.toFloat() ?: (INGAME.world.width / 2f)
|
||||
minimapPanY = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredY?.round()?.toFloat() ?: (INGAME.world.height / 2f)
|
||||
minimapPanX = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredX?.roundToInt()?.toFloat() ?: (INGAME.world.width / 2f)
|
||||
minimapPanY = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredY?.roundToInt()?.toFloat() ?: (INGAME.world.height / 2f)
|
||||
dragStatus = 1
|
||||
}
|
||||
|
||||
@@ -185,8 +185,8 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
val worldPos = it.hitbox
|
||||
val cw = t.regionWidth * sf
|
||||
val ch = t.regionHeight * sf
|
||||
val cx = worldPos.centeredX.div(TILE_SIZEF).round().toFloat()
|
||||
val cy = worldPos.startY.plus(headHeight * sf).div(TILE_SIZEF).round().toFloat()
|
||||
val cx = worldPos.centeredX.div(TILE_SIZEF).roundToInt().toFloat()
|
||||
val cy = worldPos.startY.plus(headHeight * sf).div(TILE_SIZEF).roundToInt().toFloat()
|
||||
val dx = cx - oldPanX
|
||||
val dy = cy - oldPanY
|
||||
|
||||
@@ -255,8 +255,8 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
|
||||
override fun doClosing(delta: Float) {}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
minimapPanX = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredX?.round()?.toFloat() ?: (INGAME.world.width / 2f)
|
||||
minimapPanY = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredY?.round()?.toFloat() ?: (INGAME.world.height / 2f)
|
||||
minimapPanX = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredX?.roundToInt()?.toFloat() ?: (INGAME.world.width / 2f)
|
||||
minimapPanY = INGAME.actorNowPlaying?.intTilewiseHitbox?.centeredY?.roundToInt()?.toFloat() ?: (INGAME.world.height / 2f)
|
||||
|
||||
minimapRerenderInterval = 0.25f
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.CraftingRecipeCodex
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
import net.torvald.terrarum.UIItemInventoryCatBar
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarum.ceilToInt
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||
|
||||
@@ -80,7 +80,7 @@ class UIItemCraftingCandidateGrid(
|
||||
}
|
||||
|
||||
|
||||
itemPageCount = (recipesSortList.size.toFloat() / items.size.toFloat()).ceilInt()
|
||||
itemPageCount = (recipesSortList.size.toFloat() / items.size.toFloat()).ceilToInt()
|
||||
|
||||
rebuildList = false
|
||||
}
|
||||
|
||||
@@ -15,10 +15,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.InventoryPair
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.defaultInventoryCellTheme
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.floor
|
||||
|
||||
@@ -443,7 +441,7 @@ open class UIItemInventoryItemGrid(
|
||||
}
|
||||
|
||||
|
||||
itemPageCount = (inventorySortList.size.toFloat() / items.size.toFloat()).ceilInt()
|
||||
itemPageCount = (inventorySortList.size.toFloat() / items.size.toFloat()).ceilToInt()
|
||||
|
||||
|
||||
// ¤ 42g
|
||||
|
||||
@@ -476,7 +476,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : Advanceable() {
|
||||
}
|
||||
|
||||
private fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
|
||||
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
|
||||
}
|
||||
|
||||
internal fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
|
||||
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ceilInt
|
||||
import net.torvald.terrarum.ceilToInt
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -225,7 +225,7 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
|
||||
batch.color = Toolkit.Theme.COL_MOUSE_UP
|
||||
Toolkit.drawBoxBorder(batch, xstart + 1, 1, App.scr.chatWidth - 2, App.scr.height - 2)
|
||||
|
||||
val overlayResTxt = "${(App.scr.chatWidth * App.scr.magn).ceilInt()}$TIMES${App.scr.windowH}"
|
||||
val overlayResTxt = "${(App.scr.chatWidth * App.scr.magn).ceilToInt()}$TIMES${App.scr.windowH}"
|
||||
|
||||
App.fontGame.draw(batch, overlayResTxt,
|
||||
(xstart + (App.scr.chatWidth - App.fontGame.getWidth(overlayResTxt)) / 2).toFloat(),
|
||||
|
||||
@@ -12,6 +12,8 @@ import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.getWidth
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-07-08.
|
||||
@@ -219,7 +221,7 @@ internal class UIStorageChest : UICanvas(
|
||||
if (getPlayerInventory().capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(UIInventoryCells.weightBarWidth, maxOf(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
min(UIInventoryCells.weightBarWidth, max(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
UIInventoryFull.controlHelpHeight - 6f
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemTextButtonList
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.max
|
||||
|
||||
class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
|
||||
|
||||
@@ -26,7 +27,7 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
|
||||
private val localeSecondHalf = localeList.subList(ceil(localeList.size / 2f).toInt(), localeList.size)
|
||||
|
||||
override var width = 480
|
||||
override var height = maxOf(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight
|
||||
override var height = max(localeFirstHalf.size, localeSecondHalf.size) * textButtonLineHeight
|
||||
|
||||
|
||||
private val textArea1 = UIItemTextButtonList(this,
|
||||
|
||||
@@ -261,7 +261,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
|
||||
}
|
||||
|
||||
private fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
|
||||
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class UIVitalMetre(
|
||||
g.lineWidth = 2f
|
||||
|
||||
|
||||
val ratio = minOf(1f, vitalGetterVal()!! / vitalGetterMax()!!)
|
||||
val ratio = min(1f, vitalGetterVal()!! / vitalGetterMax()!!)
|
||||
|
||||
// background
|
||||
g.color = backColor
|
||||
|
||||
@@ -11,6 +11,8 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.unicode.getKeycapPC
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
|
||||
@@ -211,7 +213,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
|
||||
if (getPlayerInventory().capacityMode == FixtureInventory.CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(UIInventoryCells.weightBarWidth, maxOf(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
min(UIInventoryCells.weightBarWidth, max(1f, UIInventoryCells.weightBarWidth * encumbrancePerc)),
|
||||
UIInventoryFull.controlHelpHeight - 6f
|
||||
)
|
||||
|
||||
|
||||
@@ -379,7 +379,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
batch.color = barBack
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, memoryGaugeWidth, buttonHeight)
|
||||
batch.color = barCol
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, (memoryGaugeWidth * (chunksUsed / chunksMax.toFloat())).ceilInt(), buttonHeight)
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, (memoryGaugeWidth * (chunksUsed / chunksMax.toFloat())).ceilToInt(), buttonHeight)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
if (selected?.worldInfo != null) {
|
||||
@@ -396,7 +396,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
|
||||
App.fontGame.draw(batch, str, textXpos + 6f, y + thumbh + 3+10 + textualListHeight * index - 2f)
|
||||
}
|
||||
// size indicator on the memory gauge
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, (memoryGaugeWidth * (selected?.worldInfo!!.dimensionInChunks / chunksMax.toFloat())).ceilInt(), buttonHeight)
|
||||
Toolkit.fillArea(batch, memoryGaugeXpos, memoryGaugeYpos, (memoryGaugeWidth * (selected?.worldInfo!!.dimensionInChunks / chunksMax.toFloat())).ceilToInt(), buttonHeight)
|
||||
|
||||
// thumbnail
|
||||
selected?.worldInfo?.screenshot?.let {
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.max
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
|
||||
private val genSlices = maxOf(threadExecutor.threadCount, world.width / 8)
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 8)
|
||||
|
||||
private val YHEIGHT_MAGIC = 2800.0 / 3.0
|
||||
private val YHEIGHT_DIVISOR = 2.0 / 7.0
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.concurrent.sliceEvenly
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.max
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
||||
|
||||
private val threadExecutor = TerrarumIngame.worldgenThreadExecutor
|
||||
|
||||
private val genSlices = maxOf(threadExecutor.threadCount, world.width / 8)
|
||||
private val genSlices = max(threadExecutor.threadCount, world.width / 8)
|
||||
|
||||
private val YHEIGHT_MAGIC = 2800.0 / 3.0
|
||||
private val YHEIGHT_DIVISOR = 2.0 / 7.0
|
||||
|
||||
Reference in New Issue
Block a user