| 1 | package net.minecraft.client.gui.screens;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.gui.components.Button;
|
| 6 | import net.minecraft.client.gui.layouts.HeaderAndFooterLayout;
|
| 7 | import net.minecraft.client.gui.layouts.LinearLayout;
|
| 8 | import net.minecraft.network.chat.CommonComponents;
|
| 9 | import net.minecraft.network.chat.Component;
|
| 10 | import net.minecraft.util.CommonLinks;
|
| 11 |
|
| 12 | @Environment(EnvType.CLIENT)
|
| 13 | public class CreditsAndAttributionScreen extends Screen {
|
| 14 | private static final int BUTTON_SPACING = 8;
|
| 15 | private static final int BUTTON_WIDTH = 210;
|
| 16 | private static final Component TITLE = Component.translatable("credits_and_attribution.screen.title");
|
| 17 | private static final Component CREDITS_BUTTON = Component.translatable("credits_and_attribution.button.credits");
|
| 18 | private static final Component ATTRIBUTION_BUTTON = Component.translatable("credits_and_attribution.button.attribution");
|
| 19 | private static final Component LICENSES_BUTTON = Component.translatable("credits_and_attribution.button.licenses");
|
| 20 | private final Screen lastScreen;
|
| 21 | private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this);
|
| 22 |
|
| 23 | public CreditsAndAttributionScreen(final Screen lastScreen) {
|
| 24 | super(TITLE);
|
| 25 | this.lastScreen = lastScreen;
|
| 26 | }
|
| 27 |
|
| 28 | @Override
|
| 29 | protected void init() {
|
| 30 | this.layout.addTitleHeader(TITLE, this.font);
|
| 31 | LinearLayout content = this.layout.addToContents(LinearLayout.vertical()).spacing(8);
|
| 32 | content.defaultCellSetting().alignHorizontallyCenter();
|
| 33 | content.addChild(Button.builder(CREDITS_BUTTON, button -> this.openCreditsScreen()).width(210).build());
|
| 34 | content.addChild(Button.builder(ATTRIBUTION_BUTTON, ConfirmLinkScreen.confirmLink(this, CommonLinks.ATTRIBUTION)).width(210).build());
|
| 35 | content.addChild(Button.builder(LICENSES_BUTTON, ConfirmLinkScreen.confirmLink(this, CommonLinks.LICENSES)).width(210).build());
|
| 36 | this.layout.addToFooter(Button.builder(CommonComponents.GUI_DONE, button -> this.onClose()).width(200).build());
|
| 37 | this.layout.arrangeElements();
|
| 38 | this.layout.visitWidgets(this::addRenderableWidget);
|
| 39 | }
|
| 40 |
|
| 41 | @Override
|
| 42 | protected void repositionElements() {
|
| 43 | this.layout.arrangeElements();
|
| 44 | }
|
| 45 |
|
| 46 | private void openCreditsScreen() {
|
| 47 | this.minecraft.gui.setScreen(new WinScreen(false, () -> this.minecraft.gui.setScreen(this)));
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | public void onClose() {
|
| 52 | this.minecraft.gui.setScreen(this.lastScreen);
|
| 53 | }
|
| 54 | }
|
| 55 |
|