19
19
@ Mixin (GuiMainMenu .class )
20
20
public abstract class MixinGuiMainMenu extends GuiScreen {
21
21
22
- private int widthVersion ;
23
- private int widthVersionRest ;
22
+ private int widthWatermark ;
23
+ private int widthWatermarkRest ;
24
+ private int widthUpdate ;
25
+ private int widthUpdateRest ;
24
26
25
27
@ Inject (method = "initGui" , at = @ At ("RETURN" ))
26
28
public void initGui$Inject$RETURN (CallbackInfo ci ) {
@@ -33,29 +35,52 @@ public abstract class MixinGuiMainMenu extends GuiScreen {
33
35
KamiCheck .INSTANCE .setDidDisplayWarning (true );
34
36
mc .displayGuiScreen (new LambdaGuiIncompat ());
35
37
}
38
+
39
+ // Version
36
40
FontRenderer fr = fontRenderer ;
37
- String slogan = TextFormatting .WHITE + LambdaMod .NAME + " " + TextFormatting .GRAY + LambdaMod .VERSION ;
38
- String version ;
41
+ String watermark = TextFormatting .WHITE + LambdaMod .NAME + " " + TextFormatting .GRAY + LambdaMod .VERSION ;
42
+ String update ;
43
+
39
44
if (WebUtils .INSTANCE .isLatestVersion ()) {
40
- version = "" ;
45
+ update = "" ;
41
46
} else {
42
- version = TextFormatting .DARK_RED + " Update Available! (" + WebUtils .INSTANCE .getLatestVersion () + ")" ;
47
+ update = TextFormatting .DARK_RED + " Update Available! (" + WebUtils .INSTANCE .getLatestVersion () + ")" ;
48
+ }
49
+
50
+ String combined = watermark + update ;
51
+ drawString (fr , combined , width - fr .getStringWidth (combined ) - 2 , height - 20 , -1 );
52
+
53
+ widthWatermark = fr .getStringWidth (watermark );
54
+ widthWatermarkRest = width - widthWatermark - 2 ;
55
+ widthUpdate = fr .getStringWidth (update );
56
+ widthUpdateRest = width - widthUpdate - 2 ;
57
+
58
+ if (isInside (mouseX , mouseY , widthUpdate , widthUpdateRest )) {
59
+ drawRect (widthUpdateRest , height - 11 , widthUpdate + widthUpdateRest , height - 10 , -1 );
43
60
}
44
- String combined = slogan + version ;
45
- drawString (fr , combined , width - fr .getStringWidth (combined ) - 2 , this .height - 20 , -1 );
46
61
47
- widthVersion = fr .getStringWidth (version );
48
- widthVersionRest = width - widthVersion - 2 ;
49
- if (mouseX > widthVersionRest && mouseX < widthVersionRest + widthVersion && mouseY > height - 20 && mouseY < height - 10 && Mouse .isInsideWindow ()) {
50
- drawRect (widthVersionRest , height - 11 , widthVersion + widthVersionRest , height - 10 , -1 );
62
+ if (isInside (mouseX , mouseY , widthWatermark , widthWatermarkRest )) {
63
+ drawRect (widthWatermarkRest , height - 11 , widthWatermark + widthWatermarkRest , height - 10 , -1 );
51
64
}
65
+
52
66
}
53
67
54
68
@ Inject (method = "mouseClicked" , at = @ At ("RETURN" ))
55
69
public void mouseClicked$Inject$RETURN (int mouseX , int mouseY , int mouseButton , CallbackInfo ci ) {
56
- if (mouseX > widthVersionRest && mouseX < widthVersionRest + widthVersion && mouseY > height - 20 && mouseY < height - 10 ) {
70
+ if (isInside (mouseX , mouseY , widthUpdate , widthUpdateRest )
71
+ && !WebUtils .INSTANCE .isLatestVersion ()
72
+ ) {
57
73
WebUtils .INSTANCE .openWebLink (LambdaMod .DOWNLOAD_LINK );
58
74
}
75
+
76
+ if (isInside (mouseX , mouseY , widthWatermark , widthWatermarkRest )) {
77
+ if (mouseButton == 0 ) {
78
+ MenuShader .setNextShader ();
79
+ } else {
80
+ MenuShader .setPreviousShader ();
81
+ }
82
+ MenuShader .reset ();
83
+ }
59
84
}
60
85
61
86
@ Redirect (method = "drawScreen" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/GuiMainMenu;drawGradientRect(IIIIII)V" ))
@@ -72,4 +97,12 @@ public abstract class MixinGuiMainMenu extends GuiScreen {
72
97
ci .cancel ();
73
98
}
74
99
}
100
+
101
+ private boolean isInside (int mouseX , int mouseY , int base , int rest ) {
102
+ return mouseX > rest
103
+ && mouseX < rest + base
104
+ && mouseY > height - 20
105
+ && mouseY < height - 10
106
+ && Mouse .isInsideWindow ();
107
+ }
75
108
}
0 commit comments