mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
fix: no module screen gets broken if the screen is magnified
This commit is contained in:
@@ -547,7 +547,7 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
Gdx.gl.glDisable(GL20.GL_DITHER);
|
// Gdx.gl.glDisable(GL20.GL_DITHER);
|
||||||
|
|
||||||
if (splashDisplayed && !postInitFired) {
|
if (splashDisplayed && !postInitFired) {
|
||||||
postInitFired = true;
|
postInitFired = true;
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package net.torvald.terrarum
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.Pixmap
|
import com.badlogic.gdx.graphics.Pixmap
|
||||||
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 net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.utils.OpenFile
|
import net.torvald.terrarum.utils.OpenFile
|
||||||
import java.awt.Desktop
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,9 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
|
|||||||
|
|
||||||
private var gamemode = 0
|
private var gamemode = 0
|
||||||
|
|
||||||
private val fbatch = SpriteBatch(1000, DefaultGL32Shaders.createSpriteBatchShader())
|
private val fbatch = FlippingSpriteBatch(1000)
|
||||||
|
private val camera = OrthographicCamera(App.scr.wf, App.scr.hf)
|
||||||
|
|
||||||
|
|
||||||
private val genericBackdrop = Toolkit.Theme.COL_CELL_FILL.cpy().add(0f,0f,0f,1f)
|
private val genericBackdrop = Toolkit.Theme.COL_CELL_FILL.cpy().add(0f,0f,0f,1f)
|
||||||
private val winTenBackdrop = Color(0x1070AAFF)
|
private val winTenBackdrop = Color(0x1070AAFF)
|
||||||
@@ -50,6 +52,11 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
|
|||||||
else
|
else
|
||||||
genericBackdrop
|
genericBackdrop
|
||||||
|
|
||||||
|
init {
|
||||||
|
fbatch.projectionMatrix = camera.combined
|
||||||
|
App.setConfig("screenmagnifyingfilter", "bilinear")
|
||||||
|
}
|
||||||
|
|
||||||
override fun render(updateRate: Float) {
|
override fun render(updateRate: Float) {
|
||||||
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
||||||
|
|
||||||
@@ -66,29 +73,30 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
// vertically centre the above
|
// vertically centre the above
|
||||||
val centering = (App.scr.hf - heights.last() - App.fontGameFBO.lineHeight) / 2f
|
val centering = (App.scr.hf - heights.last() - App.fontGame.lineHeight) / 2f
|
||||||
|
|
||||||
fbo.inAction(null, null) {
|
fbo.inAction(camera, fbatch) {
|
||||||
gdxClearAndEnableBlend(backdrop)
|
gdxClearAndEnableBlend(backdrop)
|
||||||
batch.inUse {
|
fbatch.inUse {
|
||||||
batch.color = Color.WHITE
|
it.color = Color.WHITE
|
||||||
wot.reversed().forEachIndexed { index, s ->
|
wot.forEachIndexed { index, s ->
|
||||||
if (index == 0) {
|
if (index == wot.lastIndex) {
|
||||||
pathButtonX = (Toolkit.drawWidth - pathButtonW) / 2f
|
pathButtonX = (Toolkit.drawWidth - pathButtonW) / 2f
|
||||||
pathButtonY = heights[index] + centering
|
pathButtonY = (heights[index] + centering)
|
||||||
}
|
|
||||||
else {
|
|
||||||
batch.color = Color.WHITE
|
|
||||||
App.fontGameFBO.draw(batch, s, (Toolkit.drawWidth - maxtw) / 2f, heights[index] + centering)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it.color = Color.WHITE
|
||||||
|
App.fontGame.draw(it, s, (Toolkit.drawWidth - maxtw) / 2f, (heights[index] + centering))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fbatch.projectionMatrix = camera.combined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamemode == 0) {
|
if (gamemode == 0) {
|
||||||
val mouseOnLink = (Gdx.input.x.toFloat() in pathButtonX - 48..pathButtonX + 48 + pathButtonW &&
|
val mouseOnLink = (Gdx.input.x / App.scr.magn in pathButtonX - 48..pathButtonX + 48 + pathButtonW &&
|
||||||
App.scr.hf - Gdx.input.y in pathButtonY - 12..pathButtonY + pathButtonH + 12)
|
Gdx.input.y / App.scr.magn in pathButtonY - 12..pathButtonY + pathButtonH + 12)
|
||||||
|
|
||||||
if (mouseOnLink && Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)) {
|
if (mouseOnLink && Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)) {
|
||||||
OpenFile(pathFile)
|
OpenFile(pathFile)
|
||||||
@@ -96,9 +104,9 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
|
|||||||
|
|
||||||
fbatch.inUse {
|
fbatch.inUse {
|
||||||
it.color = Color.WHITE
|
it.color = Color.WHITE
|
||||||
it.draw(fbo.colorBufferTexture, 0f, fbo.height.toFloat(), fbo.width.toFloat(), -fbo.height.toFloat())
|
it.draw(fbo.colorBufferTexture, -App.scr.halfwf, App.scr.halfhf, App.scr.wf, -App.scr.hf)
|
||||||
it.color = if (mouseOnLink) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_MOUSE_UP
|
it.color = if (mouseOnLink) Toolkit.Theme.COL_SELECTED else Toolkit.Theme.COL_MOUSE_UP
|
||||||
App.fontGame.draw(it, pathText, pathButtonX, pathButtonY)
|
App.fontGame.draw(it, pathText, pathButtonX - App.scr.halfwf, pathButtonY - App.scr.halfhf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (Gdx.input.isKeyPressed(Keys.ESCAPE)) gamemode = 1
|
// if (Gdx.input.isKeyPressed(Keys.ESCAPE)) gamemode = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user