From 04db52ca3aad439e4d68e098225aef63639b2d22 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 3 Jul 2017 02:55:33 +0900 Subject: [PATCH] fixed bug: things go dark as inventory is opened Not cloning the color when MULing was the culprit --- src/net/torvald/terrarum/StateInGameGDX.kt | 17 +++++++++------- src/net/torvald/terrarum/TerrarumGDX.kt | 4 ++-- .../torvald/terrarum/UIItemInventoryElem.kt | 1 + .../gameactors/PlayerBuilderSigrid.kt | 2 +- src/net/torvald/terrarum/ui/UIInventory.kt | 1 - .../torvald/terrarum/ui/UIItemTextButton.kt | 20 +++++++++---------- .../terrarum/ui/UIItemTextButtonList.kt | 16 +++++++-------- .../terrarum/worlddrawer/BlocksDrawer_old.kt | 9 ++++++++- work_files/UI/musicmachine_UI.psd | 3 +++ 9 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 work_files/UI/musicmachine_UI.psd diff --git a/src/net/torvald/terrarum/StateInGameGDX.kt b/src/net/torvald/terrarum/StateInGameGDX.kt index fe71b9e6f..3fc6e7999 100644 --- a/src/net/torvald/terrarum/StateInGameGDX.kt +++ b/src/net/torvald/terrarum/StateInGameGDX.kt @@ -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() } diff --git a/src/net/torvald/terrarum/TerrarumGDX.kt b/src/net/torvald/terrarum/TerrarumGDX.kt index 764eb0b9e..efd43d903 100644 --- a/src/net/torvald/terrarum/TerrarumGDX.kt +++ b/src/net/torvald/terrarum/TerrarumGDX.kt @@ -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) diff --git a/src/net/torvald/terrarum/UIItemInventoryElem.kt b/src/net/torvald/terrarum/UIItemInventoryElem.kt index 9f5a73624..3fbb9fb18 100644 --- a/src/net/torvald/terrarum/UIItemInventoryElem.kt +++ b/src/net/torvald/terrarum/UIItemInventoryElem.kt @@ -119,6 +119,7 @@ class UIItemInventoryElem( } } + } override fun keyDown(keycode: Int): Boolean { diff --git a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt index c83e5a877..8796cf0f0 100644 --- a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt +++ b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt @@ -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 diff --git a/src/net/torvald/terrarum/ui/UIInventory.kt b/src/net/torvald/terrarum/ui/UIInventory.kt index c7ecb60ee..78c9c749c 100644 --- a/src/net/torvald/terrarum/ui/UIInventory.kt +++ b/src/net/torvald/terrarum/ui/UIInventory.kt @@ -216,7 +216,6 @@ class UIInventory( controlHelpHeight - 5f ) } - } /** Persuade the UI to rebuild its item list */ diff --git a/src/net/torvald/terrarum/ui/UIItemTextButton.kt b/src/net/torvald/terrarum/ui/UIItemTextButton.kt index ed01ca795..d023e8a70 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButton.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButton.kt @@ -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 { diff --git a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt index 156fda112..1b7d64d37 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextButtonList.kt @@ -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 { diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt index 76538d616..3cf98728e 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt @@ -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 } /** diff --git a/work_files/UI/musicmachine_UI.psd b/work_files/UI/musicmachine_UI.psd new file mode 100644 index 000000000..e7ce9a254 --- /dev/null +++ b/work_files/UI/musicmachine_UI.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e302cab4aeba30bbd6ab7ad0c88c55dd36ac325a8b5ae1eb2309f82a1cda062 +size 711924