mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
fixing list UI's colours; buildingmaker palette wip
This commit is contained in:
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
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.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UINSMenu
|
||||
@@ -82,7 +82,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
val uiToolbox = UINSMenu("Menu", 100, menuYaml)
|
||||
val notifier = Notification()
|
||||
val uiPalette = UIEditorPalette()
|
||||
val uiPaletteSelector = UIPaletteSelector()
|
||||
val uiPalette = UIBuildingMakerBlockChooser(this)
|
||||
|
||||
|
||||
val uiContainer = ArrayList<UICanvas>()
|
||||
@@ -146,8 +147,9 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
actorsRenderOverlay.add(blockPointingCursor)
|
||||
|
||||
uiContainer.add(uiToolbox)
|
||||
uiContainer.add(uiPalette)
|
||||
uiContainer.add(uiPaletteSelector)
|
||||
uiContainer.add(notifier)
|
||||
uiContainer.add(uiPalette)
|
||||
|
||||
|
||||
|
||||
@@ -155,8 +157,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
uiToolbox.isVisible = true
|
||||
uiToolbox.invocationArgument = arrayOf(this)
|
||||
|
||||
uiPalette.setPosition(Terrarum.WIDTH - uiPalette.width, 0)
|
||||
uiPalette.isVisible = true
|
||||
uiPaletteSelector.setPosition(Terrarum.WIDTH - uiPaletteSelector.width, 0)
|
||||
uiPaletteSelector.isVisible = true
|
||||
|
||||
notifier.setPosition(
|
||||
(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)
|
||||
|
||||
|
||||
uiPalette.setPosition(200, 100)
|
||||
uiPalette.isVisible = true // TEST CODE should not be visible
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
}
|
||||
@@ -247,7 +252,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private fun makePenWork(worldTileX: Int, worldTileY: Int) {
|
||||
val world = gameWorld
|
||||
val palSelection = uiPalette.fore
|
||||
val palSelection = uiPaletteSelector.fore
|
||||
|
||||
when (currentPenMode) {
|
||||
// test paint terrain layer
|
||||
|
||||
@@ -774,7 +774,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
override fun addNewActor(actor: Actor?) {
|
||||
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")
|
||||
}
|
||||
else {
|
||||
@@ -807,7 +807,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
fun activateDormantActor(actor: Actor) {
|
||||
if (!isInactive(actor.referenceID!!)) {
|
||||
if (AppLoader.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID!!)) {
|
||||
if (isActive(actor.referenceID!!))
|
||||
throw Error("The actor $actor is already activated")
|
||||
else
|
||||
|
||||
@@ -89,7 +89,7 @@ object IngameRenderer {
|
||||
this.player = player
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
|
||||
|
||||
prepLightmapRGBA()
|
||||
BlocksDrawer.renderData()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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.ui.UIItem
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarum.ui.UIItemTextButton.Companion.defaultActiveCol
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.util.*
|
||||
|
||||
@@ -149,8 +150,11 @@ class UIItemInventoryDynamicList(
|
||||
UIItemImageButton(
|
||||
parentUI,
|
||||
parentUI.catIcons.get(index + 14, 0),
|
||||
backgroundCol = Color(0),
|
||||
activeBackCol = Color(0),
|
||||
highlightBackCol = Color(0),
|
||||
activeBackBlendMode = BlendMode.NORMAL,
|
||||
activeCol = defaultActiveCol,
|
||||
posX = iconPosX,
|
||||
posY = getIconPosY(index),
|
||||
highlightable = true
|
||||
@@ -160,8 +164,10 @@ class UIItemInventoryDynamicList(
|
||||
private val scrollUpButton = UIItemImageButton(
|
||||
parentUI,
|
||||
parentUI.catIcons.get(18, 0),
|
||||
backgroundCol = Color(0),
|
||||
activeBackCol = Color(0),
|
||||
activeBackBlendMode = BlendMode.NORMAL,
|
||||
activeCol = defaultActiveCol,
|
||||
posX = iconPosX,
|
||||
posY = getIconPosY(2),
|
||||
highlightable = false
|
||||
@@ -170,8 +176,10 @@ class UIItemInventoryDynamicList(
|
||||
private val scrollDownButton = UIItemImageButton(
|
||||
parentUI,
|
||||
parentUI.catIcons.get(19, 0),
|
||||
backgroundCol = Color(0),
|
||||
activeBackCol = Color(0),
|
||||
activeBackBlendMode = BlendMode.NORMAL,
|
||||
activeCol = defaultActiveCol,
|
||||
posX = iconPosX,
|
||||
posY = getIconPosY(3),
|
||||
highlightable = false
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.torvald.terrarum.ui.UINSMenu
|
||||
/**
|
||||
* Created by minjaesong on 2019-02-03.
|
||||
*/
|
||||
class UIEditorPalette : UICanvas() {
|
||||
class UIPaletteSelector : UICanvas() {
|
||||
|
||||
override var width = 36
|
||||
override var height = 72
|
||||
Reference in New Issue
Block a user