Flippin' eck

This commit is contained in:
minjaesong
2021-12-13 23:22:17 +09:00
parent 83f78edc2a
commit 254bf814a9
28 changed files with 171 additions and 87 deletions

View File

@@ -132,36 +132,39 @@ class SpriteAnimation(@Transient val parentActor: ActorWithBody) : Disposable {
// batch.color = colorFilter
// val realTY = (parentActor.hitboxTranslateY + (cellHeight - parentActor.baseHitboxH)) * scale
val tx = (parentActor.hitboxTranslateX) * scale
val txF = (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale
val ty = (parentActor.hitboxTranslateY + (cellHeight - parentActor.baseHitboxH)) * scale
val tyF = (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale
if (flipHorizontal && !flipVertical) {
if (flipHorizontal && flipVertical) {
batch.draw(region,
FastMath.floor(posX).toFloat() + (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale,
FastMath.floor(posY).toFloat() + (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale,
FastMath.floor(posX).toFloat() + txF,
FastMath.floor(posY).toFloat() + tyF,
-FastMath.floor(cellWidth * scale).toFloat(),
-FastMath.floor(cellHeight * scale).toFloat()
)
}
else if (flipHorizontal && flipVertical) {
else if (flipHorizontal && !flipVertical) {
batch.draw(region,
FastMath.floor(posX).toFloat() + (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale,
FastMath.floor(posY).toFloat() - (parentActor.hitboxTranslateY) * scale,
FastMath.floor(posX).toFloat() + txF,
FastMath.floor(posY).toFloat() - ty,
-FastMath.floor(cellWidth * scale).toFloat(),
FastMath.floor(cellHeight * scale).toFloat()
)
}
else if (!flipHorizontal && !flipVertical) {
else if (!flipHorizontal && flipVertical) {
batch.draw(region,
FastMath.floor(posX).toFloat() - (parentActor.hitboxTranslateX) * scale,
FastMath.floor(posY).toFloat() + (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale,
FastMath.floor(posX).toFloat() - tx,
FastMath.floor(posY).toFloat() + tyF,
FastMath.floor(cellWidth * scale).toFloat(),
-FastMath.floor(cellHeight * scale).toFloat()
)
}
else {
batch.draw(region,
FastMath.floor(posX).toFloat() - (parentActor.hitboxTranslateX) * scale,
FastMath.floor(posY).toFloat() - (parentActor.hitboxTranslateY) * scale,
FastMath.floor(posX).toFloat() - tx,
FastMath.floor(posY).toFloat() - ty,
FastMath.floor(cellWidth * scale).toFloat(),
FastMath.floor(cellHeight * scale).toFloat()
)

View File

@@ -184,8 +184,11 @@ public class App implements ApplicationListener {
public static CreateTileAtlas tileMaker;
/** Vanilla */
public static TerrarumSansBitmap fontGame;
/** Vertically flipped */
public static TerrarumSansBitmap fontGameFBO;
/** Big interchar */
public static TerrarumSansBitmap fontUITitle;
public static TinyAlphNum fontSmallNumbers;
@@ -232,11 +235,11 @@ public class App implements ApplicationListener {
public static Mesh fullscreenQuad;
private static OrthographicCamera camera;
private static SpriteBatch logoBatch;
private static FlippingSpriteBatch logoBatch;
public static TextureRegion logo;
public static AudioDevice audioDevice;
public static SpriteBatch batch;
public static FlippingSpriteBatch batch;
public static ShapeRenderer shapeRender;
private static com.badlogic.gdx.graphics.Color gradWhiteTop = new com.badlogic.gdx.graphics.Color(0xf8f8f8ff);
@@ -397,11 +400,11 @@ public class App implements ApplicationListener {
glInfo.create();
CommonResourcePool.INSTANCE.addToLoadingList("blockmarkings_common", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16, 0, 0, 0, 0, false, false, true));
CommonResourcePool.INSTANCE.addToLoadingList("blockmarkings_common", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16, 0, 0, 0, 0, false, false, false));
CommonResourcePool.INSTANCE.addToLoadingList("blockmarking_actor", () -> new BlockMarkerActor());
CommonResourcePool.INSTANCE.addToLoadingList("loading_circle_64", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/loading_circle_64.tga"), 64, 64, 0, 0, 0, 0, false, false, true));
CommonResourcePool.INSTANCE.addToLoadingList("inline_loading_spinner", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/inline_loading_spinner.tga"), 20, 20, 0, 0, 0, 0, false, false, true));
CommonResourcePool.INSTANCE.addToLoadingList("inventory_category", () -> new TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20, 0, 0, 0, 0, false, false, true));
CommonResourcePool.INSTANCE.addToLoadingList("loading_circle_64", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/loading_circle_64.tga"), 64, 64, 0, 0, 0, 0, false, false, false));
CommonResourcePool.INSTANCE.addToLoadingList("inline_loading_spinner", () -> new TextureRegionPack(Gdx.files.internal("assets/graphics/gui/inline_loading_spinner.tga"), 20, 20, 0, 0, 0, 0, false, false, false));
CommonResourcePool.INSTANCE.addToLoadingList("inventory_category", () -> new TextureRegionPack("./assets/graphics/gui/inventory/category.tga", 20, 20, 0, 0, 0, 0, false, false, false));
CommonResourcePool.INSTANCE.addToLoadingList("title_health1", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_take_a_break.tga")));
CommonResourcePool.INSTANCE.addToLoadingList("title_health2", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_distance.tga")));
@@ -409,17 +412,17 @@ public class App implements ApplicationListener {
// set basis of draw
logoBatch = new SpriteBatch();
logoBatch = new FlippingSpriteBatch();
camera = new OrthographicCamera((scr.getWf()), (scr.getHf()));
batch = new SpriteBatch();
batch = new FlippingSpriteBatch();
shapeRender = new ShapeRenderer();
initViewPort(scr.getWidth(), scr.getHeight());
// logo here :p
logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga")));
logo.flip(false, true);
logo.flip(false, false);
// set GL graphics constants
for (int i = 0; i < ditherPatterns.length; i++) {
@@ -515,11 +518,11 @@ public class App implements ApplicationListener {
environment = RunningEnvironment.PC;
}*/
fontGame = new TerrarumSansBitmap(FONT_DIR, false, true, false,
fontGame = new TerrarumSansBitmap(FONT_DIR, false, false, false,
false,
256, false, 0.5f, false
);
fontUITitle = new TerrarumSansBitmap(FONT_DIR, false, true, false,
fontUITitle = new TerrarumSansBitmap(FONT_DIR, false, false, false,
false,
64, false, 0.5f, false
);
@@ -694,8 +697,8 @@ public class App implements ApplicationListener {
Texture tex2 = CommonResourcePool.INSTANCE.getAsTexture("title_health2");
int virtualHeight = scr.getHeight() - logoPosY - logo.getRegionHeight() / 4;
int virtualHeightOffset = scr.getHeight() - virtualHeight;
logoBatch.draw(tex1, (drawWidth - tex1.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) - 16, tex1.getWidth(), -tex1.getHeight());
logoBatch.draw(tex2, (drawWidth - tex2.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) + 16 + tex2.getHeight(), tex2.getWidth(), -tex2.getHeight());
logoBatch.drawFlipped(tex1, (drawWidth - tex1.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) - 16, tex1.getWidth(), -tex1.getHeight());
logoBatch.drawFlipped(tex2, (drawWidth - tex2.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) + 16 + tex2.getHeight(), tex2.getWidth(), -tex2.getHeight());
}
else {

View File

@@ -23,27 +23,27 @@ object CommonResourcePool {
init {
addToLoadingList("itemplaceholder_16") {
val t = TextureRegion(Texture("assets/item_kari_16.tga"))
t.flip(false, true)
t.flip(false, false)
/*return*/t
}
addToLoadingList("itemplaceholder_24") {
val t = TextureRegion(Texture("assets/item_kari_24.tga"))
t.flip(false, true)
t.flip(false, false)
/*return*/t
}
addToLoadingList("itemplaceholder_32") {
val t = TextureRegion(Texture("assets/item_kari_32.tga"))
t.flip(false, true)
t.flip(false, false)
/*return*/t
}
addToLoadingList("itemplaceholder_48") {
val t = TextureRegion(Texture("assets/item_kari_48.tga"))
t.flip(false, true)
t.flip(false, false)
/*return*/t
}
addToLoadingList("test_texture") {
val t = TextureRegion(Texture("assets/test_texture.tga"))
t.flip(false, true)
t.flip(false, false)
/*return*/t
}
loadAll()

View File

@@ -0,0 +1,52 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
/**
* Don't flip the assets! Flip the draw command instead!
*
* Created by minjaesong on 2021-12-13.
*/
class FlippingSpriteBatch : SpriteBatch() {
/**
* This function draws the flipped version of the image by giving flipped uv-coord to the SpriteBatch
*/
override fun draw(texture: Texture, x: Float, y: Float, width: Float, height: Float) =
draw(texture, x, y, width, height, 0f, 0f, 1f, 1f)
override fun draw(texture: Texture, x: Float, y: Float) =
draw(texture, x, y, texture.width.toFloat(), texture.height.toFloat(), 0f, 0f, 1f, 1f)
fun drawFlipped(texture: Texture, x: Float, y: Float, width: Float, height: Float) =
draw(texture, x, y, width, height, 0f, 1f, 1f, 0f)
fun drawFlipped(texture: Texture, x: Float, y: Float) =
draw(texture, x, y, texture.width.toFloat(), texture.height.toFloat(), 0f, 1f, 1f, 0f)
/**
* This function does obey the flipping set to the TextureRegion and try to draw flipped version of it,
* without touching the flipping setting of the given region.
*/
override fun draw(region: TextureRegion, x: Float, y: Float, width: Float, height: Float) =
draw(region.texture, x, y, width, height, region.u, region.v, region.u2, region.v2)
override fun draw(region: TextureRegion, x: Float, y: Float) =
draw(region.texture, x, y, region.regionWidth.toFloat(), region.regionHeight.toFloat(), region.u, region.v, region.u2, region.v2)
fun drawFlipped(region: TextureRegion, x: Float, y: Float, width: Float, height: Float) =
draw(region.texture, x, y, width, height, region.u, region.v2, region.u2, region.v)
fun drawFlipped(region: TextureRegion, x: Float, y: Float) =
draw(region.texture, x, y, region.regionWidth.toFloat(), region.regionHeight.toFloat(), region.u, region.v2, region.u2, region.v)
/**
* NOTE TO SELF:
*
* It seems that original SpriteBatch Y-flips when it's drawing a texture, but NOT when it's drawing a textureregion
*
* (textureregion's default uv-coord is (0,0,1,1)
*/
}

View File

@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.badlogic.gdx.math.Matrix4
@@ -21,7 +20,7 @@ import net.torvald.terrarum.ui.Toolkit
*/
object PostProcessor : Disposable {
private lateinit var batch: SpriteBatch // not nulling to save some lines of code
private lateinit var batch: FlippingSpriteBatch // not nulling to save some lines of code
private lateinit var shapeRenderer: ShapeRenderer
private lateinit var camera: OrthographicCamera
@@ -65,7 +64,7 @@ object PostProcessor : Disposable {
debugUI.setPosition(0, 0)
batch = SpriteBatch()
batch = FlippingSpriteBatch()
camera = OrthographicCamera(App.scr.wf, App.scr.hf)
camera.setToOrtho(true)

View File

@@ -326,6 +326,27 @@ inline fun FrameBuffer.inAction(camera: OrthographicCamera?, batch: SpriteBatch?
batch?.projectionMatrix = camera?.combined
}
/**
* Vertically flipped version of [FrameBuffer.inAction]
*/
inline fun FrameBuffer.inActionF(camera: OrthographicCamera?, batch: SpriteBatch?, action: (FrameBuffer) -> Unit) {
//this.begin()
FrameBufferManager.begin(this)
camera?.setToOrtho(false, this.width.toFloat(), this.height.toFloat())
camera?.position?.set((this.width / 2f).round(), (this.height / 2f).round(), 0f) // TODO floor? ceil? round?
camera?.update()
batch?.projectionMatrix = camera?.combined
action(this)
//this.end()
FrameBufferManager.end()
camera?.setToOrtho(true, App.scr.wf, App.scr.hf)
camera?.update()
batch?.projectionMatrix = camera?.combined
}
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)

View File

@@ -106,7 +106,7 @@ object IME {
}
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20, flipY = true)
val iconSheet = TextureRegionPack("assets/graphics/gui/ime_icons_by_language.tga", 20, 20, flipY = false)
val iconPixmap = Pixmap(Gdx.files.internal("assets/graphics/gui/ime_icons_by_language.tga"))
for (k in 0 until iconPixmap.height step 20) {
val langCode = StringBuilder()

View File

@@ -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,

View File

@@ -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()

View File

@@ -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)
}

View File

@@ -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() {

View File

@@ -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,

View File

@@ -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()

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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())

View File

@@ -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()}")

View File

@@ -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()

View File

@@ -7,10 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.graphics.glutils.FloatFrameBuffer
import com.badlogic.gdx.utils.Disposable
import net.torvald.random.HQRNG
import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.FrameBufferManager
import net.torvald.terrarum.inAction
import net.torvald.terrarum.*
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -43,7 +40,7 @@ object Toolkit : Disposable {
private lateinit var blurWriteQuad2: Mesh
private lateinit var blurWriteQuad4: Mesh
val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36, flipY = true)
val baloonTile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36, flipY = false)
val textureWhiteSquare = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga"))
val textureWhiteCircle = Texture(Gdx.files.internal("assets/graphics/circle_512.tga"))
@@ -235,7 +232,7 @@ object Toolkit : Disposable {
batch.begin()
batch.shader = null
batch.draw(fboBlur.colorBufferTexture, x.toFloat(), y.toFloat())
(batch as FlippingSpriteBatch).drawFlipped(fboBlur.colorBufferTexture, x.toFloat(), y.toFloat())
}
fun drawBaloon(batch: SpriteBatch, x: Float, y: Float, w: Float, h: Float) {

View File

@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.App
import net.torvald.terrarum.FlippingSpriteBatch
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.modulebasegame.TerrarumIngame

View File

@@ -34,11 +34,11 @@ class UIItemModuleInfoCell(
private val modAuthor = modProp.author
init {
modIcon.flip(false, true)
modIcon.flip(false, false)
CommonResourcePool.addToLoadingList("basegame_errored_icon32") {
val t = TextureRegion(Texture(ModMgr.getGdxFile("basegame", "gui/modwitherror.tga")))
t.flip(false, true)
t.flip(false, false)
t
}
CommonResourcePool.loadAll()

View File

@@ -24,12 +24,12 @@ class UIItemToggleButton(
init {
CommonResourcePool.addToLoadingList("ui_item_toggler_base") {
val t = TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_back.tga")))
t.flip(false, true)
t.flip(false, false)
t
}
CommonResourcePool.addToLoadingList("ui_item_toggler_handle") {
val t = TextureRegion(Texture(Gdx.files.internal("./assets/graphics/gui/toggler_switch.tga")))
t.flip(false, true)
t.flip(false, false)
t
}
CommonResourcePool.loadAll()

View File

@@ -3,7 +3,6 @@ package net.torvald.terrarum.weather
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath
import net.torvald.gdx.graphics.Cvec
import net.torvald.random.HQRNG
@@ -121,7 +120,7 @@ internal object WeatherMixer : RNGConsumer {
/**
* Sub-portion of IngameRenderer. You are not supposed to directly deal with this.
*/
internal fun render(camera: Camera, batch: SpriteBatch, world: GameWorld) {
internal fun render(camera: Camera, batch: FlippingSpriteBatch, world: GameWorld) {
val parallaxZeroPos = (world.height / 3f) * 0.8888f
val parallaxDomainSize = world.height / 4f
@@ -179,8 +178,8 @@ internal object WeatherMixer : RNGConsumer {
batch.inUse {
it.shader = null
it.draw(skyboxTexture, 0f, -App.scr.halfhf, App.scr.wf, App.scr.hf * 2f) // because of how the linear filter works, we extend the image by two
batch.shader = null
batch.drawFlipped(skyboxTexture, 0f, -App.scr.halfhf, App.scr.wf, App.scr.hf * 2f) // because of how the linear filter works, we extend the image by two
}
// don't use shader to just fill the whole screen... frag shader will be called a million times and it's best to not burden it