mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
layer seems load, need to write better test-able code
This commit is contained in:
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.console
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.console.ConsoleCommand
|
import net.torvald.terrarum.console.ConsoleCommand
|
||||||
import net.torvald.terrarum.console.Echo
|
import net.torvald.terrarum.console.Echo
|
||||||
|
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
@@ -27,6 +28,9 @@ object ImportLayerData : ConsoleCommand {
|
|||||||
(Terrarum.ingame!!.world).spawnY * FeaturesDrawer.TILE_SIZE.toDouble(),
|
(Terrarum.ingame!!.world).spawnY * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||||
(Terrarum.ingame!!.world).spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
(Terrarum.ingame!!.world).spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IngameRenderer.
|
||||||
|
|
||||||
Echo("Successfully loaded ${args[1]}")
|
Echo("Successfully loaded ${args[1]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -137,12 +137,12 @@ internal object ReadLayerDataZip {
|
|||||||
|
|
||||||
// just in case
|
// just in case
|
||||||
if (uncompLen.toLong() != u.uncompressedSize)
|
if (uncompLen.toLong() != u.uncompressedSize)
|
||||||
throw InternalError("DEFLATE size mismatch -- expected ${u.uncompressedSize}, got $uncompLen")
|
throw InternalError("Payload $t DEFLATE size mismatch -- expected ${u.uncompressedSize}, got $uncompLen")
|
||||||
|
|
||||||
// deal with (MSB ++ LSB)
|
// deal with (MSB ++ LSB)
|
||||||
if (t == "TERR" || t == "WALL") {
|
if (t == "TERR" || t == "WALL") {
|
||||||
payloadBytes["${t}_MSB"] = inflatedFile.sliceArray(0 until worldSize.toInt()) // FIXME deflated stream cannot be larger than 2 GB
|
payloadBytes["${t}_MSB"] = inflatedFile.sliceArray(0 until worldSize.toInt()) // FIXME deflated stream cannot be larger than 2 GB
|
||||||
payloadBytes["${t}_LSb"] = inflatedFile.sliceArray(worldSize.toInt() until inflatedFile.size) // FIXME deflated stream cannot be larger than 2 GB
|
payloadBytes["${t}_LSB"] = inflatedFile.sliceArray(worldSize.toInt() until uncompLen) // FIXME deflated stream cannot be larger than 2 GB
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
payloadBytes[t] = inflatedFile
|
payloadBytes[t] = inflatedFile
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ internal object WriteLayerDataZip {
|
|||||||
// FIXME output seems legit, but I can't confirm right now !!
|
// FIXME output seems legit, but I can't confirm right now !!
|
||||||
|
|
||||||
|
|
||||||
// 2400x800 world sizes about 90 kB
|
// 2400x800 world size, default comp level: about 90 kB
|
||||||
// 8192x2048 world sizes about 670 kB
|
// 8192x2048 world size, default comp level: about 670 kB
|
||||||
|
|
||||||
|
// 2400x800 world size, best comp level: about 75 kB
|
||||||
|
// 8192x2048 world size, best comp level: about 555 kB
|
||||||
|
|
||||||
val LAYERS_FILENAME = "world"
|
val LAYERS_FILENAME = "world"
|
||||||
|
|
||||||
@@ -105,7 +108,7 @@ internal object WriteLayerDataZip {
|
|||||||
|
|
||||||
wb(PAYLOAD_HEADER); wb("TERR".toByteArray())
|
wb(PAYLOAD_HEADER); wb("TERR".toByteArray())
|
||||||
wi48(world.width * world.height * 3L / 2)
|
wi48(world.width * world.height * 3L / 2)
|
||||||
deflater = DeflaterOutputStream(outputStream, true)
|
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
|
||||||
deflater.write(world.terrainArray)
|
deflater.write(world.terrainArray)
|
||||||
deflater.write(world.layerTerrainLowBits.data)
|
deflater.write(world.layerTerrainLowBits.data)
|
||||||
deflater.finish()
|
deflater.finish()
|
||||||
@@ -114,7 +117,7 @@ internal object WriteLayerDataZip {
|
|||||||
// WALL payload
|
// WALL payload
|
||||||
wb(PAYLOAD_HEADER); wb("WALL".toByteArray())
|
wb(PAYLOAD_HEADER); wb("WALL".toByteArray())
|
||||||
wi48(world.width * world.height * 3L / 2)
|
wi48(world.width * world.height * 3L / 2)
|
||||||
deflater = DeflaterOutputStream(outputStream, true)
|
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
|
||||||
deflater.write(world.wallArray)
|
deflater.write(world.wallArray)
|
||||||
deflater.write(world.layerWallLowBits.data)
|
deflater.write(world.layerWallLowBits.data)
|
||||||
deflater.finish()
|
deflater.finish()
|
||||||
@@ -123,7 +126,7 @@ internal object WriteLayerDataZip {
|
|||||||
// WIRE payload
|
// WIRE payload
|
||||||
wb(PAYLOAD_HEADER); wb("WIRE".toByteArray())
|
wb(PAYLOAD_HEADER); wb("WIRE".toByteArray())
|
||||||
wi48(world.width * world.height.toLong())
|
wi48(world.width * world.height.toLong())
|
||||||
deflater = DeflaterOutputStream(outputStream, true)
|
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
|
||||||
deflater.write(world.wireArray)
|
deflater.write(world.wireArray)
|
||||||
deflater.finish()
|
deflater.finish()
|
||||||
wb(PAYLOAD_FOOTER)
|
wb(PAYLOAD_FOOTER)
|
||||||
@@ -132,7 +135,7 @@ internal object WriteLayerDataZip {
|
|||||||
wb(PAYLOAD_HEADER); wb("TdMG".toByteArray())
|
wb(PAYLOAD_HEADER); wb("TdMG".toByteArray())
|
||||||
wi48(world.terrainDamages.size.toLong())
|
wi48(world.terrainDamages.size.toLong())
|
||||||
|
|
||||||
deflater = DeflaterOutputStream(outputStream, true)
|
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
|
||||||
|
|
||||||
world.terrainDamages.forEach { t, u ->
|
world.terrainDamages.forEach { t, u ->
|
||||||
deflater.write(t.toLittle48())
|
deflater.write(t.toLittle48())
|
||||||
@@ -146,7 +149,7 @@ internal object WriteLayerDataZip {
|
|||||||
wb(PAYLOAD_HEADER); wb("WdMG".toByteArray())
|
wb(PAYLOAD_HEADER); wb("WdMG".toByteArray())
|
||||||
wi48(world.wallDamages.size.toLong())
|
wi48(world.wallDamages.size.toLong())
|
||||||
|
|
||||||
deflater = DeflaterOutputStream(outputStream, true)
|
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION), true)
|
||||||
|
|
||||||
world.wallDamages.forEach { t, u ->
|
world.wallDamages.forEach { t, u ->
|
||||||
deflater.write(t.toLittle48())
|
deflater.write(t.toLittle48())
|
||||||
|
|||||||
154
src/net/torvald/terrarum/ui/UIItemIntSlider.kt
Normal file
154
src/net/torvald/terrarum/ui/UIItemIntSlider.kt
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
package net.torvald.terrarum.ui
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.BlendMode
|
||||||
|
import java.awt.Color
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2018-10-02.
|
||||||
|
*/
|
||||||
|
class UIItemIntSlider(
|
||||||
|
parent: UICanvas,
|
||||||
|
initValue: Int,
|
||||||
|
override val width: Int,
|
||||||
|
override val height: Int,
|
||||||
|
val minValue: Int,
|
||||||
|
val maxValue: Int,
|
||||||
|
val step: Int,
|
||||||
|
/** Show prev- and next values (if any) */
|
||||||
|
var showNotches: Boolean,
|
||||||
|
var showMinMaxValues: Boolean,
|
||||||
|
val isVertical: Boolean,
|
||||||
|
val meterStyle: Int,
|
||||||
|
|
||||||
|
val sliderCol: Color,
|
||||||
|
val sliderBlend: BlendMode,
|
||||||
|
|
||||||
|
val notchCol: Color,
|
||||||
|
val barCol: Color,
|
||||||
|
val barAndNotchBlend: BlendMode
|
||||||
|
|
||||||
|
) : UIItem(parent) {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
parent: UICanvas,
|
||||||
|
initValue: Int,
|
||||||
|
values: IntRange,
|
||||||
|
width: Int,
|
||||||
|
height: Int,
|
||||||
|
showNotches: Boolean,
|
||||||
|
showMinMaxValues: Boolean,
|
||||||
|
isVertical: Boolean,
|
||||||
|
meterStyle: Int,
|
||||||
|
|
||||||
|
sliderCol: Color,
|
||||||
|
sliderBlend: BlendMode,
|
||||||
|
|
||||||
|
notchCol: Color,
|
||||||
|
barCol: Color,
|
||||||
|
barAndNotchBlend: BlendMode
|
||||||
|
) : this(
|
||||||
|
parent,
|
||||||
|
initValue,
|
||||||
|
values.first,
|
||||||
|
values.last,
|
||||||
|
values.step,
|
||||||
|
width, height, showNotches, showMinMaxValues, isVertical, meterStyle, sliderCol, sliderBlend, notchCol, barCol, barAndNotchBlend
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
var value = initValue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// TODO unimplemented
|
||||||
|
|
||||||
|
|
||||||
|
override var posX: Int
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
override var posY: Int
|
||||||
|
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||||
|
set(value) {}
|
||||||
|
override val mouseUp: Boolean
|
||||||
|
get() = super.mouseUp
|
||||||
|
override val mousePushed: Boolean
|
||||||
|
get() = super.mousePushed
|
||||||
|
override val mouseOverCall: UICanvas?
|
||||||
|
get() = super.mouseOverCall
|
||||||
|
override var updateListener: ((Float) -> Unit)?
|
||||||
|
get() = super.updateListener
|
||||||
|
set(value) {}
|
||||||
|
override var keyDownListener: ((Int) -> Unit)?
|
||||||
|
get() = super.keyDownListener
|
||||||
|
set(value) {}
|
||||||
|
override var keyUpListener: ((Int) -> Unit)?
|
||||||
|
get() = super.keyUpListener
|
||||||
|
set(value) {}
|
||||||
|
override var mouseMovedListener: ((Int, Int) -> Unit)?
|
||||||
|
get() = super.mouseMovedListener
|
||||||
|
set(value) {}
|
||||||
|
override var touchDraggedListener: ((Int, Int, Int) -> Unit)?
|
||||||
|
get() = super.touchDraggedListener
|
||||||
|
set(value) {}
|
||||||
|
override var touchDownListener: ((Int, Int, Int, Int) -> Unit)?
|
||||||
|
get() = super.touchDownListener
|
||||||
|
set(value) {}
|
||||||
|
override var touchUpListener: ((Int, Int, Int, Int) -> Unit)?
|
||||||
|
get() = super.touchUpListener
|
||||||
|
set(value) {}
|
||||||
|
override var scrolledListener: ((Int) -> Unit)?
|
||||||
|
get() = super.scrolledListener
|
||||||
|
set(value) {}
|
||||||
|
override var clickOnceListener: ((Int, Int, Int) -> Unit)?
|
||||||
|
get() = super.clickOnceListener
|
||||||
|
set(value) {}
|
||||||
|
override var clickOnceListenerFired: Boolean
|
||||||
|
get() = super.clickOnceListenerFired
|
||||||
|
set(value) {}
|
||||||
|
override var controllerInFocus: Boolean
|
||||||
|
get() = super.controllerInFocus
|
||||||
|
set(value) {}
|
||||||
|
|
||||||
|
override fun update(delta: Float) {
|
||||||
|
super.update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
|
super.render(batch, camera)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
|
return super.keyDown(keycode)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun keyUp(keycode: Int): Boolean {
|
||||||
|
return super.keyUp(keycode)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
||||||
|
return super.mouseMoved(screenX, screenY)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||||
|
return super.touchDragged(screenX, screenY, pointer)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
|
return super.touchDown(screenX, screenY, pointer, button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||||
|
return super.touchUp(screenX, screenY, pointer, button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun scrolled(amount: Int): Boolean {
|
||||||
|
return super.scrolled(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user