fixing list UI's colours; buildingmaker palette wip

This commit is contained in:
minjaesong
2019-02-14 15:55:31 +09:00
parent 72dbc18128
commit fcf9aa1b79
14 changed files with 229 additions and 64 deletions

View File

@@ -329,19 +329,32 @@ public class AppLoader implements ApplicationListener {
try { try {
gamepad = new XinputControllerAdapter(XInputDevice.getDeviceFor(0)); gamepad = new XinputControllerAdapter(XInputDevice.getDeviceFor(0));
} }
catch (Throwable e) { } catch (Throwable e) {
gamepad = null;
}
// nullify if not actually connected
if (!((XinputControllerAdapter) gamepad).getC().isConnected()) {
gamepad = null;
}
} }
if (gamepad == null) { if (gamepad == null) {
try { try {
gamepad = new GdxControllerAdapter(Controllers.getControllers().get(0)); gamepad = new GdxControllerAdapter(Controllers.getControllers().get(0));
} }
catch (Throwable e) { } catch (Throwable e) {
gamepad = null;
}
} }
if (gamepad != null) { if (gamepad != null) {
environment = RunningEnvironment.CONSOLE; environment = RunningEnvironment.CONSOLE;
} }
else {
environment = RunningEnvironment.PC;
}
// make loading list // make loading list

View File

@@ -54,6 +54,8 @@ class UIItemInventoryCatBar(
inventoryUI, inventoryUI,
catIcons.get(catArrangement[index], 0), catIcons.get(catArrangement[index], 0),
activeBackCol = Color(0), activeBackCol = Color(0),
backgroundCol = Color(0),
highlightBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL, activeBackBlendMode = BlendMode.NORMAL,
posX = posX + iconPosX, posX = posX + iconPosX,
posY = posY + iconPosY, posY = posY + iconPosY,
@@ -84,10 +86,12 @@ class UIItemInventoryCatBar(
inventoryUI, inventoryUI,
catIcons.get(iconIndex[index], 0), catIcons.get(iconIndex[index], 0),
activeBackCol = Color(0), activeBackCol = Color(0),
backgroundCol = Color(0),
highlightBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL, activeBackBlendMode = BlendMode.NORMAL,
posX = iconPosX, posX = iconPosX,
posY = posY + iconPosY, posY = posY + iconPosY,
buttonCol = if (index == 0 || index == 3) Color.WHITE else Color(0xffffff7f.toInt()), inactiveCol = if (index == 0 || index == 3) Color.WHITE else Color(0xffffff7f.toInt()),
activeCol = if (index == 0 || index == 3) Color(0xfff066_ff.toInt()) else Color(0xffffff7f.toInt()), activeCol = if (index == 0 || index == 3) Color(0xfff066_ff.toInt()) else Color(0xffffff7f.toInt()),
highlightable = (index == 0 || index == 3) highlightable = (index == 0 || index == 3)
) )

View File

@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
import net.torvald.terrarum.modulebasegame.ui.Notification import net.torvald.terrarum.modulebasegame.ui.Notification
import net.torvald.terrarum.modulebasegame.ui.UIEditorPalette import net.torvald.terrarum.modulebasegame.ui.UIPaletteSelector
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UINSMenu import net.torvald.terrarum.ui.UINSMenu
@@ -82,7 +82,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
val uiToolbox = UINSMenu("Menu", 100, menuYaml) val uiToolbox = UINSMenu("Menu", 100, menuYaml)
val notifier = Notification() val notifier = Notification()
val uiPalette = UIEditorPalette() val uiPaletteSelector = UIPaletteSelector()
val uiPalette = UIBuildingMakerBlockChooser(this)
val uiContainer = ArrayList<UICanvas>() val uiContainer = ArrayList<UICanvas>()
@@ -146,8 +147,9 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
actorsRenderOverlay.add(blockPointingCursor) actorsRenderOverlay.add(blockPointingCursor)
uiContainer.add(uiToolbox) uiContainer.add(uiToolbox)
uiContainer.add(uiPalette) uiContainer.add(uiPaletteSelector)
uiContainer.add(notifier) uiContainer.add(notifier)
uiContainer.add(uiPalette)
@@ -155,8 +157,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
uiToolbox.isVisible = true uiToolbox.isVisible = true
uiToolbox.invocationArgument = arrayOf(this) uiToolbox.invocationArgument = arrayOf(this)
uiPalette.setPosition(Terrarum.WIDTH - uiPalette.width, 0) uiPaletteSelector.setPosition(Terrarum.WIDTH - uiPaletteSelector.width, 0)
uiPalette.isVisible = true uiPaletteSelector.isVisible = true
notifier.setPosition( notifier.setPosition(
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height) (Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
@@ -165,6 +167,9 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
actorNowPlaying?.setPosition(512 * 16.0, 149 * 16.0) actorNowPlaying?.setPosition(512 * 16.0, 149 * 16.0)
uiPalette.setPosition(200, 100)
uiPalette.isVisible = true // TEST CODE should not be visible
LightmapRenderer.fireRecalculateEvent() LightmapRenderer.fireRecalculateEvent()
} }
@@ -247,7 +252,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
private fun makePenWork(worldTileX: Int, worldTileY: Int) { private fun makePenWork(worldTileX: Int, worldTileY: Int) {
val world = gameWorld val world = gameWorld
val palSelection = uiPalette.fore val palSelection = uiPaletteSelector.fore
when (currentPenMode) { when (currentPenMode) {
// test paint terrain layer // test paint terrain layer

View File

@@ -774,7 +774,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
override fun addNewActor(actor: Actor?) { override fun addNewActor(actor: Actor?) {
if (actor == null) return if (actor == null) return
if (theGameHasActor(actor.referenceID!!)) { if (AppLoader.IS_DEVELOPMENT_BUILD && theGameHasActor(actor.referenceID!!)) {
throw Error("The actor $actor already exists in the game") throw Error("The actor $actor already exists in the game")
} }
else { else {
@@ -807,7 +807,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
} }
fun activateDormantActor(actor: Actor) { fun activateDormantActor(actor: Actor) {
if (!isInactive(actor.referenceID!!)) { if (AppLoader.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID!!)) {
if (isActive(actor.referenceID!!)) if (isActive(actor.referenceID!!))
throw Error("The actor $actor is already activated") throw Error("The actor $actor is already activated")
else else

View File

@@ -89,7 +89,7 @@ object IngameRenderer {
this.player = player this.player = player
LightmapRenderer.fireRecalculateEvent() LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
prepLightmapRGBA() prepLightmapRGBA()
BlocksDrawer.renderData() BlocksDrawer.renderData()

View File

@@ -0,0 +1,115 @@
package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarum.ui.UIItemTextButtonList
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_BACKGROUNDCOL
/**
* Created by minjaesong on 2019-02-14.
*/
class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
companion object {
const val TILES_X = 16
const val TILES_Y = 14
const val TILESREGION_SIZE = 24
const val MENUBAR_SIZE = 80
const val SCROLLBAR_SIZE = 16
const val WIDTH = TILES_X*TILESREGION_SIZE + SCROLLBAR_SIZE + MENUBAR_SIZE
const val HEIGHT = TILES_Y*TILESREGION_SIZE
}
override var width = WIDTH
override var height = HEIGHT
override var openCloseTime = 0f
private val palette = Array<UIItemImageButton>(TILES_X * TILES_Y) {
// initialise with terrain blocks
UIItemImageButton(
this, ItemCodex.getItemImage(it),
posX = MENUBAR_SIZE + (it % 16) * TILESREGION_SIZE,
posY = (it / 16) * TILESREGION_SIZE,
highlightable = true,
width = TILESREGION_SIZE,
height = TILESREGION_SIZE,
highlightCol = Color.WHITE,
activeCol = Color.WHITE
)
}
private val tabs = UIItemTextButtonList(
this, arrayOf("Terrain", "Wall", "Wire", "Fixtures"),
0, 0, textAreaWidth = MENUBAR_SIZE, width = MENUBAR_SIZE,
defaultSelection = 0
)
private val closeButton = UIItemTextButtonList(
this, arrayOf("Close"),
0, this.height - UIItemTextButtonList.DEFAULT_LINE_HEIGHT,
width = MENUBAR_SIZE, textAreaWidth = MENUBAR_SIZE
)
private val buttonGapClickDummy = UIItemImageButton(
this, TextureRegion(AppLoader.textureWhiteSquare),
width = MENUBAR_SIZE, height = height - (tabs.height + closeButton.height),
highlightable = false,
posX = 0, posY = tabs.height,
activeCol = Color(0),
inactiveCol = Color(0),
activeBackCol = DEFAULT_BACKGROUNDCOL,
activeBackBlendMode = BlendMode.NORMAL,
backgroundCol = DEFAULT_BACKGROUNDCOL,
backgroundBlendMode = BlendMode.NORMAL
)
override fun updateUI(delta: Float) {
palette.forEach { it.update(delta) }
tabs.update(delta)
closeButton.update(delta)
buttonGapClickDummy.update(delta)
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
palette.forEach { it.render(batch, camera) }
buttonGapClickDummy.render(batch, camera)
tabs.render(batch, camera)
closeButton.render(batch, camera)
}
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
return super.touchDragged(screenX, screenY, pointer)
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return super.touchDown(screenX, screenY, pointer, button)
}
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return super.touchUp(screenX, screenY, pointer, button)
}
override fun doOpening(delta: Float) {
}
override fun doClosing(delta: Float) {
}
override fun endOpening(delta: Float) {
}
override fun endClosing(delta: Float) {
}
override fun dispose() {
// nothing to dispose; you can't dispose the palette as its image is dynamically assigned
}
}

View File

@@ -14,6 +14,7 @@ import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BL
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
import net.torvald.terrarum.ui.UIItem import net.torvald.terrarum.ui.UIItem
import net.torvald.terrarum.ui.UIItemImageButton import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarum.ui.UIItemTextButton.Companion.defaultActiveCol
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import java.util.* import java.util.*
@@ -149,8 +150,11 @@ class UIItemInventoryDynamicList(
UIItemImageButton( UIItemImageButton(
parentUI, parentUI,
parentUI.catIcons.get(index + 14, 0), parentUI.catIcons.get(index + 14, 0),
backgroundCol = Color(0),
activeBackCol = Color(0), activeBackCol = Color(0),
highlightBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL, activeBackBlendMode = BlendMode.NORMAL,
activeCol = defaultActiveCol,
posX = iconPosX, posX = iconPosX,
posY = getIconPosY(index), posY = getIconPosY(index),
highlightable = true highlightable = true
@@ -160,8 +164,10 @@ class UIItemInventoryDynamicList(
private val scrollUpButton = UIItemImageButton( private val scrollUpButton = UIItemImageButton(
parentUI, parentUI,
parentUI.catIcons.get(18, 0), parentUI.catIcons.get(18, 0),
backgroundCol = Color(0),
activeBackCol = Color(0), activeBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL, activeBackBlendMode = BlendMode.NORMAL,
activeCol = defaultActiveCol,
posX = iconPosX, posX = iconPosX,
posY = getIconPosY(2), posY = getIconPosY(2),
highlightable = false highlightable = false
@@ -170,8 +176,10 @@ class UIItemInventoryDynamicList(
private val scrollDownButton = UIItemImageButton( private val scrollDownButton = UIItemImageButton(
parentUI, parentUI,
parentUI.catIcons.get(19, 0), parentUI.catIcons.get(19, 0),
backgroundCol = Color(0),
activeBackCol = Color(0), activeBackCol = Color(0),
activeBackBlendMode = BlendMode.NORMAL, activeBackBlendMode = BlendMode.NORMAL,
activeCol = defaultActiveCol,
posX = iconPosX, posX = iconPosX,
posY = getIconPosY(3), posY = getIconPosY(3),
highlightable = false highlightable = false

View File

@@ -17,7 +17,7 @@ import net.torvald.terrarum.ui.UINSMenu
/** /**
* Created by minjaesong on 2019-02-03. * Created by minjaesong on 2019-02-03.
*/ */
class UIEditorPalette : UICanvas() { class UIPaletteSelector : UICanvas() {
override var width = 36 override var width = 36
override var height = 72 override var height = 72

View File

@@ -15,17 +15,15 @@ open class UIItemImageButton(
parent: UICanvas, parent: UICanvas,
val image: TextureRegion, val image: TextureRegion,
val buttonCol: Color = Color.WHITE, val activeCol: Color = UIItemTextButton.defaultActiveCol,
val buttonBackCol: Color = Color(0), val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
val buttonBackBlendMode: String = BlendMode.NORMAL, val activeBackBlendMode: String = BlendMode.NORMAL,
val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
val activeCol: Color = Color(0xfff066_ff.toInt()), val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
val activeBackCol: Color = Color(0xb0b0b0_ff.toInt()), val highlightBackBlendMode: String = BlendMode.NORMAL,
val activeBackBlendMode: String = BlendMode.MULTIPLY, val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
val highlightCol: Color = Color(0x00f8ff_ff), val backgroundBlendMode: String = BlendMode.NORMAL,
val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()),
val highlightBackBlendMode: String = BlendMode.MULTIPLY,
override var posX: Int, override var posX: Int,
override var posY: Int, override var posY: Int,
@@ -43,24 +41,29 @@ open class UIItemImageButton(
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {
// draw background // draw background
if (mouseUp) { if (highlighted) {
BlendMode.resolve(highlightBackBlendMode, batch)
batch.color = highlightBackCol
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
}
else if (mouseUp) {
BlendMode.resolve(activeBackBlendMode, batch) BlendMode.resolve(activeBackBlendMode, batch)
batch.color = activeBackCol batch.color = activeBackCol
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
} }
else { else {
BlendMode.resolve(buttonBackBlendMode, batch) batch.color = backgroundCol
batch.color = buttonBackCol BlendMode.resolve(backgroundBlendMode, batch)
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
} }
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
// draw image // draw image
blendNormal(batch) blendNormal(batch)
batch.color = if (highlighted) highlightCol batch.color = if (highlighted) highlightCol
else if (mouseUp) activeCol else if (mouseUp) activeCol
else buttonCol else inactiveCol
batch.draw(image, (posX + (width - image.regionWidth) / 2).toFloat(), (posY + (height - image.regionHeight) / 2).toFloat()) batch.draw(image, (posX + (width - image.regionWidth) / 2).toFloat(), (posY + (height - image.regionHeight) / 2).toFloat())
} }

View File

@@ -2,7 +2,6 @@ package net.torvald.terrarum.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.GlyphLayout
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.Terrarum import net.torvald.terrarum.Terrarum
@@ -23,13 +22,17 @@ open class UIItemTextButton(
override var posY: Int, override var posY: Int,
override val width: Int, override val width: Int,
val readFromLang: Boolean = false, val readFromLang: Boolean = false,
val activeCol: Color = Color.WHITE,
val activeBackCol: Color = Color(0), val activeCol: Color = defaultActiveCol,
val activeBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_ACTIVECOL,
val activeBackBlendMode: String = BlendMode.NORMAL, val activeBackBlendMode: String = BlendMode.NORMAL,
val highlightCol: Color = defaultHighlightCol, val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()), val highlightBackCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUND_HIGHLIGHTCOL,
val highlightBackBlendMode: String = BlendMode.MULTIPLY, val highlightBackBlendMode: String = BlendMode.NORMAL,
val inactiveCol: Color = defaultInactiveCol, val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
val backgroundBlendMode: String = BlendMode.NORMAL,
val preGapX: Int = 0, val preGapX: Int = 0,
val postGapX: Int = 0, val postGapX: Int = 0,
@@ -44,8 +47,9 @@ open class UIItemTextButton(
companion object { companion object {
val font = Terrarum.fontGame val font = Terrarum.fontGame
val height = font.lineHeight.toInt() val height = font.lineHeight.toInt()
val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt()) val defaultInactiveCol = Color.WHITE
val defaultHighlightCol: Color = Color(0x00f8ff_ff) val defaultHighlightCol = Color(0x00f8ff_ff)
val defaultActiveCol = Color(0xfff066_ff.toInt())
enum class Alignment { enum class Alignment {
CENTRE, LEFT, RIGHT CENTRE, LEFT, RIGHT
@@ -61,13 +65,11 @@ open class UIItemTextButton(
var highlighted: Boolean = false var highlighted: Boolean = false
private val glyphLayout = GlyphLayout()
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {
val textW = font.getWidth(label) val textW = font.getWidth(label)
// draw background
if (highlighted) { if (highlighted) {
BlendMode.resolve(highlightBackBlendMode, batch) BlendMode.resolve(highlightBackBlendMode, batch)
batch.color = highlightBackCol batch.color = highlightBackCol
@@ -78,6 +80,12 @@ open class UIItemTextButton(
batch.color = activeBackCol batch.color = activeBackCol
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
} }
else {
batch.color = backgroundCol
BlendMode.resolve(backgroundBlendMode, batch)
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
}
blendNormal(batch) blendNormal(batch)

View File

@@ -8,6 +8,7 @@ import net.torvald.terrarum.Second
import net.torvald.terrarum.fillRect import net.torvald.terrarum.fillRect
import net.torvald.terrarum.gameactors.ai.toInt import net.torvald.terrarum.gameactors.ai.toInt
import net.torvald.terrarum.roundInt import net.torvald.terrarum.roundInt
import net.torvald.terrarum.ui.UIItemTextButton.Companion.defaultActiveCol
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/** /**
@@ -30,23 +31,26 @@ class UIItemTextButtonList(
val iconCol: Color = UIItemTextButton.defaultInactiveCol, val iconCol: Color = UIItemTextButton.defaultInactiveCol,
// copied directly from UIItemTextButton // copied directly from UIItemTextButton
val activeCol: Color = Color(0xfff066_ff.toInt()), val activeCol: Color = defaultActiveCol,
val activeBackCol: Color = Color(0), val activeBackCol: Color = DEFAULT_BACKGROUND_ACTIVECOL,
val activeBackBlendMode: String = BlendMode.NORMAL, val activeBackBlendMode: String = BlendMode.NORMAL,
val highlightCol: Color = Color(0x00f8ff_ff), val highlightCol: Color = UIItemTextButton.defaultHighlightCol,
val highlightBackCol: Color = Color(0xb0b0b0_ff.toInt()), val highlightBackCol: Color = DEFAULT_BACKGROUND_HIGHLIGHTCOL,
val highlightBackBlendMode: String = BlendMode.MULTIPLY, val highlightBackBlendMode: String = BlendMode.NORMAL,
val inactiveCol: Color = Color(0xc0c0c0_ff.toInt()), val inactiveCol: Color = UIItemTextButton.defaultInactiveCol,
val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL, val backgroundCol: Color = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,
val backgroundBlendMode: String = BlendMode.NORMAL, val backgroundBlendMode: String = BlendMode.NORMAL,
val kinematic: Boolean = false, val kinematic: Boolean = false,
val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE, val alignment: UIItemTextButton.Companion.Alignment = UIItemTextButton.Companion.Alignment.CENTRE,
val itemHitboxSize: Int = UIItemTextButton.height val itemHitboxSize: Int = DEFAULT_LINE_HEIGHT
) : UIItem(parentUI) { ) : UIItem(parentUI) {
companion object { companion object {
val DEFAULT_BACKGROUNDCOL = Color(0x242424_80) val DEFAULT_BACKGROUNDCOL = Color(0x242424_80)
val DEFAULT_BACKGROUND_HIGHLIGHTCOL = Color(0x121212BF)
val DEFAULT_BACKGROUND_ACTIVECOL = Color(0x1b1b1b9F)
val DEFAULT_LINE_HEIGHT = 36 val DEFAULT_LINE_HEIGHT = 36
} }
@@ -87,6 +91,8 @@ class UIItemTextButtonList(
highlightBackCol = highlightBackCol, highlightBackCol = highlightBackCol,
highlightBackBlendMode = highlightBackBlendMode, highlightBackBlendMode = highlightBackBlendMode,
inactiveCol = inactiveCol, inactiveCol = inactiveCol,
backgroundCol = backgroundCol,
backgroundBlendMode = backgroundBlendMode,
preGapX = pregap, preGapX = pregap,
postGapX = postgap, postGapX = postgap,
alignment = alignment, alignment = alignment,
@@ -106,6 +112,7 @@ class UIItemTextButtonList(
highlightCol = highlightCol, highlightCol = highlightCol,
highlightBackCol = activeBackCol, // we are using custom highlighter highlightBackCol = activeBackCol, // we are using custom highlighter
highlightBackBlendMode = activeBackBlendMode, // we are using custom highlighter highlightBackBlendMode = activeBackBlendMode, // we are using custom highlighter
backgroundCol = Color(0),
inactiveCol = inactiveCol, inactiveCol = inactiveCol,
preGapX = pregap, preGapX = pregap,
postGapX = postgap, postGapX = postgap,
@@ -203,14 +210,16 @@ class UIItemTextButtonList(
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {
batch.color = backgroundCol if (kinematic) {
BlendMode.resolve(backgroundBlendMode, batch) batch.color = backgroundCol
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) BlendMode.resolve(backgroundBlendMode, batch)
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
batch.color = highlightBackCol batch.color = highlightBackCol
BlendMode.resolve(highlightBackBlendMode, batch) BlendMode.resolve(highlightBackBlendMode, batch)
if (highlightY != null) { if (highlightY != null) {
batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), itemHitboxSize.toFloat()) batch.fillRect(posX.toFloat(), highlightY!!.toFloat(), width.toFloat(), itemHitboxSize.toFloat())
}
} }
buttons.forEach { it.render(batch, camera) } buttons.forEach { it.render(batch, camera) }

View File

@@ -104,7 +104,6 @@ class UINSMenu(
uiWidth, listHeight, uiWidth, listHeight,
textAreaWidth = listWidth, textAreaWidth = listWidth,
alignment = UIItemTextButton.Companion.Alignment.LEFT, alignment = UIItemTextButton.Companion.Alignment.LEFT,
activeBackCol = UIItemTextButtonList.DEFAULT_BACKGROUNDCOL,//Color(1f,0f,.75f,1f),
inactiveCol = Color(.94f,.94f,.94f,1f), inactiveCol = Color(.94f,.94f,.94f,1f),
itemHitboxSize = LINE_HEIGHT itemHitboxSize = LINE_HEIGHT

View File

@@ -13,6 +13,7 @@ import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.concurrent.ParallelUtils.sliceEvenly import net.torvald.terrarum.concurrent.ParallelUtils.sliceEvenly
import net.torvald.terrarum.gameactors.ActorWBMovable import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.Luminous import net.torvald.terrarum.gameactors.Luminous
import net.torvald.terrarum.gameworld.BlockAddress import net.torvald.terrarum.gameworld.BlockAddress
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
@@ -230,7 +231,7 @@ object LightmapRenderer {
} }
} }
internal fun fireRecalculateEvent() { internal fun fireRecalculateEvent(vararg actorContainers: List<ActorWithBody>?) {
try { try {
world.getTileFromTerrain(0, 0) // test inquiry world.getTileFromTerrain(0, 0) // test inquiry
} }
@@ -256,7 +257,7 @@ object LightmapRenderer {
//println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y") //println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y")
AppLoader.measureDebugTime("Renderer.Lanterns") { AppLoader.measureDebugTime("Renderer.Lanterns") {
buildLanternmap() buildLanternmap(actorContainers)
} // usually takes 3000 ns } // usually takes 3000 ns
if (!SHADER_LIGHTING) { if (!SHADER_LIGHTING) {
@@ -443,10 +444,10 @@ object LightmapRenderer {
internal data class ThreadedLightmapUpdateMessage(val x: Int, val y: Int) internal data class ThreadedLightmapUpdateMessage(val x: Int, val y: Int)
private fun buildLanternmap() { private fun buildLanternmap(actorContainers: Array<out List<ActorWithBody>?>) {
lanternMap.clear() lanternMap.clear()
Terrarum.ingame?.let { actorContainers.forEach { actorContainer ->
it.actorContainer.forEach { it -> actorContainer?.forEach {
if (it is Luminous && it is ActorWBMovable) { if (it is Luminous && it is ActorWBMovable) {
// put lanterns to the area the luminantBox is occupying // put lanterns to the area the luminantBox is occupying
for (lightBox in it.lightBoxList) { for (lightBox in it.lightBoxList) {

Binary file not shown.