mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
more pictogrammes
Former-commit-id: 670df70bbed466e56034dbdd33d7a1da31cd88d7 Former-commit-id: 2b106753155be6080d4651acca1981f10d614421
This commit is contained in:
@@ -68,7 +68,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
val mouseTileX = ((MapCamera.cameraX + gc.input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||
val mouseTileY = ((MapCamera.cameraY + gc.input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||
|
||||
g.font = Terrarum.smallNumbers
|
||||
g.font = Terrarum.fontSmallNumbers
|
||||
g.color = GameFontBase.codeToCol["y"]
|
||||
|
||||
val hitbox = player.hitbox
|
||||
|
||||
@@ -14,4 +14,9 @@ object DrawUtil {
|
||||
|
||||
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
}
|
||||
|
||||
fun drawCentered(g: Graphics, image: Image, screenPosY: Int, targetW: Int, offsetX: Int = 0, offsetY: Int = 0) {
|
||||
val imageW = image.width
|
||||
g.drawImage(image, targetW.minus(imageW).ushr(1).toFloat() + offsetX, screenPosY.toFloat() + offsetY)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,5 @@ package net.torvald.terrarum.ui
|
||||
*/
|
||||
interface GamepadControlled {
|
||||
fun controllerButtonPressed(controller: Int, button: Int)
|
||||
|
||||
fun controllerButtonReleased(controller: Int, button: Int)
|
||||
}
|
||||
80
src/net/torvald/terrarum/ui/ItemImageGallery.kt
Normal file
80
src/net/torvald/terrarum/ui/ItemImageGallery.kt
Normal file
@@ -0,0 +1,80 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Image gallery. Images will be equally spaced, counted from top-left to bottom-right.
|
||||
* Created by minjaesong on 16-08-08.
|
||||
*/
|
||||
class ItemImageGallery(
|
||||
override var posX: Int,
|
||||
override var posY: Int,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
val imageList: ArrayList<Image>,
|
||||
val column: Int = 1
|
||||
) : UIItem {
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
fun column(i: Int) = i % column
|
||||
fun row(i: Int) = i / column
|
||||
|
||||
fun imagePosY(i: Int): Int {
|
||||
val gutter = (height - imageList[i].height.times(imageList.size)).toFloat().div(
|
||||
imageList.size + 1f
|
||||
)
|
||||
return row((gutter * i.plus(1) + imageList[i].height * i).roundInt())
|
||||
}
|
||||
|
||||
imageList.forEachIndexed { i, image ->
|
||||
DrawUtil.drawCentered(g, image,
|
||||
imagePosY(i),
|
||||
width.toFloat().div(column).times(column(i).plus(1)).roundInt(),
|
||||
posX, posY
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun keyPressed(key: Int, c: Char) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun keyReleased(key: Int, c: Char) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun mouseWheelMoved(change: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ object ItemSlotImageBuilder {
|
||||
const val COLOR_BLACK = 1
|
||||
const val COLOR_WHITE = 2
|
||||
|
||||
private val colourBlack = Color(0x404040)
|
||||
private val colourWhite = Color(0xC0C0C0)
|
||||
private val colourBlack = Color(0x40, 0x40, 0x40, 0xEE)
|
||||
private val colourWhite = Color(0xC0, 0xC0, 0xC0, 0xEE)
|
||||
|
||||
private val numberFont = SpriteSheetFont(
|
||||
SpriteSheet("./assets/graphics/fonts/numeric_small.png", 5, 8),
|
||||
|
||||
@@ -5,6 +5,5 @@ package net.torvald.terrarum.ui
|
||||
*/
|
||||
interface KeyboardControlled {
|
||||
fun keyPressed(key: Int, c: Char)
|
||||
|
||||
fun keyReleased(key: Int, c: Char)
|
||||
}
|
||||
@@ -5,12 +5,8 @@ package net.torvald.terrarum.ui
|
||||
*/
|
||||
interface MouseControlled {
|
||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||
|
||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||
|
||||
fun mousePressed(button: Int, x: Int, y: Int)
|
||||
|
||||
fun mouseReleased(button: Int, x: Int, y: Int)
|
||||
|
||||
fun mouseWheelMoved(change: Int)
|
||||
}
|
||||
@@ -117,10 +117,10 @@ constructor(val UI: UICanvas) {
|
||||
fun render(gc: GameContainer, sbg: StateBasedGame, ingameGraphics: Graphics) {
|
||||
if (isVisible || alwaysVisible) {
|
||||
UIGraphicInstance.clear()
|
||||
UIGraphicInstance.font = Terrarum.gameFont
|
||||
UIGraphicInstance.font = Terrarum.fontGame
|
||||
|
||||
UI.render(gc, UIGraphicInstance)
|
||||
if (sbg.currentStateID == Terrarum.SCENE_ID_GAME) {
|
||||
if (sbg.currentStateID == Terrarum.STATE_ID_GAME) {
|
||||
ingameGraphics.drawImage(UIDrawnCanvas.getScaledCopy(scale),
|
||||
posX + MapCamera.cameraX * Terrarum.ingame.screenZoom - (UI.width / 2f * scale.minus(1)),
|
||||
posY + MapCamera.cameraY * Terrarum.ingame.screenZoom - (UI.height / 2f * scale.minus(1)),
|
||||
|
||||
@@ -1,13 +1,32 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
*/
|
||||
class UIItem {
|
||||
interface UIItem {
|
||||
|
||||
// X/Y Position relative to the containing canvas
|
||||
internal var posX: Int = 0
|
||||
internal var posY: Int = 0
|
||||
var posX: Int
|
||||
var posY: Int
|
||||
|
||||
fun update(gc: GameContainer, delta: Int)
|
||||
fun render(gc: GameContainer, g: Graphics)
|
||||
|
||||
// keyboard controlled
|
||||
fun keyPressed(key: Int, c: Char)
|
||||
fun keyReleased(key: Int, c: Char)
|
||||
|
||||
// mouse controlled
|
||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int)
|
||||
fun mousePressed(button: Int, x: Int, y: Int)
|
||||
fun mouseReleased(button: Int, x: Int, y: Int)
|
||||
fun mouseWheelMoved(change: Int)
|
||||
|
||||
// gamepad controlled
|
||||
fun controllerButtonPressed(controller: Int, button: Int)
|
||||
fun controllerButtonReleased(controller: Int, button: Int)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ class UIPieMenu : UICanvas {
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
||||
selection % slotCount
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun render(gc: GameContainer, g: Graphics) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.newdawn.slick.Input
|
||||
class UIQuickBar : UICanvas, MouseControlled {
|
||||
private val gutter = 8
|
||||
override var width: Int = (ItemSlotImageBuilder.slotImageSize + gutter) * SLOT_COUNT
|
||||
override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.gameFont.lineHeight
|
||||
override var height: Int = ItemSlotImageBuilder.slotImageSize + 4 + Terrarum.fontGame.lineHeight
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user