-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIntegrationTest.java
More file actions
122 lines (109 loc) · 4.37 KB
/
Copy pathIntegrationTest.java
File metadata and controls
122 lines (109 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.tanishisherewith.dynamichud;
import com.mojang.blaze3d.platform.InputConstants;
import com.tanishisherewith.dynamichud.integration.DynamicHudConfigurator;
import com.tanishisherewith.dynamichud.integration.DynamicHudIntegration;
import com.tanishisherewith.dynamichud.screens.AbstractMoveableScreen;
import com.tanishisherewith.dynamichud.utils.DynamicValueRegistry;
import com.tanishisherewith.dynamichud.widget.Widget;
import com.tanishisherewith.dynamichud.widgets.GraphWidget;
import com.tanishisherewith.dynamichud.widgets.TextWidget;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import org.lwjgl.glfw.GLFW;
import java.awt.*;
public class IntegrationTest implements DynamicHudIntegration {
TextWidget FPSWidget;
TextWidget HelloWidget;
TextWidget DynamicHUDWidget;
GraphWidget graphWidget;
DynamicValueRegistry registry;
@Override
public void init() {
//Global registry
// We recommend using the syntax "modid:key_name" for easier debugging and to prevent data conflicts in global registries.
DynamicValueRegistry.registerGlobal("dynamichud:FPS", () -> "FPS: " + DynamicHUD.MC.getFps());
//Local registry
registry = new DynamicValueRegistry(DynamicHUD.MOD_ID);
registry.registerLocal("Hello", () -> "Hello " + DynamicHUD.MC.getGameProfile().name() + "!");
registry.registerLocal("DynamicHUD", () -> "DynamicHUD");
registry.registerLocal("FPS", () -> DynamicHUD.MC.getFps());
FPSWidget = new TextWidget.Builder()
.setX(250)
.setY(150)
.setLocked(false)
.rainbow(false)
.registryKey("dynamichud:FPS")
.setModID(DynamicHUD.MOD_ID)
.shouldScale(false)
.build();
HelloWidget = new TextWidget.Builder()
.setX(200)
.setY(100)
.setLocked(false)
.rainbow(false)
.registryKey("Hello")
.registryID(registry.getId())
.setModID(DynamicHUD.MOD_ID)
.shouldScale(true)
.shadow(true)
.build();
DynamicHUDWidget = new TextWidget.Builder()
.setX(0)
.setY(0)
.setLocked(true)
.rainbow(true)
.registryKey("DynamicHUD")
.registryID(registry.getId())
.setModID(DynamicHUD.MOD_ID)
.shouldScale(true)
.build();
graphWidget = new GraphWidget.GraphWidgetBuilder()
.setX(250)
.setY(100)
.label("FPS Chart")
.graphColor(Color.CYAN)
.anchor(Widget.Anchor._default())
.gWidth(100)
.gHeight(60)
.gridLines(10)
.backgroundColor(Color.BLACK)
.lineThickness(0.6f)
.maxDataPoints(100)
.maxValue(120)
.minValue(30)
.setModID(DynamicHUD.MOD_ID)
.setLocked(false)
.setIsVisible(true)
.showGrid(true)
.shouldScale(true)
.registryKey("FPS")
.registryID(registry.getId())
.build()
.setSampleInterval(120)
.autoUpdateRange();
}
@Override
public DynamicHudConfigurator configure(DynamicHudConfigurator configurator) {
configurator.addWidget(FPSWidget)
.addWidget(HelloWidget)
.addWidget(DynamicHUDWidget)
.addWidget(graphWidget)
.configureRenderer(renderer -> {
//Already true by default
//renderer.shouldRenderInGameHud(true);
renderer.addScreen(TitleScreen.class);
})
.withMoveableScreen(config -> new AbstractMoveableScreen(Component.literal("Editor Screen"), config.getRenderer()) {});
return configurator;
}
@Override
public void registerCustomWidgets() {
//WidgetManager.addWidgetData(MyWidget.DATA);
}
@Override
public KeyMapping getKeyBind() {
return DynamicHUD.EDITOR_SCREEN_KEYBIND;
}
}