mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
Flippin' eck
This commit is contained in:
@@ -53,15 +53,12 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
|
||||
}
|
||||
|
||||
|
||||
App.batch.inUse {
|
||||
App.batch.inUse { val it = it as FlippingSpriteBatch
|
||||
it.color = Color.WHITE
|
||||
val previewX = (drawWidth - previewWidth).div(2f).round()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
|
||||
Toolkit.drawBoxBorder(it, previewX.toInt() - 1, previewY.toInt() - 1, previewWidth + 2, previewHeight + 2)
|
||||
it.draw(previewTexture,
|
||||
previewX,
|
||||
previewY
|
||||
)
|
||||
it.drawFlipped(previewTexture, previewX, previewY)
|
||||
val text = messages.getHeadElem() ?: ""
|
||||
App.fontGame.draw(it,
|
||||
text,
|
||||
|
||||
@@ -30,13 +30,13 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
|
||||
// load common resources to the AssetsManager
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items16") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items.tga"), 16, 16, flipY = true)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items.tga"), 16, 16, flipY = false)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items24") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items24.tga"), 24, 24, flipY = true)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items24.tga"), 24, 24, flipY = false)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("$moduleName.items48") {
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48, flipY = true)
|
||||
TextureRegionPack(ModMgr.getGdxFile(moduleName, "items/items48.tga"), 48, 48, flipY = false)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.torvald.terrarum.modulebasegame
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FloatFrameBuffer
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
@@ -43,7 +42,7 @@ import kotlin.system.exitProcess
|
||||
*/
|
||||
object IngameRenderer : Disposable {
|
||||
/** for non-private use, use with care! */
|
||||
lateinit var batch: SpriteBatch
|
||||
lateinit var batch: FlippingSpriteBatch
|
||||
private lateinit var camera: OrthographicCamera
|
||||
|
||||
private lateinit var blurWriteQuad: Mesh
|
||||
@@ -234,8 +233,8 @@ object IngameRenderer : Disposable {
|
||||
|
||||
prepLightmapRGBA()
|
||||
BlocksDrawer.renderData()
|
||||
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, particlesContainer)
|
||||
drawToRGB(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawToA(actorsRenderBehind, actorsRenderMiddle, actorsRenderMidTop, actorsRenderFront, actorsRenderOverlay, particlesContainer)
|
||||
drawOverlayActors(actorsRenderOverlay)
|
||||
}
|
||||
|
||||
@@ -360,7 +359,7 @@ object IngameRenderer : Disposable {
|
||||
|
||||
//batch.shader = if (App.getConfigBoolean("fx_dither")) IngameRenderer.shaderBayer else null
|
||||
batch.shader = null
|
||||
batch.draw(mixedOutTex, 0f, 0f)
|
||||
batch.drawFlipped(mixedOutTex, 0f, 0f)
|
||||
}
|
||||
|
||||
|
||||
@@ -423,6 +422,7 @@ object IngameRenderer : Disposable {
|
||||
actorsRenderMiddle: List<ActorWithBody>?,
|
||||
actorsRenderMidTop: List<ActorWithBody>?,
|
||||
actorsRenderFront : List<ActorWithBody>?,
|
||||
actorsOverlay : List<ActorWithBody>?,
|
||||
particlesContainer: CircularArray<ParticleBase>?
|
||||
) {
|
||||
fboRGB.inAction(null, null) { clearBuffer() }
|
||||
@@ -466,6 +466,7 @@ object IngameRenderer : Disposable {
|
||||
setCameraPosition(0f, 0f)
|
||||
BlocksDrawer.drawFront(batch.projectionMatrix) // blue coloured filter of water, etc.
|
||||
|
||||
batch.shader = null
|
||||
batch.inUse {
|
||||
FeaturesDrawer.drawEnvOverlay(batch)
|
||||
}
|
||||
@@ -520,6 +521,7 @@ object IngameRenderer : Disposable {
|
||||
actorsRenderMiddle: List<ActorWithBody>?,
|
||||
actorsRenderMidTop: List<ActorWithBody>?,
|
||||
actorsRenderFront : List<ActorWithBody>?,
|
||||
actorsOverlay : List<ActorWithBody>?,
|
||||
particlesContainer: CircularArray<ParticleBase>?
|
||||
) {
|
||||
fboA.inAction(null, null) {
|
||||
@@ -591,6 +593,8 @@ object IngameRenderer : Disposable {
|
||||
lightTex.regionWidth * lightmapDownsample,
|
||||
lightTex.regionHeight * lightmapDownsample
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -602,7 +606,7 @@ object IngameRenderer : Disposable {
|
||||
}
|
||||
|
||||
private fun drawOverlayActors(actors: List<ActorWithBody>?) {
|
||||
fboRGB_lightMixed.inAction(camera, batch) {
|
||||
fboRGB_lightMixed.inActionF(camera, batch) {
|
||||
|
||||
batch.inUse {
|
||||
batch.shader = shaderAlphaDither
|
||||
@@ -625,12 +629,11 @@ object IngameRenderer : Disposable {
|
||||
|
||||
private fun invokeInit() {
|
||||
if (!initDone) {
|
||||
batch = SpriteBatch()
|
||||
batch = FlippingSpriteBatch()
|
||||
camera = OrthographicCamera(WIDTHF, HEIGHTF)
|
||||
|
||||
camera.setToOrtho(true, WIDTHF, HEIGHTF)
|
||||
camera.update()
|
||||
Gdx.gl20.glViewport(0, 0, WIDTH, HEIGHT)
|
||||
|
||||
resize(WIDTH, HEIGHT)
|
||||
|
||||
@@ -862,9 +865,9 @@ object IngameRenderer : Disposable {
|
||||
private fun worldCamToRenderPos(): Pair<Float, Float> {
|
||||
// for some reason it does not like integer. No, really; it breaks (jitter when you move) when you try to "fix" that.
|
||||
val xoff = (WorldCamera.x / TILE_SIZE) - LightmapRenderer.camX
|
||||
val yoff = (WorldCamera.y / TILE_SIZE) - LightmapRenderer.camY
|
||||
val yoff = (WorldCamera.y / TILE_SIZE) - LightmapRenderer.camY - 1
|
||||
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF) - (xoff * TILE_SIZEF)
|
||||
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF) - (yoff * TILE_SIZEF)
|
||||
val yrem = +(WorldCamera.y.toFloat() fmod TILE_SIZEF) + (yoff * TILE_SIZEF)
|
||||
|
||||
return (xrem - LightmapRenderer.LIGHTMAP_OVERRENDER * TILE_SIZEF) to (yrem - LightmapRenderer.LIGHTMAP_OVERRENDER * TILE_SIZEF)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
private val warning32bitJavaIcon = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/32_bit_warning.tga")))
|
||||
|
||||
init {
|
||||
warning32bitJavaIcon.flip(false, true)
|
||||
warning32bitJavaIcon.flip(false, false)
|
||||
}
|
||||
|
||||
private fun loadThingsWhileIntroIsVisible() {
|
||||
|
||||
@@ -68,15 +68,12 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
|
||||
}
|
||||
|
||||
|
||||
App.batch.inUse {
|
||||
App.batch.inUse { val it = it as FlippingSpriteBatch
|
||||
it.color = Color.WHITE
|
||||
val previewX = (drawWidth - previewWidth).div(2f).round()
|
||||
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
|
||||
Toolkit.drawBoxBorder(it, previewX.toInt()-1, previewY.toInt()-1, previewWidth+2, previewHeight+2)
|
||||
it.draw(previewTexture,
|
||||
previewX,
|
||||
previewY
|
||||
)
|
||||
it.drawFlipped(previewTexture, previewX, previewY)
|
||||
val text = messages.getHeadElem() ?: ""
|
||||
App.fontGame.draw(it,
|
||||
text,
|
||||
|
||||
@@ -25,7 +25,7 @@ class FixtureLogicSignalEmitter : FixtureBase, Electric {
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("basegame-sprites-fixtures-signal_source.tga") {
|
||||
val t = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "sprites/fixtures/signal_source.tga")))
|
||||
t.flip(false, true)
|
||||
t.flip(false, false)
|
||||
/*return*/t
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
@@ -40,7 +40,7 @@ internal class FixtureTikiTorch : FixtureBase, Luminous {
|
||||
|
||||
// loading textures
|
||||
CommonResourcePool.addToLoadingList("sprites-fixtures-tiki_torch.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 16, 32, flipY = true)
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 16, 32, flipY = false)
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("particles-tiki_smoke.tga") {
|
||||
TextureRegionPack(ModMgr.getGdxFile("basegame", "particles/bigger_smoke.tga"), 16, 16)
|
||||
|
||||
@@ -62,7 +62,7 @@ object MegaRainGovernor {
|
||||
|
||||
// return composed (mega)pixmap
|
||||
val region = TextureRegion(Texture(pixmap))
|
||||
region.flip(false, true)
|
||||
region.flip(false, false)
|
||||
|
||||
/*return*/region
|
||||
}
|
||||
|
||||
@@ -78,10 +78,11 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
init {
|
||||
CommonResourcePool.addToLoadingList("terrarum-defaultsavegamethumb") {
|
||||
TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png")))
|
||||
val t = TextureRegion(Texture(Gdx.files.internal("assets/graphics/gui/savegame_thumb_placeholder.png")))
|
||||
t.flip(false, false); t
|
||||
}
|
||||
CommonResourcePool.addToLoadingList("savegame_status_icon") {
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24)
|
||||
TextureRegionPack("assets/graphics/gui/savegame_status_icon.tga", 24, 24, flipY = false)
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
}
|
||||
@@ -350,7 +351,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
|
||||
setCameraPosition(batch, camera, 0f, 0f)
|
||||
val saveTex = Texture(savePixmap)
|
||||
val saveTex = TextureRegion(Texture(savePixmap)); saveTex.flip(false, true)
|
||||
batch.inUse {
|
||||
batch.draw(saveTex, (width - uiWidth - 10) / 2f, 0f)
|
||||
|
||||
@@ -362,7 +363,7 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
||||
App.fontGame.draw(batch, controlHelp, uiX.toFloat(), controlHelperY.toFloat())
|
||||
}
|
||||
|
||||
saveTex.dispose()
|
||||
saveTex.texture.dispose()
|
||||
savePixmap.dispose()
|
||||
|
||||
batch.begin()
|
||||
@@ -538,6 +539,7 @@ class UIItemPlayerCells(
|
||||
p.reassembleSprite(skimmer, p.sprite)
|
||||
p.sprite!!.textureRegion.get(0,0).let {
|
||||
thumb = it
|
||||
thumb!!.flip(false, false)
|
||||
}
|
||||
this.sprite = p.sprite
|
||||
}
|
||||
@@ -710,7 +712,7 @@ class UIItemWorldCells(
|
||||
// draw thumbnail
|
||||
batch.color = Color.WHITE
|
||||
blendNormal(batch)
|
||||
batch.draw(thumb ?: CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb"), x, y + height, width.toFloat(), -height.toFloat())
|
||||
batch.draw(thumb ?: CommonResourcePool.getAsTextureRegion("terrarum-defaultsavegamethumb"), x, y, width.toFloat(), height.toFloat())
|
||||
// draw gradient
|
||||
blendMul(batch)
|
||||
batch.draw(grad, x + width.toFloat(), y, -width.toFloat(), height.toFloat())
|
||||
|
||||
@@ -75,7 +75,7 @@ class UINewWorld(val remoCon: UIRemoCon) : UICanvas() {
|
||||
private val goButton = UIItemTextButton(this, "MENU_LABEL_CONFIRM_BUTTON", drawX + width/2 + (width/2 - goButtonWidth) / 2, drawY + height - 24, goButtonWidth, true, alignment = UIItemTextButton.Companion.Alignment.CENTRE, hasBorder = true)
|
||||
|
||||
init {
|
||||
tex.forEach { it.flip(false, true) }
|
||||
tex.forEach { it.flip(false, false) }
|
||||
|
||||
goButton.touchDownListener = { _, _, _, _ ->
|
||||
// printdbg(this, "generate! Size=${sizeSelector.selection}, Name=${nameInput.getTextOrPlaceholder()}, Seed=${seedInput.getTextOrPlaceholder()}")
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.getKeycapConsole
|
||||
@@ -179,7 +180,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
|
||||
|
||||
|
||||
setCameraPosition(batch, camera, 0f, 0f)
|
||||
val saveTex = Texture(savePixmap)
|
||||
val saveTex = TextureRegion(Texture(savePixmap)); saveTex.flip(false, true)
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
batch.draw(saveTex, (width - uiWidth - 10) / 2f, 0f)
|
||||
@@ -191,7 +192,7 @@ class UITitleModules(val remoCon: UIRemoCon) : UICanvas() {
|
||||
App.fontGame.draw(batch, controlHelp, uiX.toFloat(), controlHelperY.toFloat())
|
||||
}
|
||||
|
||||
saveTex.dispose()
|
||||
saveTex.texture.dispose()
|
||||
savePixmap.dispose()
|
||||
|
||||
batch.begin()
|
||||
|
||||
Reference in New Issue
Block a user