2929import com .mojang .blaze3d .platform .GlStateManager ;
3030import io .github .axolotlclient .AxolotlClient ;
3131import io .github .axolotlclient .AxolotlClientConfig .api .util .Colors ;
32- import io .github .axolotlclient .AxolotlClientConfig .impl .ui .vanilla .widgets .VanillaButtonWidget ;
3332import io .github .axolotlclient .modules .hud .HudEditScreen ;
3433import io .github .axolotlclient .modules .hud .HudManager ;
3534import io .github .axolotlclient .modules .hud .gui .hud .KeystrokeHud ;
3938import io .github .axolotlclient .modules .hud .util .Rectangle ;
4039import io .github .axolotlclient .util .ClientColors ;
4140import net .minecraft .client .gui .screen .Screen ;
41+ import net .minecraft .client .gui .widget .ButtonWidget ;
4242import net .minecraft .client .resource .language .I18n ;
4343
44- public class KeystrokePositioningScreen extends io .github .axolotlclient .AxolotlClientConfig .impl .ui .Screen {
44+ public class KeystrokePositioningScreen extends Screen {
45+ private static final String title = I18n .translate ("keystrokes.stroke.move" );
4546 private final Screen parent ;
4647 private final KeystrokeHud hud ;
4748 private KeystrokeHud .Keystroke focused ;
4849 private final KeystrokeHud .Keystroke editing ;
4950
5051 public KeystrokePositioningScreen (Screen parent , KeystrokeHud hud , KeystrokeHud .Keystroke focused ) {
51- super (I18n . translate ( "keystrokes.stroke.move" ) );
52+ super ();
5253 this .parent = parent ;
5354 this .hud = hud ;
5455 this .editing = focused ;
@@ -63,20 +64,27 @@ public KeystrokePositioningScreen(Screen parent, KeystrokeHud hud) {
6364 private boolean mouseDown ;
6465 private SnappingHelper snap ;
6566
67+ @ Override
68+ protected void buttonClicked (ButtonWidget buttonWidget ) {
69+ if (buttonWidget .id == 0 ) {
70+ closeScreen ();
71+ } else if (buttonWidget .id == 1 ) {
72+ HudEditScreen .toggleSnapping ();
73+ buttonWidget .message = I18n .translate ("hud.snapping" ) + ": " +
74+ I18n .translate (HudEditScreen .isSnappingEnabled () ? "options.on" : "options.off" );
75+ AxolotlClient .configManager .save ();
76+ }
77+ }
78+
6679 @ Override
6780 public void init () {
68- addDrawableChild (new VanillaButtonWidget (width / 2 - 75 , height - 50 + 22 , 150 , 20 , I18n .translate ("gui.back" ), b -> closeScreen ()));
69- this .addDrawableChild (new VanillaButtonWidget (width / 2 - 50 , height - 50 , 100 , 20 , I18n .translate ("hud.snapping" ) + ": "
70- + (I18n .translate (HudEditScreen .isSnappingEnabled () ? "options.on" : "options.off" )),
71- buttonWidget -> {
72- HudEditScreen .toggleSnapping ();
73- buttonWidget .setMessage (I18n .translate ("hud.snapping" ) + ": " +
74- I18n .translate (HudEditScreen .isSnappingEnabled () ? "options.on" : "options.off" ));
75- AxolotlClient .configManager .save ();
76- }));
81+ buttons .add (new ButtonWidget (0 , width / 2 - 75 , height - 50 + 22 , 150 , 20 , I18n .translate ("gui.back" )));
82+ buttons .add (new ButtonWidget (1 , width / 2 - 50 , height - 50 , 100 , 20 , I18n .translate ("hud.snapping" ) + ": "
83+ + (I18n .translate (HudEditScreen .isSnappingEnabled () ? "options.on" : "options.off" ))));
7784 }
7885
7986 private float partialTick ;
87+
8088 @ Override
8189 public void renderBackground () {
8290 GlStateManager .pushMatrix ();
@@ -90,6 +98,7 @@ public void renderBackground() {
9098 @ Override
9199 public void render (int mouseX , int mouseY , float partialTick ) {
92100 this .partialTick = partialTick ;
101+ renderBackground ();
93102 super .render (mouseX , mouseY , partialTick );
94103 if (editing != null ) {
95104 var rect = editing .getRenderPosition ();
@@ -118,8 +127,8 @@ public void render(int mouseX, int mouseY, float partialTick) {
118127 }
119128
120129 @ Override
121- public boolean mouseClicked (double mouseX , double mouseY , int button ) {
122- var value = super .mouseClicked (mouseX , mouseY , button );
130+ public void mouseClicked (int mouseX , int mouseY , int button ) {
131+ super .mouseClicked (mouseX , mouseY , button );
123132 if (button == 0 ) {
124133 Optional <KeystrokeHud .Keystroke > entry = Optional .empty ();
125134 Optional <Rectangle > pos = Optional .empty ();
@@ -141,15 +150,13 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
141150 focused = entry .get ();
142151 mouseDown = true ;
143152 var rect = pos .get ();
144- offset = new DrawPosition (( int ) Math . round ( mouseX - rect .x () ),
145- ( int ) Math . round ( mouseY - rect .y () ));
153+ offset = new DrawPosition (mouseX - rect .x (),
154+ mouseY - rect .y ());
146155 updateSnapState ();
147- return true ;
148156 } else {
149157 focused = null ;
150158 }
151159 }
152- return value ;
153160 }
154161
155162
@@ -159,21 +166,21 @@ public void closeScreen() {
159166 }
160167
161168 @ Override
162- public boolean mouseReleased (double mouseX , double mouseY , int button ) {
169+ public void mouseReleased (int mouseX , int mouseY , int button ) {
163170 if (focused != null ) {
164171 hud .saveKeystrokes ();
165172 }
166173 snap = null ;
167174 mouseDown = false ;
168175 focused = null ;
169- return super .mouseReleased (mouseX , mouseY , button );
176+ super .mouseReleased (mouseX , mouseY , button );
170177 }
171178
172179 @ Override
173- public boolean mouseDragged (double mouseX , double mouseY , int button , double deltaX , double deltaY ) {
180+ public void mouseDragged (int mouseX , int mouseY , int button , long mouseLastClicked ) {
174181 if (focused != null && mouseDown ) {
175- focused .setX (( int ) mouseX - offset .x ());
176- focused .setY (( int ) mouseY - offset .y ());
182+ focused .setX (mouseX - offset .x ());
183+ focused .setY (mouseY - offset .y ());
177184 if (snap != null ) {
178185 Integer snapX , snapY ;
179186 var rect = focused .getRenderPosition ();
@@ -185,9 +192,7 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
185192 focused .setY (snapY );
186193 }
187194 }
188- return true ;
189195 }
190- return false ;
191196 }
192197
193198 private List <Rectangle > getAllBounds () {
0 commit comments