LoadingOverlay.java
net.minecraft.client.gui.screens.LoadingOverlay
信息
- 全限定名:net.minecraft.client.gui.screens.LoadingOverlay
- 类型:public class
- 包:net.minecraft.client.gui.screens
- 源码路径:src/main/java/net/minecraft/client/gui/screens/LoadingOverlay.java
- 起始行号:L29
- 继承:Overlay
- 职责:
TODO
字段/常量
-
MOJANG_STUDIOS_LOGO_LOCATION- 类型:
Identifier - 修饰符:
public static final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
LOGO_BACKGROUND_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L31 - 说明:
TODO
- 类型:
-
LOGO_BACKGROUND_COLOR_DARK- 类型:
int - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
BRAND_BACKGROUND- 类型:
IntSupplier - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
LOGO_SCALE- 类型:
int - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
LOGO_QUARTER_FLOAT- 类型:
float - 修饰符:
private static final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
LOGO_QUARTER- 类型:
int - 修饰符:
private static final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
LOGO_HALF- 类型:
int - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
LOGO_OVERLAP- 类型:
float - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
SMOOTHING- 类型:
float - 修饰符:
private static final - 源码定位:
L41 - 说明:
TODO
- 类型:
-
FADE_OUT_TIME- 类型:
long - 修饰符:
public static final - 源码定位:
L42 - 说明:
TODO
- 类型:
-
FADE_IN_TIME- 类型:
long - 修饰符:
public static final - 源码定位:
L43 - 说明:
TODO
- 类型:
-
minecraft- 类型:
Minecraft - 修饰符:
private final - 源码定位:
L44 - 说明:
TODO
- 类型:
-
reload- 类型:
ReloadInstance - 修饰符:
private final - 源码定位:
L45 - 说明:
TODO
- 类型:
-
onFinish- 类型:
Consumer<Optional<Throwable>> - 修饰符:
private final - 源码定位:
L46 - 说明:
TODO
- 类型:
-
fadeIn- 类型:
boolean - 修饰符:
private final - 源码定位:
L47 - 说明:
TODO
- 类型:
-
currentProgress- 类型:
float - 修饰符:
private - 源码定位:
L48 - 说明:
TODO
- 类型:
-
fadeOutStart- 类型:
long - 修饰符:
private - 源码定位:
L49 - 说明:
TODO
- 类型:
-
fadeInStart- 类型:
long - 修饰符:
private - 源码定位:
L50 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.screens.LoadingOverlay.LogoTexture- 类型:
class - 修饰符:
private static - 源码定位:
L196 - 说明:
TODO
- 类型:
构造器
public LoadingOverlay(Minecraft minecraft, ReloadInstance reload, Consumer<Optional<Throwable>> onFinish, boolean fadeIn) @ L52
- 构造器名:LoadingOverlay
- 源码定位:L52
- 修饰符:public
参数:
- minecraft: Minecraft
- reload: ReloadInstance
- onFinish: Consumer<Optional
> - fadeIn: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static void registerTextures(TextureManager textureManager) @ L59
- 方法名:registerTextures
- 源码定位:L59
- 返回类型:void
- 修饰符:public static
参数:
- textureManager: TextureManager
说明:
TODO
private static int replaceAlpha(int color, int alpha) @ L63
- 方法名:replaceAlpha
- 源码定位:L63
- 返回类型:int
- 修饰符:private static
参数:
- color: int
- alpha: int
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L67
- 方法名:extractRenderState
- 源码定位:L67
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public void tick() @ L157
- 方法名:tick
- 源码定位:L157
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private boolean isReadyToFadeOut() @ L175
- 方法名:isReadyToFadeOut
- 源码定位:L175
- 返回类型:boolean
- 修饰符:private
参数:
- 无
说明:
TODO
private void extractProgressBar(GuiGraphicsExtractor graphics, int x0, int y0, int x1, int y1, float fade) @ L179
- 方法名:extractProgressBar
- 源码定位:L179
- 返回类型:void
- 修饰符:private
参数:
- graphics: GuiGraphicsExtractor
- x0: int
- y0: int
- x1: int
- y1: int
- fade: float
说明:
TODO
public boolean isPauseScreen() @ L190
- 方法名:isPauseScreen
- 源码定位:L190
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class LoadingOverlay extends Overlay {
public static final Identifier MOJANG_STUDIOS_LOGO_LOCATION = Identifier.withDefaultNamespace("textures/gui/title/mojangstudios.png");
private static final int LOGO_BACKGROUND_COLOR = ARGB.color(255, 239, 50, 61);
private static final int LOGO_BACKGROUND_COLOR_DARK = ARGB.color(255, 0, 0, 0);
private static final IntSupplier BRAND_BACKGROUND = () -> Minecraft.getInstance().options.darkMojangStudiosBackground().get()
? LOGO_BACKGROUND_COLOR_DARK
: LOGO_BACKGROUND_COLOR;
private static final int LOGO_SCALE = 240;
private static final float LOGO_QUARTER_FLOAT = 60.0F;
private static final int LOGO_QUARTER = 60;
private static final int LOGO_HALF = 120;
private static final float LOGO_OVERLAP = 0.0625F;
private static final float SMOOTHING = 0.95F;
public static final long FADE_OUT_TIME = 1000L;
public static final long FADE_IN_TIME = 500L;
private final Minecraft minecraft;
private final ReloadInstance reload;
private final Consumer<Optional<Throwable>> onFinish;
private final boolean fadeIn;
private float currentProgress;
private long fadeOutStart = -1L;
private long fadeInStart = -1L;
public LoadingOverlay(Minecraft minecraft, ReloadInstance reload, Consumer<Optional<Throwable>> onFinish, boolean fadeIn) {
this.minecraft = minecraft;
this.reload = reload;
this.onFinish = onFinish;
this.fadeIn = fadeIn;
}
public static void registerTextures(TextureManager textureManager) {
textureManager.registerAndLoad(MOJANG_STUDIOS_LOGO_LOCATION, new LoadingOverlay.LogoTexture());
}
private static int replaceAlpha(int color, int alpha) {
return color & 16777215 | alpha << 24;
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
int width = graphics.guiWidth();
int height = graphics.guiHeight();
long now = Util.getMillis();
if (this.fadeIn && this.fadeInStart == -1L) {
this.fadeInStart = now;
}
float fadeOutAnim = this.fadeOutStart > -1L ? (float)(now - this.fadeOutStart) / 1000.0F : -1.0F;
float fadeInAnim = this.fadeInStart > -1L ? (float)(now - this.fadeInStart) / 500.0F : -1.0F;
float logoAlpha;
if (fadeOutAnim >= 1.0F) {
if (this.minecraft.screen != null) {
this.minecraft.screen.extractRenderStateWithTooltipAndSubtitles(graphics, 0, 0, a);
} else {
this.minecraft.gui.extractDeferredSubtitles();
}
int alpha = Mth.ceil((1.0F - Mth.clamp(fadeOutAnim - 1.0F, 0.0F, 1.0F)) * 255.0F);
graphics.nextStratum();
graphics.fill(0, 0, width, height, replaceAlpha(BRAND_BACKGROUND.getAsInt(), alpha));
logoAlpha = 1.0F - Mth.clamp(fadeOutAnim - 1.0F, 0.0F, 1.0F);
} else if (this.fadeIn) {
if (this.minecraft.screen != null && fadeInAnim < 1.0F) {
this.minecraft.screen.extractRenderStateWithTooltipAndSubtitles(graphics, mouseX, mouseY, a);
} else {
this.minecraft.gui.extractDeferredSubtitles();
}
int alpha = Mth.ceil(Mth.clamp((double)fadeInAnim, 0.15, 1.0) * 255.0);
graphics.nextStratum();
graphics.fill(0, 0, width, height, replaceAlpha(BRAND_BACKGROUND.getAsInt(), alpha));
logoAlpha = Mth.clamp(fadeInAnim, 0.0F, 1.0F);
} else {
this.minecraft.gameRenderer.getGameRenderState().guiRenderState.clearColorOverride = BRAND_BACKGROUND.getAsInt();
logoAlpha = 1.0F;
}
int contentX = (int)(graphics.guiWidth() * 0.5);
int logoY = (int)(graphics.guiHeight() * 0.5);
double logoHeight = Math.min(graphics.guiWidth() * 0.75, (double)graphics.guiHeight()) * 0.25;
int logoHeightHalf = (int)(logoHeight * 0.5);
double contentWidth = logoHeight * 4.0;
int logoWidthHalf = (int)(contentWidth * 0.5);
int color = ARGB.white(logoAlpha);
graphics.blit(
RenderPipelines.MOJANG_LOGO,
MOJANG_STUDIOS_LOGO_LOCATION,
contentX - logoWidthHalf,
logoY - logoHeightHalf,
-0.0625F,
0.0F,
logoWidthHalf,
(int)logoHeight,
120,
60,
120,
120,
color
);
graphics.blit(
RenderPipelines.MOJANG_LOGO,
MOJANG_STUDIOS_LOGO_LOCATION,
contentX,
logoY - logoHeightHalf,
0.0625F,
60.0F,
logoWidthHalf,
(int)logoHeight,
120,
60,
120,
120,
color
);
int barY = (int)(graphics.guiHeight() * 0.8325);
float actualProgress = this.reload.getActualProgress();
this.currentProgress = Mth.clamp(this.currentProgress * 0.95F + actualProgress * 0.050000012F, 0.0F, 1.0F);
if (fadeOutAnim < 1.0F) {
this.extractProgressBar(
graphics, width / 2 - logoWidthHalf, barY - 5, width / 2 + logoWidthHalf, barY + 5, 1.0F - Mth.clamp(fadeOutAnim, 0.0F, 1.0F)
);
}
if (fadeOutAnim >= 2.0F) {
this.minecraft.setOverlay(null);
}
}
@Override
public void tick() {
if (this.fadeOutStart == -1L && this.reload.isDone() && this.isReadyToFadeOut()) {
try {
this.reload.checkExceptions();
this.onFinish.accept(Optional.empty());
} catch (Throwable var2) {
this.onFinish.accept(Optional.of(var2));
}
this.fadeOutStart = Util.getMillis();
if (this.minecraft.screen != null) {
Window window = this.minecraft.getWindow();
this.minecraft.screen.init(window.getGuiScaledWidth(), window.getGuiScaledHeight());
}
}
}
private boolean isReadyToFadeOut() {
return !this.fadeIn || this.fadeInStart > -1L && Util.getMillis() - this.fadeInStart >= 1000L;
}
private void extractProgressBar(GuiGraphicsExtractor graphics, int x0, int y0, int x1, int y1, float fade) {
int width = Mth.ceil((x1 - x0 - 2) * this.currentProgress);
int alpha = Math.round(fade * 255.0F);
int white = ARGB.color(alpha, 255, 255, 255);
graphics.fill(x0 + 2, y0 + 2, x0 + width, y1 - 2, white);
graphics.fill(x0 + 1, y0, x1 - 1, y0 + 1, white);
graphics.fill(x0 + 1, y1, x1 - 1, y1 - 1, white);
graphics.fill(x0, y0, x0 + 1, y1, white);
graphics.fill(x1, y0, x1 - 1, y1, white);
}
@Override
public boolean isPauseScreen() {
return true;
}
@OnlyIn(Dist.CLIENT)
private static class LogoTexture extends ReloadableTexture {
public LogoTexture() {
super(LoadingOverlay.MOJANG_STUDIOS_LOGO_LOCATION);
}
@Override
public TextureContents loadContents(ResourceManager resourceManager) throws IOException {
ResourceProvider vanillaProvider = Minecraft.getInstance().getVanillaPackResources().asProvider();
TextureContents var4;
try (InputStream resource = vanillaProvider.open(LoadingOverlay.MOJANG_STUDIOS_LOGO_LOCATION)) {
var4 = new TextureContents(NativeImage.read(resource), new TextureMetadataSection(true, true, MipmapStrategy.MEAN, 0.0F));
}
return var4;
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
NativeImage.read()
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
TextureContents()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
TextureMetadataSection()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.color(), ARGB.white()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.ceil(), Mth.clamp()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getMillis()
- 引用位置: