Skip to content

Commit bf5035c

Browse files
committed
Put Mod Settings button in good places, with or without Mod Menu.
1 parent 81effc4 commit bf5035c

File tree

1 file changed

+41
-48
lines changed

1 file changed

+41
-48
lines changed

src/main/java/se/icus/mag/modmenusettings/gui/MenuScreensChanger.java

+41-48
Original file line numberDiff line numberDiff line change
@@ -15,70 +15,63 @@
1515
public abstract class MenuScreensChanger {
1616

1717
public static void afterTitleScreenInit(TitleScreen screen) {
18+
final int fullButtonWidth = 200;
19+
int shiftDown = 0;
1820
List<ClickableWidget> buttons = Screens.getButtons(screen);
1921

20-
final int buttonWidth = 204;
22+
for (ClickableWidget button : Screens.getButtons(screen)) {
2123

22-
final int spacing = 24;
23-
int savedY = 0;
24-
int maxY = 0;
25-
for (ClickableWidget button : buttons) {
26-
if (button.y > maxY) maxY = button.y;
27-
if (buttonHasText(button, "modmenu.title")) {
24+
if (buttonHasText(button, "modmenu.title") && button.getWidth() == fullButtonWidth) {
25+
// If we find a wide ModMenu button, shorten it and fit in our button on the same row
2826
button.setWidth(98);
29-
savedY = button.y;
27+
button.x = screen.width / 2 + 2;
28+
29+
ClickableWidget msbutton = new ModsConfigButtonWidget(screen.width / 2 - fullButtonWidth / 2, button.y, 98, 20, screen);
30+
buttons.add(msbutton);
31+
return;
32+
}
33+
if (buttonHasText(button, "menu.options")) {
34+
// Otherwise put our button as full width, above "Options..."
35+
shiftDown = 24;
36+
37+
// offset it 12 pixels up
38+
ClickableWidget msbutton = new ModsConfigButtonWidget(screen.width / 2 - fullButtonWidth / 2, button.y - 12, fullButtonWidth, 20, screen);
39+
buttons.add(msbutton);
40+
}
41+
42+
if (!buttonHasText(button, "Mod Settings...")) {
43+
button.y += shiftDown;
3044
}
31-
// REALMS button: "menu.online"
3245
}
33-
ClickableWidget myButton = new ModsConfigButtonWidget(screen.width / 2 + 2, savedY, 98, 20, screen);
34-
buttons.add(myButton);
35-
ClickableWidget myButton2 = new ModsConfigButtonWidget(screen.width / 2 + 2, maxY + 24, 98, 20, screen);
36-
buttons.add(myButton2);
3746
}
3847

3948
public static void afterGameMenuScreenInit(GameMenuScreen screen) {
40-
final int buttonWidth = 204;
41-
final int spacing = 24;
42-
int yOffset = 0;
43-
boolean REMOVE_FEEDBACK = false;
44-
boolean REMOVE_BUGS = false;
49+
final int fullButtonWidth = 204;
50+
int shiftDown = 0;
51+
List<ClickableWidget> buttons = Screens.getButtons(screen);
4552

4653
for (ClickableWidget button : Screens.getButtons(screen)) {
4754

48-
if (buttonHasText(button, "menu.sendFeedback")) {
49-
button.setWidth(buttonWidth / 2);
55+
if (buttonHasText(button, "modmenu.title") && button.getWidth() == fullButtonWidth) {
56+
// If we find a wide ModMenu button, shorten it and fit in our button on the same row
57+
button.setWidth(98);
58+
button.x = screen.width / 2 + 4;
59+
60+
ClickableWidget msbutton = new ModsConfigButtonWidget(screen.width / 2 - fullButtonWidth / 2, button.y, 98, 20, screen);
61+
buttons.add(msbutton);
62+
return;
5063
}
51-
if (REMOVE_FEEDBACK) {
52-
53-
if (buttonHasText(button, "menu.sendFeedback")) {
54-
button.visible = false;
55-
}
56-
if (!REMOVE_BUGS) {
57-
58-
if (buttonHasText(button, "menu.reportBugs")) {
59-
button.setWidth(buttonWidth);
60-
button.x = screen.width / 2 - buttonWidth / 2;
61-
}
62-
}
64+
if (buttonHasText(button, "menu.options")) {
65+
// Otherwise put our button as full width, above "Options..."
66+
shiftDown = 24;
67+
68+
ClickableWidget msbutton = new ModsConfigButtonWidget(screen.width / 2 - fullButtonWidth / 2, button.y, fullButtonWidth, 20, screen);
69+
buttons.add(msbutton);
6370
}
6471

65-
if (REMOVE_BUGS) {
66-
67-
if (buttonHasText(button, "menu.reportBugs")) {
68-
button.visible = false;
69-
if (REMOVE_FEEDBACK) {
70-
yOffset += spacing;
71-
}
72-
}
73-
if (!REMOVE_FEEDBACK) {
74-
75-
if (buttonHasText(button, "menu.sendFeedback")) {
76-
button.setWidth(buttonWidth);
77-
button.x = screen.width / 2 - buttonWidth / 2;
78-
}
79-
}
72+
if (!buttonHasText(button, "Mod Settings...")) {
73+
button.y += shiftDown;
8074
}
81-
button.y -= yOffset;
8275
}
8376
}
8477

0 commit comments

Comments
 (0)