Skip to content
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
25 changes: 18 additions & 7 deletions src/main/java/meteordevelopment/meteorclient/gui/WidgetScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public abstract class WidgetScreen extends Screen {
private boolean onClose;
private boolean debug;

private boolean closing;

private double lastMouseX, lastMouseY;

public double animProgress;
Expand Down Expand Up @@ -255,9 +257,13 @@ public void renderCustom(DrawContext context, int mouseX, int mouseY, float delt
mouseX *= s;
mouseY *= s;

animProgress += delta / 20 * 14;
animProgress += (delta / 20 * 14) * (closing ? -1 : 1);
animProgress = MathHelper.clamp(animProgress, 0, 1);

if (closing && (animProgress == 0 || parent != null)) {
closeInternal();
}

GuiKeyEvents.canUseKeys = true;

// Apply projection without scaling
Expand Down Expand Up @@ -304,12 +310,7 @@ public void resize(MinecraftClient client, int width, int height) {
@Override
public void close() {
if (!locked || lockedAllowClose) {
boolean preOnClose = onClose;
onClose = true;

removed();

onClose = preOnClose;
closing = true;
}
}

Expand Down Expand Up @@ -341,6 +342,16 @@ public void removed() {
}
}

private void closeInternal() {
boolean preOnClose = onClose;
onClose = true;

super.close();
removed();

onClose = preOnClose;
}

private void loopWidgets(WWidget widget, Consumer<WWidget> action) {
action.accept(widget);

Expand Down