Renamed AppLoader into App

This commit is contained in:
minjaesong
2021-09-09 09:48:33 +09:00
parent c3dd005fb2
commit 8f834fe869
116 changed files with 796 additions and 850 deletions

View File

@@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: net.torvald.terrarum.AppLoader Main-Class: net.torvald.terrarum.App

View File

@@ -1,7 +1,6 @@
package net.torvald.random; package net.torvald.random;
import net.torvald.UnsafeHelper; import net.torvald.UnsafeHelper;
import net.torvald.terrarum.AppLoader;
/** /**
* Code from https://richardstartin.github.io/posts/xxhash * Code from https://richardstartin.github.io/posts/xxhash

View File

@@ -2,7 +2,6 @@ package net.torvald.spriteassembler
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.linearSearch import net.torvald.terrarum.linearSearch
import java.io.File import java.io.File

View File

@@ -51,7 +51,7 @@ import static net.torvald.terrarum.TerrarumKt.printStackTrace;
* *
* Created by minjaesong on 2017-08-01. * Created by minjaesong on 2017-08-01.
*/ */
public class AppLoader implements ApplicationListener { public class App implements ApplicationListener {
public static final String GAME_NAME = TerrarumAppConfiguration.GAME_NAME; public static final String GAME_NAME = TerrarumAppConfiguration.GAME_NAME;
@@ -78,7 +78,7 @@ public class AppLoader implements ApplicationListener {
/** /**
* Singleton instance * Singleton instance
*/ */
private static AppLoader INSTANCE = null; private static App INSTANCE = null;
/** /**
* Screen injected at init, so that you run THAT screen instead of the main game. * Screen injected at init, so that you run THAT screen instead of the main game.
@@ -91,9 +91,9 @@ public class AppLoader implements ApplicationListener {
* @param appConfig LWJGL3 Application Configuration * @param appConfig LWJGL3 Application Configuration
* @param injectScreen GDX Screen you want to run * @param injectScreen GDX Screen you want to run
*/ */
public AppLoader(Lwjgl3ApplicationConfiguration appConfig, Screen injectScreen) { public App(Lwjgl3ApplicationConfiguration appConfig, Screen injectScreen) {
AppLoader.injectScreen = injectScreen; App.injectScreen = injectScreen;
AppLoader.appConfig = appConfig; App.appConfig = appConfig;
} }
/** /**
@@ -101,14 +101,14 @@ public class AppLoader implements ApplicationListener {
* *
* @param appConfig LWJGL3 Application Configuration * @param appConfig LWJGL3 Application Configuration
*/ */
public AppLoader(Lwjgl3ApplicationConfiguration appConfig) { public App(Lwjgl3ApplicationConfiguration appConfig) {
AppLoader.appConfig = appConfig; App.appConfig = appConfig;
} }
/** /**
* Default null constructor. Don't use it. * Default null constructor. Don't use it.
*/ */
private AppLoader() { private App() {
} }
/** /**
@@ -119,9 +119,9 @@ public class AppLoader implements ApplicationListener {
* *
* @return * @return
*/ */
public static AppLoader getINSTANCE() { public static App getINSTANCE() {
if (INSTANCE == null) { if (INSTANCE == null) {
INSTANCE = new AppLoader(); INSTANCE = new App();
} }
return INSTANCE; return INSTANCE;
} }
@@ -179,7 +179,7 @@ public class AppLoader implements ApplicationListener {
private static Point2i resizeReqSize; private static Point2i resizeReqSize;
public static Lwjgl3ApplicationConfiguration appConfig; public static Lwjgl3ApplicationConfiguration appConfig;
public static TerrarumScreenSize screenSize; public static TerrarumScreenSize scr;
public static TerrarumGLinfo glInfo = new TerrarumGLinfo(); public static TerrarumGLinfo glInfo = new TerrarumGLinfo();
public static CreateTileAtlas tileMaker; public static CreateTileAtlas tileMaker;
@@ -298,9 +298,9 @@ public class AppLoader implements ApplicationListener {
ShaderProgram.pedantic = false; ShaderProgram.pedantic = false;
screenSize = new TerrarumScreenSize(getConfigInt("screenwidth"), getConfigInt("screenheight")); scr = new TerrarumScreenSize(getConfigInt("screenwidth"), getConfigInt("screenheight"));
int width = screenSize.getScreenW(); int width = scr.getWidth();
int height = screenSize.getScreenH(); int height = scr.getHeight();
Lwjgl3ApplicationConfiguration appConfig = new Lwjgl3ApplicationConfiguration(); Lwjgl3ApplicationConfiguration appConfig = new Lwjgl3ApplicationConfiguration();
//appConfig.useGL30 = false; // https://stackoverflow.com/questions/46753218/libgdx-should-i-use-gl30 //appConfig.useGL30 = false; // https://stackoverflow.com/questions/46753218/libgdx-should-i-use-gl30
@@ -341,7 +341,7 @@ public class AppLoader implements ApplicationListener {
// set some more configuration vars // set some more configuration vars
MULTITHREAD = THREAD_COUNT >= 3 && getConfigBoolean("multithread"); MULTITHREAD = THREAD_COUNT >= 3 && getConfigBoolean("multithread");
new Lwjgl3Application(new AppLoader(appConfig), appConfig); new Lwjgl3Application(new App(appConfig), appConfig);
} }
@Override @Override
@@ -362,12 +362,12 @@ public class AppLoader implements ApplicationListener {
// set basis of draw // set basis of draw
logoBatch = new SpriteBatch(); logoBatch = new SpriteBatch();
camera = new OrthographicCamera((screenSize.getScreenWf()), (screenSize.getScreenHf())); camera = new OrthographicCamera((scr.getWf()), (scr.getHf()));
batch = new SpriteBatch(); batch = new SpriteBatch();
shapeRender = new ShapeRenderer(); shapeRender = new ShapeRenderer();
initViewPort(screenSize.getScreenW(), screenSize.getScreenH()); initViewPort(scr.getWidth(), scr.getHeight());
// logo here :p // logo here :p
logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga"))); logo = new TextureRegion(new Texture(Gdx.files.internal("assets/graphics/logo_placeholder.tga")));
@@ -389,7 +389,7 @@ public class AppLoader implements ApplicationListener {
VertexAttribute.ColorUnpacked(), VertexAttribute.ColorUnpacked(),
VertexAttribute.TexCoords(0) VertexAttribute.TexCoords(0)
); );
updateFullscreenQuad(screenSize.getScreenW(), screenSize.getScreenH()); updateFullscreenQuad(scr.getWidth(), scr.getHeight());
// set up renderer info variables // set up renderer info variables
@@ -398,7 +398,7 @@ public class AppLoader implements ApplicationListener {
// make gamepad(s) // make gamepad(s)
if (AppLoader.getConfigBoolean("usexinput")) { if (App.getConfigBoolean("usexinput")) {
try { try {
gamepad = new XinputControllerAdapter(XInputDevice.getDeviceFor(0)); gamepad = new XinputControllerAdapter(XInputDevice.getDeviceFor(0));
} }
@@ -484,7 +484,7 @@ public class AppLoader implements ApplicationListener {
postInit(); postInit();
} }
AppLoader.setDebugTime("GDX.rawDelta", (long) (Gdx.graphics.getDeltaTime() * 1000_000_000f)); App.setDebugTime("GDX.rawDelta", (long) (Gdx.graphics.getDeltaTime() * 1000_000_000f));
FrameBufferManager.begin(renderFBO); FrameBufferManager.begin(renderFBO);
@@ -535,7 +535,7 @@ public class AppLoader implements ApplicationListener {
screenshotRequested = false; screenshotRequested = false;
try { try {
Pixmap p = ScreenUtils.getFrameBufferPixmap(0, 0, screenSize.getScreenW(), screenSize.getScreenH()); Pixmap p = ScreenUtils.getFrameBufferPixmap(0, 0, scr.getWidth(), scr.getHeight());
PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir+"/Screenshot-"+String.valueOf(System.currentTimeMillis())+".tga"), p, true); PixmapIO2.writeTGA(Gdx.files.absolute(defaultDir+"/Screenshot-"+String.valueOf(System.currentTimeMillis())+".tga"), p, true);
p.dispose(); p.dispose();
@@ -564,8 +564,8 @@ public class AppLoader implements ApplicationListener {
setCameraPosition(0f, 0f); setCameraPosition(0f, 0f);
int safetyTextLen = fontGame.getWidth(Lang.INSTANCE.get("APP_WARNING_HEALTH_AND_SAFETY")); int safetyTextLen = fontGame.getWidth(Lang.INSTANCE.get("APP_WARNING_HEALTH_AND_SAFETY"));
int logoPosX = (screenSize.getScreenW() - logo.getRegionWidth() - safetyTextLen) >>> 1; int logoPosX = (scr.getWidth() - logo.getRegionWidth() - safetyTextLen) >>> 1;
int logoPosY = Math.round(screenSize.getScreenH() / 15f); int logoPosY = Math.round(scr.getHeight() / 15f);
int textY = logoPosY + logo.getRegionHeight() - 16; int textY = logoPosY + logo.getRegionHeight() - 16;
// draw logo reflection // draw logo reflection
@@ -577,8 +577,8 @@ public class AppLoader implements ApplicationListener {
logoBatch.draw(logo, logoPosX, logoPosY + logo.getRegionHeight()); logoBatch.draw(logo, logoPosX, logoPosY + logo.getRegionHeight());
} }
else { else {
logoBatch.draw(logo, (screenSize.getScreenW() - logo.getRegionWidth()) / 2f, logoBatch.draw(logo, (scr.getWidth() - logo.getRegionWidth()) / 2f,
(screenSize.getScreenH() - logo.getRegionHeight() * 2) / 2f + logo.getRegionHeight() (scr.getHeight() - logo.getRegionHeight() * 2) / 2f + logo.getRegionHeight()
); );
} }
@@ -603,8 +603,8 @@ public class AppLoader implements ApplicationListener {
String s = Lang.INSTANCE.get("APP_CHINESE_HEALTHY_GAME_MSG_" + i); String s = Lang.INSTANCE.get("APP_CHINESE_HEALTHY_GAME_MSG_" + i);
fontGame.draw(logoBatch, s, fontGame.draw(logoBatch, s,
(screenSize.getScreenW() - fontGame.getWidth(s)) >>> 1, (scr.getWidth() - fontGame.getWidth(s)) >>> 1,
Math.round(screenSize.getScreenH() * 12f / 15f + fontGame.getLineHeight() * (i - 1)) Math.round(scr.getHeight() * 12f / 15f + fontGame.getLineHeight() * (i - 1))
); );
} }
} }
@@ -612,15 +612,15 @@ public class AppLoader implements ApplicationListener {
logoBatch.setColor(new Color(0x282828ff)); logoBatch.setColor(new Color(0x282828ff));
Texture tex1 = CommonResourcePool.INSTANCE.getAsTexture("title_health1"); Texture tex1 = CommonResourcePool.INSTANCE.getAsTexture("title_health1");
Texture tex2 = CommonResourcePool.INSTANCE.getAsTexture("title_health2"); Texture tex2 = CommonResourcePool.INSTANCE.getAsTexture("title_health2");
int virtualHeight = screenSize.getScreenH() - logoPosY - logo.getRegionHeight() / 4; int virtualHeight = scr.getHeight() - logoPosY - logo.getRegionHeight() / 4;
int virtualHeightOffset = screenSize.getScreenH() - virtualHeight; int virtualHeightOffset = scr.getHeight() - virtualHeight;
logoBatch.draw(tex1, (screenSize.getScreenW() - tex1.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) - 16, tex1.getWidth(), -tex1.getHeight()); logoBatch.draw(tex1, (scr.getWidth() - tex1.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) - 16, tex1.getWidth(), -tex1.getHeight());
logoBatch.draw(tex2, (screenSize.getScreenW() - tex2.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) + 16 + tex2.getHeight(), tex2.getWidth(), -tex2.getHeight()); logoBatch.draw(tex2, (scr.getWidth() - tex2.getWidth()) >>> 1, virtualHeightOffset + (virtualHeight >>> 1) + 16 + tex2.getHeight(), tex2.getWidth(), -tex2.getHeight());
} }
else { else {
logoBatch.draw(logo, (screenSize.getScreenW() - logo.getRegionWidth()) / 2f, logoBatch.draw(logo, (scr.getWidth() - logo.getRegionWidth()) / 2f,
(screenSize.getScreenH() - logo.getRegionHeight() * 2) / 2f (scr.getHeight() - logo.getRegionHeight() * 2) / 2f
); );
} }
@@ -634,20 +634,20 @@ public class AppLoader implements ApplicationListener {
//initViewPort(width, height); //initViewPort(width, height);
screenSize.setDimension(width, height); scr.setDimension(width, height);
if (currenScreen != null) currenScreen.resize(screenSize.getScreenW(), screenSize.getScreenH()); if (currenScreen != null) currenScreen.resize(scr.getWidth(), scr.getHeight());
updateFullscreenQuad(screenSize.getScreenW(), screenSize.getScreenH()); updateFullscreenQuad(scr.getWidth(), scr.getHeight());
if (renderFBO == null || if (renderFBO == null ||
(renderFBO.getWidth() != screenSize.getScreenW() || (renderFBO.getWidth() != scr.getWidth() ||
renderFBO.getHeight() != screenSize.getScreenH()) renderFBO.getHeight() != scr.getHeight())
) { ) {
renderFBO = new FrameBuffer( renderFBO = new FrameBuffer(
Pixmap.Format.RGBA8888, Pixmap.Format.RGBA8888,
screenSize.getScreenW(), scr.getWidth(),
screenSize.getScreenH(), scr.getHeight(),
false false
); );
} }
@@ -755,7 +755,7 @@ public class AppLoader implements ApplicationListener {
currenScreen = screen; currenScreen = screen;
currenScreen.show(); currenScreen.show();
currenScreen.resize(screenSize.getScreenW(), screenSize.getScreenH()); currenScreen.resize(scr.getWidth(), scr.getHeight());
System.gc(); System.gc();
@@ -804,7 +804,7 @@ public class AppLoader implements ApplicationListener {
private void setCameraPosition(float newX, float newY) { private void setCameraPosition(float newX, float newY) {
camera.position.set((-newX + screenSize.getScreenW() / 2), (-newY + screenSize.getScreenH() / 2), 0f); // deliberate integer division camera.position.set((-newX + scr.getWidth() / 2), (-newY + scr.getHeight() / 2), 0f); // deliberate integer division
camera.update(); camera.update();
logoBatch.setProjectionMatrix(camera.combined); logoBatch.setProjectionMatrix(camera.combined);
} }

View File

@@ -1,8 +1,6 @@
package net.torvald.terrarum package net.torvald.terrarum
import com.badlogic.gdx.Input import com.badlogic.gdx.Input
import com.badlogic.gdx.utils.Json
import net.torvald.terrarum.blockproperties.Block
/** /**
* Keys must be all lowercase * Keys must be all lowercase
@@ -18,7 +16,7 @@ object DefaultConfig {
"screenheight" to TerrarumScreenSize.defaultH, "screenheight" to TerrarumScreenSize.defaultH,
"atlastexsize" to 2048, "atlastexsize" to 2048,
"language" to AppLoader.getSysLang(), "language" to App.getSysLang(),
"notificationshowuptime" to 4000, "notificationshowuptime" to 4000,
"multithread" to true, "multithread" to true,
"multithreadedlight" to false, "multithreadedlight" to false,

View File

@@ -9,8 +9,8 @@ import net.torvald.terrarum.langpack.Lang
object ErrorDisp : Screen { object ErrorDisp : Screen {
private val logoTex = AppLoader.logo private val logoTex = App.logo
private val font = AppLoader.fontGame private val font = App.fontGame
var title = Lang["ERROR_GENERIC_TEXT"] var title = Lang["ERROR_GENERIC_TEXT"]
@@ -25,7 +25,7 @@ object ErrorDisp : Screen {
private val titleTextLeftMargin = 8 private val titleTextLeftMargin = 8
private val titleText = "${AppLoader.GAME_NAME} ${AppLoader.getVERSION_STRING()}" private val titleText = "${App.GAME_NAME} ${App.getVERSION_STRING()}"
override fun show() { override fun show() {

View File

@@ -12,7 +12,7 @@ import net.torvald.gdx.graphics.Cvec
class GdxColorMap { class GdxColorMap {
constructor(imageFile: FileHandle) { constructor(imageFile: FileHandle) {
AppLoader.printdbg(this, "Loading colormap from ${imageFile.name()}") App.printdbg(this, "Loading colormap from ${imageFile.name()}")
printStackTrace(this) printStackTrace(this)
val pixmap = Pixmap(imageFile) val pixmap = Pixmap(imageFile)

View File

@@ -2,26 +2,19 @@ package net.torvald.terrarum
import com.badlogic.gdx.Screen import com.badlogic.gdx.Screen
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.ActorID import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.BlockMarkerActor import net.torvald.terrarum.gameactors.BlockMarkerActor
import net.torvald.terrarum.gameactors.faction.FactionCodex
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.WorldSimulator
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.itemproperties.MaterialCodex
import net.torvald.terrarum.modulebasegame.IngameRenderer import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.modulebasegame.ui.Notification import net.torvald.terrarum.modulebasegame.ui.Notification
import net.torvald.terrarum.modulebasegame.ui.UITooltip import net.torvald.terrarum.modulebasegame.ui.UITooltip
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.VirtualDisk import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.VirtualDisk
import net.torvald.terrarum.ui.ConsoleWindow import net.torvald.terrarum.ui.ConsoleWindow
import net.torvald.terrarum.ui.UICanvas
import net.torvald.util.SortedArrayList import net.torvald.util.SortedArrayList
import org.khelekore.prtree.DistanceCalculator import org.khelekore.prtree.DistanceCalculator
import org.khelekore.prtree.DistanceResult import org.khelekore.prtree.DistanceResult
@@ -76,8 +69,8 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
init { init {
consoleHandler.setPosition(0, 0) consoleHandler.setPosition(0, 0)
notifier.setPosition( notifier.setPosition(
(AppLoader.screenSize.screenW - notifier.width) / 2, (App.scr.width - notifier.width) / 2,
AppLoader.screenSize.screenH - notifier.height - AppLoader.screenSize.tvSafeGraphicsHeight App.scr.height - notifier.height - App.scr.tvSafeGraphicsHeight
) )
printdbg(this, "New ingame instance ${this.hashCode()}, called from") printdbg(this, "New ingame instance ${this.hashCode()}, called from")
@@ -128,7 +121,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
val wallChangeQueue = ArrayList<BlockChangeQueueItem>() val wallChangeQueue = ArrayList<BlockChangeQueueItem>()
val wireChangeQueue = ArrayList<BlockChangeQueueItem>() // if 'old' is set and 'new' is blank, it's a wire cutter val wireChangeQueue = ArrayList<BlockChangeQueueItem>() // if 'old' is set and 'new' is blank, it's a wire cutter
var loadedTime_t = AppLoader.getTIME_T() var loadedTime_t = App.getTIME_T()
protected set protected set
override fun hide() { override fun hide() {

View File

@@ -22,7 +22,7 @@ open class LoadScreenBase : ScreenAdapter(), Disposable {
internal var errorTrapped = false internal var errorTrapped = false
internal var doContextChange = false internal var doContextChange = false
var camera = OrthographicCamera(AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) var camera = OrthographicCamera(App.scr.wf, App.scr.hf)
override fun show() { override fun show() {
messages.clear() messages.clear()
@@ -51,7 +51,7 @@ open class LoadScreenBase : ScreenAdapter(), Disposable {
} }
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
} }
fun initViewPort(width: Int, height: Int) { fun initViewPort(width: Int, height: Int) {
@@ -74,11 +74,11 @@ open class LoadScreenBase : ScreenAdapter(), Disposable {
if (doContextChange) { if (doContextChange) {
Thread.sleep(80) Thread.sleep(80)
AppLoader.setScreen(screenToLoad!!) App.setScreen(screenToLoad!!)
} }
} }
override fun resize(width: Int, height: Int) { override fun resize(width: Int, height: Int) {
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
} }
} }

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
@@ -141,7 +141,7 @@ object ModMgr {
catch (e: Throwable) { catch (e: Throwable) {
printdbgerr(this, "There was an error while loading module $moduleName") printdbgerr(this, "There was an error while loading module $moduleName")
printdbgerr(this, "\t$e") printdbgerr(this, "\t$e")
print(AppLoader.csiR); e.printStackTrace(System.out); print(AppLoader.csi0) print(App.csiR); e.printStackTrace(System.out); print(App.csi0)
moduleInfo.remove(moduleName) moduleInfo.remove(moduleName)
} }
} }
@@ -192,7 +192,7 @@ object ModMgr {
catch (e: Throwable) { catch (e: Throwable) {
printdbgerr(this, "There was an error while loading module $moduleName") printdbgerr(this, "There was an error while loading module $moduleName")
printdbgerr(this, "\t$e") printdbgerr(this, "\t$e")
print(AppLoader.csiR); e.printStackTrace(System.out); print(AppLoader.csi0) print(App.csiR); e.printStackTrace(System.out); print(App.csi0)
moduleInfo.remove(moduleName) moduleInfo.remove(moduleName)
} }
} }

View File

@@ -12,8 +12,8 @@ class ModOptionsHost : UICanvas() {
private val moduleAreaHMargin = 48 private val moduleAreaHMargin = 48
private val moduleAreaBorder = 8 private val moduleAreaBorder = 8
override var width = AppLoader.screenSize.screenW - UIRemoCon.remoConWidth - moduleAreaHMargin override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
override var height = AppLoader.screenSize.screenH - moduleAreaHMargin * 2 override var height = App.scr.height - moduleAreaHMargin * 2
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
} }

View File

@@ -42,7 +42,7 @@ object PostProcessor : Disposable {
private val functionRowHelper = Texture(Gdx.files.internal("assets/graphics/function_row_help.png")) private val functionRowHelper = Texture(Gdx.files.internal("assets/graphics/function_row_help.png"))
init { init {
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
} }
override fun dispose() { override fun dispose() {
@@ -64,27 +64,27 @@ object PostProcessor : Disposable {
debugUI.setPosition(0, 0) debugUI.setPosition(0, 0)
batch = SpriteBatch() batch = SpriteBatch()
camera = OrthographicCamera(AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera = OrthographicCamera(App.scr.wf, App.scr.hf)
camera.setToOrtho(true) camera.setToOrtho(true)
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
shapeRenderer = ShapeRenderer() shapeRenderer = ShapeRenderer()
Gdx.gl20.glViewport(0, 0, AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) Gdx.gl20.glViewport(0, 0, App.scr.width, App.scr.height)
} }
debugUI.update(Gdx.graphics.deltaTime) debugUI.update(Gdx.graphics.deltaTime)
AppLoader.measureDebugTime("Renderer.PostProcessor") { App.measureDebugTime("Renderer.PostProcessor") {
gdxClearAndSetBlend(.094f, .094f, .094f, 0f) gdxClearAndSetBlend(.094f, .094f, .094f, 0f)
postShader(projMat, fbo) postShader(projMat, fbo)
// draw things when F keys are on // draw things when F keys are on
if (AppLoader.IS_DEVELOPMENT_BUILD && KeyToggler.isOn(Input.Keys.F11)) { if (App.IS_DEVELOPMENT_BUILD && KeyToggler.isOn(Input.Keys.F11)) {
drawSafeArea() drawSafeArea()
} }
@@ -92,7 +92,7 @@ object PostProcessor : Disposable {
batch.color = Color.WHITE batch.color = Color.WHITE
batch.inUse { batch.inUse {
it.draw(functionRowHelper, it.draw(functionRowHelper,
(AppLoader.screenSize.screenW - functionRowHelper.width) / 2f, (App.scr.width - functionRowHelper.width) / 2f,
functionRowHelper.height.toFloat(), functionRowHelper.height.toFloat(),
functionRowHelper.width.toFloat(), functionRowHelper.width.toFloat(),
functionRowHelper.height * -1f functionRowHelper.height * -1f
@@ -103,7 +103,7 @@ object PostProcessor : Disposable {
if (KeyToggler.isOn(Input.Keys.F10)) { if (KeyToggler.isOn(Input.Keys.F10)) {
batch.color = Color.WHITE batch.color = Color.WHITE
batch.inUse { batch.inUse {
AppLoader.fontSmallNumbers.draw(it, "Wire draw class: ${(Terrarum.ingame as? net.torvald.terrarum.modulebasegame.TerrarumIngame)?.selectedWireRenderClass}", 2f, 2f) App.fontSmallNumbers.draw(it, "Wire draw class: ${(Terrarum.ingame as? net.torvald.terrarum.modulebasegame.TerrarumIngame)?.selectedWireRenderClass}", 2f, 2f)
} }
} }
@@ -116,10 +116,10 @@ object PostProcessor : Disposable {
} }
// draw dev build notifiers // draw dev build notifiers
if (AppLoader.IS_DEVELOPMENT_BUILD && Terrarum.ingame != null) { if (App.IS_DEVELOPMENT_BUILD && Terrarum.ingame != null) {
batch.inUse { batch.inUse {
batch.color = safeAreaCol batch.color = safeAreaCol
AppLoader.fontGame.draw(it, thisIsDebugStr, 5f, AppLoader.screenSize.screenH - 24f) App.fontGame.draw(it, thisIsDebugStr, 5f, App.scr.height - 24f)
} }
} }
} }
@@ -127,17 +127,17 @@ object PostProcessor : Disposable {
private fun postShader(projMat: Matrix4, fbo: FrameBuffer) { private fun postShader(projMat: Matrix4, fbo: FrameBuffer) {
val shader: ShaderProgram? = val shader: ShaderProgram? =
if (AppLoader.getConfigBoolean("fxretro")) if (App.getConfigBoolean("fxretro"))
AppLoader.shaderHicolour App.shaderHicolour
else else
AppLoader.shaderPassthruRGB App.shaderPassthruRGB
fbo.colorBufferTexture.bind(0) fbo.colorBufferTexture.bind(0)
shader?.bind() shader?.bind()
shader?.setUniformMatrix("u_projTrans", projMat) shader?.setUniformMatrix("u_projTrans", projMat)
shader?.setUniformi("u_texture", 0) shader?.setUniformi("u_texture", 0)
AppLoader.fullscreenQuad.render(shader, GL20.GL_TRIANGLES) App.fullscreenQuad.render(shader, GL20.GL_TRIANGLES)
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
@@ -145,35 +145,35 @@ object PostProcessor : Disposable {
} }
private fun drawSafeArea() { private fun drawSafeArea() {
val tvSafeAreaW = AppLoader.screenSize.tvSafeGraphicsWidth.toFloat() val tvSafeAreaW = App.scr.tvSafeGraphicsWidth.toFloat()
val tvSafeAreaH = AppLoader.screenSize.tvSafeGraphicsHeight.toFloat() val tvSafeAreaH = App.scr.tvSafeGraphicsHeight.toFloat()
val tvSafeArea2W = AppLoader.screenSize.tvSafeActionWidth.toFloat() val tvSafeArea2W = App.scr.tvSafeActionWidth.toFloat()
val tvSafeArea2H = AppLoader.screenSize.tvSafeActionHeight.toFloat() val tvSafeArea2H = App.scr.tvSafeActionHeight.toFloat()
shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) { shapeRenderer.inUse(ShapeRenderer.ShapeType.Line) {
// centre ind // centre ind
shapeRenderer.color = safeAreaCol2 shapeRenderer.color = safeAreaCol2
shapeRenderer.line(0f, 0f, AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) shapeRenderer.line(0f, 0f, App.scr.wf, App.scr.hf)
shapeRenderer.line(0f, AppLoader.screenSize.screenHf, AppLoader.screenSize.screenWf, 0f) shapeRenderer.line(0f, App.scr.hf, App.scr.wf, 0f)
// safe action area // safe action area
shapeRenderer.color = safeAreaCol2 shapeRenderer.color = safeAreaCol2
shapeRenderer.rect( shapeRenderer.rect(
tvSafeArea2W, tvSafeArea2H, AppLoader.screenSize.screenW - 2 * tvSafeArea2W, AppLoader.screenSize.screenH - 2 * tvSafeArea2H tvSafeArea2W, tvSafeArea2H, App.scr.width - 2 * tvSafeArea2W, App.scr.height - 2 * tvSafeArea2H
) )
// safe graphics area // safe graphics area
shapeRenderer.color = safeAreaCol shapeRenderer.color = safeAreaCol
shapeRenderer.rect( shapeRenderer.rect(
tvSafeAreaW, tvSafeAreaH, AppLoader.screenSize.screenW - 2 * tvSafeAreaW, AppLoader.screenSize.screenH - 2 * tvSafeAreaH tvSafeAreaW, tvSafeAreaH, App.scr.width - 2 * tvSafeAreaW, App.scr.height - 2 * tvSafeAreaH
) )
// default res ind // default res ind
shapeRenderer.color = defaultResCol shapeRenderer.color = defaultResCol
shapeRenderer.rect( shapeRenderer.rect(
(AppLoader.screenSize.screenW - TerrarumScreenSize.minimumW).div(2).toFloat(), (App.scr.width - TerrarumScreenSize.minimumW).div(2).toFloat(),
(AppLoader.screenSize.screenH - TerrarumScreenSize.minimumH).div(2).toFloat(), (App.scr.height - TerrarumScreenSize.minimumH).div(2).toFloat(),
TerrarumScreenSize.minimumW.toFloat(), TerrarumScreenSize.minimumW.toFloat(),
TerrarumScreenSize.minimumH.toFloat() TerrarumScreenSize.minimumH.toFloat()
) )
@@ -182,22 +182,22 @@ object PostProcessor : Disposable {
try { try {
batch.inUse { batch.inUse {
batch.color = safeAreaCol batch.color = safeAreaCol
AppLoader.fontSmallNumbers.draw( App.fontSmallNumbers.draw(
batch, safeAreaStr, batch, safeAreaStr,
tvSafeAreaW, tvSafeAreaH - 10 tvSafeAreaW, tvSafeAreaH - 10
) )
batch.color = defaultResCol batch.color = defaultResCol
AppLoader.fontSmallNumbers.draw( App.fontSmallNumbers.draw(
batch, defaultResStr, batch, defaultResStr,
(AppLoader.screenSize.screenW - TerrarumScreenSize.minimumW).div(2).toFloat(), (App.scr.width - TerrarumScreenSize.minimumW).div(2).toFloat(),
(AppLoader.screenSize.screenH - TerrarumScreenSize.minimumH).div(2).toFloat() (App.scr.height - TerrarumScreenSize.minimumH).div(2).toFloat()
) )
batch.color = currentResCol batch.color = currentResCol
AppLoader.fontSmallNumbers.draw( App.fontSmallNumbers.draw(
batch, currentResStr, batch, currentResStr,
AppLoader.screenSize.screenW - 80f, App.scr.width - 80f,
0f 0f
) )
} }
@@ -212,10 +212,10 @@ object PostProcessor : Disposable {
} }
private val defaultResStr = "${TerrarumScreenSize.minimumW}x${TerrarumScreenSize.minimumH}" private val defaultResStr = "${TerrarumScreenSize.minimumW}x${TerrarumScreenSize.minimumH}"
private val currentResStr = "${AppLoader.screenSize.screenW}x${AppLoader.screenSize.screenH}" private val currentResStr = "${App.scr.width}x${App.scr.height}"
private val safeAreaStr = "TV Safe Area" private val safeAreaStr = "TV Safe Area"
private val versionStr = "Version ${AppLoader.getVERSION_STRING()}" private val versionStr = "Version ${App.getVERSION_STRING()}"
internal val thisIsDebugStr = "${AppLoader.GAME_NAME} Develoment Build $versionStr" internal val thisIsDebugStr = "${App.GAME_NAME} Develoment Build $versionStr"
/** /**
* 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.

View File

@@ -15,13 +15,13 @@ import net.torvald.terrarum.modulebasegame.TerrarumIngame
object SanicLoadScreen : LoadScreenBase() { object SanicLoadScreen : LoadScreenBase() {
init { init {
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
} }
private var arrowObjPos = 0f // 0 means at starting position, regardless of screen position private var arrowObjPos = 0f // 0 means at starting position, regardless of screen position
private var arrowObjGlideOffsetX = 0f private var arrowObjGlideOffsetX = 0f
private var arrowObjGlideSize = 0f private var arrowObjGlideSize = 0f
private val arrowGlideSpeed: Float; get() = AppLoader.screenSize.screenW * 2f // pixels per sec private val arrowGlideSpeed: Float; get() = App.scr.width * 2f // pixels per sec
private lateinit var arrowObjTex: Texture private lateinit var arrowObjTex: Texture
private var glideTimer = 0f private var glideTimer = 0f
private var glideDispY = 0f private var glideDispY = 0f
@@ -46,10 +46,10 @@ object SanicLoadScreen : LoadScreenBase() {
textFbo = FrameBuffer( textFbo = FrameBuffer(
Pixmap.Format.RGBA4444, Pixmap.Format.RGBA4444,
maxOf( maxOf(
AppLoader.fontGame.getWidth(Lang["MENU_IO_LOADING"]), App.fontGame.getWidth(Lang["MENU_IO_LOADING"]),
AppLoader.fontGame.getWidth(Lang["ERROR_GENERIC_TEXT"]) App.fontGame.getWidth(Lang["ERROR_GENERIC_TEXT"])
), ),
AppLoader.fontGame.lineHeight.toInt(), App.fontGame.lineHeight.toInt(),
true true
) )
@@ -60,7 +60,7 @@ object SanicLoadScreen : LoadScreenBase() {
} }
val textX: Float; get() = (AppLoader.screenSize.screenW * 0.72f).floor() val textX: Float; get() = (App.scr.width * 0.72f).floor()
private var genuineSonic = false // the "NOW LOADING..." won't appear unless the arrow first run passes it (it's totally not a GenuineIntel tho) private var genuineSonic = false // the "NOW LOADING..." won't appear unless the arrow first run passes it (it's totally not a GenuineIntel tho)
@@ -72,8 +72,8 @@ object SanicLoadScreen : LoadScreenBase() {
val delta = Gdx.graphics.deltaTime val delta = Gdx.graphics.deltaTime
glideDispY = AppLoader.screenSize.screenH - 100f - AppLoader.fontGame.lineHeight glideDispY = App.scr.height - 100f - App.fontGame.lineHeight
arrowObjGlideSize = arrowObjTex.width + 2f * AppLoader.screenSize.screenW arrowObjGlideSize = arrowObjTex.width + 2f * App.scr.width
@@ -105,43 +105,43 @@ object SanicLoadScreen : LoadScreenBase() {
val textToPrint = if (errorTrapped) Lang["ERROR_GENERIC_TEXT"] else Lang["MENU_IO_LOADING"] val textToPrint = if (errorTrapped) Lang["ERROR_GENERIC_TEXT"] else Lang["MENU_IO_LOADING"]
val textWidth = AppLoader.fontGame.getWidth(textToPrint).toFloat() val textWidth = App.fontGame.getWidth(textToPrint).toFloat()
if (!doContextChange) { if (!doContextChange) {
// draw text to FBO // draw text to FBO
textFbo.inAction(camera, AppLoader.batch) { textFbo.inAction(camera, App.batch) {
AppLoader.batch.inUse { App.batch.inUse {
blendNormal(AppLoader.batch) blendNormal(App.batch)
AppLoader.fontGame App.fontGame
it.color = Color.WHITE it.color = Color.WHITE
AppLoader.fontGame.draw(it, textToPrint, ((textFbo.width - textWidth) / 2).toInt().toFloat(), 0f) App.fontGame.draw(it, textToPrint, ((textFbo.width - textWidth) / 2).toInt().toFloat(), 0f)
blendMul(AppLoader.batch) blendMul(App.batch)
// draw colour overlay, flipped // draw colour overlay, flipped
it.draw(textOverlayTex, it.draw(textOverlayTex,
(textFbo.width - textWidth) / 2f, (textFbo.width - textWidth) / 2f,
AppLoader.fontGame.lineHeight, App.fontGame.lineHeight,
textWidth, textWidth,
-AppLoader.fontGame.lineHeight -App.fontGame.lineHeight
) )
} }
} }
AppLoader.batch.inUse { App.batch.inUse {
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) // dunno, no render without this initViewPort(App.scr.width, App.scr.height) // dunno, no render without this
it.projectionMatrix = camera.combined it.projectionMatrix = camera.combined
blendNormal(AppLoader.batch) blendNormal(App.batch)
// almost black background // almost black background
it.color = Color(0x181818ff) it.color = Color(0x181818ff)
it.fillRect(0f, 0f, AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) it.fillRect(0f, 0f, App.scr.wf, App.scr.hf)
it.color = Color.WHITE it.color = Color.WHITE
@@ -184,52 +184,52 @@ object SanicLoadScreen : LoadScreenBase() {
// message backgrounds // message backgrounds
it.color = messageBackgroundColour it.color = messageBackgroundColour
it.fillRect(0f, 60f, AppLoader.screenSize.screenWf, 40f + (messages.size) * AppLoader.fontGame.lineHeight) it.fillRect(0f, 60f, App.scr.wf, 40f + (messages.size) * App.fontGame.lineHeight)
// log messages // log messages
it.color = messageForegroundColour it.color = messageForegroundColour
messages.reversed().forEachIndexed { i, s -> messages.reversed().forEachIndexed { i, s ->
AppLoader.fontGame.draw(it, App.fontGame.draw(it,
s, s,
AppLoader.screenSize.tvSafeGraphicsWidth + 16f, App.scr.tvSafeGraphicsWidth + 16f,
80f + (messages.size - i - 1) * AppLoader.fontGame.lineHeight 80f + (messages.size - i - 1) * App.fontGame.lineHeight
) )
} }
} }
} }
else { else {
AppLoader.batch.inUse { App.batch.inUse {
// recycling part of the draw code // // recycling part of the draw code //
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) // dunno, no render without this initViewPort(App.scr.width, App.scr.height) // dunno, no render without this
it.projectionMatrix = camera.combined it.projectionMatrix = camera.combined
blendNormal(AppLoader.batch) blendNormal(App.batch)
// message backgrounds // message backgrounds
it.color = messageBackgroundColour it.color = messageBackgroundColour
it.fillRect(0f, 60f, AppLoader.screenSize.screenWf, 40f + (messages.size) * AppLoader.fontGame.lineHeight) it.fillRect(0f, 60f, App.scr.wf, 40f + (messages.size) * App.fontGame.lineHeight)
// log messages // log messages
it.color = messageForegroundColour it.color = messageForegroundColour
messages.reversed().forEachIndexed { i, s -> messages.reversed().forEachIndexed { i, s ->
AppLoader.fontGame.draw(it, App.fontGame.draw(it,
s, s,
AppLoader.screenSize.tvSafeGraphicsWidth + 16f, App.scr.tvSafeGraphicsWidth + 16f,
80f + (messages.size - i - 1) * AppLoader.fontGame.lineHeight 80f + (messages.size - i - 1) * App.fontGame.lineHeight
) )
} }
} }
AppLoader.batch.flush() App.batch.flush()
} }
// replaces super.render() // replaces super.render()
if (doContextChange) { if (doContextChange) {
Thread.sleep(80) Thread.sleep(80)
AppLoader.setScreen(screenToLoad!!) App.setScreen(screenToLoad!!)
} }
} }

View File

@@ -14,7 +14,7 @@ import com.jme3.math.FastMath
import net.torvald.UnsafeHelper import net.torvald.UnsafeHelper
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockproperties.BlockCodex import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex import net.torvald.terrarum.blockproperties.WireCodex
@@ -129,7 +129,7 @@ object Terrarum : Disposable {
println("[Terrarum] init called by:") println("[Terrarum] init called by:")
printStackTrace(this) printStackTrace(this)
println("[Terrarum] ${AppLoader.GAME_NAME} version ${AppLoader.getVERSION_STRING()}") println("[Terrarum] ${App.GAME_NAME} version ${App.getVERSION_STRING()}")
println("[Terrarum] LibGDX version ${com.badlogic.gdx.Version.VERSION}") println("[Terrarum] LibGDX version ${com.badlogic.gdx.Version.VERSION}")
@@ -144,7 +144,7 @@ object Terrarum : Disposable {
println("[Terrarum] vendor = $processorVendor") println("[Terrarum] vendor = $processorVendor")
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
@@ -199,8 +199,8 @@ object Terrarum : Disposable {
//shapeRender = ShapeRenderer() //shapeRender = ShapeRenderer()
AppLoader.GAME_LOCALE = getConfigString("language") App.GAME_LOCALE = getConfigString("language")
printdbg(this, "locale = ${AppLoader.GAME_LOCALE}") printdbg(this, "locale = ${App.GAME_LOCALE}")
@@ -216,7 +216,7 @@ object Terrarum : Disposable {
// title screen // title screen
AppLoader.setScreen(TitleScreen(batch)) App.setScreen(TitleScreen(batch))
} }
/** Don't call this! Call AppLoader.dispose() */ /** Don't call this! Call AppLoader.dispose() */
@@ -339,7 +339,7 @@ inline fun FrameBuffer.inAction(camera: OrthographicCamera?, batch: SpriteBatch?
//this.end() //this.end()
FrameBufferManager.end() FrameBufferManager.end()
camera?.setToOrtho(true, AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera?.setToOrtho(true, App.scr.wf, App.scr.hf)
camera?.update() camera?.update()
batch?.projectionMatrix = camera?.combined batch?.projectionMatrix = camera?.combined
} }
@@ -347,10 +347,10 @@ inline fun FrameBuffer.inAction(camera: OrthographicCamera?, batch: SpriteBatch?
// ShapeRenderer alternative for rects // ShapeRenderer alternative for rects
fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) { fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) {
this.draw(AppLoader.textureWhiteSquare, x, y, w, h) this.draw(App.textureWhiteSquare, x, y, w, h)
} }
fun SpriteBatch.fillCircle(x: Float, y: Float, w: Float, h: Float) { fun SpriteBatch.fillCircle(x: Float, y: Float, w: Float, h: Float) {
this.draw(AppLoader.textureWhiteCircle, x, y, w, h) this.draw(App.textureWhiteCircle, x, y, w, h)
} }
fun SpriteBatch.drawStraightLine(x: Float, y: Float, otherEnd: Float, thickness: Float, isVertical: Boolean) { fun SpriteBatch.drawStraightLine(x: Float, y: Float, otherEnd: Float, thickness: Float, isVertical: Boolean) {
if (!isVertical) if (!isVertical)
@@ -589,7 +589,7 @@ fun <T> List<T>.linearSearchBy(selector: (T) -> Boolean): T? {
inline fun printStackTrace(obj: Any) = printStackTrace(obj, System.out) // because of Java inline fun printStackTrace(obj: Any) = printStackTrace(obj, System.out) // because of Java
fun printStackTrace(obj: Any, out: PrintStream = System.out) { fun printStackTrace(obj: Any, out: PrintStream = System.out) {
if (AppLoader.IS_DEVELOPMENT_BUILD) { if (App.IS_DEVELOPMENT_BUILD) {
Thread.currentThread().stackTrace.forEachIndexed { index, it -> Thread.currentThread().stackTrace.forEachIndexed { index, it ->
if (index >= 3) if (index >= 3)
out.println("[${obj.javaClass.simpleName}] ... $it") out.println("[${obj.javaClass.simpleName}] ... $it")

View File

@@ -12,37 +12,37 @@ class TerrarumScreenSize(scrw: Int = defaultW, scrh: Int = defaultH) {
const val TV_SAFE_ACTION = 0.035f // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf) const val TV_SAFE_ACTION = 0.035f // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf)
} }
var screenW: Int = 0; private set var width: Int = 0; private set
var screenH: Int = 0; private set var height: Int = 0; private set
var screenWf: Float = 0f; private set var wf: Float = 0f; private set
var screenHf: Float = 0f; private set var hf: Float = 0f; private set
var halfScreenW: Int = 0; private set var halfw: Int = 0; private set
var halfScreenH: Int = 0; private set var halfh: Int = 0; private set
var halfScreenWf: Float = 0f; private set var halfwf: Float = 0f; private set
var halfScreenHf: Float = 0f; private set var halfhf: Float = 0f; private set
var aspectRatio: Float = 0f; private set var aspectRatio: Float = 0f; private set
val tvSafeGraphicsWidth: Int; get() = Math.round(screenW * TV_SAFE_GRAPHICS) val tvSafeGraphicsWidth: Int; get() = Math.round(width * TV_SAFE_GRAPHICS)
val tvSafeGraphicsHeight: Int; get() = Math.round(screenH * TV_SAFE_GRAPHICS) val tvSafeGraphicsHeight: Int; get() = Math.round(height * TV_SAFE_GRAPHICS)
val tvSafeActionWidth: Int; get() = Math.round(screenW * TV_SAFE_ACTION) val tvSafeActionWidth: Int; get() = Math.round(width * TV_SAFE_ACTION)
val tvSafeActionHeight: Int; get() = Math.round(screenH * TV_SAFE_ACTION) val tvSafeActionHeight: Int; get() = Math.round(height * TV_SAFE_ACTION)
init { init {
setDimension(maxOf(minimumW, scrw), maxOf(minimumH, scrh)) setDimension(maxOf(minimumW, scrw), maxOf(minimumH, scrh))
} }
fun setDimension(scrw: Int, scrh: Int) { fun setDimension(scrw: Int, scrh: Int) {
screenW = scrw and 0x7FFFFFFE width = scrw and 0x7FFFFFFE
screenH = scrh and 0x7FFFFFFE height = scrh and 0x7FFFFFFE
screenWf = scrw.toFloat() wf = scrw.toFloat()
screenHf = scrh.toFloat() hf = scrh.toFloat()
halfScreenW = screenW / 2 halfw = width / 2
halfScreenH = screenH / 2 halfh = height / 2
halfScreenWf = screenWf / 2f halfwf = wf / 2f
halfScreenHf = screenHf / 2f halfhf = hf / 2f
aspectRatio = screenWf / screenHf aspectRatio = wf / hf
} }
} }

View File

@@ -45,7 +45,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
fun enter() { fun enter() {
// init view port // init view port
camera = OrthographicCamera(AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera = OrthographicCamera(App.scr.wf, App.scr.hf)
img = Texture("assets/test_texture.tga") img = Texture("assets/test_texture.tga")
@@ -57,14 +57,14 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
blurFboA = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false) blurFboA = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false)
blurFboB = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false) blurFboB = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false)
worldFbo = FrameBuffer(Pixmap.Format.RGBA8888, AppLoader.screenSize.screenW, AppLoader.screenSize.screenH, false) worldFbo = FrameBuffer(Pixmap.Format.RGBA8888, App.scr.width, App.scr.height, false)
//blurShader.begin() //blurShader.begin()
//blurShader.setUniformf("iResolution", img.width.toFloat(), img.height.toFloat(), 0f) //blurShader.setUniformf("iResolution", img.width.toFloat(), img.height.toFloat(), 0f)
//blurShader.end() //blurShader.end()
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
} }
override fun render(delta: Float) { override fun render(delta: Float) {
@@ -135,7 +135,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
batch.inUse { batch.inUse {
batch.shader = null batch.shader = null
camera.position.set(AppLoader.screenSize.screenW / 2f - 50f, AppLoader.screenSize.screenH / 2f - 50f, 0f) camera.position.set(App.scr.width / 2f - 50f, App.scr.height / 2f - 50f, 0f)
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
@@ -147,11 +147,11 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
} }
camera.setToOrtho(true, AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera.setToOrtho(true, App.scr.wf, App.scr.hf)
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
batch.inUse { batch.inUse {
camera.position.set(AppLoader.screenSize.screenW / 2f, AppLoader.screenSize.screenH / 2f, 0f) camera.position.set(App.scr.width / 2f, App.scr.height / 2f, 0f)
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
@@ -168,7 +168,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
} }
override fun show() { override fun show() {
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
} }
override fun pause() { override fun pause() {

View File

@@ -5,12 +5,13 @@ import com.badlogic.gdx.InputAdapter
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
import net.torvald.terrarum.console.CommandDict import net.torvald.terrarum.console.CommandDict
@@ -39,7 +40,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
// todo register titlescreen as the ingame, similar in a way that the buildingmaker did // todo register titlescreen as the ingame, similar in a way that the buildingmaker did
var camera = OrthographicCamera(AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) var camera = OrthographicCamera(App.scr.wf, App.scr.hf)
// invert Y // invert Y
@@ -160,6 +161,15 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
IngameRenderer.setRenderedWorld(demoWorld) IngameRenderer.setRenderedWorld(demoWorld)
// load a half-gradient texture that would be used throughout the titlescreen and its sub UIs
CommonResourcePool.addToLoadingList("title_halfgrad") { Texture(Gdx.files.internal("./assets/graphics/halfgrad.png")) }
CommonResourcePool.loadAll()
// fake UI for gradient overlay
val uiFakeGradOverlay = UIFakeGradOverlay()
uiMenu = UIRemoCon(UITitleRemoConYaml())//UITitleRemoConRoot() uiMenu = UIRemoCon(UITitleRemoConYaml())//UITitleRemoConRoot()
uiMenu.setPosition(0, 0) uiMenu.setPosition(0, 0)
uiMenu.setAsOpen() uiMenu.setAsOpen()
@@ -181,13 +191,13 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
override fun show() { override fun show() {
printdbg(this, "show() called") printdbg(this, "show() called")
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
Gdx.input.inputProcessor = TitleScreenController(this) Gdx.input.inputProcessor = TitleScreenController(this)
worldFBO = FrameBuffer(Pixmap.Format.RGBA8888, AppLoader.screenSize.screenW, AppLoader.screenSize.screenH, false) worldFBO = FrameBuffer(Pixmap.Format.RGBA8888, App.scr.width, App.scr.height, false)
loadThingsWhileIntroIsVisible() loadThingsWhileIntroIsVisible()
@@ -214,15 +224,15 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
var i = 0L var i = 0L
while (updateAkku >= updateRate) { while (updateAkku >= updateRate) {
AppLoader.measureDebugTime("Ingame.Update") { updateScreen(updateRate) } App.measureDebugTime("Ingame.Update") { updateScreen(updateRate) }
updateAkku -= updateRate updateAkku -= updateRate
i += 1 i += 1
} }
AppLoader.setDebugTime("Ingame.UpdateCounter", i) App.setDebugTime("Ingame.UpdateCounter", i)
// render? just do it anyway // render? just do it anyway
AppLoader.measureDebugTime("Ingame.Render") { renderScreen() } App.measureDebugTime("Ingame.Render") { renderScreen() }
} }
fun updateScreen(delta: Float) { fun updateScreen(delta: Float) {
@@ -278,14 +288,14 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
) )
COPYTING.forEachIndexed { index, s -> COPYTING.forEachIndexed { index, s ->
val textWidth = AppLoader.fontGame.getWidth(s) val textWidth = App.fontGame.getWidth(s)
AppLoader.fontGame.draw(batch, s, App.fontGame.draw(batch, s,
(AppLoader.screenSize.screenW - textWidth - 1f).toInt().toFloat(), (App.scr.width - textWidth - 1f).toInt().toFloat(),
(AppLoader.screenSize.screenH - AppLoader.fontGame.lineHeight * (COPYTING.size - index) - 1f).toInt().toFloat() (App.scr.height - App.fontGame.lineHeight * (COPYTING.size - index) - 1f).toInt().toFloat()
) )
} }
AppLoader.fontGame.draw(batch, PostProcessor.thisIsDebugStr, 5f, AppLoader.screenSize.screenH - 24f) App.fontGame.draw(batch, PostProcessor.thisIsDebugStr, 5f, App.scr.height - 24f)
} }
@@ -301,11 +311,11 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
printStackTrace(this) printStackTrace(this)
// Set up viewport when window is resized // Set up viewport when window is resized
initViewPort(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) initViewPort(App.scr.width, App.scr.height)
// resize UI by re-creating it (!!) // resize UI by re-creating it (!!)
uiMenu.resize(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) uiMenu.resize(App.scr.width, App.scr.height)
// TODO I forgot what the fuck kind of hack I was talking about // TODO I forgot what the fuck kind of hack I was talking about
//uiMenu.setPosition(0, UITitleRemoConRoot.menubarOffY) //uiMenu.setPosition(0, UITitleRemoConRoot.menubarOffY)
uiMenu.setPosition(0, 0) // shitty hack. Could be: uiMenu.setPosition(0, 0) // shitty hack. Could be:
@@ -313,7 +323,7 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
// 2: The UI is coded shit // 2: The UI is coded shit
IngameRenderer.resize(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) IngameRenderer.resize(App.scr.width, App.scr.height)
printdbg(this, "resize() exit") printdbg(this, "resize() exit")
} }

View File

@@ -0,0 +1,42 @@
package net.torvald.terrarum
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.ui.UICanvas
/**
* Created by minjaesong on 2021-09-09.
*/
class UIFakeGradOverlay : UICanvas() {
override var width: Int
get() = App.scr.width
set(value) {}
override var height: Int
get() = App.scr.height
set(value) {}
override var openCloseTime: Second = 0f
private val tex = CommonResourcePool.getAsTexture("title_halfgrad")
init {
setAsAlwaysVisible()
}
override fun updateUI(delta: Float) {}
override fun renderUI(batch: SpriteBatch, camera: Camera) {
gdxSetBlendMul()
batch.draw(tex, 0f, 0f, App.scr.wf, App.scr.hf)
gdxSetBlendNormal()
}
override fun doOpening(delta: Float) {}
override fun doClosing(delta: Float) {}
override fun endOpening(delta: Float) {}
override fun endClosing(delta: Float) {}
override fun dispose() {}
}

View File

@@ -1,15 +1,10 @@
package net.torvald.terrarum package net.torvald.terrarum
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVEN_DEBUG_MODE
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
@@ -108,7 +103,7 @@ class UIItemInventoryElem(
batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol
// draw name of the item // draw name of the item
if (INVEN_DEBUG_MODE) { if (INVEN_DEBUG_MODE) {
AppLoader.fontGame.draw(batch, App.fontGame.draw(batch,
// print static id, dynamic id, and count // print static id, dynamic id, and count
"${item!!.originalID}/${item!!.dynamicID}" + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else ""), "${item!!.originalID}/${item!!.dynamicID}" + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else ""),
posX + textOffsetX, posX + textOffsetX,
@@ -116,7 +111,7 @@ class UIItemInventoryElem(
) )
} }
else { else {
AppLoader.fontGame.draw(batch, App.fontGame.draw(batch,
// print name and amount in parens // print name and amount in parens
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else "") + item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amountString)" else if (amount != 1) "$fwsp!!$amountString!!" else "") +
// TEMPORARY print eqipped slot info as well // TEMPORARY print eqipped slot info as well
@@ -147,8 +142,8 @@ class UIItemInventoryElem(
if (quickslot != null) { if (quickslot != null) {
val label = quickslot!!.plus(0xE010).toChar() val label = quickslot!!.plus(0xE010).toChar()
val labelW = AppLoader.fontGame.getWidth("$label") val labelW = App.fontGame.getWidth("$label")
AppLoader.fontGame.draw(batch, "$label", barOffset + barFullLen - labelW, posY + textOffsetY) App.fontGame.draw(batch, "$label", barOffset + barFullLen - labelW, posY + textOffsetY)
} }
} }

View File

@@ -1,15 +1,10 @@
package net.torvald.terrarum package net.torvald.terrarum
import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellBase
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes
import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText import net.torvald.terrarum.modulebasegame.ui.UIItemInventoryCellCommonRes.toItemCountText
@@ -117,10 +112,10 @@ class UIItemInventoryElemSimple(
} }
AppLoader.fontSmallNumbers.draw(batch, App.fontSmallNumbers.draw(batch,
amountString, amountString,
posX + (width - AppLoader.fontSmallNumbers.getWidth(amountString)).toFloat(), posX + (width - App.fontSmallNumbers.getWidth(amountString)).toFloat(),
posY + (height - AppLoader.fontSmallNumbers.H).toFloat() posY + (height - App.fontSmallNumbers.H).toFloat()
) )
} }

View File

@@ -1,16 +1,14 @@
package net.torvald.terrarum.blockproperties package net.torvald.terrarum.blockproperties
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printmsg import net.torvald.terrarum.App.printmsg
import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.ReferencingRanges.PREFIX_VIRTUALTILE import net.torvald.terrarum.ReferencingRanges.PREFIX_VIRTUALTILE
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.FluidType import net.torvald.terrarum.gameworld.FluidType
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.utils.CSVFetcher import net.torvald.terrarum.utils.CSVFetcher
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.util.SortedArrayList import net.torvald.util.SortedArrayList
import org.apache.commons.csv.CSVRecord import org.apache.commons.csv.CSVRecord
import java.io.IOException import java.io.IOException
@@ -61,7 +59,7 @@ class BlockCodex {
* Later entry (possible from other modules) will replace older ones * Later entry (possible from other modules) will replace older ones
*/ */
internal constructor(module: String, path: String) : this() { internal constructor(module: String, path: String) : this() {
AppLoader.printmsg(this, "Building block properties table") App.printmsg(this, "Building block properties table")
try { try {
register(module, CSVFetcher.readFromModule(module, path)) register(module, CSVFetcher.readFromModule(module, path))
} }
@@ -69,7 +67,7 @@ class BlockCodex {
} }
fun fromCSV(module: String, csvString: String) { fun fromCSV(module: String, csvString: String) {
AppLoader.printmsg(this, "Building wire properties table for module $module") App.printmsg(this, "Building wire properties table for module $module")
val csvParser = org.apache.commons.csv.CSVParser.parse( val csvParser = org.apache.commons.csv.CSVParser.parse(
csvString, csvString,

View File

@@ -39,7 +39,7 @@ class WireCodex {
* @param path to the "wires" directory, not path to the CSV; must end with a slash! * @param path to the "wires" directory, not path to the CSV; must end with a slash!
*/ */
internal constructor(module: String, path: String) : this() { internal constructor(module: String, path: String) : this() {
AppLoader.printmsg(this, "Building wire properties table for module $module") App.printmsg(this, "Building wire properties table for module $module")
try { try {
register(module, path, CSVFetcher.readFromModule(module, path + "wires.csv")) register(module, path, CSVFetcher.readFromModule(module, path + "wires.csv"))
} }
@@ -47,7 +47,7 @@ class WireCodex {
} }
fun fromCSV(module: String, path: String, csvString: String) { fun fromCSV(module: String, path: String, csvString: String) {
AppLoader.printmsg(this, "Building wire properties table for module $module") App.printmsg(this, "Building wire properties table for module $module")
val csvParser = org.apache.commons.csv.CSVParser.parse( val csvParser = org.apache.commons.csv.CSVParser.parse(
csvString, csvString,
@@ -64,7 +64,7 @@ class WireCodex {
setProp(module, it.intVal("id"), it) setProp(module, it.intVal("id"), it)
} }
AppLoader.printmsg(this, "Registering wire textures into the resource pool") App.printmsg(this, "Registering wire textures into the resource pool")
wireProps.keys.forEach { id -> wireProps.keys.forEach { id ->
val wireid = id.split(':').last().toInt() val wireid = id.split(':').last().toInt()
@@ -148,6 +148,6 @@ class WireCodex {
val loadedClassInstance = loadedClassConstructor.newInstance(prop.id, invImgSheet, invImgX, invImgY) val loadedClassInstance = loadedClassConstructor.newInstance(prop.id, invImgSheet, invImgX, invImgY)
ItemCodex[prop.id] = loadedClassInstance as GameItem ItemCodex[prop.id] = loadedClassInstance as GameItem
AppLoader.printmsg(this, "Setting prop ${prop.id} ->>\t${prop.nameKey}") App.printmsg(this, "Setting prop ${prop.id} ->>\t${prop.nameKey}")
} }
} }

View File

@@ -1,15 +1,13 @@
package net.torvald.terrarum.blockstats package net.torvald.terrarum.blockstats
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumAppConfiguration
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.worlddrawer.BlocksDrawer import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import java.util.* import java.util.*
/** /**
@@ -31,8 +29,8 @@ object BlockStats {
val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying val player = (Terrarum.ingame!! as TerrarumIngame).actorNowPlaying
if (player == null) return if (player == null) return
val renderWidth = FastMath.ceil(AppLoader.screenSize.screenWf) val renderWidth = FastMath.ceil(App.scr.wf)
val renderHeight = FastMath.ceil(AppLoader.screenSize.screenHf) val renderHeight = FastMath.ceil(App.scr.hf)
val noZoomCameraX = Math.round(FastMath.clamp( val noZoomCameraX = Math.round(FastMath.clamp(
player.hitbox.centeredX.toFloat() - renderWidth / 2, TILE_SIZEF, map.width * TILE_SIZE - renderWidth - TILE_SIZEF)) player.hitbox.centeredX.toFloat() - renderWidth / 2, TILE_SIZEF, map.width * TILE_SIZE - renderWidth - TILE_SIZEF))

View File

@@ -5,12 +5,9 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import com.badlogic.gdx.utils.GdxRuntimeException import com.badlogic.gdx.utils.GdxRuntimeException
import com.badlogic.gdx.utils.Queue import com.badlogic.gdx.utils.Queue
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
object MinimapComposer : Disposable { object MinimapComposer : Disposable {
@@ -22,7 +19,7 @@ object MinimapComposer : Disposable {
fun setWorld(world: GameWorld) { fun setWorld(world: GameWorld) {
try { try {
if (this.world != world) { if (this.world != world) {
AppLoader.printdbg(this, "World change detected -- old world: ${this.world.hashCode()}, new world: ${world.hashCode()}") App.printdbg(this, "World change detected -- old world: ${this.world.hashCode()}, new world: ${world.hashCode()}")
// TODO, also set totalWidth/Height // TODO, also set totalWidth/Height
} }
@@ -59,7 +56,7 @@ object MinimapComposer : Disposable {
private val liveTilesMeta = Array(TILES_IN_X * TILES_IN_Y) { LiveTileMeta(revalidate = true) } private val liveTilesMeta = Array(TILES_IN_X * TILES_IN_Y) { LiveTileMeta(revalidate = true) }
private val updaterQueue = Queue<Runnable>(TILES_IN_X * TILES_IN_Y * 2) private val updaterQueue = Queue<Runnable>(TILES_IN_X * TILES_IN_Y * 2)
private var currentThreads = Array(maxOf(1, AppLoader.THREAD_COUNT.times(2).div(3))) { private var currentThreads = Array(maxOf(1, App.THREAD_COUNT.times(2).div(3))) {
Thread() Thread()
} }
@@ -67,7 +64,7 @@ object MinimapComposer : Disposable {
totalWidth = minimap.width totalWidth = minimap.width
totalHeight = minimap.height totalHeight = minimap.height
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
} }
fun update() { fun update() {
@@ -136,8 +133,8 @@ object MinimapComposer : Disposable {
for (x in if (tileSlotIndexY >= TILES_IN_X / 2) (topLeftX + LIVETILE_SIZE - 1) downTo topLeftX else topLeftX until topLeftX + LIVETILE_SIZE) { for (x in if (tileSlotIndexY >= TILES_IN_X / 2) (topLeftX + LIVETILE_SIZE - 1) downTo topLeftX else topLeftX until topLeftX + LIVETILE_SIZE) {
val tileTerr = world.getTileFromTerrain(x, y) val tileTerr = world.getTileFromTerrain(x, y)
val wallTerr = world.getTileFromWall(x, y) val wallTerr = world.getTileFromWall(x, y)
val colTerr = AppLoader.tileMaker.terrainTileColourMap.get(tileTerr)!!.toGdxColor() val colTerr = App.tileMaker.terrainTileColourMap.get(tileTerr)!!.toGdxColor()
val colWall = AppLoader.tileMaker.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(AppLoader.tileMaker.wallOverlayColour) val colWall = App.tileMaker.terrainTileColourMap.get(wallTerr)!!.toGdxColor().mul(App.tileMaker.wallOverlayColour)
val outCol = if (colTerr.a > 0.1f) colTerr else colWall val outCol = if (colTerr.a > 0.1f) colTerr else colWall

View File

@@ -1,14 +1,10 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.ModMgr.loadOrder
import net.torvald.terrarum.modulebasegame.console.*
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStreamReader import java.io.InputStreamReader
import java.util.*
import kotlin.streams.toList
/** /**
* Created by minjaesong on 2016-01-15. * Created by minjaesong on 2016-01-15.

View File

@@ -1,19 +1,19 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.TerrarumScreenSize import net.torvald.terrarum.TerrarumScreenSize
@ConsoleAlias("resize") @ConsoleAlias("resize")
object ResizeScreen: ConsoleCommand { object ResizeScreen: ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 3) { if (args.size == 3) {
AppLoader.resizeScreen(args[1].toInt(), args[2].toInt()) App.resizeScreen(args[1].toInt(), args[2].toInt())
} }
else if (args.size == 2) { else if (args.size == 2) {
when (args[1]) { when (args[1]) {
"720p" -> AppLoader.resizeScreen(1280,720) "720p" -> App.resizeScreen(1280,720)
"1080p" -> AppLoader.resizeScreen(1920,1080) "1080p" -> App.resizeScreen(1920,1080)
"default" -> AppLoader.resizeScreen(TerrarumScreenSize.defaultW, TerrarumScreenSize.defaultH) "default" -> App.resizeScreen(TerrarumScreenSize.defaultW, TerrarumScreenSize.defaultH)
else -> { printUsage(); return } else -> { printUsage(); return }
} }
} }
@@ -21,7 +21,7 @@ object ResizeScreen: ConsoleCommand {
printUsage(); return printUsage(); return
} }
Echo("Screen resized to ${AppLoader.screenSize.screenW}x${AppLoader.screenSize.screenH}") Echo("Screen resized to ${App.scr.width}x${App.scr.height}")
} }
override fun printUsage() { override fun printUsage() {

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.console
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import net.torvald.gdx.graphics.PixmapIO2 import net.torvald.gdx.graphics.PixmapIO2
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.ccG import net.torvald.terrarum.ccG
import net.torvald.terrarum.modulebasegame.IngameRenderer import net.torvald.terrarum.modulebasegame.IngameRenderer
@@ -15,7 +15,7 @@ object ScreencapNogui: ConsoleCommand {
val w = 960 val w = 960
val h = 640 val h = 640
val p = Pixmap.createFromFrameBuffer((it.width - w).ushr(1), (it.height - h).ushr(1), w, h) val p = Pixmap.createFromFrameBuffer((it.width - w).ushr(1), (it.height - h).ushr(1), w, h)
PixmapIO2.writeTGA(Gdx.files.absolute(AppLoader.defaultDir + "/Exports/${args[1]}.tga"), p, true) PixmapIO2.writeTGA(Gdx.files.absolute(App.defaultDir + "/Exports/${args[1]}.tga"), p, true)
p.dispose() p.dispose()
} }
IngameRenderer.fboRGBexportRequested = true IngameRenderer.fboRGBexportRequested = true

View File

@@ -1,7 +1,7 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import java.io.IOException import java.io.IOException
@@ -11,14 +11,14 @@ import java.io.IOException
internal object SetLocale : ConsoleCommand { internal object SetLocale : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
val prevLocale = AppLoader.GAME_LOCALE val prevLocale = App.GAME_LOCALE
AppLoader.GAME_LOCALE = args[1] App.GAME_LOCALE = args[1]
try { try {
Echo("Set locale to '" + AppLoader.GAME_LOCALE + "'.") Echo("Set locale to '" + App.GAME_LOCALE + "'.")
} }
catch (e: IOException) { catch (e: IOException) {
Echo("could not read lang file.") Echo("could not read lang file.")
AppLoader.GAME_LOCALE = prevLocale App.GAME_LOCALE = prevLocale
} }
} }

View File

@@ -1,11 +1,11 @@
package net.torvald.terrarum.console package net.torvald.terrarum.console
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
@ConsoleNoExport @ConsoleNoExport
object TakeScreenshot: ConsoleCommand { object TakeScreenshot: ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
AppLoader.requestScreenshot() App.requestScreenshot()
} }
override fun printUsage() { override fun printUsage() {

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.console
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
/** /**
@@ -11,7 +11,7 @@ import net.torvald.terrarum.langpack.Lang
internal object Version : ConsoleCommand { internal object Version : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
Echo("${AppLoader.GAME_NAME} ${AppLoader.getVERSION_STRING()}") Echo("${App.GAME_NAME} ${App.getVERSION_STRING()}")
Echo("Java version: ${System.getProperty("java.version")}") Echo("Java version: ${System.getProperty("java.version")}")
Echo("Polyglot language pack version: ${Lang.POLYGLOT_VERSION}") Echo("Polyglot language pack version: ${Lang.POLYGLOT_VERSION}")
Echo("GL version: ${Terrarum.GL_VERSION}") Echo("GL version: ${Terrarum.GL_VERSION}")

View File

@@ -1,7 +1,7 @@
package net.torvald.terrarum.controller package net.torvald.terrarum.controller
import net.torvald.terrarum.AppLoader.gamepadDeadzone import net.torvald.terrarum.App.gamepadDeadzone
import net.torvald.terrarum.AppLoader.getConfigDoubleArray import net.torvald.terrarum.App.getConfigDoubleArray
/** /**
* Created by minjaesong on 2019-02-09. * Created by minjaesong on 2019-02-09.

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.controller
import com.github.strikerx3.jxinput.XInputAxes import com.github.strikerx3.jxinput.XInputAxes
import com.github.strikerx3.jxinput.XInputDevice import com.github.strikerx3.jxinput.XInputDevice
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import kotlin.math.roundToInt import kotlin.math.roundToInt
/** /**
@@ -26,8 +26,8 @@ class XinputControllerAdapter(val c: XInputDevice): TerrarumController {
5 -> button.rShoulder 5 -> button.rShoulder
6 -> button.back 6 -> button.back
7 -> button.start 7 -> button.start
8 -> getAxis(4) >= AppLoader.gamepadDeadzone 8 -> getAxis(4) >= App.gamepadDeadzone
9 -> getAxis(5) >= AppLoader.gamepadDeadzone 9 -> getAxis(5) >= App.gamepadDeadzone
10 -> button.lThumb 10 -> button.lThumb
11 -> button.rThumb 11 -> button.rThumb
else -> throw UnsupportedOperationException("Unknown button: $index") else -> throw UnsupportedOperationException("Unknown button: $index")

View File

@@ -6,8 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.spriteanimation.HasAssembledSprite import net.torvald.spriteanimation.HasAssembledSprite
import net.torvald.spriteanimation.SpriteAnimation import net.torvald.spriteanimation.SpriteAnimation
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
@@ -376,7 +376,7 @@ open class ActorWithBody : Actor {
val feetPosTile: Point2i = Point2i(0,0) val feetPosTile: Point2i = Point2i(0,0)
//get() = Point2i(hIntTilewiseHitbox.centeredX.floorInt(), hIntTilewiseHitbox.endY.floorInt()) //get() = Point2i(hIntTilewiseHitbox.centeredX.floorInt(), hIntTilewiseHitbox.endY.floorInt())
override fun run() = update(AppLoader.UPDATE_RATE) override fun run() = update(App.UPDATE_RATE)
/** /**
* Add vector value to the velocity, in the time unit of single frame. * Add vector value to the velocity, in the time unit of single frame.

View File

@@ -7,9 +7,9 @@ import com.badlogic.gdx.InputAdapter
import com.badlogic.gdx.controllers.Controllers import com.badlogic.gdx.controllers.Controllers
import com.badlogic.gdx.utils.GdxRuntimeException import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.controller.TerrarumController import net.torvald.terrarum.controller.TerrarumController
import net.torvald.terrarum.floorInt import net.torvald.terrarum.floorInt
@@ -130,8 +130,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
// also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing // also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing
// the very job. // the very job.
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) && !worldPrimaryClickLatched) { if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary")) && !worldPrimaryClickLatched) {
terrarumIngame.worldPrimaryClickStart(AppLoader.UPDATE_RATE) terrarumIngame.worldPrimaryClickStart(App.UPDATE_RATE)
worldPrimaryClickLatched = true worldPrimaryClickLatched = true
} }
/*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary")) { /*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary")) {
@@ -141,7 +141,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
// unlatch when: // unlatch when:
// - not clicking anymore // - not clicking anymore
// - using any item that is not fixture (blocks, picks) // - using any item that is not fixture (blocks, picks)
if (!Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) || if (!Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary")) ||
GameItem.Category.FIXTURE != ItemCodex.get(terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP))?.inventoryCategory) { GameItem.Category.FIXTURE != ItemCodex.get(terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP))?.inventoryCategory) {
worldPrimaryClickLatched = false worldPrimaryClickLatched = false
} }
@@ -160,14 +160,14 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
terrarumIngame.actorNowPlaying?.keyDown(keycode) terrarumIngame.actorNowPlaying?.keyDown(keycode)
// quickslot by number keys // quickslot by number keys
val quickslotKeys = AppLoader.getConfigIntArray("config_keyquickslots") val quickslotKeys = App.getConfigIntArray("config_keyquickslots")
if (keycode in quickslotKeys) { if (keycode in quickslotKeys) {
terrarumIngame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode)) terrarumIngame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode))
} }
// pie menu // pie menu
if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode) if (App.getConfigIntArray("config_keyquickselalt").contains(keycode)
|| keycode == AppLoader.getConfigInt("config_keyquicksel")) { || keycode == App.getConfigInt("config_keyquicksel")) {
terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiPieMenu.setAsOpen()
terrarumIngame.uiQuickBar.setAsClose() terrarumIngame.uiQuickBar.setAsClose()
} }
@@ -183,7 +183,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
// screenshot key // screenshot key
if (keycode == Input.Keys.F12 && !f12Down) { if (keycode == Input.Keys.F12 && !f12Down) {
AppLoader.requestScreenshot() App.requestScreenshot()
f12Down = true f12Down = true
println("Screenshot taken.") println("Screenshot taken.")
} }
@@ -192,8 +192,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
} }
private fun tKeyUp(keycode: Int): Boolean { private fun tKeyUp(keycode: Int): Boolean {
if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode) if (App.getConfigIntArray("config_keyquickselalt").contains(keycode)
|| keycode == AppLoader.getConfigInt("config_keyquicksel")) { || keycode == App.getConfigInt("config_keyquicksel")) {
terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiPieMenu.setAsClose()
terrarumIngame.uiQuickBar.setAsOpen() terrarumIngame.uiQuickBar.setAsOpen()
} }
@@ -219,9 +219,9 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
if (terrarumIngame.uiContainer.map { if ((it?.isOpening == true || it?.isOpened == true) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right? if (terrarumIngame.uiContainer.map { if ((it?.isOpening == true || it?.isOpened == true) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
if ( if (
button == AppLoader.getConfigInt("config_mouseprimary") || button == App.getConfigInt("config_mouseprimary") ||
button == AppLoader.getConfigInt("config_mousesecondary")) { button == App.getConfigInt("config_mousesecondary")) {
terrarumIngame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE) terrarumIngame.worldPrimaryClickEnd(App.UPDATE_RATE)
} }
/*if (button == AppLoader.getConfigInt("config_mousesecondary")) { /*if (button == AppLoader.getConfigInt("config_mousesecondary")) {
ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE) ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE)
@@ -230,7 +230,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
} }
// pie menu // pie menu
if (button == AppLoader.getConfigInt("config_mousequicksel")) { if (button == App.getConfigInt("config_mousequicksel")) {
terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiPieMenu.setAsClose()
terrarumIngame.uiQuickBar.setAsOpen() terrarumIngame.uiQuickBar.setAsOpen()
} }
@@ -263,7 +263,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
terrarumIngame.uiContainer.forEach { it?.touchDown(screenX, screenY, pointer, button) } terrarumIngame.uiContainer.forEach { it?.touchDown(screenX, screenY, pointer, button) }
// pie menu // pie menu
if (button == AppLoader.getConfigInt("config_mousequicksel")) { if (button == App.getConfigInt("config_mousequicksel")) {
terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiPieMenu.setAsOpen()
terrarumIngame.uiQuickBar.setAsClose() terrarumIngame.uiQuickBar.setAsClose()
} }

View File

@@ -4,8 +4,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.Hitbox import net.torvald.terrarum.gameactors.Hitbox
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
@@ -20,7 +18,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
/** Will NOT actually delete from the CircularArray */ /** Will NOT actually delete from the CircularArray */
@Volatile var flagDespawn = false @Volatile var flagDespawn = false
override fun run() = update(AppLoader.UPDATE_RATE) override fun run() = update(App.UPDATE_RATE)
var isNoSubjectToGrav = false var isNoSubjectToGrav = false
var dragCoefficient = 3.0 var dragCoefficient = 3.0

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameworld
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.UnsafeHelper import net.torvald.UnsafeHelper
import net.torvald.UnsafePtr import net.torvald.UnsafePtr
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
/** /**
* Memory layout: * Memory layout:

View File

@@ -4,9 +4,8 @@ package net.torvald.terrarum.gameworld
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.gameactors.ActorID import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.gameactors.WireActor import net.torvald.terrarum.gameactors.WireActor
@@ -36,9 +35,9 @@ class GameWorld() : Disposable {
var width: Int = 999; private set var width: Int = 999; private set
var height: Int = 999; private set var height: Int = 999; private set
var creationTime: Long = AppLoader.getTIME_T() var creationTime: Long = App.getTIME_T()
internal set internal set
var lastPlayTime: Long = AppLoader.getTIME_T() var lastPlayTime: Long = App.getTIME_T()
internal set // there's a case of save-and-continue-playing internal set // there's a case of save-and-continue-playing
var totalPlayTime: Long = 0 var totalPlayTime: Long = 0
internal set internal set
@@ -134,7 +133,7 @@ class GameWorld() : Disposable {
this.totalPlayTime = totalPlayTime this.totalPlayTime = totalPlayTime
AppLoader.tileMaker.tags.forEach { App.tileMaker.tags.forEach {
printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}") printdbg(this, "tileNumber ${it.value.tileNumber} <-> tileName ${it.key}")
tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key tileNumberToNameMap[it.value.tileNumber.toLong()] = it.key

View File

@@ -1,30 +1,18 @@
package net.torvald.terrarum.gameworld package net.torvald.terrarum.gameworld
import com.badlogic.gdx.Input
import com.badlogic.gdx.utils.Queue import com.badlogic.gdx.utils.Queue
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.Fluid import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.modulebasegame.TerrarumIngame.Companion.inUpdateRange import net.torvald.terrarum.modulebasegame.TerrarumIngame.Companion.inUpdateRange
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.modulebasegame.gameactors.BlockBoxIndex
import net.torvald.terrarum.modulebasegame.gameactors.Electric import net.torvald.terrarum.modulebasegame.gameactors.Electric
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.util.IntArrayStack
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
import org.khelekore.prtree.*
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
import kotlin.experimental.and
import kotlin.math.roundToInt import kotlin.math.roundToInt
/** /**
@@ -93,13 +81,13 @@ object WorldSimulator {
degrass() degrass()
AppLoader.measureDebugTime("WorldSimulator.fluids") { App.measureDebugTime("WorldSimulator.fluids") {
//moveFluids(delta) //moveFluids(delta)
} }
AppLoader.measureDebugTime("WorldSimulator.fallables") { App.measureDebugTime("WorldSimulator.fallables") {
displaceFallables(delta) displaceFallables(delta)
} }
AppLoader.measureDebugTime("WorldSimulator.wires") { App.measureDebugTime("WorldSimulator.wires") {
simulateWires(delta) simulateWires(delta)
} }
@@ -109,7 +97,7 @@ object WorldSimulator {
fun degrass() { fun degrass() {
if (ingame.terrainChangeQueue.isNotEmpty()) { AppLoader.measureDebugTime("WorldSimulator.degrass") { if (ingame.terrainChangeQueue.isNotEmpty()) { App.measureDebugTime("WorldSimulator.degrass") {
//val grassPlacedByPlayer = ArrayList<IngameInstance.BlockChangeQueueItem>() //val grassPlacedByPlayer = ArrayList<IngameInstance.BlockChangeQueueItem>()
@@ -167,7 +155,7 @@ object WorldSimulator {
simCompression() simCompression()
if (AppLoader.IS_DEVELOPMENT_BUILD) { if (App.IS_DEVELOPMENT_BUILD) {
monitorIllegalFluidSetup() // non-air non-zero fluid is kinda inevitable monitorIllegalFluidSetup() // non-air non-zero fluid is kinda inevitable
} }

View File

@@ -1,8 +1,8 @@
package net.torvald.terrarum.itemproperties package net.torvald.terrarum.itemproperties
import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.graphics.g2d.TextureRegion
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.ReferencingRanges import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM import net.torvald.terrarum.ReferencingRanges.PREFIX_ACTORITEM
@@ -58,7 +58,7 @@ class ItemCodex {
* @param: dynamicID string of "dyn:<random id>" * @param: dynamicID string of "dyn:<random id>"
*/ */
fun registerNewDynamicItem(dynamicID: ItemID, item: GameItem) { fun registerNewDynamicItem(dynamicID: ItemID, item: GameItem) {
if (AppLoader.IS_DEVELOPMENT_BUILD) { if (App.IS_DEVELOPMENT_BUILD) {
printdbg(this, "Registering new dynamic item $dynamicID (from ${item.originalID})") printdbg(this, "Registering new dynamic item $dynamicID (from ${item.originalID})")
} }
dynamicItemDescription[dynamicID] = item dynamicItemDescription[dynamicID] = item
@@ -121,18 +121,18 @@ class ItemCodex {
} }
// wall // wall
else if (itemID.startsWith("wall@")) { else if (itemID.startsWith("wall@")) {
val itemSheetNumber = AppLoader.tileMaker.tileIDtoItemSheetNumber(itemID.substring(5)) val itemSheetNumber = App.tileMaker.tileIDtoItemSheetNumber(itemID.substring(5))
return BlocksDrawer.tileItemWall.get( return BlocksDrawer.tileItemWall.get(
itemSheetNumber % AppLoader.tileMaker.ITEM_ATLAS_TILES_X, itemSheetNumber % App.tileMaker.ITEM_ATLAS_TILES_X,
itemSheetNumber / AppLoader.tileMaker.ITEM_ATLAS_TILES_X itemSheetNumber / App.tileMaker.ITEM_ATLAS_TILES_X
) )
} }
// terrain // terrain
else { else {
val itemSheetNumber = AppLoader.tileMaker.tileIDtoItemSheetNumber(itemID) val itemSheetNumber = App.tileMaker.tileIDtoItemSheetNumber(itemID)
return BlocksDrawer.tileItemTerrain.get( return BlocksDrawer.tileItemTerrain.get(
itemSheetNumber % AppLoader.tileMaker.ITEM_ATLAS_TILES_X, itemSheetNumber % App.tileMaker.ITEM_ATLAS_TILES_X,
itemSheetNumber / AppLoader.tileMaker.ITEM_ATLAS_TILES_X itemSheetNumber / App.tileMaker.ITEM_ATLAS_TILES_X
) )
} }

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.itemproperties package net.torvald.terrarum.itemproperties
import net.torvald.terrarum.AppLoader.printmsg import net.torvald.terrarum.App.printmsg
import net.torvald.terrarum.Codex import net.torvald.terrarum.Codex
import net.torvald.terrarum.blockproperties.floatVal import net.torvald.terrarum.blockproperties.floatVal
import net.torvald.terrarum.blockproperties.intVal import net.torvald.terrarum.blockproperties.intVal

View File

@@ -1,7 +1,7 @@
package net.torvald.terrarum.langpack package net.torvald.terrarum.langpack
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.utils.JsonFetcher import net.torvald.terrarum.utils.JsonFetcher
import java.io.File import java.io.File
import java.util.* import java.util.*
@@ -120,17 +120,17 @@ object Lang {
fun fallback(): String = langpack["${key}_$FALLBACK_LANG_CODE"] ?: "$$key" fun fallback(): String = langpack["${key}_$FALLBACK_LANG_CODE"] ?: "$$key"
val ret = langpack["${key}_${AppLoader.GAME_LOCALE}"] val ret = langpack["${key}_${App.GAME_LOCALE}"]
val ret2 = if (ret.isNullOrEmpty()) fallback() else ret!! val ret2 = if (ret.isNullOrEmpty()) fallback() else ret!!
// special treatment // special treatment
if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL")) if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL"))
return ret2.replace('>', AppLoader.gamepadLabelStart).capitalize() return ret2.replace('>', App.gamepadLabelStart).capitalize()
return if (key.getEndTag().contains("bg")) return if (key.getEndTag().contains("bg"))
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}" "${App.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${App.fontGame.charsetOverrideDefault}"
else if (key.getEndTag().contains("sr")) else if (key.getEndTag().contains("sr"))
"${AppLoader.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideDefault}" "${App.fontGame.charsetOverrideSerbian}${ret2.capitalize()}${App.fontGame.charsetOverrideDefault}"
else else
ret2.capitalize() ret2.capitalize()
} }
@@ -144,7 +144,7 @@ object Lang {
fun pluralise(word: String, count: Int): String { fun pluralise(word: String, count: Int): String {
if (count < 2) return word if (count < 2) return word
when (AppLoader.GAME_LOCALE) { when (App.GAME_LOCALE) {
"fr" -> { "fr" -> {
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) { if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
return word + "s" return word + "s"

View File

@@ -15,7 +15,6 @@ import net.torvald.terrarum.gameitem.ItemID
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
import net.torvald.terrarum.gameworld.WorldTime import net.torvald.terrarum.gameworld.WorldTime
import net.torvald.terrarum.modulebasegame.ui.Notification
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerBlockChooser import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerBlockChooser
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerPenMenu import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerPenMenu
import net.torvald.terrarum.modulebasegame.ui.UIPaletteSelector import net.torvald.terrarum.modulebasegame.ui.UIPaletteSelector
@@ -284,11 +283,11 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
uiToolbox.isVisible = true uiToolbox.isVisible = true
uiToolbox.invocationArgument = arrayOf(this) uiToolbox.invocationArgument = arrayOf(this)
uiPaletteSelector.setPosition(AppLoader.screenSize.screenW - uiPaletteSelector.width, 0) uiPaletteSelector.setPosition(App.scr.width - uiPaletteSelector.width, 0)
uiPaletteSelector.isVisible = true uiPaletteSelector.isVisible = true
notifier.setPosition( notifier.setPosition(
(AppLoader.screenSize.screenW - notifier.width) / 2, AppLoader.screenSize.screenH - notifier.height) (App.scr.width - notifier.width) / 2, App.scr.height - notifier.height)
actorNowPlaying?.setPosition(512 * 16.0, 149 * 16.0) actorNowPlaying?.setPosition(512 * 16.0, 149 * 16.0)
@@ -318,22 +317,22 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
var i = 0L var i = 0L
while (updateAkku >= updateRate) { while (updateAkku >= updateRate) {
AppLoader.measureDebugTime("Ingame.Update") { updateGame(updateRate) } App.measureDebugTime("Ingame.Update") { updateGame(updateRate) }
updateAkku -= updateRate updateAkku -= updateRate
i += 1 i += 1
} }
AppLoader.setDebugTime("Ingame.UpdateCounter", i) App.setDebugTime("Ingame.UpdateCounter", i)
// render? just do it anyway // render? just do it anyway
AppLoader.measureDebugTime("Ingame.Render") { renderGame() } App.measureDebugTime("Ingame.Render") { renderGame() }
AppLoader.setDebugTime("Ingame.Render - (Light + Tiling)", App.setDebugTime("Ingame.Render - (Light + Tiling)",
((AppLoader.debugTimers["Ingame.Render"] as? Long) ?: 0) - ((App.debugTimers["Ingame.Render"] as? Long) ?: 0) -
( (
((AppLoader.debugTimers["Renderer.Lanterns"] as? Long) ?: 0) + ((App.debugTimers["Renderer.Lanterns"] as? Long) ?: 0) +
((AppLoader.debugTimers["Renderer.LightPrecalc"] as? Long) ?: 0) + ((App.debugTimers["Renderer.LightPrecalc"] as? Long) ?: 0) +
((AppLoader.debugTimers["Renderer.LightRuns"] as? Long) ?: 0) + ((App.debugTimers["Renderer.LightRuns"] as? Long) ?: 0) +
((AppLoader.debugTimers["Renderer.LightToScreen"] as? Long) ?: 0) + ((App.debugTimers["Renderer.LightToScreen"] as? Long) ?: 0) +
((AppLoader.debugTimers["Renderer.Tiling"] as? Long) ?: 0) ((App.debugTimers["Renderer.Tiling"] as? Long) ?: 0)
) )
) )
@@ -364,19 +363,19 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
// make pen work HERE // make pen work HERE
// when LEFT mouse is down // when LEFT mouse is down
if (!tappedOnUI && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) && !mouseOnUI) { if (!tappedOnUI && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary")) && !mouseOnUI) {
makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY) makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY)
// TODO drag support using bresenham's algo // TODO drag support using bresenham's algo
// for some reason it just doesn't work... // for some reason it just doesn't work...
} }
else if (!uiPenMenu.isVisible && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary"))) { else if (!uiPenMenu.isVisible && Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) {
// open pen menu // open pen menu
// position the menu to where the cursor is // position the menu to where the cursor is
uiPenMenu.posX = Terrarum.mouseScreenX - uiPenMenu.width / 2 uiPenMenu.posX = Terrarum.mouseScreenX - uiPenMenu.width / 2
uiPenMenu.posY = Terrarum.mouseScreenY - uiPenMenu.height / 2 uiPenMenu.posY = Terrarum.mouseScreenY - uiPenMenu.height / 2
uiPenMenu.posX = uiPenMenu.posX.coerceIn(0, AppLoader.screenSize.screenW - uiPenMenu.width) uiPenMenu.posX = uiPenMenu.posX.coerceIn(0, App.scr.width - uiPenMenu.width)
uiPenMenu.posY = uiPenMenu.posY.coerceIn(0, AppLoader.screenSize.screenH - uiPenMenu.height) uiPenMenu.posY = uiPenMenu.posY.coerceIn(0, App.scr.height - uiPenMenu.height)
// actually open // actually open
uiPenMenu.setAsOpen() uiPenMenu.setAsOpen()
@@ -390,14 +389,14 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
IngameRenderer.invoke(false, actorsRenderOverlay = if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays, uiContainer = uiContainer) IngameRenderer.invoke(false, actorsRenderOverlay = if (showSelection) actorsRenderOverlay + essentialOverlays else essentialOverlays, uiContainer = uiContainer)
AppLoader.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls) App.setDebugTime("Test.MarkerDrawCalls", _testMarkerDrawCalls)
} }
override fun resize(width: Int, height: Int) { override fun resize(width: Int, height: Int) {
IngameRenderer.resize(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) IngameRenderer.resize(App.scr.width, App.scr.height)
uiToolbox.setPosition(0, 0) uiToolbox.setPosition(0, 0)
notifier.setPosition( notifier.setPosition(
(AppLoader.screenSize.screenW - notifier.width) / 2, AppLoader.screenSize.screenH - notifier.height) (App.scr.width - notifier.width) / 2, App.scr.height - notifier.height)
println("[BuildingMaker] Resize event") println("[BuildingMaker] Resize event")
} }
@@ -554,12 +553,12 @@ class MovableWorldCamera(val parent: BuildingMaker) : ActorHumanoid(0, physProp
// TODO resize-aware // TODO resize-aware
private var coerceInStart = Point2d( private var coerceInStart = Point2d(
(AppLoader.screenSize.screenW - hitbox.width) / 2.0, (App.scr.width - hitbox.width) / 2.0,
(AppLoader.screenSize.screenH - hitbox.height) / 2.0 (App.scr.height - hitbox.height) / 2.0
) )
private var coerceInEnd = Point2d( private var coerceInEnd = Point2d(
parent.world.width * TILE_SIZE - (AppLoader.screenSize.screenW - hitbox.width) / 2.0, parent.world.width * TILE_SIZE - (App.scr.width - hitbox.width) / 2.0,
parent.world.height * TILE_SIZE - (AppLoader.screenSize.screenH - hitbox.height) / 2.0 parent.world.height * TILE_SIZE - (App.scr.height - hitbox.height) / 2.0
) )
override fun update(delta: Float) { override fun update(delta: Float) {
@@ -582,7 +581,7 @@ class MovableWorldCamera(val parent: BuildingMaker) : ActorHumanoid(0, physProp
class YamlCommandExit : YamlInvokable { class YamlCommandExit : YamlInvokable {
override fun invoke(args: Array<Any>) { override fun invoke(args: Array<Any>) {
AppLoader.setScreen(TitleScreen(AppLoader.batch)) App.setScreen(TitleScreen(App.batch))
} }
} }

View File

@@ -1,8 +1,8 @@
package net.torvald.terrarum.modulebasegame package net.torvald.terrarum.modulebasegame
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD import net.torvald.terrarum.App.IS_DEVELOPMENT_BUILD
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.blockproperties.BlockProp import net.torvald.terrarum.blockproperties.BlockProp
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.modulebasegame.gameitems.BlockBase import net.torvald.terrarum.modulebasegame.gameitems.BlockBase

View File

@@ -9,7 +9,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShaderProgram import com.badlogic.gdx.graphics.glutils.ShaderProgram
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.measureDebugTime import net.torvald.terrarum.App.measureDebugTime
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZEF
import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameactors.ActorWithBody
@@ -58,8 +58,8 @@ object IngameRenderer : Disposable {
val shaderAtoGrey: ShaderProgram val shaderAtoGrey: ShaderProgram
val shaderPassthru = SpriteBatch.createDefaultShader() val shaderPassthru = SpriteBatch.createDefaultShader()
private val WIDTH = AppLoader.screenSize.screenW private val WIDTH = App.scr.width
private val HEIGHT = AppLoader.screenSize.screenH private val HEIGHT = App.scr.height
private val WIDTHF = WIDTH.toFloat() private val WIDTHF = WIDTH.toFloat()
private val HEIGHTF = HEIGHT.toFloat() private val HEIGHTF = HEIGHT.toFloat()
@@ -88,25 +88,25 @@ object IngameRenderer : Disposable {
// these codes will run regardless of the invocation of the "initialise()" function // these codes will run regardless of the invocation of the "initialise()" function
// the "initialise()" function will also be called // the "initialise()" function will also be called
init { init {
shaderBlur = AppLoader.loadShaderFromFile("assets/blur.vert", "assets/blur.frag") shaderBlur = App.loadShaderFromFile("assets/blur.vert", "assets/blur.frag")
if (AppLoader.getConfigBoolean("fxdither")) { if (App.getConfigBoolean("fxdither")) {
shaderBayer = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/4096_bayer.frag") shaderBayer = App.loadShaderFromFile("assets/4096.vert", "assets/4096_bayer.frag")
shaderBayer.bind() shaderBayer.bind()
shaderBayer.setUniformf("rcount", 64f) shaderBayer.setUniformf("rcount", 64f)
shaderBayer.setUniformf("gcount", 64f) shaderBayer.setUniformf("gcount", 64f)
shaderBayer.setUniformf("bcount", 64f) shaderBayer.setUniformf("bcount", 64f)
} }
else { else {
shaderBayer = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/passthrurgb.frag") shaderBayer = App.loadShaderFromFile("assets/4096.vert", "assets/passthrurgb.frag")
} }
shaderBlendGlow = AppLoader.loadShaderFromFile("assets/blendGlow.vert", "assets/blendGlow.frag") shaderBlendGlow = App.loadShaderFromFile("assets/blendGlow.vert", "assets/blendGlow.frag")
shaderRGBOnly = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/rgbonly.frag") shaderRGBOnly = App.loadShaderFromFile("assets/4096.vert", "assets/rgbonly.frag")
shaderAtoGrey = AppLoader.loadShaderFromFile("assets/4096.vert", "assets/aonly.frag") shaderAtoGrey = App.loadShaderFromFile("assets/4096.vert", "assets/aonly.frag")
if (!shaderBlendGlow.isCompiled) { if (!shaderBlendGlow.isCompiled) {
@@ -115,7 +115,7 @@ object IngameRenderer : Disposable {
} }
if (AppLoader.getConfigBoolean("fxdither")) { if (App.getConfigBoolean("fxdither")) {
if (!shaderBayer.isCompiled) { if (!shaderBayer.isCompiled) {
Gdx.app.log("shaderBayer", shaderBayer.log) Gdx.app.log("shaderBayer", shaderBayer.log)
exitProcess(1) exitProcess(1)
@@ -132,7 +132,7 @@ object IngameRenderer : Disposable {
* actually matter */ * actually matter */
@JvmStatic fun initialise() { @JvmStatic fun initialise() {
if (!initialisedExternally) { if (!initialisedExternally) {
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
// also initialise these sinigletons // also initialise these sinigletons
BlocksDrawer BlocksDrawer
@@ -206,7 +206,7 @@ object IngameRenderer : Disposable {
if (!gamePaused || newWorldLoadedLatch) { if (!gamePaused || newWorldLoadedLatch) {
measureDebugTime("Renderer.ApparentLightRun") { measureDebugTime("Renderer.ApparentLightRun") {
// recalculate for even frames, or if the sign of the cam-x changed // recalculate for even frames, or if the sign of the cam-x changed
if (AppLoader.GLOBAL_RENDER_TIMER % 3 == 0 || WorldCamera.x * oldCamX < 0 || newWorldLoadedLatch) if (App.GLOBAL_RENDER_TIMER % 3 == 0 || WorldCamera.x * oldCamX < 0 || newWorldLoadedLatch)
LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay) LightmapRenderer.fireRecalculateEvent(actorsRenderBehind, actorsRenderFront, actorsRenderMidTop, actorsRenderMiddle, actorsRenderOverlay)
oldCamX = WorldCamera.x oldCamX = WorldCamera.x
@@ -601,7 +601,7 @@ object IngameRenderer : Disposable {
* 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.
*/ */
private fun setCameraPosition(newX: Float, newY: Float) { private fun setCameraPosition(newX: Float, newY: Float) {
camera.position.set((-newX + AppLoader.screenSize.halfScreenW).round(), (-newY + AppLoader.screenSize.halfScreenH).round(), 0f) camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
} }

View File

@@ -6,12 +6,10 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.EMDASH import net.torvald.EMDASH
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.BlockPropUtil import net.torvald.terrarum.blockproperties.BlockPropUtil
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.blockstats.BlockStats import net.torvald.terrarum.blockstats.BlockStats
import net.torvald.terrarum.blockstats.MinimapComposer import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.concurrent.ThreadExecutor import net.torvald.terrarum.concurrent.ThreadExecutor
@@ -22,7 +20,6 @@ import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.WireActor import net.torvald.terrarum.gameactors.WireActor
import net.torvald.terrarum.gameactors.faction.FactionCodex
import net.torvald.terrarum.gamecontroller.IngameController import net.torvald.terrarum.gamecontroller.IngameController
import net.torvald.terrarum.gamecontroller.KeyToggler import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
@@ -30,7 +27,6 @@ import net.torvald.terrarum.gameparticles.ParticleBase
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.WorldSimulator import net.torvald.terrarum.gameworld.WorldSimulator
import net.torvald.terrarum.itemproperties.ItemCodex import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.itemproperties.MaterialCodex
import net.torvald.terrarum.modulebasegame.gameactors.* import net.torvald.terrarum.modulebasegame.gameactors.*
import net.torvald.terrarum.modulebasegame.gameactors.physicssolver.CollisionSolver import net.torvald.terrarum.modulebasegame.gameactors.physicssolver.CollisionSolver
import net.torvald.terrarum.modulebasegame.gameworld.GameEconomy import net.torvald.terrarum.modulebasegame.gameworld.GameEconomy
@@ -47,7 +43,6 @@ import net.torvald.terrarum.worlddrawer.BlocksDrawer
import net.torvald.terrarum.worlddrawer.FeaturesDrawer import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.util.CircularArray import net.torvald.util.CircularArray
import org.khelekore.prtree.MBRConverter
import org.khelekore.prtree.PRTree import org.khelekore.prtree.PRTree
import java.util.concurrent.locks.ReentrantLock import java.util.concurrent.locks.ReentrantLock
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -68,7 +63,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
* list of Actors that is sorted by Actors' referenceID * list of Actors that is sorted by Actors' referenceID
*/ */
//val ACTORCONTAINER_INITIAL_SIZE = 64 //val ACTORCONTAINER_INITIAL_SIZE = 64
val PARTICLES_MAX = AppLoader.getConfigInt("maxparticles") val PARTICLES_MAX = App.getConfigInt("maxparticles")
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true) val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX, true)
val uiContainer = UIContainer() val uiContainer = UIContainer()
@@ -86,14 +81,14 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
companion object { companion object {
/** Sets camera position so that (0,0) would be top-left of the screen, (width, height) be bottom-right. */ /** Sets camera position so that (0,0) would be top-left of the screen, (width, height) be bottom-right. */
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) { fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
camera.position.set((-newX + AppLoader.screenSize.halfScreenW).round(), (-newY + AppLoader.screenSize.halfScreenH).round(), 0f) camera.position.set((-newX + App.scr.halfw).round(), (-newY + App.scr.halfh).round(), 0f)
camera.update() camera.update()
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
} }
fun getCanonicalTitle() = AppLoader.GAME_NAME + fun getCanonicalTitle() = App.GAME_NAME +
" $EMDASH F: ${Gdx.graphics.framesPerSecond}" + " $EMDASH F: ${Gdx.graphics.framesPerSecond}" +
if (AppLoader.IS_DEVELOPMENT_BUILD) if (App.IS_DEVELOPMENT_BUILD)
" (ΔF${Terrarum.updateRateStr})" + " (ΔF${Terrarum.updateRateStr})" +
" $EMDASH M: J${Terrarum.memJavaHeap}M / N${Terrarum.memNativeHeap}M / U${Terrarum.memUnsafe}M / X${Terrarum.memXmx}M" " $EMDASH M: J${Terrarum.memJavaHeap}M / N${Terrarum.memNativeHeap}M / U${Terrarum.memUnsafe}M / X${Terrarum.memXmx}M"
else else
@@ -287,12 +282,12 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
printdbg(this, "loaded successfully.") printdbg(this, "loaded successfully.")
} }
else { else {
AppLoader.getLoadScreen().addMessage("${AppLoader.GAME_NAME} version ${AppLoader.getVERSION_STRING()}") App.getLoadScreen().addMessage("${App.GAME_NAME} version ${App.getVERSION_STRING()}")
AppLoader.getLoadScreen().addMessage("Creating new world") App.getLoadScreen().addMessage("Creating new world")
// init map as chosen size // init map as chosen size
val timeNow = AppLoader.getTIME_T() val timeNow = App.getTIME_T()
world = GameWorld(1, worldParams.width, worldParams.height, timeNow, timeNow, 0) // new game, so the creation time is right now world = GameWorld(1, worldParams.width, worldParams.height, timeNow, timeNow, 0) // new game, so the creation time is right now
gameworldIndices.add(world.worldIndex) gameworldIndices.add(world.worldIndex)
world.extraFields["basegame.economy"] = GameEconomy() world.extraFields["basegame.economy"] = GameEconomy()
@@ -322,7 +317,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
savegameArchive = VDUtil.createNewDisk( savegameArchive = VDUtil.createNewDisk(
1L shl 60, 1L shl 60,
actorNowPlaying!!.actorValue.getAsString(AVKey.NAME) ?: "Player ${AppLoader.getTIME_T()}", actorNowPlaying!!.actorValue.getAsString(AVKey.NAME) ?: "Player ${App.getTIME_T()}",
Common.CHARSET Common.CHARSET
) )
} }
@@ -335,8 +330,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// make controls work // make controls work
Gdx.input.inputProcessor = ingameController Gdx.input.inputProcessor = ingameController
if (AppLoader.gamepad != null) { if (App.gamepad != null) {
ingameController.gamepad = AppLoader.gamepad ingameController.gamepad = App.gamepad
} }
// init console window // init console window
@@ -355,11 +350,11 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// quick bar // quick bar
uiQuickBar = UIQuickslotBar() uiQuickBar = UIQuickslotBar()
uiQuickBar.isVisible = true uiQuickBar.isVisible = true
uiQuickBar.setPosition((AppLoader.screenSize.screenW - uiQuickBar.width) / 2, AppLoader.screenSize.tvSafeGraphicsHeight) uiQuickBar.setPosition((App.scr.width - uiQuickBar.width) / 2, App.scr.tvSafeGraphicsHeight)
// pie menu // pie menu
uiPieMenu = UIQuickslotPie() uiPieMenu = UIQuickslotPie()
uiPieMenu.setPosition(AppLoader.screenSize.halfScreenW, AppLoader.screenSize.halfScreenH) uiPieMenu.setPosition(App.scr.halfw, App.scr.halfh)
// vital metre // vital metre
// fill in getter functions by // fill in getter functions by
@@ -374,14 +369,14 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
uiWatchTierOne = UITierOneWatch() uiWatchTierOne = UITierOneWatch()
uiWatchTierOne.setAsAlwaysVisible() uiWatchTierOne.setAsAlwaysVisible()
uiWatchTierOne.setPosition( uiWatchTierOne.setPosition(
((AppLoader.screenSize.screenW - AppLoader.screenSize.tvSafeActionWidth) - (uiQuickBar.posX + uiQuickBar.width) - uiWatchTierOne.width) / 2 + (uiQuickBar.posX + uiQuickBar.width), ((App.scr.width - App.scr.tvSafeActionWidth) - (uiQuickBar.posX + uiQuickBar.width) - uiWatchTierOne.width) / 2 + (uiQuickBar.posX + uiQuickBar.width),
AppLoader.screenSize.tvSafeGraphicsHeight + 8 App.scr.tvSafeGraphicsHeight + 8
) )
// basic watch-style notification bar (temperature, new mail) // basic watch-style notification bar (temperature, new mail)
uiBasicInfo = UIBasicInfo() uiBasicInfo = UIBasicInfo()
uiBasicInfo.setAsAlwaysVisible() uiBasicInfo.setAsAlwaysVisible()
uiBasicInfo.setPosition((uiQuickBar.posX - uiBasicInfo.width - AppLoader.screenSize.tvSafeActionWidth) / 2 + AppLoader.screenSize.tvSafeActionWidth, uiWatchTierOne.posY) uiBasicInfo.setPosition((uiQuickBar.posX - uiBasicInfo.width - App.scr.tvSafeActionWidth) / 2 + App.scr.tvSafeActionWidth, uiWatchTierOne.posY)
@@ -418,7 +413,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// these need to appear on top of any others // these need to appear on top of any others
uiContainer.add(notifier) uiContainer.add(notifier)
AppLoader.setDebugTime("Ingame.UpdateCounter", 0) App.setDebugTime("Ingame.UpdateCounter", 0)
// some sketchy test code here // some sketchy test code here
@@ -435,7 +430,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// TODO actorsUnderMouse: support ROUNDWORLD // TODO actorsUnderMouse: support ROUNDWORLD
val actorsUnderMouse: List<FixtureBase> = getActorsAt(Terrarum.mouseX, Terrarum.mouseY).filterIsInstance<FixtureBase>() val actorsUnderMouse: List<FixtureBase> = getActorsAt(Terrarum.mouseX, Terrarum.mouseY).filterIsInstance<FixtureBase>()
if (actorsUnderMouse.size > 1) { if (actorsUnderMouse.size > 1) {
AppLoader.printdbgerr(this, "Multiple fixtures at world coord ${Terrarum.mouseX}, ${Terrarum.mouseY}") App.printdbgerr(this, "Multiple fixtures at world coord ${Terrarum.mouseX}, ${Terrarum.mouseY}")
} }
// scan for the one with non-null UI. // scan for the one with non-null UI.
// what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation. // what if there's multiple of such fixtures? whatever, you are supposed to DISALLOW such situation.
@@ -521,7 +516,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// define custom update rate // define custom update rate
val updateRate = if (KeyToggler.isOn(Input.Keys.APOSTROPHE)) 1f / 8f else AppLoader.UPDATE_RATE val updateRate = if (KeyToggler.isOn(Input.Keys.APOSTROPHE)) 1f / 8f else App.UPDATE_RATE
// ASYNCHRONOUS UPDATE AND RENDER // // ASYNCHRONOUS UPDATE AND RENDER //
@@ -822,11 +817,11 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
val actors = actorContainerActive.size.toFloat() val actors = actorContainerActive.size.toFloat()
// set up indices // set up indices
for (i in 0..AppLoader.THREAD_COUNT - 1) { for (i in 0..App.THREAD_COUNT - 1) {
ThreadExecutor.submit( ThreadExecutor.submit(
ThreadActorUpdate( ThreadActorUpdate(
actors.div(AppLoader.THREAD_COUNT).times(i).roundToInt(), actors.div(App.THREAD_COUNT).times(i).roundToInt(),
actors.div(AppLoader.THREAD_COUNT).times(i + 1).roundToInt() - 1 actors.div(App.THREAD_COUNT).times(i + 1).roundToInt() - 1
) )
) )
} }
@@ -963,7 +958,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
override fun addNewActor(actor: Actor?) { override fun addNewActor(actor: Actor?) {
if (actor == null) return if (actor == null) return
if (AppLoader.IS_DEVELOPMENT_BUILD && theGameHasActor(actor.referenceID)) { if (App.IS_DEVELOPMENT_BUILD && theGameHasActor(actor.referenceID)) {
throw ReferencedActorAlreadyExistsException(actor) throw ReferencedActorAlreadyExistsException(actor)
} }
else { else {
@@ -978,7 +973,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
} }
fun activateDormantActor(actor: Actor) { fun activateDormantActor(actor: Actor) {
if (AppLoader.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID)) { if (App.IS_DEVELOPMENT_BUILD && !isInactive(actor.referenceID)) {
/*if (isActive(actor.referenceID)) /*if (isActive(actor.referenceID))
throw Error("The actor $actor is already activated") throw Error("The actor $actor is already activated")
else else
@@ -1033,7 +1028,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
//MegaRainGovernor.resize() //MegaRainGovernor.resize()
IngameRenderer.resize(AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) IngameRenderer.resize(App.scr.width, App.scr.height)
if (gameInitialised) { if (gameInitialised) {
@@ -1045,8 +1040,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// resize UIs // resize UIs
notifier.setPosition( notifier.setPosition(
(AppLoader.screenSize.screenW - notifier.width) / 2, AppLoader.screenSize.screenH - notifier.height) (App.scr.width - notifier.width) / 2, App.scr.height - notifier.height)
uiQuickBar.setPosition((AppLoader.screenSize.screenW - uiQuickBar.width) / 2, AppLoader.screenSize.tvSafeGraphicsHeight) uiQuickBar.setPosition((App.scr.width - uiQuickBar.width) / 2, App.scr.tvSafeGraphicsHeight)
// inventory // inventory
/*uiInventoryPlayer = /*uiInventoryPlayer =
@@ -1058,10 +1053,10 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// basic watch-style notification bar (temperature, new mail) // basic watch-style notification bar (temperature, new mail)
uiBasicInfo.setPosition(AppLoader.screenSize.screenW - uiBasicInfo.width, 0) uiBasicInfo.setPosition(App.scr.width - uiBasicInfo.width, 0)
uiWatchTierOne.setPosition( uiWatchTierOne.setPosition(
((AppLoader.screenSize.screenW - AppLoader.screenSize.tvSafeGraphicsWidth) - (uiQuickBar.posX + uiQuickBar.width) - uiWatchTierOne.width) / 2 + (uiQuickBar.posX + uiQuickBar.width), ((App.scr.width - App.scr.tvSafeGraphicsWidth) - (uiQuickBar.posX + uiQuickBar.width) - uiWatchTierOne.width) / 2 + (uiQuickBar.posX + uiQuickBar.width),
AppLoader.screenSize.tvSafeGraphicsHeight + 8 App.scr.tvSafeGraphicsHeight + 8
) )
} }

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -18,7 +17,7 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
// a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway // a Class impl is chosen to make resize-handling easier, there's not much benefit making this a singleton anyway
init { init {
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
} }
override var screenToLoad: IngameInstance? = screenToBeLoaded override var screenToLoad: IngameInstance? = screenToBeLoaded
@@ -27,15 +26,15 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
companion object { companion object {
private const val WIDTH_RATIO = 0.7 private const val WIDTH_RATIO = 0.7
private const val PREVIEW_UPDATE_RATE = AppLoader.UPDATE_RATE private const val PREVIEW_UPDATE_RATE = App.UPDATE_RATE
private val COL_TERR = Color.WHITE private val COL_TERR = Color.WHITE
private val COL_WALLED = Color(.5f, .5f, .5f, 1f) private val COL_WALLED = Color(.5f, .5f, .5f, 1f)
private val COL_AIR = Color.BLACK private val COL_AIR = Color.BLACK
} }
private val previewWidth = (AppLoader.screenSize.screenW * WIDTH_RATIO).roundToInt() private val previewWidth = (App.scr.width * WIDTH_RATIO).roundToInt()
private val previewHeight = (AppLoader.screenSize.screenW * WIDTH_RATIO * worldheight / worldwidth).roundToInt() private val previewHeight = (App.scr.width * WIDTH_RATIO * worldheight / worldwidth).roundToInt()
private lateinit var previewPixmap: Pixmap private lateinit var previewPixmap: Pixmap
private lateinit var previewTexture: Texture private lateinit var previewTexture: Texture
@@ -66,18 +65,18 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
} }
AppLoader.batch.inUse { App.batch.inUse {
it.color = Color.WHITE it.color = Color.WHITE
val previewY = (AppLoader.screenSize.screenH - previewHeight.times(1.5f)).div(2f).round() val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
it.draw(previewTexture, it.draw(previewTexture,
(AppLoader.screenSize.screenW - previewWidth).div(2f).round(), (App.scr.width - previewWidth).div(2f).round(),
previewY previewY
) )
val text = messages.getHeadElem() ?: "" val text = messages.getHeadElem() ?: ""
AppLoader.fontGame.draw(it, App.fontGame.draw(it,
text, text,
(AppLoader.screenSize.screenW - AppLoader.fontGame.getWidth(text)).div(2f).round(), (App.scr.width - App.fontGame.getWidth(text)).div(2f).round(),
previewY + previewHeight + 98 - AppLoader.fontGame.lineHeight previewY + previewHeight + 98 - App.fontGame.lineHeight
) )
} }

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.utils.JsonWriter import net.torvald.terrarum.utils.JsonWriter
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
@@ -21,7 +21,7 @@ internal object ExportAV : ConsoleCommand {
JsonWriter.writeToFile( JsonWriter.writeToFile(
player, player,
AppLoader.defaultDir + "/Exports/" + args[1] + ".json") App.defaultDir + "/Exports/" + args[1] + ".json")
Echo("ExportAV: exported to " + args[1] + ".json") Echo("ExportAV: exported to " + args[1] + ".json")
} }

View File

@@ -1,13 +1,12 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.console.EchoError import net.torvald.terrarum.console.EchoError
import net.torvald.terrarum.utils.RasterWriter import net.torvald.terrarum.utils.RasterWriter
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarum.worlddrawer.toRGBA import net.torvald.terrarum.worlddrawer.toRGBA
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
@@ -33,7 +32,7 @@ internal object ExportMap : ConsoleCommand {
var mapDataPointer = 0 var mapDataPointer = 0
for (tile in world.terrainIterator()) { for (tile in world.terrainIterator()) {
val colArray = AppLoader.tileMaker.terrainTileColourMap.get(tile)!!.toByteArray() val colArray = App.tileMaker.terrainTileColourMap.get(tile)!!.toByteArray()
for (i in 0..2) { for (i in 0..2) {
mapData[mapDataPointer + i] = colArray[i] mapData[mapDataPointer + i] = colArray[i]
@@ -42,7 +41,7 @@ internal object ExportMap : ConsoleCommand {
mapDataPointer += 3 mapDataPointer += 3
} }
val dir = AppLoader.defaultDir + "/Exports/" val dir = App.defaultDir + "/Exports/"
val dirAsFile = File(dir) val dirAsFile = File(dir)
if (!dirAsFile.exists()) { if (!dirAsFile.exists()) {
dirAsFile.mkdir() dirAsFile.mkdir()

View File

@@ -1,7 +1,6 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import com.badlogic.gdx.utils.Json import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.Terrarum.ingame import net.torvald.terrarum.Terrarum.ingame
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
@@ -11,7 +10,6 @@ import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
import net.torvald.terrarum.serialise.WriteActor import net.torvald.terrarum.serialise.WriteActor
import net.torvald.terrarum.serialise.WriteMeta import net.torvald.terrarum.serialise.WriteMeta
import net.torvald.terrarum.serialise.WriteWorld import net.torvald.terrarum.serialise.WriteWorld
import net.torvald.terrarum.utils.JsonWriter
import java.io.IOException import java.io.IOException
/** /**
@@ -20,9 +18,9 @@ import java.io.IOException
object ExportMeta : ConsoleCommand { object ExportMeta : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
try { try {
val currentPlayTime_t = AppLoader.getTIME_T() - ingame!!.loadedTime_t val currentPlayTime_t = App.getTIME_T() - ingame!!.loadedTime_t
val str = WriteMeta(ingame!! as TerrarumIngame, currentPlayTime_t) val str = WriteMeta(ingame!! as TerrarumIngame, currentPlayTime_t)
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/savegame.json", false) val writer = java.io.FileWriter(App.defaultDir + "/Exports/savegame.json", false)
writer.write(str) writer.write(str)
writer.close() writer.close()
Echo("Exportmeta: exported to savegame.json") Echo("Exportmeta: exported to savegame.json")
@@ -43,7 +41,7 @@ object ExportWorld : ConsoleCommand {
if (args.size == 2) { if (args.size == 2) {
try { try {
val str = WriteWorld(ingame!! as TerrarumIngame) val str = WriteWorld(ingame!! as TerrarumIngame)
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/${args[1]}.json", false) val writer = java.io.FileWriter(App.defaultDir + "/Exports/${args[1]}.json", false)
writer.write(str) writer.write(str)
writer.close() writer.close()
Echo("Exportworld: exported to ${args[1]}.json") Echo("Exportworld: exported to ${args[1]}.json")
@@ -71,7 +69,7 @@ object ExportActor : ConsoleCommand {
if (player == null) return if (player == null) return
val str = WriteActor(player as IngamePlayer) val str = WriteActor(player as IngamePlayer)
val writer = java.io.FileWriter(AppLoader.defaultDir + "/Exports/${args[1]}.json", false) val writer = java.io.FileWriter(App.defaultDir + "/Exports/${args[1]}.json", false)
writer.write(str) writer.write(str)
writer.close() writer.close()

View File

@@ -1,15 +1,5 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.utils.JsonWriter
import java.io.BufferedWriter
import java.io.FileWriter
import java.io.IOException
/** /**
* Created by minjaesong on 2016-02-10. * Created by minjaesong on 2016-02-10.
*/ */

View File

@@ -1,13 +1,12 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.serialise.ReadActor import net.torvald.terrarum.serialise.ReadActor
import net.torvald.terrarum.serialise.ReadWorld import net.torvald.terrarum.serialise.ReadWorld
import net.torvald.terrarum.serialise.WriteMeta
import java.io.IOException import java.io.IOException
/** /**
@@ -17,7 +16,7 @@ object ImportWorld : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
try { try {
val reader = java.io.FileReader(AppLoader.defaultDir + "/Exports/${args[1]}.json") val reader = java.io.FileReader(App.defaultDir + "/Exports/${args[1]}.json")
ReadWorld.readWorldAndSetNewWorld(Terrarum.ingame!! as TerrarumIngame, reader) ReadWorld.readWorldAndSetNewWorld(Terrarum.ingame!! as TerrarumIngame, reader)
Echo("Importworld: imported a world from ${args[1]}.json") Echo("Importworld: imported a world from ${args[1]}.json")
} }
@@ -40,7 +39,7 @@ object ImportActor : ConsoleCommand {
override fun execute(args: Array<String>) { override fun execute(args: Array<String>) {
if (args.size == 2) { if (args.size == 2) {
try { try {
val reader = java.io.FileReader(AppLoader.defaultDir + "/Exports/${args[1]}.json") val reader = java.io.FileReader(App.defaultDir + "/Exports/${args[1]}.json")
ReadActor.readActorAndAddToWorld(Terrarum.ingame!! as TerrarumIngame, reader) ReadActor.readActorAndAddToWorld(Terrarum.ingame!! as TerrarumIngame, reader)
Echo("Importactor: imported an actor from ${args[1]}.json") Echo("Importactor: imported an actor from ${args[1]}.json")
} }

View File

@@ -1,20 +1,16 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.ELLIPSIS import net.torvald.ELLIPSIS
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.ccC import net.torvald.terrarum.ccC
import net.torvald.terrarum.ccG import net.torvald.terrarum.ccG
import net.torvald.terrarum.ccR import net.torvald.terrarum.ccR
import net.torvald.terrarum.console.ConsoleCommand import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64Reader
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.EntryFile
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.VDUtil import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.VDUtil
import net.torvald.terrarum.serialise.* import net.torvald.terrarum.serialise.*
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.io.StringReader
import kotlin.reflect.full.declaredMemberProperties
/** /**
* Created by minjaesong on 2021-08-30. * Created by minjaesong on 2021-08-30.
@@ -27,7 +23,7 @@ object Load : ConsoleCommand {
Echo("${ccC}Changing context, ${ccR}do not touch the controller$ccC and ${ccG}wait$ccC$ELLIPSIS") Echo("${ccC}Changing context, ${ccR}do not touch the controller$ccC and ${ccG}wait$ccC$ELLIPSIS")
val charset = Common.CHARSET val charset = Common.CHARSET
val file = File(AppLoader.defaultDir + "/Exports/${args[1]}") val file = File(App.defaultDir + "/Exports/${args[1]}")
val disk = VDUtil.readDiskArchive(file, charset = charset) val disk = VDUtil.readDiskArchive(file, charset = charset)
LoadSavegame(disk) LoadSavegame(disk)

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.modulebasegame.console package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.ReferencingRanges import net.torvald.terrarum.ReferencingRanges
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
@@ -40,7 +40,7 @@ object Save : ConsoleCommand {
val ingame = Terrarum.ingame!! as TerrarumIngame val ingame = Terrarum.ingame!! as TerrarumIngame
val savename = args[1].trim() val savename = args[1].trim()
val disk = VDUtil.createNewDisk(1L shl 60, savename, Common.CHARSET) val disk = VDUtil.createNewDisk(1L shl 60, savename, Common.CHARSET)
val file = File(AppLoader.defaultDir + "/Exports/${args[1]}") val file = File(App.defaultDir + "/Exports/${args[1]}")
WriteSavegame(disk, file, ingame) WriteSavegame(disk, file, ingame)

View File

@@ -5,11 +5,10 @@ import com.jme3.math.FastMath
import net.torvald.gdx.graphics.Cvec import net.torvald.gdx.graphics.Cvec
import net.torvald.spriteanimation.HasAssembledSprite import net.torvald.spriteanimation.HasAssembledSprite
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.gameactors.* import net.torvald.terrarum.gameactors.*
import net.torvald.terrarum.gameactors.faction.Faction import net.torvald.terrarum.gameactors.faction.Faction
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.itemproperties.Material import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.realestate.LandUtil import net.torvald.terrarum.realestate.LandUtil
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
@@ -224,22 +223,22 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
private fun updateGamerControlBox() { private fun updateGamerControlBox() {
if (isGamer) { if (isGamer) {
isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyup")) isUpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyup"))
isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyleft")) isLeftDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyleft"))
isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keydown")) isDownDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keydown"))
isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyright")) isRightDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyright"))
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) isJumpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyjump"))
val gamepad = AppLoader.gamepad val gamepad = App.gamepad
if (gamepad != null) { if (gamepad != null) {
axisX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")) axisX = gamepad.getAxis(App.getConfigInt("config_gamepadaxislx"))
axisY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")) axisY = gamepad.getAxis(App.getConfigInt("config_gamepadaxisly"))
axisRX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisrx")) axisRX = gamepad.getAxis(App.getConfigInt("config_gamepadaxisrx"))
axisRY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisry")) axisRY = gamepad.getAxis(App.getConfigInt("config_gamepadaxisry"))
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) || isJumpDown = Gdx.input.isKeyPressed(App.getConfigInt("config_keyjump")) ||
gamepad.getButton(AppLoader.getConfigInt("config_gamepadltrigger")) gamepad.getButton(App.getConfigInt("config_gamepadltrigger"))
} }
if (isJumpJustDown && jumpJustPressedLatched) { if (isJumpJustDown && jumpJustPressedLatched) {
@@ -263,7 +262,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
} }
private inline val hasController: Boolean private inline val hasController: Boolean
get() = if (isGamer) AppLoader.gamepad != null get() = if (isGamer) App.gamepad != null
else true else true
private var playerJumpKeyHeldDown = false private var playerJumpKeyHeldDown = false
@@ -308,11 +307,11 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
// ↑F, ↓S // ↑F, ↓S
if (isRightDown && !isLeftDown) { if (isRightDown && !isLeftDown) {
walkHorizontal(false, AXIS_KEYBOARD) walkHorizontal(false, AXIS_KEYBOARD)
prevHMoveKey = AppLoader.getConfigInt("config_keyright") prevHMoveKey = App.getConfigInt("config_keyright")
} // ↓F, ↑S } // ↓F, ↑S
else if (isLeftDown && !isRightDown) { else if (isLeftDown && !isRightDown) {
walkHorizontal(true, AXIS_KEYBOARD) walkHorizontal(true, AXIS_KEYBOARD)
prevHMoveKey = AppLoader.getConfigInt("config_keyleft") prevHMoveKey = App.getConfigInt("config_keyleft")
} // ↓F, ↓S } // ↓F, ↓S
/*else if (isLeftDown && isRightDown) { /*else if (isLeftDown && isRightDown) {
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) { if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
@@ -336,11 +335,11 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
// ↑E, ↓D // ↑E, ↓D
if (isDownDown && !isUpDown) { if (isDownDown && !isUpDown) {
walkVertical(false, AXIS_KEYBOARD) walkVertical(false, AXIS_KEYBOARD)
prevVMoveKey = AppLoader.getConfigInt("config_keydown") prevVMoveKey = App.getConfigInt("config_keydown")
} // ↓E, ↑D } // ↓E, ↑D
else if (isUpDown && !isDownDown) { else if (isUpDown && !isDownDown) {
walkVertical(true, AXIS_KEYBOARD) walkVertical(true, AXIS_KEYBOARD)
prevVMoveKey = AppLoader.getConfigInt("config_keyup") prevVMoveKey = App.getConfigInt("config_keyup")
} // ↓E, ↓D } // ↓E, ↓D
/*else if (isUpDown && isDownDown) { /*else if (isUpDown && isDownDown) {
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) { if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.ItemCodex import net.torvald.terrarum.ItemCodex
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
@@ -96,7 +96,7 @@ class ActorInventory() : FixtureInventory() {
actor.avStrength / 1000.0 actor.avStrength / 1000.0
else else
1.0 // TODO variable: scale, strength 1.0 // TODO variable: scale, strength
val swingDmgToFrameDmg = AppLoader.UPDATE_RATE.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!! val swingDmgToFrameDmg = App.UPDATE_RATE.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
// damage the item // damage the item
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat() newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()

View File

@@ -1,18 +1,16 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.IngameInstance import net.torvald.terrarum.IngameInstance
import net.torvald.terrarum.Point2i import net.torvald.terrarum.Point2i
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.gameactors.ActorID import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.gameactors.ActorWithBody import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.gameactors.PhysProperties import net.torvald.terrarum.gameactors.PhysProperties
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -57,7 +55,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
this.inventory = inventory this.inventory = inventory
if (mainUI != null) if (mainUI != null)
AppLoader.disposableSingletonsPool.add(mainUI) App.disposableSingletonsPool.add(mainUI)
} }
/** /**

View File

@@ -57,15 +57,15 @@ internal class FixtureStorageChest : FixtureBase {
internal class UIStorageChest : UICanvas( internal class UIStorageChest : UICanvas(
toggleKeyLiteral = AppLoader.getConfigInt("config_keyinventory"), toggleKeyLiteral = App.getConfigInt("config_keyinventory"),
toggleButtonLiteral = AppLoader.getConfigInt("config_gamepadstart"), toggleButtonLiteral = App.getConfigInt("config_gamepadstart"),
), HasInventory { ), HasInventory {
lateinit var chestInventory: FixtureInventory lateinit var chestInventory: FixtureInventory
lateinit var chestNameFun: () -> String lateinit var chestNameFun: () -> String
override var width = AppLoader.screenSize.screenW override var width = App.scr.width
override var height = AppLoader.screenSize.screenH override var height = App.scr.height
override var openCloseTime: Second = 0.0f override var openCloseTime: Second = 0.0f
private val shapeRenderer = ShapeRenderer() private val shapeRenderer = ShapeRenderer()
@@ -127,8 +127,8 @@ internal class UIStorageChest : UICanvas(
catBar = UIItemInventoryCatBar( catBar = UIItemInventoryCatBar(
this, this,
(AppLoader.screenSize.screenW - catBarWidth) / 2, (App.scr.width - catBarWidth) / 2,
42 + (AppLoader.screenSize.screenH - internalHeight) / 2, 42 + (App.scr.height - internalHeight) / 2,
internalWidth, internalWidth,
catBarWidth, catBarWidth,
false false
@@ -195,17 +195,17 @@ internal class UIStorageChest : UICanvas(
gdxSetBlendNormal() gdxSetBlendNormal()
val gradTopStart = (AppLoader.screenSize.screenH - internalHeight).div(2).toFloat() val gradTopStart = (App.scr.height - internalHeight).div(2).toFloat()
val gradBottomEnd = AppLoader.screenSize.screenH - gradTopStart val gradBottomEnd = App.scr.height - gradTopStart
shapeRenderer.inUse { shapeRenderer.inUse {
shapeRenderer.rect(0f, gradTopStart, AppLoader.screenSize.screenWf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradBottomEnd, AppLoader.screenSize.screenWf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradTopStart + gradHeight, AppLoader.screenSize.screenWf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, 0f, AppLoader.screenSize.screenWf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol) shapeRenderer.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
shapeRenderer.rect(0f, AppLoader.screenSize.screenHf, AppLoader.screenSize.screenWf, -(AppLoader.screenSize.screenHf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol) shapeRenderer.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
} }
@@ -225,7 +225,7 @@ internal class UIStorageChest : UICanvas(
// encumbrance meter // encumbrance meter
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"] val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth val encumbBarXPos = itemListPlayer.posX + itemListPlayer.width - weightBarWidth
val encumbBarTextXPos = encumbBarXPos - 6 - AppLoader.fontGame.getWidth(encumbranceText) val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
val encumbBarYPos = UIInventoryCells.encumbBarYPos val encumbBarYPos = UIInventoryCells.encumbBarYPos
val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f) val encumbCol = UIItemInventoryCellCommonRes.getHealthMeterColour(1f - encumbrancePerc, 0f, 1f)
val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening val encumbBack = encumbCol mul UIItemInventoryCellCommonRes.meterBackDarkening
@@ -250,10 +250,10 @@ internal class UIStorageChest : UICanvas(
// chest name text // chest name text
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, chestName, itemListChest.posX + 6f, encumbBarYPos - 3f) App.fontGame.draw(batch, chestName, itemListChest.posX + 6f, encumbBarYPos - 3f)
// encumb text // encumb text
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f) App.fontGame.draw(batch, encumbranceText, encumbBarTextXPos, encumbBarYPos - 3f)
} }
override fun doOpening(delta: Float) { override fun doOpening(delta: Float) {

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.utils.JsonFetcher import net.torvald.terrarum.utils.JsonFetcher
import net.torvald.random.Fudge3 import net.torvald.random.Fudge3
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.ActorValue import net.torvald.terrarum.gameactors.ActorValue

View File

@@ -1,12 +1,9 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.WireCodex
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameactors.faction.FactionFactory import net.torvald.terrarum.gameactors.faction.FactionFactory
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -79,7 +76,7 @@ object PlayerBuilderSigrid {
fun fillTestInventory(inventory: ActorInventory) { fun fillTestInventory(inventory: ActorInventory) {
AppLoader.tileMaker.tags.forEach { t, _ -> App.tileMaker.tags.forEach { t, _ ->
inventory.add(t, 9995) inventory.add(t, 9995)
try { try {
inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs inventory.add("wall@"+t, 9995) // this code will try to add nonexisting wall items, do not get surprised with NPEs

View File

@@ -1,9 +1,8 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.gameactors.ActorValue import net.torvald.terrarum.gameactors.ActorValue
import net.torvald.terrarum.gameitem.GameItem import net.torvald.terrarum.gameitem.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -36,7 +35,7 @@ interface Pocketed {
// Relevant Actorvalue is NOT being updated on time // Relevant Actorvalue is NOT being updated on time
// They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove // They're being safely handled by UIItemInventoryElem*.touchDown() and ActorInventory.remove
item.effectOnUnequip(AppLoader.UPDATE_RATE) item.effectOnUnequip(App.UPDATE_RATE)
} }
fun unequipItem(itemID: ItemID?) { fun unequipItem(itemID: ItemID?) {
@@ -67,7 +66,7 @@ interface Pocketed {
if (item.equipPosition >= 0) { if (item.equipPosition >= 0) {
inventory.itemEquipped[item.equipPosition] = item.dynamicID inventory.itemEquipped[item.equipPosition] = item.dynamicID
item.effectWhenEquipped(AppLoader.UPDATE_RATE) item.effectWhenEquipped(App.UPDATE_RATE)
} }
// else do nothing // else do nothing
} }

View File

@@ -1,8 +1,7 @@
package net.torvald.terrarum.modulebasegame.gameactors package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.itemproperties.ItemCodex
import java.util.concurrent.Callable import java.util.concurrent.Callable
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -13,13 +12,13 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Callable<Unit>
override fun call() { override fun call() {
for (i in startIndex..endIndex) { for (i in startIndex..endIndex) {
val it = Terrarum.ingame!!.actorContainerActive[i] val it = Terrarum.ingame!!.actorContainerActive[i]
it.update(AppLoader.UPDATE_RATE) it.update(App.UPDATE_RATE)
if (it is Pocketed) { if (it is Pocketed) {
it.inventory.forEach { inventoryEntry -> it.inventory.forEach { inventoryEntry ->
ItemCodex[inventoryEntry.itm]?.effectWhileInPocket(AppLoader.UPDATE_RATE) ItemCodex[inventoryEntry.itm]?.effectWhileInPocket(App.UPDATE_RATE)
if (it.equipped(inventoryEntry.itm)) { if (it.equipped(inventoryEntry.itm)) {
ItemCodex[inventoryEntry.itm]?.effectWhenEquipped(AppLoader.UPDATE_RATE) ItemCodex[inventoryEntry.itm]?.effectWhenEquipped(App.UPDATE_RATE)
} }
} }
} }

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/** /**
@@ -13,7 +13,7 @@ object FloatDrawer : Disposable {
val tile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36) val tile = TextureRegionPack("assets/graphics/gui/message_black_tileable.tga", 36, 36)
init { init {
AppLoader.disposableSingletonsPool.add(this) App.disposableSingletonsPool.add(this)
} }
/** /**

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -26,7 +26,7 @@ class Notification : UICanvas() {
override var height: Int = 0 override var height: Int = 0
private val visibleTime = Math.min( private val visibleTime = Math.min(
AppLoader.getConfigInt("notificationshowuptime"), App.getConfigInt("notificationshowuptime"),
SHOWUP_MAX SHOWUP_MAX
) / 1000f ) / 1000f
private var displayTimer = 0f private var displayTimer = 0f
@@ -55,15 +55,15 @@ class Notification : UICanvas() {
fontCol.a = handler.opacity fontCol.a = handler.opacity
val realTextWidth = 12 + if (message.size == 1) val realTextWidth = 12 + if (message.size == 1)
AppLoader.fontGame.getWidth(message[0]) App.fontGame.getWidth(message[0])
else else
message.map { AppLoader.fontGame.getWidth(it) }.sorted().last() message.map { App.fontGame.getWidth(it) }.sorted().last()
val displayedTextWidth = maxOf(240, realTextWidth) val displayedTextWidth = maxOf(240, realTextWidth)
// force the UI to the centre of the screen // force the UI to the centre of the screen
this.posX = (AppLoader.screenSize.screenW - displayedTextWidth) / 2 this.posX = (App.scr.width - displayedTextWidth) / 2
val textHeight = message.size * AppLoader.fontGame.lineHeight val textHeight = message.size * App.fontGame.lineHeight
batch.color = drawColor batch.color = drawColor
@@ -72,8 +72,8 @@ class Notification : UICanvas() {
batch.color = fontCol batch.color = fontCol
message.forEachIndexed { index, s -> message.forEachIndexed { index, s ->
val xoff = 6 + (displayedTextWidth - realTextWidth) / 2 val xoff = 6 + (displayedTextWidth - realTextWidth) / 2
val y = -textHeight + AppLoader.fontGame.lineHeight * index val y = -textHeight + App.fontGame.lineHeight * index
AppLoader.fontGame.draw(batch, s, LRmargin + xoff, y) App.fontGame.draw(batch, s, LRmargin + xoff, y)
} }

View File

@@ -42,7 +42,7 @@ class UIBasicInfo() : UICanvas() {
ELuptimer += delta ELuptimer += delta
} }
if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) { if (mouseUp || Gdx.input.isKeyPressed(App.getConfigInt("config_keyinteract"))) {
ELuptimer = 0f ELuptimer = 0f
ELon = true ELon = true
} }

View File

@@ -4,18 +4,15 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.fillRect import net.torvald.terrarum.fillRect
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.BuildingMaker import net.torvald.terrarum.modulebasegame.BuildingMaker
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_WHITE import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_WHITE
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemImageButton import net.torvald.terrarum.ui.UIItemImageButton
import net.torvald.terrarum.ui.UIItemTextButtonList import net.torvald.terrarum.ui.UIItemTextButtonList
import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_BACKGROUNDCOL import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_BACKGROUNDCOL
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import kotlin.math.roundToInt import kotlin.math.roundToInt
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -89,7 +86,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
} }
// respond to click // respond to click
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
// scroll bar // scroll bar
if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) { if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) {
mouseOnScroll = true mouseOnScroll = true

View File

@@ -7,7 +7,6 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.BuildingMaker import net.torvald.terrarum.modulebasegame.BuildingMaker
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemImageButton import net.torvald.terrarum.ui.UIItemImageButton
@@ -71,8 +70,8 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
{ {
parent.uiPalette.isVisible = true parent.uiPalette.isVisible = true
parent.uiPalette.setPosition(Gdx.input.x - parent.uiPalette.width / 2, Gdx.input.y - parent.uiPalette.height / 2) parent.uiPalette.setPosition(Gdx.input.x - parent.uiPalette.width / 2, Gdx.input.y - parent.uiPalette.height / 2)
parent.uiPalette.posX = parent.uiPalette.posX.coerceIn(0, AppLoader.screenSize.screenW - parent.uiPalette.width) parent.uiPalette.posX = parent.uiPalette.posX.coerceIn(0, App.scr.width - parent.uiPalette.width)
parent.uiPalette.posY = parent.uiPalette.posY.coerceIn(0, AppLoader.screenSize.screenH - parent.uiPalette.height) parent.uiPalette.posY = parent.uiPalette.posY.coerceIn(0, App.scr.height - parent.uiPalette.height)
}, },
{ {
parent.currentPenMode = BuildingMaker.PENMODE_PENCIL_ERASE parent.currentPenMode = BuildingMaker.PENMODE_PENCIL_ERASE
@@ -100,7 +99,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
uiItems.add(button) uiItems.add(button)
button.clickOnceListener = { _, _, b -> button.clickOnceListener = { _, _, b ->
if (b == AppLoader.getConfigInt("config_mouseprimary")) { if (b == App.getConfigInt("config_mouseprimary")) {
toolButtonsJob[index].invoke() toolButtonsJob[index].invoke()
closeGracefully() closeGracefully()
} }
@@ -134,7 +133,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
} }
// primary click // primary click
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
// close by clicking close button or out-of-boud // close by clicking close button or out-of-boud
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) { if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) {
closeGracefully() closeGracefully()
@@ -176,7 +175,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f) batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f)
// update as well while looping // update as well while looping
if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
parent.setPencilColour(slotConfig[i]) parent.setPencilColour(slotConfig[i])
closeGracefully() closeGracefully()
} }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.fillRect import net.torvald.terrarum.fillRect
@@ -16,11 +16,11 @@ import net.torvald.terrarum.ui.UICanvas
class UICheatDetected : UICanvas() { class UICheatDetected : UICanvas() {
override var width: Int override var width: Int
get() = AppLoader.screenSize.screenW get() = App.scr.width
set(value) { throw UnsupportedOperationException() } set(value) { throw UnsupportedOperationException() }
override var height: Int override var height: Int
get() = AppLoader.screenSize.screenH get() = App.scr.height
set(value) { throw UnsupportedOperationException() } set(value) { throw UnsupportedOperationException() }
override var openCloseTime: Second = 0f override var openCloseTime: Second = 0f
@@ -38,10 +38,10 @@ class UICheatDetected : UICanvas() {
batch.color = Color.WHITE batch.color = Color.WHITE
val txt = Lang["ERROR_GENERIC_CHEATING"] val txt = Lang["ERROR_GENERIC_CHEATING"]
val txtW = AppLoader.fontGame.getWidth(txt) val txtW = App.fontGame.getWidth(txt)
val txtH = AppLoader.fontGame.lineHeight.toInt() val txtH = App.fontGame.lineHeight.toInt()
AppLoader.fontGame.draw(batch, txt, width.minus(txtW).ushr(1).toFloat(), height.minus(txtH).ushr(1).toFloat()) App.fontGame.draw(batch, txt, width.minus(txtW).ushr(1).toFloat(), height.minus(txtH).ushr(1).toFloat())
} }
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {

View File

@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.ActorWithBody
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory import net.torvald.terrarum.modulebasegame.gameactors.FixtureInventory
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELLS_HOR
@@ -22,8 +21,8 @@ internal class UIInventoryCells(
val full: UIInventoryFull val full: UIInventoryFull
) : UICanvas() { ) : UICanvas() {
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = AppLoader.screenSize.screenH override var height: Int = App.scr.height
override var openCloseTime: Second = 0.0f override var openCloseTime: Second = 0.0f
companion object { companion object {
@@ -53,7 +52,7 @@ internal class UIInventoryCells(
private val equipped: UIItemInventoryEquippedView = private val equipped: UIItemInventoryEquippedView =
UIItemInventoryEquippedView( UIItemInventoryEquippedView(
full, full,
internalWidth - UIItemInventoryEquippedView.WIDTH + (AppLoader.screenSize.screenW - internalWidth) / 2, internalWidth - UIItemInventoryEquippedView.WIDTH + (App.scr.width - internalWidth) / 2,
INVENTORY_CELLS_OFFSET_Y, INVENTORY_CELLS_OFFSET_Y,
{ rebuildList() } { rebuildList() }
) )
@@ -64,7 +63,7 @@ internal class UIInventoryCells(
} }
fun rebuildList() { fun rebuildList() {
AppLoader.printdbg(this, "rebuilding list") App.printdbg(this, "rebuilding list")
itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.selectedIcon]) itemList.rebuild(full.catBar.catIconsMeaning[full.catBar.selectedIcon])
equipped.rebuild() equipped.rebuild()
@@ -94,21 +93,21 @@ internal class UIInventoryCells(
val controlHintXPos = full.offsetX val controlHintXPos = full.offsetX
blendNormal(batch) blendNormal(batch)
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, full.listControlHelp, controlHintXPos, full.yEnd - 20) App.fontGame.draw(batch, full.listControlHelp, controlHintXPos, full.yEnd - 20)
// encumbrance meter // encumbrance meter
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"] val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
// encumbrance bar will go one row down if control help message is too long // encumbrance bar will go one row down if control help message is too long
val encumbBarXPos = full.xEnd - weightBarWidth val encumbBarXPos = full.xEnd - weightBarWidth
val encumbBarTextXPos = encumbBarXPos - 6 - AppLoader.fontGame.getWidth(encumbranceText) val encumbBarTextXPos = encumbBarXPos - 6 - App.fontGame.getWidth(encumbranceText)
val encumbBarYPos = full.yEnd-20 + 3f + val encumbBarYPos = full.yEnd-20 + 3f +
if (AppLoader.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos) if (App.fontGame.getWidth(full.listControlHelp) + 2 + controlHintXPos >= encumbBarTextXPos)
AppLoader.fontGame.lineHeight App.fontGame.lineHeight
else 0f else 0f
Companion.encumbBarYPos = encumbBarYPos // q&d hack to share some numbers Companion.encumbBarYPos = encumbBarYPos // q&d hack to share some numbers
AppLoader.fontGame.draw(batch, App.fontGame.draw(batch,
encumbranceText, encumbranceText,
encumbBarTextXPos, encumbBarTextXPos,
encumbBarYPos - 3f encumbBarYPos - 3f
@@ -136,7 +135,7 @@ internal class UIInventoryCells(
// debug text // debug text
batch.color = Color.LIGHT_GRAY batch.color = Color.LIGHT_GRAY
if (INVEN_DEBUG_MODE) { if (INVEN_DEBUG_MODE) {
AppLoader.fontSmallNumbers.draw(batch, App.fontSmallNumbers.draw(batch,
"${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}", "${full.actor.inventory.capacity}/${full.actor.inventory.maxCapacity}",
encumbBarTextXPos, encumbBarTextXPos,
encumbBarYPos + controlHelpHeight - 4f encumbBarYPos + controlHelpHeight - 4f

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.TitleScreen import net.torvald.terrarum.TitleScreen
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.INVENTORY_CELLS_OFFSET_Y
@@ -15,8 +15,8 @@ import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGH
class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() { class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = AppLoader.screenSize.screenH override var height: Int = App.scr.height
override var openCloseTime = 0.0f override var openCloseTime = 0.0f
private val gameMenu = arrayOf("MENU_LABEL_MAINMENU", "MENU_LABEL_DESKTOP", "MENU_OPTIONS_CONTROLS", "MENU_OPTIONS_SOUND", "MENU_LABEL_GRAPHICS") private val gameMenu = arrayOf("MENU_LABEL_MAINMENU", "MENU_LABEL_DESKTOP", "MENU_OPTIONS_CONTROLS", "MENU_OPTIONS_SOUND", "MENU_LABEL_GRAPHICS")
@@ -24,7 +24,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
private val gameMenuListWidth = 400 private val gameMenuListWidth = 400
private val gameMenuButtons = UIItemTextButtonList( private val gameMenuButtons = UIItemTextButtonList(
this, DEFAULT_LINE_HEIGHT, gameMenu, this, DEFAULT_LINE_HEIGHT, gameMenu,
(AppLoader.screenSize.screenW - gameMenuListWidth) / 2, (App.scr.width - gameMenuListWidth) / 2,
INVENTORY_CELLS_OFFSET_Y + (INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2, INVENTORY_CELLS_OFFSET_Y + (INVENTORY_CELLS_UI_HEIGHT - gameMenuListHeight) / 2,
gameMenuListWidth, gameMenuListHeight, gameMenuListWidth, gameMenuListHeight,
readFromLang = true, readFromLang = true,
@@ -41,7 +41,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
gameMenuButtons.selectionChangeListener = { _, new -> gameMenuButtons.selectionChangeListener = { _, new ->
when (new) { when (new) {
0 -> AppLoader.setScreen(TitleScreen(AppLoader.batch)) 0 -> App.setScreen(TitleScreen(App.batch))
1 -> Gdx.app.exit() 1 -> Gdx.app.exit()
} }
} }
@@ -55,7 +55,7 @@ class UIInventoryEscMenu(val full: UIInventoryFull) : UICanvas() {
// control hints // control hints
blendNormal(batch) blendNormal(batch)
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.gameMenuControlHelp, full.offsetX, full.yEnd - 20)
// text buttons // text buttons
gameMenuButtons.render(batch, camera) gameMenuButtons.render(batch, camera)

View File

@@ -5,12 +5,11 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import net.torvald.ENDASH import net.torvald.ENDASH
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.App.*
import net.torvald.terrarum.blockstats.MinimapComposer import net.torvald.terrarum.blockstats.MinimapComposer
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
import net.torvald.terrarum.ui.* import net.torvald.terrarum.ui.*
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -18,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
* Created by minjaesong on 2017-10-21. * Created by minjaesong on 2017-10-21.
*/ */
class UIInventoryFull( class UIInventoryFull(
toggleKeyLiteral: Int? = AppLoader.getConfigInt("config_keyinventory"), toggleButtonLiteral: Int? = AppLoader.getConfigInt("config_gamepadstart"), toggleKeyLiteral: Int? = App.getConfigInt("config_keyinventory"), toggleButtonLiteral: Int? = App.getConfigInt("config_gamepadstart"),
// UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int)) // UI positions itself? (you must g.flush() yourself after the g.translate(Int, Int))
customPositioning: Boolean = false, // mainly used by vital meter customPositioning: Boolean = false, // mainly used by vital meter
doNotWarnConstant: Boolean = false doNotWarnConstant: Boolean = false
@@ -27,8 +26,8 @@ class UIInventoryFull(
val actor: ActorHumanoid val actor: ActorHumanoid
get() = Terrarum.ingame!!.actorNowPlaying!! get() = Terrarum.ingame!!.actorNowPlaying!!
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = AppLoader.screenSize.screenH override var height: Int = App.scr.height
override var openCloseTime: Second = 0.0f override var openCloseTime: Second = 0.0f
companion object { companion object {
@@ -36,7 +35,7 @@ class UIInventoryFull(
const val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8 const val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
const val CELLS_HOR = 10 const val CELLS_HOR = 10
val CELLS_VRT: Int; get() = (AppLoader.screenSize.screenH - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number val CELLS_VRT: Int; get() = (App.scr.height - REQUIRED_MARGIN - 134 + UIItemInventoryItemGrid.listGap) / // 134 is another magic number
(UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap) (UIItemInventoryElemSimple.height + UIItemInventoryItemGrid.listGap)
const val itemListToEquipViewGap = UIItemInventoryItemGrid.listGap // used to be 24; figured out that the extra gap does nothig const val itemListToEquipViewGap = UIItemInventoryItemGrid.listGap // used to be 24; figured out that the extra gap does nothig
@@ -47,8 +46,8 @@ class UIInventoryFull(
val itemListHeight: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap val itemListHeight: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * net.torvald.terrarum.modulebasegame.ui.UIItemInventoryItemGrid.Companion.listGap
val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap val INVENTORY_CELLS_UI_HEIGHT: Int = CELLS_VRT * UIItemInventoryElemSimple.height + (CELLS_VRT - 1) * UIItemInventoryItemGrid.listGap
val INVENTORY_CELLS_OFFSET_X = 0 + (AppLoader.screenSize.screenW - internalWidth) / 2 val INVENTORY_CELLS_OFFSET_X = 0 + (App.scr.width - internalWidth) / 2
val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (AppLoader.screenSize.screenH - internalHeight) / 2 val INVENTORY_CELLS_OFFSET_Y: Int = 107 + (App.scr.height - internalHeight) / 2
val catBarWidth = 330 val catBarWidth = 330
@@ -56,7 +55,7 @@ class UIInventoryFull(
val gradEndCol = Color(0x000000_70) val gradEndCol = Color(0x000000_70)
val gradHeight = 48f val gradHeight = 48f
val controlHelpHeight = AppLoader.fontGame.lineHeight val controlHelpHeight = App.fontGame.lineHeight
} }
//val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8 //val REQUIRED_MARGIN: Int = 138 // hard-coded value. Don't know the details. Range: [91-146]. I chose MAX-8 because cell gap is 8
@@ -86,7 +85,7 @@ class UIInventoryFull(
private val SP = "${0x3000.toChar()} " private val SP = "${0x3000.toChar()} "
val listControlHelp: String val listControlHelp: String
get() = if (AppLoader.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${0xe006.toChar()} ${Lang["GAME_INVENTORY_USE"]}$SP" + "${0xe006.toChar()} ${Lang["GAME_INVENTORY_USE"]}$SP" +
"${0xe011.toChar()}$ENDASH${0x2009.toChar()}${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" + "${0xe011.toChar()}$ENDASH${0x2009.toChar()}${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
@@ -99,7 +98,7 @@ class UIInventoryFull(
"$gamepadLabelNorth$gamepadLabelLStick ${Lang["GAME_INVENTORY_REGISTER"]}$SP" + "$gamepadLabelNorth$gamepadLabelLStick ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
"$gamepadLabelEast ${Lang["GAME_INVENTORY_DROP"]}" "$gamepadLabelEast ${Lang["GAME_INVENTORY_DROP"]}"
val minimapControlHelp: String val minimapControlHelp: String
get() = if (AppLoader.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP" + "${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}$SP" +
"${0xe006.toChar()} ${Lang["GAME_ACTION_MOVE_VERB"]}" "${0xe006.toChar()} ${Lang["GAME_ACTION_MOVE_VERB"]}"
else else
@@ -107,7 +106,7 @@ class UIInventoryFull(
"$gamepadLabelRStick ${Lang["GAME_ACTION_MOVE_VERB"]}$SP" + "$gamepadLabelRStick ${Lang["GAME_ACTION_MOVE_VERB"]}$SP" +
"$gamepadLabelRT ${Lang["GAME_INVENTORY"]}" "$gamepadLabelRT ${Lang["GAME_INVENTORY"]}"
val gameMenuControlHelp: String val gameMenuControlHelp: String
get() = if (AppLoader.environment == RunningEnvironment.PC) get() = if (App.environment == RunningEnvironment.PC)
"${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}" "${0xe031.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
else else
"$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" + "$gamepadLabelStart ${Lang["GAME_ACTION_CLOSE"]}$SP" +
@@ -115,8 +114,8 @@ class UIInventoryFull(
val catBar = UIItemInventoryCatBar( val catBar = UIItemInventoryCatBar(
this, this,
(AppLoader.screenSize.screenW - catBarWidth) / 2, (App.scr.width - catBarWidth) / 2,
42 + (AppLoader.screenSize.screenH - internalHeight) / 2, 42 + (App.scr.height - internalHeight) / 2,
internalWidth, internalWidth,
catBarWidth, catBarWidth,
true, true,
@@ -129,10 +128,10 @@ class UIInventoryFull(
private val transitionalEscMenu = UIInventoryEscMenu(this) private val transitionalEscMenu = UIInventoryEscMenu(this)
private val transitionPanel = UIItemHorizontalFadeSlide( private val transitionPanel = UIItemHorizontalFadeSlide(
this, this,
(AppLoader.screenSize.screenW - internalWidth) / 2, (App.scr.width - internalWidth) / 2,
INVENTORY_CELLS_OFFSET_Y, INVENTORY_CELLS_OFFSET_Y,
AppLoader.screenSize.screenW, App.scr.width,
AppLoader.screenSize.screenH, App.scr.height,
1f, 1f,
transitionalMinimap, transitionalItemCells, transitionalEscMenu transitionalMinimap, transitionalItemCells, transitionalEscMenu
) )
@@ -153,9 +152,9 @@ class UIInventoryFull(
} }
internal var offsetX = ((AppLoader.screenSize.screenW - internalWidth) / 2).toFloat() internal var offsetX = ((App.scr.width - internalWidth) / 2).toFloat()
private set private set
internal var offsetY = ((AppLoader.screenSize.screenH - internalHeight) / 2).toFloat() internal var offsetY = ((App.scr.height - internalHeight) / 2).toFloat()
private set private set
fun requestTransition(target: Int) = transitionPanel.requestTransition(target) fun requestTransition(target: Int) = transitionPanel.requestTransition(target)
@@ -174,9 +173,9 @@ class UIInventoryFull(
//private val gradHeight = 48f //private val gradHeight = 48f
private val shapeRenderer = ShapeRenderer() private val shapeRenderer = ShapeRenderer()
internal var xEnd = (AppLoader.screenSize.screenW + internalWidth).div(2).toFloat() internal var xEnd = (App.scr.width + internalWidth).div(2).toFloat()
private set private set
internal var yEnd = (AppLoader.screenSize.screenH + internalHeight).div(2).toFloat() internal var yEnd = (App.scr.height + internalHeight).div(2).toFloat()
private set private set
override fun renderUI(batch: SpriteBatch, camera: Camera) { override fun renderUI(batch: SpriteBatch, camera: Camera) {
@@ -187,17 +186,17 @@ class UIInventoryFull(
gdxSetBlendNormal() gdxSetBlendNormal()
val gradTopStart = (AppLoader.screenSize.screenH - internalHeight).div(2).toFloat() val gradTopStart = (App.scr.height - internalHeight).div(2).toFloat()
val gradBottomEnd = AppLoader.screenSize.screenH - gradTopStart val gradBottomEnd = App.scr.height - gradTopStart
shapeRenderer.inUse { shapeRenderer.inUse {
shapeRenderer.rect(0f, gradTopStart, AppLoader.screenSize.screenWf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradTopStart, App.scr.wf, gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradBottomEnd, AppLoader.screenSize.screenWf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradBottomEnd, App.scr.wf, -gradHeight, gradStartCol, gradStartCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, gradTopStart + gradHeight, AppLoader.screenSize.screenWf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol) shapeRenderer.rect(0f, gradTopStart + gradHeight, App.scr.wf, internalHeight - (2 * gradHeight), gradEndCol, gradEndCol, gradEndCol, gradEndCol)
shapeRenderer.rect(0f, 0f, AppLoader.screenSize.screenWf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol) shapeRenderer.rect(0f, 0f, App.scr.wf, gradTopStart, gradStartCol, gradStartCol, gradStartCol, gradStartCol)
shapeRenderer.rect(0f, AppLoader.screenSize.screenHf, AppLoader.screenSize.screenWf, -(AppLoader.screenSize.screenHf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol) shapeRenderer.rect(0f, App.scr.hf, App.scr.wf, -(App.scr.hf - gradBottomEnd), gradStartCol, gradStartCol, gradStartCol, gradStartCol)
} }
@@ -257,11 +256,11 @@ class UIInventoryFull(
override fun resize(width: Int, height: Int) { override fun resize(width: Int, height: Int) {
super.resize(width, height) super.resize(width, height)
offsetX = ((AppLoader.screenSize.screenW - internalWidth) / 2).toFloat() offsetX = ((App.scr.width - internalWidth) / 2).toFloat()
offsetY = ((AppLoader.screenSize.screenH - internalHeight) / 2).toFloat() offsetY = ((App.scr.height - internalHeight) / 2).toFloat()
xEnd = (AppLoader.screenSize.screenW + internalWidth).div(2).toFloat() xEnd = (App.scr.width + internalWidth).div(2).toFloat()
yEnd = (AppLoader.screenSize.screenH + internalHeight).div(2).toFloat() yEnd = (App.scr.height + internalHeight).div(2).toFloat()
} }
} }

View File

@@ -15,8 +15,8 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
private val debugvals = true private val debugvals = true
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = AppLoader.screenSize.screenH override var height: Int = App.scr.height
override var openCloseTime = 0.0f override var openCloseTime = 0.0f
private val MINIMAP_WIDTH = 800f private val MINIMAP_WIDTH = 800f
@@ -44,7 +44,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
// update map panning // update map panning
// if left click is down and cursor is in the map area // if left click is down and cursor is in the map area
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) && if (Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary")) &&
Terrarum.mouseScreenY in INVENTORY_CELLS_OFFSET_Y..INVENTORY_CELLS_OFFSET_Y + INVENTORY_CELLS_UI_HEIGHT) { Terrarum.mouseScreenY in INVENTORY_CELLS_OFFSET_Y..INVENTORY_CELLS_OFFSET_Y + INVENTORY_CELLS_UI_HEIGHT) {
minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom
minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom
@@ -115,23 +115,23 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
batch.begin() batch.begin()
if (debugvals) { if (debugvals) {
AppLoader.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", (AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2, -10f + INVENTORY_CELLS_OFFSET_Y) App.fontSmallNumbers.draw(batch, "$minimapPanX, $minimapPanY; x$minimapZoom", (App.scr.width - MINIMAP_WIDTH) / 2, -10f + INVENTORY_CELLS_OFFSET_Y)
} }
batch.projectionMatrix = camera.combined batch.projectionMatrix = camera.combined
// 1px stroke // 1px stroke
batch.color = Color.WHITE batch.color = Color.WHITE
batch.fillRect((AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2, -1 + INVENTORY_CELLS_OFFSET_Y.toFloat(), MINIMAP_WIDTH, 1f) batch.fillRect((App.scr.width - MINIMAP_WIDTH) / 2, -1 + INVENTORY_CELLS_OFFSET_Y.toFloat(), MINIMAP_WIDTH, 1f)
batch.fillRect((AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f) batch.fillRect((App.scr.width - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y + MINIMAP_HEIGHT, MINIMAP_WIDTH, 1f)
batch.fillRect(-1 + (AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT) batch.fillRect(-1 + (App.scr.width - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
batch.fillRect((AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT) batch.fillRect((App.scr.width - MINIMAP_WIDTH) / 2 + MINIMAP_WIDTH, INVENTORY_CELLS_OFFSET_Y.toFloat(), 1f, MINIMAP_HEIGHT)
// control hints // control hints
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, full.minimapControlHelp, full.offsetX, full.yEnd - 20) App.fontGame.draw(batch, full.minimapControlHelp, full.offsetX, full.yEnd - 20)
// the minimap // the minimap
batch.draw(minimapFBO.colorBufferTexture, (AppLoader.screenSize.screenW - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat()) batch.draw(minimapFBO.colorBufferTexture, (App.scr.width - MINIMAP_WIDTH) / 2, INVENTORY_CELLS_OFFSET_Y.toFloat())
} }
override fun doOpening(delta: Float) {} override fun doOpening(delta: Float) {}

View File

@@ -38,7 +38,7 @@ class UIItemPlayerInfoCell(
private val backColInactive = ItemSlotImageFactory.CELLCOLOUR_BLACK private val backColInactive = ItemSlotImageFactory.CELLCOLOUR_BLACK
private val backColActive = ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE private val backColActive = ItemSlotImageFactory.CELLCOLOUR_BLACK_ACTIVE
private val textRow1 = (((height / 2) - AppLoader.fontGame.lineHeight) / 2).toFloat() private val textRow1 = (((height / 2) - App.fontGame.lineHeight) / 2).toFloat()
private val textRow2 = textRow1 + (height / 2) private val textRow2 = textRow1 + (height / 2)
private val creationTimeStr: String private val creationTimeStr: String
@@ -62,7 +62,7 @@ class UIItemPlayerInfoCell(
worldCountStr = Lang["CONTEXT_WORLD_COUNT"] + saveInfo.get("worlds").asIntArray().size worldCountStr = Lang["CONTEXT_WORLD_COUNT"] + saveInfo.get("worlds").asIntArray().size
worldCountStrWidth = AppLoader.fontGame.getWidth(worldCountStr) worldCountStrWidth = App.fontGame.getWidth(worldCountStr)
} }
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {

View File

@@ -2,8 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItem import net.torvald.terrarum.ui.UIItem
import java.io.File import java.io.File
@@ -21,7 +20,7 @@ class UIItemSavegameInfoCell(
initialY: Int initialY: Int
) : UIItem(parent, initialX, initialY) { ) : UIItem(parent, initialX, initialY) {
override val height: Int = AppLoader.fontGame.lineHeight.toInt() * 2 override val height: Int = App.fontGame.lineHeight.toInt() * 2
override fun render(batch: SpriteBatch, camera: Camera) { override fun render(batch: SpriteBatch, camera: Camera) {

View File

@@ -5,12 +5,11 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.fillRect import net.torvald.terrarum.fillRect
import net.torvald.terrarum.gameitem.ItemID import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.BuildingMaker import net.torvald.terrarum.modulebasegame.BuildingMaker
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -28,7 +27,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
val LINE_HEIGHT = 24 val LINE_HEIGHT = 24
val TEXT_OFFSETX = 3f val TEXT_OFFSETX = 3f
val TEXT_OFFSETY = (LINE_HEIGHT - AppLoader.fontGame.lineHeight) / 2f val TEXT_OFFSETY = (LINE_HEIGHT - App.fontGame.lineHeight) / 2f
fun mouseOnTitleBar() = fun mouseOnTitleBar() =
relativeMouseX in 0 until width && relativeMouseY in 0 until LINE_HEIGHT relativeMouseX in 0 until width && relativeMouseY in 0 until LINE_HEIGHT
@@ -80,7 +79,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
// draw "Pal." // draw "Pal."
batch.color = UINSMenu.DEFAULT_TITLETEXTCOL batch.color = UINSMenu.DEFAULT_TITLETEXTCOL
AppLoader.fontGame.draw(batch, titleText, TEXT_OFFSETX, TEXT_OFFSETY) App.fontGame.draw(batch, titleText, TEXT_OFFSETX, TEXT_OFFSETY)
// draw background // draw background
batch.color = CELLCOLOUR_BLACK batch.color = CELLCOLOUR_BLACK
@@ -91,7 +90,7 @@ class UIPaletteSelector(val parent: BuildingMaker) : UICanvas() {
// TODO carve the overlap // TODO carve the overlap
batch.draw(ItemCodex.getItemImage(back), 14f, 41f) batch.draw(ItemCodex.getItemImage(back), 14f, 41f)
batch.draw(ItemCodex.getItemImage(fore), 6f, 33f) batch.draw(ItemCodex.getItemImage(fore), 6f, 33f)
AppLoader.fontSmallNumbers.draw(batch, fore.toString(), 3f, 61f) App.fontSmallNumbers.draw(batch, fore.toString(), 3f, 61f)
// draw swap icon // draw swap icon
batch.color = Color.WHITE batch.color = Color.WHITE

View File

@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.SanicLoadScreen import net.torvald.terrarum.SanicLoadScreen
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
@@ -32,11 +32,11 @@ class UIProxyNewBuildingMaker : UICanvas() {
} }
override fun endOpening(delta: Float) { override fun endOpening(delta: Float) {
val ingame = BuildingMaker(AppLoader.batch) val ingame = BuildingMaker(App.batch)
Terrarum.setCurrentIngameInstance(ingame) Terrarum.setCurrentIngameInstance(ingame)
SanicLoadScreen.screenToLoad = ingame SanicLoadScreen.screenToLoad = ingame
AppLoader.setLoadScreen(SanicLoadScreen) App.setLoadScreen(SanicLoadScreen)
} }
override fun endClosing(delta: Float) { override fun endClosing(delta: Float) {

View File

@@ -3,8 +3,8 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
@@ -37,7 +37,7 @@ class UIProxyNewRandomGame : UICanvas() {
printdbg(this, "endOpening") printdbg(this, "endOpening")
val ingame = TerrarumIngame(AppLoader.batch) val ingame = TerrarumIngame(App.batch)
// val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, 0x51621DL) // val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, 0x51621DL)
val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, HQRNG().nextLong()) val worldParam = TerrarumIngame.NewWorldParameters(2400, 1280, HQRNG().nextLong())
@@ -52,7 +52,7 @@ class UIProxyNewRandomGame : UICanvas() {
//LoadScreen.screenToLoad = ingame //LoadScreen.screenToLoad = ingame
//AppLoader.setScreen(LoadScreen) //AppLoader.setScreen(LoadScreen)
val loadScreen = WorldgenLoadScreen(ingame, worldParam.width, worldParam.height) val loadScreen = WorldgenLoadScreen(ingame, worldParam.width, worldParam.height)
AppLoader.setLoadScreen(loadScreen) App.setLoadScreen(loadScreen)
} }
override fun endClosing(delta: Float) { override fun endClosing(delta: Float) {

View File

@@ -3,12 +3,11 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.* import net.torvald.terrarum.*
@@ -23,7 +22,7 @@ class UIQuickslotBar : UICanvas() {
private val gutter = 10 - 6 // do -6 to get a gutter size of not-enlarged cells private val gutter = 10 - 6 // do -6 to get a gutter size of not-enlarged cells
override var width: Int = cellSize * SLOT_COUNT + gutter * (SLOT_COUNT - 1) // 452 override var width: Int = cellSize * SLOT_COUNT + gutter * (SLOT_COUNT - 1) // 452
override var height: Int = ItemSlotImageFactory.slotImage.tileH + 4 + AppLoader.fontGame.lineHeight.toInt() override var height: Int = ItemSlotImageFactory.slotImage.tileH + 4 + App.fontGame.lineHeight.toInt()
/** /**
* In milliseconds * In milliseconds
*/ */

View File

@@ -4,11 +4,10 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AVKey import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.itemproperties.ItemCodex
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar.Companion.COMMON_OPEN_CLOSE import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar.Companion.COMMON_OPEN_CLOSE
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar.Companion.SLOT_COUNT import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar.Companion.SLOT_COUNT
@@ -50,7 +49,7 @@ class UIQuickslotPie : UICanvas() {
// update controls // update controls
if (handler.isOpened || handler.isOpening) { if (handler.isOpened || handler.isOpening) {
val cursorPos = Vector2(Terrarum.mouseScreenX.toDouble(), Terrarum.mouseScreenY.toDouble()) val cursorPos = Vector2(Terrarum.mouseScreenX.toDouble(), Terrarum.mouseScreenY.toDouble())
val centre = Vector2(AppLoader.screenSize.halfScreenW.toDouble(), AppLoader.screenSize.halfScreenH.toDouble()) val centre = Vector2(App.scr.halfw.toDouble(), App.scr.halfh.toDouble())
val deg = -(centre - cursorPos).direction.toFloat() val deg = -(centre - cursorPos).direction.toFloat()
selection = Math.round(deg * slotCount / FastMath.TWO_PI) selection = Math.round(deg * slotCount / FastMath.TWO_PI)

View File

@@ -5,8 +5,8 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbgerr import net.torvald.terrarum.App.printdbgerr
import net.torvald.terrarum.QNDTreeNode import net.torvald.terrarum.QNDTreeNode
import net.torvald.terrarum.Yaml import net.torvald.terrarum.Yaml
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -295,7 +295,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
val remoConWidth = 300 val remoConWidth = 300
fun getRemoConHeight(menu: ArrayList<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1) fun getRemoConHeight(menu: ArrayList<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
fun getRemoConHeight(menu: Array<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1) fun getRemoConHeight(menu: Array<String>) = DEFAULT_LINE_HEIGHT * menu.size.plus(1)
val menubarOffX: Int; get() = (0.11 * AppLoader.screenSize.screenW).toInt() val menubarOffX: Int; get() = (0.11 * App.scr.width).toInt()
val menubarOffY: Int; get() = (0.82 * AppLoader.screenSize.screenH).toInt() val menubarOffY: Int; get() = (0.82 * App.scr.height).toInt()
} }
} }

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.EMDASH import net.torvald.EMDASH
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumScreenSize import net.torvald.terrarum.TerrarumScreenSize
import net.torvald.terrarum.keyToIcon import net.torvald.terrarum.keyToIcon
@@ -17,13 +17,13 @@ import net.torvald.terrarum.ui.UICanvas
* Created by minjaesong on 2019-08-11. * Created by minjaesong on 2019-08-11.
*/ */
class UIScreenZoom : UICanvas( class UIScreenZoom : UICanvas(
AppLoader.getConfigInt("config_keyzoom") App.getConfigInt("config_keyzoom")
) { ) {
val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out" val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out"
override var width = AppLoader.fontGame.getWidth(zoomText) override var width = App.fontGame.getWidth(zoomText)
override var height = AppLoader.fontGame.lineHeight.toInt() override var height = App.fontGame.lineHeight.toInt()
override var openCloseTime = 0.15f override var openCloseTime = 0.15f
@@ -38,10 +38,10 @@ class UIScreenZoom : UICanvas(
override fun renderUI(batch: SpriteBatch, camera: Camera) { override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw( App.fontGame.draw(
batch, zoomText, batch, zoomText,
(AppLoader.screenSize.screenW * TerrarumScreenSize.TV_SAFE_GRAPHICS + 1).toInt().toFloat(), (App.scr.width * TerrarumScreenSize.TV_SAFE_GRAPHICS + 1).toInt().toFloat(),
(AppLoader.screenSize.screenH - height - AppLoader.screenSize.tvSafeGraphicsHeight).toFloat() (App.scr.height - height - App.scr.tvSafeGraphicsHeight).toFloat()
) )
} }

View File

@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.gameworld.WorldTime import net.torvald.terrarum.gameworld.WorldTime
import net.torvald.terrarum.modulebasegame.imagefont.WatchFont import net.torvald.terrarum.modulebasegame.imagefont.WatchFont
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -46,7 +45,7 @@ class UITierOneWatch() : UICanvas() {
ELuptimer += delta ELuptimer += delta
} }
if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) { if (mouseUp || Gdx.input.isKeyPressed(App.getConfigInt("config_keyinteract"))) {
ELuptimer = 0f ELuptimer = 0f
ELon = true ELon = true
} }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -19,8 +19,8 @@ class UITitleCharactersList : UICanvas() {
private val moduleAreaHMargin = 48 private val moduleAreaHMargin = 48
private val moduleAreaBorder = 8 private val moduleAreaBorder = 8
override var width = AppLoader.screenSize.screenW - UIRemoCon.remoConWidth - moduleAreaHMargin override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
override var height = AppLoader.screenSize.screenH - moduleAreaHMargin * 2 override var height = App.scr.height - moduleAreaHMargin * 2
private val moduleInfoCells = ArrayList<UIItemSavegameInfoCell>() private val moduleInfoCells = ArrayList<UIItemSavegameInfoCell>()
// build characters list // build characters list

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -20,14 +20,14 @@ class UITitleLanguage : UICanvas() {
private val textAreaHMargin = 48 private val textAreaHMargin = 48
override var width = (AppLoader.screenSize.screenW * 0.75).toInt() override var width = (App.scr.width * 0.75).toInt()
override var height = AppLoader.screenSize.screenH - textAreaHMargin * 2 override var height = App.scr.height - textAreaHMargin * 2
private val localeList = Lang.languageList.toList().sorted() private val localeList = Lang.languageList.toList().sorted()
private val textArea = UIItemTextButtonList(this, private val textArea = UIItemTextButtonList(this,
24, 24,
localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(), localeList.map { Lang.langpack["MENU_LANGUAGE_THIS_$it"] ?: "!ERR: $it" }.toTypedArray(),
AppLoader.screenSize.screenW - width, textAreaHMargin, App.scr.width - width, textAreaHMargin,
width, height, width, height,
textAreaWidth = width, textAreaWidth = width,
readFromLang = false, readFromLang = false,
@@ -51,7 +51,7 @@ class UITitleLanguage : UICanvas() {
// attach listeners // attach listeners
textArea.selectionChangeListener = { _, newSelectionIndex -> textArea.selectionChangeListener = { _, newSelectionIndex ->
AppLoader.GAME_LOCALE = localeList[newSelectionIndex] App.GAME_LOCALE = localeList[newSelectionIndex]
} }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.ModMgr import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.blendNormal import net.torvald.terrarum.blendNormal
@@ -21,8 +21,8 @@ class UITitleModules : UICanvas() {
private val moduleAreaHMargin = 48 private val moduleAreaHMargin = 48
private val moduleAreaBorder = 8 private val moduleAreaBorder = 8
override var width = AppLoader.screenSize.screenW - UIRemoCon.remoConWidth - moduleAreaHMargin override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
override var height = AppLoader.screenSize.screenH - moduleAreaHMargin * 2 override var height = App.scr.height - moduleAreaHMargin * 2
private val moduleInfoCells = ArrayList<UIItemModuleInfoCell>() private val moduleInfoCells = ArrayList<UIItemModuleInfoCell>()

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.modulebasegame.ui package net.torvald.terrarum.modulebasegame.ui
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Yaml import net.torvald.terrarum.Yaml
@@ -42,7 +42,7 @@ object UITitleRemoConYaml {
- MENU_LABEL_RETURN - MENU_LABEL_RETURN
""".trimIndent()*/ """.trimIndent()*/
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD) operator fun invoke() = if (App.IS_DEVELOPMENT_BUILD)
Yaml(menus + "\n" + debugTools).parse() Yaml(menus + "\n" + debugTools).parse()
else else
Yaml(menus).parse() Yaml(menus).parse()

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.CreditSingleton import net.torvald.terrarum.CreditSingleton
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -15,8 +15,8 @@ open class UITitleWallOfText(private val text: List<String>) : UICanvas() {
private val textAreaHMargin = 48 private val textAreaHMargin = 48
override var width = AppLoader.screenSize.screenW - UIRemoCon.remoConWidth - textAreaHMargin override var width = App.scr.width - UIRemoCon.remoConWidth - textAreaHMargin
override var height = AppLoader.screenSize.screenH - textAreaHMargin * 2 override var height = App.scr.height - textAreaHMargin * 2
private val textArea = UIItemTextArea(this, private val textArea = UIItemTextArea(this,
UIRemoCon.remoConWidth, textAreaHMargin, UIRemoCon.remoConWidth, textAreaHMargin,
width, height width, height

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -28,7 +28,7 @@ class UITooltip : UICanvas() {
msgWidth = msgBuffer.maxOf { font.getWidth(it) } msgWidth = msgBuffer.maxOf { font.getWidth(it) }
} }
private val font = AppLoader.fontGame private val font = App.fontGame
private var msgWidth = 0 private var msgWidth = 0
val textMarginX = 4 val textMarginX = 4

View File

@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.colourutil.darkerLab import net.torvald.colourutil.darkerLab
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.ui.UICanvas import net.torvald.terrarum.ui.UICanvas
@@ -50,8 +50,8 @@ class UIVitalMetre(
override fun updateUI(delta: Float) { override fun updateUI(delta: Float) {
handler.setPosition( handler.setPosition(
AppLoader.screenSize.halfScreenW, App.scr.halfw,
AppLoader.screenSize.halfScreenH App.scr.halfh
) )
} }

View File

@@ -1,18 +1,16 @@
package net.torvald.terrarum.modulebasegame.worldgenerator package net.torvald.terrarum.modulebasegame.worldgenerator
import com.badlogic.gdx.graphics.Pixmap
import com.sudoplay.joise.Joise import com.sudoplay.joise.Joise
import com.sudoplay.joise.module.ModuleAutoCorrect import com.sudoplay.joise.module.ModuleAutoCorrect
import com.sudoplay.joise.module.ModuleBasisFunction import com.sudoplay.joise.module.ModuleBasisFunction
import com.sudoplay.joise.module.ModuleFractal import com.sudoplay.joise.module.ModuleFractal
import com.sudoplay.joise.module.ModuleScaleDomain import com.sudoplay.joise.module.ModuleScaleDomain
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.concurrent.ThreadExecutor import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.concurrent.sliceEvenly import net.torvald.terrarum.concurrent.sliceEvenly
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.gameworld.fmod
import java.util.concurrent.Future
import kotlin.math.cos import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin
@@ -49,7 +47,7 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
ThreadExecutor.join() ThreadExecutor.join()
AppLoader.printdbg(this, "Waking up Worldgen") App.printdbg(this, "Waking up Worldgen")
} }
companion object { companion object {

View File

@@ -3,14 +3,11 @@ package net.torvald.terrarum.modulebasegame.worldgenerator
import com.sudoplay.joise.Joise import com.sudoplay.joise.Joise
import com.sudoplay.joise.module.* import com.sudoplay.joise.module.*
import net.torvald.random.XXHash32 import net.torvald.random.XXHash32
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.Block import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.concurrent.ThreadExecutor import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.concurrent.sliceEvenly import net.torvald.terrarum.concurrent.sliceEvenly
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.toInt
import java.util.concurrent.Future
import kotlin.math.cos import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin

View File

@@ -4,8 +4,8 @@ import com.jme3.math.FastMath
import com.sudoplay.joise.Joise import com.sudoplay.joise.Joise
import com.sudoplay.joise.module.* import com.sudoplay.joise.module.*
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.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.concurrent.ThreadParallel import net.torvald.terrarum.concurrent.ThreadParallel

View File

@@ -1,9 +1,8 @@
package net.torvald.terrarum.modulebasegame.worldgenerator package net.torvald.terrarum.modulebasegame.worldgenerator
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.GameWorld
import java.util.concurrent.Callable
/** /**
* New world generator. * New world generator.
@@ -35,7 +34,7 @@ object Worldgen {
val it = jobs[i] val it = jobs[i]
AppLoader.getLoadScreen().addMessage(it.loadingScreenName) App.getLoadScreen().addMessage(it.loadingScreenName)
it.theWork.getDone() it.theWork.getDone()
} }

View File

@@ -3,7 +3,7 @@ package net.torvald.terrarum.serialise
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
import net.torvald.gdx.graphics.PixmapIO2 import net.torvald.gdx.graphics.PixmapIO2
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.console.Echo import net.torvald.terrarum.console.Echo
import net.torvald.terrarum.modulebasegame.IngameRenderer import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
@@ -45,7 +45,7 @@ object WriteSavegame {
val creation_t = ingame.world.creationTime val creation_t = ingame.world.creationTime
val time_t = AppLoader.getTIME_T() val time_t = App.getTIME_T()
val currentPlayTime_t = time_t - ingame.loadedTime_t val currentPlayTime_t = time_t - ingame.loadedTime_t
@@ -137,7 +137,7 @@ object LoadSavegame {
private fun getFileReader(disk: VirtualDisk, id: Int): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET) private fun getFileReader(disk: VirtualDisk, id: Int): Reader = ByteArray64Reader(getFileBytes(disk, id), Common.CHARSET)
operator fun invoke(disk: VirtualDisk) { operator fun invoke(disk: VirtualDisk) {
val ingame = TerrarumIngame(AppLoader.batch) val ingame = TerrarumIngame(App.batch)
// NOTE: do NOT set ingame.actorNowPlaying as one read directly from the disk; // NOTE: do NOT set ingame.actorNowPlaying as one read directly from the disk;
// you'll inevitably read the player actor twice, and they're separate instances of the player! // you'll inevitably read the player actor twice, and they're separate instances of the player!
@@ -166,7 +166,7 @@ object LoadSavegame {
// ModMgr.reloadModules() // ModMgr.reloadModules()
Terrarum.setCurrentIngameInstance(ingame) Terrarum.setCurrentIngameInstance(ingame)
AppLoader.setScreen(ingame) App.setScreen(ingame)
Echo("${ccW}Savegame loaded from $ccY${disk.getDiskNameString(Common.CHARSET)}") Echo("${ccW}Savegame loaded from $ccY${disk.getDiskNameString(Common.CHARSET)}")
printdbg(this, "Savegame loaded from ${disk.getDiskNameString(Common.CHARSET)}") printdbg(this, "Savegame loaded from ${disk.getDiskNameString(Common.CHARSET)}")

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.swingapp package net.torvald.terrarum.swingapp
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import java.awt.BorderLayout import java.awt.BorderLayout
import java.awt.FlowLayout import java.awt.FlowLayout
@@ -45,7 +45,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
this.title = labelTitle this.title = labelTitle
defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
AppLoader.getINSTANCE().pause() App.getINSTANCE().pause()
buttonOkay.addMouseListener(object : MouseListener { buttonOkay.addMouseListener(object : MouseListener {
override fun mouseEntered(e: MouseEvent?) { } override fun mouseEntered(e: MouseEvent?) { }
@@ -55,7 +55,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
override fun mousePressed(e: MouseEvent?) { override fun mousePressed(e: MouseEvent?) {
userInput = inputArea.text userInput = inputArea.text
isVisible = false isVisible = false
AppLoader.getINSTANCE().resume() App.getINSTANCE().resume()
feedInput(userInput) feedInput(userInput)
@@ -71,7 +71,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
override fun mousePressed(e: MouseEvent?) { override fun mousePressed(e: MouseEvent?) {
userInput = ""//null userInput = ""//null
isVisible = false isVisible = false
AppLoader.getINSTANCE().resume() App.getINSTANCE().resume()
dispose() dispose()
} }
@@ -83,7 +83,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
override fun keyPressed(e: KeyEvent?) { override fun keyPressed(e: KeyEvent?) {
userInput = inputArea.text userInput = inputArea.text
isVisible = false isVisible = false
AppLoader.getINSTANCE().resume() App.getINSTANCE().resume()
feedInput(userInput) feedInput(userInput)

View File

@@ -17,8 +17,7 @@ import com.sudoplay.joise.module.ModuleBasisFunction
import com.sudoplay.joise.module.ModuleFractal import com.sudoplay.joise.module.ModuleFractal
import com.sudoplay.joise.module.ModuleScaleOffset import com.sudoplay.joise.module.ModuleScaleOffset
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.concurrent.ThreadExecutor import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.concurrent.sliceEvenly import net.torvald.terrarum.concurrent.sliceEvenly
import net.torvald.terrarum.inUse import net.torvald.terrarum.inUse
@@ -45,11 +44,11 @@ class NoiseGenerator : ScreenAdapter() {
Gdx.input.inputProcessor = NoiseGeneratorController(this) Gdx.input.inputProcessor = NoiseGeneratorController(this)
batch = SpriteBatch() batch = SpriteBatch()
camera = OrthographicCamera(AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera = OrthographicCamera(App.scr.wf, App.scr.hf)
camera.setToOrtho(true, AppLoader.screenSize.screenWf, AppLoader.screenSize.screenHf) camera.setToOrtho(true, App.scr.wf, App.scr.hf)
camera.update() camera.update()
Gdx.gl20.glViewport(0, 0, AppLoader.screenSize.screenW, AppLoader.screenSize.screenH) Gdx.gl20.glViewport(0, 0, App.scr.width, App.scr.height)
pixmap = Pixmap(IMAGE_SIZE, IMAGE_SIZE, Pixmap.Format.RGBA8888) pixmap = Pixmap(IMAGE_SIZE, IMAGE_SIZE, Pixmap.Format.RGBA8888)
texture = Texture(1, 1, Pixmap.Format.RGBA8888) texture = Texture(1, 1, Pixmap.Format.RGBA8888)
@@ -142,7 +141,7 @@ class NoiseGenerator : ScreenAdapter() {
batch.draw(texture, 0f, 0f) batch.draw(texture, 0f, 0f)
batch.color = Color.CYAN batch.color = Color.CYAN
AppLoader.fontGame.draw(batch, "Tests: $totalTestsDone / ${testSets.size * samplingCount}", 10f, 10f) App.fontGame.draw(batch, "Tests: $totalTestsDone / ${testSets.size * samplingCount}", 10f, 10f)
} }
} }
@@ -258,5 +257,5 @@ fun main(args: Array<String>) {
appConfig.setResizable(false) appConfig.setResizable(false)
appConfig.setWindowedMode(1024, 1024) appConfig.setWindowedMode(1024, 1024)
Lwjgl3Application(AppLoader(appConfig, NoiseGenerator()), appConfig) Lwjgl3Application(App(appConfig, NoiseGenerator()), appConfig)
} }

View File

@@ -106,7 +106,7 @@ class UITestPad1 : ScreenAdapter() {
Color.LIME Color.LIME
else else
Color.FIREBRICK Color.FIREBRICK
AppLoader.fontGame.draw(batch, "Mouse: ${Terrarum.mouseScreenX}, ${Terrarum.mouseScreenY}", 8f, 740 - 28f) App.fontGame.draw(batch, "Mouse: ${Terrarum.mouseScreenX}, ${Terrarum.mouseScreenY}", 8f, 740 - 28f)
} }
_dct = (_dct + delta*2) % 10f _dct = (_dct + delta*2) % 10f
@@ -156,5 +156,5 @@ fun main(args: Array<String>) {
appConfig.setResizable(false) appConfig.setResizable(false)
appConfig.setWindowedMode(UITEST1_WIDTH, UITEST1_HEIGHT) appConfig.setWindowedMode(UITEST1_WIDTH, UITEST1_HEIGHT)
Lwjgl3Application(AppLoader(appConfig, UITestPad1()), appConfig) Lwjgl3Application(App(appConfig, UITestPad1()), appConfig)
} }

View File

@@ -16,7 +16,6 @@ import net.torvald.terrarum.modulebasegame.IngameRenderer
import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory
import net.torvald.terrarum.realestate.LandUtil import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
import net.torvald.terrarum.worlddrawer.LightmapRenderer import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarum.worlddrawer.WorldCamera import net.torvald.terrarum.worlddrawer.WorldCamera
@@ -25,8 +24,8 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
*/ */
class BasicDebugInfoWindow : UICanvas() { class BasicDebugInfoWindow : UICanvas() {
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = AppLoader.screenSize.screenH override var height: Int = App.scr.height
override var openCloseTime: Float = 0f override var openCloseTime: Float = 0f
@@ -78,7 +77,7 @@ class BasicDebugInfoWindow : UICanvas() {
val hitbox = player?.hitbox val hitbox = player?.hitbox
val updateCount = maxOf(1L, (AppLoader.debugTimers["Ingame.UpdateCounter"] ?: 1L) as Long) val updateCount = maxOf(1L, (App.debugTimers["Ingame.UpdateCounter"] ?: 1L) as Long)
/** /**
* First column * First column
@@ -172,7 +171,7 @@ class BasicDebugInfoWindow : UICanvas() {
// print time // print time
var dbgCnt = 12 var dbgCnt = 12
AppLoader.debugTimers.forEach { t, u -> App.debugTimers.forEach { t, u ->
printLine(batch, dbgCnt, "$ccM$t $ccG${formatNanoTime(u as? Long)}$ccY ns") printLine(batch, dbgCnt, "$ccM$t $ccG${formatNanoTime(u as? Long)}$ccY ns")
dbgCnt++ dbgCnt++
} }
@@ -206,9 +205,9 @@ class BasicDebugInfoWindow : UICanvas() {
val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad
if (gamepad != null) { if (gamepad != null) {
drawGamepadAxis(gamepad, batch, drawGamepadAxis(gamepad, batch,
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")), gamepad.getAxis(App.getConfigInt("config_gamepadaxislx")),
gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")), gamepad.getAxis(App.getConfigInt("config_gamepadaxisly")),
AppLoader.screenSize.screenW - 128 - TinyAlphNum.W * 2, App.scr.width - 128 - TinyAlphNum.W * 2,
line(3).toInt() line(3).toInt()
) )
} }
@@ -218,68 +217,68 @@ class BasicDebugInfoWindow : UICanvas() {
*/ */
// memory pressure // memory pressure
AppLoader.fontSmallNumbers.draw(batch, "${ccY}MEM ", (AppLoader.screenSize.screenW - 23 * TinyAlphNum.W - 2).toFloat(), line(1)) App.fontSmallNumbers.draw(batch, "${ccY}MEM ", (App.scr.width - 23 * TinyAlphNum.W - 2).toFloat(), line(1))
// thread count // thread count
AppLoader.fontSmallNumbers.draw(batch, "${ccY}CPUs${if (AppLoader.MULTITHREAD) ccG else ccR}${AppLoader.THREAD_COUNT.toString().padStart(2, ' ')}", App.fontSmallNumbers.draw(batch, "${ccY}CPUs${if (App.MULTITHREAD) ccG else ccR}${App.THREAD_COUNT.toString().padStart(2, ' ')}",
(AppLoader.screenSize.screenW - 2 - 8 * TinyAlphNum.W).toFloat(), line(2)) (App.scr.width - 2 - 8 * TinyAlphNum.W).toFloat(), line(2))
// memory texts // memory texts
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M", App.fontSmallNumbers.draw(batch, "${Terrarum.memJavaHeap}M",
(AppLoader.screenSize.screenW - 19 * TinyAlphNum.W - 2).toFloat(), line(1)) (App.scr.width - 19 * TinyAlphNum.W - 2).toFloat(), line(1))
AppLoader.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/", App.fontSmallNumbers.draw(batch, "/${Terrarum.memNativeHeap}M/",
(AppLoader.screenSize.screenW - 14 * TinyAlphNum.W - 2).toFloat(), line(1)) (App.scr.width - 14 * TinyAlphNum.W - 2).toFloat(), line(1))
AppLoader.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M", App.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
(AppLoader.screenSize.screenW - 7 * TinyAlphNum.W - 2).toFloat(), line(1)) (App.scr.width - 7 * TinyAlphNum.W - 2).toFloat(), line(1))
// FPS count // FPS count
AppLoader.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}", App.fontSmallNumbers.draw(batch, "${ccY}FPS${ccG}${Gdx.graphics.framesPerSecond.toString().padStart(3, ' ')}",
(AppLoader.screenSize.screenW - 3 - 15 * TinyAlphNum.W).toFloat(), line(2)) (App.scr.width - 3 - 15 * TinyAlphNum.W).toFloat(), line(2))
// global render counter // global render counter
AppLoader.fontSmallNumbers.draw(batch, "${ccO}${AppLoader.GLOBAL_RENDER_TIMER.toString().padStart(10, ' ')}", App.fontSmallNumbers.draw(batch, "${ccO}${App.GLOBAL_RENDER_TIMER.toString().padStart(10, ' ')}",
(AppLoader.screenSize.screenW - 35 * TinyAlphNum.W - 2).toFloat(), line(1)) (App.scr.width - 35 * TinyAlphNum.W - 2).toFloat(), line(1))
/** /**
* Bottom left * Bottom left
*/ */
if (ingame != null) { if (ingame != null) {
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}", App.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${ingame!!.actorContainerActive.size + ingame!!.actorContainerInactive.size}",
TinyAlphNum.W * 2f, AppLoader.screenSize.screenH - TinyAlphNum.H * 2f) TinyAlphNum.W * 2f, App.scr.height - TinyAlphNum.H * 2f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${ingame!!.actorContainerActive.size}", App.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${ingame!!.actorContainerActive.size}",
(TinyAlphNum.W * 2 + 17 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f) (TinyAlphNum.W * 2 + 17 * 8).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}", App.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${ingame!!.actorContainerInactive.size}",
(TinyAlphNum.W * 2 + 28 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f) (TinyAlphNum.W * 2 + 28 * 8).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
if (ingame is TerrarumIngame) { if (ingame is TerrarumIngame) {
AppLoader.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as TerrarumIngame).particlesActive}", App.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${(ingame as TerrarumIngame).particlesActive}",
(TinyAlphNum.W * 2 + 41 * 8).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f) (TinyAlphNum.W * 2 + 41 * 8).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
} }
} }
AppLoader.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}", App.fontSmallNumbers.draw(batch, "${ccY}Actors rendering $ccG${IngameRenderer.renderingActorsCount}",
TinyAlphNum.W * 2f, AppLoader.screenSize.screenH - TinyAlphNum.H * 3f) TinyAlphNum.W * 2f, App.scr.height - TinyAlphNum.H * 3f)
AppLoader.fontSmallNumbers.draw(batch, "${ccY}UIs rendering $ccG${IngameRenderer.renderingUIsCount}", App.fontSmallNumbers.draw(batch, "${ccY}UIs rendering $ccG${IngameRenderer.renderingUIsCount}",
TinyAlphNum.W * 2f + (21 * 8), AppLoader.screenSize.screenH - TinyAlphNum.H * 3f) TinyAlphNum.W * 2f + (21 * 8), App.scr.height - TinyAlphNum.H * 3f)
/** /**
* Bottom right * Bottom right
*/ */
// processor and renderer // processor and renderer
AppLoader.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName", App.fontSmallNumbers.draw(batch, "$ccY$totalHardwareName",
(AppLoader.screenSize.screenW - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), AppLoader.screenSize.screenH - TinyAlphNum.H * 2f) (App.scr.width - (totalHardwareName.length + 2) * TinyAlphNum.W).toFloat(), App.scr.height - TinyAlphNum.H * 2f)
} }
private val processorName = AppLoader.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (AppLoader.is32BitJVM) " (32-bit)" else "" private val processorName = App.processor.replace(Regex(""" Processor|( CPU)? @ [0-9.]+GHz"""), "") + if (App.is32BitJVM) " (32-bit)" else ""
private val rendererName = AppLoader.renderer private val rendererName = App.renderer
private val totalHardwareName = "$processorName $rendererName" private val totalHardwareName = "$processorName $rendererName"
private fun printLine(batch: SpriteBatch, l: Int, s: String) { private fun printLine(batch: SpriteBatch, l: Int, s: String) {
AppLoader.fontSmallNumbers.draw(batch, App.fontSmallNumbers.draw(batch,
s, TinyAlphNum.W * 2f, line(l) s, TinyAlphNum.W * 2f, line(l)
) )
} }
private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) { private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) {
AppLoader.fontSmallNumbers.draw(batch, App.fontSmallNumbers.draw(batch,
s, (TinyAlphNum.W * 2f + column(col)), line(row) s, (TinyAlphNum.W * 2f + column(col)), line(row)
) )
} }
@@ -303,9 +302,9 @@ class BasicDebugInfoWindow : UICanvas() {
batch.color = uiColour batch.color = uiColour
batch.fillRect(x.toFloat(), y.toFloat(), w.plus(1), h) batch.fillRect(x.toFloat(), y.toFloat(), w.plus(1), h)
batch.color = Color.GRAY batch.color = Color.GRAY
AppLoader.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2) App.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
AppLoader.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2) App.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
AppLoader.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2) App.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
blendScreen(batch) blendScreen(batch)
for (c in 0..3) { for (c in 0..3) {
@@ -340,7 +339,7 @@ class BasicDebugInfoWindow : UICanvas() {
val pointDX = axisX * halfW val pointDX = axisX * halfW
val pointDY = -axisY * halfH val pointDY = -axisY * halfH
val deadzone = AppLoader.gamepadDeadzone val deadzone = App.gamepadDeadzone
blendNormal(batch) blendNormal(batch)
@@ -348,16 +347,16 @@ class BasicDebugInfoWindow : UICanvas() {
gdxSetBlendNormal() gdxSetBlendNormal()
Terrarum.inShapeRenderer { Terrarum.inShapeRenderer {
it.color = uiColour it.color = uiColour
it.rect(uiX.toFloat(), AppLoader.screenSize.screenH - uiY.toFloat(), w, -h) it.rect(uiX.toFloat(), App.scr.height - uiY.toFloat(), w, -h)
it.color = deadzoneColour it.color = deadzoneColour
it.rect(uiX + halfW - (halfW * deadzone), AppLoader.screenSize.screenH - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone) it.rect(uiX + halfW - (halfW * deadzone), App.scr.height - (uiY + halfH - halfH * deadzone), w * deadzone, -h * deadzone)
it.color = Color.WHITE it.color = Color.WHITE
it.line(uiX + halfW, AppLoader.screenSize.screenH - (uiY + halfH), uiX + halfW + pointDX, AppLoader.screenSize.screenH - (uiY + halfH + pointDY)) it.line(uiX + halfW, App.scr.height - (uiY + halfH), uiX + halfW + pointDX, App.scr.height - (uiY + halfH + pointDY))
it.color = Color.GRAY it.color = Color.GRAY
} }
batch.begin() batch.begin()
AppLoader.fontSmallNumbers.draw(batch, gamepad.getName(), AppLoader.screenSize.screenW - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2) App.fontSmallNumbers.draw(batch, gamepad.getName(), App.scr.width - (gamepad.getName().length + 2f) * TinyAlphNum.W, uiY.toFloat() + h + 2)
} }

View File

@@ -36,7 +36,7 @@ class ConsoleWindow : UICanvas() {
private val LINE_HEIGHT = 20 private val LINE_HEIGHT = 20
private val MESSAGES_DISPLAY_COUNT = 11 private val MESSAGES_DISPLAY_COUNT = 11
override var width: Int = AppLoader.screenSize.screenW override var width: Int = App.scr.width
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1) override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
override var openCloseTime = 0f override var openCloseTime = 0f
@@ -78,12 +78,12 @@ class ConsoleWindow : UICanvas() {
batch.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat()) batch.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat())
val input = commandInputPool!!.toString() val input = commandInputPool!!.toString()
val inputDrawWidth = AppLoader.fontGame.getWidth(input) val inputDrawWidth = App.fontGame.getWidth(input)
val inputDrawHeight = AppLoader.fontGame.lineHeight val inputDrawHeight = App.fontGame.lineHeight
// text and cursor // text and cursor
batch.color = Color.WHITE batch.color = Color.WHITE
AppLoader.fontGame.draw(batch, input, 1f + drawOffX, drawOffY) App.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
batch.color = Color(0x7f7f7f_ff) batch.color = Color(0x7f7f7f_ff)
batch.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight) batch.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight)
@@ -94,7 +94,7 @@ class ConsoleWindow : UICanvas() {
// messages // messages
for (i in 0..MESSAGES_DISPLAY_COUNT - 1) { for (i in 0..MESSAGES_DISPLAY_COUNT - 1) {
val message = messages[messageDisplayPos + i] val message = messages[messageDisplayPos + i]
AppLoader.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY) App.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
} }
} }
@@ -201,7 +201,7 @@ class ConsoleWindow : UICanvas() {
commandInputPool = StringBuilder() commandInputPool = StringBuilder()
if (Authenticator.b()) { if (Authenticator.b()) {
sendMessage("$ccE${TerrarumAppConfiguration.GAME_NAME} ${AppLoader.getVERSION_STRING()} $EMDASH ${TerrarumAppConfiguration.COPYRIGHT_DATE_NAME}") sendMessage("$ccE${TerrarumAppConfiguration.GAME_NAME} ${App.getVERSION_STRING()} $EMDASH ${TerrarumAppConfiguration.COPYRIGHT_DATE_NAME}")
sendMessage("$ccE${TerrarumAppConfiguration.COPYRIGHT_LICENSE}") sendMessage("$ccE${TerrarumAppConfiguration.COPYRIGHT_LICENSE}")
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"]) sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
} }

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.fillRect import net.torvald.terrarum.fillRect
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -26,7 +26,7 @@ object Toolkit {
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) { fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
val imageW = image.width val imageW = image.width
val targetW = if (ui == null) AppLoader.screenSize.screenW else ui.width val targetW = if (ui == null) App.scr.width else ui.width
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat()) batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
} }

View File

@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.AppLoader import net.torvald.terrarum.App
import net.torvald.terrarum.Second import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -86,7 +86,7 @@ abstract class UICanvas(
get() = _mouseUpThis || handler.mouseUp get() = _mouseUpThis || handler.mouseUp
/** If mouse is hovering over it and mouse is down */ /** If mouse is hovering over it and mouse is down */
val mousePushed: Boolean val mousePushed: Boolean
get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) get() = mouseUp && Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))
private val _mouseUpThis: Boolean private val _mouseUpThis: Boolean
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1 get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
@@ -148,7 +148,7 @@ abstract class UICanvas(
uiItems.add(uiItem) uiItems.add(uiItem)
} }
fun mouseInScreen(x: Int, y: Int) = x in 0 until AppLoader.screenSize.screenW && y in 0 until AppLoader.screenSize.screenH fun mouseInScreen(x: Int, y: Int) = x in 0 until App.scr.width && y in 0 until App.scr.height
/** /**
* Called by the screen's InputProcessor * Called by the screen's InputProcessor
@@ -307,13 +307,13 @@ abstract class UICanvas(
).roundToInt() ).roundToInt()
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut( Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime, ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenSize.screenWf, App.scr.wf,
AppLoader.screenSize.screenW - ui.width.toFloat() App.scr.width - ui.width.toFloat()
).roundToInt() ).roundToInt()
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut( Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime, ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenSize.screenHf, App.scr.hf,
AppLoader.screenSize.screenH - ui.height.toFloat() App.scr.height - ui.height.toFloat()
).roundToInt() ).roundToInt()
} }
} }
@@ -331,13 +331,13 @@ abstract class UICanvas(
).roundToInt() ).roundToInt()
Position.RIGHT -> ui.handler.posX = Movement.fastPullOut( Position.RIGHT -> ui.handler.posX = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime, ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenSize.screenW - ui.width.toFloat(), App.scr.width - ui.width.toFloat(),
AppLoader.screenSize.screenWf App.scr.wf
).roundToInt() ).roundToInt()
Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut( Position.BOTTOM -> ui.handler.posY = Movement.fastPullOut(
ui.handler.openCloseCounter / openCloseTime, ui.handler.openCloseCounter / openCloseTime,
AppLoader.screenSize.screenH - ui.height.toFloat(), App.scr.height - ui.height.toFloat(),
AppLoader.screenSize.screenHf App.scr.hf
).roundToInt() ).roundToInt()
} }
} }
@@ -345,16 +345,16 @@ abstract class UICanvas(
when (position) { when (position) {
Position.LEFT -> ui.handler.posX = 0 Position.LEFT -> ui.handler.posX = 0
Position.TOP -> ui.handler.posY = 0 Position.TOP -> ui.handler.posY = 0
Position.RIGHT -> ui.handler.posX = AppLoader.screenSize.screenW - ui.width Position.RIGHT -> ui.handler.posX = App.scr.width - ui.width
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH - ui.height Position.BOTTOM -> ui.handler.posY = App.scr.height - ui.height
} }
} }
fun endClosingPopOut(ui: UICanvas, position: Position) { fun endClosingPopOut(ui: UICanvas, position: Position) {
when (position) { when (position) {
Position.LEFT -> ui.handler.posX = -ui.width Position.LEFT -> ui.handler.posX = -ui.width
Position.TOP -> ui.handler.posY = -ui.height Position.TOP -> ui.handler.posY = -ui.height
Position.RIGHT -> ui.handler.posX = AppLoader.screenSize.screenW Position.RIGHT -> ui.handler.posX = App.scr.width
Position.BOTTOM -> ui.handler.posY = AppLoader.screenSize.screenH Position.BOTTOM -> ui.handler.posY = App.scr.height
} }
} }

Some files were not shown because too many files have changed in this diff Show More