player is now nullable; wtf is calling Ingame 5 times?

This commit is contained in:
minjaesong
2018-09-17 01:46:50 +09:00
parent 967eafe8a3
commit 03b642ddd3
35 changed files with 252 additions and 150 deletions

View File

@@ -38,8 +38,8 @@ class UIPieMenu : UICanvas() {
var selection: Int = -1
override fun updateUI(delta: Float) {
if (selection >= 0)
(Terrarum.ingame!! as Ingame).playableActor.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
if (selection >= 0 && (Terrarum.ingame!! as Ingame).actorNowPlaying != null)
(Terrarum.ingame!! as Ingame).actorNowPlaying!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
selection % slotCount
@@ -83,7 +83,11 @@ class UIPieMenu : UICanvas() {
// draw item
val itemPair = (Terrarum.ingame!! as Ingame).playableActor.inventory.getQuickBar(i)
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return // don't draw actual items
val itemPair = player.inventory.getQuickBar(i)
if (itemPair != null) {
val itemImage = ItemCodex.getItemImage(itemPair.item)

View File

@@ -28,8 +28,8 @@ class UIQuickBar : UICanvas() {
private val startPointY = ItemSlotImageBuilder.slotImage.tileH / 2
private var selection: Int
get() = (Terrarum.ingame!! as Ingame).playableActor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
set(value) { (Terrarum.ingame!! as Ingame).playableActor.actorValue.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
get() = (Terrarum.ingame!! as Ingame).actorNowPlaying?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
set(value) { (Terrarum.ingame!! as Ingame).actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
override fun updateUI(delta: Float) {
}
@@ -54,7 +54,11 @@ class UIQuickBar : UICanvas() {
)
// draw item
val itemPair = (Terrarum.ingame!! as Ingame).playableActor.inventory.getQuickBar(i)
val player = (Terrarum.ingame!! as Ingame).actorNowPlaying
if (player == null) return // if player is null, don't draw actual items
val itemPair = player.inventory.getQuickBar(i)
if (itemPair != null) {
val itemImage = ItemCodex.getItemImage(itemPair.item)

View File

@@ -5,10 +5,14 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr
import net.torvald.terrarum.LoadScreen
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.gameactors.PlayerBuilderSigrid
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextButton
import net.torvald.terrarum.ui.UIItemTextButtonList
@@ -100,6 +104,22 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
throw NullPointerException("No parent node to return")
}
}
else if (it.labelText.contains("Start New Random Game")) {
printdbg(this, 1)
val ingame = Ingame(Terrarum.batch)
ingame.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong())
ingame.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW
printdbg(this, 2)
Terrarum.ingame = ingame
LoadScreen.screenToLoad = ingame
Terrarum.setScreen(LoadScreen)
printdbg(this, 3)
}
else {
// check if target exists
//println("current node: ${currentRemoConContents.data}")