mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-31 18:18:04 +01:00
Add VFPScreen#addRefreshButton
This commit is contained in:
parent
b076971686
commit
12bafd99f5
@ -49,7 +49,7 @@ import java.awt.*;
|
||||
* <li>{@link #setupSubtitle(Text, ButtonWidget.PressAction)}</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Automatically adds a button when set inside the constructor</li>
|
||||
* <li>Automatically adds a back button when set inside the constructor</li>
|
||||
* <li>Helper functions:
|
||||
* <ul>
|
||||
* <li>{@link #playClickSound()}</li>
|
||||
@ -156,6 +156,13 @@ public class VFPScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
public void addRefreshButton(final Runnable click) {
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.refresh"), button -> {
|
||||
click.run();
|
||||
client.setScreen(this);
|
||||
}).position(width - 60 - 5, 5).size(60, 20).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
@ -67,10 +67,7 @@ public class BetaCraftScreen extends VFPScreen {
|
||||
this.setupSubtitle(Text.of(BETA_CRAFT_SERVER_LIST_URL), ConfirmLinkScreen.opening(this, BETA_CRAFT_SERVER_LIST_URL));
|
||||
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, -5, (textRenderer.fontHeight + 2) * 3));
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.refresh"), button -> {
|
||||
SERVER_LIST = null;
|
||||
client.setScreen(this);
|
||||
}).position(width - 60 - 5, 5).size(60, 20).build());
|
||||
this.addRefreshButton(() -> SERVER_LIST = null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,10 +102,7 @@ public class BedrockRealmsScreen extends VFPScreen {
|
||||
}
|
||||
this.addDrawableChild(slotList = new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, 30, (textRenderer.fontHeight + 2) * 4));
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.refresh"), button -> {
|
||||
realmsWorlds = null;
|
||||
client.setScreen(this);
|
||||
}).position(width - 60 - 5, 5).size(60, 20).build());
|
||||
this.addRefreshButton(() -> realmsWorlds = null);
|
||||
|
||||
final int slotWidth = 360 - 4;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user