| 1 | package net.minecraft.client.gui.screens.reporting;
|
| 2 |
|
| 3 | import java.util.UUID;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.ChatFormatting;
|
| 7 | import net.minecraft.client.gui.components.MultiLineEditBox;
|
| 8 | import net.minecraft.client.gui.components.StringWidget;
|
| 9 | import net.minecraft.client.gui.layouts.CommonLayouts;
|
| 10 | import net.minecraft.client.gui.screens.Screen;
|
| 11 | import net.minecraft.client.input.MouseButtonEvent;
|
| 12 | import net.minecraft.client.multiplayer.chat.report.NameReport;
|
| 13 | import net.minecraft.client.multiplayer.chat.report.ReportingContext;
|
| 14 | import net.minecraft.network.chat.Component;
|
| 15 | import org.jspecify.annotations.Nullable;
|
| 16 |
|
| 17 | @Environment(EnvType.CLIENT)
|
| 18 | public class NameReportScreen extends AbstractReportScreen<NameReport.Builder> {
|
| 19 | private static final Component TITLE = Component.translatable("gui.abuseReport.name.title");
|
| 20 | private static final Component COMMENT_BOX_LABEL = Component.translatable("gui.abuseReport.name.comment_box_label");
|
| 21 | private @Nullable MultiLineEditBox commentBox;
|
| 22 |
|
| 23 | private NameReportScreen(final Screen lastScreen, final ReportingContext reportingContext, final NameReport.Builder reportBuilder) {
|
| 24 | super(TITLE, lastScreen, reportingContext, reportBuilder);
|
| 25 | }
|
| 26 |
|
| 27 | public NameReportScreen(final Screen lastScreen, final ReportingContext reportingContext, final UUID playerId, final String reportedName) {
|
| 28 | this(lastScreen, reportingContext, new NameReport.Builder(playerId, reportedName, reportingContext.sender().reportLimits()));
|
| 29 | }
|
| 30 |
|
| 31 | public NameReportScreen(final Screen lastScreen, final ReportingContext reportingContext, final NameReport draft) {
|
| 32 | this(lastScreen, reportingContext, new NameReport.Builder(draft, reportingContext.sender().reportLimits()));
|
| 33 | }
|
| 34 |
|
| 35 | @Override
|
| 36 | protected void addContent() {
|
| 37 | Component reportedName = Component.literal(this.reportBuilder.report().getReportedName()).withStyle(ChatFormatting.YELLOW);
|
| 38 | this.layout
|
| 39 | .addChild(
|
| 40 | new StringWidget(Component.translatable("gui.abuseReport.name.reporting", reportedName), this.font), s -> s.alignHorizontallyCenter().padding(0, 8)
|
| 41 | );
|
| 42 | this.commentBox = this.createCommentBox(280, 9 * 8, comments -> {
|
| 43 | this.reportBuilder.setComments(comments);
|
| 44 | this.onReportChanged();
|
| 45 | });
|
| 46 | this.layout.addChild(CommonLayouts.labeledElement(this.font, this.commentBox, COMMENT_BOX_LABEL, s -> s.paddingBottom(12)));
|
| 47 | }
|
| 48 |
|
| 49 | @Override
|
| 50 | public boolean mouseReleased(final MouseButtonEvent event) {
|
| 51 | if (super.mouseReleased(event)) {
|
| 52 | return true;
|
| 53 | } else {
|
| 54 | return this.commentBox != null ? this.commentBox.mouseReleased(event) : false;
|
| 55 | }
|
| 56 | }
|
| 57 | }
|
| 58 |
|