mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
UI testing env and working text buttons
Former-commit-id: b8fd27c7f71f9bc8da259ae132badcbc9ce117ac
This commit is contained in:
@@ -5,6 +5,11 @@
|
|||||||
"APP_ADJUST_YOUR_MONITOR": "Best player experience can be achieved with properly adjusted monitor. If you have not, please do it before you play.",
|
"APP_ADJUST_YOUR_MONITOR": "Best player experience can be achieved with properly adjusted monitor. If you have not, please do it before you play.",
|
||||||
|
|
||||||
"APP_WARNING_HEALTH_AND_SAFETY": "WARNING-HEALTH AND SAFETY",
|
"APP_WARNING_HEALTH_AND_SAFETY": "WARNING-HEALTH AND SAFETY",
|
||||||
"MENU_LABEL_PRESS_START_SYMBOL": "Press >"
|
"MENU_LABEL_PRESS_START_SYMBOL": "Press >",
|
||||||
|
|
||||||
|
"GAME_INVENTORY_INGREDIENTS" : "Ingredients",
|
||||||
|
"GAME_INVENTORY_POTIONS" : "Potions",
|
||||||
|
"GAME_INVENTORY_BLOCKS" : "Blocks",
|
||||||
|
"GAME_INVENTORY_WALLPAPERS" : "Walls",
|
||||||
|
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Equipments"
|
||||||
}
|
}
|
||||||
@@ -6,5 +6,11 @@
|
|||||||
"APP_ADJUST_YOUR_MONITOR": "Paras pelikokemus saavutetaan on oikealla säädetty näytöllä. Jos et ole ollut, säädä ennen pelaamista.",
|
"APP_ADJUST_YOUR_MONITOR": "Paras pelikokemus saavutetaan on oikealla säädetty näytöllä. Jos et ole ollut, säädä ennen pelaamista.",
|
||||||
|
|
||||||
"APP_WARNING_HEALTH_AND_SAFETY": "VAROITUS-TERVEYS JA TURVALLISUUS",
|
"APP_WARNING_HEALTH_AND_SAFETY": "VAROITUS-TERVEYS JA TURVALLISUUS",
|
||||||
"MENU_LABEL_PRESS_START_SYMBOL": "Paina >"
|
"MENU_LABEL_PRESS_START_SYMBOL": "Paina >",
|
||||||
|
|
||||||
|
"GAME_INVENTORY_INGREDIENTS" : "Ainekset",
|
||||||
|
"GAME_INVENTORY_POTIONS" : "Juomat",
|
||||||
|
"GAME_INVENTORY_BLOCKS" : "Lohkareet",
|
||||||
|
"GAME_INVENTORY_WALLPAPERS" : "Tapetit",
|
||||||
|
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Varusteet"
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,11 @@
|
|||||||
"APP_ADJUST_YOUR_MONITOR": "본 게임은 적절히 조정된 모니터에서 최상으로 즐길 수 있습니다. 조정하지 않았다면 플레이하기 전에 조정해 주십시오.",
|
"APP_ADJUST_YOUR_MONITOR": "본 게임은 적절히 조정된 모니터에서 최상으로 즐길 수 있습니다. 조정하지 않았다면 플레이하기 전에 조정해 주십시오.",
|
||||||
|
|
||||||
"APP_WARNING_HEALTH_AND_SAFETY": "경고—건강과 안전을 위하여",
|
"APP_WARNING_HEALTH_AND_SAFETY": "경고—건강과 안전을 위하여",
|
||||||
"MENU_LABEL_PRESS_START_SYMBOL": ">을 누르세요"
|
"MENU_LABEL_PRESS_START_SYMBOL": ">을 누르세요",
|
||||||
|
|
||||||
|
"GAME_INVENTORY_INGREDIENTS" : "재료",
|
||||||
|
"GAME_INVENTORY_POTIONS" : "물약",
|
||||||
|
"GAME_INVENTORY_BLOCKS" : "블록",
|
||||||
|
"GAME_INVENTORY_WALLPAPERS" : "벽지",
|
||||||
|
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "장비"
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ object WriteGameMapData {
|
|||||||
val path = Paths.get("${Terrarum.defaultSaveDir}" +
|
val path = Paths.get("${Terrarum.defaultSaveDir}" +
|
||||||
"/$saveDirectoryName/${WriteMeta.META_FILENAME}")
|
"/$saveDirectoryName/${WriteMeta.META_FILENAME}")
|
||||||
val tempPath = Files.createTempFile(path.toString(), "_temp")
|
val tempPath = Files.createTempFile(path.toString(), "_temp")
|
||||||
val map = Terrarum.ingame.world
|
val map = Terrarum.ingame!!.world
|
||||||
|
|
||||||
// TODO gzip
|
// TODO gzip
|
||||||
|
|
||||||
|
|||||||
@@ -178,17 +178,16 @@ class StateInGame : BasicGameState() {
|
|||||||
// vital metre
|
// vital metre
|
||||||
// fill in getter functions by
|
// fill in getter functions by
|
||||||
// (uiAliases[UI_QUICK_BAR]!!.UI as UIVitalMetre).vitalGetterMax = { some_function }
|
// (uiAliases[UI_QUICK_BAR]!!.UI as UIVitalMetre).vitalGetterMax = { some_function }
|
||||||
uiAliases[UI_VITAL1] = UIHandler(UIVitalMetre(player, { 80f }, { 100f }, Color.green, 0))
|
uiAliases[UI_VITAL1] = UIHandler(UIVitalMetre(player, { 80f }, { 100f }, Color.red, 0))
|
||||||
uiAliases[UI_VITAL1]!!.setAsAlwaysVisible()
|
uiAliases[UI_VITAL1]!!.setAsAlwaysVisible()
|
||||||
uiAliases[UI_VITAL2] = UIHandler(UIVitalMetre(player, { null }, { null }, null, 1))
|
uiAliases[UI_VITAL2] = UIHandler(UIVitalMetre(player, { 73f }, { 100f }, Color(0x00dfff), 1))
|
||||||
uiAliases[UI_VITAL2]!!.setAsAlwaysVisible()
|
uiAliases[UI_VITAL2]!!.setAsAlwaysVisible()
|
||||||
uiAliases[UI_VITAL3] = UIHandler(UIVitalMetre(player, { null }, { null }, null, 2))
|
uiAliases[UI_VITAL3] = UIHandler(UIVitalMetre(player, { 32f }, { 100f }, Color(0xffcc00), 2))
|
||||||
uiAliases[UI_VITAL3]!!.setAsAlwaysVisible()
|
uiAliases[UI_VITAL3]!!.setAsAlwaysVisible()
|
||||||
|
|
||||||
|
|
||||||
// batch-process uiAliases
|
// batch-process uiAliases
|
||||||
uiAliases.forEach { _, uiHandler ->
|
uiAliases.forEach { _, uiHandler ->
|
||||||
uiHandler.UI.handler = uiHandler // attach UIHandlers
|
|
||||||
uiContainer.add(uiHandler) // put them all to the UIContainer
|
uiContainer.add(uiHandler) // put them all to the UIContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +280,7 @@ class StateInGame : BasicGameState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// determine if lightmap blending should be done
|
// determine if lightmap blending should be done
|
||||||
Terrarum.gameConfig["smoothlighting"] = KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH)
|
Terrarum.setConfig("smoothlighting", KeyToggler.isOn(KEY_LIGHTMAP_SMOOTH))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun repossessActor() {
|
private fun repossessActor() {
|
||||||
@@ -644,8 +643,8 @@ class StateInGame : BasicGameState() {
|
|||||||
/** whether the actor is within screen */
|
/** whether the actor is within screen */
|
||||||
private fun ActorVisible.inScreen() =
|
private fun ActorVisible.inScreen() =
|
||||||
distToCameraSqr(this) <=
|
distToCameraSqr(this) <=
|
||||||
(Terrarum.WIDTH.plus(this.hitbox.width.div(2)).times(1 / Terrarum.ingame.screenZoom).sqr() +
|
(Terrarum.WIDTH.plus(this.hitbox.width.div(2)).times(1 / Terrarum.ingame!!.screenZoom).sqr() +
|
||||||
Terrarum.HEIGHT.plus(this.hitbox.height.div(2)).times(1 / Terrarum.ingame.screenZoom).sqr())
|
Terrarum.HEIGHT.plus(this.hitbox.height.div(2)).times(1 / Terrarum.ingame!!.screenZoom).sqr())
|
||||||
|
|
||||||
|
|
||||||
/** whether the actor is within update range */
|
/** whether the actor is within update range */
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
private val colourLUT = IntArray(32, { 255.times(it + 1).div(32) })
|
private val colourLUT = IntArray(32, { 255.times(it + 1).div(32) })
|
||||||
|
|
||||||
val pictograms = ArrayList<Image>()
|
val pictograms = ArrayList<Image>()
|
||||||
lateinit var imageGallery: ItemImageGallery
|
val imageGallery: UIItemImageGallery
|
||||||
|
|
||||||
val instructionY = Terrarum.HEIGHT / 2//Terrarum.HEIGHT * 9 / 16
|
val instructionY = Terrarum.HEIGHT / 2//Terrarum.HEIGHT * 9 / 16
|
||||||
val anykeyY = Terrarum.HEIGHT * 15 / 16
|
val anykeyY = Terrarum.HEIGHT * 15 / 16
|
||||||
@@ -58,7 +58,9 @@ class StateMonitorCheck : BasicGameState() {
|
|||||||
pictograms.add(Image("./assets/graphics/gui/monitor_good.tga"))
|
pictograms.add(Image("./assets/graphics/gui/monitor_good.tga"))
|
||||||
pictograms.add(Image("./assets/graphics/gui/monitor_bad.tga"))
|
pictograms.add(Image("./assets/graphics/gui/monitor_bad.tga"))
|
||||||
|
|
||||||
imageGallery = ItemImageGallery(0, instructionY, Terrarum.WIDTH, anykeyY - instructionY, pictograms)
|
imageGallery = UIItemImageGallery(
|
||||||
|
this, 0, instructionY, Terrarum.WIDTH, anykeyY - instructionY, pictograms
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import net.torvald.terrarum.gameactors.roundInt
|
|||||||
import net.torvald.terrarum.gamecontroller.Key
|
import net.torvald.terrarum.gamecontroller.Key
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.ui.DrawUtil
|
import net.torvald.terrarum.ui.DrawUtil
|
||||||
import net.torvald.terrarum.ui.ItemImageGallery
|
import net.torvald.terrarum.ui.NullUI
|
||||||
|
import net.torvald.terrarum.ui.UIItemImageGallery
|
||||||
import net.torvald.terrarum.ui.Typography
|
import net.torvald.terrarum.ui.Typography
|
||||||
import org.newdawn.slick.Color
|
import org.newdawn.slick.Color
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
@@ -46,7 +47,7 @@ class StateSplash : BasicGameState() {
|
|||||||
|
|
||||||
var init = false
|
var init = false
|
||||||
|
|
||||||
lateinit var imageGallery: ItemImageGallery
|
lateinit var imageGallery: UIItemImageGallery
|
||||||
|
|
||||||
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||||
// pre-load lang
|
// pre-load lang
|
||||||
@@ -62,7 +63,9 @@ class StateSplash : BasicGameState() {
|
|||||||
imageBoardHeight = Terrarum.HEIGHT - thisG.font.lineHeight.times(6)
|
imageBoardHeight = Terrarum.HEIGHT - thisG.font.lineHeight.times(6)
|
||||||
imageBoardOffset = thisG.font.lineHeight.times(3)
|
imageBoardOffset = thisG.font.lineHeight.times(3)
|
||||||
|
|
||||||
imageGallery = ItemImageGallery(0, imageBoardOffset, Terrarum.WIDTH, imageBoardHeight, pictogramCollection)
|
imageGallery = UIItemImageGallery(
|
||||||
|
NullUI(), 0, imageBoardOffset, Terrarum.WIDTH, imageBoardHeight, pictogramCollection
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
||||||
|
|||||||
120
src/net/torvald/terrarum/StateUITest.kt
Normal file
120
src/net/torvald/terrarum/StateUITest.kt
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import net.torvald.terrarum.gameactors.ActorInventory
|
||||||
|
import net.torvald.terrarum.gameitem.InventoryItem
|
||||||
|
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||||
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.terrarum.ui.UIHandler
|
||||||
|
import net.torvald.terrarum.ui.UIItemTextButton
|
||||||
|
import net.torvald.terrarum.ui.UIItemTextButtonList
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.Input
|
||||||
|
import org.newdawn.slick.state.BasicGameState
|
||||||
|
import org.newdawn.slick.state.StateBasedGame
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
|
*/
|
||||||
|
class StateUITest : BasicGameState() {
|
||||||
|
|
||||||
|
val ui = UIHandler(SimpleUI())
|
||||||
|
|
||||||
|
val inventory = ActorInventory()
|
||||||
|
|
||||||
|
init {
|
||||||
|
ui.posX = 50
|
||||||
|
ui.isVisible = true
|
||||||
|
|
||||||
|
|
||||||
|
inventory.add(object : InventoryItem() {
|
||||||
|
override val id: Int = 5656
|
||||||
|
override var baseMass: Double = 12.0
|
||||||
|
override var baseToolSize: Double? = 8.0
|
||||||
|
override var category: String = "tool"
|
||||||
|
})
|
||||||
|
|
||||||
|
inventory.add(object : InventoryItem() {
|
||||||
|
override val id: Int = 4633
|
||||||
|
override var baseMass: Double = 1.4
|
||||||
|
override var baseToolSize: Double? = null
|
||||||
|
override var category: String = "bulk"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
||||||
|
ui.update(container, delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getID() = Terrarum.STATE_ID_TEST_UI
|
||||||
|
|
||||||
|
override fun render(container: GameContainer, game: StateBasedGame, g: Graphics) {
|
||||||
|
ui.render(container, game, g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private class SimpleUI : UICanvas {
|
||||||
|
override var width = 400
|
||||||
|
override var height = 600
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
override var openCloseTime: Int = UICanvas.OPENCLOSE_GENERIC
|
||||||
|
|
||||||
|
val buttons = UIItemTextButtonList(
|
||||||
|
this,
|
||||||
|
arrayOf(
|
||||||
|
"GAME_INVENTORY_WEAPONS", // weapons and tools
|
||||||
|
"CONTEXT_ITEM_EQUIPMENT_PLURAL",
|
||||||
|
"CONTEXT_ITEM_ARMOR",
|
||||||
|
"GAME_INVENTORY_INGREDIENTS",
|
||||||
|
"GAME_INVENTORY_POTIONS",
|
||||||
|
"GAME_INVENTORY_BLOCKS",
|
||||||
|
"GAME_INVENTORY_WALLPAPERS",
|
||||||
|
"MENU_LABEL_ALL"
|
||||||
|
),
|
||||||
|
300, height,
|
||||||
|
readFromLang = true
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
Terrarum.gameLocale = "fiFI" // hot swap this to test
|
||||||
|
|
||||||
|
buttons.update(gc, delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
g.color = Color(0x282828)
|
||||||
|
g.fillRect(0f, 0f, 300f, 600f)
|
||||||
|
|
||||||
|
|
||||||
|
buttons.render(gc, g)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
UICanvas.doOpeningFade(handler, openCloseTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
|
UICanvas.doClosingFade(handler, openCloseTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
|
UICanvas.endOpeningFade(handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
|
UICanvas.endClosingFade(handler)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,8 +66,8 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
|||||||
|
|
||||||
var gameStarted = false
|
var gameStarted = false
|
||||||
|
|
||||||
lateinit var ingame: StateInGame
|
var ingame: StateInGame? = null
|
||||||
lateinit var gameConfig: GameConfig
|
private val gameConfig = GameConfig()
|
||||||
|
|
||||||
val OSName = System.getProperty("os.name")
|
val OSName = System.getProperty("os.name")
|
||||||
val OSVersion = System.getProperty("os.version")
|
val OSVersion = System.getProperty("os.version")
|
||||||
@@ -133,6 +133,7 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
|||||||
val STATE_ID_TEST_TTY = 0x102
|
val STATE_ID_TEST_TTY = 0x102
|
||||||
val STATE_ID_TEST_BLUR = 0x103
|
val STATE_ID_TEST_BLUR = 0x103
|
||||||
val STATE_ID_TEST_SHADER = 0x104
|
val STATE_ID_TEST_SHADER = 0x104
|
||||||
|
val STATE_ID_TEST_UI = 0x105
|
||||||
|
|
||||||
val STATE_ID_TOOL_NOISEGEN = 0x200
|
val STATE_ID_TOOL_NOISEGEN = 0x200
|
||||||
|
|
||||||
@@ -187,8 +188,6 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
|||||||
println("Java is running in 32 Bit")
|
println("Java is running in 32 Bit")
|
||||||
}
|
}
|
||||||
|
|
||||||
gameConfig = GameConfig()
|
|
||||||
|
|
||||||
joypadLabelStart = when (getConfigString("joypadlabelstyle")) {
|
joypadLabelStart = when (getConfigString("joypadlabelstyle")) {
|
||||||
"nwii" -> 0xE04B.toChar() // + mark
|
"nwii" -> 0xE04B.toChar() // + mark
|
||||||
"logitech" -> 0xE05A.toChar() // number 10
|
"logitech" -> 0xE05A.toChar() // number 10
|
||||||
@@ -282,9 +281,10 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
|||||||
//addState(StateBlurTest())
|
//addState(StateBlurTest())
|
||||||
//addState(StateShaderTest())
|
//addState(StateShaderTest())
|
||||||
//addState(StateNoiseTester())
|
//addState(StateNoiseTester())
|
||||||
|
addState(StateUITest())
|
||||||
|
|
||||||
ingame = StateInGame()
|
//ingame = StateInGame()
|
||||||
addState(ingame)
|
//addState(ingame)
|
||||||
|
|
||||||
|
|
||||||
// foolproof
|
// foolproof
|
||||||
@@ -435,6 +435,10 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
|||||||
return cfg!!
|
return cfg!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setConfig(key: String, value: Any) {
|
||||||
|
gameConfig[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
val currentSaveDir: File
|
val currentSaveDir: File
|
||||||
get() {
|
get() {
|
||||||
val file = File(defaultSaveDir + "/test")
|
val file = File(defaultSaveDir + "/test")
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ object AVTracker : ConsoleCommand {
|
|||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size < 2) {
|
if (args.size < 2) {
|
||||||
jPanelInstances.add(ActorValueTracker(Terrarum.ingame.player))
|
jPanelInstances.add(ActorValueTracker(Terrarum.ingame!!.player))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
val actorID = args[1].toInt()
|
val actorID = args[1].toInt()
|
||||||
|
|
||||||
if (Terrarum.ingame.theGameHasActor(actorID)) {
|
if (Terrarum.ingame!!.theGameHasActor(actorID)) {
|
||||||
jPanelInstances.add(ActorValueTracker(Terrarum.ingame.getActorByID(actorID)))
|
jPanelInstances.add(ActorValueTracker(Terrarum.ingame!!.getActorByID(actorID)))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw IllegalArgumentException()
|
throw IllegalArgumentException()
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ object ActorsList : ConsoleCommand {
|
|||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
jPanelInstances.add(ActorsLister(
|
jPanelInstances.add(ActorsLister(
|
||||||
Terrarum.ingame.actorContainer,
|
Terrarum.ingame!!.actorContainer,
|
||||||
Terrarum.ingame.actorContainerInactive)
|
Terrarum.ingame!!.actorContainerInactive)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ internal object Authenticator : ConsoleCommand {
|
|||||||
Echo(msg)
|
Echo(msg)
|
||||||
println("[Authenticator] " + msg)
|
println("[Authenticator] " + msg)
|
||||||
a = !a
|
a = !a
|
||||||
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).reset()
|
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).reset()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printUsage() // thou shalt not pass!
|
printUsage() // thou shalt not pass!
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ internal object Echo : ConsoleCommand {
|
|||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
for (ch in single_line) {
|
for (ch in single_line) {
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||||
sb.delete(0, sb.length - 1)
|
sb.delete(0, sb.length - 1)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sb.append(ch)
|
sb.append(ch)
|
||||||
}
|
}
|
||||||
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun invoke(args: Array<String>) = execute(args)
|
operator fun invoke(args: Array<String>) = execute(args)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ internal object EchoError : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun execute(single_line: String) {
|
fun execute(single_line: String) {
|
||||||
(Terrarum.ingame.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line")
|
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage("${GameFontBase.colToCode["r"]}$single_line")
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun invoke(args: Array<String>) = execute(args)
|
operator fun invoke(args: Array<String>) = execute(args)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ internal object ExportAV : ConsoleCommand {
|
|||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
try {
|
try {
|
||||||
JsonWriter.writeToFile(
|
JsonWriter.writeToFile(
|
||||||
Terrarum.ingame.player.actorValue,
|
Terrarum.ingame!!.player.actorValue,
|
||||||
Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
|
Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
|
||||||
|
|
||||||
Echo("ExportAV: exported to " + args[1] + ".json")
|
Echo("ExportAV: exported to " + args[1] + ".json")
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ internal object ExportMap : ConsoleCommand {
|
|||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
|
|
||||||
var mapData = ByteArray(Terrarum.ingame.world.width * Terrarum.ingame.world.height * 3)
|
var mapData = ByteArray(Terrarum.ingame!!.world.width * Terrarum.ingame!!.world.height * 3)
|
||||||
var mapDataPointer = 0
|
var mapDataPointer = 0
|
||||||
|
|
||||||
for (tile in Terrarum.ingame.world.terrainIterator()) {
|
for (tile in Terrarum.ingame!!.world.terrainIterator()) {
|
||||||
val colArray = (colorTable as Map<Int, Col4096>)
|
val colArray = (colorTable as Map<Int, Col4096>)
|
||||||
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
|
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ internal object ExportMap : ConsoleCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
RasterWriter.writePNG_RGB(
|
RasterWriter.writePNG_RGB(
|
||||||
Terrarum.ingame.world.width, Terrarum.ingame.world.height, mapData, dir + args[1] + ".png")
|
Terrarum.ingame!!.world.width, Terrarum.ingame!!.world.height, mapData, dir + args[1] + ".png")
|
||||||
Echo("ExportMap: exported to " + args[1] + ".png")
|
Echo("ExportMap: exported to " + args[1] + ".png")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ internal object GetAV : ConsoleCommand {
|
|||||||
try {
|
try {
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
// print all actorvalue of player
|
// print all actorvalue of player
|
||||||
val av = Terrarum.ingame.player.actorValue
|
val av = Terrarum.ingame!!.player.actorValue
|
||||||
val keyset = av.keySet
|
val keyset = av.keySet
|
||||||
|
|
||||||
Echo("$ccW== ActorValue list for ${ccY}player $ccW==")
|
Echo("$ccW== ActorValue list for ${ccY}player $ccW==")
|
||||||
@@ -37,19 +37,19 @@ internal object GetAV : ConsoleCommand {
|
|||||||
if (!args[1].isNum()) { // args[1] is ActorValue name
|
if (!args[1].isNum()) { // args[1] is ActorValue name
|
||||||
Echo("${ccW}player.$ccM${args[1]} $ccW= " +
|
Echo("${ccW}player.$ccM${args[1]} $ccW= " +
|
||||||
ccG +
|
ccG +
|
||||||
Terrarum.ingame.player.actorValue[args[1]] +
|
Terrarum.ingame!!.player.actorValue[args[1]] +
|
||||||
" $ccO" +
|
" $ccO" +
|
||||||
Terrarum.ingame.player.actorValue[args[1]]!!.javaClass.simpleName
|
Terrarum.ingame!!.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||||
)
|
)
|
||||||
println("[GetAV] player.${args[1]} = " +
|
println("[GetAV] player.${args[1]} = " +
|
||||||
Terrarum.ingame.player.actorValue[args[1]] +
|
Terrarum.ingame!!.player.actorValue[args[1]] +
|
||||||
" " +
|
" " +
|
||||||
Terrarum.ingame.player.actorValue[args[1]]!!.javaClass.simpleName
|
Terrarum.ingame!!.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// args[1] is actor ID
|
// args[1] is actor ID
|
||||||
val actor = Terrarum.ingame.getActorByID(args[1].toInt())
|
val actor = Terrarum.ingame!!.getActorByID(args[1].toInt())
|
||||||
val av = actor.actorValue
|
val av = actor.actorValue
|
||||||
val keyset = av.keySet
|
val keyset = av.keySet
|
||||||
|
|
||||||
@@ -71,14 +71,14 @@ internal object GetAV : ConsoleCommand {
|
|||||||
val id = args[1].toInt()
|
val id = args[1].toInt()
|
||||||
val av = args[2]
|
val av = args[2]
|
||||||
Echo("$ccW$id.$ccM$av $ccW= $ccG" +
|
Echo("$ccW$id.$ccM$av $ccW= $ccG" +
|
||||||
Terrarum.ingame.getActorByID(id).actorValue[av] +
|
Terrarum.ingame!!.getActorByID(id).actorValue[av] +
|
||||||
" $ccO" +
|
" $ccO" +
|
||||||
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
Terrarum.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||||
)
|
)
|
||||||
println("$id.$av = " +
|
println("$id.$av = " +
|
||||||
Terrarum.ingame.getActorByID(id).actorValue[av] +
|
Terrarum.ingame!!.getActorByID(id).actorValue[av] +
|
||||||
" " +
|
" " +
|
||||||
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
Terrarum.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ internal object GetFactioning : ConsoleCommand {
|
|||||||
val error = Error()
|
val error = Error()
|
||||||
|
|
||||||
fun printOutFactioning(id: Int) {
|
fun printOutFactioning(id: Int) {
|
||||||
val a = Terrarum.ingame.getActorByID(id)
|
val a = Terrarum.ingame!!.getActorByID(id)
|
||||||
if (a is Factionable) {
|
if (a is Factionable) {
|
||||||
Echo("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
|
Echo("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
|
||||||
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")
|
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.Terrarum
|
|||||||
internal object GetTime : ConsoleCommand {
|
internal object GetTime : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
|
|
||||||
val worldTime = Terrarum.ingame.world.time
|
val worldTime = Terrarum.ingame!!.world.time
|
||||||
Echo(worldTime.getFormattedTime())
|
Echo(worldTime.getFormattedTime())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.io.IOException
|
|||||||
internal object GsonTest : ConsoleCommand {
|
internal object GsonTest : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
val avelem = Gson().toJsonTree(Terrarum.ingame.player)
|
val avelem = Gson().toJsonTree(Terrarum.ingame!!.player)
|
||||||
|
|
||||||
val jsonString = avelem.toString()
|
val jsonString = avelem.toString()
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
|||||||
*/
|
*/
|
||||||
internal object Inventory : ConsoleCommand {
|
internal object Inventory : ConsoleCommand {
|
||||||
|
|
||||||
private var target: Pocketed = Terrarum.ingame.player
|
private var target: Pocketed = Terrarum.ingame!!.player
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
@@ -45,7 +45,7 @@ internal object Inventory : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) {
|
private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) {
|
||||||
val actor = Terrarum.ingame.getActorByID(actorRefId)
|
val actor = Terrarum.ingame!!.getActorByID(actorRefId)
|
||||||
if (actor !is Pocketed) {
|
if (actor !is Pocketed) {
|
||||||
EchoError("Cannot edit inventory of incompatible actor: $actor")
|
EchoError("Cannot edit inventory of incompatible actor: $actor")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ object KillActor : ConsoleCommand {
|
|||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
try {
|
try {
|
||||||
val actorid = args[1].toInt()
|
val actorid = args[1].toInt()
|
||||||
Terrarum.ingame.removeActor(actorid)
|
Terrarum.ingame!!.removeActor(actorid)
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
EchoError("Wrong number input.")
|
EchoError("Wrong number input.")
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ internal object Seed : ConsoleCommand {
|
|||||||
val ccY = GameFontBase.colToCode["y"]
|
val ccY = GameFontBase.colToCode["y"]
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
Echo("Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}")
|
Echo("Map$ccW: $ccG${Terrarum.ingame!!.world.generatorSeed}")
|
||||||
println("[seed] Map$ccW: $ccG${Terrarum.ingame.world.generatorSeed}")
|
println("[seed] Map$ccW: $ccG${Terrarum.ingame!!.world.generatorSeed}")
|
||||||
// TODO display randomiser seed
|
// TODO display randomiser seed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ internal object SetAV : ConsoleCommand {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrarum.ingame.player.actorValue[args[1]] = newValue
|
Terrarum.ingame!!.player.actorValue[args[1]] = newValue
|
||||||
Echo("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$newValue")
|
Echo("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$newValue")
|
||||||
println("[SetAV] set ActorValue '${args[1]}' for player to '$newValue'.")
|
println("[SetAV] set ActorValue '${args[1]}' for player to '$newValue'.")
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ internal object SetAV : ConsoleCommand {
|
|||||||
try {
|
try {
|
||||||
val id = args[1].toInt()
|
val id = args[1].toInt()
|
||||||
val newValue = parseAVInput(args[3])
|
val newValue = parseAVInput(args[3])
|
||||||
val actor = Terrarum.ingame.getActorByID(id)
|
val actor = Terrarum.ingame!!.getActorByID(id)
|
||||||
|
|
||||||
// check if av is number
|
// check if av is number
|
||||||
if (args[2].isNum()) {
|
if (args[2].isNum()) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ internal object SetBulletin : ConsoleCommand {
|
|||||||
* @param message real message
|
* @param message real message
|
||||||
*/
|
*/
|
||||||
fun send(message: Array<String>) {
|
fun send(message: Array<String>) {
|
||||||
Terrarum.ingame.sendNotification(message)
|
Terrarum.ingame!!.sendNotification(message)
|
||||||
println("sent notifinator")
|
println("sent notifinator")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
|||||||
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
|
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
|
||||||
|
|
||||||
lightOverride = true
|
lightOverride = true
|
||||||
Terrarum.ingame.world.globalLight = GL
|
Terrarum.ingame!!.world.globalLight = GL
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
Echo("Wrong number input.")
|
Echo("Wrong number input.")
|
||||||
@@ -38,7 +38,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
|||||||
Echo("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
|
Echo("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Terrarum.ingame.world.globalLight = GL
|
Terrarum.ingame!!.world.globalLight = GL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ object SetScale : ConsoleCommand {
|
|||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 2 || args.size == 3) {
|
if (args.size == 2 || args.size == 3) {
|
||||||
try {
|
try {
|
||||||
val targetID = if (args.size == 3) args[1].toInt() else Terrarum.ingame.player.referenceID
|
val targetID = if (args.size == 3) args[1].toInt() else Terrarum.ingame!!.player.referenceID
|
||||||
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
||||||
|
|
||||||
val target = Terrarum.ingame.getActorByID(targetID)
|
val target = Terrarum.ingame!!.getActorByID(targetID)
|
||||||
|
|
||||||
if (target !is ActorWithSprite) {
|
if (target !is ActorWithSprite) {
|
||||||
EchoError("Target is not ActorWithSprite")
|
EchoError("Target is not ActorWithSprite")
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ internal object SetTime : ConsoleCommand {
|
|||||||
if (args.size == 2) {
|
if (args.size == 2) {
|
||||||
val timeToSet = WorldTime.parseTime(args[1])
|
val timeToSet = WorldTime.parseTime(args[1])
|
||||||
|
|
||||||
Terrarum.ingame.world.time.setTime(timeToSet)
|
Terrarum.ingame!!.world.time.setTime(timeToSet)
|
||||||
|
|
||||||
Echo("Set time to ${Terrarum.ingame.world.time.elapsedSeconds} " +
|
Echo("Set time to ${Terrarum.ingame!!.world.time.elapsedSeconds} " +
|
||||||
"(${Terrarum.ingame.world.time.hours}h${formatMin(Terrarum.ingame.world.time.minutes)})")
|
"(${Terrarum.ingame!!.world.time.hours}h${formatMin(Terrarum.ingame!!.world.time.minutes)})")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ internal object SetTimeDelta : ConsoleCommand {
|
|||||||
if (args[1].toInt() > HARD_LIMIT)
|
if (args[1].toInt() > HARD_LIMIT)
|
||||||
EchoError("Delta too large -- acceptable delta is 0-60.")
|
EchoError("Delta too large -- acceptable delta is 0-60.")
|
||||||
|
|
||||||
Terrarum.ingame.world.time.setTimeDelta(args[1].toInt())
|
Terrarum.ingame!!.world.time.setTimeDelta(args[1].toInt())
|
||||||
if (Terrarum.ingame.world.time.timeDelta == 0)
|
if (Terrarum.ingame!!.world.time.timeDelta == 0)
|
||||||
Echo("時間よ止まれ!ザ・ワルド!!")
|
Echo("時間よ止まれ!ザ・ワルド!!")
|
||||||
else
|
else
|
||||||
Echo("Set time delta to ${Terrarum.ingame.world.time.timeDelta}")
|
Echo("Set time delta to ${Terrarum.ingame!!.world.time.timeDelta}")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
|||||||
ball.elasticity = elasticity
|
ball.elasticity = elasticity
|
||||||
ball.applyForce(Vector2(xvel, yvel))
|
ball.applyForce(Vector2(xvel, yvel))
|
||||||
|
|
||||||
Terrarum.ingame.addNewActor(ball)
|
Terrarum.ingame!!.addNewActor(ball)
|
||||||
}
|
}
|
||||||
else if (args.size == 2) {
|
else if (args.size == 2) {
|
||||||
val elasticity = args[1].toDouble()
|
val elasticity = args[1].toDouble()
|
||||||
@@ -43,7 +43,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
|||||||
)
|
)
|
||||||
ball.elasticity = elasticity
|
ball.elasticity = elasticity
|
||||||
|
|
||||||
Terrarum.ingame.addNewActor(ball)
|
Terrarum.ingame!!.addNewActor(ball)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ object SpawnTapestry : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val tapestry = DecodeTapestry(File(args[1]))
|
val tapestry = DecodeTapestry(File(args[1]))
|
||||||
Terrarum.ingame.addNewActor(tapestry)
|
Terrarum.ingame!!.addNewActor(tapestry)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun printUsage() {
|
override fun printUsage() {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ object SpawnTikiTorch : ConsoleCommand {
|
|||||||
val torch = FixtureTikiTorch()
|
val torch = FixtureTikiTorch()
|
||||||
torch.setPosition(Terrarum.appgc.mouseX, Terrarum.appgc.mouseY)
|
torch.setPosition(Terrarum.appgc.mouseX, Terrarum.appgc.mouseY)
|
||||||
|
|
||||||
Terrarum.ingame.addNewActor(torch)
|
Terrarum.ingame!!.addNewActor(torch)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun printUsage() {
|
override fun printUsage() {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ internal object Teleport : ConsoleCommand {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrarum.ingame.player.setPosition(x.toDouble(), y.toDouble())
|
Terrarum.ingame!!.player.setPosition(x.toDouble(), y.toDouble())
|
||||||
}
|
}
|
||||||
else if (args.size == 4) {
|
else if (args.size == 4) {
|
||||||
if (args[2].toLowerCase() != "to") {
|
if (args[2].toLowerCase() != "to") {
|
||||||
@@ -36,20 +36,20 @@ internal object Teleport : ConsoleCommand {
|
|||||||
try {
|
try {
|
||||||
val fromActorID = args[1].toInt()
|
val fromActorID = args[1].toInt()
|
||||||
val targetActorID = if (args[3].toLowerCase() == "player")
|
val targetActorID = if (args[3].toLowerCase() == "player")
|
||||||
Terrarum.ingame.player.referenceID
|
Terrarum.ingame!!.player.referenceID
|
||||||
else
|
else
|
||||||
args[3].toInt()
|
args[3].toInt()
|
||||||
|
|
||||||
// if from == target, ignore the action
|
// if from == target, ignore the action
|
||||||
if (fromActorID == targetActorID) return
|
if (fromActorID == targetActorID) return
|
||||||
|
|
||||||
if (Terrarum.ingame.getActorByID(fromActorID) !is ActorWithSprite ||
|
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWithSprite ||
|
||||||
Terrarum.ingame.getActorByID(targetActorID) !is ActorWithSprite) {
|
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWithSprite) {
|
||||||
throw IllegalArgumentException()
|
throw IllegalArgumentException()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fromActor = Terrarum.ingame.getActorByID(fromActorID) as ActorWithSprite
|
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWithSprite
|
||||||
targetActor = Terrarum.ingame.getActorByID(targetActorID) as ActorWithSprite
|
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWithSprite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
@@ -80,11 +80,11 @@ internal object Teleport : ConsoleCommand {
|
|||||||
y = args[4].toInt() * FeaturesDrawer.TILE_SIZE + FeaturesDrawer.TILE_SIZE / 2
|
y = args[4].toInt() * FeaturesDrawer.TILE_SIZE + FeaturesDrawer.TILE_SIZE / 2
|
||||||
val actorID = args[1].toInt()
|
val actorID = args[1].toInt()
|
||||||
|
|
||||||
if (Terrarum.ingame.getActorByID(actorID) !is ActorWithSprite) {
|
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWithSprite) {
|
||||||
throw IllegalArgumentException()
|
throw IllegalArgumentException()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
actor = Terrarum.ingame.getActorByID(actorID) as ActorWithSprite
|
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWithSprite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import net.torvald.terrarum.Terrarum
|
|||||||
*/
|
*/
|
||||||
internal object ToggleNoClip : ConsoleCommand {
|
internal object ToggleNoClip : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val status = Terrarum.ingame.player.isNoClip()
|
val status = Terrarum.ingame!!.player.isNoClip()
|
||||||
|
|
||||||
Terrarum.ingame.player.setNoClip(!status)
|
Terrarum.ingame!!.player.setNoClip(!status)
|
||||||
Echo("Set no-clip status to " + (!status).toString())
|
Echo("Set no-clip status to " + (!status).toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ internal object Zoom : ConsoleCommand {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoom < Terrarum.ingame.ZOOM_MIN) {
|
if (zoom < Terrarum.ingame!!.ZOOM_MIN) {
|
||||||
zoom = Terrarum.ingame.ZOOM_MIN
|
zoom = Terrarum.ingame!!.ZOOM_MIN
|
||||||
}
|
}
|
||||||
else if (zoom > Terrarum.ingame.ZOOM_MAX) {
|
else if (zoom > Terrarum.ingame!!.ZOOM_MAX) {
|
||||||
zoom = Terrarum.ingame.ZOOM_MAX
|
zoom = Terrarum.ingame!!.ZOOM_MAX
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrarum.ingame.screenZoom = zoom
|
Terrarum.ingame!!.screenZoom = zoom
|
||||||
|
|
||||||
System.gc()
|
System.gc()
|
||||||
|
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ class ActorValueTracker constructor() : JFrame() {
|
|||||||
override fun mouseExited(e: MouseEvent?) { }
|
override fun mouseExited(e: MouseEvent?) { }
|
||||||
override fun mousePressed(e: MouseEvent?) {
|
override fun mousePressed(e: MouseEvent?) {
|
||||||
if (actorIDField.text.toLowerCase() == "player") {
|
if (actorIDField.text.toLowerCase() == "player") {
|
||||||
actor = Terrarum.ingame.player
|
actor = Terrarum.ingame!!.player
|
||||||
actorValue = actor!!.actorValue
|
actorValue = actor!!.actorValue
|
||||||
}
|
}
|
||||||
else if (actorIDField.text.isNotBlank()) {
|
else if (actorIDField.text.isNotBlank()) {
|
||||||
actor = Terrarum.ingame.getActorByID(actorIDField.text.toInt()) as ActorWithSprite
|
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWithSprite
|
||||||
actorValue = actor!!.actorValue
|
actorValue = actor!!.actorValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ abstract class Actor(val renderOrder: ActorOrder) : Comparable<Actor>, Runnable
|
|||||||
*/
|
*/
|
||||||
fun generateUniqueReferenceID(): Int {
|
fun generateUniqueReferenceID(): Int {
|
||||||
fun checkForCollision(value: Int) =
|
fun checkForCollision(value: Int) =
|
||||||
Terrarum.ingame.theGameHasActor(value) ||
|
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||||
value < ItemCodex.ITEM_COUNT_MAX ||
|
value < ItemCodex.ITEM_COUNT_MAX ||
|
||||||
value < when (renderOrder) {
|
value < when (renderOrder) {
|
||||||
ActorOrder.BEHIND -> ItemCodex.ITEM_COUNT_MAX
|
ActorOrder.BEHIND -> ItemCodex.ITEM_COUNT_MAX
|
||||||
|
|||||||
@@ -132,14 +132,14 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
|||||||
protected var isRightDown = false
|
protected var isRightDown = false
|
||||||
protected var isJumpDown = false
|
protected var isJumpDown = false
|
||||||
protected val isGamer: Boolean
|
protected val isGamer: Boolean
|
||||||
get() = this == Terrarum.ingame.player
|
get() = this == Terrarum.ingame!!.player
|
||||||
|
|
||||||
|
|
||||||
private val nullItem = object : InventoryItem() {
|
private val nullItem = object : InventoryItem() {
|
||||||
override val id: Int = 0
|
override val id: Int = 0
|
||||||
override var scale: Double = 1.0
|
|
||||||
override var baseMass: Double = 0.0
|
override var baseMass: Double = 0.0
|
||||||
override var baseToolSize: Double? = null
|
override var baseToolSize: Double? = null
|
||||||
|
override var category = "should_not_be_seen"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
|||||||
@@ -55,8 +55,9 @@ class ActorInventory() {
|
|||||||
fun add(item: InventoryItem, count: Int = 1) {
|
fun add(item: InventoryItem, count: Int = 1) {
|
||||||
if (item.id == Player.PLAYER_REF_ID)
|
if (item.id == Player.PLAYER_REF_ID)
|
||||||
throw IllegalArgumentException("Attempted to put human player into the inventory.")
|
throw IllegalArgumentException("Attempted to put human player into the inventory.")
|
||||||
if (Terrarum.ingame.playableActorDelegate != null &&
|
if (Terrarum.ingame != null &&
|
||||||
item.id == Terrarum.ingame.player.referenceID)
|
Terrarum.ingame!!.playableActorDelegate != null &&
|
||||||
|
item.id == Terrarum.ingame!!.player.referenceID)
|
||||||
throw IllegalArgumentException("Attempted to put active player into the inventory.")
|
throw IllegalArgumentException("Attempted to put active player into the inventory.")
|
||||||
|
|
||||||
// If we already have the item, increment the amount
|
// If we already have the item, increment the amount
|
||||||
|
|||||||
@@ -7,15 +7,10 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
|
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.tileproperties.TileCodex
|
import net.torvald.terrarum.tileproperties.TileCodex
|
||||||
import net.torvald.spriteanimation.SpriteAnimation
|
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.mapdrawer.MapCamera
|
||||||
import net.torvald.terrarum.tileproperties.Tile
|
import net.torvald.terrarum.tileproperties.Tile
|
||||||
import net.torvald.terrarum.tileproperties.TileProp
|
import net.torvald.terrarum.tileproperties.TileProp
|
||||||
import org.dyn4j.Epsilon
|
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import org.newdawn.slick.Color
|
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
import org.newdawn.slick.Image
|
import org.newdawn.slick.Image
|
||||||
@@ -42,7 +37,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
|||||||
|
|
||||||
var drawMode = BLEND_NORMAL
|
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
|
var hitboxTranslateX: Double = 0.0// relative to spritePosX
|
||||||
protected set
|
protected set
|
||||||
@@ -1273,8 +1268,8 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
|||||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||||
if (x < 0)
|
if (x < 0)
|
||||||
return 0
|
return 0
|
||||||
else if (x >= Terrarum.ingame.world.width shl 4)
|
else if (x >= Terrarum.ingame!!.world.width shl 4)
|
||||||
return Terrarum.ingame.world.width - 1
|
return Terrarum.ingame!!.world.width - 1
|
||||||
else
|
else
|
||||||
return x and 0x7FFFFFFF shr 4
|
return x and 0x7FFFFFFF shr 4
|
||||||
}
|
}
|
||||||
@@ -1282,8 +1277,8 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
|||||||
private fun div16TruncateToMapHeight(y: Int): Int {
|
private fun div16TruncateToMapHeight(y: Int): Int {
|
||||||
if (y < 0)
|
if (y < 0)
|
||||||
return 0
|
return 0
|
||||||
else if (y >= Terrarum.ingame.world.height shl 4)
|
else if (y >= Terrarum.ingame!!.world.height shl 4)
|
||||||
return Terrarum.ingame.world.height - 1
|
return Terrarum.ingame!!.world.height - 1
|
||||||
else
|
else
|
||||||
return y and 0x7FFFFFFF shr 4
|
return y and 0x7FFFFFFF shr 4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ open class HumanoidNPC(
|
|||||||
set(value) {
|
set(value) {
|
||||||
actorValue[AVKey.SCALE] = value
|
actorValue[AVKey.SCALE] = value
|
||||||
}
|
}
|
||||||
|
override var category = "npc"
|
||||||
|
|
||||||
override fun secondaryUse(gc: GameContainer, delta: Int) {
|
override fun secondaryUse(gc: GameContainer, delta: Int) {
|
||||||
// TODO place this Actor to the world
|
// TODO place this Actor to the world
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ open class ParticleBase(renderOrder: ActorOrder, maxLifeTime: Int? = null) : Run
|
|||||||
lifetimeCounter += delta
|
lifetimeCounter += delta
|
||||||
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
|
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
|
||||||
// simple stuck check
|
// simple stuck check
|
||||||
TileCodex[Terrarum.ingame.world.getTileFromTerrain(
|
TileCodex[Terrarum.ingame!!.world.getTileFromTerrain(
|
||||||
hitbox.pointedX.div(TILE_SIZE).floorInt(),
|
hitbox.pointedX.div(TILE_SIZE).floorInt(),
|
||||||
hitbox.pointedY.div(TILE_SIZE).floorInt()
|
hitbox.pointedY.div(TILE_SIZE).floorInt()
|
||||||
) ?: Tile.STONE].isSolid) {
|
) ?: Tile.STONE].isSolid) {
|
||||||
@@ -52,7 +52,7 @@ open class ParticleBase(renderOrder: ActorOrder, maxLifeTime: Int? = null) : Run
|
|||||||
|
|
||||||
// gravity, winds, etc. (external forces)
|
// gravity, winds, etc. (external forces)
|
||||||
if (!isNoSubjectToGrav) {
|
if (!isNoSubjectToGrav) {
|
||||||
velocity += Terrarum.ingame.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
velocity += Terrarum.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ class PhysTestBall : ActorWithSprite(ActorOrder.MIDDLE, immobileBody = true) {
|
|||||||
hitbox.height.toFloat())
|
hitbox.height.toFloat())
|
||||||
|
|
||||||
g.fillOval(
|
g.fillOval(
|
||||||
hitbox.posX.toFloat() + Terrarum.ingame.world.width * TILE_SIZE,
|
hitbox.posX.toFloat() + Terrarum.ingame!!.world.width * TILE_SIZE,
|
||||||
hitbox.posY.toFloat(),
|
hitbox.posY.toFloat(),
|
||||||
hitbox.width.toFloat(),
|
hitbox.width.toFloat(),
|
||||||
hitbox.height.toFloat())
|
hitbox.height.toFloat())
|
||||||
|
|
||||||
g.fillOval(
|
g.fillOval(
|
||||||
hitbox.posX.toFloat() - Terrarum.ingame.world.width * TILE_SIZE,
|
hitbox.posX.toFloat() - Terrarum.ingame!!.world.width * TILE_SIZE,
|
||||||
hitbox.posY.toFloat(),
|
hitbox.posY.toFloat(),
|
||||||
hitbox.width.toFloat(),
|
hitbox.width.toFloat(),
|
||||||
hitbox.height.toFloat())
|
hitbox.height.toFloat())
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ object PlayerBuilder {
|
|||||||
private val jsonString = String()
|
private val jsonString = String()
|
||||||
|
|
||||||
operator fun invoke(): Actor {
|
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")
|
InjectCreatureRaw(p.actorValue, "CreatureHuman.json")
|
||||||
|
|
||||||
// attach sprite
|
// attach sprite
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ open class ProjectileSimple(
|
|||||||
lifetimeCounter += delta
|
lifetimeCounter += delta
|
||||||
if (ccdCollided || grounded || lifetimeCounter >= lifetimeMax ||
|
if (ccdCollided || grounded || lifetimeCounter >= lifetimeMax ||
|
||||||
// stuck check
|
// 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()
|
flagDespawn()
|
||||||
}
|
}
|
||||||
@@ -90,13 +90,13 @@ open class ProjectileSimple(
|
|||||||
colourTail.a = 0.16f
|
colourTail.a = 0.16f
|
||||||
|
|
||||||
// draw trail of solid colour (Terraria style maybe?)
|
// draw trail of solid colour (Terraria style maybe?)
|
||||||
g.lineWidth = 2f * Terrarum.ingame.screenZoom
|
g.lineWidth = 2f * Terrarum.ingame!!.screenZoom
|
||||||
g.drawGradientLine(
|
g.drawGradientLine(
|
||||||
hitbox.centeredX.toFloat() * Terrarum.ingame.screenZoom,
|
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||||
hitbox.centeredY.toFloat() * Terrarum.ingame.screenZoom,
|
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||||
displayColour,
|
displayColour,
|
||||||
posPre.x.toFloat() * Terrarum.ingame.screenZoom,
|
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||||
posPre.y.toFloat() * Terrarum.ingame.screenZoom,
|
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||||
colourTail
|
colourTail
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int,
|
|||||||
val gc: GameContainer, val delta: Int) : Runnable {
|
val gc: GameContainer, val delta: Int) : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
for (i in startIndex..endIndex)
|
for (i in startIndex..endIndex)
|
||||||
Terrarum.ingame.actorContainer[i].update(gc, delta)
|
Terrarum.ingame!!.actorContainer[i].update(gc, delta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,7 +239,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
|
|||||||
luatable[y - feetTilePos[1]] = LuaTable()
|
luatable[y - feetTilePos[1]] = LuaTable()
|
||||||
|
|
||||||
for (x in feetTilePos[0] - radius..feetTilePos[0] + radius) {
|
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 solidity = tile.isSolid.toInt()
|
||||||
val liquidity = tile.isFluid.toInt()
|
val liquidity = tile.isFluid.toInt()
|
||||||
val gravity = tile.isFallable.toInt()
|
val gravity = tile.isFallable.toInt()
|
||||||
@@ -283,7 +283,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
|
|||||||
// search down
|
// search down
|
||||||
var searchDownCounter = 0
|
var searchDownCounter = 0
|
||||||
while (true) {
|
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) {
|
if (TileCodex[tile].isSolid || searchDownCounter >= searchDownLimit) {
|
||||||
luatable[x - feetTilePos[0]] = searchDownCounter
|
luatable[x - feetTilePos[0]] = searchDownCounter
|
||||||
break
|
break
|
||||||
@@ -326,7 +326,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
|
|||||||
// search up
|
// search up
|
||||||
var searchUpCounter = 0
|
var searchUpCounter = 0
|
||||||
while (true) {
|
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) {
|
if (TileCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||||
break
|
break
|
||||||
@@ -368,7 +368,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithSprite) {
|
|||||||
// search up
|
// search up
|
||||||
var searchUpCounter = 0
|
var searchUpCounter = 0
|
||||||
while (true) {
|
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) {
|
if (!TileCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ object FactionFactory {
|
|||||||
val jsonObj = JsonFetcher(JSONPATH + filename)
|
val jsonObj = JsonFetcher(JSONPATH + filename)
|
||||||
val factionObj = Faction(jsonObj.get("factionname").asString)
|
val factionObj = Faction(jsonObj.get("factionname").asString)
|
||||||
|
|
||||||
jsonObj.get("factionamicable").asJsonArray.forEach { s -> factionObj.addFactionAmicable(s.asString) }
|
jsonObj.get("factionamicable").asJsonArray.forEach { factionObj.addFactionAmicable(it.asString) }
|
||||||
jsonObj.get("factionneutral").asJsonArray.forEach { s -> factionObj.addFactionNeutral(s.asString) }
|
jsonObj.get("factionneutral").asJsonArray.forEach { factionObj.addFactionNeutral(it.asString) }
|
||||||
jsonObj.get("factionhostile").asJsonArray.forEach { s -> factionObj.addFactionHostile(s.asString) }
|
jsonObj.get("factionhostile").asJsonArray.forEach { factionObj.addFactionHostile(it.asString) }
|
||||||
jsonObj.get("factionfearful").asJsonArray.forEach { s -> factionObj.addFactionFearful(s.asString) }
|
jsonObj.get("factionfearful").asJsonArray.forEach { factionObj.addFactionFearful(it.asString) }
|
||||||
|
|
||||||
return factionObj
|
return factionObj
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ object CollisionSolver {
|
|||||||
collCandidateY.clear()
|
collCandidateY.clear()
|
||||||
|
|
||||||
// mark list x
|
// mark list x
|
||||||
Terrarum.ingame.actorContainer.forEach { it ->
|
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||||
if (it is ActorWithSprite) {
|
if (it is ActorWithSprite) {
|
||||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||||
@@ -72,7 +72,7 @@ object CollisionSolver {
|
|||||||
collCandidateStack.clear()
|
collCandidateStack.clear()
|
||||||
|
|
||||||
// mark list y
|
// mark list y
|
||||||
Terrarum.ingame.actorContainer.forEach { it ->
|
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||||
if (it is ActorWithSprite) {
|
if (it is ActorWithSprite) {
|
||||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ object GameController {
|
|||||||
|
|
||||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */
|
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */
|
||||||
internal val mouseX: Float
|
internal val mouseX: Float
|
||||||
get() = (MapCamera.x + Terrarum.appgc.input.mouseX / Terrarum.ingame.screenZoom)
|
get() = (MapCamera.x + Terrarum.appgc.input.mouseX / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise)*/
|
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise)*/
|
||||||
internal val mouseY: Float
|
internal val mouseY: Float
|
||||||
get() = (MapCamera.y + Terrarum.appgc.input.mouseY / Terrarum.ingame.screenZoom)
|
get() = (MapCamera.y + Terrarum.appgc.input.mouseY / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||||
/** currently pointing tile coordinate */
|
/** currently pointing tile coordinate */
|
||||||
internal val mouseTileX: Int
|
internal val mouseTileX: Int
|
||||||
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
|
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||||
@@ -40,62 +40,68 @@ object GameController {
|
|||||||
|
|
||||||
KeyToggler.update(input)
|
KeyToggler.update(input)
|
||||||
|
|
||||||
|
if (Terrarum.ingame != null) {
|
||||||
|
val ingame = Terrarum.ingame!!
|
||||||
|
|
||||||
if (!Terrarum.ingame.consoleHandler.isTakingControl) {
|
|
||||||
if (Terrarum.ingame.player is Player && (Terrarum.ingame.player as Player).vehicleRiding != null) {
|
if (!ingame.consoleHandler.isTakingControl) {
|
||||||
(Terrarum.ingame.player as Player).vehicleRiding!!.processInput(gc, delta, input)
|
if (ingame.player is Player && (ingame.player as Player).vehicleRiding != null) {
|
||||||
|
(ingame.player as Player).vehicleRiding!!.processInput(gc, delta, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
ingame.actorContainer.forEach {
|
||||||
|
if (it is Controllable) it.processInput(gc, delta, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
ingame.uiContainer.forEach {
|
||||||
|
it.processInput(gc, delta, input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ingame.consoleHandler.processInput(gc, delta, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrarum.ingame.actorContainer.forEach {
|
|
||||||
if (it is Controllable) it.processInput(gc, delta, input)
|
|
||||||
}
|
|
||||||
|
|
||||||
Terrarum.ingame.uiContainer.forEach {
|
///////////////////
|
||||||
it.processInput(gc, delta, input)
|
// MOUSE CONTROL //
|
||||||
}
|
///////////////////
|
||||||
|
// PRIMARY/SECONDARY IS FIXED TO LEFT/RIGHT BUTTON //
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////
|
||||||
|
// GAMEPAD CONTROL //
|
||||||
|
/////////////////////
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Terrarum.ingame.consoleHandler.processInput(gc, delta, input)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////
|
|
||||||
// MOUSE CONTROL //
|
|
||||||
///////////////////
|
|
||||||
// PRIMARY/SECONDARY IS FIXED TO LEFT/RIGHT BUTTON //
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
|
||||||
// GAMEPAD CONTROL //
|
|
||||||
/////////////////////
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyPressed(key: Int, c: Char) {
|
fun keyPressed(key: Int, c: Char) {
|
||||||
if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) {
|
if (Terrarum.ingame != null) {
|
||||||
Terrarum.ingame.consoleHandler.toggleOpening()
|
val ingame = Terrarum.ingame!!
|
||||||
}
|
|
||||||
else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) {
|
|
||||||
Terrarum.ingame.debugWindow.toggleOpening()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!Terrarum.ingame.consoleHandler.isTakingControl) {
|
if (keyPressedByCode(key, EnumKeyFunc.UI_CONSOLE)) {
|
||||||
if (Terrarum.ingame.player is Player && (Terrarum.ingame.player as Player).vehicleRiding != null) {
|
ingame.consoleHandler.toggleOpening()
|
||||||
(Terrarum.ingame.player as Player).vehicleRiding!!.keyPressed(key, c)
|
}
|
||||||
|
else if (keyPressedByCode(key, EnumKeyFunc.UI_BASIC_INFO)) {
|
||||||
|
ingame.debugWindow.toggleOpening()
|
||||||
}
|
}
|
||||||
|
|
||||||
Terrarum.ingame.player.keyPressed(key, c)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Terrarum.ingame.consoleHandler.keyPressed(key, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println(String.valueOf(key) + ", " + String.valueOf(c));
|
|
||||||
|
if (!ingame.consoleHandler.isTakingControl) {
|
||||||
|
if (ingame.player is Player && (ingame.player as Player).vehicleRiding != null) {
|
||||||
|
(ingame.player as Player).vehicleRiding!!.keyPressed(key, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
ingame.player.keyPressed(key, c)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ingame.consoleHandler.keyPressed(key, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
//System.out.println(String.valueOf(key) + ", " + String.valueOf(c));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun keyReleased(key: Int, c: Char) {
|
fun keyReleased(key: Int, c: Char) {
|
||||||
@@ -113,9 +119,9 @@ object GameController {
|
|||||||
fun mousePressed(button: Int, x: Int, y: Int) {
|
fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
// bullet test
|
// bullet test
|
||||||
/*if (button == 0) {
|
/*if (button == 0) {
|
||||||
Terrarum.ingame.addActor(ProjectileSimple(
|
Terrarum.ingame!!.addActor(ProjectileSimple(
|
||||||
0,
|
0,
|
||||||
Terrarum.ingame.player.centrePosVector,
|
Terrarum.ingame!!.player.centrePosVector,
|
||||||
Vector2(mouseX.toDouble(), mouseY.toDouble())
|
Vector2(mouseX.toDouble(), mouseY.toDouble())
|
||||||
))
|
))
|
||||||
}*/
|
}*/
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ abstract class InventoryItem {
|
|||||||
|
|
||||||
abstract var baseToolSize: Double?
|
abstract var baseToolSize: Double?
|
||||||
|
|
||||||
|
abstract var category: String // "weapon", "tool", "armor", etc. (all smallcaps)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where to equip the item
|
* Where to equip the item
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +57,7 @@ abstract class InventoryItem {
|
|||||||
* For static item, it must be 1.0. If you tinkered the item to be bigger,
|
* For static item, it must be 1.0. If you tinkered the item to be bigger,
|
||||||
* it must be re-assigned as Dynamic Item
|
* it must be re-assigned as Dynamic Item
|
||||||
*/
|
*/
|
||||||
abstract var scale: Double
|
open var scale: Double = 1.0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied continuously while in pocket
|
* Effects applied continuously while in pocket
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ object WorldSimulator {
|
|||||||
val colourNone = Color(0x808080)
|
val colourNone = Color(0x808080)
|
||||||
val colourWater = Color(0x66BBFF)
|
val colourWater = Color(0x66BBFF)
|
||||||
|
|
||||||
private val world = Terrarum.ingame.world
|
private val world = Terrarum.ingame!!.world
|
||||||
|
|
||||||
// TODO future Kotlin feature -- typealias AnyPlayer: HistoricalFigure
|
// TODO future Kotlin feature -- typealias AnyPlayer: HistoricalFigure
|
||||||
operator fun invoke(p: HistoricalFigure, delta: Int) {
|
operator fun invoke(p: HistoricalFigure, delta: Int) {
|
||||||
|
|||||||
@@ -39,10 +39,9 @@ object ItemCodex {
|
|||||||
itemCodex[i] = object : InventoryItem() {
|
itemCodex[i] = object : InventoryItem() {
|
||||||
override val id: Int = i
|
override val id: Int = i
|
||||||
override var baseMass: Double = TileCodex[i].density / 1000.0
|
override var baseMass: Double = TileCodex[i].density / 1000.0
|
||||||
override var scale: Double = 1.0 // no need to set setter as scale would not change
|
|
||||||
override var baseToolSize: Double? = null
|
override var baseToolSize: Double? = null
|
||||||
override var equipPosition = EquipPosition.HAND_GRIP
|
override var equipPosition = EquipPosition.HAND_GRIP
|
||||||
|
override var category = "block"
|
||||||
|
|
||||||
override fun primaryUse(gc: GameContainer, delta: Int) {
|
override fun primaryUse(gc: GameContainer, delta: Int) {
|
||||||
// TODO base punch attack
|
// TODO base punch attack
|
||||||
@@ -51,12 +50,12 @@ object ItemCodex {
|
|||||||
override fun secondaryUse(gc: GameContainer, delta: Int) {
|
override fun secondaryUse(gc: GameContainer, delta: Int) {
|
||||||
val mousePoint = Point2d(gc.mouseTileX.toDouble(), gc.mouseTileY.toDouble())
|
val mousePoint = Point2d(gc.mouseTileX.toDouble(), gc.mouseTileY.toDouble())
|
||||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||||
Terrarum.ingame.actorContainer.forEach {
|
Terrarum.ingame!!.actorContainer.forEach {
|
||||||
if (it is ActorWithSprite && it.tilewiseHitbox.intersects(mousePoint))
|
if (it is ActorWithSprite && it.tilewiseHitbox.intersects(mousePoint))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// filter passed, do the job
|
// filter passed, do the job
|
||||||
Terrarum.ingame.world.setTileTerrain(
|
Terrarum.ingame!!.world.setTileTerrain(
|
||||||
gc.mouseTileX,
|
gc.mouseTileX,
|
||||||
gc.mouseTileY,
|
gc.mouseTileY,
|
||||||
i
|
i
|
||||||
@@ -77,7 +76,7 @@ object ItemCodex {
|
|||||||
TODO("read from dynamicitem description (JSON)")
|
TODO("read from dynamicitem description (JSON)")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val a = Terrarum.ingame.getActorByID(code) // actor item
|
val a = Terrarum.ingame!!.getActorByID(code) // actor item
|
||||||
if (a is CanBeAnItem) return a.itemData
|
if (a is CanBeAnItem) return a.itemData
|
||||||
|
|
||||||
throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)")
|
throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)")
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ object FeaturesDrawer {
|
|||||||
val colTemp_cold = colTempLinearFunc(onscreen_cold_tiles / onscreen_tiles_cap)
|
val colTemp_cold = colTempLinearFunc(onscreen_cold_tiles / onscreen_tiles_cap)
|
||||||
val colTemp_warm = colTempLinearFunc(-(onscreen_warm_tiles / onscreen_tiles_cap))
|
val colTemp_warm = colTempLinearFunc(-(onscreen_warm_tiles / onscreen_tiles_cap))
|
||||||
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
|
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
|
||||||
val zoom = Terrarum.ingame.screenZoom
|
val zoom = Terrarum.ingame!!.screenZoom
|
||||||
|
|
||||||
blendMul()
|
blendMul()
|
||||||
|
|
||||||
|
|||||||
@@ -23,21 +23,21 @@ import java.util.concurrent.locks.ReentrantLock
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
object LightmapRenderer {
|
object LightmapRenderer {
|
||||||
private val world: GameWorld = Terrarum.ingame.world
|
private val world: GameWorld = Terrarum.ingame!!.world
|
||||||
|
|
||||||
val overscan_open: Int = Math.min(32, 256f.div(TileCodex[Tile.AIR].opacity and 0xFF).ceil())
|
val overscan_open: Int = Math.min(32, 256f.div(TileCodex[Tile.AIR].opacity and 0xFF).ceil())
|
||||||
val overscan_opaque: Int = Math.min(8, 256f.div(TileCodex[Tile.STONE].opacity and 0xFF).ceil())
|
val overscan_opaque: Int = Math.min(8, 256f.div(TileCodex[Tile.STONE].opacity and 0xFF).ceil())
|
||||||
|
|
||||||
private val LIGHTMAP_WIDTH = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.WIDTH)
|
private val LIGHTMAP_WIDTH = Terrarum.ingame!!.ZOOM_MIN.inv().times(Terrarum.WIDTH)
|
||||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||||
private val LIGHTMAP_HEIGHT = Terrarum.ingame.ZOOM_MIN.inv().times(Terrarum.HEIGHT)
|
private val LIGHTMAP_HEIGHT = Terrarum.ingame!!.ZOOM_MIN.inv().times(Terrarum.HEIGHT)
|
||||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 8-Bit RGB values
|
* 8-Bit RGB values
|
||||||
*/
|
*/
|
||||||
private val lightmap: Array<IntArray> = Array(LIGHTMAP_HEIGHT) { IntArray(LIGHTMAP_WIDTH) }
|
private val lightmap: Array<IntArray> = Array(LIGHTMAP_HEIGHT) { IntArray(LIGHTMAP_WIDTH) }
|
||||||
private val lanternMap = ArrayList<Lantern>(Terrarum.ingame.ACTORCONTAINER_INITIAL_SIZE * 4)
|
private val lanternMap = ArrayList<Lantern>(Terrarum.ingame!!.ACTORCONTAINER_INITIAL_SIZE * 4)
|
||||||
|
|
||||||
private val AIR = Tile.AIR
|
private val AIR = Tile.AIR
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ object LightmapRenderer {
|
|||||||
// build noop map
|
// build noop map
|
||||||
for (i in 0..rect_size) {
|
for (i in 0..rect_size) {
|
||||||
val point = edgeToMaskNum(i)
|
val point = edgeToMaskNum(i)
|
||||||
val tile = Terrarum.ingame.world.getTileFromTerrain(point.first, point.second) ?: Tile.NULL
|
val tile = Terrarum.ingame!!.world.getTileFromTerrain(point.first, point.second) ?: Tile.NULL
|
||||||
val isSolid = TileCodex[tile].isSolid
|
val isSolid = TileCodex[tile].isSolid
|
||||||
|
|
||||||
noop_mask.set(i, isSolid)
|
noop_mask.set(i, isSolid)
|
||||||
@@ -216,7 +216,7 @@ object LightmapRenderer {
|
|||||||
|
|
||||||
private fun buildLanternmap() {
|
private fun buildLanternmap() {
|
||||||
lanternMap.clear()
|
lanternMap.clear()
|
||||||
Terrarum.ingame.actorContainer.forEach { it ->
|
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||||
if (it is Luminous && it is ActorWithSprite) {
|
if (it is Luminous && it is ActorWithSprite) {
|
||||||
// put lanterns to the area the luminantBox is occupying
|
// put lanterns to the area the luminantBox is occupying
|
||||||
for (lightBox in it.lightBoxList) {
|
for (lightBox in it.lightBoxList) {
|
||||||
@@ -246,11 +246,11 @@ object LightmapRenderer {
|
|||||||
// TODO devise multithreading on this
|
// TODO devise multithreading on this
|
||||||
|
|
||||||
var lightLevelThis: Int = 0
|
var lightLevelThis: Int = 0
|
||||||
val thisTerrain = Terrarum.ingame.world.getTileFromTerrain(x, y)
|
val thisTerrain = Terrarum.ingame!!.world.getTileFromTerrain(x, y)
|
||||||
val thisWall = Terrarum.ingame.world.getTileFromWall(x, y)
|
val thisWall = Terrarum.ingame!!.world.getTileFromWall(x, y)
|
||||||
val thisTileLuminosity = TileCodex[thisTerrain].luminosity
|
val thisTileLuminosity = TileCodex[thisTerrain].luminosity
|
||||||
val thisTileOpacity = TileCodex[thisTerrain].opacity
|
val thisTileOpacity = TileCodex[thisTerrain].opacity
|
||||||
val sunLight = Terrarum.ingame.world.globalLight
|
val sunLight = Terrarum.ingame!!.world.globalLight
|
||||||
|
|
||||||
// MIX TILE
|
// MIX TILE
|
||||||
// open air
|
// open air
|
||||||
@@ -313,8 +313,8 @@ object LightmapRenderer {
|
|||||||
while (x < this_x_end) {
|
while (x < this_x_end) {
|
||||||
// smoothing enabled and zoom is 0.75 or greater
|
// smoothing enabled and zoom is 0.75 or greater
|
||||||
// (zoom of 0.5 should not smoothed, for performance)
|
// (zoom of 0.5 should not smoothed, for performance)
|
||||||
if (Terrarum.gameConfig.getAsBoolean("smoothlighting") ?: false &&
|
if (Terrarum.getConfigBoolean("smoothlighting") ?: false &&
|
||||||
Terrarum.ingame.screenZoom >= 0.75) {
|
Terrarum.ingame!!.screenZoom >= 0.75) {
|
||||||
|
|
||||||
val thisLightLevel = getLight(x, y) ?: 0
|
val thisLightLevel = getLight(x, y) ?: 0
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
* Created by minjaesong on 2016-12-30.
|
* Created by minjaesong on 2016-12-30.
|
||||||
*/
|
*/
|
||||||
object MapCamera {
|
object MapCamera {
|
||||||
private val world: GameWorld = Terrarum.ingame.world
|
private val world: GameWorld? = Terrarum.ingame?.world
|
||||||
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||||
|
|
||||||
var x: Int = 0
|
var x: Int = 0
|
||||||
@@ -25,19 +25,22 @@ object MapCamera {
|
|||||||
get() = y + height.ushr(1)
|
get() = y + height.ushr(1)
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
val player = Terrarum.ingame.player
|
if (Terrarum.ingame != null) {
|
||||||
|
|
||||||
width = FastMath.ceil(Terrarum.WIDTH / Terrarum.ingame.screenZoom) // div, not mul
|
val player = Terrarum.ingame!!.player
|
||||||
height = FastMath.ceil(Terrarum.HEIGHT / Terrarum.ingame.screenZoom)
|
|
||||||
|
|
||||||
// position - (WH / 2)
|
width = FastMath.ceil(Terrarum.WIDTH / Terrarum.ingame!!.screenZoom) // div, not mul
|
||||||
x = Math.round(// X only: ROUNDWORLD implementation
|
height = FastMath.ceil(Terrarum.HEIGHT / Terrarum.ingame!!.screenZoom)
|
||||||
player.hitbox.centeredX.toFloat() - width / 2)
|
|
||||||
y = Math.round(FastMath.clamp(
|
|
||||||
player.hitbox.centeredY.toFloat() - height / 2,
|
|
||||||
TILE_SIZE.toFloat(),
|
|
||||||
world.height * TILE_SIZE - height - TILE_SIZE.toFloat()
|
|
||||||
))
|
|
||||||
|
|
||||||
|
// position - (WH / 2)
|
||||||
|
x = Math.round(// X only: ROUNDWORLD implementation
|
||||||
|
player.hitbox.centeredX.toFloat() - width / 2)
|
||||||
|
y = Math.round(FastMath.clamp(
|
||||||
|
player.hitbox.centeredY.toFloat() - height / 2,
|
||||||
|
TILE_SIZE.toFloat(),
|
||||||
|
world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat()
|
||||||
|
))
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ import java.util.*
|
|||||||
* Created by minjaesong on 16-01-19.
|
* Created by minjaesong on 16-01-19.
|
||||||
*/
|
*/
|
||||||
object TilesDrawer {
|
object TilesDrawer {
|
||||||
private val world: GameWorld = Terrarum.ingame.world
|
private val world: GameWorld = Terrarum.ingame!!.world
|
||||||
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||||
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ object TilesDrawer {
|
|||||||
)
|
)
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
val player = Terrarum.ingame.player
|
val player = Terrarum.ingame!!.player
|
||||||
}
|
}
|
||||||
|
|
||||||
val wallOverlayColour = Color(2f/3f, 2f/3f, 2f/3f, 1f)
|
val wallOverlayColour = Color(2f/3f, 2f/3f, 2f/3f, 1f)
|
||||||
|
|||||||
@@ -8,17 +8,17 @@ import net.torvald.terrarum.gameactors.faction.FactionCodex
|
|||||||
*/
|
*/
|
||||||
object RealEstateUtility {
|
object RealEstateUtility {
|
||||||
fun getAbsoluteTileNumber(x: Int, y: Int): Long =
|
fun getAbsoluteTileNumber(x: Int, y: Int): Long =
|
||||||
(Terrarum.ingame.world.width * y).toLong() + x
|
(Terrarum.ingame!!.world.width * y).toLong() + x
|
||||||
|
|
||||||
fun resolveAbsoluteTileNumber(t: Long): Pair<Int, Int> =
|
fun resolveAbsoluteTileNumber(t: Long): Pair<Int, Int> =
|
||||||
Pair((t % Terrarum.ingame.world.width).toInt(), (t / Terrarum.ingame.world.width).toInt())
|
Pair((t % Terrarum.ingame!!.world.width).toInt(), (t / Terrarum.ingame!!.world.width).toInt())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get owner ID as an Actor/Faction
|
* Get owner ID as an Actor/Faction
|
||||||
*/
|
*/
|
||||||
fun resolveOwner(id: Long): Any =
|
fun resolveOwner(id: Long): Any =
|
||||||
if (id < 0x80000000L)
|
if (id < 0x80000000L)
|
||||||
Terrarum.ingame.getActorByID(id.toInt())
|
Terrarum.ingame!!.getActorByID(id.toInt())
|
||||||
else
|
else
|
||||||
FactionCodex.getFactionByID(id)
|
FactionCodex.getFactionByID(id)
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ object TilePropUtil {
|
|||||||
fun getDynamicLumFunc(baseLum: Int, type: Int): Int {
|
fun getDynamicLumFunc(baseLum: Int, type: Int): Int {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
1 -> getTorchFlicker(baseLum)
|
1 -> getTorchFlicker(baseLum)
|
||||||
2 -> Terrarum.ingame.world.globalLight // current global light
|
2 -> Terrarum.ingame!!.world.globalLight // current global light
|
||||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2).toInt() // daylight at noon
|
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2).toInt() // daylight at noon
|
||||||
4 -> getSlowBreath(baseLum)
|
4 -> getSlowBreath(baseLum)
|
||||||
5 -> getPulsate(baseLum)
|
5 -> getPulsate(baseLum)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ object TileStats {
|
|||||||
|
|
||||||
// Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0
|
// Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0
|
||||||
// no matter how the screen is zoomed.
|
// no matter how the screen is zoomed.
|
||||||
val map = Terrarum.ingame.world
|
val map = Terrarum.ingame!!.world
|
||||||
val player = Terrarum.ingame.player
|
val player = Terrarum.ingame!!.player
|
||||||
|
|
||||||
val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat())
|
val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat())
|
||||||
val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat())
|
val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat())
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
val player = Terrarum.ingame.player
|
val player = Terrarum.ingame!!.player
|
||||||
val hitbox = player.hitbox
|
val hitbox = player.hitbox
|
||||||
|
|
||||||
xdelta = hitbox.pointedX - prevPlayerX
|
xdelta = hitbox.pointedX - prevPlayerX
|
||||||
@@ -59,10 +59,10 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
|
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
|
||||||
fun Int.rawB() = this % LightmapRenderer.MUL
|
fun Int.rawB() = this % LightmapRenderer.MUL
|
||||||
|
|
||||||
val player = Terrarum.ingame.player
|
val player = Terrarum.ingame!!.player
|
||||||
|
|
||||||
val mouseTileX = ((MapCamera.x + gc.input.mouseX / Terrarum.ingame.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
val mouseTileX = ((MapCamera.x + gc.input.mouseX / Terrarum.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
||||||
val mouseTileY = ((MapCamera.y + gc.input.mouseY / Terrarum.ingame.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
val mouseTileY = ((MapCamera.y + gc.input.mouseY / Terrarum.ingame!!.screenZoom) / FeaturesDrawer.TILE_SIZE).toInt()
|
||||||
|
|
||||||
g.font = Terrarum.fontSmallNumbers
|
g.font = Terrarum.fontSmallNumbers
|
||||||
g.color = GameFontBase.codeToCol["y"]
|
g.color = GameFontBase.codeToCol["y"]
|
||||||
@@ -114,7 +114,7 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
printLine(g, 8, "light@cursor $ccG$lightVal")
|
printLine(g, 8, "light@cursor $ccG$lightVal")
|
||||||
|
|
||||||
val tileNo: String
|
val tileNo: String
|
||||||
val tileNumRaw = Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
val tileNumRaw = Terrarum.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||||
val tilenum = tileNumRaw / PairedMapLayer.RANGE
|
val tilenum = tileNumRaw / PairedMapLayer.RANGE
|
||||||
val tiledmg = tileNumRaw % PairedMapLayer.RANGE
|
val tiledmg = tileNumRaw % PairedMapLayer.RANGE
|
||||||
tileNo = if (tileNumRaw == -1) "—" else "$tilenum:$tiledmg"
|
tileNo = if (tileNumRaw == -1) "—" else "$tilenum:$tiledmg"
|
||||||
@@ -127,8 +127,8 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
|
|
||||||
printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
printLineColumn(g, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
||||||
printLineColumn(g, 2, 2, "Env colour temp $ccG" + FeaturesDrawer.colTemp)
|
printLineColumn(g, 2, 2, "Env colour temp $ccG" + FeaturesDrawer.colTemp)
|
||||||
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame.world.time.elapsedSeconds}" +
|
printLineColumn(g, 2, 5, "Time $ccG${Terrarum.ingame!!.world.time.elapsedSeconds}" +
|
||||||
" (${Terrarum.ingame.world.time.getFormattedTime()})")
|
" (${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, 7, "p_WalkX $ccG${player.walkX}")
|
||||||
@@ -171,13 +171,13 @@ class BasicDebugInfoWindow : UICanvas {
|
|||||||
* Bottom left
|
* Bottom left
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g.drawString("${ccY}Actors total $ccG${Terrarum.ingame.actorContainer.size + Terrarum.ingame.actorContainerInactive.size}",
|
g.drawString("${ccY}Actors total $ccG${Terrarum.ingame!!.actorContainer.size + Terrarum.ingame!!.actorContainerInactive.size}",
|
||||||
2f, Terrarum.HEIGHT - 10f)
|
2f, Terrarum.HEIGHT - 10f)
|
||||||
g.drawString("${ccY}Active $ccG${Terrarum.ingame.actorContainer.size}",
|
g.drawString("${ccY}Active $ccG${Terrarum.ingame!!.actorContainer.size}",
|
||||||
(2 + 17*8).toFloat(), Terrarum.HEIGHT - 10f)
|
(2 + 17*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||||
g.drawString("${ccY}Dormant $ccG${Terrarum.ingame.actorContainerInactive.size}",
|
g.drawString("${ccY}Dormant $ccG${Terrarum.ingame!!.actorContainerInactive.size}",
|
||||||
(2 + 28*8).toFloat(), Terrarum.HEIGHT - 10f)
|
(2 + 28*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||||
g.drawString("${ccM}Particles $ccG${Terrarum.ingame.particlesActive}",
|
g.drawString("${ccM}Particles $ccG${Terrarum.ingame!!.particlesActive}",
|
||||||
(2 + 41*8).toFloat(), Terrarum.HEIGHT - 10f)
|
(2 + 41*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ import java.util.*
|
|||||||
* Image gallery. Images will be equally spaced, counted from top-left to bottom-right.
|
* Image gallery. Images will be equally spaced, counted from top-left to bottom-right.
|
||||||
* Created by minjaesong on 16-08-08.
|
* Created by minjaesong on 16-08-08.
|
||||||
*/
|
*/
|
||||||
class ItemImageGallery(
|
class UIItemImageGallery(
|
||||||
|
parentUI: UICanvas,
|
||||||
override var posX: Int,
|
override var posX: Int,
|
||||||
override var posY: Int,
|
override var posY: Int,
|
||||||
val width: Int,
|
override val width: Int,
|
||||||
val height: Int,
|
override val height: Int,
|
||||||
val imageList: ArrayList<Image>,
|
val imageList: ArrayList<Image>,
|
||||||
val column: Int = 1) : UIItem {
|
val column: Int = 1
|
||||||
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/net/torvald/terrarum/ui/NullUI.kt
Normal file
36
src/net/torvald/terrarum/ui/NullUI.kt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.Input
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
|
*/
|
||||||
|
class NullUI : UICanvas {
|
||||||
|
override var width: Int = 0
|
||||||
|
override var height: Int = 0
|
||||||
|
override var handler: UIHandler? = null
|
||||||
|
override var openCloseTime: Int = 0
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,24 +12,15 @@ import org.newdawn.slick.state.StateBasedGame
|
|||||||
* to the coordinate of displayed cartesian coords, and update and render the UI.
|
* to the coordinate of displayed cartesian coords, and update and render the UI.
|
||||||
* It also process game inputs and send control events to the UI so that the UI can handle them.
|
* It also process game inputs and send control events to the UI so that the UI can handle them.
|
||||||
*
|
*
|
||||||
|
* Newly created UI is invisible by default.
|
||||||
|
*
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
class UIHandler
|
class UIHandler(val UI: UICanvas) {
|
||||||
/**
|
|
||||||
* Construct new UIHandler with given UI attached.
|
|
||||||
* Invisible in default.
|
|
||||||
* @param UI
|
|
||||||
* *
|
|
||||||
* @throws SlickException
|
|
||||||
*/
|
|
||||||
@Throws(SlickException::class)
|
|
||||||
constructor(val UI: UICanvas) {
|
|
||||||
|
|
||||||
// X/Y Position to the game window.
|
// X/Y Position to the game window.
|
||||||
var posX: Int = 0
|
var posX: Int = 0
|
||||||
private set
|
|
||||||
var posY: Int = 0
|
var posY: Int = 0
|
||||||
private set
|
|
||||||
|
|
||||||
private var alwaysVisible = false
|
private var alwaysVisible = false
|
||||||
|
|
||||||
@@ -61,10 +52,11 @@ constructor(val UI: UICanvas) {
|
|||||||
var openCloseCounter: Int = 0
|
var openCloseCounter: Int = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
UI.handler = this
|
||||||
|
|
||||||
println("[UIHandler] Creating framebuffer for UI '${UI.javaClass.simpleName}'")
|
println("[UIHandler] Creating framebuffer for UI '${UI.javaClass.simpleName}'")
|
||||||
|
|
||||||
UIDrawnCanvas = Image(UI.width, UI.height)
|
UIDrawnCanvas = Image(UI.width, UI.height)
|
||||||
|
|
||||||
UIGraphicInstance = UIDrawnCanvas.graphics
|
UIGraphicInstance = UIDrawnCanvas.graphics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
src/net/torvald/terrarum/ui/UIInventory.kt
Normal file
63
src/net/torvald/terrarum/ui/UIInventory.kt
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
import org.newdawn.slick.Input
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
|
*/
|
||||||
|
class UIInventory : UICanvas {
|
||||||
|
override var width: Int
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
override var height: Int
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
override var handler: UIHandler?
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
override var openCloseTime: Int
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
|
||||||
|
|
||||||
|
private val categories = arrayOf(
|
||||||
|
"GAME_INVENTORY_WEAPONS", // weapons and tools
|
||||||
|
"CONTEXT_ITEM_EQUIPMENT_PLURAL",
|
||||||
|
"CONTEXT_ITEM_ARMOR",
|
||||||
|
"GAME_INVENTORY_INGREDIENTS",
|
||||||
|
"GAME_INVENTORY_POTIONS",
|
||||||
|
"GAME_INVENTORY_BLOCKS",
|
||||||
|
"GAME_INVENTORY_WALLPAPERS",
|
||||||
|
"MENU_LABEL_ALL"
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOpening(gc: GameContainer, delta: Int) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doClosing(gc: GameContainer, delta: Int) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endOpening(gc: GameContainer, delta: Int) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun endClosing(gc: GameContainer, delta: Int) {
|
||||||
|
TODO("not implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +1,48 @@
|
|||||||
package net.torvald.terrarum.ui
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.gameactors.roundInt
|
||||||
|
import net.torvald.terrarum.gamecontroller.mouseX
|
||||||
|
import net.torvald.terrarum.gamecontroller.mouseY
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 15-12-31.
|
* Created by minjaesong on 15-12-31.
|
||||||
*/
|
*/
|
||||||
interface UIItem {
|
abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UIHandler!
|
||||||
|
|
||||||
// X/Y Position relative to the containing canvas
|
// X/Y Position relative to the containing canvas
|
||||||
var posX: Int
|
abstract var posX: Int
|
||||||
var posY: Int
|
abstract var posY: Int
|
||||||
|
abstract val width: Int
|
||||||
|
abstract val height: Int
|
||||||
|
|
||||||
fun update(gc: GameContainer, delta: Int)
|
protected val relativeMouseX: Int
|
||||||
fun render(gc: GameContainer, g: Graphics)
|
get() = (Terrarum.appgc.mouseX - (parentUI.handler?.posX ?: 0) - this.posX).roundInt()
|
||||||
|
protected val relativeMouseY: Int
|
||||||
|
get() = (Terrarum.appgc.mouseY - (parentUI.handler?.posY ?: 0) - this.posY).roundInt()
|
||||||
|
|
||||||
|
val mouseUp: Boolean
|
||||||
|
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||||
|
val mousePushed: Boolean
|
||||||
|
get() = mouseUp && Terrarum.appgc.input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary")!!)
|
||||||
|
|
||||||
|
abstract fun update(gc: GameContainer, delta: Int)
|
||||||
|
abstract fun render(gc: GameContainer, g: Graphics)
|
||||||
|
|
||||||
// keyboard controlled
|
// keyboard controlled
|
||||||
fun keyPressed(key: Int, c: Char)
|
abstract fun keyPressed(key: Int, c: Char)
|
||||||
fun keyReleased(key: Int, c: Char)
|
abstract fun keyReleased(key: Int, c: Char)
|
||||||
|
|
||||||
// mouse controlled
|
// mouse controlled
|
||||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
abstract fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
abstract fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||||
fun mousePressed(button: Int, x: Int, y: Int)
|
abstract fun mousePressed(button: Int, x: Int, y: Int)
|
||||||
fun mouseReleased(button: Int, x: Int, y: Int)
|
abstract fun mouseReleased(button: Int, x: Int, y: Int)
|
||||||
fun mouseWheelMoved(change: Int)
|
abstract fun mouseWheelMoved(change: Int)
|
||||||
|
|
||||||
// gamepad controlled
|
// gamepad controlled
|
||||||
fun controllerButtonPressed(controller: Int, button: Int)
|
abstract fun controllerButtonPressed(controller: Int, button: Int)
|
||||||
fun controllerButtonReleased(controller: Int, button: Int)
|
abstract fun controllerButtonReleased(controller: Int, button: Int)
|
||||||
}
|
}
|
||||||
|
|||||||
82
src/net/torvald/terrarum/ui/UIItemTextButton.kt
Normal file
82
src/net/torvald/terrarum/ui/UIItemTextButton.kt
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import org.newdawn.slick.Color
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text button. Height of hitbox is extended (double lineHeight, or 40 px) for better clicking
|
||||||
|
*
|
||||||
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
|
*/
|
||||||
|
class UIItemTextButton(
|
||||||
|
parentUI: UICanvas,
|
||||||
|
val labelText: String,
|
||||||
|
override var posX: Int,
|
||||||
|
override var posY: Int,
|
||||||
|
override val width: Int,
|
||||||
|
val readFromLang: Boolean = false,
|
||||||
|
val activeCol: Color = Color.white,
|
||||||
|
val highlightCol: Color = Color(0x00f8ff),
|
||||||
|
val inactiveCol: Color = Color(0xc0c0c0)
|
||||||
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val font = Terrarum.fontGame!!
|
||||||
|
val height = font.lineHeight * 2
|
||||||
|
}
|
||||||
|
|
||||||
|
private val label: String
|
||||||
|
get() = if (readFromLang) Lang[labelText] else labelText
|
||||||
|
|
||||||
|
|
||||||
|
override val height: Int = UIItemTextButton.height
|
||||||
|
|
||||||
|
var highlighted: Boolean = false
|
||||||
|
var mouseOver = false
|
||||||
|
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
val textW = font.getWidth(label)
|
||||||
|
|
||||||
|
g.font = font
|
||||||
|
mouseOver = mouseUp
|
||||||
|
g.color = if (highlighted) highlightCol
|
||||||
|
else if (mouseOver) activeCol
|
||||||
|
else inactiveCol
|
||||||
|
|
||||||
|
g.drawString(label, posX.toFloat() + (width.minus(textW).div(2)), posY.toFloat() + height / 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyReleased(key: Int, c: Char) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseWheelMoved(change: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
|
}
|
||||||
|
}
|
||||||
83
src/net/torvald/terrarum/ui/UIItemTextButtonList.kt
Normal file
83
src/net/torvald/terrarum/ui/UIItemTextButtonList.kt
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import net.torvald.terrarum.gameactors.roundInt
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import org.newdawn.slick.GameContainer
|
||||||
|
import org.newdawn.slick.Graphics
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by SKYHi14 on 2017-03-13.
|
||||||
|
*/
|
||||||
|
class UIItemTextButtonList(
|
||||||
|
parentUI: UICanvas,
|
||||||
|
labelsList: Array<String>,
|
||||||
|
override val width: Int,
|
||||||
|
override val height: Int,
|
||||||
|
val readFromLang: Boolean = false
|
||||||
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
|
val buttons = labelsList.mapIndexed { index, s ->
|
||||||
|
val height = this.height - UIItemTextButton.height
|
||||||
|
UIItemTextButton(
|
||||||
|
parentUI, s,
|
||||||
|
0,
|
||||||
|
(height / labelsList.size.minus(1).toFloat() * index).roundInt(),
|
||||||
|
width,
|
||||||
|
readFromLang = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override var posX = 0
|
||||||
|
override var posY = 0
|
||||||
|
|
||||||
|
var selected: Int? = labelsList.size - 1 // default to "All"
|
||||||
|
|
||||||
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
|
buttons.forEachIndexed { index, btn ->
|
||||||
|
// update width because Lang is mutable (you can change language at any moment)
|
||||||
|
val textW = UIItemTextButton.font.getWidth(
|
||||||
|
if (readFromLang) Lang[btn.labelText] else btn.labelText
|
||||||
|
)
|
||||||
|
|
||||||
|
btn.update(gc, delta)
|
||||||
|
|
||||||
|
|
||||||
|
if (btn.mousePushed) {
|
||||||
|
selected = index
|
||||||
|
}
|
||||||
|
btn.highlighted = (index == selected) // forcibly highlight if this.highlighted != null
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(gc: GameContainer, g: Graphics) {
|
||||||
|
buttons.forEach { it.render(gc, g) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyPressed(key: Int, c: Char) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyReleased(key: Int, c: Char) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseWheelMoved(change: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ class UIPieMenu : UICanvas {
|
|||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
if (selection >= 0)
|
if (selection >= 0)
|
||||||
Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] =
|
Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] =
|
||||||
selection % slotCount
|
selection % slotCount
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ class UIQuickBar : UICanvas, MouseControlled {
|
|||||||
override var handler: UIHandler? = null
|
override var handler: UIHandler? = null
|
||||||
|
|
||||||
private var selection: Int
|
private var selection: Int
|
||||||
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKBARSEL) ?: 0
|
get() = Terrarum.ingame!!.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKBARSEL) ?: 0
|
||||||
set(value) { Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] = value }
|
set(value) { Terrarum.ingame!!.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] = value }
|
||||||
|
|
||||||
override fun update(gc: GameContainer, delta: Int) {
|
override fun update(gc: GameContainer, delta: Int) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.torvald.terrarum.Terrarum
|
|||||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.gameactors.floorInt
|
import net.torvald.terrarum.gameactors.floorInt
|
||||||
import net.torvald.terrarum.gameactors.roundInt
|
import net.torvald.terrarum.gameactors.roundInt
|
||||||
import net.torvald.terrarum.times
|
|
||||||
import org.newdawn.slick.Color
|
import org.newdawn.slick.Color
|
||||||
import org.newdawn.slick.GameContainer
|
import org.newdawn.slick.GameContainer
|
||||||
import org.newdawn.slick.Graphics
|
import org.newdawn.slick.Graphics
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class WorldInformationProvider(globals: Globals) {
|
|||||||
companion object {
|
companion object {
|
||||||
fun getWorldTimeInLuaFormat() : LuaTable {
|
fun getWorldTimeInLuaFormat() : LuaTable {
|
||||||
val t = LuaTable()
|
val t = LuaTable()
|
||||||
val time = if (Terrarum.gameStarted) Terrarum.ingame.world.time else WorldTime()
|
val time = if (Terrarum.gameStarted) Terrarum.ingame!!.world.time else WorldTime()
|
||||||
|
|
||||||
// int Terrarum World Time format
|
// int Terrarum World Time format
|
||||||
t["hour"] = time.hours
|
t["hour"] = time.hours
|
||||||
@@ -43,7 +43,7 @@ class WorldInformationProvider(globals: Globals) {
|
|||||||
|
|
||||||
/** evaluate single C date format */
|
/** evaluate single C date format */
|
||||||
fun String.evalAsDate(): String {
|
fun String.evalAsDate(): String {
|
||||||
val time = if (Terrarum.gameStarted) Terrarum.ingame.world.time else WorldTime()
|
val time = if (Terrarum.gameStarted) Terrarum.ingame!!.world.time else WorldTime()
|
||||||
return when (this) {
|
return when (this) {
|
||||||
"%a" -> time.getDayNameShort()
|
"%a" -> time.getDayNameShort()
|
||||||
"%A" -> time.getDayNameFull()
|
"%A" -> time.getDayNameFull()
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ object WeatherMixer {
|
|||||||
lateinit var mixedWeather: BaseModularWeather
|
lateinit var mixedWeather: BaseModularWeather
|
||||||
|
|
||||||
val globalLightNow = Color(0)
|
val globalLightNow = Color(0)
|
||||||
private val world = Terrarum.ingame.world
|
private val world = Terrarum.ingame!!.world
|
||||||
|
|
||||||
// Weather indices
|
// Weather indices
|
||||||
const val WEATHER_GENERIC = "generic"
|
const val WEATHER_GENERIC = "generic"
|
||||||
@@ -83,13 +83,13 @@ object WeatherMixer {
|
|||||||
|
|
||||||
// test rain toggled by F2
|
// test rain toggled by F2
|
||||||
if (KeyToggler.isOn(Key.F2)) {
|
if (KeyToggler.isOn(Key.F2)) {
|
||||||
val playerPos = Terrarum.ingame.player.centrePosPoint
|
val playerPos = Terrarum.ingame!!.player.centrePosPoint
|
||||||
kotlin.repeat(4) { // 4 seems good
|
kotlin.repeat(4) { // 4 seems good
|
||||||
val rainParticle = ParticleTestRain(
|
val rainParticle = ParticleTestRain(
|
||||||
playerPos.x + HQRNG().nextInt(Terrarum.WIDTH) - Terrarum.HALFW,
|
playerPos.x + HQRNG().nextInt(Terrarum.WIDTH) - Terrarum.HALFW,
|
||||||
playerPos.y - Terrarum.HALFH
|
playerPos.y - Terrarum.HALFH
|
||||||
)
|
)
|
||||||
Terrarum.ingame.addParticle(rainParticle)
|
Terrarum.ingame!!.addParticle(rainParticle)
|
||||||
}
|
}
|
||||||
globalLightNow.set(getGlobalLightOfTime(world.time.elapsedSeconds).darker(0.3f))
|
globalLightNow.set(getGlobalLightOfTime(world.time.elapsedSeconds).darker(0.3f))
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ object WeatherMixer {
|
|||||||
fun render(g: Graphics) {
|
fun render(g: Graphics) {
|
||||||
|
|
||||||
// we will not care for nextSkybox for now
|
// we will not care for nextSkybox for now
|
||||||
val timeNow = Terrarum.ingame.world.time.elapsedSeconds
|
val timeNow = Terrarum.ingame!!.world.time.elapsedSeconds
|
||||||
val skyboxColourMap = currentWeather.skyboxGradColourMap
|
val skyboxColourMap = currentWeather.skyboxGradColourMap
|
||||||
val lightColourMap = currentWeather.globalLightColourMap
|
val lightColourMap = currentWeather.globalLightColourMap
|
||||||
|
|
||||||
@@ -119,15 +119,15 @@ object WeatherMixer {
|
|||||||
val skyColourFill = GradientFill(
|
val skyColourFill = GradientFill(
|
||||||
0f, 0f,
|
0f, 0f,
|
||||||
getGradientColour(skyboxColourMap, 0, timeNow),
|
getGradientColour(skyboxColourMap, 0, timeNow),
|
||||||
0f, Terrarum.HEIGHT.toFloat(),// / Terrarum.ingame.screenZoom,
|
0f, Terrarum.HEIGHT.toFloat(),// / Terrarum.ingame!!.screenZoom,
|
||||||
getGradientColour(skyboxColourMap, 1, timeNow)
|
getGradientColour(skyboxColourMap, 1, timeNow)
|
||||||
)
|
)
|
||||||
|
|
||||||
blendNormal()
|
blendNormal()
|
||||||
g.fill(Rectangle(
|
g.fill(Rectangle(
|
||||||
0f, 0f,
|
0f, 0f,
|
||||||
Terrarum.WIDTH.toFloat(),// / Terrarum.ingame.screenZoom,
|
Terrarum.WIDTH.toFloat(),// / Terrarum.ingame!!.screenZoom,
|
||||||
Terrarum.HEIGHT.toFloat()// / Terrarum.ingame.screenZoom
|
Terrarum.HEIGHT.toFloat()// / Terrarum.ingame!!.screenZoom
|
||||||
), skyColourFill)
|
), skyColourFill)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user