TelemetryInfoScreen .java

net.minecraft.client.gui.screens.telemetry.TelemetryInfoScreen (class, 134 lines): members: EXTRA_TELEMETRY_AVAILABLE, BUTTON_PRIVACY_STATEMENT, checkbox.

net.minecraft.client.gui.screens.telemetryclass134 linesclientextends Screen5.6 KB

API Surface (5)

Component getNarrationMessage()
void init()
void repositionElements()
void setInitialFocus()
void onClose()

Fields & Constants (15)

TITLE
DESCRIPTION
BUTTON_PRIVACY_STATEMENT
BUTTON_GIVE_FEEDBACK
BUTTON_VIEW_DATA
CHECKBOX_OPT_IN
SPACING
EXTRA_TELEMETRY_AVAILABLE
lastScreen
options
layout
telemetryEventWidget
description
checkbox
savedScroll

String literals (6)

"telemetry_info.screen.title"
"telemetry_info.screen.description"
"telemetry_info.button.privacy_statement"
"telemetry_info.button.give_feedback"
"telemetry_info.button.show_data"
"telemetry_info.opt_in.description"

Full Source

TelemetryInfoScreen.java134 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.gui.screens.telemetry;
2
3
import com.mojang.blaze3d.Blaze3D;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.Minecraft;
7
import net.minecraft.client.Options;
8
import net.minecraft.client.gui.components.AbstractWidget;
9
import net.minecraft.client.gui.components.Button;
10
import net.minecraft.client.gui.components.Checkbox;
11
import net.minecraft.client.gui.components.MultiLineTextWidget;
12
import net.minecraft.client.gui.components.StringWidget;
13
import net.minecraft.client.gui.layouts.HeaderAndFooterLayout;
14
import net.minecraft.client.gui.layouts.LinearLayout;
15
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
16
import net.minecraft.client.gui.screens.Screen;
17
import net.minecraft.network.chat.CommonComponents;
18
import net.minecraft.network.chat.Component;
19
import net.minecraft.util.CommonLinks;
20
import org.jspecify.annotations.Nullable;
21
22
@Environment(EnvType.CLIENT)
23
public class TelemetryInfoScreen extends Screen {
24
	private static final Component TITLE = Component.translatable("telemetry_info.screen.title");
25
	private static final Component DESCRIPTION = Component.translatable("telemetry_info.screen.description").withColor(-4539718);
26
	private static final Component BUTTON_PRIVACY_STATEMENT = Component.translatable("telemetry_info.button.privacy_statement");
27
	private static final Component BUTTON_GIVE_FEEDBACK = Component.translatable("telemetry_info.button.give_feedback");
28
	private static final Component BUTTON_VIEW_DATA = Component.translatable("telemetry_info.button.show_data");
29
	private static final Component CHECKBOX_OPT_IN = Component.translatable("telemetry_info.opt_in.description").withColor(-2039584);
30
	private static final int SPACING = 8;
31
	private static final boolean EXTRA_TELEMETRY_AVAILABLE = Minecraft.getInstance().extraTelemetryAvailable();
32
	private final Screen lastScreen;
33
	private final Options options;
34
	private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(
35
		this, 16 + 9 * 5 + 20, EXTRA_TELEMETRY_AVAILABLE ? 33 + Checkbox.getBoxSize(Minecraft.getInstance().font) : 33
36
	);
37
	private @Nullable TelemetryEventWidget telemetryEventWidget;
38
	private @Nullable MultiLineTextWidget description;
39
	private @Nullable Checkbox checkbox;
40
	private double savedScroll;
41
42
	public TelemetryInfoScreen(final Screen lastScreen, final Options options) {
43
		super(TITLE);
44
		this.lastScreen = lastScreen;
45
		this.options = options;
46
	}
47
48
	@Override
49
	public Component getNarrationMessage() {
50
		return CommonComponents.joinForNarration(super.getNarrationMessage(), DESCRIPTION);
51
	}
52
53
	@Override
54
	protected void init() {
55
		LinearLayout header = this.layout.addToHeader(LinearLayout.vertical().spacing(4));
56
		header.defaultCellSetting().alignHorizontallyCenter();
57
		header.addChild(new StringWidget(TITLE, this.font));
58
		this.description = header.addChild(new MultiLineTextWidget(DESCRIPTION, this.font).setCentered(true));
59
		LinearLayout upperContentButtons = header.addChild(LinearLayout.horizontal().spacing(8));
60
		upperContentButtons.addChild(Button.builder(BUTTON_PRIVACY_STATEMENT, this::openPrivacyStatementLink).build());
61
		upperContentButtons.addChild(Button.builder(BUTTON_GIVE_FEEDBACK, this::openFeedbackLink).build());
62
		LinearLayout footer = this.layout.addToFooter(LinearLayout.vertical().spacing(4));
63
		footer.defaultCellSetting().alignHorizontallyCenter();
64
		if (EXTRA_TELEMETRY_AVAILABLE) {
65
			this.checkbox = footer.addChild(
66
				Checkbox.builder(CHECKBOX_OPT_IN, this.font)
67
					.maxWidth(this.width - 40)
68
					.selected(this.options.telemetryOptInExtra())
69
					.onValueChange(this::onOptInChanged)
70
					.build()
71
			);
72
		}
73
74
		LinearLayout footerButtons = footer.addChild(LinearLayout.horizontal().spacing(8));
75
		footerButtons.addChild(Button.builder(BUTTON_VIEW_DATA, this::openDataFolder).build());
76
		footerButtons.addChild(Button.builder(CommonComponents.GUI_DONE, button -> this.onClose()).build());
77
		LinearLayout content = this.layout.addToContents(LinearLayout.vertical().spacing(8));
78
		this.telemetryEventWidget = content.addChild(new TelemetryEventWidget(0, 0, this.width - 40, this.layout.getContentHeight(), this.font));
79
		this.telemetryEventWidget.setOnScrolledListener(scroll -> this.savedScroll = scroll);
80
		this.layout.visitWidgets(x$0 -> this.addRenderableWidget(x$0));
81
		this.repositionElements();
82
	}
83
84
	@Override
85
	protected void repositionElements() {
86
		if (this.telemetryEventWidget != null) {
87
			this.telemetryEventWidget.setScrollAmount(this.savedScroll);
88
			this.telemetryEventWidget.setWidth(this.width - 40);
89
			this.telemetryEventWidget.setHeight(this.layout.getContentHeight());
90
			this.telemetryEventWidget.updateLayout();
91
		}
92
93
		if (this.description != null) {
94
			this.description.setMaxWidth(this.width - 16);
95
		}
96
97
		if (this.checkbox != null) {
98
			this.checkbox.adjustWidth(this.width - 40, this.font);
99
		}
100
101
		this.layout.arrangeElements();
102
	}
103
104
	@Override
105
	protected void setInitialFocus() {
106
		if (this.telemetryEventWidget != null) {
107
			this.setInitialFocus(this.telemetryEventWidget);
108
		}
109
	}
110
111
	private void onOptInChanged(final AbstractWidget widget, final boolean value) {
112
		if (this.telemetryEventWidget != null) {
113
			this.telemetryEventWidget.onOptInChanged(value);
114
		}
115
	}
116
117
	private void openPrivacyStatementLink(final Button button) {
118
		ConfirmLinkScreen.confirmLinkNow(this, CommonLinks.PRIVACY_STATEMENT);
119
	}
120
121
	private void openFeedbackLink(final Button button) {
122
		ConfirmLinkScreen.confirmLinkNow(this, CommonLinks.RELEASE_FEEDBACK);
123
	}
124
125
	private void openDataFolder(final Button button) {
126
		Blaze3D.openPath(this.minecraft.getTelemetryManager().getLogDirectory());
127
	}
128
129
	@Override
130
	public void onClose() {
131
		this.minecraft.gui.setScreen(this.lastScreen);
132
	}
133
}
134

Decompiled Minecraft 26.3 source of TelemetryInfoScreen (net/minecraft/client/gui/screens/telemetry/TelemetryInfoScreen.java) with Mojang official mappings, stored verbatim on the site.