mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
dithered skybox
This commit is contained in:
@@ -15,7 +15,7 @@ import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
class UIHandler(var UI: UICanvas,
|
||||
var toggleKey: Int? = null, var toggleButton: Int? = null,
|
||||
var toggleKeyLiteral: Int? = null, var toggleButtonLiteral: Int? = null,
|
||||
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
|
||||
var customPositioning: Boolean = false, // mainly used by vital meter
|
||||
var doNotWarnConstant: Boolean = false
|
||||
@@ -62,6 +62,10 @@ class UIHandler(var UI: UICanvas,
|
||||
}
|
||||
|
||||
|
||||
private val toggleKey: Int?; get() = toggleKeyLiteral // to support in-screen keybind changing
|
||||
private val toggleButton: Int?; get() = toggleButtonLiteral // to support in-screen keybind changing
|
||||
|
||||
|
||||
fun update(delta: Float) {
|
||||
// open/close UI by key pressed
|
||||
if (toggleKey != null) {
|
||||
|
||||
@@ -58,6 +58,10 @@ class UIInventory(
|
||||
|
||||
val controlHelpHeight = Terrarum.fontGame.lineHeight.toInt()
|
||||
|
||||
val pageButtonExtraGap = 32
|
||||
|
||||
val pageButtonRealWidth = pageButtonExtraGap + itemStripGutterH
|
||||
|
||||
val catButtons = UIItemTextButtonList(
|
||||
this,
|
||||
arrayOf(
|
||||
@@ -90,12 +94,12 @@ class UIInventory(
|
||||
inactiveCol = defaultTextColour
|
||||
)
|
||||
|
||||
val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2
|
||||
val itemsStripWidth = ((width - catButtons.width) - (2 * itemStripGutterH + itemInterColGutter)) / 2 - pageButtonExtraGap
|
||||
val items = Array(
|
||||
((height - controlHelpHeight) / (UIItemInventoryElem.height + itemStripGutterV)) * 2, {
|
||||
UIItemInventoryElem(
|
||||
parentUI = this,
|
||||
posX = catButtons.width + if (it % 2 == 0) itemStripGutterH else (itemStripGutterH + itemsStripWidth + itemInterColGutter),
|
||||
posX = pageButtonExtraGap + catButtons.width + if (it % 2 == 0) itemStripGutterH else (itemStripGutterH + itemsStripWidth + itemInterColGutter),
|
||||
posY = itemStripGutterH + it / 2 * (UIItemInventoryElem.height + itemStripGutterV),
|
||||
width = itemsStripWidth,
|
||||
item = null,
|
||||
@@ -134,6 +138,13 @@ class UIInventory(
|
||||
private var encumbrancePerc = 0f
|
||||
private var isEncumbered = false
|
||||
|
||||
|
||||
private val seekLeft: Int; get() = Terrarum.getConfigInt("keyleft") // to support in-screen keybind changing
|
||||
private val seekRight: Int; get() = Terrarum.getConfigInt("keyright") // to support in-screen keybind changing
|
||||
private val seekUp: Int; get() = Terrarum.getConfigInt("keyup") // to support in-screen keybind changing
|
||||
private val seekDown: Int; get() = Terrarum.getConfigInt("keydown") // to support in-screen keybind changing
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (handler == null) {
|
||||
throw Error("Handler for this UI is null, you douchebag.")
|
||||
|
||||
83
src/net/torvald/terrarum/ui/UIItemImageButton.kt
Normal file
83
src/net/torvald/terrarum/ui/UIItemImageButton.kt
Normal file
@@ -0,0 +1,83 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.BlendMode
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.fillRect
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-07-16.
|
||||
*/
|
||||
class UIItemImageButton(
|
||||
parent: UICanvas,
|
||||
val image: TextureRegion,
|
||||
|
||||
val buttonCol: Color = Color.WHITE,
|
||||
val buttonBackCol: Color = Color(0),
|
||||
val buttonBackBlendMode: String = BlendMode.NORMAL,
|
||||
|
||||
val activeCol: Color = Color(0x00f8ff_ff),
|
||||
val activeBackCol: Color = Color(0xb0b0b0_ff.toInt()),
|
||||
val activeBackBlendMode: String = BlendMode.MULTIPLY,
|
||||
|
||||
override var posX: Int,
|
||||
override var posY: Int,
|
||||
override val width: Int,
|
||||
override val height: Int
|
||||
) : UIItem(parent) {
|
||||
|
||||
override fun update(delta: Float) {
|
||||
}
|
||||
|
||||
override fun render(batch: SpriteBatch) {
|
||||
if (mouseUp) {
|
||||
BlendMode.resolve(activeBackBlendMode)
|
||||
batch.color = activeBackCol
|
||||
}
|
||||
else {
|
||||
BlendMode.resolve(buttonBackBlendMode)
|
||||
batch.color = buttonBackCol
|
||||
}
|
||||
|
||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||
|
||||
blendNormal()
|
||||
|
||||
batch.color = if (mouseUp) activeCol else buttonCol
|
||||
batch.draw(image, (posX - (image.regionWidth / 2)).toFloat(), (posY - (image.regionHeight / 2)).toFloat())
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
image.texture.dispose()
|
||||
}
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun keyUp(keycode: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun scrolled(amount: Int): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,6 @@ class UIItemTextButton(
|
||||
override val height: Int = UIItemTextButton.height
|
||||
|
||||
var highlighted: Boolean = false
|
||||
var mouseOver = false
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
@@ -59,7 +58,7 @@ class UIItemTextButton(
|
||||
batch.color = highlightBackCol
|
||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||
}
|
||||
else if (mouseOver) {
|
||||
else if (mouseUp) {
|
||||
BlendMode.resolve(activeBackBlendMode)
|
||||
batch.color = activeBackCol
|
||||
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
|
||||
@@ -68,9 +67,8 @@ class UIItemTextButton(
|
||||
blendNormal()
|
||||
|
||||
|
||||
mouseOver = mouseUp
|
||||
batch.color = if (highlighted) highlightCol
|
||||
else if (mouseOver) activeCol
|
||||
else if (mouseUp) activeCol
|
||||
else inactiveCol
|
||||
|
||||
font.draw(batch,
|
||||
|
||||
Reference in New Issue
Block a user