Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Custom Scoreboard Update time #2685

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment
import at.hannibal2.skyhanni.utils.RenderUtils.VerticalAlignment
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderable
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.fromNow
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.renderables.Renderable
Expand All @@ -50,7 +51,7 @@ object CustomScoreboard {
private var cache = emptyList<ScoreboardElementType>()
private const val GUI_NAME = "Custom Scoreboard"

private var lastScoreboardUpdate = SimpleTimeMark.farFuture()
private var nextScoreboardUpdate = SimpleTimeMark.farFuture()

@SubscribeEvent
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
Expand Down Expand Up @@ -82,9 +83,7 @@ object CustomScoreboard {
fun onGuiPositionMoved(event: GuiPositionMovedEvent) {
if (event.guiName == GUI_NAME) {
with(alignmentConfig) {
if (horizontalAlignment != HorizontalAlignment.DONT_ALIGN ||
verticalAlignment != VerticalAlignment.DONT_ALIGN
) {
if (horizontalAlignment != HorizontalAlignment.DONT_ALIGN || verticalAlignment != VerticalAlignment.DONT_ALIGN) {
val tempHori = horizontalAlignment
val tempVert = verticalAlignment

Expand All @@ -108,15 +107,9 @@ object CustomScoreboard {
fun onTick(event: LorenzTickEvent) {
if (!isEnabled()) return

// We want to update the scoreboard as soon as we have new data, not 5 ticks delayed
var dirty = false
if (lastScoreboardUpdate.passedSince() > 250.milliseconds) {
lastScoreboardUpdate = SimpleTimeMark.farFuture()
dirty = true
}

// Creating the lines
if (dirty) {
if (dirty || nextScoreboardUpdate.isInPast()) {
nextScoreboardUpdate = 250.milliseconds.fromNow()
dirty = false
display = createLines().removeEmptyLinesFromEdges()
if (TabListData.fullyLoaded) {
cache = display.toList()
Expand All @@ -129,10 +122,9 @@ object CustomScoreboard {

@SubscribeEvent
fun onScoreboardChange(event: ScoreboardUpdateEvent) {
lastScoreboardUpdate = SimpleTimeMark.now()
dirty = true
}


internal val config get() = SkyHanniMod.feature.gui.customScoreboard
internal val displayConfig get() = config.display
internal val alignmentConfig get() = displayConfig.alignment
Expand Down
Loading