mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
gapbox toggle with F11
This commit is contained in:
@@ -2,6 +2,7 @@ package net.torvald.terrarum;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.audio.AudioDevice;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
@@ -16,6 +17,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import net.torvald.dataclass.ArrayListMap;
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler;
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum;
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer;
|
||||
import net.torvald.terrarum.utils.JsonFetcher;
|
||||
@@ -151,6 +153,8 @@ public class AppLoader implements ApplicationListener {
|
||||
private static boolean splashDisplayed = false;
|
||||
private static boolean postInitFired = false;
|
||||
private static boolean screenshotRequested = false;
|
||||
private static boolean resizeRequested = false;
|
||||
private static Point2i resizeReqSize;
|
||||
|
||||
public static LwjglApplicationConfiguration appConfig;
|
||||
public static GameFontBase fontGame;
|
||||
@@ -164,8 +168,10 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
public static ArrayListMap debugTimers = new ArrayListMap<String, Long>();
|
||||
|
||||
static final int defaultW = 1110;
|
||||
static final int defaultH = 740;
|
||||
public static final int defaultW = 1110;
|
||||
public static final int defaultH = 740;
|
||||
public static final int minimumW = 1080;
|
||||
public static final int minimumH = 720;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// load configs
|
||||
@@ -191,6 +197,8 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
if (args.length == 1 && args[0].equals("isdev=true")) {
|
||||
IS_DEVELOPMENT_BUILD = true;
|
||||
// safe area box
|
||||
KeyToggler.INSTANCE.forceSet(Input.Keys.F11, true);
|
||||
}
|
||||
|
||||
new LwjglApplication(new AppLoader(appConfig), appConfig);
|
||||
@@ -320,6 +328,13 @@ public class AppLoader implements ApplicationListener {
|
||||
PostProcessor.INSTANCE.draw(camera.combined, renderFBO);
|
||||
|
||||
|
||||
// process resize request
|
||||
if (resizeRequested) {
|
||||
resizeRequested = false;
|
||||
resize(resizeReqSize.getX(), resizeReqSize.getY());
|
||||
}
|
||||
|
||||
|
||||
// process screenshot request
|
||||
if (screenshotRequested) {
|
||||
screenshotRequested = false;
|
||||
@@ -340,6 +355,11 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
printdbg(this, "Resize called");
|
||||
for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) {
|
||||
printdbg(this, stackTraceElement);
|
||||
}
|
||||
|
||||
//initViewPort(width, height);
|
||||
|
||||
screenW = width;
|
||||
@@ -368,7 +388,12 @@ public class AppLoader implements ApplicationListener {
|
||||
|
||||
updateFullscreenQuad(screenW, screenH);
|
||||
|
||||
printdbg(this, "Resize event");
|
||||
printdbg(this, "Resize end");
|
||||
}
|
||||
|
||||
public static void resizeScreen(int width, int height) {
|
||||
resizeRequested = true;
|
||||
resizeReqSize = new Point2i(Math.max(width, minimumW), Math.max(height, minimumH));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.GL20
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
@@ -10,6 +11,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/**
|
||||
@@ -71,7 +73,7 @@ object PostProcessor {
|
||||
|
||||
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 && KeyToggler.isOn(Input.Keys.F11)) {
|
||||
val tvSafeAreaW = AppLoader.getTvSafeGraphicsWidth().toFloat()
|
||||
val tvSafeAreaH = AppLoader.getTvSafeGraphicsHeight().toFloat()
|
||||
val tvSafeArea2W = AppLoader.getTvSafeActionWidth().toFloat()
|
||||
@@ -90,10 +92,10 @@ object PostProcessor {
|
||||
|
||||
shapeRenderer.color = defaultResCol
|
||||
shapeRenderer.rect(
|
||||
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
||||
(AppLoader.screenH - AppLoader.defaultH).div(2).toFloat(),
|
||||
AppLoader.defaultW.toFloat(),
|
||||
AppLoader.defaultH.toFloat()
|
||||
(AppLoader.screenW - AppLoader.minimumW).div(2).toFloat(),
|
||||
(AppLoader.screenH - AppLoader.minimumH).div(2).toFloat(),
|
||||
AppLoader.minimumW.toFloat(),
|
||||
AppLoader.minimumH.toFloat()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -108,8 +110,8 @@ object PostProcessor {
|
||||
batch.color = defaultResCol
|
||||
AppLoader.fontSmallNumbers.draw(
|
||||
batch, defaultResStr,
|
||||
(AppLoader.screenW - AppLoader.defaultW).div(2).toFloat(),
|
||||
(AppLoader.screenH - AppLoader.defaultH).div(2).minus(10).toFloat()
|
||||
(AppLoader.screenW - AppLoader.minimumW).div(2).toFloat(),
|
||||
(AppLoader.screenH - AppLoader.minimumH).div(2).minus(10).toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -118,7 +120,7 @@ object PostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private val defaultResStr = "${AppLoader.defaultW}x${AppLoader.defaultH}"
|
||||
private val defaultResStr = "${AppLoader.minimumW}x${AppLoader.minimumH}"
|
||||
private val safeAreaStr = "TV Safe Area"
|
||||
|
||||
/**
|
||||
|
||||
@@ -433,11 +433,9 @@ object Terrarum : Screen {
|
||||
AppLoader.getINSTANCE().screen.hide()
|
||||
}
|
||||
|
||||
/** For the actual resize, call AppLoader.resize() */
|
||||
override fun resize(width: Int, height: Int) {
|
||||
/*try {
|
||||
AppLoader.getINSTANCE().screen.resize(width, height)
|
||||
}
|
||||
catch (e: NullPointerException) { }*/ // I sense circular recursion...
|
||||
ingame?.resize(width, height)
|
||||
|
||||
printdbg(this, "newsize: ${Gdx.graphics.width}x${Gdx.graphics.height} | internal: ${width}x$height")
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ object CommandDict {
|
||||
"kill" to KillActor,
|
||||
"money" to MoneyDisp,
|
||||
"screenshot" to TakeScreenshot,
|
||||
//"resize" to ResizeScreen,
|
||||
|
||||
// Test codes
|
||||
"bulletintest" to SetBulletin,
|
||||
|
||||
@@ -22,7 +22,8 @@ internal object CommandInterpreter {
|
||||
"help",
|
||||
"version",
|
||||
"tips",
|
||||
"screenshot"
|
||||
"screenshot",
|
||||
"resize"
|
||||
)
|
||||
|
||||
internal fun execute(command: String) {
|
||||
|
||||
30
src/net/torvald/terrarum/console/ResizeScreen.kt
Normal file
30
src/net/torvald/terrarum/console/ResizeScreen.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
object ResizeScreen: ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 3) {
|
||||
Terrarum.resize(args[1].toInt(), args[2].toInt())
|
||||
}
|
||||
else if (args.size == 2) {
|
||||
when (args[1]) {
|
||||
"720p" -> AppLoader.resizeScreen(1280,720)
|
||||
"1080p" -> AppLoader.resizeScreen(1920,1080)
|
||||
"default" -> AppLoader.resizeScreen(AppLoader.defaultW, AppLoader.defaultH)
|
||||
else -> { printUsage(); return }
|
||||
}
|
||||
}
|
||||
else {
|
||||
printUsage(); return
|
||||
}
|
||||
|
||||
Echo("Screen resized to ${AppLoader.screenW}x${AppLoader.screenH}")
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Usage: resize [width] [height]. Minimum size is ${AppLoader.minimumW}x${AppLoader.minimumH}")
|
||||
Echo("Reserved keywords: 720p, 1080p, default")
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class UIItemInventoryDynamicList(
|
||||
|
||||
companion object {
|
||||
const val listGap = 8
|
||||
const val horizontalCells = 12
|
||||
const val horizontalCells = 11
|
||||
const val verticalCells = 8
|
||||
val largeListWidth = (horizontalCells * UIItemInventoryElemSimple.height + (horizontalCells - 2) * listGap) / 2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user