zh_cn:tutorial:screen
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
zh_cn:tutorial:screen [2023/04/24 08:28] – [添加文本] solidblock | zh_cn:tutorial:screen [2023/12/18 01:40] (current) – [添加文本] solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 添加屏幕 ====== | ====== 添加屏幕 ====== | ||
- | **屏幕**是指的图形用户界面,其类继承了 '' | + | **屏幕**是指的图形用户界面,其类继承了 '' |
你可以使用 mixin 以在现有的屏幕中,加入你的屏幕的链接。但是很多情况下,我们可以实现 Mod Menu 模组中的 '' | 你可以使用 mixin 以在现有的屏幕中,加入你的屏幕的链接。但是很多情况下,我们可以实现 Mod Menu 模组中的 '' | ||
Line 111: | Line 111: | ||
* **Title**:屏幕的标题,会在构造函数中指定。当你进入屏幕时,这个标题会被自动复述。 | * **Title**:屏幕的标题,会在构造函数中指定。当你进入屏幕时,这个标题会被自动复述。 | ||
- | * **Position*:告诉你当前正在选中的部件的位置。在原版中,是“// | + | * **Position**:告诉你当前正在选中的部件的位置。在原版中,是“// |
* **Hint**:这个是指的当前选中或悬浮的元素的提示。例如,你可能会记得在上面的代码中创建 '' | * **Hint**:这个是指的当前选中或悬浮的元素的提示。例如,你可能会记得在上面的代码中创建 '' | ||
* **Usage**:在原版中,用法为“// | * **Usage**:在原版中,用法为“// | ||
Line 124: | Line 124: | ||
在 '' | 在 '' | ||
<code java> | <code java> | ||
+ | // 对于 1.20 以下版本 | ||
@Override | @Override | ||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { | public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { | ||
super.render(matrices, | super.render(matrices, | ||
drawCenteredTextWithShadow(matrices, | drawCenteredTextWithShadow(matrices, | ||
+ | } | ||
+ | |||
+ | // 对于 1.20 及以上的版本 | ||
+ | @Override | ||
+ | public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
+ | super.render(context, | ||
+ | context.drawCenteredTextWithShadow(textRenderer, | ||
} | } | ||
</ | </ | ||
Line 134: | Line 142: | ||
<code java> | <code java> | ||
final MultilineText multilineText = MultilineText.create(textRenderer, | final MultilineText multilineText = MultilineText.create(textRenderer, | ||
+ | | ||
+ | // 对于 1.20 以下版本 | ||
multilineText.drawWithShadow(matrices, | multilineText.drawWithShadow(matrices, | ||
+ | // 对于 1.20 及以下的版本 | ||
+ | multilineText.drawWithShadow(context, | ||
</ | </ | ||
另一个选择是使用 '' | 另一个选择是使用 '' | ||
===== 滚动 ===== | ===== 滚动 ===== | ||
- | The screen does not support scrolling, but you can add widgets that supports scrolling. | + | 屏幕不支持滚动,但是你可以添加支持滚动的部件。''< |
- | + | ||
- | * ''< | + | |
- | * ''< | + | |
+ | * ''< | ||
+ | * ''< | ||
===== 完成之前需要检查的事情 ===== | ===== 完成之前需要检查的事情 ===== | ||
- | After finishing your screen, in order to avoid potential issues, please check: | + | 在完成你的屏幕之后,为避免潜在的问题,请检查: |
- | * whether the screen returns to the last screen (parent screen) when you press "Esc" | + | * 按下 |
- | * whether these classes exist only on client (which means they will not be loaded in the dedicated server) | + | * 这些类是否仅存在于客户端(也就是说在专用服务器上不会加载) |
- | * whether elements are focused in the correct order when you press "Tab" to select them | + | * 按下 |
- | * whether the behaviors are correct when you resize | + | * 重新调整屏幕尺寸时的行为是否正确 |
- | * whether the narrations are correct when you use "Tab" or mouse cursor to select element while narration enabled | + | * 启用了复述功能时,按下 |
zh_cn/tutorial/screen.1682324930.txt.gz · Last modified: 2023/04/24 08:28 by solidblock