Inceptum/launcher/src/main/java/io/gitlab/jfronny/inceptum/frontend/gui/window/Window.java

57 lines
1.1 KiB
Java
Raw Normal View History

package io.gitlab.jfronny.inceptum.frontend.gui.window;
2021-10-28 20:19:09 +02:00
2021-10-28 21:31:51 +02:00
import imgui.flag.ImGuiWindowFlags;
import imgui.type.ImBoolean;
2021-10-30 22:05:24 +02:00
import io.gitlab.jfronny.inceptum.InceptumGui;
2021-10-27 22:00:08 +02:00
2021-10-30 19:26:59 +02:00
import java.io.Closeable;
public abstract class Window implements Closeable {
2021-10-27 22:00:08 +02:00
private final String name;
2021-10-30 19:26:59 +02:00
private final ImBoolean openState = new ImBoolean(true);
2021-12-01 16:12:47 +01:00
private State state = State.New;
2021-10-27 22:00:08 +02:00
public Window(String name) {
this.name = name;
}
public void preFirstDraw() {
}
public abstract void draw();
public String getName() {
return name;
}
2021-10-30 19:26:59 +02:00
@Override
2021-10-27 22:00:08 +02:00
public void close() {
2021-12-01 16:12:47 +01:00
state = State.Closed;
2021-10-28 21:31:51 +02:00
openState.set(false);
2021-10-30 22:05:24 +02:00
InceptumGui.WINDOWS.remove(this);
2021-10-27 22:00:08 +02:00
}
public boolean isNew() {
2021-12-01 16:12:47 +01:00
if (state == State.New) {
state = State.Open;
2021-10-27 22:00:08 +02:00
return true;
}
return false;
}
2021-10-28 21:31:51 +02:00
2021-12-01 16:12:47 +01:00
public boolean isClosed() {
return state == State.Closed;
}
2021-10-28 21:31:51 +02:00
public int getFlags() {
return ImGuiWindowFlags.AlwaysAutoResize;
}
public ImBoolean getOpenState() {
return openState;
}
2021-12-01 16:12:47 +01:00
public enum State {
New, Open, Closed
}
2021-10-27 22:00:08 +02:00
}