mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
removing default batch on blendxxx() funs
This commit is contained in:
@@ -161,7 +161,7 @@ object LoadScreen : ScreenAdapter() {
|
|||||||
Terrarum.batch.inUse {
|
Terrarum.batch.inUse {
|
||||||
|
|
||||||
|
|
||||||
blendNormal()
|
blendNormal(Terrarum.batch)
|
||||||
Terrarum.fontGame
|
Terrarum.fontGame
|
||||||
it.color = Color.WHITE
|
it.color = Color.WHITE
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ object LoadScreen : ScreenAdapter() {
|
|||||||
Terrarum.fontGame.draw(it, textToPrint, ((textFbo.width - textWidth) / 2).toInt().toFloat(), 0f)
|
Terrarum.fontGame.draw(it, textToPrint, ((textFbo.width - textWidth) / 2).toInt().toFloat(), 0f)
|
||||||
|
|
||||||
|
|
||||||
blendMul()
|
blendMul(Terrarum.batch)
|
||||||
// draw colour overlay, flipped
|
// draw colour overlay, flipped
|
||||||
it.draw(textOverlayTex,
|
it.draw(textOverlayTex,
|
||||||
(textFbo.width - textWidth) / 2f,
|
(textFbo.width - textWidth) / 2f,
|
||||||
@@ -184,7 +184,7 @@ object LoadScreen : ScreenAdapter() {
|
|||||||
Terrarum.batch.inUse {
|
Terrarum.batch.inUse {
|
||||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) // dunno, no render without this
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) // dunno, no render without this
|
||||||
it.projectionMatrix = camera.combined
|
it.projectionMatrix = camera.combined
|
||||||
blendNormal()
|
blendNormal(Terrarum.batch)
|
||||||
|
|
||||||
|
|
||||||
// almost black background
|
// almost black background
|
||||||
@@ -251,7 +251,7 @@ object LoadScreen : ScreenAdapter() {
|
|||||||
|
|
||||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) // dunno, no render without this
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT) // dunno, no render without this
|
||||||
it.projectionMatrix = camera.combined
|
it.projectionMatrix = camera.combined
|
||||||
blendNormal()
|
blendNormal(Terrarum.batch)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -576,25 +576,25 @@ fun SpriteBatch.drawStraightLine(x: Float, y: Float, otherEnd: Float, thickness:
|
|||||||
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)
|
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)
|
||||||
|
|
||||||
|
|
||||||
fun blendMul(batch: SpriteBatch? = null) {
|
fun blendMul(batch: SpriteBatch) {
|
||||||
// will break if the colour image contains semitransparency
|
// will break if the colour image contains semitransparency
|
||||||
(batch ?: Terrarum.batch).enableBlending()
|
batch.enableBlending()
|
||||||
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
batch.setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun blendScreen(batch: SpriteBatch? = null) {
|
fun blendScreen(batch: SpriteBatch) {
|
||||||
// will break if the colour image contains semitransparency
|
// will break if the colour image contains semitransparency
|
||||||
(batch ?: Terrarum.batch).enableBlending()
|
batch.enableBlending()
|
||||||
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
|
batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun blendDisable(batch: SpriteBatch? = null) {
|
fun blendDisable(batch: SpriteBatch) {
|
||||||
(batch ?: Terrarum.batch).disableBlending()
|
batch.disableBlending()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun blendNormal(batch: SpriteBatch? = null) {
|
fun blendNormal(batch: SpriteBatch) {
|
||||||
(batch ?: Terrarum.batch).enableBlending()
|
batch.enableBlending()
|
||||||
(batch ?: Terrarum.batch).setBlendFunctionSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_SRC_ALPHA, GL20.GL_ONE)
|
batch.setBlendFunctionSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_SRC_ALPHA, GL20.GL_ONE)
|
||||||
|
|
||||||
// ALPHA *MUST BE* PREMULTIPLIED //
|
// ALPHA *MUST BE* PREMULTIPLIED //
|
||||||
|
|
||||||
@@ -648,7 +648,7 @@ object BlendMode {
|
|||||||
const val NORMAL = "normal"
|
const val NORMAL = "normal"
|
||||||
//const val MAX = "GL_MAX" // not supported by GLES -- use shader
|
//const val MAX = "GL_MAX" // not supported by GLES -- use shader
|
||||||
|
|
||||||
fun resolve(mode: String, batch: SpriteBatch? = null) {
|
fun resolve(mode: String, batch: SpriteBatch) {
|
||||||
when (mode) {
|
when (mode) {
|
||||||
SCREEN -> blendScreen(batch)
|
SCREEN -> blendScreen(batch)
|
||||||
MULTIPLY -> blendMul(batch)
|
MULTIPLY -> blendMul(batch)
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
private fun renderOverlayTexts() {
|
private fun renderOverlayTexts() {
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.shader = null
|
batch.shader = null
|
||||||
|
|
||||||
batch.color = Color.LIGHT_GRAY
|
batch.color = Color.LIGHT_GRAY
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ class UIItemInventoryElem(
|
|||||||
if (item != null || drawBackOnNull) {
|
if (item != null || drawBackOnNull) {
|
||||||
// do not highlight even if drawBackOnNull is true
|
// do not highlight even if drawBackOnNull is true
|
||||||
if (mouseUp && item != null) {
|
if (mouseUp && item != null) {
|
||||||
BlendMode.resolve(mouseoverBackBlendMode)
|
BlendMode.resolve(mouseoverBackBlendMode, batch)
|
||||||
batch.color = mouseoverBackCol
|
batch.color = mouseoverBackCol
|
||||||
}
|
}
|
||||||
// if drawBackOnNull, just draw background
|
// if drawBackOnNull, just draw background
|
||||||
else {
|
else {
|
||||||
BlendMode.resolve(backBlendMode)
|
BlendMode.resolve(backBlendMode, batch)
|
||||||
batch.color = backCol
|
batch.color = backCol
|
||||||
}
|
}
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
@@ -87,7 +87,7 @@ class UIItemInventoryElem(
|
|||||||
|
|
||||||
|
|
||||||
if (item != null && itemImage != null) {
|
if (item != null && itemImage != null) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
// item image
|
// item image
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|||||||
@@ -56,12 +56,12 @@ class UIItemInventoryElemSimple(
|
|||||||
if (item != null || drawBackOnNull) {
|
if (item != null || drawBackOnNull) {
|
||||||
// do not highlight even if drawBackOnNull is true
|
// do not highlight even if drawBackOnNull is true
|
||||||
if (mouseUp && item != null || equippedSlot != null) { // "equippedSlot != null": also highlight back if equipped
|
if (mouseUp && item != null || equippedSlot != null) { // "equippedSlot != null": also highlight back if equipped
|
||||||
BlendMode.resolve(mouseoverBackBlendMode)
|
BlendMode.resolve(mouseoverBackBlendMode, batch)
|
||||||
batch.color = mouseoverBackCol
|
batch.color = mouseoverBackCol
|
||||||
}
|
}
|
||||||
// if drawBackOnNull, just draw background
|
// if drawBackOnNull, just draw background
|
||||||
else {
|
else {
|
||||||
BlendMode.resolve(backBlendMode)
|
BlendMode.resolve(backBlendMode, batch)
|
||||||
batch.color = backCol
|
batch.color = backCol
|
||||||
}
|
}
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
@@ -72,7 +72,7 @@ class UIItemInventoryElemSimple(
|
|||||||
// and you can clearly see the quickslot UI anyway
|
// and you can clearly see the quickslot UI anyway
|
||||||
|
|
||||||
if (item != null && itemImage != null) {
|
if (item != null && itemImage != null) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
// item image
|
// item image
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package net.torvald.terrarum.modulebasegame.ui
|
|||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.Second
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blendNormal
|
import net.torvald.terrarum.blendNormal
|
||||||
import net.torvald.terrarum.Second
|
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
val textWidth = messagesList.map { Terrarum.fontGame.getWidth(it) }.sorted()[1]
|
val textWidth = messagesList.map { Terrarum.fontGame.getWidth(it) }.sorted()[1]
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
|
|||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
// light overlay or EL
|
// light overlay or EL
|
||||||
if (ELon) {
|
if (ELon) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.draw(atlas.get(0, 2), 0f, 0f)
|
batch.draw(atlas.get(0, 2), 0f, 0f)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -124,7 +124,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LCD back
|
// LCD back
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.draw(atlas.get(0, 3), 0f, 0f)
|
batch.draw(atlas.get(0, 3), 0f, 0f)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class UIInventoryFull(
|
|||||||
)
|
)
|
||||||
|
|
||||||
// encumbrance bar background
|
// encumbrance bar background
|
||||||
blendMul()
|
blendMul(batch)
|
||||||
batch.color = Color(0xa0a0a0_ff.toInt())
|
batch.color = Color(0xa0a0a0_ff.toInt())
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
xEnd - 3 - weightBarWidth,
|
xEnd - 3 - weightBarWidth,
|
||||||
@@ -197,7 +197,7 @@ class UIInventoryFull(
|
|||||||
controlHelpHeight - 6f
|
controlHelpHeight - 6f
|
||||||
)
|
)
|
||||||
// encumbrance bar
|
// encumbrance bar
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.color = if (isEncumbered) Color(0xff0000_cc.toInt()) else Color(0x00ff00_cc.toInt())
|
batch.color = if (isEncumbered) Color(0xff0000_cc.toInt()) else Color(0x00ff00_cc.toInt())
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
xEnd - 3 - weightBarWidth,
|
xEnd - 3 - weightBarWidth,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class UIItemInventoryEquippedView(
|
|||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
// sprite background
|
// sprite background
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.color = spriteViewBackCol
|
batch.color = spriteViewBackCol
|
||||||
batch.fillRect(
|
batch.fillRect(
|
||||||
posX.toFloat(), posY.toFloat(),
|
posX.toFloat(), posY.toFloat(),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class UIItemModuleInfoCell(
|
|||||||
private val numberAreaWidth = Terrarum.fontSmallNumbers.W * 3 + 4
|
private val numberAreaWidth = Terrarum.fontSmallNumbers.W * 3 + 4
|
||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
if (ModMgr.moduleInfo.containsKey(moduleName)) {
|
if (ModMgr.moduleInfo.containsKey(moduleName)) {
|
||||||
val modInfo = ModMgr.moduleInfo[moduleName]!!
|
val modInfo = ModMgr.moduleInfo[moduleName]!!
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
|
|||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
// light overlay or EL
|
// light overlay or EL
|
||||||
if (ELon) {
|
if (ELon) {
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.draw(atlas.get(0, 2), 0f, 0f)
|
batch.draw(atlas.get(0, 2), 0f, 0f)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -73,7 +73,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LCD back
|
// LCD back
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
batch.draw(atlas.get(0, 3), 0f, 0f)
|
batch.draw(atlas.get(0, 3), 0f, 0f)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class UITitleCharactersList : UICanvas() {
|
|||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
mouduleArea.render(batch, camera)
|
mouduleArea.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class UITitleModules : UICanvas() {
|
|||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
mouduleArea.render(batch, camera)
|
mouduleArea.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
Terrarum.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
Terrarum.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
||||||
Terrarum.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
Terrarum.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||||
|
|
||||||
blendScreen()
|
blendScreen(batch)
|
||||||
for (c in 0..2) {
|
for (c in 0..2) {
|
||||||
for (i in 0..255) {
|
for (i in 0..255) {
|
||||||
var histogram_value = if (i == 255) 0 else histogram.get(c)[i]
|
var histogram_value = if (i == 255) 0 else histogram.get(c)[i]
|
||||||
@@ -291,7 +291,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
batch.fillRect(bar_x, bar_y, bar_w, bar_h)
|
batch.fillRect(bar_x, bar_y, bar_w, bar_h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawGamepadAxis(batch: SpriteBatch, axisX: Float, axisY: Float, uiX: Int, uiY: Int) {
|
private fun drawGamepadAxis(batch: SpriteBatch, axisX: Float, axisY: Float, uiX: Int, uiY: Int) {
|
||||||
@@ -307,7 +307,7 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
val padName = if (Terrarum.controller!!.name.isEmpty()) "Gamepad"
|
val padName = if (Terrarum.controller!!.name.isEmpty()) "Gamepad"
|
||||||
else Terrarum.controller!!.name
|
else Terrarum.controller!!.name
|
||||||
|
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
batch.end()
|
batch.end()
|
||||||
Terrarum.inShapeRenderer {
|
Terrarum.inShapeRenderer {
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ open class UIItemImageButton(
|
|||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
// draw background
|
// draw background
|
||||||
if (mouseUp) {
|
if (mouseUp) {
|
||||||
BlendMode.resolve(activeBackBlendMode)
|
BlendMode.resolve(activeBackBlendMode, batch)
|
||||||
batch.color = activeBackCol
|
batch.color = activeBackCol
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BlendMode.resolve(buttonBackBlendMode)
|
BlendMode.resolve(buttonBackBlendMode, batch)
|
||||||
batch.color = buttonBackCol
|
batch.color = buttonBackCol
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ open class UIItemImageButton(
|
|||||||
|
|
||||||
|
|
||||||
// draw image
|
// draw image
|
||||||
blendNormal()
|
blendNormal(batch)
|
||||||
|
|
||||||
batch.color = if (highlighted) highlightCol
|
batch.color = if (highlighted) highlightCol
|
||||||
else if (mouseUp) activeCol
|
else if (mouseUp) activeCol
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import com.badlogic.gdx.graphics.Camera
|
|||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.terrarum.BlendMode
|
import net.torvald.terrarum.BlendMode
|
||||||
import net.torvald.terrarum.fillRect
|
|
||||||
import net.torvald.terrarum.Second
|
import net.torvald.terrarum.Second
|
||||||
|
import net.torvald.terrarum.fillRect
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,11 +106,11 @@ class UIItemList<Item: UIItem>(
|
|||||||
|
|
||||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||||
batch.color = backgroundCol
|
batch.color = backgroundCol
|
||||||
BlendMode.resolve(backgroundBlendMode)
|
BlendMode.resolve(backgroundBlendMode, batch)
|
||||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||||
|
|
||||||
batch.color = highlightBackCol
|
batch.color = highlightBackCol
|
||||||
BlendMode.resolve(highlightBackBlendMode)
|
BlendMode.resolve(highlightBackBlendMode, batch)
|
||||||
if (highlightY != null) {
|
if (highlightY != null) {
|
||||||
batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), UIItemTextButton.height.toFloat())
|
batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), UIItemTextButton.height.toFloat())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user