mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
module UI now has margin; game update will drop consecutive updates if its try count is exhausted (reduced lag after window move/resize)
This commit is contained in:
@@ -394,9 +394,15 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
||||
///////////////
|
||||
private class ThreadIngameUpdate(val ingame: Ingame): Runnable {
|
||||
override fun run() {
|
||||
var updateTries = 0
|
||||
while (ingame.updateDeltaCounter >= ingame.updateRate) {
|
||||
ingame.updateGame(Terrarum.deltaTime)
|
||||
ingame.updateDeltaCounter -= ingame.updateRate
|
||||
updateTries++
|
||||
|
||||
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,9 +457,15 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
||||
// else, NOP;
|
||||
}
|
||||
else {
|
||||
var updateTries = 0
|
||||
while (updateDeltaCounter >= updateRate) {
|
||||
updateGame(delta)
|
||||
updateDeltaCounter -= updateRate
|
||||
updateTries++
|
||||
|
||||
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ object Terrarum : Screen {
|
||||
*/
|
||||
val TARGET_INTERNAL_FPS: Double = 60.0
|
||||
|
||||
internal val UPDATE_CATCHUP_MAX_TRIES = 10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public class TerrarumAppLoader implements ApplicationListener {
|
||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2017 Torvald (minjaesong)";
|
||||
public static final String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||
|
||||
|
||||
/**
|
||||
* 0xAA_BB_XXXX
|
||||
* AA: Major version
|
||||
|
||||
@@ -190,9 +190,15 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
else {
|
||||
// async update
|
||||
updateDeltaCounter += delta
|
||||
var updateTries = 0
|
||||
while (updateDeltaCounter >= updateRate) {
|
||||
updateScreen(delta)
|
||||
updateDeltaCounter -= updateRate
|
||||
updateTries++
|
||||
|
||||
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// render? just do it anyway
|
||||
|
||||
@@ -31,13 +31,14 @@ class UIItemList<Item: UIItem>(
|
||||
val inactiveCol: Color = Color(0xc0c0c0_ff.toInt()),
|
||||
val backgroundCol: Color = Color(0x242424_80),
|
||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||
val kinematic: Boolean = false
|
||||
val kinematic: Boolean = false,
|
||||
val border: Int = 0
|
||||
) : UIItem(parentUI) {
|
||||
|
||||
init {
|
||||
itemList.forEachIndexed { index, item ->
|
||||
item.posX = this.posX
|
||||
item.posY = if (index == 0) this.posY else itemList[index - 1].posY + itemList[index - 1].height
|
||||
item.posX = this.posX + border
|
||||
item.posY = if (index == 0) this.posY + border else itemList[index - 1].posY + itemList[index - 1].height
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
||||
|
||||
|
||||
private val moduleAreaHMargin = 48
|
||||
|
||||
private val moduleAreaBorder = 8
|
||||
|
||||
private val moduleAreaWidth = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
||||
private val moduleAreaHeight = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
||||
|
||||
@@ -50,7 +53,7 @@ class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
||||
moduleInfoCells.add(UIItemModuleInfoCell(
|
||||
this,
|
||||
it.first,
|
||||
moduleAreaWidth,
|
||||
moduleAreaWidth - 2 * moduleAreaBorder,
|
||||
0, 0 // placeholder
|
||||
))
|
||||
}
|
||||
@@ -62,7 +65,8 @@ class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
||||
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
||||
moduleAreaWidth,
|
||||
moduleAreaHeight,
|
||||
inactiveCol = Color.WHITE
|
||||
inactiveCol = Color.WHITE,
|
||||
border = moduleAreaBorder
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user