This commit is contained in:
27
app/src/main/java/gui/widget/TimerRenderer.java
Normal file
27
app/src/main/java/gui/widget/TimerRenderer.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user