mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-12 14:51:51 +09:00
F12 for screenshot; it's high time to care about TVs
(besides, the EBU gap is also a good guideline for placing UIs on edge)
This commit is contained in:
@@ -110,6 +110,14 @@ public class AppLoader implements ApplicationListener {
|
|||||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2019 Torvald (minjaesong)";
|
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2019 Torvald (minjaesong)";
|
||||||
public static String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
public static String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||||
|
|
||||||
|
public static final float TV_SAFE_GRAPHICS = 0.05f; // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf)
|
||||||
|
public static final float TV_SAFE_ACTION = 0.035f; // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf)
|
||||||
|
|
||||||
|
public static int getTvSafeGraphicsWidth() { return Math.round(screenW * TV_SAFE_GRAPHICS); }
|
||||||
|
public static int getTvSafeGraphicsHeight() { return Math.round(screenH * TV_SAFE_GRAPHICS); }
|
||||||
|
public static int getTvSafeActionWidth() { return Math.round(screenW * TV_SAFE_ACTION); }
|
||||||
|
public static int getTvSafeActionHeight() { return Math.round(screenH * TV_SAFE_ACTION); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These languages won't distinguish regional differences (e.g. enUS and enUK, frFR and frCA)
|
* These languages won't distinguish regional differences (e.g. enUS and enUK, frFR and frCA)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ object PostProcessor {
|
|||||||
lutTex = Texture(Gdx.files.internal("assets/clut/$filename"))
|
lutTex = Texture(Gdx.files.internal("assets/clut/$filename"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val defaultResCol = Color(0x00ffffdd)
|
||||||
|
private val safeAreaCol = Color(0xffffffaa.toInt())
|
||||||
|
private val safeAreaCol2 = Color(0xffffff66.toInt())
|
||||||
|
|
||||||
fun draw(projMat: Matrix4, fbo: FrameBuffer) {
|
fun draw(projMat: Matrix4, fbo: FrameBuffer) {
|
||||||
|
|
||||||
// init
|
// init
|
||||||
@@ -68,8 +72,23 @@ object PostProcessor {
|
|||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
if (AppLoader.IS_DEVELOPMENT_BUILD) {
|
||||||
shapeRenderer.color = Color.CYAN
|
val tvSafeAreaW = AppLoader.getTvSafeGraphicsWidth().toFloat()
|
||||||
|
val tvSafeAreaH = AppLoader.getTvSafeGraphicsHeight().toFloat()
|
||||||
|
val tvSafeArea2W = AppLoader.getTvSafeActionWidth().toFloat()
|
||||||
|
val tvSafeArea2H = AppLoader.getTvSafeActionHeight().toFloat()
|
||||||
|
|
||||||
shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) {
|
shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) {
|
||||||
|
shapeRenderer.color = safeAreaCol2
|
||||||
|
shapeRenderer.rect(
|
||||||
|
tvSafeArea2W, tvSafeArea2H, AppLoader.screenW - 2 * tvSafeArea2W, AppLoader.screenH - 2 * tvSafeArea2H
|
||||||
|
)
|
||||||
|
|
||||||
|
shapeRenderer.color = safeAreaCol
|
||||||
|
shapeRenderer.rect(
|
||||||
|
tvSafeAreaW, tvSafeAreaH, AppLoader.screenW - 2 * tvSafeAreaW, AppLoader.screenH - 2 * tvSafeAreaH
|
||||||
|
)
|
||||||
|
|
||||||
|
shapeRenderer.color = defaultResCol
|
||||||
shapeRenderer.rect(
|
shapeRenderer.rect(
|
||||||
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
||||||
(AppLoader.screenH - AppLoader.defaultH).div(2).toFloat(),
|
(AppLoader.screenH - AppLoader.defaultH).div(2).toFloat(),
|
||||||
@@ -79,8 +98,14 @@ object PostProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
batch.color = Color.CYAN
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
|
batch.color = safeAreaCol
|
||||||
|
AppLoader.fontSmallNumbers.draw(
|
||||||
|
batch, safeAreaStr,
|
||||||
|
tvSafeAreaW, tvSafeAreaH - 10
|
||||||
|
)
|
||||||
|
|
||||||
|
batch.color = defaultResCol
|
||||||
AppLoader.fontSmallNumbers.draw(
|
AppLoader.fontSmallNumbers.draw(
|
||||||
batch, defaultResStr,
|
batch, defaultResStr,
|
||||||
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
||||||
@@ -94,6 +119,7 @@ object PostProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val defaultResStr = "${AppLoader.defaultW}x${AppLoader.defaultH}"
|
private val defaultResStr = "${AppLoader.defaultW}x${AppLoader.defaultH}"
|
||||||
|
private val safeAreaStr = "TV Safe Area"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Camera will be moved so that (newX, newY) would be sit on the top-left edge.
|
* Camera will be moved so that (newX, newY) would be sit on the top-left edge.
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.Input
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import net.torvald.spriteanimation.SpriteAnimation
|
import net.torvald.spriteanimation.SpriteAnimation
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
@@ -9,7 +7,6 @@ import net.torvald.terrarum.AppLoader.printdbg
|
|||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||||
import net.torvald.terrarum.blockproperties.BlockProp
|
import net.torvald.terrarum.blockproperties.BlockProp
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
|
||||||
import net.torvald.terrarum.gameworld.BlockAddress
|
import net.torvald.terrarum.gameworld.BlockAddress
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
@@ -1343,10 +1340,11 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
|||||||
|
|
||||||
override fun drawBody(batch: SpriteBatch) {
|
override fun drawBody(batch: SpriteBatch) {
|
||||||
if (isVisible && sprite != null) {
|
if (isVisible && sprite != null) {
|
||||||
if (!KeyToggler.isOn(Input.Keys.F12)) {
|
//if (!KeyToggler.isOn(Input.Keys.F12)) {
|
||||||
BlendMode.resolve(drawMode, batch)
|
BlendMode.resolve(drawMode, batch)
|
||||||
drawSpriteInGoodPosition(sprite!!, batch)
|
drawSpriteInGoodPosition(sprite!!, batch)
|
||||||
}
|
/*}
|
||||||
|
// ye olde tilewiseposition debugger, we don't use it anymore.
|
||||||
else {
|
else {
|
||||||
batch.color = Color.NAVY
|
batch.color = Color.NAVY
|
||||||
val hb = intTilewiseHitbox
|
val hb = intTilewiseHitbox
|
||||||
@@ -1360,7 +1358,7 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
|||||||
|
|
||||||
batch.color = Color.VIOLET
|
batch.color = Color.VIOLET
|
||||||
batch.fillRect(hitbox.startX.toFloat(), hitbox.startY.toFloat(), hitbox.width.toFloat(), hitbox.height.toFloat())
|
batch.fillRect(hitbox.startX.toFloat(), hitbox.startY.toFloat(), hitbox.width.toFloat(), hitbox.height.toFloat())
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
/////////////////////
|
/////////////////////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var f12Down = false
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
|
|
||||||
if (ingame.canPlayerControl) {
|
if (ingame.canPlayerControl) {
|
||||||
@@ -98,6 +100,15 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// screenshot key
|
||||||
|
if (keycode == Input.Keys.F12 && !f12Down) {
|
||||||
|
AppLoader.requestScreenshot()
|
||||||
|
// FIXME
|
||||||
|
//ingame.sendNotification(arrayOf("Screenshot taken", ""))
|
||||||
|
f12Down = true
|
||||||
|
println("Screenshot taken.")
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +122,10 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
ingame.uiContainer.forEach { it.keyUp(keycode) } // for KeyboardControlled UIcanvases
|
ingame.uiContainer.forEach { it.keyUp(keycode) } // for KeyboardControlled UIcanvases
|
||||||
|
|
||||||
|
|
||||||
|
// screenshot key
|
||||||
|
if (keycode == Input.Keys.F12) f12Down = false
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gamecontroller
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-01-15.
|
* Created by minjaesong on 2016-01-15.
|
||||||
*/
|
*/
|
||||||
@Deprecated("Use Gdx.Input.Keys")
|
/*@Deprecated("Use Gdx.Input.Keys")
|
||||||
object DeprecatedAsFuckKey {
|
object DeprecatedAsFuckKey {
|
||||||
|
|
||||||
val RETURN = 28
|
val RETURN = 28
|
||||||
@@ -90,4 +90,4 @@ object DeprecatedAsFuckKey {
|
|||||||
val PGDN = 209
|
val PGDN = 209
|
||||||
val HOME = 199
|
val HOME = 199
|
||||||
val END = 207
|
val END = 207
|
||||||
}
|
}*/
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
// quick bar
|
// quick bar
|
||||||
uiQuickBar = UIQuickslotBar()
|
uiQuickBar = UIQuickslotBar()
|
||||||
uiQuickBar.isVisible = true
|
uiQuickBar.isVisible = true
|
||||||
uiQuickBar.setPosition((Terrarum.WIDTH - uiQuickBar.width) / 2, 8)
|
uiQuickBar.setPosition((Terrarum.WIDTH - uiQuickBar.width) / 2, AppLoader.getTvSafeGraphicsHeight())
|
||||||
|
|
||||||
// pie menu
|
// pie menu
|
||||||
uiPieMenu = uiQuickslotPie()
|
uiPieMenu = uiQuickslotPie()
|
||||||
|
|||||||
Reference in New Issue
Block a user