Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
desht committed Aug 14, 2024
2 parents 39c52bf + cbf3e09 commit cf467e3
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ftb.mods.ftbchunks.client.gui;

import com.mojang.blaze3d.platform.InputConstants;
import dev.architectury.networking.NetworkManager;
import dev.ftb.mods.ftbchunks.client.map.MapManager;
import dev.ftb.mods.ftbchunks.client.map.WaypointImpl;
Expand Down Expand Up @@ -51,12 +52,17 @@ public WaypointEditorScreen() {
}

buttonExpandAll = new SimpleButton(topPanel, List.of(Component.translatable("gui.expand_all"), hotkeyTooltip("="), hotkeyTooltip("+")), Icons.UP,
(widget, button) -> toggleAll(false));
buttonCollapseAll = new SimpleButton(topPanel, List.of(Component.translatable("gui.collapse_all"), hotkeyTooltip("-")), Icons.DOWN,
(widget, button) -> toggleAll(true));
buttonCollapseAll = new SimpleButton(topPanel, List.of(Component.translatable("gui.collapse_all"), hotkeyTooltip("-")), Icons.DOWN,
(widget, button) -> toggleAll(false));
}

private void toggleAll(boolean collapsed) {
boolean allOpen = this.collapsed.values().stream().noneMatch(b -> b);
//Don't try and re-render if everything is already open
if (allOpen && !collapsed) {
return;
}
this.collapsed.keySet().forEach(levelResourceKey -> this.collapsed.put(levelResourceKey, collapsed));
scrollBar.setValue(0);
getGui().refreshWidgets();
Expand All @@ -77,6 +83,19 @@ public boolean onInit() {
return true;
}

@Override
public boolean keyPressed(Key key) {
if (super.keyPressed(key)) {
return true;
} else if (key.is(InputConstants.KEY_ADD) || key.is(InputConstants.KEY_EQUALS)) {
toggleAll(false);
} else if (key.is(InputConstants.KEY_MINUS) || key.is(GLFW.GLFW_KEY_KP_SUBTRACT)) {
toggleAll(true);
}
return false;
}


@Override
protected int getTopPanelHeight() {
return 22;
Expand Down Expand Up @@ -238,7 +257,7 @@ public void setWidth(int newWidth) {
distField.setPos(hideButton.getPosX() - 5 - distField.width, yOff);

nameField.setPos(5, yOff);
nameField.setText(ClientTextComponentUtils.ellipsize(getTheme().getFont(), Component.literal(wp.getName()),distField.getPosX() - 5).getString());
nameField.setText(ClientTextComponentUtils.ellipsize(getTheme().getFont(), Component.literal(wp.getName()), distField.getPosX() - 5).getString());
nameField.setHeight(getTheme().getFontHeight() + 2);
}
}
Expand Down

0 comments on commit cf467e3

Please sign in to comment.