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()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
RealmsUploadScreen()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
EditBox()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringWidget()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
HeaderAndFooterLayout()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
LinearLayout.horizontal(), LinearLayout.vertical()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用/构造调用 - 关联成员:
Builder(), WorldSelectionList.Builder()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.nullToEmpty(), Component.translatable()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置: