gdx 1.10/lwjgl3 migration; removing old Lua stuffs

This commit is contained in:
minjaesong
2021-07-27 12:43:01 +09:00
parent f75b5da0e1
commit a91156ac21
323 changed files with 937 additions and 12100 deletions

View File

@@ -24,8 +24,8 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
*/
class BasicDebugInfoWindow : UICanvas() {
override var width: Int = AppLoader.screenW
override var height: Int = AppLoader.screenH
override var width: Int = AppLoader.screenSize.screenW
override var height: Int = AppLoader.screenSize.screenH
override var openCloseTime: Float = 0f
@@ -194,8 +194,8 @@ class BasicDebugInfoWindow : UICanvas() {
}
/*drawHistogram(batch, LightmapRenderer.histogram,
AppLoader.screenW - histogramW - TinyAlphNum.W * 2,
AppLoader.screenH - histogramH - TinyAlphNum.H * 4
AppLoader.terrarumAppConfig.screenW - histogramW - TinyAlphNum.W * 2,
AppLoader.terrarumAppConfig.screenH - histogramH - TinyAlphNum.H * 4
)*/ // histogram building is currently bugged
batch.color = Color.WHITE
@@ -205,7 +205,7 @@ class BasicDebugInfoWindow : UICanvas() {
drawGamepadAxis(gamepad, batch,
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")),
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")),
AppLoader.screenW - 128 - TinyAlphNum.W * 2,
AppLoader.screenSize.screenW - 128 - TinyAlphNum.W * 2,
line(3).toInt()
)
}
@@ -215,21 +215,21 @@ class BasicDebugInfoWindow : UICanvas() {
*/
// memory pressure
AppLoader.fontSmallNumbers.draw(batch, "${ccY}MEM ", (AppLoader.screenW - 23 * TinyAlphNum.W - 2).toFloat(), line(1))
AppLoader.fontSmallNumbers.draw(batch, "${ccY}MEM ", (AppLoader.screenSize.screenW - 23 * TinyAlphNum.W - 2).toFloat(), line(1))
// thread count
AppLoader.fontSmallNumbers.draw(batch, "${ccY}CPUs${if (AppLoader.MULTITHREAD) ccG else ccR}${AppLoader.THREAD_COUNT.toString().padStart(2, ' ')}",
(AppLoader.screenW - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
(AppLoader.screenSize.screenW - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
// memory texts
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M",
(AppLoader.screenW - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
(AppLoader.screenSize.screenW - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
AppLoader.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/",
(AppLoader.screenW - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
(AppLoader.screenSize.screenW - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
(AppLoader.screenW - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
(AppLoader.screenSize.screenW - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
// FPS count
AppLoader.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}",
(AppLoader.screenW - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
(AppLoader.screenSize.screenW - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
/**
* Bottom left
@@ -237,21 +237,21 @@ class BasicDebugInfoWindow : UICanvas() {
if (ingame != null) {
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}",
TinyAlphNum.W * 2f, AppLoader.screenH - TinyAlphNum.H * 2f)
TinyAlphNum.W * 2f, AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${ingame!!.actorContainerActive.size}",
(TinyAlphNum.W * 2 + 17 * 8).toFloat(), AppLoader.screenH - TinyAlphNum.H * 2f)
(TinyAlphNum.W * 2 + 17 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}",
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), AppLoader.screenH - TinyAlphNum.H * 2f)
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
if (ingame is TerrarumIngame) {
AppLoader.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as TerrarumIngame).particlesActive}",
(TinyAlphNum.W * 2 + 41 * 8).toFloat(), AppLoader.screenH - TinyAlphNum.H * 2f)
(TinyAlphNum.W * 2 + 41 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
}
}
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
TinyAlphNum.W * 2f, AppLoader.screenH - TinyAlphNum.H * 3f)
TinyAlphNum.W * 2f, AppLoader.screenSize.screenH - TinyAlphNum.H * 3f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}UIs rendering $ccG${IngameRenderer.renderingUIsCount}",
TinyAlphNum.W * 2f + (21 * 8), AppLoader.screenH - TinyAlphNum.H * 3f)
TinyAlphNum.W * 2f + (21 * 8), AppLoader.screenSize.screenH - TinyAlphNum.H * 3f)
/**
* Bottom right
@@ -259,7 +259,7 @@ class BasicDebugInfoWindow : UICanvas() {
// processor and renderer
AppLoader.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
(AppLoader.screenW - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), AppLoader.screenH - TinyAlphNum.H * 2f)
(AppLoader.screenSize.screenW - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
}
private val processorName = AppLoader.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (AppLoader.is32BitJVM) " (32-bit)" else ""
@@ -342,16 +342,16 @@ class BasicDebugInfoWindow : UICanvas() {
gdxSetBlendNormal()
Terrarum.inShapeRenderer {
it.color = uiColour
it.rect(uiX.toFloat(), AppLoader.screenH - uiY.toFloat(), w, -h)
it.rect(uiX.toFloat(), AppLoader.screenSize.screenH - uiY.toFloat(), w, -h)
it.color = deadzoneColour
it.rect(uiX + halfW - (halfW * deadzone), AppLoader.screenH - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone)
it.rect(uiX + halfW - (halfW * deadzone), AppLoader.screenSize.screenH - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone)
it.color = Color.WHITE
it.line(uiX + halfW, AppLoader.screenH - (uiY + halfH), uiX + halfW + pointDX, AppLoader.screenH - (uiY + halfH + pointDY))
it.line(uiX + halfW, AppLoader.screenSize.screenH - (uiY + halfH), uiX + halfW + pointDX, AppLoader.screenSize.screenH - (uiY + halfH + pointDY))
it.color = Color.GRAY
}
batch.begin()
AppLoader.fontSmallNumbers.draw(batch, gamepad.getName(), AppLoader.screenW - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
AppLoader.fontSmallNumbers.draw(batch, gamepad.getName(), AppLoader.screenSize.screenW - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
}

View File

@@ -35,7 +35,7 @@ class ConsoleWindow : UICanvas() {
private val LINE_HEIGHT = 20
private val MESSAGES_DISPLAY_COUNT = 11
override var width: Int = AppLoader.screenW
override var width: Int = AppLoader.screenSize.screenW
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
override var openCloseTime = 0f

View File

@@ -26,7 +26,7 @@ object Toolkit {
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
val imageW = image.width
val targetW = if (ui == null) AppLoader.screenW else ui.width
val targetW = if (ui == null) AppLoader.screenSize.screenW else ui.width
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
}

View File

@@ -148,7 +148,7 @@ abstract class UICanvas(
uiItems.add(uiItem)
}
fun mouseInScreen(x: Int, y: Int) = x in 0 until AppLoader.appConfig.width && y in 0 until AppLoader.appConfig.height
fun mouseInScreen(x: Int, y: Int) = x in 0 until AppLoader.screenSize.screenW && y in 0 until AppLoader.screenSize.screenH
open fun mouseMoved(screenX: Int, screenY: Int): Boolean {
if (this.isVisible) {
@@ -191,10 +191,10 @@ abstract class UICanvas(
else return false
}
/** Called by the screen's InputProcessor */
open fun scrolled(amount: Int): Boolean {
open fun scrolled(amountX: Float, amountY: Float): Boolean {
if (this.isVisible) {
uiItems.forEach { it.scrolled(amount) }
handler.subUIs.forEach { it.scrolled(amount) }
uiItems.forEach { it.scrolled(amountX, amountY) }
handler.subUIs.forEach { it.scrolled(amountX, amountY) }
return true
}
else return false
@@ -316,13 +316,13 @@ abstract class UICanvas(
).roundToInt()
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenWf,
AppLoader.screenW - ui.width.toFloat()
AppLoader.screenSize.screenWf,
AppLoader.screenSize.screenW - ui.width.toFloat()
).roundToInt()
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenHf,
AppLoader.screenH - ui.height.toFloat()
AppLoader.screenSize.screenHf,
AppLoader.screenSize.screenH - ui.height.toFloat()
).roundToInt()
}
}
@@ -340,13 +340,13 @@ abstract class UICanvas(
).roundToInt()
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenW - ui.width.toFloat(),
AppLoader.screenWf
AppLoader.screenSize.screenW - ui.width.toFloat(),
AppLoader.screenSize.screenWf
).roundToInt()
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenH - ui.height.toFloat(),
AppLoader.screenHf
AppLoader.screenSize.screenH - ui.height.toFloat(),
AppLoader.screenSize.screenHf
).roundToInt()
}
}
@@ -354,16 +354,16 @@ abstract class UICanvas(
when (position) {
Position.LEFT -> ui.handler.posX = 0
Position.TOP -> ui.handler.posY = 0
Position.RIGHT -> ui.handler.posX = AppLoader.screenW - ui.width
Position.BOTTOM -> ui.handler.posY = AppLoader.screenH - ui.height
Position.RIGHT -> ui.handler.posX = AppLoader.screenSize.screenW - ui.width
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH - ui.height
}
}
fun endClosingPopOut(ui: UICanvas, position: Position) {
when (position) {
Position.LEFT -> ui.handler.posX = -ui.width
Position.TOP -> ui.handler.posY = -ui.height
Position.RIGHT -> ui.handler.posX = AppLoader.screenW
Position.BOTTOM -> ui.handler.posY = AppLoader.screenH
Position.RIGHT -> ui.handler.posX = AppLoader.screenSize.screenW
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH
}
}

View File

@@ -386,10 +386,10 @@ void main() {
return false
}
}
fun scrolled(uiItems: List<UIItem>, amount: Int): Boolean {
fun scrolled(uiItems: List<UIItem>, amountX: Float, amountY: Float): Boolean {
if (isVisible) {
uiItems.forEach { it.scrolled(amount) }
subUIs.forEach { it.scrolled(amount) }
uiItems.forEach { it.scrolled(amountX, amountY) }
subUIs.forEach { it.scrolled(amountX, amountY) }
return true
}
else {

View File

@@ -106,11 +106,12 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
open var keyUpListener: ((Int) -> Unit)? = null
open var mouseMovedListener: ((Int, Int) -> Unit)? = null
open var touchDraggedListener: ((Int, Int, Int) -> Unit)? = null
/** Parametres: screenX, screenY, pointer, button */
/** Parameters: screenX, screenY, pointer, button */
open var touchDownListener: ((Int, Int, Int, Int) -> Unit)? = null
open var touchUpListener: ((Int, Int, Int, Int) -> Unit)? = null
open var scrolledListener: ((Int) -> Unit)? = null
/** Parametres: relative mouseX, relative mouseY, button */
/** Parameters: amountX, amountY */
open var scrolledListener: ((Float, Float) -> Unit)? = null
/** Parameters: relative mouseX, relative mouseY, button */
open var clickOnceListener: ((Int, Int, Int) -> Unit)? = null
open var clickOnceListenerFired = false
@@ -219,9 +220,9 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
return false
}
open fun scrolled(amount: Int): Boolean {
open fun scrolled(amountX: Float, amountY: Float): Boolean {
if (parentUI.isVisible && scrolledListener != null) {
scrolledListener!!.invoke(amount)
scrolledListener!!.invoke(amountX, amountY)
return true
}

View File

@@ -76,22 +76,6 @@ open class UIItemImageButton(
image.texture.dispose()
}
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 {
if (mouseUp && highlightable) {
highlighted = !highlighted
@@ -99,12 +83,4 @@ open class UIItemImageButton(
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)
}
}

View File

@@ -67,7 +67,7 @@ class UIItemImageGallery(
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun scrolled(amount: Int): Boolean {
override fun scrolled(amountX: Float, amountY: Float): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

View File

@@ -115,7 +115,7 @@ class UIItemIntSlider(
override var touchUpListener: ((Int, Int, Int, Int) -> Unit)?
get() = super.touchUpListener
set(value) {}
override var scrolledListener: ((Int) -> Unit)?
override var scrolledListener: ((Float, Float) -> Unit)?
get() = super.scrolledListener
set(value) {}
override var clickOnceListener: ((Int, Int, Int) -> Unit)?
@@ -128,42 +128,6 @@ class UIItemIntSlider(
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.
}

View File

@@ -46,36 +46,12 @@ class UIItemTextArea(
}
}
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 {
scrollPos += amount * 3
override fun scrolled(amountX: Float, amountY: Float): Boolean {
scrollPos += Math.round(amountX * 3)
if (scrollPos > entireText.size - lineCount) scrollPos = entireText.size - lineCount
if (scrollPos < 0) scrollPos = 0
return super.scrolled(amount)
return super.scrolled(amountX, amountY)
}
override fun dispose() {

View File

@@ -111,32 +111,4 @@ open class UIItemTextButton(
override fun dispose() {
}
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)
}
}

View File

@@ -273,7 +273,7 @@ class UIItemTextButtonList(
return super.touchUp(screenX, screenY, pointer, button) || buttons.map { it.touchUp(screenX, screenY, pointer, button).toInt() }.sum() != 0
}
override fun scrolled(amount: Int): Boolean {
return super.scrolled(amount) || buttons.map { it.scrolled(amount).toInt() }.sum() != 0
override fun scrolled(amountX: Float, amountY: Float): Boolean {
return super.scrolled(amountX, amountY) || buttons.map { it.scrolled(amountX, amountY).toInt() }.sum() != 0
}
}

View File

@@ -116,8 +116,8 @@ open class UIItemTransitionContainer(
return true
}
override fun scrolled(amount: Int): Boolean {
uis.forEachIndexed { index, ui -> if (timeToUpdate(index)) ui.scrolled(amount) }
override fun scrolled(amountX: Float, amountY: Float): Boolean {
uis.forEachIndexed { index, ui -> if (timeToUpdate(index)) ui.scrolled(amountX, amountY) }
return true
}

View File

@@ -236,26 +236,6 @@ class UINSMenu(
return true
}
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 keyDown(keycode: Int): Boolean {
return super.keyDown(keycode)
}
override fun keyUp(keycode: Int): Boolean {
return super.keyUp(keycode)
}
override fun keyTyped(character: Char): Boolean {
return super.keyTyped(character)
}
override fun resize(width: Int, height: Int) {
}
}