NoticeWithLinkScreen.java

net.minecraft.client.gui.screens.NoticeWithLinkScreen

信息

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

    TODO

字段/常量

  • SYMLINK_WORLD_TITLE

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

      TODO

  • SYMLINK_WORLD_MESSAGE_TEXT

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

      TODO

  • SYMLINK_PACK_TITLE

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

      TODO

  • SYMLINK_PACK_MESSAGE_TEXT

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

      TODO

  • message

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

      TODO

  • uri

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

      TODO

  • onClose

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

      TODO

  • layout

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

      TODO

内部类/嵌套类型

构造器

public NoticeWithLinkScreen(Component title, Component message, URI uri, Runnable onClose) @ L32

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

参数:

  • title: Component
  • message: Component
  • uri: URI
  • onClose: Runnable

说明:

TODO

方法

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

public static Screen createWorldSymlinkWarningScreen(Runnable onClose) @ L39

  • 方法名:createWorldSymlinkWarningScreen
  • 源码定位:L39
  • 返回类型:Screen
  • 修饰符:public static

参数:

  • onClose: Runnable

说明:

TODO

public static Screen createPackSymlinkWarningScreen(Runnable onClose) @ L43

  • 方法名:createPackSymlinkWarningScreen
  • 源码定位:L43
  • 返回类型:Screen
  • 修饰符:public static

参数:

  • onClose: Runnable

说明:

TODO

protected void init() @ L47

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

参数:

说明:

TODO

protected void repositionElements() @ L69

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

参数:

说明:

TODO

public Component getNarrationMessage() @ L75

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

参数:

说明:

TODO

public void onClose() @ L80

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class NoticeWithLinkScreen extends Screen {
    private static final Component SYMLINK_WORLD_TITLE = Component.translatable("symlink_warning.title.world").withStyle(ChatFormatting.BOLD);
    private static final Component SYMLINK_WORLD_MESSAGE_TEXT = Component.translatable(
        "symlink_warning.message.world", Component.translationArg(CommonLinks.SYMLINK_HELP)
    );
    private static final Component SYMLINK_PACK_TITLE = Component.translatable("symlink_warning.title.pack").withStyle(ChatFormatting.BOLD);
    private static final Component SYMLINK_PACK_MESSAGE_TEXT = Component.translatable(
        "symlink_warning.message.pack", Component.translationArg(CommonLinks.SYMLINK_HELP)
    );
    private final Component message;
    private final URI uri;
    private final Runnable onClose;
    private final GridLayout layout = new GridLayout().rowSpacing(10);
 
    public NoticeWithLinkScreen(Component title, Component message, URI uri, Runnable onClose) {
        super(title);
        this.message = message;
        this.uri = uri;
        this.onClose = onClose;
    }
 
    public static Screen createWorldSymlinkWarningScreen(Runnable onClose) {
        return new NoticeWithLinkScreen(SYMLINK_WORLD_TITLE, SYMLINK_WORLD_MESSAGE_TEXT, CommonLinks.SYMLINK_HELP, onClose);
    }
 
    public static Screen createPackSymlinkWarningScreen(Runnable onClose) {
        return new NoticeWithLinkScreen(SYMLINK_PACK_TITLE, SYMLINK_PACK_MESSAGE_TEXT, CommonLinks.SYMLINK_HELP, onClose);
    }
 
    @Override
    protected void init() {
        super.init();
        this.layout.defaultCellSetting().alignHorizontallyCenter();
        GridLayout.RowHelper rowHelper = this.layout.createRowHelper(1);
        rowHelper.addChild(new StringWidget(this.title, this.font));
        rowHelper.addChild(new MultiLineTextWidget(this.message, this.font).setMaxWidth(this.width - 50).setCentered(true));
        int buttonWidth = 120;
        GridLayout buttonGrid = new GridLayout().columnSpacing(5);
        GridLayout.RowHelper buttonRow = buttonGrid.createRowHelper(3);
        buttonRow.addChild(Button.builder(CommonComponents.GUI_OPEN_IN_BROWSER, button -> Util.getPlatform().openUri(this.uri)).size(120, 20).build());
        buttonRow.addChild(
            Button.builder(CommonComponents.GUI_COPY_LINK_TO_CLIPBOARD, button -> this.minecraft.keyboardHandler.setClipboard(this.uri.toString()))
                .size(120, 20)
                .build()
        );
        buttonRow.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).size(120, 20).build());
        rowHelper.addChild(buttonGrid);
        this.repositionElements();
        this.layout.visitWidgets(this::addRenderableWidget);
    }
 
    @Override
    protected void repositionElements() {
        this.layout.arrangeElements();
        FrameLayout.centerInRectangle(this.layout, this.getRectangle());
    }
 
    @Override
    public Component getNarrationMessage() {
        return CommonComponents.joinForNarration(super.getNarrationMessage(), this.message);
    }
 
    @Override
    public void onClose() {
        this.onClose.run();
    }
}

引用的其他类

  • Button

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

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

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

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

    • 引用位置: 字段/构造调用
    • 关联成员: GridLayout()
  • Screen

    • 引用位置: 继承/返回值
  • CommonComponents

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

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

    • 引用位置: 方法调用
    • 关联成员: Util.getPlatform()