mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fullscreen GUI complications wip
This commit is contained in:
@@ -432,7 +432,6 @@ public class App implements ApplicationListener {
|
||||
scr = new TerrarumScreenSize(getConfigInt("screenwidth"), getConfigInt("screenheight"));
|
||||
int width = scr.getWindowW();
|
||||
int height = scr.getWindowH();
|
||||
boolean useFullscreen = getConfigBoolean("fullscreen");
|
||||
float magn = (float) getConfigDouble("screenmagnifying");
|
||||
|
||||
Lwjgl3ApplicationConfiguration appConfig = new Lwjgl3ApplicationConfiguration();
|
||||
@@ -524,7 +523,7 @@ public class App implements ApplicationListener {
|
||||
printdbg(this, "Fullscreen display resolution: " + w + "x" + h);
|
||||
var newWidth = ((int) (w / magn)) & 0x7FFFFFFE;
|
||||
var newHeight = ((int) (h / magn)) & 0x7FFFFFFE;
|
||||
scr.setDimension(newWidth, newHeight, magn);
|
||||
scr.setDimension(newWidth, newHeight, magn, useFullscreen);
|
||||
|
||||
Gdx.graphics.setFullscreenMode(selected);
|
||||
}
|
||||
@@ -915,7 +914,7 @@ public class App implements ApplicationListener {
|
||||
|
||||
//initViewPort(width, height);
|
||||
|
||||
scr.setDimension(width, height, magn);
|
||||
scr.setDimension(width, height, magn, scr.isFullscreen());
|
||||
|
||||
if (currentScreen != null) currentScreen.resize(scr.getWidth(), scr.getHeight());
|
||||
TerrarumPostProcessor.INSTANCE.resize(scr.getWidth(), scr.getHeight());
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.badlogic.gdx.utils.Disposable
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.App.IS_DEVELOPMENT_BUILD
|
||||
import net.torvald.terrarum.TerrarumScreenSize.Companion.TV_SAFE_ACTION
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.savegame.toHex
|
||||
import net.torvald.terrarum.ui.BasicDebugInfoWindow
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.unsafe.UnsafeHelper
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
/**
|
||||
* Must be called by the App Loader
|
||||
@@ -109,8 +109,14 @@ object TerrarumPostProcessor : Disposable {
|
||||
Gdx.gl20.glViewport(0, 0, App.scr.width, App.scr.height)
|
||||
|
||||
resize(App.scr.width, App.scr.height)
|
||||
|
||||
update()
|
||||
}
|
||||
|
||||
// update every 1 second or so
|
||||
if (App.GLOBAL_RENDER_TIMER % Gdx.graphics.framesPerSecond.coerceAtLeast(20) == 1L)
|
||||
update()
|
||||
|
||||
|
||||
debugUI.update(Gdx.graphics.deltaTime)
|
||||
|
||||
@@ -166,6 +172,10 @@ object TerrarumPostProcessor : Disposable {
|
||||
if (!debugUI.isClosed && !debugUI.isClosing) debugUI.setAsClose()
|
||||
}
|
||||
|
||||
if (App.scr.isFullscreen) {
|
||||
drawFullscreenComplications()
|
||||
}
|
||||
|
||||
// draw dev build notifiers
|
||||
// omitting this screws up HQ2X render for some reason
|
||||
if (Terrarum.ingame != null) {
|
||||
@@ -370,6 +380,38 @@ object TerrarumPostProcessor : Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
fun update() {
|
||||
val time = ZonedDateTime.now()
|
||||
clockH = time.hour.toString().padStart(2,'0')
|
||||
clockM = time.minute.toString().padStart(2,'0')
|
||||
clockS = time.second.toString().padStart(2,'0')
|
||||
clockN = time.nano.toString()
|
||||
}
|
||||
|
||||
private var clockH = "00"
|
||||
private var clockM = "00"
|
||||
private var clockS = "00"
|
||||
private var clockN = "0"
|
||||
private var hasBattery = false
|
||||
private var isCharging = false
|
||||
private var batteryPercentage = "0%"
|
||||
|
||||
private fun drawFullscreenComplications() {
|
||||
val tvSafeArea2H = App.scr.tvSafeActionHeight.toFloat()
|
||||
val dockHeight = tvSafeArea2H
|
||||
val watchWidth = App.fontSmallNumbers.W * 15
|
||||
val watchHeight = 14
|
||||
val marginEach = (dockHeight - watchHeight) / 2f
|
||||
val wx = (App.scr.width - marginEach * 1.5f - watchWidth).floorToFloat()
|
||||
val wy = marginEach.ceilToFloat()
|
||||
val watchStr = "$clockH:$clockM:$clockS.$clockN"
|
||||
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
App.fontSmallNumbers.draw(batch, watchStr, wx, wy)
|
||||
}
|
||||
}
|
||||
|
||||
private val defaultResStr = "Ingame UI Area"
|
||||
private val currentResStr = "${App.scr.width}x${App.scr.height}"
|
||||
private val safeAreaStr = "TV Safe Area"
|
||||
|
||||
@@ -39,11 +39,16 @@ class TerrarumScreenSize(scrw: Int = defaultW, scrh: Int = defaultH) {
|
||||
/** Apparent window size. `roundToEven(height * magn)` */
|
||||
var windowH: Int = 0; private set
|
||||
|
||||
var isFullscreen: Boolean = false; private set
|
||||
|
||||
init {
|
||||
setDimension(max(minimumW, scrw), max(minimumH, scrh), App.getConfigDouble("screenmagnifying").toFloat())
|
||||
setDimension(max(minimumW, scrw), max(minimumH, scrh),
|
||||
App.getConfigDouble("screenmagnifying").toFloat(),
|
||||
App.getConfigBoolean("fullscreen")
|
||||
)
|
||||
}
|
||||
|
||||
fun setDimension(scrw: Int, scrh: Int, magn: Float,) {
|
||||
fun setDimension(scrw: Int, scrh: Int, magn: Float, isFullscreen: Boolean) {
|
||||
width = scrw and 0x7FFFFFFE
|
||||
height = scrh and 0x7FFFFFFE
|
||||
wf = scrw.toFloat()
|
||||
@@ -60,6 +65,7 @@ class TerrarumScreenSize(scrw: Int = defaultW, scrh: Int = defaultH) {
|
||||
windowW = (scrw * magn + 1).ceilToInt() and 0x7FFFFFFE
|
||||
windowH = (scrh * magn + 1).ceilToInt() and 0x7FFFFFFE
|
||||
|
||||
this.isFullscreen = isFullscreen
|
||||
|
||||
printdbg(this, "Window dim: $windowW x $windowH, called by:")
|
||||
printStackTrace(this)
|
||||
|
||||
Reference in New Issue
Block a user