more pictogrammes

Former-commit-id: 670df70bbed466e56034dbdd33d7a1da31cd88d7
Former-commit-id: 2b106753155be6080d4651acca1981f10d614421
This commit is contained in:
Song Minjae
2016-08-25 21:46:01 +09:00
parent fa5e95a89d
commit 720df532aa
50 changed files with 589 additions and 265 deletions

View File

@@ -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

View File

@@ -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)
}
}

View File

@@ -7,6 +7,5 @@ package net.torvald.terrarum.ui
*/
interface GamepadControlled {
fun controllerButtonPressed(controller: Int, button: Int)
fun controllerButtonReleased(controller: Int, button: Int)
}

View 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.
}
}

View File

@@ -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),

View File

@@ -5,6 +5,5 @@ package net.torvald.terrarum.ui
*/
interface KeyboardControlled {
fun keyPressed(key: Int, c: Char)
fun keyReleased(key: Int, c: Char)
}

View File

@@ -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)
}

View File

@@ -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)),

View File

@@ -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)
}

View File

@@ -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) {

View File

@@ -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
*/