UI testing env and working text buttons

Former-commit-id: b8fd27c7f71f9bc8da259ae132badcbc9ce117ac
This commit is contained in:
Song Minjae
2017-03-13 21:40:50 +09:00
parent 0113ca5d09
commit bc4fd8866a
73 changed files with 688 additions and 264 deletions

View File

@@ -41,7 +41,7 @@ abstract class Actor(val renderOrder: ActorOrder) : Comparable<Actor>, Runnable
*/
fun generateUniqueReferenceID(): Int {
fun checkForCollision(value: Int) =
Terrarum.ingame.theGameHasActor(value) ||
Terrarum.ingame!!.theGameHasActor(value) ||
value < ItemCodex.ITEM_COUNT_MAX ||
value < when (renderOrder) {
ActorOrder.BEHIND -> ItemCodex.ITEM_COUNT_MAX

View File

@@ -132,14 +132,14 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
protected var isRightDown = false
protected var isJumpDown = false
protected val isGamer: Boolean
get() = this == Terrarum.ingame.player
get() = this == Terrarum.ingame!!.player
private val nullItem = object : InventoryItem() {
override val id: Int = 0
override var scale: Double = 1.0
override var baseMass: Double = 0.0
override var baseToolSize: Double? = null
override var category = "should_not_be_seen"
}
override fun update(gc: GameContainer, delta: Int) {

View File

@@ -55,8 +55,9 @@ class ActorInventory() {
fun add(item: InventoryItem, count: Int = 1) {
if (item.id == Player.PLAYER_REF_ID)
throw IllegalArgumentException("Attempted to put human player into the inventory.")
if (Terrarum.ingame.playableActorDelegate != null &&
item.id == Terrarum.ingame.player.referenceID)
if (Terrarum.ingame != null &&
Terrarum.ingame!!.playableActorDelegate != null &&
item.id == Terrarum.ingame!!.player.referenceID)
throw IllegalArgumentException("Attempted to put active player into the inventory.")
// If we already have the item, increment the amount

View File

@@ -7,15 +7,10 @@ import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
import net.torvald.terrarum.tileproperties.TileCodex
import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.gamecontroller.Key
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.mapdrawer.FeaturesDrawer.TILE_SIZE
import net.torvald.terrarum.mapdrawer.MapCamera
import net.torvald.terrarum.tileproperties.Tile
import net.torvald.terrarum.tileproperties.TileProp
import org.dyn4j.Epsilon
import org.dyn4j.geometry.Vector2
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Image
@@ -42,7 +37,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
var drawMode = BLEND_NORMAL
@Transient private val world: GameWorld = Terrarum.ingame.world
@Transient private val world: GameWorld = Terrarum.ingame!!.world
var hitboxTranslateX: Double = 0.0// relative to spritePosX
protected set
@@ -1273,8 +1268,8 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
private fun div16TruncateToMapWidth(x: Int): Int {
if (x < 0)
return 0
else if (x >= Terrarum.ingame.world.width shl 4)
return Terrarum.ingame.world.width - 1
else if (x >= Terrarum.ingame!!.world.width shl 4)
return Terrarum.ingame!!.world.width - 1
else
return x and 0x7FFFFFFF shr 4
}
@@ -1282,8 +1277,8 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
private fun div16TruncateToMapHeight(y: Int): Int {
if (y < 0)
return 0
else if (y >= Terrarum.ingame.world.height shl 4)
return Terrarum.ingame.world.height - 1
else if (y >= Terrarum.ingame!!.world.height shl 4)
return Terrarum.ingame!!.world.height - 1
else
return y and 0x7FFFFFFF shr 4
}

View File

@@ -52,6 +52,7 @@ open class HumanoidNPC(
set(value) {
actorValue[AVKey.SCALE] = value
}
override var category = "npc"
override fun secondaryUse(gc: GameContainer, delta: Int) {
// TODO place this Actor to the world

View File

@@ -43,7 +43,7 @@ open class ParticleBase(renderOrder: ActorOrder, maxLifeTime: Int? = null) : Run
lifetimeCounter += delta
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
// simple stuck check
TileCodex[Terrarum.ingame.world.getTileFromTerrain(
TileCodex[Terrarum.ingame!!.world.getTileFromTerrain(
hitbox.pointedX.div(TILE_SIZE).floorInt(),
hitbox.pointedY.div(TILE_SIZE).floorInt()
) ?: Tile.STONE].isSolid) {
@@ -52,7 +52,7 @@ open class ParticleBase(renderOrder: ActorOrder, maxLifeTime: Int? = null) : Run
// gravity, winds, etc. (external forces)
if (!isNoSubjectToGrav) {
velocity += Terrarum.ingame.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
velocity += Terrarum.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
}

View File

@@ -31,13 +31,13 @@ class PhysTestBall : ActorWithSprite(ActorOrder.MIDDLE, immobileBody = true) {
hitbox.height.toFloat())
g.fillOval(
hitbox.posX.toFloat() + Terrarum.ingame.world.width * TILE_SIZE,
hitbox.posX.toFloat() + Terrarum.ingame!!.world.width * TILE_SIZE,
hitbox.posY.toFloat(),
hitbox.width.toFloat(),
hitbox.height.toFloat())
g.fillOval(
hitbox.posX.toFloat() - Terrarum.ingame.world.width * TILE_SIZE,
hitbox.posX.toFloat() - Terrarum.ingame!!.world.width * TILE_SIZE,
hitbox.posY.toFloat(),
hitbox.width.toFloat(),
hitbox.height.toFloat())

View File

@@ -12,7 +12,7 @@ object PlayerBuilder {
private val jsonString = String()
operator fun invoke(): Actor {
val p: Actor = Player(Terrarum.ingame.world.time.currentTimeAsGameDate)
val p: Actor = Player(Terrarum.ingame!!.world.time.currentTimeAsGameDate)
InjectCreatureRaw(p.actorValue, "CreatureHuman.json")
// attach sprite

View File

@@ -75,7 +75,7 @@ open class ProjectileSimple(
lifetimeCounter += delta
if (ccdCollided || grounded || lifetimeCounter >= lifetimeMax ||
// stuck check
TileCodex[Terrarum.ingame.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Tile.STONE].isSolid
TileCodex[Terrarum.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Tile.STONE].isSolid
) {
flagDespawn()
}
@@ -90,13 +90,13 @@ open class ProjectileSimple(
colourTail.a = 0.16f
// draw trail of solid colour (Terraria style maybe?)
g.lineWidth = 2f * Terrarum.ingame.screenZoom
g.lineWidth = 2f * Terrarum.ingame!!.screenZoom
g.drawGradientLine(
hitbox.centeredX.toFloat() * Terrarum.ingame.screenZoom,
hitbox.centeredY.toFloat() * Terrarum.ingame.screenZoom,
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
displayColour,
posPre.x.toFloat() * Terrarum.ingame.screenZoom,
posPre.y.toFloat() * Terrarum.ingame.screenZoom,
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
colourTail
)
}

View File

@@ -10,6 +10,6 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int,
val gc: GameContainer, val delta: Int) : Runnable {
override fun run() {
for (i in startIndex..endIndex)
Terrarum.ingame.actorContainer[i].update(gc, delta)
Terrarum.ingame!!.actorContainer[i].update(gc, delta)
}
}

View File

@@ -239,7 +239,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
luatable[y - feetTilePos[1]] = LuaTable()
for (x in feetTilePos[0] - radius..feetTilePos[0] + radius) {
val tile = TileCodex[Terrarum.ingame.world.getTileFromTerrain(x, y) ?: 4096]
val tile = TileCodex[Terrarum.ingame!!.world.getTileFromTerrain(x, y) ?: 4096]
val solidity = tile.isSolid.toInt()
val liquidity = tile.isFluid.toInt()
val gravity = tile.isFallable.toInt()
@@ -283,7 +283,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
// search down
var searchDownCounter = 0
while (true) {
val tile = Terrarum.ingame.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Tile.STONE
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Tile.STONE
if (TileCodex[tile].isSolid || searchDownCounter >= searchDownLimit) {
luatable[x - feetTilePos[0]] = searchDownCounter
break
@@ -326,7 +326,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
// search up
var searchUpCounter = 0
while (true) {
val tile = Terrarum.ingame.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Tile.STONE
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Tile.STONE
if (TileCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
luatable[x - feetTilePos[0]] = searchUpCounter
break
@@ -368,7 +368,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
// search up
var searchUpCounter = 0
while (true) {
val tile = Terrarum.ingame.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Tile.STONE
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Tile.STONE
if (!TileCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
luatable[x - feetTilePos[0]] = searchUpCounter
break

View File

@@ -20,10 +20,10 @@ object FactionFactory {
val jsonObj = JsonFetcher(JSONPATH + filename)
val factionObj = Faction(jsonObj.get("factionname").asString)
jsonObj.get("factionamicable").asJsonArray.forEach { s -> factionObj.addFactionAmicable(s.asString) }
jsonObj.get("factionneutral").asJsonArray.forEach { s -> factionObj.addFactionNeutral(s.asString) }
jsonObj.get("factionhostile").asJsonArray.forEach { s -> factionObj.addFactionHostile(s.asString) }
jsonObj.get("factionfearful").asJsonArray.forEach { s -> factionObj.addFactionFearful(s.asString) }
jsonObj.get("factionamicable").asJsonArray.forEach { factionObj.addFactionAmicable(it.asString) }
jsonObj.get("factionneutral").asJsonArray.forEach { factionObj.addFactionNeutral(it.asString) }
jsonObj.get("factionhostile").asJsonArray.forEach { factionObj.addFactionHostile(it.asString) }
jsonObj.get("factionfearful").asJsonArray.forEach { factionObj.addFactionFearful(it.asString) }
return factionObj
}

View File

@@ -39,7 +39,7 @@ object CollisionSolver {
collCandidateY.clear()
// mark list x
Terrarum.ingame.actorContainer.forEach { it ->
Terrarum.ingame!!.actorContainer.forEach { it ->
if (it is ActorWithSprite) {
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
@@ -72,7 +72,7 @@ object CollisionSolver {
collCandidateStack.clear()
// mark list y
Terrarum.ingame.actorContainer.forEach { it ->
Terrarum.ingame!!.actorContainer.forEach { it ->
if (it is ActorWithSprite) {
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))