mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
Renamed AppLoader into App
This commit is contained in:
@@ -16,7 +16,6 @@ import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
@@ -25,8 +24,8 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
*/
|
||||
class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
override var width: Int = AppLoader.screenSize.screenW
|
||||
override var height: Int = AppLoader.screenSize.screenH
|
||||
override var width: Int = App.scr.width
|
||||
override var height: Int = App.scr.height
|
||||
|
||||
override var openCloseTime: Float = 0f
|
||||
|
||||
@@ -78,7 +77,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
val hitbox = player?.hitbox
|
||||
|
||||
val updateCount = maxOf(1L, (AppLoader.debugTimers["Ingame.UpdateCounter"] ?: 1L) as Long)
|
||||
val updateCount = maxOf(1L, (App.debugTimers["Ingame.UpdateCounter"] ?: 1L) as Long)
|
||||
|
||||
/**
|
||||
* First column
|
||||
@@ -172,7 +171,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
|
||||
// print time
|
||||
var dbgCnt = 12
|
||||
AppLoader.debugTimers.forEach { t, u ->
|
||||
App.debugTimers.forEach { t, u ->
|
||||
printLine(batch, dbgCnt, "$ccM$t $ccG${formatNanoTime(u as? Long)}$ccY ns")
|
||||
dbgCnt++
|
||||
}
|
||||
@@ -206,9 +205,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad
|
||||
if (gamepad != null) {
|
||||
drawGamepadAxis(gamepad, batch,
|
||||
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")),
|
||||
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")),
|
||||
AppLoader.screenSize.screenW - 128 - TinyAlphNum.W * 2,
|
||||
gamepad.getAxis(App.getConfigInt("config_gamepadaxislx")),
|
||||
gamepad.getAxis(App.getConfigInt("config_gamepadaxisly")),
|
||||
App.scr.width - 128 - TinyAlphNum.W * 2,
|
||||
line(3).toInt()
|
||||
)
|
||||
}
|
||||
@@ -218,68 +217,68 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
*/
|
||||
|
||||
// memory pressure
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccY}MEM ", (AppLoader.screenSize.screenW - 23 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}MEM ", (App.scr.width - 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.screenSize.screenW - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}CPUs${if (App.MULTITHREAD) ccG else ccR}${App.THREAD_COUNT.toString().padStart(2, ' ')}",
|
||||
(App.scr.width - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
|
||||
|
||||
// memory texts
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M",
|
||||
(AppLoader.screenSize.screenW - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
AppLoader.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/",
|
||||
(AppLoader.screenSize.screenW - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
|
||||
(AppLoader.screenSize.screenW - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
App.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M",
|
||||
(App.scr.width - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
App.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/",
|
||||
(App.scr.width - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
App.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
|
||||
(App.scr.width - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
// FPS count
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}",
|
||||
(AppLoader.screenSize.screenW - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}",
|
||||
(App.scr.width - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
|
||||
// global render counter
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccO}${AppLoader.GLOBAL_RENDER_TIMER.toString().padStart(10, ' ')}",
|
||||
(AppLoader.screenSize.screenW - 35 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
App.fontSmallNumbers.draw(batch, "${ccO}${App.GLOBAL_RENDER_TIMER.toString().padStart(10, ' ')}",
|
||||
(App.scr.width - 35 * TinyAlphNum.W - 2).toFloat(), line(1))
|
||||
|
||||
/**
|
||||
* Bottom left
|
||||
*/
|
||||
|
||||
if (ingame != null) {
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}",
|
||||
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.screenSize.screenH - TinyAlphNum.H * 2f)
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}",
|
||||
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}",
|
||||
TinyAlphNum.W * 2f, App.scr.height - TinyAlphNum.H * 2f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${ingame!!.actorContainerActive.size}",
|
||||
(TinyAlphNum.W * 2 + 17 * 8).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}",
|
||||
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), App.scr.height - 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.screenSize.screenH - TinyAlphNum.H * 2f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as TerrarumIngame).particlesActive}",
|
||||
(TinyAlphNum.W * 2 + 41 * 8).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
|
||||
}
|
||||
}
|
||||
|
||||
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
|
||||
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.screenSize.screenH - TinyAlphNum.H * 3f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
|
||||
TinyAlphNum.W * 2f, App.scr.height - TinyAlphNum.H * 3f)
|
||||
App.fontSmallNumbers.draw(batch, "${ccY}UIs rendering $ccG${IngameRenderer.renderingUIsCount}",
|
||||
TinyAlphNum.W * 2f + (21 * 8), App.scr.height - TinyAlphNum.H * 3f)
|
||||
|
||||
/**
|
||||
* Bottom right
|
||||
*/
|
||||
|
||||
// processor and renderer
|
||||
AppLoader.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
|
||||
(AppLoader.screenSize.screenW - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f)
|
||||
App.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
|
||||
(App.scr.width - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
|
||||
}
|
||||
|
||||
private val processorName = AppLoader.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (AppLoader.is32BitJVM) " (32-bit)" else ""
|
||||
private val rendererName = AppLoader.renderer
|
||||
private val processorName = App.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (App.is32BitJVM) " (32-bit)" else ""
|
||||
private val rendererName = App.renderer
|
||||
private val totalHardwareName = "$processorName $rendererName"
|
||||
|
||||
private fun printLine(batch: SpriteBatch, l: Int, s: String) {
|
||||
AppLoader.fontSmallNumbers.draw(batch,
|
||||
App.fontSmallNumbers.draw(batch,
|
||||
s, TinyAlphNum.W * 2f, line(l)
|
||||
)
|
||||
}
|
||||
|
||||
private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) {
|
||||
AppLoader.fontSmallNumbers.draw(batch,
|
||||
App.fontSmallNumbers.draw(batch,
|
||||
s, (TinyAlphNum.W * 2f + column(col)), line(row)
|
||||
)
|
||||
}
|
||||
@@ -303,9 +302,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
batch.color = uiColour
|
||||
batch.fillRect(x.toFloat(), y.toFloat(), w.plus(1), h)
|
||||
batch.color = Color.GRAY
|
||||
AppLoader.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
AppLoader.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
||||
AppLoader.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
App.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
App.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
||||
App.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
|
||||
blendScreen(batch)
|
||||
for (c in 0..3) {
|
||||
@@ -340,7 +339,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
val pointDX = axisX * halfW
|
||||
val pointDY = -axisY * halfH
|
||||
|
||||
val deadzone = AppLoader.gamepadDeadzone
|
||||
val deadzone = App.gamepadDeadzone
|
||||
|
||||
blendNormal(batch)
|
||||
|
||||
@@ -348,16 +347,16 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
gdxSetBlendNormal()
|
||||
Terrarum.inShapeRenderer {
|
||||
it.color = uiColour
|
||||
it.rect(uiX.toFloat(), AppLoader.screenSize.screenH - uiY.toFloat(), w, -h)
|
||||
it.rect(uiX.toFloat(), App.scr.height - uiY.toFloat(), w, -h)
|
||||
it.color = deadzoneColour
|
||||
it.rect(uiX + halfW - (halfW * deadzone), AppLoader.screenSize.screenH - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone)
|
||||
it.rect(uiX + halfW - (halfW * deadzone), App.scr.height - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone)
|
||||
it.color = Color.WHITE
|
||||
it.line(uiX + halfW, AppLoader.screenSize.screenH - (uiY + halfH), uiX + halfW + pointDX, AppLoader.screenSize.screenH - (uiY + halfH + pointDY))
|
||||
it.line(uiX + halfW, App.scr.height - (uiY + halfH), uiX + halfW + pointDX, App.scr.height - (uiY + halfH + pointDY))
|
||||
it.color = Color.GRAY
|
||||
}
|
||||
batch.begin()
|
||||
|
||||
AppLoader.fontSmallNumbers.draw(batch, gamepad.getName(), AppLoader.screenSize.screenW - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
|
||||
App.fontSmallNumbers.draw(batch, gamepad.getName(), App.scr.width - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConsoleWindow : UICanvas() {
|
||||
private val LINE_HEIGHT = 20
|
||||
private val MESSAGES_DISPLAY_COUNT = 11
|
||||
|
||||
override var width: Int = AppLoader.screenSize.screenW
|
||||
override var width: Int = App.scr.width
|
||||
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
|
||||
|
||||
override var openCloseTime = 0f
|
||||
@@ -78,12 +78,12 @@ class ConsoleWindow : UICanvas() {
|
||||
batch.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat())
|
||||
|
||||
val input = commandInputPool!!.toString()
|
||||
val inputDrawWidth = AppLoader.fontGame.getWidth(input)
|
||||
val inputDrawHeight = AppLoader.fontGame.lineHeight
|
||||
val inputDrawWidth = App.fontGame.getWidth(input)
|
||||
val inputDrawHeight = App.fontGame.lineHeight
|
||||
|
||||
// text and cursor
|
||||
batch.color = Color.WHITE
|
||||
AppLoader.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
App.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
|
||||
batch.color = Color(0x7f7f7f_ff)
|
||||
batch.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight)
|
||||
@@ -94,7 +94,7 @@ class ConsoleWindow : UICanvas() {
|
||||
// messages
|
||||
for (i in 0..MESSAGES_DISPLAY_COUNT - 1) {
|
||||
val message = messages[messageDisplayPos + i]
|
||||
AppLoader.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
App.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ class ConsoleWindow : UICanvas() {
|
||||
commandInputPool = StringBuilder()
|
||||
|
||||
if (Authenticator.b()) {
|
||||
sendMessage("$ccE${TerrarumAppConfiguration.GAME_NAME} ${AppLoader.getVERSION_STRING()} $EMDASH ${TerrarumAppConfiguration.COPYRIGHT_DATE_NAME}")
|
||||
sendMessage("$ccE${TerrarumAppConfiguration.GAME_NAME} ${App.getVERSION_STRING()} $EMDASH ${TerrarumAppConfiguration.COPYRIGHT_DATE_NAME}")
|
||||
sendMessage("$ccE${TerrarumAppConfiguration.COPYRIGHT_LICENSE}")
|
||||
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -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.screenSize.screenW else ui.width
|
||||
val targetW = if (ui == null) App.scr.width else ui.width
|
||||
|
||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import kotlin.math.roundToInt
|
||||
@@ -86,7 +86,7 @@ abstract class UICanvas(
|
||||
get() = _mouseUpThis || handler.mouseUp
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))
|
||||
|
||||
private val _mouseUpThis: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
@@ -148,7 +148,7 @@ abstract class UICanvas(
|
||||
uiItems.add(uiItem)
|
||||
}
|
||||
|
||||
fun mouseInScreen(x: Int, y: Int) = x in 0 until AppLoader.screenSize.screenW && y in 0 until AppLoader.screenSize.screenH
|
||||
fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.width && y in 0 until App.scr.height
|
||||
|
||||
/**
|
||||
* Called by the screen's InputProcessor
|
||||
@@ -307,13 +307,13 @@ abstract class UICanvas(
|
||||
).roundToInt()
|
||||
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
|
||||
ui.handler.openCloseCounter / openCloseTime,
|
||||
AppLoader.screenSize.screenWf,
|
||||
AppLoader.screenSize.screenW - ui.width.toFloat()
|
||||
App.scr.wf,
|
||||
App.scr.width - ui.width.toFloat()
|
||||
).roundToInt()
|
||||
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
|
||||
ui.handler.openCloseCounter / openCloseTime,
|
||||
AppLoader.screenSize.screenHf,
|
||||
AppLoader.screenSize.screenH - ui.height.toFloat()
|
||||
App.scr.hf,
|
||||
App.scr.height - ui.height.toFloat()
|
||||
).roundToInt()
|
||||
}
|
||||
}
|
||||
@@ -331,13 +331,13 @@ abstract class UICanvas(
|
||||
).roundToInt()
|
||||
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
|
||||
ui.handler.openCloseCounter / openCloseTime,
|
||||
AppLoader.screenSize.screenW - ui.width.toFloat(),
|
||||
AppLoader.screenSize.screenWf
|
||||
App.scr.width - ui.width.toFloat(),
|
||||
App.scr.wf
|
||||
).roundToInt()
|
||||
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
|
||||
ui.handler.openCloseCounter / openCloseTime,
|
||||
AppLoader.screenSize.screenH - ui.height.toFloat(),
|
||||
AppLoader.screenSize.screenHf
|
||||
App.scr.height - ui.height.toFloat(),
|
||||
App.scr.hf
|
||||
).roundToInt()
|
||||
}
|
||||
}
|
||||
@@ -345,16 +345,16 @@ abstract class UICanvas(
|
||||
when (position) {
|
||||
Position.LEFT -> ui.handler.posX = 0
|
||||
Position.TOP -> ui.handler.posY = 0
|
||||
Position.RIGHT -> ui.handler.posX = AppLoader.screenSize.screenW - ui.width
|
||||
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH - ui.height
|
||||
Position.RIGHT -> ui.handler.posX = App.scr.width - ui.width
|
||||
Position.BOTTOM -> ui.handler.posY = App.scr.height - 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.screenSize.screenW
|
||||
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH
|
||||
Position.RIGHT -> ui.handler.posX = App.scr.width
|
||||
Position.BOTTOM -> ui.handler.posY = App.scr.height
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
@@ -115,7 +115,7 @@ void main() {
|
||||
|
||||
var openCloseCounter = 0f
|
||||
|
||||
private val shader = AppLoader.loadShaderInline(SHADER_PROG_VERT, SHADER_PROG_FRAG)
|
||||
private val shader = App.loadShaderInline(SHADER_PROG_VERT, SHADER_PROG_FRAG)
|
||||
|
||||
init {
|
||||
//UI.handler = this
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
open val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))
|
||||
|
||||
|
||||
/** UI to call (show up) while mouse is up */
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.floor
|
||||
@@ -16,9 +16,9 @@ class UIItemModuleInfoCell(
|
||||
initialY: Int
|
||||
) : UIItem(parent, initialX, initialY) {
|
||||
|
||||
override val height: Int = AppLoader.fontGame.lineHeight.toInt() * 2
|
||||
override val height: Int = App.fontGame.lineHeight.toInt() * 2
|
||||
|
||||
private val numberAreaWidth = AppLoader.fontSmallNumbers.W * 3 + 4
|
||||
private val numberAreaWidth = App.fontSmallNumbers.W * 3 + 4
|
||||
|
||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||
blendNormal(batch)
|
||||
@@ -28,53 +28,53 @@ class UIItemModuleInfoCell(
|
||||
|
||||
// print load order index
|
||||
batch.color = Color(0xccccccff.toInt())
|
||||
var strlen = AppLoader.fontSmallNumbers.getWidth(modInfo.order.toString())
|
||||
AppLoader.fontSmallNumbers.draw(batch,
|
||||
var strlen = App.fontSmallNumbers.getWidth(modInfo.order.toString())
|
||||
App.fontSmallNumbers.draw(batch,
|
||||
modInfo.order.toString(),
|
||||
posX + (numberAreaWidth - strlen).div(2f).floor(),
|
||||
posY + (height - AppLoader.fontSmallNumbers.H).div(2f).floor()
|
||||
posY + (height - App.fontSmallNumbers.H).div(2f).floor()
|
||||
)
|
||||
|
||||
// print module name
|
||||
batch.color = Color.WHITE
|
||||
AppLoader.fontGame.draw(batch,
|
||||
App.fontGame.draw(batch,
|
||||
"${modInfo.properName} (${modInfo.version})",
|
||||
posX + numberAreaWidth.toFloat(),
|
||||
posY.toFloat()
|
||||
)
|
||||
|
||||
// print author name
|
||||
strlen = AppLoader.fontGame.getWidth(modInfo.author)
|
||||
AppLoader.fontGame.draw(batch,
|
||||
strlen = App.fontGame.getWidth(modInfo.author)
|
||||
App.fontGame.draw(batch,
|
||||
modInfo.author,
|
||||
posX + width - strlen.toFloat(),
|
||||
posY.toFloat()
|
||||
)
|
||||
|
||||
// print description
|
||||
AppLoader.fontGame.draw(batch,
|
||||
App.fontGame.draw(batch,
|
||||
modInfo.description,
|
||||
posX + numberAreaWidth.toFloat(),
|
||||
posY + AppLoader.fontGame.lineHeight
|
||||
posY + App.fontGame.lineHeight
|
||||
)
|
||||
|
||||
// print releasedate
|
||||
strlen = AppLoader.fontGame.getWidth(modInfo.releaseDate)
|
||||
AppLoader.fontGame.draw(batch,
|
||||
strlen = App.fontGame.getWidth(modInfo.releaseDate)
|
||||
App.fontGame.draw(batch,
|
||||
modInfo.releaseDate,
|
||||
posX + width - strlen.toFloat(),
|
||||
posY + AppLoader.fontGame.lineHeight
|
||||
posY + App.fontGame.lineHeight
|
||||
)
|
||||
|
||||
}
|
||||
else {
|
||||
batch.color = Color(0xff8080_ff.toInt())
|
||||
val str = "InternalError: no such module: '$moduleName'"
|
||||
val strlen = AppLoader.fontSmallNumbers.getWidth(str)
|
||||
AppLoader.fontSmallNumbers.draw(batch,
|
||||
val strlen = App.fontSmallNumbers.getWidth(str)
|
||||
App.fontSmallNumbers.draw(batch,
|
||||
str,
|
||||
posX + (width - numberAreaWidth - strlen).div(2f).floor() + numberAreaWidth,
|
||||
posY + (height - AppLoader.fontSmallNumbers.H).div(2f).floor()
|
||||
posY + (height - App.fontSmallNumbers.H).div(2f).floor()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.floor
|
||||
import net.torvald.terrarum.ui.UIItemTextButton.Companion.Alignment
|
||||
|
||||
@@ -13,7 +13,7 @@ class UIItemTextArea(
|
||||
override val width: Int,
|
||||
override val height: Int,
|
||||
val lineGap: Int = 0,
|
||||
val lineCount: Int = ((height + lineGap) / AppLoader.fontGame.lineHeight).toInt(),
|
||||
val lineCount: Int = ((height + lineGap) / App.fontGame.lineHeight).toInt(),
|
||||
val align: Alignment = Alignment.LEFT
|
||||
) : UIItem(parentUI, initialX, initialY) {
|
||||
|
||||
@@ -36,12 +36,12 @@ class UIItemTextArea(
|
||||
for (i in scrollPos until minOf(lineCount + scrollPos, entireText.size)) {
|
||||
val yPtr = i - scrollPos
|
||||
|
||||
val textWidth = AppLoader.fontGame.getWidth(entireText[i])
|
||||
val textWidth = App.fontGame.getWidth(entireText[i])
|
||||
|
||||
when (align) {
|
||||
Alignment.LEFT -> AppLoader.fontGame.draw(batch, entireText[i], posX.toFloat(), posY + yPtr * (AppLoader.fontGame.lineHeight + lineGap))
|
||||
Alignment.CENTRE -> AppLoader.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).floor(), posY + yPtr * (AppLoader.fontGame.lineHeight + lineGap))
|
||||
Alignment.RIGHT -> AppLoader.fontGame.draw(batch, entireText[i], posX + width - textWidth.toFloat(), posY + yPtr * (AppLoader.fontGame.lineHeight + lineGap))
|
||||
Alignment.LEFT -> App.fontGame.draw(batch, entireText[i], posX.toFloat(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
|
||||
Alignment.CENTRE -> App.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).floor(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
|
||||
Alignment.RIGHT -> App.fontGame.draw(batch, entireText[i], posX + width - textWidth.toFloat(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
import net.torvald.terrarum.BlendMode
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.fillRect
|
||||
@@ -49,7 +49,7 @@ open class UIItemTextButton(
|
||||
) : UIItem(parentUI, initialX, initialY) {
|
||||
|
||||
companion object {
|
||||
val font = AppLoader.fontGame
|
||||
val font = App.fontGame
|
||||
val height = font.lineHeight.toInt()
|
||||
val defaultInactiveCol = Color.WHITE
|
||||
val defaultHighlightCol = Color(0x00f8ff_ff)
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.App
|
||||
|
||||
open class UIItemTransitionContainer(
|
||||
parent: UICanvas,
|
||||
@@ -72,7 +72,7 @@ open class UIItemTransitionContainer(
|
||||
ui.render(batch, camera)
|
||||
|
||||
if (debugvals) {
|
||||
AppLoader.fontSmallNumbers.draw(batch, "$index", 300f + (20 * index), 10f)
|
||||
App.fontSmallNumbers.draw(batch, "$index", 300f + (20 * index), 10f)
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -82,7 +82,7 @@ open class UIItemTransitionContainer(
|
||||
|
||||
if (debugvals) {
|
||||
batch.color = Color.WHITE
|
||||
AppLoader.fontSmallNumbers.draw(batch, "position:$currentPosition", 500f, 10f)
|
||||
App.fontSmallNumbers.draw(batch, "position:$currentPosition", 500f, 10f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class UINSMenu(
|
||||
override var openCloseTime: Second = 0f
|
||||
val LINE_HEIGHT = 24
|
||||
val TEXT_OFFSETX = 3f
|
||||
val TEXT_OFFSETY = (LINE_HEIGHT - AppLoader.fontGame.lineHeight) / 2f
|
||||
val TEXT_OFFSETY = (LINE_HEIGHT - App.fontGame.lineHeight) / 2f
|
||||
val CHILD_ARROW = "${0x2023.toChar()}"
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ class UINSMenu(
|
||||
}
|
||||
|
||||
val listWidth = maxOf(
|
||||
AppLoader.fontGame.getWidth(menuTitle), minimumWidth,
|
||||
stringsFromTree.map { AppLoader.fontGame.getWidth(it) }.maxOrNull() ?: 0
|
||||
App.fontGame.getWidth(menuTitle), minimumWidth,
|
||||
stringsFromTree.map { App.fontGame.getWidth(it) }.maxOrNull() ?: 0
|
||||
)
|
||||
val uiWidth = listWidth + (2 * TEXT_OFFSETX.toInt())
|
||||
val listHeight = stringsFromTree.size * LINE_HEIGHT
|
||||
@@ -175,7 +175,7 @@ class UINSMenu(
|
||||
|
||||
batch.color = titleTextCol
|
||||
blendNormal(batch)
|
||||
AppLoader.fontGame.draw(batch, it.title, TEXT_OFFSETX + it.ui.posX, TEXT_OFFSETY + it.ui.posY - LINE_HEIGHT)
|
||||
App.fontGame.draw(batch, it.title, TEXT_OFFSETX + it.ui.posX, TEXT_OFFSETY + it.ui.posY - LINE_HEIGHT)
|
||||
|
||||
// draw the list
|
||||
batch.color = Color.WHITE
|
||||
|
||||
Reference in New Issue
Block a user