UnsupportedGraphicsWarningScreen.java
net.minecraft.client.gui.screens.options.UnsupportedGraphicsWarningScreen
信息
- 全限定名:net.minecraft.client.gui.screens.options.UnsupportedGraphicsWarningScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.options
- 源码路径:src/main/java/net/minecraft/client/gui/screens/options/UnsupportedGraphicsWarningScreen.java
- 起始行号:L18
- 继承:Screen
- 职责:
TODO
字段/常量
-
BUTTON_PADDING- 类型:
int - 修饰符:
private static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
BUTTON_MARGIN- 类型:
int - 修饰符:
private static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
BUTTON_HEIGHT- 类型:
int - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
narrationMessage- 类型:
Component - 修饰符:
private final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
message- 类型:
List<Component> - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
buttonOptions- 类型:
ImmutableList<UnsupportedGraphicsWarningScreen.ButtonOption> - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
messageLines- 类型:
MultiLineLabel - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
-
contentTop- 类型:
int - 修饰符:
private - 源码定位:
L26 - 说明:
TODO
- 类型:
-
buttonWidth- 类型:
int - 修饰符:
private - 源码定位:
L27 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.screens.options.UnsupportedGraphicsWarningScreen.ButtonOption- 类型:
class - 修饰符:
public static final - 源码定位:
L77 - 说明:
TODO
- 类型:
构造器
protected UnsupportedGraphicsWarningScreen(Component title, List<Component> message, ImmutableList<UnsupportedGraphicsWarningScreen.ButtonOption> buttonOptions) @ L29
- 构造器名:UnsupportedGraphicsWarningScreen
- 源码定位:L29
- 修饰符:protected
参数:
- title: Component
- message: List
- buttonOptions: ImmutableList<UnsupportedGraphicsWarningScreen.ButtonOption>
说明:
TODO
方法
下面的方法块按源码顺序生成。
public Component getNarrationMessage() @ L38
- 方法名:getNarrationMessage
- 源码定位:L38
- 返回类型:Component
- 修饰符:public
参数:
- 无
说明:
TODO
public void init() @ L43
- 方法名:init
- 源码定位:L43
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L63
- 方法名:extractRenderState
- 源码定位:L63
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public boolean shouldCloseOnEsc() @ L71
- 方法名:shouldCloseOnEsc
- 源码定位:L71
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class UnsupportedGraphicsWarningScreen extends Screen {
private static final int BUTTON_PADDING = 20;
private static final int BUTTON_MARGIN = 5;
private static final int BUTTON_HEIGHT = 20;
private final Component narrationMessage;
private final List<Component> message;
private final ImmutableList<UnsupportedGraphicsWarningScreen.ButtonOption> buttonOptions;
private MultiLineLabel messageLines = MultiLineLabel.EMPTY;
private int contentTop;
private int buttonWidth;
protected UnsupportedGraphicsWarningScreen(
Component title, List<Component> message, ImmutableList<UnsupportedGraphicsWarningScreen.ButtonOption> buttonOptions
) {
super(title);
this.message = message;
this.narrationMessage = CommonComponents.joinForNarration(title, ComponentUtils.formatList(message, CommonComponents.EMPTY));
this.buttonOptions = buttonOptions;
}
@Override
public Component getNarrationMessage() {
return this.narrationMessage;
}
@Override
public void init() {
for (UnsupportedGraphicsWarningScreen.ButtonOption buttonOption : this.buttonOptions) {
this.buttonWidth = Math.max(this.buttonWidth, 20 + this.font.width(buttonOption.message) + 20);
}
int buttonAdvance = 5 + this.buttonWidth + 5;
int contentWidth = buttonAdvance * this.buttonOptions.size();
this.messageLines = MultiLineLabel.create(this.font, contentWidth, this.message.toArray(new Component[0]));
int messageHeight = this.messageLines.getLineCount() * 9;
this.contentTop = (int)(this.height / 2.0 - messageHeight / 2.0);
int buttonTop = this.contentTop + messageHeight + 9 * 2;
int x = (int)(this.width / 2.0 - contentWidth / 2.0);
for (UnsupportedGraphicsWarningScreen.ButtonOption buttonOption : this.buttonOptions) {
this.addRenderableWidget(Button.builder(buttonOption.message, buttonOption.onPress).bounds(x, buttonTop, this.buttonWidth, 20).build());
x += buttonAdvance;
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
ActiveTextCollector textRenderer = graphics.textRenderer();
graphics.centeredText(this.font, this.title, this.width / 2, this.contentTop - 9 * 2, -1);
this.messageLines.visitLines(TextAlignment.CENTER, this.width / 2, this.contentTop, 9, textRenderer);
}
@Override
public boolean shouldCloseOnEsc() {
return false;
}
@OnlyIn(Dist.CLIENT)
public static final class ButtonOption {
private final Component message;
private final Button.OnPress onPress;
public ButtonOption(Component message, Button.OnPress onPress) {
this.message = message;
this.onPress = onPress;
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
MultiLineLabel.create()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CommonComponents.joinForNarration()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ComponentUtils.formatList()
- 引用位置: