TutorialToast.java
net.minecraft.client.gui.components.toasts.TutorialToast
信息
- 全限定名:net.minecraft.client.gui.components.toasts.TutorialToast
- 类型:public class
- 包:net.minecraft.client.gui.components.toasts
- 源码路径:src/main/java/net/minecraft/client/gui/components/toasts/TutorialToast.java
- 起始行号:L17
- 实现:Toast
- 职责:
TODO
字段/常量
-
BACKGROUND_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
PROGRESS_BAR_WIDTH- 类型:
int - 修饰符:
public static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
PROGRESS_BAR_HEIGHT- 类型:
int - 修饰符:
public static final - 源码定位:
L20 - 说明:
TODO
- 类型:
-
PROGRESS_BAR_X- 类型:
int - 修饰符:
public static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
PROGRESS_BAR_MARGIN_BOTTOM- 类型:
int - 修饰符:
public static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
PADDING_TOP- 类型:
int - 修饰符:
private static final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
PADDING_BOTTOM- 类型:
int - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
LINE_SPACING- 类型:
int - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
TEXT_LEFT- 类型:
int - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
TEXT_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
icon- 类型:
TutorialToast.Icons - 修饰符:
private final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
lines- 类型:
List<FormattedCharSequence> - 修饰符:
private final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
visibility- 类型:
Toast.Visibility - 修饰符:
private - 源码定位:
L30 - 说明:
TODO
- 类型:
-
lastSmoothingTime- 类型:
long - 修饰符:
private - 源码定位:
L31 - 说明:
TODO
- 类型:
-
smoothedProgress- 类型:
float - 修饰符:
private - 源码定位:
L32 - 说明:
TODO
- 类型:
-
progress- 类型:
float - 修饰符:
private - 源码定位:
L33 - 说明:
TODO
- 类型:
-
progressable- 类型:
boolean - 修饰符:
private final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
timeToDisplayMs- 类型:
int - 修饰符:
private final - 源码定位:
L35 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.gui.components.toasts.TutorialToast.Icons- 类型:
enum - 修饰符:
public static - 源码定位:
L117 - 说明:
TODO
- 类型:
构造器
public TutorialToast(Font font, TutorialToast.Icons icon, Component title, Component message, boolean progressable, int timeToDisplayMs) @ L37
- 构造器名:TutorialToast
- 源码定位:L37
- 修饰符:public
参数:
- font: Font
- icon: TutorialToast.Icons
- title: Component
- message: Component
- progressable: boolean
- timeToDisplayMs: int
说明:
TODO
public TutorialToast(Font font, TutorialToast.Icons icon, Component title, Component message, boolean progressable) @ L49
- 构造器名:TutorialToast
- 源码定位:L49
- 修饰符:public
参数:
- font: Font
- icon: TutorialToast.Icons
- title: Component
- message: Component
- progressable: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public Toast.Visibility getWantedVisibility() @ L53
- 方法名:getWantedVisibility
- 源码定位:L53
- 返回类型:Toast.Visibility
- 修饰符:public
参数:
- 无
说明:
TODO
public void update(ToastManager manager, long fullyVisibleForMs) @ L58
- 方法名:update
- 源码定位:L58
- 返回类型:void
- 修饰符:public
参数:
- manager: ToastManager
- fullyVisibleForMs: long
说明:
TODO
public int height() @ L73
- 方法名:height
- 源码定位:L73
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
private int contentHeight() @ L78
- 方法名:contentHeight
- 源码定位:L78
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, Font font, long fullyVisibleForMs) @ L82
- 方法名:extractRenderState
- 源码定位:L82
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- font: Font
- fullyVisibleForMs: long
说明:
TODO
public void hide() @ L108
- 方法名:hide
- 源码定位:L108
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void updateProgress(float progress) @ L112
- 方法名:updateProgress
- 源码定位:L112
- 返回类型:void
- 修饰符:public
参数:
- progress: float
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class TutorialToast implements Toast {
private static final Identifier BACKGROUND_SPRITE = Identifier.withDefaultNamespace("toast/tutorial");
public static final int PROGRESS_BAR_WIDTH = 154;
public static final int PROGRESS_BAR_HEIGHT = 1;
public static final int PROGRESS_BAR_X = 3;
public static final int PROGRESS_BAR_MARGIN_BOTTOM = 4;
private static final int PADDING_TOP = 7;
private static final int PADDING_BOTTOM = 3;
private static final int LINE_SPACING = 11;
private static final int TEXT_LEFT = 30;
private static final int TEXT_WIDTH = 126;
private final TutorialToast.Icons icon;
private final List<FormattedCharSequence> lines;
private Toast.Visibility visibility = Toast.Visibility.SHOW;
private long lastSmoothingTime;
private float smoothedProgress;
private float progress;
private final boolean progressable;
private final int timeToDisplayMs;
public TutorialToast(Font font, TutorialToast.Icons icon, Component title, @Nullable Component message, boolean progressable, int timeToDisplayMs) {
this.icon = icon;
this.lines = new ArrayList<>(2);
this.lines.addAll(font.split(title.copy().withColor(-11534256), 126));
if (message != null) {
this.lines.addAll(font.split(message, 126));
}
this.progressable = progressable;
this.timeToDisplayMs = timeToDisplayMs;
}
public TutorialToast(Font font, TutorialToast.Icons icon, Component title, @Nullable Component message, boolean progressable) {
this(font, icon, title, message, progressable, 0);
}
@Override
public Toast.Visibility getWantedVisibility() {
return this.visibility;
}
@Override
public void update(ToastManager manager, long fullyVisibleForMs) {
if (this.timeToDisplayMs > 0) {
this.progress = Math.min((float)fullyVisibleForMs / this.timeToDisplayMs, 1.0F);
this.smoothedProgress = this.progress;
this.lastSmoothingTime = fullyVisibleForMs;
if (fullyVisibleForMs > this.timeToDisplayMs) {
this.hide();
}
} else if (this.progressable) {
this.smoothedProgress = Mth.clampedLerp((float)(fullyVisibleForMs - this.lastSmoothingTime) / 100.0F, this.smoothedProgress, this.progress);
this.lastSmoothingTime = fullyVisibleForMs;
}
}
@Override
public int height() {
return 7 + this.contentHeight() + 3;
}
private int contentHeight() {
return Math.max(this.lines.size(), 2) * 11;
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, Font font, long fullyVisibleForMs) {
int height = this.height();
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, BACKGROUND_SPRITE, 0, 0, this.width(), height);
this.icon.extractRenderState(graphics, 6, 6);
int textHeight = this.lines.size() * 11;
int textTop = 7 + (this.contentHeight() - textHeight) / 2;
for (int i = 0; i < this.lines.size(); i++) {
graphics.text(font, this.lines.get(i), 30, textTop + i * 11, -16777216, false);
}
if (this.progressable) {
int progressBarY = height - 4;
graphics.fill(3, progressBarY, 157, progressBarY + 1, -1);
int col;
if (this.progress >= this.smoothedProgress) {
col = -16755456;
} else {
col = -11206656;
}
graphics.fill(3, progressBarY, (int)(3.0F + 154.0F * this.smoothedProgress), progressBarY + 1, col);
}
}
public void hide() {
this.visibility = Toast.Visibility.HIDE;
}
public void updateProgress(float progress) {
this.progress = progress;
}
@OnlyIn(Dist.CLIENT)
public static enum Icons {
MOVEMENT_KEYS(Identifier.withDefaultNamespace("toast/movement_keys")),
MOUSE(Identifier.withDefaultNamespace("toast/mouse")),
TREE(Identifier.withDefaultNamespace("toast/tree")),
RECIPE_BOOK(Identifier.withDefaultNamespace("toast/recipe_book")),
WOODEN_PLANKS(Identifier.withDefaultNamespace("toast/wooden_planks")),
SOCIAL_INTERACTIONS(Identifier.withDefaultNamespace("toast/social_interactions")),
RIGHT_CLICK(Identifier.withDefaultNamespace("toast/right_click"));
private final Identifier sprite;
private Icons(Identifier sprite) {
this.sprite = sprite;
}
public void extractRenderState(GuiGraphicsExtractor graphics, int x, int y) {
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, this.sprite, x, y, 20, 20);
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/实现/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clampedLerp()
- 引用位置: