| 1 | package net.minecraft.client.gui.screens.reporting;
|
| 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.components.MultiLineTextWidget;
|
| 7 | import net.minecraft.client.gui.components.StringWidget;
|
| 8 | import net.minecraft.client.gui.components.Tooltip;
|
| 9 | import net.minecraft.client.gui.layouts.FrameLayout;
|
| 10 | import net.minecraft.client.gui.layouts.LinearLayout;
|
| 11 | import net.minecraft.client.gui.layouts.SpacerElement;
|
| 12 | import net.minecraft.client.gui.screens.Screen;
|
| 13 | import net.minecraft.client.gui.screens.social.PlayerEntry;
|
| 14 | import net.minecraft.client.multiplayer.chat.report.ReportingContext;
|
| 15 | import net.minecraft.network.chat.CommonComponents;
|
| 16 | import net.minecraft.network.chat.Component;
|
| 17 |
|
| 18 | @Environment(EnvType.CLIENT)
|
| 19 | public class ReportPlayerScreen extends Screen {
|
| 20 | private static final Component TITLE = Component.translatable("gui.abuseReport.title");
|
| 21 | private static final Component MESSAGE = Component.translatable("gui.abuseReport.message");
|
| 22 | private static final Component REPORT_CHAT = Component.translatable("gui.abuseReport.type.chat");
|
| 23 | private static final Component REPORT_SKIN = Component.translatable("gui.abuseReport.type.skin");
|
| 24 | private static final Component REPORT_NAME = Component.translatable("gui.abuseReport.type.name");
|
| 25 | private static final int SPACING = 6;
|
| 26 | private final Screen lastScreen;
|
| 27 | private final ReportingContext context;
|
| 28 | private final PlayerEntry player;
|
| 29 | private final boolean chatDisabledOrBlocked;
|
| 30 | private final LinearLayout layout = LinearLayout.vertical().spacing(6);
|
| 31 |
|
| 32 | public ReportPlayerScreen(final Screen lastScreen, final ReportingContext context, final PlayerEntry player, final boolean chatDisabledOrBlocked) {
|
| 33 | super(TITLE);
|
| 34 | this.lastScreen = lastScreen;
|
| 35 | this.context = context;
|
| 36 | this.player = player;
|
| 37 | this.chatDisabledOrBlocked = chatDisabledOrBlocked;
|
| 38 | }
|
| 39 |
|
| 40 | @Override
|
| 41 | public Component getNarrationMessage() {
|
| 42 | return CommonComponents.joinForNarration(super.getNarrationMessage(), MESSAGE);
|
| 43 | }
|
| 44 |
|
| 45 | @Override
|
| 46 | protected void init() {
|
| 47 | this.layout.defaultCellSetting().alignHorizontallyCenter();
|
| 48 | this.layout.addChild(new StringWidget(this.title, this.font), this.layout.newCellSettings().paddingBottom(6));
|
| 49 | this.layout.addChild(new MultiLineTextWidget(MESSAGE, this.font).setCentered(true), this.layout.newCellSettings().paddingBottom(6));
|
| 50 | Button chatButton = this.layout
|
| 51 | .addChild(
|
| 52 | Button.builder(REPORT_CHAT, var1x -> this.minecraft.gui.setScreen(new ChatReportScreen(this.lastScreen, this.context, this.player.getPlayerId()))).build()
|
| 53 | );
|
| 54 | if (this.chatDisabledOrBlocked) {
|
| 55 | chatButton.active = false;
|
| 56 | chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.chat_disabled_or_blocked")));
|
| 57 | } else if (!this.player.isChatReportable()) {
|
| 58 | chatButton.active = false;
|
| 59 | chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.not_reportable")));
|
| 60 | } else if (!this.player.hasRecentMessages()) {
|
| 61 | chatButton.active = false;
|
| 62 | chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.no_messages", this.player.getPlayerName())));
|
| 63 | }
|
| 64 |
|
| 65 | this.layout
|
| 66 | .addChild(
|
| 67 | Button.builder(
|
| 68 | REPORT_SKIN,
|
| 69 | var1x -> this.minecraft.gui.setScreen(new SkinReportScreen(this.lastScreen, this.context, this.player.getPlayerId(), this.player.getSkinGetter()))
|
| 70 | )
|
| 71 | .build()
|
| 72 | );
|
| 73 | this.layout
|
| 74 | .addChild(
|
| 75 | Button.builder(
|
| 76 | REPORT_NAME,
|
| 77 | b -> this.minecraft.gui.setScreen(new NameReportScreen(this.lastScreen, this.context, this.player.getPlayerId(), this.player.getPlayerName()))
|
| 78 | )
|
| 79 | .build()
|
| 80 | );
|
| 81 | this.layout.addChild(SpacerElement.height(20));
|
| 82 | this.layout.addChild(Button.builder(CommonComponents.GUI_CANCEL, b -> this.onClose()).build());
|
| 83 | this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
|
| 84 | this.repositionElements();
|
| 85 | }
|
| 86 |
|
| 87 | @Override
|
| 88 | protected void repositionElements() {
|
| 89 | this.layout.arrangeElements();
|
| 90 | FrameLayout.centerInRectangle(this.layout, this.getRectangle());
|
| 91 | }
|
| 92 |
|
| 93 | @Override
|
| 94 | public void onClose() {
|
| 95 | this.minecraft.gui.setScreen(this.lastScreen);
|
| 96 | }
|
| 97 | }
|
| 98 |
|