KeyBindsScreen.java
net.minecraft.client.gui.screens.options.controls.KeyBindsScreen
信息
- 全限定名:net.minecraft.client.gui.screens.options.controls.KeyBindsScreen
- 类型:public class
- 包:net.minecraft.client.gui.screens.options.controls
- 源码路径:src/main/java/net/minecraft/client/gui/screens/options/controls/KeyBindsScreen.java
- 起始行号:L21
- 继承:OptionsSubScreen
- 职责:
TODO
字段/常量
-
TITLE- 类型:
Component - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
selectedKey- 类型:
KeyMapping - 修饰符:
public - 源码定位:
L23 - 说明:
TODO
- 类型:
-
lastKeySelection- 类型:
long - 修饰符:
public - 源码定位:
L24 - 说明:
TODO
- 类型:
-
keyBindsList- 类型:
KeyBindsList - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
-
resetButton- 类型:
Button - 修饰符:
private - 源码定位:
L26 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public KeyBindsScreen(Screen lastScreen, Options options) @ L28
- 构造器名:KeyBindsScreen
- 源码定位:L28
- 修饰符:public
参数:
- lastScreen: Screen
- options: Options
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected void addContents() @ L32
- 方法名:addContents
- 源码定位:L32
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void addOptions() @ L37
- 方法名:addOptions
- 源码定位:L37
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void addFooter() @ L41
- 方法名:addFooter
- 源码定位:L41
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
protected void repositionElements() @ L55
- 方法名:repositionElements
- 源码定位:L55
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) @ L61
- 方法名:mouseClicked
- 源码定位:L61
- 返回类型:boolean
- 修饰符:public
参数:
- event: MouseButtonEvent
- doubleClick: boolean
说明:
TODO
public boolean keyPressed(KeyEvent event) @ L73
- 方法名:keyPressed
- 源码定位:L73
- 返回类型:boolean
- 修饰符:public
参数:
- event: KeyEvent
说明:
TODO
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) @ L91
- 方法名:extractRenderState
- 源码定位:L91
- 返回类型:void
- 修饰符:public
参数:
- graphics: GuiGraphicsExtractor
- mouseX: int
- mouseY: int
- a: float
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class KeyBindsScreen extends OptionsSubScreen {
private static final Component TITLE = Component.translatable("controls.keybinds.title");
public @Nullable KeyMapping selectedKey;
public long lastKeySelection;
private KeyBindsList keyBindsList;
private Button resetButton;
public KeyBindsScreen(Screen lastScreen, Options options) {
super(lastScreen, options, TITLE);
}
@Override
protected void addContents() {
this.keyBindsList = this.layout.addToContents(new KeyBindsList(this, this.minecraft));
}
@Override
protected void addOptions() {
}
@Override
protected void addFooter() {
this.resetButton = Button.builder(Component.translatable("controls.resetAll"), button -> {
for (KeyMapping key : this.options.keyMappings) {
key.setKey(key.getDefaultKey());
}
this.keyBindsList.resetMappingAndUpdateButtons();
}).build();
LinearLayout bottomButtons = this.layout.addToFooter(LinearLayout.horizontal().spacing(8));
bottomButtons.addChild(this.resetButton);
bottomButtons.addChild(Button.builder(CommonComponents.GUI_DONE, button -> this.onClose()).build());
}
@Override
protected void repositionElements() {
this.layout.arrangeElements();
this.keyBindsList.updateSize(this.width, this.layout);
}
@Override
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
if (this.selectedKey != null) {
this.selectedKey.setKey(InputConstants.Type.MOUSE.getOrCreate(event.button()));
this.selectedKey = null;
this.keyBindsList.resetMappingAndUpdateButtons();
return true;
} else {
return super.mouseClicked(event, doubleClick);
}
}
@Override
public boolean keyPressed(KeyEvent event) {
if (this.selectedKey != null) {
if (event.isEscape()) {
this.selectedKey.setKey(InputConstants.UNKNOWN);
} else {
this.selectedKey.setKey(InputConstants.getKey(event));
}
this.selectedKey = null;
this.lastKeySelection = Util.getMillis();
this.keyBindsList.resetMappingAndUpdateButtons();
return true;
} else {
return super.keyPressed(event);
}
}
@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
super.extractRenderState(graphics, mouseX, mouseY, a);
boolean canReset = false;
for (KeyMapping key : this.options.keyMappings) {
if (!key.isDefault()) {
canReset = true;
break;
}
}
this.resetButton.active = canReset;
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
InputConstants.getKey()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Button.builder()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
LinearLayout.horizontal()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
KeyBindsList()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Component.translatable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getMillis()
- 引用位置: