text labels now has background

Former-commit-id: 05f2767134b385960deb65c2e76c97432c8303ad
This commit is contained in:
Song Minjae
2017-03-14 15:08:18 +09:00
parent f47c66db44
commit ff817c25e6
12 changed files with 136 additions and 37 deletions

View File

@@ -52,6 +52,21 @@ Magical/Surreal: Use 24 Bits
- MULTIPLY blend chosen colour with white texture
### Colour keys ###
Things are colour-keyed so that players would get the idea by just a glance.
- Amber: Inactivated, TBA??
- Cyan-blue: Activated, Energy weapon?
- Purple: Magic
- Application: spell tomes/scrolls written with Magic Description Language
- Phosphor Green:
- Cherry red (#F04): Health (using this to help with deuterans)
NOTE: cyan is a tricky colour for deuterans; will be inextinguishable between greys!
## Roguelike identity ##
* Randomised things

View File

@@ -10,6 +10,6 @@
"GAME_INVENTORY_INGREDIENTS" : "Ingredients",
"GAME_INVENTORY_POTIONS" : "Potions",
"GAME_INVENTORY_BLOCKS" : "Blocks",
"GAME_INVENTORY_WALLPAPERS" : "Walls",
"GAME_INVENTORY_WALLS" : "Walls",
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Equipments"
}

View File

@@ -11,6 +11,6 @@
"GAME_INVENTORY_INGREDIENTS" : "Ainekset",
"GAME_INVENTORY_POTIONS" : "Juomat",
"GAME_INVENTORY_BLOCKS" : "Lohkareet",
"GAME_INVENTORY_WALLPAPERS" : "Tapetit",
"GAME_INVENTORY_WALLS" : "Seinät",
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Varusteet"
}

View File

@@ -6,5 +6,11 @@
"APP_ADJUST_YOUR_MONITOR": "Meilleur l'expérience du joueur peut être obtenue avec un écran correctement réglé. Si vous ne l'avez pas, faites-le avant de jouer.",
"APP_WARNING_HEALTH_AND_SAFETY": "ATTENTION-SANTÉ ET SÉCURITÉ",
"MENU_LABEL_PRESS_START_SYMBOL": "Appuyez sur >"
"MENU_LABEL_PRESS_START_SYMBOL": "Appuyez sur >",
"GAME_INVENTORY_INGREDIENTS" : "Ingrédients",
"GAME_INVENTORY_POTIONS" : "Potions",
"GAME_INVENTORY_BLOCKS" : "Blocs",
"GAME_INVENTORY_WALLS" : "Murs",
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "Équipements"
}

View File

@@ -11,6 +11,6 @@
"GAME_INVENTORY_INGREDIENTS" : "재료",
"GAME_INVENTORY_POTIONS" : "물약",
"GAME_INVENTORY_BLOCKS" : "블록",
"GAME_INVENTORY_WALLPAPERS" : "벽지",
"GAME_INVENTORY_WALLS" : "벽지",
"CONTEXT_ITEM_EQUIPMENT_PLURAL" : "장비"
}

View File

@@ -9,6 +9,7 @@ import net.torvald.terrarum.virtualcomputer.terminal.GraphicsTerminal
import org.lwjgl.opengl.GL11
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Image
import org.newdawn.slick.state.BasicGameState
import org.newdawn.slick.state.StateBasedGame
import java.util.*
@@ -20,19 +21,25 @@ class StateGraphicComputerTest : BasicGameState() {
val computer = TerrarumComputer(8)
val monitor = GraphicsTerminal(computer)
val monitorUI: Image
val monitorUIG: Graphics
init {
val videocard = PeripheralVideoCard(computer)
monitor.attachVideoCard(videocard)
computer.attachTerminal(monitor)
computer.attachPeripheral(videocard)
monitorUI = Image(videocard.width, videocard.height * 2)
monitorUIG = monitorUI.graphics
}
override fun init(container: GameContainer?, game: StateBasedGame?) {
val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard).vram
// it's a-me, Mario!
/*(0..3).forEach {
(0..3).forEach {
vcard.sprites[it].setPaletteSet(64,33,12,62)
vcard.sprites[it].isVisible = true
vcard.sprites[it].drawWide = true
@@ -77,9 +84,11 @@ class StateGraphicComputerTest : BasicGameState() {
0,1,1,1,0,0,0,0,
0,0,2,2,2,0,0,0,
0,0,2,2,2,2,0,0
))*/
))
}
var angle = 0.0
override fun update(container: GameContainer, game: StateBasedGame?, delta: Int) {
UPDATE_DELTA = delta
@@ -90,17 +99,30 @@ class StateGraphicComputerTest : BasicGameState() {
computer.update(container, delta)
/*val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard).vram
vcard.sprites[0].setPos(20, 20)
vcard.sprites[1].setPos(36, 20)
vcard.sprites[2].setPos(20, 28)
vcard.sprites[3].setPos(36, 28)*/
val vcard = (computer.getPeripheral("ppu") as PeripheralVideoCard).vram
val sprites = vcard.sprites
angle += delta / 1000.0
sprites[0].posX = (Math.cos(angle) * 80 + 100).roundInt() - 16
sprites[0].posY = (Math.sin(angle) * 0 + 100).roundInt() - 8
sprites[1].posX = (Math.cos(angle) * 80 + 100).roundInt()
sprites[1].posY = (Math.sin(angle) * 0 + 100).roundInt() - 8
sprites[2].posX = (Math.cos(angle) * 80 + 100).roundInt() - 16
sprites[2].posY = (Math.sin(angle) * 0 + 100).roundInt()
sprites[3].posX = (Math.cos(angle) * 80 + 100).roundInt()
sprites[3].posY = (Math.sin(angle) * 0 + 100).roundInt()
}
override fun getID() = Terrarum.STATE_ID_TEST_TTY
override fun render(container: GameContainer, game: StateBasedGame?, g: Graphics) {
monitor.render(container, g)
monitor.render(container, monitorUIG)
g.drawImage(monitorUI, 30f, 30f)
}
override fun keyPressed(key: Int, c: Char) {

View File

@@ -25,6 +25,7 @@ class StateUITest : BasicGameState() {
init {
ui.posX = 50
ui.posY = 30
ui.isVisible = true
@@ -64,8 +65,8 @@ class StateUITest : BasicGameState() {
private class SimpleUI : UICanvas {
override var width = 400
override var height = 600
override var width = 700
override var height = 440 // multiple of 40 (2 * font.lineHeight)
override var handler: UIHandler? = null
override var openCloseTime: Int = UICanvas.OPENCLOSE_GENERIC
@@ -77,12 +78,16 @@ private class SimpleUI : UICanvas {
"CONTEXT_ITEM_ARMOR",
"GAME_INVENTORY_INGREDIENTS",
"GAME_INVENTORY_POTIONS",
"CONTEXT_ITEM_MAGIC",
"GAME_INVENTORY_BLOCKS",
"GAME_INVENTORY_WALLPAPERS",
"GAME_INVENTORY_WALLS",
"MENU_LABEL_ALL"
),
300, height,
readFromLang = true
width = (width / 3 / 100) * 100, // chop to hundreds unit (100, 200, 300, ...) with the black magic of integer division
height = height,
readFromLang = true,
highlightBackCol = Color(0x202020),
highlightBackBlendMode = BlendMode.NORMAL
)
override fun update(gc: GameContainer, delta: Int) {
@@ -92,8 +97,11 @@ private class SimpleUI : UICanvas {
}
override fun render(gc: GameContainer, g: Graphics) {
g.color = Color(0x282828)
g.fillRect(0f, 0f, 300f, 600f)
g.color = Color(0x202020)
g.fillRect(0f, 0f, width.toFloat(), height.toFloat())
g.color = Color(0x383838)
g.fillRect(0f, 0f, buttons.width.toFloat(), height.toFloat())
buttons.render(gc, g)

View File

@@ -539,6 +539,23 @@ fun blendDisable() {
GL11.glDisable(GL11.GL_BLEND)
}
object BlendMode {
const val SCREEN = "GL_BLEND screen"
const val MULTIPLY = "GL_BLEND multiply"
const val NORMAL = "GL_BLEND normal"
const val MAX = "GL_MAX"
fun resolve(mode: String) {
when (mode) {
SCREEN -> blendScreen()
MULTIPLY -> blendMul()
NORMAL -> blendNormal()
MAX -> blendLightenOnly()
else -> throw Error("Unknown blend mode: $mode")
}
}
}
enum class RunningEnvironment {
PC, CONSOLE, MOBILE
}

View File

@@ -35,7 +35,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
@Transient internal var sprite: SpriteAnimation? = null
@Transient internal var spriteGlow: SpriteAnimation? = null
var drawMode = BLEND_NORMAL
var drawMode = BlendMode.NORMAL
@Transient private val world: GameWorld = Terrarum.ingame!!.world
@@ -1090,11 +1090,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
override fun drawBody(g: Graphics) {
if (isVisible && sprite != null) {
when (drawMode) {
BLEND_NORMAL -> blendNormal()
BLEND_MULTIPLY -> blendMul()
BLEND_SCREEN -> blendScreen()
}
BlendMode.resolve(drawMode)
val offsetX = if (!sprite!!.flippedHorizontal())
hitboxTranslateX * scale
@@ -1259,9 +1255,6 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
@Transient const val COLLISION_STATIC = 3
@Transient const val COLLISION_KNOCKBACK_GIVER = 4 // mobs
@Transient const val COLLISION_KNOCKBACK_TAKER = 5 // benevolent NPCs
@Transient const val BLEND_NORMAL = 4
@Transient const val BLEND_SCREEN = 5
@Transient const val BLEND_MULTIPLY = 6
@Transient private val TILE_SIZE = FeaturesDrawer.TILE_SIZE

View File

@@ -28,8 +28,9 @@ class UIInventory : UICanvas {
"CONTEXT_ITEM_ARMOR",
"GAME_INVENTORY_INGREDIENTS",
"GAME_INVENTORY_POTIONS",
"CONTEXT_ITEM_MAGIC",
"GAME_INVENTORY_BLOCKS",
"GAME_INVENTORY_WALLPAPERS",
"GAME_INVENTORY_WALLS",
"MENU_LABEL_ALL"
)

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.ui
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.*
import net.torvald.terrarum.langpack.Lang
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
@@ -19,8 +19,12 @@ class UIItemTextButton(
override val width: Int,
val readFromLang: Boolean = false,
val activeCol: Color = Color.white,
val activeBackCol: Color = Color(0xd0d0d0),
val activeBackBlendMode: String = BlendMode.MULTIPLY,
val highlightCol: Color = Color(0x00f8ff),
val inactiveCol: Color = Color(0xc0c0c0)
val highlightBackCol: Color = Color(0xb0b0b0),
val highlightBackBlendMode: String = BlendMode.MULTIPLY,
val inactiveCol: Color = Color(0xc8c8c8)
) : UIItem(parentUI) {
companion object {
@@ -44,6 +48,21 @@ class UIItemTextButton(
override fun render(gc: GameContainer, g: Graphics) {
val textW = font.getWidth(label)
if (highlighted) {
BlendMode.resolve(highlightBackBlendMode)
g.color = highlightBackCol
g.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
}
else if (mouseOver) {
BlendMode.resolve(activeBackBlendMode)
g.color = activeBackCol
g.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
}
blendNormal()
g.font = font
mouseOver = mouseUp
g.color = if (highlighted) highlightCol
@@ -79,4 +98,4 @@ class UIItemTextButton(
override fun controllerButtonReleased(controller: Int, button: Int) {
}
}
}

View File

@@ -1,7 +1,9 @@
package net.torvald.terrarum.ui
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.gameactors.roundInt
import net.torvald.terrarum.langpack.Lang
import org.newdawn.slick.Color
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
@@ -13,17 +15,33 @@ class UIItemTextButtonList(
labelsList: Array<String>,
override val width: Int,
override val height: Int,
val readFromLang: Boolean = false
val readFromLang: Boolean = false,
// copied directly from UIItemTextButton
activeCol: Color = Color.white,
activeBackCol: Color = Color(0xd0d0d0),
activeBackBlendMode: String = BlendMode.MULTIPLY,
highlightCol: Color = Color(0x00f8ff),
highlightBackCol: Color = Color(0xb0b0b0),
highlightBackBlendMode: String = BlendMode.MULTIPLY,
inactiveCol: Color = Color(0xc8c8c8)
) : UIItem(parentUI) {
val buttons = labelsList.mapIndexed { index, s ->
val height = this.height - UIItemTextButton.height
UIItemTextButton(
parentUI, s,
0,
(height / labelsList.size.minus(1).toFloat() * index).roundInt(),
width,
readFromLang = true
posX = 0,
posY = (height / labelsList.size.minus(1).toFloat() * index).roundInt(),
width = width,
readFromLang = true,
activeCol = activeCol,
activeBackCol = activeBackCol,
activeBackBlendMode = activeBackBlendMode,
highlightCol = highlightCol,
highlightBackCol = highlightBackCol,
highlightBackBlendMode = highlightBackBlendMode,
inactiveCol = inactiveCol
)
}