tutorial:screen
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:screen [2023/04/21 10:22] – [Notice about the order] solidblock | tutorial:screen [2023/12/18 01:38] (current) – [Adding text] solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Creating a screen ====== | ====== Creating a screen ====== | ||
- | :!: The page is still in progress. | + | A **screen** is a graphical user interface that extends '' |
- | + | ||
- | A **screen** is a graphical user interface that extends '' | + | |
You may use mixins to add into an existing screen a button that goes to your screen. But in many cases, we can implement the '' | You may use mixins to add into an existing screen a button that goes to your screen. But in many cases, we can implement the '' | ||
Line 89: | Line 87: | ||
===== The parent screen ===== | ===== The parent screen ===== | ||
- | I accessed the screen via another screen, such as the Mod Menu screen, but when I press '' | + | I accessed the screen via another screen, such as the Mod Menu screen, but when I press "Esc" |
- | Add a parent as a parameter and field, and use it in the '' | + | This is because you did not specify a parent screen, and the '' |
+ | |||
+ | Add a '' | ||
<code java> | <code java> | ||
Line 112: | Line 112: | ||
* **Title**: The title of the screen, which is defined in the constructor. When you enter the screen, the title will be automatically narrated. | * **Title**: The title of the screen, which is defined in the constructor. When you enter the screen, the title will be automatically narrated. | ||
* **Position**: | * **Position**: | ||
- | * **Hint**: This refers the tooltip of the element you focus on or hovers on. For example, the '' | + | * **Hint**: This refers the tooltip of the element you focus on or hovers on. For example, |
* **Usage**: In vanilla, the usage is: "//Use mouse cursor or Tab button to select element//" | * **Usage**: In vanilla, the usage is: "//Use mouse cursor or Tab button to select element//" | ||
Line 124: | Line 124: | ||
In '' | In '' | ||
<code java> | <code java> | ||
+ | // For versions 1.20 below | ||
@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, | ||
+ | } | ||
+ | | ||
+ | // For versions 1.20 and after | ||
+ | @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, | ||
+ | | ||
+ | // For versions 1.20 below | ||
multilineText.drawWithShadow(matrices, | multilineText.drawWithShadow(matrices, | ||
+ | // For versions 1.20 and after | ||
+ | multilineText.drawWithShadow(context, | ||
</ | </ | ||
Another alterative is using '' | Another alterative is using '' | ||
- | [WIP] | + | ===== Scrolling ===== |
+ | The screen does not support scrolling, but you can add widgets that supports scrolling. ''< | ||
+ | |||
+ | * ''< | ||
+ | * ''< | ||
+ | |||
+ | ===== Things to check before finishing ===== | ||
+ | |||
+ | 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 " | ||
+ | * 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 " | ||
+ | * whether the behaviors are correct when you resize | ||
+ | * whether the narrations are correct when you use " |
tutorial/screen.1682072550.txt.gz · Last modified: 2023/04/21 10:22 by solidblock