ConfirmExperimentalFeaturesScreen.java
net.minecraft.client.gui.screens.worldselection.ConfirmExperimentalFeaturesScreen
信息
- 全限定名:net.minecraft.client.gui.screens.worldselection.ConfirmExperimentalFeaturesScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.worldselection
- 源码路径:src/main/java/net/minecraft/client/gui/screens/worldselection/ConfirmExperimentalFeaturesScreen.java
- 起始行号:L31
- 继承:Screen
- 职责:
TODO
字段/常量
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
MESSAGE- 类型:
Component - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
DETAILS_BUTTON- 类型:
Component - 修饰符:
private static final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
COLUMN_SPACING- 类型:
int - 修饰符:
private static final - 源码定位:
L35 - 说明:
TODO
- 类型:
-
DETAILS_BUTTON_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
callback- 类型:
BooleanConsumer - 修饰符:
private final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
enabledPacks- 类型:
Collection<Pack> - 修饰符:
private final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
layout- 类型:
GridLayout - 修饰符:
private final - 源码定位:
L39 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.gui.screens.worldselection.ConfirmExperimentalFeaturesScreen.DetailsScreen- 类型:
class - 修饰符:
private - 源码定位:
L83 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.screens.worldselection.ConfirmExperimentalFeaturesScreen.DetailsScreen.PackList- 类型:
class - 修饰符:
private - 源码定位:
L121 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.screens.worldselection.ConfirmExperimentalFeaturesScreen.DetailsScreen.PackListEntry- 类型:
class - 修饰符:
private - 源码定位:
L147 - 说明:
TODO
- 类型:
构造器
public ConfirmExperimentalFeaturesScreen(Collection<Pack> enabledPacks, BooleanConsumer callback) @ L41
- 构造器名:ConfirmExperimentalFeaturesScreen
- 源码定位:L41
- 修饰符:public
参数:
- enabledPacks: Collection
- callback: BooleanConsumer
说明:
TODO
方法
下面的方法块按源码顺序生成。
public Component getNarrationMessage() @ L47
- 方法名:getNarrationMessage
- 源码定位:L47
- 返回类型:Component
- 修饰符:public
参数:
- 无
说明:
TODO
protected void init() @ L52
- 方法名:init
- 源码定位:L52
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void repositionElements() @ L72
- 方法名:repositionElements
- 源码定位:L72
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void onClose() @ L77
- 方法名:onClose
- 源码定位:L77
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ConfirmExperimentalFeaturesScreen extends Screen {
private static final Component TITLE = Component.translatable("selectWorld.experimental.title");
private static final Component MESSAGE = Component.translatable("selectWorld.experimental.message");
private static final Component DETAILS_BUTTON = Component.translatable("selectWorld.experimental.details");
private static final int COLUMN_SPACING = 10;
private static final int DETAILS_BUTTON_WIDTH = 100;
private final BooleanConsumer callback;
private final Collection<Pack> enabledPacks;
private final GridLayout layout = new GridLayout().columnSpacing(10).rowSpacing(20);
public ConfirmExperimentalFeaturesScreen(Collection<Pack> enabledPacks, BooleanConsumer callback) {
super(TITLE);
this.enabledPacks = enabledPacks;
this.callback = callback;
}
@Override
public Component getNarrationMessage() {
return CommonComponents.joinForNarration(super.getNarrationMessage(), MESSAGE);
}
@Override
protected void init() {
super.init();
GridLayout.RowHelper helper = this.layout.createRowHelper(2);
LayoutSettings centered = helper.newCellSettings().alignHorizontallyCenter();
helper.addChild(new StringWidget(this.title, this.font), 2, centered);
MultiLineTextWidget messageLabel = helper.addChild(new MultiLineTextWidget(MESSAGE, this.font).setCentered(true), 2, centered);
messageLabel.setMaxWidth(310);
helper.addChild(
Button.builder(DETAILS_BUTTON, button -> this.minecraft.setScreen(new ConfirmExperimentalFeaturesScreen.DetailsScreen())).width(100).build(),
2,
centered
);
helper.addChild(Button.builder(CommonComponents.GUI_PROCEED, button -> this.callback.accept(true)).build());
helper.addChild(Button.builder(CommonComponents.GUI_BACK, button -> this.callback.accept(false)).build());
this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
this.layout.arrangeElements();
this.repositionElements();
}
@Override
protected void repositionElements() {
FrameLayout.alignInRectangle(this.layout, 0, 0, this.width, this.height, 0.5F, 0.5F);
}
@Override
public void onClose() {
this.callback.accept(false);
}
@OnlyIn(Dist.CLIENT)
private class DetailsScreen extends Screen {
private static final Component TITLE = Component.translatable("selectWorld.experimental.details.title");
private final HeaderAndFooterLayout layout;
private ConfirmExperimentalFeaturesScreen.DetailsScreen.@Nullable PackList list;
private DetailsScreen() {
Objects.requireNonNull(ConfirmExperimentalFeaturesScreen.this);
super(TITLE);
this.layout = new HeaderAndFooterLayout(this);
}
@Override
protected void init() {
this.layout.addTitleHeader(TITLE, this.font);
this.list = this.layout
.addToContents(
new ConfirmExperimentalFeaturesScreen.DetailsScreen.PackList(this.minecraft, ConfirmExperimentalFeaturesScreen.this.enabledPacks)
);
this.layout.addToFooter(Button.builder(CommonComponents.GUI_BACK, button -> this.onClose()).build());
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
public void onClose() {
this.minecraft.setScreen(ConfirmExperimentalFeaturesScreen.this);
}
@OnlyIn(Dist.CLIENT)
private class PackList extends ObjectSelectionList<ConfirmExperimentalFeaturesScreen.DetailsScreen.PackListEntry> {
public PackList(Minecraft minecraft, Collection<Pack> selectedPacks) {
Objects.requireNonNull(DetailsScreen.this);
super(
minecraft, DetailsScreen.this.width, DetailsScreen.this.layout.getContentHeight(), DetailsScreen.this.layout.getHeaderHeight(), (9 + 2) * 3
);
for (Pack pack : selectedPacks) {
String nonVanillaFeatures = FeatureFlags.printMissingFlags(FeatureFlags.VANILLA_SET, pack.getRequestedFeatures());
if (!nonVanillaFeatures.isEmpty()) {
Component title = ComponentUtils.mergeStyles(pack.getTitle(), Style.EMPTY.withBold(true));
Component message = Component.translatable("selectWorld.experimental.details.entry", nonVanillaFeatures);
this.addEntry(
DetailsScreen.this.new PackListEntry(title, message, MultiLineLabel.create(DetailsScreen.this.font, message, this.getRowWidth()))
);
}
}
}
@Override
public int getRowWidth() {
return this.width * 3 / 4;
}
}
@OnlyIn(Dist.CLIENT)
private class PackListEntry extends ObjectSelectionList.Entry<ConfirmExperimentalFeaturesScreen.DetailsScreen.PackListEntry> {
private final Component packId;
private final Component message;
private final MultiLineLabel splitMessage;
private PackListEntry(Component packId, Component message, MultiLineLabel splitMessage) {
Objects.requireNonNull(DetailsScreen.this);
super();
this.packId = packId;
this.message = message;
this.splitMessage = splitMessage;
}
@Override
public void extractContent(GuiGraphicsExtractor graphics, int mouseX, int mouseY, boolean hovered, float a) {
ActiveTextCollector textRenderer = graphics.textRenderer();
graphics.text(DetailsScreen.this.minecraft.font, this.packId, this.getContentX(), this.getContentY(), -1);
this.splitMessage.visitLines(TextAlignment.LEFT, this.getContentX(), this.getContentY() + 12, 9, textRenderer);
}
@Override
public Component getNarration() {
return Component.translatable("narrator.select", CommonComponents.joinForNarration(this.packId, this.message));
}
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
MultiLineLabel.create()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
MultiLineTextWidget()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringWidget()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FrameLayout.alignInRectangle()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
GridLayout()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
HeaderAndFooterLayout()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CommonComponents.joinForNarration()
- 引用位置:
-
- 引用位置:
字段/方法调用/返回值 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ComponentUtils.mergeStyles()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FeatureFlags.printMissingFlags()
- 引用位置: