ReportPlayerScreen.java

net.minecraft.client.gui.screens.reporting.ReportPlayerScreen

信息

  • 全限定名:net.minecraft.client.gui.screens.reporting.ReportPlayerScreen
  • 类型:public class
  • 包:net.minecraft.client.gui.screens.reporting
  • 源码路径:src/main/java/net/minecraft/client/gui/screens/reporting/ReportPlayerScreen.java
  • 起始行号:L19
  • 继承:Screen
  • 职责:

    TODO

字段/常量

  • TITLE

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L20
    • 说明:

      TODO

  • MESSAGE

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L21
    • 说明:

      TODO

  • REPORT_CHAT

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L22
    • 说明:

      TODO

  • REPORT_SKIN

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L23
    • 说明:

      TODO

  • REPORT_NAME

    • 类型: Component
    • 修饰符: private static final
    • 源码定位: L24
    • 说明:

      TODO

  • SPACING

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L25
    • 说明:

      TODO

  • lastScreen

    • 类型: Screen
    • 修饰符: private final
    • 源码定位: L26
    • 说明:

      TODO

  • context

    • 类型: ReportingContext
    • 修饰符: private final
    • 源码定位: L27
    • 说明:

      TODO

  • player

    • 类型: PlayerEntry
    • 修饰符: private final
    • 源码定位: L28
    • 说明:

      TODO

  • chatDisabledOrBlocked

    • 类型: boolean
    • 修饰符: private final
    • 源码定位: L29
    • 说明:

      TODO

  • layout

    • 类型: LinearLayout
    • 修饰符: private final
    • 源码定位: L30
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ReportPlayerScreen(Screen lastScreen, ReportingContext context, PlayerEntry player, boolean chatDisabledOrBlocked) @ L32

  • 构造器名:ReportPlayerScreen
  • 源码定位:L32
  • 修饰符:public

参数:

  • lastScreen: Screen
  • context: ReportingContext
  • player: PlayerEntry
  • chatDisabledOrBlocked: boolean

说明:

TODO

方法

下面的方法块按源码顺序生成。

public Component getNarrationMessage() @ L40

  • 方法名:getNarrationMessage
  • 源码定位:L40
  • 返回类型:Component
  • 修饰符:public

参数:

说明:

TODO

protected void init() @ L45

  • 方法名:init
  • 源码定位:L45
  • 返回类型:void
  • 修饰符:protected

参数:

说明:

TODO

protected void repositionElements() @ L90

  • 方法名:repositionElements
  • 源码定位:L90
  • 返回类型:void
  • 修饰符:protected

参数:

说明:

TODO

public void onClose() @ L96

  • 方法名:onClose
  • 源码定位:L96
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ReportPlayerScreen extends Screen {
    private static final Component TITLE = Component.translatable("gui.abuseReport.title");
    private static final Component MESSAGE = Component.translatable("gui.abuseReport.message");
    private static final Component REPORT_CHAT = Component.translatable("gui.abuseReport.type.chat");
    private static final Component REPORT_SKIN = Component.translatable("gui.abuseReport.type.skin");
    private static final Component REPORT_NAME = Component.translatable("gui.abuseReport.type.name");
    private static final int SPACING = 6;
    private final Screen lastScreen;
    private final ReportingContext context;
    private final PlayerEntry player;
    private final boolean chatDisabledOrBlocked;
    private final LinearLayout layout = LinearLayout.vertical().spacing(6);
 
    public ReportPlayerScreen(Screen lastScreen, ReportingContext context, PlayerEntry player, boolean chatDisabledOrBlocked) {
        super(TITLE);
        this.lastScreen = lastScreen;
        this.context = context;
        this.player = player;
        this.chatDisabledOrBlocked = chatDisabledOrBlocked;
    }
 
    @Override
    public Component getNarrationMessage() {
        return CommonComponents.joinForNarration(super.getNarrationMessage(), MESSAGE);
    }
 
    @Override
    protected void init() {
        this.layout.defaultCellSetting().alignHorizontallyCenter();
        this.layout.addChild(new StringWidget(this.title, this.font), this.layout.newCellSettings().paddingBottom(6));
        this.layout.addChild(new MultiLineTextWidget(MESSAGE, this.font).setCentered(true), this.layout.newCellSettings().paddingBottom(6));
        Button chatButton = this.layout
            .addChild(
                Button.builder(REPORT_CHAT, b -> this.minecraft.setScreen(new ChatReportScreen(this.lastScreen, this.context, this.player.getPlayerId())))
                    .build()
            );
        if (this.chatDisabledOrBlocked) {
            chatButton.active = false;
            chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.chat_disabled_or_blocked")));
        } else if (!this.player.isChatReportable()) {
            chatButton.active = false;
            chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.not_reportable")));
        } else if (!this.player.hasRecentMessages()) {
            chatButton.active = false;
            chatButton.setTooltip(Tooltip.create(Component.translatable("gui.socialInteractions.tooltip.report.no_messages", this.player.getPlayerName())));
        }
 
        this.layout
            .addChild(
                Button.builder(
                        REPORT_SKIN,
                        b -> this.minecraft
                            .setScreen(new SkinReportScreen(this.lastScreen, this.context, this.player.getPlayerId(), this.player.getSkinGetter()))
                    )
                    .build()
            );
        this.layout
            .addChild(
                Button.builder(
                        REPORT_NAME,
                        b -> this.minecraft
                            .setScreen(new NameReportScreen(this.lastScreen, this.context, this.player.getPlayerId(), this.player.getPlayerName()))
                    )
                    .build()
            );
        this.layout.addChild(SpacerElement.height(20));
        this.layout.addChild(Button.builder(CommonComponents.GUI_CANCEL, b -> this.onClose()).build());
        this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
        this.repositionElements();
    }
 
    @Override
    protected void repositionElements() {
        this.layout.arrangeElements();
        FrameLayout.centerInRectangle(this.layout, this.getRectangle());
    }
 
    @Override
    public void onClose() {
        this.minecraft.setScreen(this.lastScreen);
    }
}

引用的其他类

  • Button

    • 引用位置: 方法调用
    • 关联成员: Button.builder()
  • MultiLineTextWidget

    • 引用位置: 构造调用
    • 关联成员: MultiLineTextWidget()
  • StringWidget

    • 引用位置: 构造调用
    • 关联成员: StringWidget()
  • Tooltip

    • 引用位置: 方法调用
    • 关联成员: Tooltip.create()
  • FrameLayout

    • 引用位置: 方法调用
    • 关联成员: FrameLayout.centerInRectangle()
  • LinearLayout

    • 引用位置: 字段/方法调用
    • 关联成员: LinearLayout.vertical()
  • SpacerElement

    • 引用位置: 方法调用
    • 关联成员: SpacerElement.height()
  • Screen

    • 引用位置: 参数/字段/继承
  • ChatReportScreen

    • 引用位置: 构造调用
    • 关联成员: ChatReportScreen()
  • NameReportScreen

    • 引用位置: 构造调用
    • 关联成员: NameReportScreen()
  • SkinReportScreen

    • 引用位置: 构造调用
    • 关联成员: SkinReportScreen()
  • PlayerEntry

    • 引用位置: 参数/字段
  • ReportingContext

    • 引用位置: 参数/字段
  • CommonComponents

    • 引用位置: 方法调用
    • 关联成员: CommonComponents.joinForNarration()
  • Component

    • 引用位置: 字段/方法调用/返回值
    • 关联成员: Component.translatable()