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 65ef9c2787
commit 04db52ca3a
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.update()
batch.projectionMatrix = camera.combined
batch.color = Color.WHITE
blendNormal()
@@ -428,7 +425,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
blendNormal()
else
blendMul()
LightmapRenderer.draw(batch)
//LightmapRenderer.draw(batch)
//////////////////////
@@ -449,11 +446,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
/////////////////////////
// draw to main screen //
/////////////////////////
blendNormal()
batch.inUse {
camera.position.set(TerrarumGDX.HALFW.toFloat(), TerrarumGDX.HALFH.toFloat(), 0f) // make camara work
camera.update()
batch.projectionMatrix = camera.combined
batch.color = Color.WHITE
blendNormal()
/////////////////////////////////
@@ -462,6 +460,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
WeatherMixer.render(batch)
batch.color = Color.WHITE
val tex = worldDrawFrameBuffer.colorBufferTexture // TODO zoom!
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) //
/////////////////////////////
//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)
// make sure console draws on top of other UIs
consoleHandler.render(batch)
notifier.render(batch)
blendNormal()
}

View File

@@ -88,7 +88,7 @@ object TerrarumGDX : ApplicationAdapter() {
/**
* 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
@@ -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 {

View File

@@ -32,7 +32,7 @@ object PlayerBuilderSigrid {
p.actorValue[AVKey.SPEEDBUFF] = 1.0
p.actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE
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.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
)
}
}
/** Persuade the UI to rebuild its item list */

View File

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

View File

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

View File

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