RealmsSelectFileToUploadScreen.java

com.mojang.realmsclient.gui.screens.RealmsSelectFileToUploadScreen

信息

  • 全限定名:com.mojang.realmsclient.gui.screens.RealmsSelectFileToUploadScreen
  • 类型:public class
  • 包:com.mojang.realmsclient.gui.screens
  • 源码路径:src/main/java/com/mojang/realmsclient/gui/screens/RealmsSelectFileToUploadScreen.java
  • 起始行号:L21
  • 继承:RealmsScreen
  • 职责:

    TODO

字段/常量

  • LOGGER

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

      TODO

  • TITLE

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

      TODO

  • UNABLE_TO_LOAD_WORLD

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

      TODO

  • realmCreationTask

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

      TODO

  • lastScreen

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

      TODO

  • realmId

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

      TODO

  • slotId

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

      TODO

  • layout

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

      TODO

  • searchBox

    • 类型: EditBox
    • 修饰符: protected
    • 源码定位: L30
    • 说明:

      TODO

  • list

    • 类型: WorldSelectionList
    • 修饰符: private
    • 源码定位: L31
    • 说明:

      TODO

  • uploadButton

    • 类型: Button
    • 修饰符: private
    • 源码定位: L32
    • 说明:

      TODO

内部类/嵌套类型

构造器

public RealmsSelectFileToUploadScreen(RealmCreationTask realmCreationTask, long realmId, int slotId, RealmsResetWorldScreen lastScreen) @ L34

  • 构造器名:RealmsSelectFileToUploadScreen
  • 源码定位:L34
  • 修饰符:public

参数:

  • realmCreationTask: RealmCreationTask
  • realmId: long
  • slotId: int
  • lastScreen: RealmsResetWorldScreen

说明:

TODO

方法

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

public void init() @ L42

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

参数:

说明:

TODO

protected void repositionElements() @ L86

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

参数:

说明:

TODO

protected void setInitialFocus() @ L95

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

参数:

说明:

TODO

private void updateButtonState(LevelSummary ignored) @ L100

  • 方法名:updateButtonState
  • 源码定位:L100
  • 返回类型:void
  • 修饰符:private

参数:

  • ignored: LevelSummary

说明:

TODO

private void upload(WorldSelectionList.WorldListEntry worldListEntry) @ L106

  • 方法名:upload
  • 源码定位:L106
  • 返回类型:void
  • 修饰符:private

参数:

  • worldListEntry: WorldSelectionList.WorldListEntry

说明:

TODO

public void onClose() @ L110

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class RealmsSelectFileToUploadScreen extends RealmsScreen {
    private static final Logger LOGGER = LogUtils.getLogger();
    public static final Component TITLE = Component.translatable("mco.upload.select.world.title");
    private static final Component UNABLE_TO_LOAD_WORLD = Component.translatable("selectWorld.unable_to_load");
    private final @Nullable RealmCreationTask realmCreationTask;
    private final RealmsResetWorldScreen lastScreen;
    private final long realmId;
    private final int slotId;
    private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this, 8 + 9 + 8 + 20 + 4, 33);
    protected @Nullable EditBox searchBox;
    private @Nullable WorldSelectionList list;
    private @Nullable Button uploadButton;
 
    public RealmsSelectFileToUploadScreen(@Nullable RealmCreationTask realmCreationTask, long realmId, int slotId, RealmsResetWorldScreen lastScreen) {
        super(TITLE);
        this.realmCreationTask = realmCreationTask;
        this.lastScreen = lastScreen;
        this.realmId = realmId;
        this.slotId = slotId;
    }
 
    @Override
    public void init() {
        LinearLayout header = this.layout.addToHeader(LinearLayout.vertical().spacing(4));
        header.defaultCellSetting().alignHorizontallyCenter();
        header.addChild(new StringWidget(this.title, this.font));
        this.searchBox = header.addChild(
            new EditBox(this.font, this.width / 2 - 100, 22, 200, 20, this.searchBox, Component.translatable("selectWorld.search"))
        );
        this.searchBox.setResponder(value -> {
            if (this.list != null) {
                this.list.updateFilter(value);
            }
        });
 
        try {
            this.list = this.layout
                .addToContents(
                    new WorldSelectionList.Builder(this.minecraft, this)
                        .width(this.width)
                        .height(this.layout.getContentHeight())
                        .filter(this.searchBox.getValue())
                        .oldList(this.list)
                        .uploadWorld()
                        .onEntrySelect(this::updateButtonState)
                        .onEntryInteract(this::upload)
                        .build()
                );
        } catch (Exception var4) {
            LOGGER.error("Couldn't load level list", (Throwable)var4);
            this.minecraft.setScreen(new RealmsGenericErrorScreen(UNABLE_TO_LOAD_WORLD, Component.nullToEmpty(var4.getMessage()), this.lastScreen));
            return;
        }
 
        LinearLayout footer = this.layout.addToFooter(LinearLayout.horizontal().spacing(8));
        footer.defaultCellSetting().alignHorizontallyCenter();
        this.uploadButton = footer.addChild(
            Button.builder(Component.translatable("mco.upload.button.name"), button -> this.list.getSelectedOpt().ifPresent(this::upload)).build()
        );
        footer.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).build());
        this.updateButtonState(null);
        this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
        this.repositionElements();
    }
 
    @Override
    protected void repositionElements() {
        if (this.list != null) {
            this.list.updateSize(this.width, this.layout);
        }
 
        this.layout.arrangeElements();
    }
 
    @Override
    protected void setInitialFocus() {
        this.setInitialFocus(this.searchBox);
    }
 
    private void updateButtonState(@Nullable LevelSummary ignored) {
        if (this.list != null && this.uploadButton != null) {
            this.uploadButton.active = this.list.getSelected() != null;
        }
    }
 
    private void upload(WorldSelectionList.WorldListEntry worldListEntry) {
        this.minecraft.setScreen(new RealmsUploadScreen(this.realmCreationTask, this.realmId, this.slotId, this.lastScreen, worldListEntry.getLevelSummary()));
    }
 
    @Override
    public void onClose() {
        this.minecraft.setScreen(this.lastScreen);
    }
}

引用的其他类

  • RealmsGenericErrorScreen

    • 引用位置: 构造调用
    • 关联成员: RealmsGenericErrorScreen()
  • RealmsResetWorldScreen

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

    • 引用位置: 构造调用
    • 关联成员: RealmsUploadScreen()
  • RealmCreationTask

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

    • 引用位置: 字段/方法调用
    • 关联成员: Button.builder()
  • EditBox

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

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

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

    • 引用位置: 方法调用
    • 关联成员: LinearLayout.horizontal(), LinearLayout.vertical()
  • WorldSelectionList

    • 引用位置: 参数/字段/方法调用/构造调用
    • 关联成员: Builder(), WorldSelectionList.Builder()
  • Component

    • 引用位置: 字段/方法调用
    • 关联成员: Component.nullToEmpty(), Component.translatable()
  • RealmsScreen

    • 引用位置: 继承
  • LevelSummary

    • 引用位置: 参数