debugwin: drawing ingame weatherboxes

This commit is contained in:
minjaesong
2023-08-31 17:03:27 +09:00
parent 7f3f94e01a
commit 5eed921288
91 changed files with 311 additions and 235 deletions

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulecomputers.gameitems
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.utils.Disposable
@@ -118,7 +119,7 @@ class WearableWorldRadarUI(val device: VM) : UICanvas() {
device.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()
batch.color = Color.WHITE

View File

@@ -50,7 +50,7 @@ internal class UIHomeComputer : UICanvas(
override fun updateUI(delta: Float) {
}
override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) {
override fun renderUI(otherBatch: SpriteBatch, otherCamera: OrthographicCamera) {
otherBatch.end()
fbo.inAction(camera, batch) {

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
import net.torvald.terrarum.ui.UICanvas
@@ -17,7 +18,7 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
}
override fun dispose() {

View File

@@ -35,7 +35,7 @@ class UIFakeGradOverlay : UICanvas() {
}
override fun updateUI(delta: Float) {}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()
val dither = App.getConfigBoolean("fx_dither")
@@ -84,7 +84,7 @@ class UIFakeBlurOverlay(val blurRadius: Float, val nodarken: Boolean) : UICanvas
private val batchDrawCol = Color(-1)
override fun updateUI(delta: Float) {}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batchDrawCol.a = openness
batch.color = batchDrawCol
if (App.getConfigBoolean("fx_backgroundblur")) {

View File

@@ -1,9 +1,6 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.gameitems.GameItem
import net.torvald.terrarum.langpack.Lang
@@ -271,7 +268,7 @@ class UIItemInventoryCatBar(
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
// button

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.gameitems.GameItem
@@ -53,7 +54,7 @@ class UIItemInventoryElemSimple(
private var highlightToMainCol = false
private var highlightToSubCol = false
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
highlightToMainCol = customHighlightRuleMain?.invoke(this) ?: (equippedSlot != null && highlightEquippedItem) || forceHighlighted

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.gameitems.GameItem
@@ -78,7 +79,7 @@ class UIItemInventoryElemWide(
var textHighlightMouseUpCol = Toolkit.Theme.COL_MOUSE_UP
var textHighlightNormalCol = Color.WHITE
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
highlightToMainCol = customHighlightRuleMain?.invoke(this) ?: (equippedSlot != null && highlightEquippedItem) || forceHighlighted

View File

@@ -4,7 +4,9 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import net.torvald.terrarum.*
import net.torvald.terrarum.App.*
import net.torvald.terrarum.Terrarum.getPlayerSaveFiledesc
@@ -12,8 +14,8 @@ import net.torvald.terrarum.Terrarum.getWorldSaveFiledesc
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.blockproperties.BlockPropUtil
import net.torvald.terrarum.blockstats.TileSurvey
import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.blockstats.TileSurvey
import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.console.AVTracker
import net.torvald.terrarum.console.ActorsList
@@ -95,12 +97,24 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
companion object {
/** Sets camera position so that (0,0) would be top-left of the screen, (width, height) be bottom-right. */
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
fun setCameraPosition(batch: SpriteBatch, camera: OrthographicCamera, newX: Float, newY: Float) {
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
batch.projectionMatrix = camera.combined
}
fun setCameraPosition(batch: SpriteBatch, shape: ShapeRenderer, camera: OrthographicCamera, newX: Float, newY: Float) {
camera.setToOrtho(false, App.scr.wf, App.scr.hf)
camera.update()
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
shape.projectionMatrix = camera.combined
camera.setToOrtho(true, App.scr.wf, App.scr.hf)
camera.update()
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
batch.projectionMatrix = camera.combined
}
fun getCanonicalTitle() = App.GAME_NAME +
" $EMDASH F: ${Gdx.graphics.framesPerSecond}" +
if (App.IS_DEVELOPMENT_BUILD)

View File

@@ -511,7 +511,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
fun setCameraPosition(newX: Float, newY: Float) {
TerrarumIngame.setCameraPosition(batch, camera, newX, newY)
TerrarumIngame.setCameraPosition(batch, App.shapeRender, camera, newX, newY)
}

View File

@@ -26,7 +26,7 @@ package net.torvald.terrarum.modulebasegame.ui
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormal(batch)
val textWidth = messagesList.map { AppLoader.fontGame.getWidth(it) }.sorted()[1]

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Second
@@ -49,7 +50,7 @@ class Notification : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
fontCol.a = handler.opacity * OPACITY

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.ui.UICanvas
@@ -15,7 +16,7 @@ object NullUI : UICanvas() {
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
}
override fun doOpening(delta: Float) {

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.modulebasegame.TerrarumIngame
@@ -86,7 +87,7 @@ class UIBasicInfo() : UICanvas() {
private val lcdLitCol: Color = lcdLitColELoff
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = drawCol
batch.draw(atlas.get(0, 0), 0f, 0f)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlockCodex
import net.torvald.terrarum.ItemCodex
@@ -126,7 +127,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
palette.forEach { it.render(batch, camera) }
blendNormalStraightAlpha(batch)

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.Block
@@ -146,7 +147,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
parent.tappedOnUI = true
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// draw back
batch.color = backCol
Toolkit.fillCircle(batch,0, 0, SIZE, SIZE)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Second
@@ -37,7 +38,7 @@ class UIBuildingMakerToolbox : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
tools.forEach { it.render(batch, camera) }
}

View File

@@ -32,7 +32,7 @@ class UICheatDetected : UICanvas() {
private val backgroundCol = Color(0x00000080)
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
Terrarum.ingame?.consoleHandler?.setAsClose()
Terrarum.ingame?.consoleHandler?.isVisible = false

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.gamepadLabelLEFTRIGHT
@@ -450,7 +451,7 @@ class UICrafting(val full: UIInventoryFull) : UICanvas(), HasInventory {
if (openingClickLatched && !Terrarum.mouseDown) openingClickLatched = false
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// NO super.render due to an infinite recursion
this.uiItems.forEach { it.render(batch, camera) }

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
@@ -45,7 +46,7 @@ class UIGraphicsControlPanel(remoCon: UIRemoCon?) : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
ControlPanelCommon.render("basegame.graphicscontrolpanel", width, batch)
uiItems.forEach { it.render(batch, camera) }

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.unicode.EMDASH
import net.torvald.terrarum.App
@@ -168,7 +169,7 @@ class UIIMEConfig(remoCon: UIRemoCon?) : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
val txt1 = Lang["MENU_LABEL_KEYBOARD_LAYOUT"]; val tw1 = App.fontGame.getWidth(txt1)
@@ -266,7 +267,7 @@ private class UIItemInputKeycap(
c in 0x1DC0..0x1DFF || c in 0x20D0..0x20FF || c in 0xFE20..0xFE2F ||
c == 0xE31 || c in 0xE33..0xE3A || c in 0xE47..0xE4E
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
// key background

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
@@ -119,7 +120,7 @@ class UIImportAvatar(val remoCon: UIRemoCon) : Advanceable() {
Lang["ERROR_AVATAR_ALREADY_EXISTS"], // 2
)
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
val textboxWidth = textboxIndices.maxOf { App.fontGame.getWidth(Lang["CONTEXT_IMPORT_AVATAR_INSTRUCTION_$it"]) }
val textX = (Toolkit.drawWidth - textboxWidth) / 2
@@ -264,7 +265,7 @@ class UIItemCodeBox(parent: UIImportAvatar, initialX: Int, initialY: Int, val co
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// draw box backgrounds
batch.color = UIInventoryFull.CELL_COL
Toolkit.fillArea(batch, posX, posY, width, height)

View File

@@ -213,7 +213,7 @@ package net.torvald.terrarum.modulebasegame.ui
private val weightBarWidth = 60f
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// background
blendNormal()
batch.color = backgroundColour

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
@@ -84,7 +85,7 @@ internal class UIInventoryCells(
equipped.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
//itemList.posX = itemList.initialX + inventoryScrOffX.roundToInt()
itemList.render(batch, camera)
//equipped.posX = equipped.initialX + inventoryScrOffX.roundToInt()

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
@@ -178,31 +179,31 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
// `screens` order
private val screenRenders = arrayOf(
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
// control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
// text buttons
gameMenuButtons.render(batch, camera)
},
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
// control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
keyboardSetupUI.render(batch, camera)
},
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
// control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
areYouSureMainMenuButtons.render(batch, camera)
},
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
savingUI.render(batch, camera)
},
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
// control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
keyConfigUI.render(batch, camera)
},
{ batch: SpriteBatch, camera: Camera ->
{ batch: SpriteBatch, camera: OrthographicCamera ->
// control hints
App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
languageUI.render(batch, camera)
@@ -281,7 +282,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
yeet.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
batch.color = Color.WHITE
screenRenders[screen](batch, camera)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.terrarum.*
@@ -313,7 +314,7 @@ class UIInventoryFull(
internal var yEnd = -YPOS_CORRECTION + (App.scr.height + internalHeight).div(2).toFloat()
private set
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
drawBackground(batch, 1f)

View File

@@ -65,7 +65,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
minimapRerenderTimer += Gdx.graphics.deltaTime
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
val cellOffY = INVENTORY_CELLS_OFFSET_Y()
val worldWidth = INGAME.world.width

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.GdxColorMap
@@ -33,7 +34,7 @@ abstract class UIItemInventoryCellBase(
open protected val highlightEquippedItem: Boolean = true // for some UIs that only cares about getting equipped slot number but not highlighting
) : UIItem(parentUI, initialX, initialY) {
abstract override fun update(delta: Float)
abstract override fun render(batch: SpriteBatch, camera: Camera)
abstract override fun render(batch: SpriteBatch, camera: OrthographicCamera)
/** Custom highlight rule to highlight tihs button to primary accent colour (blue by default).
* Set to `null` to use default rule:

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.spriteanimation.AssembledSpriteAnimation
import net.torvald.spriteanimation.SheetSpriteAnimation
@@ -67,7 +68,7 @@ class UIItemInventoryEquippedView(
itemGrid.forEach { it.update(delta) }
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
val posXDelta = posX - oldPosX

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.UIItemInventoryCatBar.Companion.CAT_ALL
@@ -289,7 +290,7 @@ open class UIItemInventoryItemGrid(
// private fun getIconPosY(index: Int) =
// posY + 8 + 26 * index
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
val posXDelta = posX - oldPosX
itemGrid.forEach { it.posX += posXDelta }
itemList.forEach { it.posX += posXDelta }

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.CommonResourcePool
@@ -110,7 +111,7 @@ class UIItemListNavBarVertical(
var itemPage = 0
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
val posXDelta = posX - oldPosX
gridModeButtons.forEach { it.posX += posXDelta }

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
@@ -30,7 +31,7 @@ class UIItemSaving(parentUI: UICanvas, initialX: Int, initialY: Int) : UIItem(pa
init {
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// these things will not scroll along with the parent GUI!
val t = Lang["MENU_IO_SAVING"]
val tlen = App.fontGame.getWidth(t)

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.*
@@ -200,7 +201,7 @@ class UIKeyboardControlPanel(remoCon: UIRemoCon?) : UICanvas() {
controlPalette.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// batch.color = borderNormal
// Toolkit.drawBoxBorder(batch, drawX, drawY, width, height)
// batch.color = fillCol
@@ -336,7 +337,7 @@ private class UIItemKeycap(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
batch.color = if (key == null)
@@ -446,7 +447,7 @@ class UIItemControlPaletteBaloon(val parent: UIKeyboardControlPanel, initialX: I
)
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
Toolkit.drawBaloon(batch, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())

View File

@@ -122,7 +122,7 @@ import java.util.zip.GZIPInputStream
private var loadFiredFrameCounter = 0
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
if (mode == MODE_INIT) {
// "The Autosave is more recent than the manual save"
Toolkit.drawTextCentered(batch, App.fontGame, Lang["GAME_MORE_RECENT_AUTOSAVE1"], Toolkit.drawWidth, 0, altSelDrawY)

View File

@@ -304,7 +304,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : Advanceable() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
if (mode == 2) {
loadFired += 1
@@ -475,7 +475,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : Advanceable() {
sliderFBO = FrameBuffer(Pixmap.Format.RGBA8888, uiWidth + 10, height, false)
}
private fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
private fun setCameraPosition(batch: SpriteBatch, camera: OrthographicCamera, newX: Float, newY: Float) {
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
batch.projectionMatrix = camera.combined
@@ -584,7 +584,7 @@ class UIItemPlayerCells(
private val avatarViewWidth = 120
fun render(batch: SpriteBatch, camera: Camera, offX: Int, offY: Int) {
fun render(batch: SpriteBatch, camera: OrthographicCamera, offX: Int, offY: Int) {
// try to generate a texture
if (!hasTexture) { acquirePlayerAvatar(); hasTexture = true }
@@ -652,7 +652,7 @@ class UIItemPlayerCells(
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
render(batch, camera, 0, 0)
}
@@ -819,7 +819,7 @@ class UIItemWorldCells(
highlightCol = if (mouseUp) Toolkit.Theme.COL_MOUSE_UP else Toolkit.Theme.COL_LIST_DEFAULT
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// try to generate a texture
if (skimmer.initialised && !hasTexture) {
// load thumbnail or use stock if the file is not there

View File

@@ -161,7 +161,7 @@ class UILoadList(val full: UILoadSavegame) : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()
val cells = playerCells

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
@@ -208,7 +209,7 @@ class UILoadManage(val full: UILoadSavegame) : UICanvas() {
private var loadFiredFrameCounter = 0
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val buttonYdelta = (full.titleTopGradEnd) - full.playerButtonSelected!!.posY
full.playerButtonSelected!!.render(batch, camera, 0, buttonYdelta)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.ui.Toolkit
@@ -18,7 +19,7 @@ class UILoadNewCharacter(val full: UILoadSavegame) : UICanvas() {
TODO("Not yet implemented")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
TODO("Not yet implemented")
}

View File

@@ -144,7 +144,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
transitionPanel.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
transitionPanel.render(batch, camera)
}
@@ -182,7 +182,7 @@ class UILoadSavegame(val remoCon: UIRemoCon) : Advanceable() {
super.resize(width, height)
}
internal fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
internal fun setCameraPosition(batch: SpriteBatch, camera: OrthographicCamera, newX: Float, newY: Float) {
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
batch.projectionMatrix = camera.combined

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.App.playersDir
@@ -120,7 +121,7 @@ class UINewCharacter(val remoCon: UIRemoCon) : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
// ui title
// val titlestr = Lang["CONTEXT_WORLD_NEW"]

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
@@ -151,7 +152,7 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
// ui title
// val titlestr = Lang["CONTEXT_WORLD_NEW"]

View File

@@ -1,9 +1,6 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.ItemCodex
@@ -71,7 +68,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// draw title bar
batch.color = UINSMenu.DEFAULT_TITLEBACKCOL
blendNormalStraightAlpha(batch)

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
@@ -42,7 +43,7 @@ class UIPerformanceControlPanel(remoCon: UIRemoCon?) : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
ControlPanelCommon.render("basegame.performancecontrolpanel", width, batch)
uiItems.forEach { it.render(batch, camera) }
}

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Second
import net.torvald.terrarum.ui.UICanvas
@@ -17,7 +18,7 @@ class UIProxyLoadLatestSave(val remoCon: UIRemoCon) : UICanvas() {
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
}
override fun doOpening(delta: Float) {

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.SanicLoadScreen
@@ -21,7 +22,7 @@ class UIProxyNewBuildingMaker : UICanvas() {
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
}
override fun doOpening(delta: Float) {

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.random.HQRNG
import net.torvald.terrarum.App
@@ -26,7 +27,7 @@ class UIProxyNewRandomGame(val remoCon: UIRemoCon) : UICanvas() {
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
}
override fun doOpening(delta: Float) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.terrarum.*
@@ -84,7 +85,7 @@ class UIQuickslotBar : UICanvas() {
private val itemCntTextCol = Color(0x404040ff)
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
(Terrarum.ingame!! as TerrarumIngame).actorNowPlaying?.let { actor ->
for (i in 0 until SLOT_COUNT) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.terrarum.*
@@ -66,7 +67,7 @@ class UIQuickslotPie : UICanvas() {
private val drawColor = Color(1f, 1f, 1f, 1f)
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// draw radial thingies
for (i in 0 until slotCount) {
val qs = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying?.inventory?.getQuickslotItem(i)

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.App.*
@@ -213,7 +214,7 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
openUI = external
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
remoConTray.render(batch, camera)
openUI?.render(batch, camera)
}
@@ -307,7 +308,7 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
menubar.update(delta)
}
fun render(batch: SpriteBatch, camera: Camera) {
fun render(batch: SpriteBatch, camera: OrthographicCamera) {
menubar.render(batch, camera)
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
@@ -40,7 +41,7 @@ class UIScreenZoom : UICanvas(
override fun updateUI(delta: Float) {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
val offX = (App.scr.tvSafeGraphicsWidth * 1.25f).roundToInt().toFloat()

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.UICanvas
@@ -31,7 +32,7 @@ class UISoundControlPanel(remoCon: UIRemoCon?) : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
ControlPanelCommon.render("basegame.soundcontrolpanel", width, batch)
uiItems.forEach { it.render(batch, camera) }
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.AVKey
@@ -179,7 +180,7 @@ internal class UIStorageChest : UICanvas(
else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]} "
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// background fill
UIInventoryFull.drawBackground(batch, 1f)

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameworld.WorldTime
@@ -55,7 +56,7 @@ class UITierOneWatch() : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// light overlay or EL
/*blendNormal(batch)
if (ELon) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
@@ -104,7 +105,7 @@ class UITitleLanguage(remoCon: UIRemoCon?) : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
textArea1.render(batch, camera)

View File

@@ -135,7 +135,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
moduleCells.clear()
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()
lateinit var savePixmap: Pixmap
@@ -260,7 +260,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
sliderFBO = FrameBuffer(Pixmap.Format.RGBA8888, uiWidth + 10, height, true)
}
private fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
private fun setCameraPosition(batch: SpriteBatch, camera: OrthographicCamera, newX: Float, newY: Float) {
camera.position.set((-newX + App.scr.halfw).roundToFloat(), (-newY + App.scr.halfh).roundToFloat(), 0f)
camera.update()
batch.projectionMatrix = camera.combined

View File

@@ -124,7 +124,7 @@ package net.torvald.terrarum.modulebasegame.ui
//println("UITitleRemoConRoot bro u even updatez")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
menubar.render(batch, camera)
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CreditSingleton
@@ -31,7 +32,7 @@ open class UITitleWallOfText(private val text: List<String>) : UICanvas() {
textArea.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = Color.WHITE
textArea.render(batch, camera)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Second
@@ -45,7 +46,7 @@ class UITooltip : UICanvas() {
get() = 36 * 2 + font.lineHeight.toInt()
set(value) { throw Error("You are not supposed to set the height of the tooltip manually.") }
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val mouseXoff = 28f
val mouseYoff = 0f
val txtW = msgWidth + 2f * textMarginX

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.colourutil.darkerLab
@@ -62,7 +63,7 @@ class UIVitalMetre(
/**
* g must be same as World Graphics!
*/
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// TODO now that we just can't draw arcs, we need to re-think about this
/*if (vitalGetterVal() != null && vitalGetterMax() != null && player != null) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameworld.WorldTime
@@ -78,7 +79,7 @@ class UIWallCalendar : UICanvas(
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
UIInventoryFull.drawBackground(batch, 1f)
val thisYear = INGAME.world.worldTime.years

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.terrarum.*
@@ -116,7 +117,7 @@ class UIWorldPortal : UICanvas(
transitionPanel.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
drawBackground(batch, 1f)
// UI items
@@ -329,7 +330,7 @@ class UIItemWorldPortalTopBar(
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
// button

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.AVKey
@@ -171,7 +172,7 @@ class UIWorldPortalCargo(val full: UIWorldPortal) : UICanvas(), HasInventory {
else
"${App.gamepadLabelStart} ${Lang["GAME_ACTION_CLOSE"]} "
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// background fill
UIInventoryFull.drawBackground(batch, 1f)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.langpack.Lang
@@ -44,7 +45,7 @@ class UIWorldPortalDelete(private val full: UIWorldPortal) : UICanvas() {
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
full.selectedButton?.let {
val buttonYdelta = (App.scr.tvSafeGraphicsHeight + 172 + 36) - it.posY
val buttonXdelta = (Toolkit.drawWidth - it.width) / 2 - it.posX

View File

@@ -1,9 +1,6 @@
package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.utils.Disposable
@@ -339,7 +336,7 @@ class UIWorldPortalListing(val full: UIWorldPortal) : UICanvas() {
private var selectedWorldThumb: TextureRegion? = null
val icons = CommonResourcePool.getAsTextureRegionPack("terrarum-basegame-worldportalicons")
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val memoryGaugeXpos = hx - memoryGaugeWidth - gridGap/2
val memoryGaugeYpos = y + listHeight - buttonHeight
val textXpos = memoryGaugeXpos + 3
@@ -511,7 +508,7 @@ class UIItemWorldCellsSimple(
super.update(delta)
}
fun render(batch: SpriteBatch, camera: Camera, offX: Int, offY: Int) {
fun render(batch: SpriteBatch, camera: OrthographicCamera, offX: Int, offY: Int) {
super.render(batch, camera)
val posX = posX + offX
@@ -543,7 +540,7 @@ class UIItemWorldCellsSimple(
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
render(batch, camera, 0, 0)
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.langpack.Lang
@@ -63,7 +64,7 @@ class UIWorldPortalRename(private val full: UIWorldPortal) : UICanvas() {
private var oldPosX = full.posX
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val posXDelta = posX - oldPosX
// ugh why won't you just scroll along??

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
@@ -153,7 +154,7 @@ class UIWorldPortalSearch(val full: UIWorldPortal) : UICanvas() {
val icons = CommonResourcePool.getAsTextureRegionPack("terrarum-basegame-worldportalicons")
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val memoryGaugeXpos = hx - memoryGaugeWidth/2
val memoryGaugeYpos = drawY + sizeSelY + buttonHeight + 10
val textXpos = memoryGaugeXpos + 3

View File

@@ -221,7 +221,7 @@ object Common {
}
override fun read(json: Json, jsonData: JsonValue, type: Class<*>?): WeatherStateBox {
return jsonData.asString().split(';').map { it.toDouble() }.let {
return jsonData.asString().split(';').map { it.toFloat() }.let {
WeatherStateBox(it[0], it[1], it[2], it[3], it[4])
}
}

View File

@@ -122,7 +122,7 @@ class DummyTogglePane : UICanvas() {
uiItems.forEach { it.update(delta) }
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
batch.inUse {
batch.color = Color.CORAL
Toolkit.fillArea(batch, 0f, 0f, 800f, 600f)

View File

@@ -5,9 +5,9 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.Input.Keys
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.random.HQRNG
import net.torvald.terrarum.*
import net.torvald.terrarum.Terrarum.mouseTileX
import net.torvald.terrarum.Terrarum.mouseTileY
@@ -20,7 +20,6 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
import net.torvald.terrarum.weather.WeatherMixer
import net.torvald.terrarum.weather.WeatherStateBox
import net.torvald.terrarum.weather.Weatherbox
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -126,7 +125,10 @@ class BasicDebugInfoWindow : UICanvas() {
private val tileCursX = 0; private val tileCursY = 4
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
TerrarumIngame.setCameraPosition(batch, App.shapeRender, camera, 0f, 0f)
// toggle show-something
showTimers = showTimers xor (Gdx.input.isKeyJustPressed(KEY_TIMERS) && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
showWeatherInfo = showWeatherInfo xor (Gdx.input.isKeyJustPressed(KEY_WEATHERS) && Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
@@ -137,7 +139,6 @@ class BasicDebugInfoWindow : UICanvas() {
if (showWeatherInfo) drawWeatherInfo(batch)
testBox.getAndUpdate(0.001, testBoxRng)
}
private fun drawMain(batch: SpriteBatch) {
@@ -340,78 +341,104 @@ class BasicDebugInfoWindow : UICanvas() {
}
}
private val testBox = WeatherStateBox(Math.random(), Math.random(), Math.random(), Math.random(), Math.random())
private val testBoxRng = HQRNG()
private fun drawWeatherInfo(batch: SpriteBatch) {
drawWeatherStateBox(batch, testBox, "Test", App.scr.width - 170, App.scr.height - 120)
drawWeatherStateBox(batch, WeatherMixer.weatherbox.windSpeed, "WindSpd", App.scr.width - 170, App.scr.height - 140 - 120, WeatherMixer.currentWeather.windSpeed * (1.0 + WeatherMixer.currentWeather.windSpeedVariance))
drawWeatherStateBox(batch, WeatherMixer.weatherbox.windDir, "WindDir", App.scr.width - 170, App.scr.height - 140)
}
private val colHairline = Color(0xf22100ff.toInt())
private val colGraph = Toolkit.Theme.COL_SELECTED
private val colGraphBack = Toolkit.Theme.COL_CELL_FILL
private val colGraphFore = Color(1f, 1f, 1f, 0.5f)
private val colGraphForf = Color(1f, 1f, 1f, 0.25f)
private val colGraphForg = Color(1f, 1f, 1f, 0.125f)
private fun drawWeatherStateBox(batch: SpriteBatch, box: WeatherStateBox, label: String, x: Int, y: Int) {
private fun drawWeatherStateBox(batch: SpriteBatch, box: WeatherStateBox, label: String, x: Int, y: Int, ymax: Double = 1.0) {
val bw = 50*3 + 1
val bh = 40*2 + 1
val yc = bh/2
val yh = yc
val bh = 100
val xstart = (bw/3)*1
val xw = (bw/3)
val MIN_RULE_GAP = 5.0
// back
batch.color = colGraphBack
Toolkit.fillArea(batch, x, y, bw, bh)
Toolkit.fillArea(batch, x, y + 1, bw, bh - 1)
// frame
batch.color = colGraphFore
Toolkit.drawBoxBorder(batch, x + 1, y, bw - 1, bh)
// grid
Toolkit.drawBoxBorder(batch, x + 1, y + 1, bw - 1, bh - 1)
// x grids
Toolkit.drawStraightLine(batch, x + (bw/3)*1, y, y+bh, 1, true)
Toolkit.drawStraightLine(batch, x + (bw/3)*2, y, y+bh, 1, true)
// centreline
// y grids
val yrange =
//// ymax small and bh tall enought to fit the 0.25 rules?
if (bh / ymax * 0.25 >= MIN_RULE_GAP)
(ymax.toInt() * 4 downTo 0).map { it * 0.25 }
//// ymax small and bh tall enought to fit the 0.5 rules?
else if (bh / ymax * 0.5 >= MIN_RULE_GAP)
(ymax.toInt() * 2 downTo 0).map { it * 0.5 }
//// ymax small and bh tall enought to fit the 1.0 rules?
else if (bh / ymax >= MIN_RULE_GAP)
(ymax.toInt() downTo 0).map { it * 1.0 }
//// ymax small and bh tall enought to fit the 2.0 rules?
else if (bh / ymax * 2.0 >= MIN_RULE_GAP)
(ymax.toInt() / 2 downTo 0).map { it * 2.0 }
//// ymax small and bh tall enought to fit the 5.0 rules?
else if (bh / ymax * 5.0 >= MIN_RULE_GAP)
(ymax.toInt() / 5 downTo 0).map { it * 5.0 }
//// ymax small and bh tall enought to fit the 10.0 rules?
else if (bh / ymax * 10.0 >= MIN_RULE_GAP)
(ymax.toInt() / 10 downTo 0).map { it * 10.0 }
else
(ymax.toInt() / 20 downTo 0).map { it * 20.0 }
yrange.forEach { d ->
val yc = bh - (bh / ymax * d).roundToInt()
batch.color = when (d % 1.0) {
0.0 -> colGraphFore
0.5 -> colGraphForf
else-> colGraphForg
}
Toolkit.drawStraightLine(batch, x, y + yc, x + bw, 1, false)
}
// graph points
batch.color = colGraph
Toolkit.fillArea(batch, x + - 1, y + yc-(box.p0 * yh).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + (bw/3)*1 - 1, y + yc-(box.p1 * yh).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + (bw/3)*2 - 1, y + yc-(box.p2 * yh).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + bw - 1, y + yc-(box.p3 * yh).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + - 1, y + bh-(box.p0 * bh / ymax).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + (bw/3)*1 - 1, y + bh-(box.p1 * bh / ymax).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + (bw/3)*2 - 1, y + bh-(box.p2 * bh / ymax).roundToInt(), 3, 3)
Toolkit.fillArea(batch, x + bw - 1, y + bh-(box.p3 * bh / ymax).roundToInt(), 3, 3)
batch.end()
// interpolated values
val pys = (0 until xw).map {
val px = it.toDouble() / xw
1 * yc - (yh * WeatherStateBox.interpolateCatmullRom(px, box.p0, box.p1, box.p2, box.p3)).roundToInt()
val px = it.toFloat() / xw
bh - (bh * WeatherStateBox.interpolateCatmullRom(px, box.p0, box.p1, box.p2, box.p3) / ymax).toFloat()
}
pys.forEachIndexed { index, py ->
val px = x + xstart + index
if (index in 1 until pys.lastIndex) {
val py0 = pys[index - 1]
val py2 = pys[index + 1]
val pys = ((py0 + py) / 2.0).roundToInt()
var pye = ((py + py2) / 2.0).roundToInt()
if (pye - pys < 1) pye = pys + 1
Toolkit.drawStraightLine(batch, px, y + pys, y + pye, 1, true)
}
else if (index == pys.lastIndex) {
val py0 = pys[index - 1]
val pys = ((py0 + py) / 2.0).roundToInt()
val pye = if (py - pys < 1) pys + 1 else py
Toolkit.drawStraightLine(batch, px, y + pys, y + pye, 1, true)
}
else {
val py2 = pys[index + 1]
var pye = ((py + py2) / 2.0).roundToInt()
if (pye - py < 1) pye = py + 1
Toolkit.drawStraightLine(batch, px, y + py, y + pye, 1, true)
App.shapeRender.inUse {
it.color = colGraph
for (index in 0 until pys.lastIndex) {
val px = x + xstart + index.toFloat()
it.rectLine(
px,
App.scr.hf - 1 - (y + pys[index]),
px + 1f,
App.scr.hf - 1 - (y + pys[index + 1]),
1.5f
)
}
}
// hairline
batch.begin()
batch.color = colHairline
Toolkit.drawStraightLine(batch, x + xstart + (box.x * xw).roundToInt(), y, y+bh, 1, true)
// text
batch.color = Color.WHITE
App.fontSmallNumbers.draw(batch, "$ccY$label $ccG${box.get().toIntAndFrac(3)}", x.toFloat(), y - 14f)
App.fontSmallNumbers.draw(batch, "$ccY$label $ccG${box.get().toDouble().toIntAndFrac(3)}", x.toFloat(), y - 14f)
}
private val processorName = App.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (App.is32BitJVM) " (32-bit)" else ""

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
@@ -102,7 +103,7 @@ class ConsoleWindow : UICanvas() {
textinput.isEnabled = (isOpened && !isClosing)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
// background
batch.color = UIColour
Toolkit.fillArea(batch, drawOffX, drawOffY, width.toFloat(), height.toFloat())

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
@@ -50,7 +51,7 @@ class UIAutosaveNotifier : UICanvas() {
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
val spin = spinner.get(spinnerFrame % 8, spinnerFrame / 8)
val offX = App.scr.width - WIDTH - (App.scr.tvSafeGraphicsWidth * 1.25f).roundToInt().toFloat()
val offY = App.scr.height - HEIGHT - App.scr.tvSafeGraphicsHeight - 9f // +9 to align to quickslot and watch UI

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.App
@@ -118,7 +119,7 @@ abstract class UICanvas(
handler.update(this, delta)
}
/** Called by the screen */
fun render(batch: SpriteBatch, camera: Camera, parentOpacity: Float = 1f) {
fun render(batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float = 1f) {
handler.render(this, batch, camera, parentOpacity)
}
@@ -154,7 +155,7 @@ abstract class UICanvas(
* The transparency of the handler is independent of the draw, you must set the drawing color yourself
* (use handler.opacity or handler.opacityColour)
*/
abstract fun renderUI(batch: SpriteBatch, camera: Camera)
abstract fun renderUI(batch: SpriteBatch, camera: OrthographicCamera)
/**
* Do not modify ui.handler.openCloseCounter here.

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.App
@@ -278,7 +279,7 @@ void main() {
subUIs.forEach { it.update(delta) }
}
fun render(ui: UICanvas, batch: SpriteBatch, camera: Camera, parentOpacity: Float) {
fun render(ui: UICanvas, batch: SpriteBatch, camera: OrthographicCamera, parentOpacity: Float) {
if (isVisible) {
// camera SHOULD BE CENTERED to HALFX and HALFY (see StateInGame) //
@@ -390,7 +391,7 @@ void main() {
return isVisible && !isOpening
}
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
fun setCameraPosition(batch: SpriteBatch, camera: OrthographicCamera, newX: Float, newY: Float) {
TerrarumIngame.setCameraPosition(batch, camera, newX, newY)
}

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.App
@@ -174,7 +175,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
/**
* In this time, you do write like: ```draw(posX + 4, posY + 32)```, unlike UICanvas, because posX/posY comes from the parent UI.
*/
open fun render(batch: SpriteBatch, camera: Camera) {
open fun render(batch: SpriteBatch, camera: OrthographicCamera) {
if (parentUI.isVisible) {
// if (isActive) {
mouseOverCall?.render(batch, camera)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.imagefont.TinyAlphNum
@@ -39,7 +40,7 @@ class UIItemConfigKeycap(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// draw keycap
batch.draw(capTex.get(0, 0), posX.toFloat(), posY.toFloat())
batch.draw(capTex.get(1, 0), (posX + capTex.tileW).toFloat(), posY.toFloat(),

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.*
@@ -94,7 +95,7 @@ class UIItemHorzSlider(
private val renderOrderMouseUp = arrayOf(0,2,3,1).map { renderJobs[it] }
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
renderOrderMouseUp.forEach { it(batch) }

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.BlendMode
@@ -53,7 +54,7 @@ open class UIItemImageButton(
var highlighted = false
var extraDrawOp: (UIItem, SpriteBatch) -> Unit = { _,_ -> }
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// draw background
if (highlighted) {
BlendMode.resolve(highlightBackBlendMode, batch)

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import java.util.*
@@ -23,7 +24,7 @@ class UIItemImageGallery(
override fun update(delta: Float) {
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
fun column(i: Int) = i % column
fun row(i: Int) = i / column

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
@@ -51,7 +52,7 @@ class UIItemInlineRadioButtons(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
// backgrounds
batch.color = UIItemTextLineInput.TEXTINPUT_COL_BACKGROUND
for (i in labelfuns.indices) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.Second
@@ -103,7 +104,7 @@ class UIItemList<Item: UIItem>(
}
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
batch.color = backgroundCol
BlendMode.resolve(backgroundBlendMode, batch)
Toolkit.fillArea(batch, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
@@ -57,7 +58,7 @@ class UIItemModuleInfoCell(
private val ccNum2 = App.fontGame.toColorCode(12,11,4)
private val ccDesc = App.fontGame.toColorCode(13,13,13)
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)
batch.color = Toolkit.Theme.COL_CELL_FILL

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
@@ -110,7 +111,7 @@ class UIItemSpinner(
fboUpdateLatch = true
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
batch.end()

View File

@@ -1,6 +1,7 @@
package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.roundToFloat
@@ -33,7 +34,7 @@ class UIItemTextArea(
if (scrollPos < 0) scrollPos = 0
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
for (i in scrollPos until min(lineCount + scrollPos, entireText.size)) {
val yPtr = i - scrollPos

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.BlendMode
@@ -74,7 +75,7 @@ open class UIItemTextButton(
super.update(delta)
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
val textW = font.getWidth(label)
val fontX = when (alignment) {
Alignment.CENTRE -> posX + width.minus(textW).div(2) + (paddingLeft - paddingRight).div(2)

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.Second
@@ -223,7 +224,7 @@ class UIItemTextButtonList(
oldPosX = posX
}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
/*if (kinematic) {
batch.color = backgroundCol

View File

@@ -511,7 +511,7 @@ class UIItemTextLineInput(
private var textDrawOffset = 0
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
val posXDelta = posX - oldPosX

View File

@@ -131,7 +131,7 @@ class UIItemTextSelector(
private val leftIcon = if (useSpinnerButtons) labels.get(9,2) else labels.get(16,0)
private val rightIcon = if (useSpinnerButtons) labels.get(10,2) else labels.get(17,0)
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
labelCache = labelfuns.map { it() }
batch.end()

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
@@ -134,7 +135,7 @@ class UIItemToggleButton(
Color(0x00E800FF)
)
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
blendNormalStraightAlpha(batch)

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
@@ -54,7 +55,7 @@ open class UIItemTransitionContainer(
open fun onTransition(currentPosition: Float, uis: List<UICanvas>) {}
override fun render(batch: SpriteBatch, camera: Camera) {
override fun render(batch: SpriteBatch, camera: OrthographicCamera) {
super.render(batch, camera)
if (transitionRequested && !transitionOngoing) {

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.*
import kotlin.math.max
@@ -167,7 +168,7 @@ class UINSMenu(
}
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
listStack.forEach {
// draw title bar
batch.color = titleBackCol

View File

@@ -29,6 +29,7 @@ import java.io.File
import java.io.FileFilter
import java.lang.Double.doubleToLongBits
import java.lang.Math.toDegrees
import java.lang.Math.toRadians
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.*
@@ -89,9 +90,13 @@ internal object WeatherMixer : RNGConsumer {
private var astrumOffX = 0f
private var astrumOffY = 0f
private val clouds = SortedArrayList<WeatherObjectCloud>()
// val weatherbox: Weatherbox
var weatherbox = Weatherbox()
// Clouds are merely a response to the current Weatherbox status //
private val clouds = SortedArrayList<WeatherObjectCloud>()
var cloudsSpawned = 0; private set
private var windVector = Vector3(-1f, 0f, 0.1f) // this is a direction vector
@@ -124,10 +129,22 @@ internal object WeatherMixer : RNGConsumer {
cloudsSpawned = 0
windVector = Vector3(-0.98f, 0f, 0.21f)
windDirWindow = null
windSpeedWindow = null
oldCamPos.set(WorldCamera.camVector)
weatherbox = Weatherbox()
// TEST FILL WITH RANDOM VALUES
(0..3).map { takeUniformRand(0f..1f) }.let {
weatherbox.windDir.p0 = it[0]
weatherbox.windDir.p1 = it[1]
weatherbox.windDir.p2 = it[2]
weatherbox.windDir.p3 = it[3]
}
(0..3).map { takeUniformRand(-1f..1f) }.let {
weatherbox.windSpeed.p0 = currentWeather.getRandomWindSpeed(it[0])
weatherbox.windSpeed.p1 = currentWeather.getRandomWindSpeed(it[1])
weatherbox.windSpeed.p2 = currentWeather.getRandomWindSpeed(it[2])
weatherbox.windSpeed.p3 = currentWeather.getRandomWindSpeed(it[3])
}
}
init {
@@ -213,12 +230,8 @@ internal object WeatherMixer : RNGConsumer {
private val TWO_PI = 6.2831855f
private val THREE_PI = 9.424778f
private var windDirWindow: FloatArray? = null
private var windSpeedWindow: FloatArray? = null
private val WIND_DIR_TIME_UNIT = 14400 // every 4hr
private val WIND_SPEED_TIME_UNIT = 3600 // every 1hr
private var windDirAkku = 0 // only needed if timeDelta is not divisible by WIND_TIME_UNIT
private var windSpeedAkku = 0
private val WIND_DIR_TIME_UNIT = 14400f // every 4hr
private val WIND_SPEED_TIME_UNIT = 3600f // every 1hr
// see: https://stackoverflow.com/questions/2708476/rotation-interpolation/14498790#14498790
private fun getShortestAngle(start: Float, end: Float) =
@@ -227,54 +240,23 @@ internal object WeatherMixer : RNGConsumer {
}
private fun updateWind(delta: Float, world: GameWorld) {
if (windDirWindow == null) {
windDirWindow = FloatArray(4) { takeUniformRand(-PI..PI) } // completely random regardless of the seed
}
if (windSpeedWindow == null) {
windSpeedWindow = FloatArray(4) { currentWeather.getRandomWindSpeed(takeTriangularRand(-1f..1f)) } // completely random regardless of the seed
val currentWindSpeed = weatherbox.windSpeed.getAndUpdate( world.worldTime.timeDelta / WIND_SPEED_TIME_UNIT) {
currentWeather.getRandomWindSpeed(takeUniformRand(-1f..1f))
}
val currentWindDir = weatherbox.windDir.getAndUpdate( world.worldTime.timeDelta / WIND_DIR_TIME_UNIT) { RNG.nextFloat() } * 2.0 * Math.PI
val windDirStep = windDirAkku / WIND_DIR_TIME_UNIT.toFloat()
val windSpeedStep = windSpeedAkku / WIND_SPEED_TIME_UNIT.toFloat()
// val angle0 = windDirWindow[0]
// val angle1 = getShortestAngle(angle0, windDirWindow[1])
// val angle2 = getShortestAngle(angle1, windDirWindow[2])
// val angle3 = getShortestAngle(angle2, windDirWindow[3])
// val fixedAngles = floatArrayOf(angle0, angle1, angle2, angle3)
val currentWindDir = FastMath.interpolateCatmullRom(windDirStep, windDirWindow)
val currentWindSpeed = FastMath.interpolateCatmullRom(windSpeedStep, windSpeedWindow)
/*
printdbg(this,
"dir ${Math.toDegrees(currentWindDir.toDouble()).roundToInt()}\t" +
"spd ${currentWindSpeed.times(10f).roundToInt().div(10f)}\t " +
"dirs ${windDirWindow!!.map { Math.toDegrees(it.toDouble()).roundToInt() }} ${windDirStep.times(100).roundToInt()}\t" +
"spds ${windSpeedWindow!!.map { it.times(10f).roundToInt().div(10f) }} ${windSpeedStep.times(100).roundToInt()}"
)*/
if (currentWeather.forceWindVec != null) {
windVector.set(currentWeather.forceWindVec)
}
else {
windVector.set(
cos(currentWindDir) * currentWindSpeed,
(cos(currentWindDir) * currentWindSpeed).toFloat(),
0f,
sin(currentWindDir) * currentWindSpeed
(sin(currentWindDir) * currentWindSpeed).toFloat()
)
}
while (windDirAkku >= WIND_DIR_TIME_UNIT) {
windDirAkku -= WIND_DIR_TIME_UNIT
windDirWindow!!.shiftAndPut(takeUniformRand(-PI..PI))
}
while (windSpeedAkku >= WIND_SPEED_TIME_UNIT) {
windSpeedAkku -= WIND_SPEED_TIME_UNIT
windSpeedWindow!!.shiftAndPut(currentWeather.getRandomWindSpeed(takeTriangularRand(-1f..1f)))
}
windDirAkku += world.worldTime.timeDelta
windSpeedAkku += world.worldTime.timeDelta
}
private val cloudParallaxMultY = -0.035f
@@ -537,7 +519,7 @@ internal object WeatherMixer : RNGConsumer {
/**
* Sub-portion of IngameRenderer. You are not supposed to directly deal with this.
*/
internal fun render(camera: Camera, batch: FlippingSpriteBatch, world: GameWorld) {
internal fun render(camera: OrthographicCamera, batch: FlippingSpriteBatch, world: GameWorld) {
drawSkybox(camera, batch, world)
drawClouds(batch)
batch.color = Color.WHITE
@@ -559,7 +541,7 @@ internal object WeatherMixer : RNGConsumer {
private val parallaxDomainSize = 400f
private val turbidityDomainSize = 533.3333f
private fun drawSkybox(camera: Camera, batch: FlippingSpriteBatch, world: GameWorld) {
private fun drawSkybox(camera: OrthographicCamera, batch: FlippingSpriteBatch, world: GameWorld) {
val parallaxZeroPos = (world.height / 3f)
// we will not care for nextSkybox for now

View File

@@ -1,33 +1,28 @@
package net.torvald.terrarum.weather
import com.jme3.math.FastMath
import net.torvald.random.HQRNG
import java.util.*
class Weatherbox {
val RNG: HQRNG
get() = WeatherMixer.RNG
val windDir = WeatherStateBox() // 0 .. 1.0
val windSpeed = WeatherStateBox() // 0 .. arbitrarily large number
}
data class WeatherStateBox(var x: Double, var p0: Double, var p1: Double, var p2: Double, var p3: Double) {
data class WeatherStateBox(var x: Float = 0f, var p0: Float = 0f, var p1: Float = 0f, var p2: Float = 0f, var p3: Float = 0f) {
fun get() = interpolateCatmullRom(x, p0, p1, p2, p3)
fun getAndUpdate(xdelta: Double, RNG: Random): Double {
synchronized(RNG) {
fun getAndUpdate(xdelta: Float, next: () -> Float): Float {
synchronized(WeatherMixer.RNG) {
val y = get()
x += xdelta
while (x >= 1.0) {
x -= 1.0
x -= 1.0f
p0 = p1
p1 = p2
p2 = p3
p3 = RNG.nextDouble()
p3 = next()
}
return y
}
@@ -35,11 +30,11 @@ data class WeatherStateBox(var x: Double, var p0: Double, var p1: Double, var p2
companion object {
// fixed with T=0.5
fun interpolateCatmullRom(u: Double, p0: Double, p1: Double, p2: Double, p3: Double): Double {
val c1: Double = p1
val c2: Double = -0.5 * p0 + 0.5 * p2
val c3: Double = p0 - 2.5 * p1 + 2.0 * p2 - 0.5 * p3
val c4: Double = -0.5 * p0 + 1.5 * p1 - 1.5 * p2 + 0.5 * p3
fun interpolateCatmullRom(u: Float, p0: Float, p1: Float, p2: Float, p3: Float): Float {
val c1: Float = p1
val c2: Float = -0.5f * p0 + 0.5f * p2
val c3: Float = p0 - 2.5f * p1 + 2.0f * p2 - 0.5f * p3
val c4: Float = -0.5f * p0 + 1.5f * p1 - 1.5f * p2 + 0.5f * p3
return (((c4 * u + c3) * u + c2) * u + c1)
}