RealmsLongRunningMcoTaskScreen.java
com.mojang.realmsclient.gui.screens.RealmsLongRunningMcoTaskScreen
信息
- 全限定名:com.mojang.realmsclient.gui.screens.RealmsLongRunningMcoTaskScreen
- 类型:public class
- 包:com.mojang.realmsclient.gui.screens
- 源码路径:src/main/java/com/mojang/realmsclient/gui/screens/RealmsLongRunningMcoTaskScreen.java
- 起始行号:L25
- 继承:RealmsScreen
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
REPEATED_NARRATOR- 类型:
RepeatedNarrator - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
queuedTasks- 类型:
List<LongRunningTask> - 修饰符:
private final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
lastScreen- 类型:
Screen - 修饰符:
private final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
layout- 类型:
LinearLayout - 修饰符:
protected final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
title- 类型:
Component - 修饰符:
private volatile - 源码定位:
L31 - 说明:
TODO
- 类型:
-
loadingDotsWidget- 类型:
LoadingDotsWidget - 修饰符:
private - 源码定位:
L32 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public RealmsLongRunningMcoTaskScreen(Screen lastScreen, LongRunningTask... tasks) @ L34
- 构造器名:RealmsLongRunningMcoTaskScreen
- 源码定位:L34
- 修饰符:public
参数:
- lastScreen: Screen
- tasks: LongRunningTask…
说明:
TODO
方法
下面的方法块按源码顺序生成。
public boolean canInterruptWithAnotherScreen() @ L61
- 方法名:canInterruptWithAnotherScreen
- 源码定位:L61
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public void tick() @ L66
- 方法名:tick
- 源码定位:L66
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean keyPressed(KeyEvent event) @ L74
- 方法名:keyPressed
- 源码定位:L74
- 返回类型:boolean
- 修饰符:public
参数:
- event: KeyEvent
说明:
TODO
public void init() @ L84
- 方法名:init
- 源码定位:L84
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
protected void repositionElements() @ L95
- 方法名:repositionElements
- 源码定位:L95
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void cancel() @ L101
- 方法名:cancel
- 源码定位:L101
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void setTitle(Component title) @ L109
- 方法名:setTitle
- 源码定位:L109
- 返回类型:void
- 修饰符:public
参数:
- title: Component
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class RealmsLongRunningMcoTaskScreen extends RealmsScreen {
private static final Logger LOGGER = LogUtils.getLogger();
private static final RepeatedNarrator REPEATED_NARRATOR = new RepeatedNarrator(Duration.ofSeconds(5L));
private final List<LongRunningTask> queuedTasks;
private final Screen lastScreen;
protected final LinearLayout layout = LinearLayout.vertical();
private volatile Component title;
private @Nullable LoadingDotsWidget loadingDotsWidget;
public RealmsLongRunningMcoTaskScreen(Screen lastScreen, LongRunningTask... tasks) {
super(GameNarrator.NO_TITLE);
this.lastScreen = lastScreen;
this.queuedTasks = List.of(tasks);
if (this.queuedTasks.isEmpty()) {
throw new IllegalArgumentException("No tasks added");
} else {
this.title = this.queuedTasks.get(0).getTitle();
Runnable runnable = () -> {
for (LongRunningTask task : tasks) {
this.setTitle(task.getTitle());
if (task.aborted()) {
break;
}
task.run();
if (task.aborted()) {
return;
}
}
};
Thread thread = new Thread(runnable, "Realms-long-running-task");
thread.setUncaughtExceptionHandler(new RealmsDefaultUncaughtExceptionHandler(LOGGER));
thread.start();
}
}
@Override
public boolean canInterruptWithAnotherScreen() {
return false;
}
@Override
public void tick() {
super.tick();
if (this.loadingDotsWidget != null) {
REPEATED_NARRATOR.narrate(this.minecraft.getNarrator(), this.loadingDotsWidget.getMessage());
}
}
@Override
public boolean keyPressed(KeyEvent event) {
if (event.isEscape()) {
this.cancel();
return true;
} else {
return super.keyPressed(event);
}
}
@Override
public void init() {
this.layout.defaultCellSetting().alignHorizontallyCenter();
this.layout.addChild(realmsLogo());
this.loadingDotsWidget = new LoadingDotsWidget(this.font, this.title);
this.layout.addChild(this.loadingDotsWidget, layoutSettings -> layoutSettings.paddingTop(10).paddingBottom(30));
this.layout.addChild(Button.builder(CommonComponents.GUI_CANCEL, button -> this.cancel()).build());
this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
this.repositionElements();
}
@Override
protected void repositionElements() {
this.layout.arrangeElements();
FrameLayout.centerInRectangle(this.layout, this.getRectangle());
}
protected void cancel() {
for (LongRunningTask queuedTask : this.queuedTasks) {
queuedTask.abortTask();
}
this.minecraft.setScreen(this.lastScreen);
}
public void setTitle(Component title) {
if (this.loadingDotsWidget != null) {
this.loadingDotsWidget.setMessage(title);
}
this.title = title;
}
}引用的其他类
-
RealmsDefaultUncaughtExceptionHandler
- 引用位置:
构造调用 - 关联成员:
RealmsDefaultUncaughtExceptionHandler()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
LoadingDotsWidget()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FrameLayout.centerInRectangle()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
LinearLayout.vertical()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
RepeatedNarrator()
- 引用位置: