mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +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 {
|
private class ThreadIngameUpdate(val ingame: Ingame): Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
var updateTries = 0
|
||||||
while (ingame.updateDeltaCounter >= ingame.updateRate) {
|
while (ingame.updateDeltaCounter >= ingame.updateRate) {
|
||||||
ingame.updateGame(Terrarum.deltaTime)
|
ingame.updateGame(Terrarum.deltaTime)
|
||||||
ingame.updateDeltaCounter -= ingame.updateRate
|
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, NOP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
var updateTries = 0
|
||||||
while (updateDeltaCounter >= updateRate) {
|
while (updateDeltaCounter >= updateRate) {
|
||||||
updateGame(delta)
|
updateGame(delta)
|
||||||
updateDeltaCounter -= updateRate
|
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
|
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 COPYRIGHT_DATE_NAME = "Copyright 2013-2017 Torvald (minjaesong)";
|
||||||
public static final String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
public static final String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 0xAA_BB_XXXX
|
* 0xAA_BB_XXXX
|
||||||
* AA: Major version
|
* AA: Major version
|
||||||
|
|||||||
@@ -190,9 +190,15 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
else {
|
else {
|
||||||
// async update
|
// async update
|
||||||
updateDeltaCounter += delta
|
updateDeltaCounter += delta
|
||||||
|
var updateTries = 0
|
||||||
while (updateDeltaCounter >= updateRate) {
|
while (updateDeltaCounter >= updateRate) {
|
||||||
updateScreen(delta)
|
updateScreen(delta)
|
||||||
updateDeltaCounter -= updateRate
|
updateDeltaCounter -= updateRate
|
||||||
|
updateTries++
|
||||||
|
|
||||||
|
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// render? just do it anyway
|
// render? just do it anyway
|
||||||
|
|||||||
@@ -31,13 +31,14 @@ class UIItemList<Item: UIItem>(
|
|||||||
val inactiveCol: Color = Color(0xc0c0c0_ff.toInt()),
|
val inactiveCol: Color = Color(0xc0c0c0_ff.toInt()),
|
||||||
val backgroundCol: Color = Color(0x242424_80),
|
val backgroundCol: Color = Color(0x242424_80),
|
||||||
val backgroundBlendMode: String = BlendMode.NORMAL,
|
val backgroundBlendMode: String = BlendMode.NORMAL,
|
||||||
val kinematic: Boolean = false
|
val kinematic: Boolean = false,
|
||||||
|
val border: Int = 0
|
||||||
) : UIItem(parentUI) {
|
) : UIItem(parentUI) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
itemList.forEachIndexed { index, item ->
|
itemList.forEachIndexed { index, item ->
|
||||||
item.posX = this.posX
|
item.posX = this.posX + border
|
||||||
item.posY = if (index == 0) this.posY else itemList[index - 1].posY + itemList[index - 1].height
|
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 moduleAreaHMargin = 48
|
||||||
|
|
||||||
|
private val moduleAreaBorder = 8
|
||||||
|
|
||||||
private val moduleAreaWidth = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
private val moduleAreaWidth = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
||||||
private val moduleAreaHeight = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
private val moduleAreaHeight = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
||||||
|
|
||||||
@@ -50,7 +53,7 @@ class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
|||||||
moduleInfoCells.add(UIItemModuleInfoCell(
|
moduleInfoCells.add(UIItemModuleInfoCell(
|
||||||
this,
|
this,
|
||||||
it.first,
|
it.first,
|
||||||
moduleAreaWidth,
|
moduleAreaWidth - 2 * moduleAreaBorder,
|
||||||
0, 0 // placeholder
|
0, 0 // placeholder
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -62,7 +65,8 @@ class UITitleRemoConModules(val superMenu: UICanvas) : UICanvas() {
|
|||||||
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
||||||
moduleAreaWidth,
|
moduleAreaWidth,
|
||||||
moduleAreaHeight,
|
moduleAreaHeight,
|
||||||
inactiveCol = Color.WHITE
|
inactiveCol = Color.WHITE,
|
||||||
|
border = moduleAreaBorder
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user