fixed bug: things go dark as inventory is opened

Not cloning the color when MULing was the culprit
This commit is contained in:
minjaesong
2017-07-03 02:55:33 +09:00
parent 9b32cf63ff
commit 2ea3ce0c67
9 changed files with 41 additions and 32 deletions

View File

@@ -390,10 +390,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work camera.position.set(WorldCamera.gdxCamX, WorldCamera.gdxCamY, 0f) // make camara work
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
batch.color = Color.WHITE
blendNormal() blendNormal()
@@ -428,7 +425,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
blendNormal() blendNormal()
else else
blendMul() blendMul()
LightmapRenderer.draw(batch) //LightmapRenderer.draw(batch)
////////////////////// //////////////////////
@@ -449,11 +446,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
///////////////////////// /////////////////////////
// draw to main screen // // draw to main screen //
///////////////////////// /////////////////////////
blendNormal()
batch.inUse { batch.inUse {
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
batch.color = Color.WHITE
blendNormal()
///////////////////////////////// /////////////////////////////////
@@ -462,6 +460,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
WeatherMixer.render(batch) WeatherMixer.render(batch)
batch.color = Color.WHITE
val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom! val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom!
batch.draw(tex, 0f, 0f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat()) batch.draw(tex, 0f, 0f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
@@ -529,11 +528,15 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
// draw some overlays (UI) // // draw some overlays (UI) //
///////////////////////////// /////////////////////////////
//uiContainer.forEach { if (it != consoleHandler) it.render(batch) } // FIXME draws black of grey coloured box on top right uiContainer.forEach { if (it != consoleHandler) it.render(batch) } // FIXME draws black of grey coloured box on top right
batch.color = Color.WHITE
debugWindow.render(batch) debugWindow.render(batch)
// make sure console draws on top of other UIs // make sure console draws on top of other UIs
consoleHandler.render(batch) consoleHandler.render(batch)
notifier.render(batch) notifier.render(batch)
blendNormal()
} }

View File

@@ -88,7 +88,7 @@ object TerrarumGDX : ApplicationAdapter() {
/** /**
* To be used with physics simulator * To be used with physics simulator
*/ */
val TARGET_FPS = 50 val TARGET_FPS = 33.333333333333333333333
/** /**
* To be used with render, to achieve smooth frame drawing * To be used with render, to achieve smooth frame drawing
@@ -526,7 +526,7 @@ inline fun SpriteBatch.drawStraightLine(x: Float, y: Float, p2: Float, thickness
infix fun Color.mul(other: Color): Color = this.mul(other) infix fun Color.mul(other: Color): Color = this.cpy().mul(other)

View File

@@ -119,6 +119,7 @@ class UIItemInventoryElem(
} }
} }
} }
override fun keyDown(keycode: Int): Boolean { override fun keyDown(keycode: Int): Boolean {

View File

@@ -32,7 +32,7 @@ object PlayerBuilderSigrid {
p.actorValue[AVKey.SPEEDBUFF] = 1.0 p.actorValue[AVKey.SPEEDBUFF] = 1.0
p.actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE p.actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE
p.actorValue[AVKey.ACCELBUFF] = 1.0 p.actorValue[AVKey.ACCELBUFF] = 1.0
p.actorValue[AVKey.JUMPPOWER] = 5.2 p.actorValue[AVKey.JUMPPOWER] = 9.0
p.actorValue[AVKey.BASEMASS] = 80.0 p.actorValue[AVKey.BASEMASS] = 80.0
p.actorValue[AVKey.SCALEBUFF] = 1.0 // Constant 1.0 for player, meant to be used by random mobs p.actorValue[AVKey.SCALEBUFF] = 1.0 // Constant 1.0 for player, meant to be used by random mobs

View File

@@ -216,7 +216,6 @@ class UIInventory(
controlHelpHeight - 5f controlHelpHeight - 5f
) )
} }
} }
/** Persuade the UI to rebuild its item list */ /** Persuade the UI to rebuild its item list */

View File

@@ -68,18 +68,16 @@ class UIItemTextButton(
blendNormal() blendNormal()
batch.inUse { mouseOver = mouseUp
mouseOver = mouseUp batch.color = if (highlighted) highlightCol
batch.color = if (highlighted) highlightCol else if (mouseOver) activeCol
else if (mouseOver) activeCol else inactiveCol
else inactiveCol
font.draw(batch, font.draw(batch,
label, label,
posX.toFloat() + width.minus(textW).div(2) + (preGapX - postGapX).div(2), posX.toFloat() + width.minus(textW).div(2) + (preGapX - postGapX).div(2),
posY.toFloat() + height / 4 posY.toFloat() + height / 4
) )
}
} }
override fun keyDown(keycode: Int): Boolean { override fun keyDown(keycode: Int): Boolean {

View File

@@ -155,18 +155,16 @@ class UIItemTextButtonList(
buttons.forEach { it.render(batch) } buttons.forEach { it.render(batch) }
batch.inUse { if (iconSpriteSheet != null) {
if (iconSpriteSheet != null) { val iconY = (buttons[1].height - iconCellHeight) / 2
val iconY = (buttons[1].height - iconCellHeight) / 2 batch.color = iconCol
batch.color = iconCol
iconSpriteSheetIndices!!.forEachIndexed { counter, imageIndex -> iconSpriteSheetIndices!!.forEachIndexed { counter, imageIndex ->
batch.draw(iconSpriteSheet.get(imageIndex, 0), 32f, buttons[counter].posY + iconY.toFloat()) batch.draw(iconSpriteSheet.get(imageIndex, 0), 32f, buttons[counter].posY + iconY.toFloat())
}
} }
batch.color = backgroundCol
} }
batch.color = backgroundCol
} }
override fun keyDown(keycode: Int): Boolean { override fun keyDown(keycode: Int): Boolean {

View File

@@ -390,6 +390,7 @@ object BlocksDrawer {
var zeroTileCounter = 0 var zeroTileCounter = 0
val originalBatchColour = batch.color.cpy()
batch.color = color batch.color = color
// loop // loop
@@ -459,12 +460,14 @@ object BlocksDrawer {
// draw a tile // draw a tile
if (drawModeTilesBlendMul) { if (drawModeTilesBlendMul) {
if (BlocksDrawer.isBlendMul(thisTile)) { if (BlocksDrawer.isBlendMul(thisTile)) {
batch.color = color
drawTile(batch, mode, x, y, thisTileX, thisTileY) drawTile(batch, mode, x, y, thisTileX, thisTileY)
} }
} }
else { else {
// do NOT add "if (!isBlendMul(thisTile))"! // do NOT add "if (!isBlendMul(thisTile))"!
// or else they will not look like they should be when backed with wall // or else they will not look like they should be when backed with wall
batch.color = color
drawTile(batch, mode, x, y, thisTileX, thisTileY) drawTile(batch, mode, x, y, thisTileX, thisTileY)
} }
@@ -475,6 +478,7 @@ object BlocksDrawer {
val stage = (breakage / maxHealth).times(breakAnimSteps).roundInt() val stage = (breakage / maxHealth).times(breakAnimSteps).roundInt()
// actual drawing // actual drawing
if (stage > 0) { if (stage > 0) {
batch.color = color
drawTile(batch, mode, x, y, 5 + stage, 0) drawTile(batch, mode, x, y, 5 + stage, 0)
} }
} }
@@ -485,7 +489,7 @@ object BlocksDrawer {
else { else {
zeroTileCounter++ // unused for now zeroTileCounter++ // unused for now
batch.color = Color.BLACK //batch.color = Color.BLACK
batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF) batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF)
@@ -498,6 +502,9 @@ object BlocksDrawer {
} }
} }
batch.color = originalBatchColour
} }
/** /**

BIN
work_files/UI/musicmachine_UI.psd LFS Normal file

Binary file not shown.