AddRealmPopupScreen.java
com.mojang.realmsclient.gui.screens.AddRealmPopupScreen
信息
- 全限定名:com.mojang.realmsclient.gui.screens.AddRealmPopupScreen
- 类型:public class
- 包:com.mojang.realmsclient.gui.screens
- 源码路径:src/main/java/com/mojang/realmsclient/gui/screens/AddRealmPopupScreen.java
- 起始行号:L24
- 继承:RealmsScreen
- 职责:
TODO
字段/常量
-
POPUP_TEXT- 类型:
Component - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
CLOSE_TEXT- 类型:
Component - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
BACKGROUND_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
TRIAL_AVAILABLE_SPRITE- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
CROSS_BUTTON_SPRITES- 类型:
WidgetSprites - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
IMAGE_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L32 - 说明:
TODO
- 类型:
-
IMAGE_HEIGHT- 类型:
int - 修饰符:
private static final - 源码定位:
L33 - 说明:
TODO
- 类型:
-
BG_BORDER_SIZE- 类型:
int - 修饰符:
private static final - 源码定位:
L34 - 说明:
TODO
- 类型:
-
BUTTON_SPACING- 类型:
int - 修饰符:
private static final - 源码定位:
L35 - 说明:
TODO
- 类型:
-
PADDING- 类型:
int - 修饰符:
private static final - 源码定位:
L36 - 说明:
TODO
- 类型:
-
WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
HEIGHT- 类型:
int - 修饰符:
private static final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
TEXT_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L39 - 说明:
TODO
- 类型:
-
BUTTON_WIDTH- 类型:
int - 修饰符:
private static final - 源码定位:
L40 - 说明:
TODO
- 类型:
-
CAROUSEL_SWITCH_INTERVAL- 类型:
int - 修饰符:
private static final - 源码定位:
L41 - 说明:
TODO
- 类型:
-
carouselImages- 类型:
List<Identifier> - 修饰符:
private static - 源码定位:
L42 - 说明:
TODO
- 类型:
-
backgroundScreen- 类型:
Screen - 修饰符:
private final - 源码定位:
L43 - 说明:
TODO
- 类型:
-
trialAvailable- 类型:
boolean - 修饰符:
private final - 源码定位:
L44 - 说明:
TODO
- 类型:
-
createTrialButton- 类型:
Button - 修饰符:
private - 源码定位:
L45 - 说明:
TODO
- 类型:
-
carouselIndex- 类型:
int - 修饰符:
private - 源码定位:
L46 - 说明:
TODO
- 类型:
-
carouselTick- 类型:
int - 修饰符:
private - 源码定位:
L47 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public AddRealmPopupScreen(Screen backgroundScreen, boolean trialAvailable) @ L49
- 构造器名:AddRealmPopupScreen
- 源码定位:L49
- 修饰符:public
参数:
- backgroundScreen: Screen
- trialAvailable: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static void updateCarouselImages(ResourceManager resourceManager) @ L55
- 方法名:updateCarouselImages
- 源码定位:L55
- 返回类型:void
- 修饰符:public static
参数:
- resourceManager: ResourceManager
说明:
TODO
protected void init() @ L60
- 方法名:init
- 源码定位:L60
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void tick() @ L91
- 方法名:tick
- 源码定位:L91
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L100
- 方法名:extractRenderState
- 源码定位:L100
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
public static void extractDiamond(GuiGraphicsExtractor graphics, Button button) @ L108
- 方法名:extractDiamond
- 源码定位:L108
- 返回类型:void
- 修饰符:public static
参数:
- graphics: GuiGraphicsExtractor
- button: Button
说明:
TODO
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L115
- 方法名:extractBackground
- 源码定位:L115
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
private int left() @ L130
- 方法名:left
- 源码定位:L130
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
private int top() @ L134
- 方法名:top
- 源码定位:L134
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
private int right() @ L138
- 方法名:right
- 源码定位:L138
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
private int bottom() @ L142
- 方法名:bottom
- 源码定位:L142
- 返回类型:int
- 修饰符:private
参数:
- 无
说明:
TODO
public void onClose() @ L146
- 方法名:onClose
- 源码定位:L146
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class AddRealmPopupScreen extends RealmsScreen {
private static final Component POPUP_TEXT = Component.translatable("mco.selectServer.popup");
private static final Component CLOSE_TEXT = Component.translatable("mco.selectServer.close");
private static final Identifier BACKGROUND_SPRITE = Identifier.withDefaultNamespace("popup/background");
private static final Identifier TRIAL_AVAILABLE_SPRITE = Identifier.withDefaultNamespace("icon/trial_available");
private static final WidgetSprites CROSS_BUTTON_SPRITES = new WidgetSprites(
Identifier.withDefaultNamespace("widget/cross_button"), Identifier.withDefaultNamespace("widget/cross_button_highlighted")
);
private static final int IMAGE_WIDTH = 195;
private static final int IMAGE_HEIGHT = 152;
private static final int BG_BORDER_SIZE = 6;
private static final int BUTTON_SPACING = 4;
private static final int PADDING = 10;
private static final int WIDTH = 320;
private static final int HEIGHT = 172;
private static final int TEXT_WIDTH = 100;
private static final int BUTTON_WIDTH = 99;
private static final int CAROUSEL_SWITCH_INTERVAL = 100;
private static List<Identifier> carouselImages = List.of();
private final Screen backgroundScreen;
private final boolean trialAvailable;
private @Nullable Button createTrialButton;
private int carouselIndex;
private int carouselTick;
public AddRealmPopupScreen(Screen backgroundScreen, boolean trialAvailable) {
super(POPUP_TEXT);
this.backgroundScreen = backgroundScreen;
this.trialAvailable = trialAvailable;
}
public static void updateCarouselImages(ResourceManager resourceManager) {
Collection<Identifier> candidates = resourceManager.listResources("textures/gui/images", s -> s.getPath().endsWith(".png")).keySet();
carouselImages = candidates.stream().filter(id -> id.getNamespace().equals("realms")).toList();
}
@Override
protected void init() {
this.backgroundScreen.resize(this.width, this.height);
if (this.trialAvailable) {
this.createTrialButton = this.addRenderableWidget(
Button.builder(Component.translatable("mco.selectServer.trial"), ConfirmLinkScreen.confirmLink(this, CommonLinks.START_REALMS_TRIAL))
.bounds(this.right() - 10 - 99, this.bottom() - 10 - 4 - 40, 99, 20)
.build()
);
}
this.addRenderableWidget(
Button.builder(Component.translatable("mco.selectServer.buy"), ConfirmLinkScreen.confirmLink(this, CommonLinks.BUY_REALMS))
.bounds(this.right() - 10 - 99, this.bottom() - 10 - 20, 99, 20)
.build()
);
ImageButton closeButton = this.addRenderableWidget(
new ImageButton(this.left() + 4, this.top() + 4, 14, 14, CROSS_BUTTON_SPRITES, button -> this.onClose(), CLOSE_TEXT)
);
closeButton.setTooltip(Tooltip.create(CLOSE_TEXT));
int textBoxHeight = 142 - (this.trialAvailable ? 40 : 20);
FittingMultiLineTextWidget fittingMultiLineTextWidget = new FittingMultiLineTextWidget(
this.right() - 10 - 100, this.top() + 10, 100, textBoxHeight, POPUP_TEXT, this.font
);
if (fittingMultiLineTextWidget.showingScrollBar()) {
fittingMultiLineTextWidget.setWidth(100 - fittingMultiLineTextWidget.scrollbarWidth());
}
this.addRenderableWidget(fittingMultiLineTextWidget);
}
@Override
public void tick() {
super.tick();
if (++this.carouselTick > 100) {
this.carouselTick = 0;
this.carouselIndex = (this.carouselIndex + 1) % carouselImages.size();
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
if (this.createTrialButton != null) {
extractDiamond(graphics, this.createTrialButton);
}
}
public static void extractDiamond(GuiGraphicsExtractor graphics, Button button) {
int size = 8;
graphics.blitSprite(
RenderPipelines.GUI_TEXTURED, TRIAL_AVAILABLE_SPRITE, button.getX() + button.getWidth() - 8 - 4, button.getY() + button.getHeight() / 2 - 4, 8, 8
);
}
@Override
public void extractBackground(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
this.backgroundScreen.extractBackground(graphics, -1, -1, a);
graphics.nextStratum();
this.backgroundScreen.extractRenderState(graphics, -1, -1, a);
graphics.nextStratum();
this.extractTransparentBackground(graphics);
graphics.blitSprite(RenderPipelines.GUI_TEXTURED, BACKGROUND_SPRITE, this.left(), this.top(), 320, 172);
if (!carouselImages.isEmpty()) {
graphics.blit(
RenderPipelines.GUI_TEXTURED, carouselImages.get(this.carouselIndex), this.left() + 10, this.top() + 10, 0.0F, 0.0F, 195, 152, 195, 152
);
}
}
private int left() {
return (this.width - 320) / 2;
}
private int top() {
return (this.height - 172) / 2;
}
private int right() {
return this.left() + 320;
}
private int bottom() {
return this.top() + 172;
}
@Override
public void onClose() {
this.minecraft.setScreen(this.backgroundScreen);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
FittingMultiLineTextWidget()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ImageButton()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Tooltip.create()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
WidgetSprites()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ConfirmLinkScreen.confirmLink()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: