AccessibilityOnboardingScreen.java
net.minecraft.client.gui.screens.AccessibilityOnboardingScreen
信息
- 全限定名:net.minecraft.client.gui.screens.AccessibilityOnboardingScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens
- 源码路径:src/main/java/net/minecraft/client/gui/screens/AccessibilityOnboardingScreen.java
- 起始行号:L31
- 继承:Screen
- 职责:
TODO
字段/常量
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
ONBOARDING_NARRATOR_MESSAGE- 类型:
Component - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
PADDING- 类型:
int - 修饰符:
private static final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
TITLE_PADDING- 类型:
int - 修饰符:
private static final - 源码定位:
L35 - 说明:
TODO
- 类型:
-
FADE_OUT_TIME- 类型:
float - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
TEXT_WIDGET_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
logoRenderer- 类型:
LogoRenderer - 修饰符:
private final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
options- 类型:
Options - 修饰符:
private final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
narratorAvailable- 类型:
boolean - 修饰符:
private final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
hasNarrated- 类型:
boolean - 修饰符:
private - 源码定位:
L41 - 说明:
TODO
- 类型:
-
timer- 类型:
float - 修饰符:
private - 源码定位:
L42 - 说明:
TODO
- 类型:
-
onClose- 类型:
Runnable - 修饰符:
private final - 源码定位:
L43 - 说明:
TODO
- 类型:
-
layout- 类型:
HeaderAndFooterLayout - 修饰符:
private final - 源码定位:
L44 - 说明:
TODO
- 类型:
-
focusableTextWidget- 类型:
FocusableTextWidget - 修饰符:
private - 源码定位:
L45 - 说明:
TODO
- 类型:
-
fadeInStart- 类型:
float - 修饰符:
private - 源码定位:
L46 - 说明:
TODO
- 类型:
-
fadingIn- 类型:
boolean - 修饰符:
private - 源码定位:
L47 - 说明:
TODO
- 类型:
-
fadeOutStart- 类型:
float - 修饰符:
private - 源码定位:
L48 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public AccessibilityOnboardingScreen(Options options, Runnable onClose) @ L50
- 构造器名:AccessibilityOnboardingScreen
- 源码定位:L50
- 修饰符:public
参数:
- options: Options
- onClose: Runnable
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void init() @ L58
- 方法名:init
- 源码定位:L58
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void repositionElements() @ L93
- 方法名:repositionElements
- 源码定位:L93
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void setInitialFocus() @ L102
- 方法名:setInitialFocus
- 源码定位:L102
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
private int initTitleYPos() @ L111
- 方法名:initTitleYPos
- 源码定位:L111
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
public void onClose() @ L115
- 方法名:onClose
- 源码定位:L115
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private void closeAndSetScreen(Screen screen) @ L122
- 方法名:closeAndSetScreen
- 源码定位:L122
- 返回类型:void
- 修饰符:private
参数:
- screen: Screen
说明:
TODO
private void close(boolean onboardingFinished, Runnable runnable) @ L126
- 方法名:close
- 源码定位:L126
- 返回类型:void
- 修饰符:private
参数:
- onboardingFinished: boolean
- runnable: Runnable
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L135
- 方法名:extractRenderState
- 源码定位:L135
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
protected boolean panoramaShouldSpin() @ L174
- 方法名:panoramaShouldSpin
- 源码定位:L174
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
private void handleInitialNarrationDelay() @ L179
- 方法名:handleInitialNarrationDelay
- 源码定位:L179
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class AccessibilityOnboardingScreen extends Screen {
private static final Component TITLE = Component.translatable("accessibility.onboarding.screen.title");
private static final Component ONBOARDING_NARRATOR_MESSAGE = Component.translatable("accessibility.onboarding.screen.narrator");
private static final int PADDING = 4;
private static final int TITLE_PADDING = 16;
private static final float FADE_OUT_TIME = 1000.0F;
private static final int TEXT_WIDGET_WIDTH = 374;
private final LogoRenderer logoRenderer;
private final Options options;
private final boolean narratorAvailable;
private boolean hasNarrated;
private float timer;
private final Runnable onClose;
private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this, this.initTitleYPos(), 33);
private @Nullable FocusableTextWidget focusableTextWidget;
private float fadeInStart;
private boolean fadingIn = true;
private float fadeOutStart;
public AccessibilityOnboardingScreen(Options options, Runnable onClose) {
super(TITLE);
this.options = options;
this.onClose = onClose;
this.logoRenderer = new LogoRenderer(true);
this.narratorAvailable = Minecraft.getInstance().getNarrator().isActive();
}
@Override
public void init() {
LinearLayout content = this.layout.addToContents(LinearLayout.vertical());
content.defaultCellSetting().alignHorizontallyCenter().padding(4);
this.focusableTextWidget = content.addChild(FocusableTextWidget.builder(this.title, this.font).maxWidth(374).build(), w -> w.padding(8));
GridLayout grid = content.addChild(new GridLayout());
grid.defaultCellSetting().padding(4);
GridLayout.RowHelper rowHelper = grid.createRowHelper(2);
if (this.options.narrator().createButton(this.options) instanceof CycleButton<?> cycleButton) {
this.narratorButton = (CycleButton<NarratorStatus>)cycleButton;
this.narratorButton.active = this.narratorAvailable;
rowHelper.addChild(this.narratorButton);
}
rowHelper.addChild(
SpriteIconButton.builder(
Component.translatable("options.sounds"), button -> this.closeAndSetScreen(new SoundOptionsScreen(this, this.options)), false
)
.width(150)
.sprite(Identifier.withDefaultNamespace("icon/music_notes"), 16, 16)
.build()
);
rowHelper.addChild(
CommonButtons.accessibility(150, button -> this.closeAndSetScreen(new AccessibilityOptionsScreen(this, this.minecraft.options)), false)
);
rowHelper.addChild(
CommonButtons.language(
150, button -> this.closeAndSetScreen(new LanguageSelectScreen(this, this.minecraft.options, this.minecraft.getLanguageManager())), false
)
);
this.layout.addToFooter(Button.builder(CommonComponents.GUI_CONTINUE, button -> this.onClose()).build());
this.layout.visitWidgets(this::addRenderableWidget);
this.repositionElements();
}
@Override
protected void repositionElements() {
if (this.focusableTextWidget != null) {
this.focusableTextWidget.updateHeight();
}
this.layout.arrangeElements();
}
@Override
protected void setInitialFocus() {
if (this.narratorAvailable && this.narratorButton != null) {
this.setInitialFocus(this.narratorButton);
} else {
super.setInitialFocus();
}
}
private int initTitleYPos() {
return 90;
}
@Override
public void onClose() {
if (this.fadeOutStart == 0.0F) {
this.fadeOutStart = (float)Util.getMillis();
}
}
private void closeAndSetScreen(Screen screen) {
this.close(false, () -> this.minecraft.setScreen(screen));
}
private void close(boolean onboardingFinished, Runnable runnable) {
if (onboardingFinished) {
this.options.onboardingAccessibilityFinished();
}
Narrator.getNarrator().clear();
runnable.run();
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
this.handleInitialNarrationDelay();
if (this.fadeInStart == 0.0F && this.fadingIn) {
this.fadeInStart = (float)Util.getMillis();
}
if (this.fadeInStart > 0.0F) {
float fade = ((float)Util.getMillis() - this.fadeInStart) / 2000.0F;
float widgetAlpha = 1.0F;
if (fade >= 1.0F) {
this.fadingIn = false;
this.fadeInStart = 0.0F;
} else {
fade = Mth.clamp(fade, 0.0F, 1.0F);
widgetAlpha = Mth.clampedMap(fade, 0.5F, 1.0F, 0.0F, 1.0F);
}
this.fadeWidgets(widgetAlpha);
}
if (this.fadeOutStart > 0.0F) {
float fade = 1.0F - ((float)Util.getMillis() - this.fadeOutStart) / 1000.0F;
float widgetAlpha = 0.0F;
if (fade <= 0.0F) {
this.fadeOutStart = 0.0F;
this.close(true, this.onClose);
} else {
fade = Mth.clamp(fade, 0.0F, 1.0F);
widgetAlpha = Mth.clampedMap(fade, 0.5F, 1.0F, 0.0F, 1.0F);
}
this.fadeWidgets(widgetAlpha);
}
this.logoRenderer.extractRenderState(graphics, this.width, 1.0F);
}
@Override
protected boolean panoramaShouldSpin() {
return false;
}
private void handleInitialNarrationDelay() {
if (!this.hasNarrated && this.narratorAvailable) {
if (this.timer < 40.0F) {
this.timer++;
} else if (this.minecraft.isWindowActive()) {
Narrator.getNarrator().say(ONBOARDING_NARRATOR_MESSAGE.getString(), true, this.minecraft.options.getFinalSoundSourceVolume(SoundSource.VOICE));
this.hasNarrated = true;
}
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CommonButtons.accessibility(), CommonButtons.language()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
FocusableTextWidget.builder()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
LogoRenderer()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SpriteIconButton.builder()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
GridLayout()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
HeaderAndFooterLayout()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
LinearLayout.vertical()
- 引用位置:
-
- 引用位置:
参数/继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
AccessibilityOptionsScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
LanguageSelectScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SoundOptionsScreen()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp(), Mth.clampedMap()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getMillis()
- 引用位置: