feat: display wrong timer
All checks were successful
Linux arm64 / Build (push) Successful in 28s

This commit is contained in:
2025-02-01 00:19:00 +01:00
parent a5c046f891
commit 6d96455ac4
3 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
package gui.widget;
import imgui.ImGui;
public class TimerRenderer {
private float time;
private final float duration;
public TimerRenderer(float duration) {
this.time = 0;
this.duration = duration;
}
public void render() {
this.time += ImGui.getIO().getDeltaTime();
float remainingTime = this.duration - this.time;
int seconds = (int) remainingTime;
int minutes = seconds / 60;
seconds %= 60;
String text = minutes + ":" + seconds;
var textSize = ImGui.calcTextSize(text);
ImGui.setCursorPosX(ImGui.getIO().getDisplaySizeX() / 2.0f - textSize.x / 2.0f);
ImGui.text(text);
}
}