mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
setting up the inventory using builder (during init) requires ingame.player to be nullable, lateinit won't work
This commit is contained in:
@@ -45,13 +45,13 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
val player = Terrarum.ingame!!.player
|
||||
val hitbox = player.hitbox
|
||||
val hitbox = player?.hitbox
|
||||
|
||||
xdelta = hitbox.pointedX - prevPlayerX
|
||||
ydelta = hitbox.pointedY - prevPlayerY
|
||||
xdelta = hitbox?.pointedX ?: 0 - prevPlayerX
|
||||
ydelta = hitbox?.pointedY ?: 0 - prevPlayerY
|
||||
|
||||
prevPlayerX = hitbox.pointedX
|
||||
prevPlayerY = hitbox.pointedY
|
||||
prevPlayerX = hitbox?.pointedX ?: 0.0
|
||||
prevPlayerY = hitbox?.pointedY ?: 0.0
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
@@ -67,8 +67,8 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
g.font = Terrarum.fontSmallNumbers
|
||||
g.color = GameFontBase.codeToCol["y"]
|
||||
|
||||
val hitbox = player.hitbox
|
||||
val nextHitbox = player.nextHitbox
|
||||
val hitbox = player?.hitbox
|
||||
val nextHitbox = player?.nextHitbox
|
||||
|
||||
/**
|
||||
* First column
|
||||
@@ -76,25 +76,25 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
printLine(g, 1, "posX "
|
||||
+ ccG
|
||||
+ "${hitbox.pointedX}"
|
||||
+ "${hitbox?.pointedX}"
|
||||
+ " ("
|
||||
+ "${(hitbox.pointedX / FeaturesDrawer.TILE_SIZE).toInt()}"
|
||||
+ "${(hitbox?.pointedX?.div(FeaturesDrawer.TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLine(g, 2, "posY "
|
||||
+ ccG
|
||||
+ hitbox.pointedY.toString()
|
||||
+ hitbox?.pointedY.toString()
|
||||
+ " ("
|
||||
+ (hitbox.pointedY / FeaturesDrawer.TILE_SIZE).toInt().toString()
|
||||
+ (hitbox?.pointedY?.div(FeaturesDrawer.TILE_SIZE))?.toInt().toString()
|
||||
+ ")")
|
||||
|
||||
printLine(g, 3, "veloX reported $ccG${player.moveDelta.x}")
|
||||
printLine(g, 4, "veloY reported $ccG${player.moveDelta.y}")
|
||||
printLine(g, 3, "veloX reported $ccG${player?.moveDelta?.x}")
|
||||
printLine(g, 4, "veloY reported $ccG${player?.moveDelta?.y}")
|
||||
|
||||
printLineColumn(g, 2, 3, "veloX measured $ccG${xdelta}")
|
||||
printLineColumn(g, 2, 4, "veloY measured $ccG${ydelta}")
|
||||
|
||||
printLine(g, 5, "grounded $ccG${player.grounded}")
|
||||
printLine(g, 6, "noClip $ccG${player.noClip}")
|
||||
printLine(g, 5, "grounded $ccG${player?.grounded}")
|
||||
printLine(g, 6, "noClip $ccG${player?.noClip}")
|
||||
|
||||
//printLine(g, 7, "jump $ccG${player.jumpAcc}")
|
||||
|
||||
@@ -129,10 +129,10 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
printLineColumn(g, 2, 2, "Env colour temp $ccG" + FeaturesDrawer.colTemp)
|
||||
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame!!.world.time.todaySeconds.toString().padStart(5, '0')}" +
|
||||
" (${Terrarum.ingame!!.world.time.getFormattedTime()})")
|
||||
printLineColumn(g, 2, 6, "Mass $ccG${player.mass}")
|
||||
printLineColumn(g, 2, 6, "Mass $ccG${player?.mass}")
|
||||
|
||||
printLineColumn(g, 2, 7, "p_WalkX $ccG${player.walkX}")
|
||||
printLineColumn(g, 2, 8, "p_WalkY $ccG${player.walkY}")
|
||||
printLineColumn(g, 2, 7, "p_WalkX $ccG${player?.walkX}")
|
||||
printLineColumn(g, 2, 8, "p_WalkY $ccG${player?.walkY}")
|
||||
|
||||
|
||||
drawHistogram(g, LightmapRenderer.histogram,
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.torvald.terrarum.Terrarum.QUICKSLOT_MAX
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinA
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinY
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER
|
||||
import net.torvald.terrarum.gameitem.InventoryItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
@@ -125,6 +126,9 @@ class UIInventory(
|
||||
|
||||
private var oldCatSelect = -1
|
||||
|
||||
private var encumbrancePerc = 0f
|
||||
private var isEncumbered = false
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
catButtons.update(gc, delta)
|
||||
|
||||
@@ -140,6 +144,12 @@ class UIInventory(
|
||||
if (rebuildList) {
|
||||
val filter = catButtonsToCatIdent[catButtons.selectedButton.labelText]
|
||||
|
||||
// encumbrance
|
||||
encumbrancePerc = inventory!!.capacity.toFloat() / inventory!!.maxCapacity
|
||||
isEncumbered = inventory!!.isEncumbered
|
||||
|
||||
|
||||
|
||||
inventorySortList = ArrayList<InventoryPair>()
|
||||
|
||||
// filter items
|
||||
@@ -250,12 +260,14 @@ class UIInventory(
|
||||
)
|
||||
// encumbrance bar
|
||||
blendNormal()
|
||||
val encumbPerc = inventory!!.capacity.toFloat() / inventory!!.maxCapacity
|
||||
g.color = if (inventory!!.isEncumbered) Color(0xccff0000.toInt()) else Color(0xcc00ff00.toInt())
|
||||
g.color = if (isEncumbered) Color(0xccff0000.toInt()) else Color(0xcc00ff00.toInt())
|
||||
g.fillRect(
|
||||
width - 3 - weightBarWidth,
|
||||
height - controlHelpHeight + 3f,
|
||||
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbPerc)), // make sure 1px is always be seen
|
||||
if (actor?.inventory?.capacityMode == CAPACITY_MODE_NO_ENCUMBER)
|
||||
1f
|
||||
else // make sure 1px is always be seen
|
||||
minOf(weightBarWidth, maxOf(1f, weightBarWidth * encumbrancePerc)),
|
||||
controlHelpHeight - 5f
|
||||
)
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ class UIPieMenu : UICanvas {
|
||||
var selection: Int = -1
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
|
||||
|
||||
if (Terrarum.ingame!!.player != null) {
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
|
||||
@@ -25,8 +25,8 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = value }
|
||||
get() = Terrarum.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { Terrarum.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value) }
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user