TitleScreen.java
net.minecraft.client.gui.screens.TitleScreen
信息
- 全限定名:net.minecraft.client.gui.screens.TitleScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens
- 源码路径:src/main/java/net/minecraft/client/gui/screens/TitleScreen.java
- 起始行号:L46
- 继承:Screen
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L47 - 说明:
TODO
- 类型:
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L48 - 说明:
TODO
- 类型:
-
COPYRIGHT_TEXT- 类型:
Component - 修饰符:
private static final - 源码定位:
L49 - 说明:
TODO
- 类型:
-
DEMO_LEVEL_ID- 类型:
String - 修饰符:
private static final - 源码定位:
L50 - 说明:
TODO
- 类型:
-
splash- 类型:
SplashRenderer - 修饰符:
private - 源码定位:
L51 - 说明:
TODO
- 类型:
-
realmsNotificationsScreen- 类型:
RealmsNotificationsScreen - 修饰符:
private - 源码定位:
L52 - 说明:
TODO
- 类型:
-
fading- 类型:
boolean - 修饰符:
private - 源码定位:
L53 - 说明:
TODO
- 类型:
-
fadeInStart- 类型:
long - 修饰符:
private - 源码定位:
L54 - 说明:
TODO
- 类型:
-
logoRenderer- 类型:
LogoRenderer - 修饰符:
private final - 源码定位:
L55 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public TitleScreen() @ L57
- 构造器名:TitleScreen
- 源码定位:L57
- 修饰符:public
参数:
- 无
说明:
TODO
public TitleScreen(boolean fading) @ L61
- 构造器名:TitleScreen
- 源码定位:L61
- 修饰符:public
参数:
- fading: boolean
说明:
TODO
public TitleScreen(boolean fading, LogoRenderer logoRenderer) @ L65
- 构造器名:TitleScreen
- 源码定位:L65
- 修饰符:public
参数:
- fading: boolean
- logoRenderer: LogoRenderer
说明:
TODO
方法
下面的方法块按源码顺序生成。
private boolean realmsNotificationsEnabled() @ L71
- 方法名:realmsNotificationsEnabled
- 源码定位:L71
- 返回类型:boolean
- 修饰符:private
参数:
- 无
说明:
TODO
public void tick() @ L75
- 方法名:tick
- 源码定位:L75
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public static void registerTextures(TextureManager textureManager) @ L82
- 方法名:registerTextures
- 源码定位:L82
- 返回类型:void
- 修饰符:public static
参数:
- textureManager: TextureManager
说明:
TODO
public boolean isPauseScreen() @ L88
- 方法名:isPauseScreen
- 源码定位:L88
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean shouldCloseOnEsc() @ L93
- 方法名:shouldCloseOnEsc
- 源码定位:L93
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
protected void init() @ L98
- 方法名:init
- 源码定位:L98
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
private int createTestWorldButton(int topPos, int spacing) @ L155
- 方法名:createTestWorldButton
- 源码定位:L155
- 返回类型:int
- 修饰符:private
参数:
- topPos: int
- spacing: int
说明:
TODO
private int createNormalMenuOptions(int topPos, int spacing) @ L169
- 方法名:createNormalMenuOptions
- 源码定位:L169
- 返回类型:int
- 修饰符:private
参数:
- topPos: int
- spacing: int
说明:
TODO
private Component getMultiplayerDisabledReason() @ L193
- 方法名:getMultiplayerDisabledReason
- 源码定位:L193
- 返回类型:Component
- 修饰符:private
参数:
- 无
说明:
TODO
private int createDemoMenuOptions(int topPos, int spacing) @ L210
- 方法名:createDemoMenuOptions
- 源码定位:L210
- 返回类型:int
- 修饰符:private
参数:
- topPos: int
- spacing: int
说明:
TODO
private boolean checkDemoWorldPresence() @ L263
- 方法名:checkDemoWorldPresence
- 源码定位:L263
- 返回类型:boolean
- 修饰符:private
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L278
- 方法名:extractRenderState
- 源码定位:L278
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L319
- 方法名:extractBackground
- 源码定位:L319
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) @ L323
- 方法名:mouseClicked
- 源码定位:L323
- 返回类型:boolean
- 修饰符:public
参数:
- event: MouseButtonEvent
- doubleClick: boolean
说明:
TODO
public void removed() @ L330
- 方法名:removed
- 源码定位:L330
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void added() @ L337
- 方法名:added
- 源码定位:L337
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private void confirmDemo(boolean result) @ L345
- 方法名:confirmDemo
- 源码定位:L345
- 返回类型:void
- 修饰符:private
参数:
- result: boolean
说明:
TODO
public boolean canInterruptWithAnotherScreen() @ L358
- 方法名:canInterruptWithAnotherScreen
- 源码定位:L358
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TitleScreen extends Screen {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Component TITLE = Component.translatable("narrator.screen.title");
private static final Component COPYRIGHT_TEXT = Component.translatable("title.credits");
private static final String DEMO_LEVEL_ID = "Demo_World";
private @Nullable SplashRenderer splash;
private @Nullable RealmsNotificationsScreen realmsNotificationsScreen;
private boolean fading;
private long fadeInStart;
private final LogoRenderer logoRenderer;
public TitleScreen() {
this(false);
}
public TitleScreen(boolean fading) {
this(fading, null);
}
public TitleScreen(boolean fading, @Nullable LogoRenderer logoRenderer) {
super(TITLE);
this.fading = fading;
this.logoRenderer = Objects.requireNonNullElseGet(logoRenderer, () -> new LogoRenderer(false));
}
private boolean realmsNotificationsEnabled() {
return this.realmsNotificationsScreen != null;
}
@Override
public void tick() {
if (this.realmsNotificationsEnabled()) {
this.realmsNotificationsScreen.tick();
}
}
public static void registerTextures(TextureManager textureManager) {
textureManager.registerForNextReload(LogoRenderer.MINECRAFT_LOGO);
textureManager.registerForNextReload(LogoRenderer.MINECRAFT_EDITION);
textureManager.registerForNextReload(Panorama.PANORAMA_OVERLAY);
}
@Override
public boolean isPauseScreen() {
return false;
}
@Override
public boolean shouldCloseOnEsc() {
return false;
}
@Override
protected void init() {
if (this.splash == null) {
this.splash = this.minecraft.getSplashManager().getSplash();
}
int copyrightWidth = this.font.width(COPYRIGHT_TEXT);
int copyrightX = this.width - copyrightWidth - 2;
int spacing = 24;
int topPos = this.height / 4 + 48;
if (this.minecraft.isDemo()) {
topPos = this.createDemoMenuOptions(topPos, 24);
} else {
topPos = this.createNormalMenuOptions(topPos, 24);
}
topPos = this.createTestWorldButton(topPos, 24);
SpriteIconButton language = this.addRenderableWidget(
CommonButtons.language(
20, button -> this.minecraft.setScreen(new LanguageSelectScreen(this, this.minecraft.options, this.minecraft.getLanguageManager())), true
)
);
int var10001 = this.width / 2 - 124;
topPos += 36;
language.setPosition(var10001, topPos);
this.addRenderableWidget(
Button.builder(Component.translatable("menu.options"), button -> this.minecraft.setScreen(new OptionsScreen(this, this.minecraft.options, false)))
.bounds(this.width / 2 - 100, topPos, 98, 20)
.build()
);
this.addRenderableWidget(
Button.builder(Component.translatable("menu.quit"), button -> this.minecraft.stop()).bounds(this.width / 2 + 2, topPos, 98, 20).build()
);
SpriteIconButton accessibility = this.addRenderableWidget(
CommonButtons.accessibility(20, button -> this.minecraft.setScreen(new AccessibilityOptionsScreen(this, this.minecraft.options)), true)
);
accessibility.setPosition(this.width / 2 + 104, topPos);
this.addRenderableWidget(
new PlainTextButton(
copyrightX,
this.height - 10,
copyrightWidth,
10,
COPYRIGHT_TEXT,
button -> this.minecraft.setScreen(new CreditsAndAttributionScreen(this)),
this.font
)
);
if (this.realmsNotificationsScreen == null) {
this.realmsNotificationsScreen = new RealmsNotificationsScreen();
}
if (this.realmsNotificationsEnabled()) {
this.realmsNotificationsScreen.init(this.width, this.height);
}
}
private int createTestWorldButton(int topPos, int spacing) {
if (SharedConstants.IS_RUNNING_IN_IDE) {
this.addRenderableWidget(
Button.builder(
Component.literal("Create Test World"), button -> CreateWorldScreen.testWorld(this.minecraft, () -> this.minecraft.setScreen(this))
)
.bounds(this.width / 2 - 100, topPos += spacing, 200, 20)
.build()
);
}
return topPos;
}
private int createNormalMenuOptions(int topPos, int spacing) {
this.addRenderableWidget(
Button.builder(Component.translatable("menu.singleplayer"), button -> this.minecraft.setScreen(new SelectWorldScreen(this)))
.bounds(this.width / 2 - 100, topPos, 200, 20)
.build()
);
Component multiplayerDisabledReason = this.getMultiplayerDisabledReason();
boolean multiplayerAllowed = multiplayerDisabledReason == null;
Tooltip tooltip = multiplayerDisabledReason != null ? Tooltip.create(multiplayerDisabledReason) : null;
int var6;
this.addRenderableWidget(Button.builder(Component.translatable("menu.multiplayer"), button -> {
Screen screen = (Screen)(this.minecraft.options.skipMultiplayerWarning ? new JoinMultiplayerScreen(this) : new SafetyScreen(this));
this.minecraft.setScreen(screen);
}).bounds(this.width / 2 - 100, var6 = topPos + spacing, 200, 20).tooltip(tooltip).build()).active = multiplayerAllowed;
this.addRenderableWidget(
Button.builder(Component.translatable("menu.online"), button -> this.minecraft.setScreen(new RealmsMainScreen(this)))
.bounds(this.width / 2 - 100, topPos = var6 + spacing, 200, 20)
.tooltip(tooltip)
.build()
)
.active = multiplayerAllowed;
return topPos;
}
private @Nullable Component getMultiplayerDisabledReason() {
if (this.minecraft.allowsMultiplayer()) {
return null;
} else if (this.minecraft.isNameBanned()) {
return Component.translatable("title.multiplayer.disabled.banned.name");
} else {
BanDetails multiplayerBan = this.minecraft.multiplayerBan();
if (multiplayerBan != null) {
return multiplayerBan.expires() != null
? Component.translatable("title.multiplayer.disabled.banned.temporary")
: Component.translatable("title.multiplayer.disabled.banned.permanent");
} else {
return Component.translatable("title.multiplayer.disabled");
}
}
}
private int createDemoMenuOptions(int topPos, int spacing) {
boolean demoWorldPresent = this.checkDemoWorldPresence();
this.addRenderableWidget(
Button.builder(
Component.translatable("menu.playdemo"),
button -> {
if (demoWorldPresent) {
this.minecraft.createWorldOpenFlows().openWorld("Demo_World", () -> this.minecraft.setScreen(this));
} else {
this.minecraft
.createWorldOpenFlows()
.createFreshLevel(
"Demo_World", MinecraftServer.DEMO_SETTINGS, WorldOptions.DEMO_OPTIONS, WorldPresets::createNormalWorldDimensions, this
);
}
}
)
.bounds(this.width / 2 - 100, topPos, 200, 20)
.build()
);
int var5;
Button resetDemoButton = this.addRenderableWidget(
Button.builder(
Component.translatable("menu.resetdemo"),
button -> {
LevelStorageSource levelSource = this.minecraft.getLevelSource();
try (LevelStorageSource.LevelStorageAccess levelAccess = levelSource.createAccess("Demo_World")) {
if (levelAccess.hasWorldData()) {
this.minecraft
.setScreen(
new ConfirmScreen(
this::confirmDemo,
Component.translatable("selectWorld.deleteQuestion"),
Component.translatable("selectWorld.deleteWarning", MinecraftServer.DEMO_SETTINGS.levelName()),
Component.translatable("selectWorld.deleteButton"),
CommonComponents.GUI_CANCEL
)
);
}
} catch (IOException var8) {
SystemToast.onWorldAccessFailure(this.minecraft, "Demo_World");
LOGGER.warn("Failed to access demo world", (Throwable)var8);
}
}
)
.bounds(this.width / 2 - 100, var5 = topPos + spacing, 200, 20)
.build()
);
resetDemoButton.active = demoWorldPresent;
return var5;
}
private boolean checkDemoWorldPresence() {
try {
boolean var2;
try (LevelStorageSource.LevelStorageAccess levelSource = this.minecraft.getLevelSource().createAccess("Demo_World")) {
var2 = levelSource.hasWorldData();
}
return var2;
} catch (IOException var6) {
SystemToast.onWorldAccessFailure(this.minecraft, "Demo_World");
LOGGER.warn("Failed to read demo world data", (Throwable)var6);
return false;
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
if (this.fadeInStart == 0L && this.fading) {
this.fadeInStart = Util.getMillis();
}
float widgetFade = 1.0F;
if (this.fading) {
float fade = (float)(Util.getMillis() - this.fadeInStart) / 2000.0F;
if (fade > 1.0F) {
this.fading = false;
} else {
fade = Mth.clamp(fade, 0.0F, 1.0F);
widgetFade = Mth.clampedMap(fade, 0.5F, 1.0F, 0.0F, 1.0F);
}
this.fadeWidgets(widgetFade);
}
this.extractPanorama(graphics, a);
super.extractRenderState(graphics, mouseX, mouseY, a);
this.logoRenderer.extractRenderState(graphics, this.width, this.logoRenderer.keepLogoThroughFade() ? 1.0F : widgetFade);
if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) {
this.splash.extractRenderState(graphics, this.width, this.font, widgetFade);
}
String versionString = "Minecraft " + SharedConstants.getCurrentVersion().name();
if (this.minecraft.isDemo()) {
versionString = versionString + " Demo";
}
if (Minecraft.checkModStatus().shouldReportAsModified()) {
versionString = versionString + I18n.get("menu.modded");
}
graphics.text(this.font, versionString, 2, this.height - 10, ARGB.white(widgetFade));
if (this.realmsNotificationsEnabled() && widgetFade >= 1.0F) {
this.realmsNotificationsScreen.extractRenderState(graphics, mouseX, mouseY, a);
}
}
@Override
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
}
@Override
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
return super.mouseClicked(event, doubleClick)
? true
: this.realmsNotificationsEnabled() && this.realmsNotificationsScreen.mouseClicked(event, doubleClick);
}
@Override
public void removed() {
if (this.realmsNotificationsScreen != null) {
this.realmsNotificationsScreen.removed();
}
}
@Override
public void added() {
super.added();
if (this.realmsNotificationsScreen != null) {
this.realmsNotificationsScreen.added();
}
}
private void confirmDemo(boolean result) {
if (result) {
try (LevelStorageSource.LevelStorageAccess levelSource = this.minecraft.getLevelSource().createAccess("Demo_World")) {
levelSource.deleteLevel();
} catch (IOException var7) {
SystemToast.onWorldDeleteFailure(this.minecraft, "Demo_World");
LOGGER.warn("Failed to delete demo world", (Throwable)var7);
}
}
this.minecraft.setScreen(this);
}
@Override
public boolean canInterruptWithAnotherScreen() {
return true;
}
}引用的其他类
-
- 引用位置:
构造调用 - 关联成员:
RealmsMainScreen()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
RealmsNotificationsScreen()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedConstants.getCurrentVersion()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.checkModStatus()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CommonButtons.accessibility(), CommonButtons.language()
- 引用位置:
-
- 引用位置:
参数/字段/构造调用 - 关联成员:
LogoRenderer()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
PlainTextButton()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Tooltip.create()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SystemToast.onWorldAccessFailure(), SystemToast.onWorldDeleteFailure()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ConfirmScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
CreditsAndAttributionScreen()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
JoinMultiplayerScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SafetyScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
AccessibilityOptionsScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
LanguageSelectScreen()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
OptionsScreen()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
CreateWorldScreen.testWorld()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SelectWorldScreen()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
I18n.get()
- 引用位置:
-
- 引用位置:
字段/方法调用/返回值 - 关联成员:
Component.literal(), Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.white()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp(), Mth.clampedMap()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getMillis()
- 引用位置: