new tiny numbers font

This commit is contained in:
minjaesong
2019-06-26 19:32:27 +09:00
parent 98ec8154d5
commit da1c752996
10 changed files with 184 additions and 172 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -198,51 +198,6 @@ public class AppLoader implements ApplicationListener {
public static final int minimumW = 1080;
public static final int minimumH = 720;
public static void main(String[] args) {
// load configs
getDefaultDirectory();
createDirs();
readConfigJson();
try { processor = GetCpuName.getModelName(); }
catch (IOException e1) { processor = "Unknown CPU"; }
try { processorVendor = GetCpuName.getCPUID(); }
catch (IOException e2) { processorVendor = "Unknown CPU"; }
ShaderProgram.pedantic = false;
LwjglApplicationConfiguration appConfig = new LwjglApplicationConfiguration();
appConfig.useGL30 = true; // utilising some GL trickeries, need this to be TRUE
appConfig.vSyncEnabled = getConfigBoolean("usevsync");
appConfig.resizable = false;//true;
//appConfig.width = 1110; // photographic ratio (1.5:1)
//appConfig.height = 740; // photographic ratio (1.5:1)
appConfig.width = getConfigInt("screenwidth");
appConfig.height = getConfigInt("screenheight");
appConfig.backgroundFPS = getConfigInt("displayfps");
appConfig.foregroundFPS = getConfigInt("displayfps");
appConfig.title = GAME_NAME;
appConfig.forceExit = false;
// load app icon
int[] appIconSizes = new int[]{256,128,64,32,16};
for (int size : appIconSizes) {
String name = "assets/appicon" + size + ".png";
if (new File("./" + name).exists()) {
appConfig.addIcon(name, Files.FileType.Internal);
}
}
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);
}
private static ShaderProgram shaderBayerSkyboxFill;
@@ -288,6 +243,76 @@ public class AppLoader implements ApplicationListener {
public static HashSet<File> tempFilePool = new HashSet();
public static HashSet<Disposable> disposableSingletonsPool = new HashSet();
public static char gamepadLabelStart = 0xE000; // lateinit
public static char gamepadLabelSelect = 0xE000; // lateinit
public static char gamepadLabelEast = 0xE000; // lateinit
public static char gamepadLabelSouth = 0xE000; // lateinit
public static char gamepadLabelNorth = 0xE000; // lateinit
public static char gamepadLabelWest = 0xE000; // lateinit
public static char gamepadLabelLB = 0xE000; // lateinit
public static char gamepadLabelRB = 0xE000; // lateinit
public static char gamepadLabelLT = 0xE000; // lateinit
public static char gamepadLabelRT = 0xE000; // lateinit
public static char gamepadLabelLEFT = 0xE068;
public static char gamepadLabelDOWN = 0xE069;
public static char gamepadLabelUP = 0xE06A;
public static char gamepadLabelRIGHT = 0xE06B;
public static char gamepadLabelUPDOWN = 0xE072;
public static char gamepadLabelLEFTRIGHT = 0xE071;
public static char gamepadLabelDPAD = 0xE070;
public static char gamepadLabelLStick = 0xE044;
public static char gamepadLabelRStick = 0xE045;
public static char gamepadLabelLStickPush = 0xE046;
public static char gamepadLabelRStickPush = 0xE047;
public static void main(String[] args) {
// load configs
getDefaultDirectory();
createDirs();
readConfigJson();
setGamepadButtonLabels();
try { processor = GetCpuName.getModelName(); }
catch (IOException e1) { processor = "Unknown CPU"; }
try { processorVendor = GetCpuName.getCPUID(); }
catch (IOException e2) { processorVendor = "Unknown CPU"; }
ShaderProgram.pedantic = false;
LwjglApplicationConfiguration appConfig = new LwjglApplicationConfiguration();
appConfig.useGL30 = true; // utilising some GL trickeries, need this to be TRUE
appConfig.vSyncEnabled = getConfigBoolean("usevsync");
appConfig.resizable = false;//true;
//appConfig.width = 1110; // photographic ratio (1.5:1)
//appConfig.height = 740; // photographic ratio (1.5:1)
appConfig.width = getConfigInt("screenwidth");
appConfig.height = getConfigInt("screenheight");
appConfig.backgroundFPS = getConfigInt("displayfps");
appConfig.foregroundFPS = getConfigInt("displayfps");
appConfig.title = GAME_NAME;
appConfig.forceExit = false;
// load app icon
int[] appIconSizes = new int[]{256,128,64,32,16};
for (int size : appIconSizes) {
String name = "assets/appicon" + size + ".png";
if (new File("./" + name).exists()) {
appConfig.addIcon(name, Files.FileType.Internal);
}
}
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);
}
@Override
public void create() {
resourcePool = CommonResourcePool.INSTANCE;
@@ -637,6 +662,72 @@ public class AppLoader implements ApplicationListener {
fullscreenQuad.setIndices(new short[]{0, 1, 2, 2, 3, 0});
}
public static void setGamepadButtonLabels() {
switch (getConfigString("gamepadlabelstyle")) {
case "nwii" : gamepadLabelStart = 0xE04B; break; // + mark
case "logitech" : gamepadLabelStart = 0xE05A; break; // number 10
case "msxbone" : gamepadLabelStart = 0xE049; break; // trifold equal sign?
default : gamepadLabelStart = 0xE042; break; // |> mark (sonyps, msxb360, generic)
}
switch (getConfigString("gamepadlabelstyle")) {
case "nwii" : gamepadLabelSelect = 0xE04D; break; // - mark
case "logitech" : gamepadLabelSelect = 0xE059; break; // number 9
case "sonyps" : gamepadLabelSelect = 0xE043; break; // solid rectangle
case "msxb360" : gamepadLabelSelect = 0xE041; break; // <| mark
case "msxbone" : gamepadLabelSelect = 0xE048; break; // multitask button?
default : gamepadLabelSelect = 0xE043; break; // solid rectangle
}
switch (getConfigString("gamepadlabelstyle")) {
case "msxb360": case "msxbone" : {
gamepadLabelSouth = 0xE061;
gamepadLabelEast = 0xE062;
gamepadLabelWest = 0xE078;
gamepadLabelNorth = 0xE079;
gamepadLabelLB = 0xE06D;
gamepadLabelRB = 0xE06E;
gamepadLabelLT = 0xE06C;
gamepadLabelRT = 0xE06F;
break;
}
case "nwii": {
gamepadLabelSouth = 0xE062;
gamepadLabelEast = 0xE061;
gamepadLabelWest = 0xE079;
gamepadLabelNorth = 0xE078;
gamepadLabelLB = 0xE065;
gamepadLabelRB = 0xE066;
gamepadLabelLT = 0xE064;
gamepadLabelRT = 0xE067;
break;
}
case "sonyps": {
gamepadLabelSouth = 0xE063;
gamepadLabelEast = 0xE050;
gamepadLabelWest = 0xE073;
gamepadLabelNorth = 0xE074;
gamepadLabelLB = 0xE07B;
gamepadLabelRB = 0xE07C;
gamepadLabelLT = 0xE07A;
gamepadLabelRT = 0xE07D;
break;
}
case "logitech": {
gamepadLabelSouth = 0xE052;
gamepadLabelEast = 0xE053;
gamepadLabelWest = 0xE051;
gamepadLabelNorth = 0xE054;
gamepadLabelLB = 0xE055;
gamepadLabelRB = 0xE056;
gamepadLabelLT = 0xE057;
gamepadLabelRT = 0xE058;
break;
}
}
}
public static void requestScreenshot() {
screenshotRequested = true;
}

View File

@@ -83,6 +83,7 @@ object Terrarum : Screen, Disposable {
var previousScreen: Screen? = null // to be used with temporary states like StateMonitorCheck
/** Current ingame instance the game is holding */
var ingame: IngameInstance? = null
private val javaHeapCircularArray = CircularArray<Int>(64)
@@ -122,28 +123,6 @@ object Terrarum : Screen, Disposable {
val fontGame: GameFontBase = AppLoader.fontGame
val fontSmallNumbers: TinyAlphNum = AppLoader.fontSmallNumbers
var gamepadLabelStart = 0xE000.toChar() // lateinit
var gamepadLabelSelect = 0xE000.toChar() // lateinit
var gamepadLabelEast = 0xE000.toChar() // lateinit
var gamepadLabelSouth = 0xE000.toChar() // lateinit
var gamepadLabelNorth = 0xE000.toChar() // lateinit
var gamepadLabelWest = 0xE000.toChar() // lateinit
var gamepadLabelLB = 0xE000.toChar() // lateinit
var gamepadLabelRB = 0xE000.toChar() // lateinit
var gamepadLabelLT = 0xE000.toChar() // lateinit
var gamepadLabelRT = 0xE000.toChar() // lateinit
val gamepadLabelLEFT = 0xE068.toChar()
val gamepadLabelDOWN = 0xE069.toChar()
val gamepadLabelUP = 0xE06A.toChar()
val gamepadLabelRIGHT = 0xE06B.toChar()
val gamepadLabelUPDOWN = 0xE072.toChar()
val gamepadLabelLEFTRIGHT = 0xE071.toChar()
val gamepadLabelDPAD = 0xE070.toChar()
val gamepadLabelLStick = 0xE044.toChar()
val gamepadLabelRStick = 0xE045.toChar()
val gamepadLabelLStickPush = 0xE046.toChar()
val gamepadLabelRStickPush = 0xE047.toChar()
// 0x0 - 0xF: Game-related
// 0x10 - 0x1F: Config
// 0x100 and onward: unit tests for dev
@@ -206,9 +185,6 @@ object Terrarum : Screen, Disposable {
println("[Terrarum] vendor = $processorVendor")
setGamepadButtonLabels()
AppLoader.disposableSingletonsPool.add(this)
@@ -216,67 +192,6 @@ object Terrarum : Screen, Disposable {
println("[Terrarum] init complete")
}
private fun setGamepadButtonLabels() {
gamepadLabelStart = when (getConfigString("gamepadlabelstyle")) {
"nwii" -> 0xE04B.toChar() // + mark
"logitech" -> 0xE05A.toChar() // number 10
"msxbone" -> 0xE049.toChar() // trifold equal sign?
else -> 0xE042.toChar() // |> mark (sonyps, msxb360, generic)
}
gamepadLabelSelect = when (getConfigString("gamepadlabelstyle")) {
"nwii" -> 0xE04D.toChar() // - mark
"logitech" -> 0xE059.toChar() // number 9
"sonyps" -> 0xE043.toChar() // solid rectangle
"msxb360" -> 0xE041.toChar() // <| mark
"msxbone" -> 0xE048.toChar() // multitask button?
else -> 0xE043.toChar() // solid rectangle
}
when (getConfigString("gamepadlabelstyle")) {
"msxb360", "msxbone" -> {
gamepadLabelSouth = 0xE061.toChar()
gamepadLabelEast = 0xE062.toChar()
gamepadLabelWest = 0xE078.toChar()
gamepadLabelNorth = 0xE079.toChar()
gamepadLabelLB = 0xE06D.toChar()
gamepadLabelRB = 0xE06E.toChar()
gamepadLabelLT = 0xE06C.toChar()
gamepadLabelRT = 0xE06F.toChar()
}
"nwii" -> {
gamepadLabelSouth = 0xE062.toChar()
gamepadLabelEast = 0xE061.toChar()
gamepadLabelWest = 0xE079.toChar()
gamepadLabelNorth = 0xE078.toChar()
gamepadLabelLB = 0xE065.toChar()
gamepadLabelRB = 0xE066.toChar()
gamepadLabelLT = 0xE064.toChar()
gamepadLabelRT = 0xE067.toChar()
}
"sonyps" -> {
gamepadLabelSouth = 0xE063.toChar()
gamepadLabelEast = 0xE050.toChar()
gamepadLabelWest = 0xE073.toChar()
gamepadLabelNorth = 0xE074.toChar()
gamepadLabelLB = 0xE07B.toChar()
gamepadLabelRB = 0xE07C.toChar()
gamepadLabelLT = 0xE07A.toChar()
gamepadLabelRT = 0xE07D.toChar()
}
"logitech" -> {
gamepadLabelSouth = 0xE052.toChar()
gamepadLabelEast = 0xE053.toChar()
gamepadLabelWest = 0xE051.toChar()
gamepadLabelNorth = 0xE054.toChar()
gamepadLabelLB = 0xE055.toChar()
gamepadLabelRB = 0xE056.toChar()
gamepadLabelLT = 0xE057.toChar()
gamepadLabelRT = 0xE058.toChar()
}
}
}
val RENDER_FPS = getConfigInt("displayfps")
val USE_VSYNC = getConfigBoolean("usevsync")

View File

@@ -12,10 +12,10 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
*/
object TinyAlphNum : BitmapFont() {
internal val W = 8
internal val H = 8
internal val W = 7
internal val H = 13
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/milky.tga", W, H)
internal val fontSheet = TextureRegionPack("./assets/graphics/fonts/7x13_Tamzen7x14b.tga", W, H)
init {

View File

@@ -1,10 +1,9 @@
package net.torvald.terrarum.langpack
import net.torvald.terrarum.utils.JsonFetcher
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.AppLoader.printdbg
import java.io.*
import net.torvald.terrarum.utils.JsonFetcher
import java.io.File
import java.util.*
/**
@@ -118,7 +117,7 @@ object Lang {
// special treatment
if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL"))
return ret2.replace('>', Terrarum.gamepadLabelStart).capitalize()
return ret2.replace('>', AppLoader.gamepadLabelStart).capitalize()
return if (key.getEndTag().contains("bg"))
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}"

View File

@@ -10,14 +10,14 @@ import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.Terrarum.gamepadLabelEast
import net.torvald.terrarum.Terrarum.gamepadLabelLStick
import net.torvald.terrarum.Terrarum.gamepadLabelLT
import net.torvald.terrarum.Terrarum.gamepadLabelNorth
import net.torvald.terrarum.Terrarum.gamepadLabelRStick
import net.torvald.terrarum.Terrarum.gamepadLabelRT
import net.torvald.terrarum.Terrarum.gamepadLabelStart
import net.torvald.terrarum.Terrarum.gamepadLabelWest
import net.torvald.terrarum.AppLoader.gamepadLabelEast
import net.torvald.terrarum.AppLoader.gamepadLabelLStick
import net.torvald.terrarum.AppLoader.gamepadLabelLT
import net.torvald.terrarum.AppLoader.gamepadLabelNorth
import net.torvald.terrarum.AppLoader.gamepadLabelRStick
import net.torvald.terrarum.AppLoader.gamepadLabelRT
import net.torvald.terrarum.AppLoader.gamepadLabelStart
import net.torvald.terrarum.AppLoader.gamepadLabelWest
import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.gameactors.ActorWBMovable
import net.torvald.terrarum.langpack.Lang

View File

@@ -9,6 +9,7 @@ import net.torvald.terrarum.Terrarum.mouseTileX
import net.torvald.terrarum.Terrarum.mouseTileY
import net.torvald.terrarum.controller.TerrarumController
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.imagefont.TinyAlphNum
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
@@ -151,8 +152,8 @@ class BasicDebugInfoWindow : UICanvas() {
printLine(batch, 8, "light@cursor $ccG$lightVal")
if (ingame != null) {
val wallNum = ingame!!.world.getTileFromWall(mouseTileX, mouseTileY) ?: -1
val tileNum = ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
val wallNum = ingame!!.world.getTileFromWall(mouseTileX, mouseTileY)
val tileNum = ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY)
val wireNum = ingame!!.world.getWiringBlocks(mouseTileX, mouseTileY)
val fluid = ingame!!.world.getFluid(mouseTileX, mouseTileY)
@@ -189,8 +190,8 @@ class BasicDebugInfoWindow : UICanvas() {
}
drawHistogram(batch, LightmapRenderer.histogram,
Terrarum.WIDTH - histogramW - 30,
Terrarum.HEIGHT - histogramH - 30
Terrarum.WIDTH - histogramW - TinyAlphNum.W * 2,
Terrarum.HEIGHT - histogramH - TinyAlphNum.H * 4
)
batch.color = Color.WHITE
@@ -200,8 +201,8 @@ class BasicDebugInfoWindow : UICanvas() {
drawGamepadAxis(gamepad, batch,
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")),
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")),
Terrarum.WIDTH - 135,
40
Terrarum.WIDTH - 128 - TinyAlphNum.W * 2,
line(3).toInt()
)
}
@@ -210,21 +211,21 @@ class BasicDebugInfoWindow : UICanvas() {
*/
// memory pressure
Terrarum.fontSmallNumbers.draw(batch, "${ccY}MEM ", (Terrarum.WIDTH - 21 * 8 - 2).toFloat(), 2f)
Terrarum.fontSmallNumbers.draw(batch, "${ccY}MEM ", (Terrarum.WIDTH - 23 * TinyAlphNum.W - 2).toFloat(), line(1))
// thread count
Terrarum.fontSmallNumbers.draw(batch, "${ccY}CPUs${if (Terrarum.MULTITHREAD) ccG else ccR}${Terrarum.THREADS.toString().padStart(2, ' ')}",
(Terrarum.WIDTH - 2 - 6 * 8).toFloat(), 10f)
(Terrarum.WIDTH - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
// memory texts
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M",
(Terrarum.WIDTH - 17 * 8 - 2).toFloat(), 2f)
(Terrarum.WIDTH - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
Terrarum.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/",
(Terrarum.WIDTH - 12 * 8 - 2).toFloat(), 2f)
(Terrarum.WIDTH - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
(Terrarum.WIDTH - 5 * 8 - 2).toFloat(), 2f)
(Terrarum.WIDTH - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
// FPS count
Terrarum.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}",
(Terrarum.WIDTH - 2 - 13 * 8).toFloat(), 10F)
(Terrarum.WIDTH - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
/**
* Bottom left
@@ -232,21 +233,21 @@ class BasicDebugInfoWindow : UICanvas() {
if (ingame != null) {
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}",
2f, Terrarum.HEIGHT - 10f)
TinyAlphNum.W * 2f, Terrarum.HEIGHT - TinyAlphNum.H * 2f)
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${ingame!!.actorContainerActive.size}",
(2 + 17 * 8).toFloat(), Terrarum.HEIGHT - 10f)
(TinyAlphNum.W * 2 + 17 * 8).toFloat(), Terrarum.HEIGHT - TinyAlphNum.H * 2f)
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}",
(2 + 28 * 8).toFloat(), Terrarum.HEIGHT - 10f)
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), Terrarum.HEIGHT - TinyAlphNum.H * 2f)
if (ingame is Ingame) {
Terrarum.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as Ingame).particlesActive}",
(2 + 41 * 8).toFloat(), Terrarum.HEIGHT - 10f)
(TinyAlphNum.W * 2 + 41 * 8).toFloat(), Terrarum.HEIGHT - TinyAlphNum.H * 2f)
}
}
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
2f, Terrarum.HEIGHT - 18f)
TinyAlphNum.W * 2f, Terrarum.HEIGHT - TinyAlphNum.H * 3f)
Terrarum.fontSmallNumbers.draw(batch, "${ccY}UIs rendering $ccG${IngameRenderer.renderingUIsCount}",
2f + (21 * 8), Terrarum.HEIGHT - 18f)
TinyAlphNum.W * 2f + (21 * 8), Terrarum.HEIGHT - TinyAlphNum.H * 3f)
/**
* Bottom right
@@ -254,7 +255,7 @@ class BasicDebugInfoWindow : UICanvas() {
// processor and renderer
Terrarum.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
(Terrarum.WIDTH - 2 - totalHardwareName.length * 8).toFloat(), Terrarum.HEIGHT - 10f)
(Terrarum.WIDTH - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), Terrarum.HEIGHT - TinyAlphNum.H * 2f)
}
private val processorName = AppLoader.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (AppLoader.is32BitJVM) " (32-bit)" else ""
@@ -263,13 +264,13 @@ class BasicDebugInfoWindow : UICanvas() {
private fun printLine(batch: SpriteBatch, l: Int, s: String) {
Terrarum.fontSmallNumbers.draw(batch,
s, 10f, line(l)
s, TinyAlphNum.W * 2f, line(l)
)
}
private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) {
Terrarum.fontSmallNumbers.draw(batch,
s, (10 + column(col)), line(row)
s, (TinyAlphNum.W * 2f + column(col)), line(row)
)
}
@@ -341,11 +342,11 @@ class BasicDebugInfoWindow : UICanvas() {
}
batch.begin()
Terrarum.fontSmallNumbers.draw(batch, gamepad.getName(), Terrarum.WIDTH - (gamepad.getName().length) * 8f, uiY.toFloat() + h + 2)
Terrarum.fontSmallNumbers.draw(batch, gamepad.getName(), Terrarum.WIDTH - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
}
private fun line(i: Int): Float = i * 10f
private fun line(i: Int): Float = i * TinyAlphNum.H.toFloat()
private fun column(i: Int): Float = 300f * (i - 1)

Binary file not shown.

Binary file not shown.