Skip to content

Commit 62462f1

Browse files
committed
Fixup new mod menu and ditch old one.
1 parent 87eafe6 commit 62462f1

File tree

5 files changed

+66
-206
lines changed

5 files changed

+66
-206
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2023-2025 Fox2Code
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.fox2code.foxloader.client.gui;
25+
26+
import com.fox2code.foxloader.updater.UpdateManager;
27+
import net.minecraft.client.Minecraft;
28+
import net.minecraft.common.util.ChatColors;
29+
30+
public class GuiButtonCallbackUpdate extends GuiButtonCallback {
31+
private final String text, textColor;
32+
33+
public GuiButtonCallbackUpdate(int id, int x, int y, String text, Runnable callback) {
34+
super(id, x, y, text, callback);
35+
this.text = text;
36+
this.textColor = ChatColors.RAINBOW + text + ChatColors.RESET;
37+
}
38+
39+
public GuiButtonCallbackUpdate(int id, int x, int y, String text, String extraText, Runnable callback) {
40+
super(id, x, y, text, extraText, callback);
41+
this.text = text;
42+
this.textColor = ChatColors.RAINBOW + text + ChatColors.RESET;
43+
}
44+
45+
public GuiButtonCallbackUpdate(int id, int x, int y, int w, int h, String text, Runnable callback) {
46+
super(id, x, y, w, h, text, callback);
47+
this.text = text;
48+
this.textColor = ChatColors.RAINBOW + text + ChatColors.RESET;
49+
}
50+
51+
public GuiButtonCallbackUpdate(int id, int x, int y, int w, int h, String text, String extraText, Runnable callback) {
52+
super(id, x, y, w, h, text, extraText, callback);
53+
this.text = text;
54+
this.textColor = ChatColors.RAINBOW + text + ChatColors.RESET;
55+
}
56+
57+
@Override
58+
public void drawElement(Minecraft minecraft, float x, float y, float deltaTicks) {
59+
this.displayString = UpdateManager.getInstance().hasUpdates() ? this.textColor : this.text;
60+
super.drawElement(minecraft, x, y, deltaTicks);
61+
}
62+
}

loader/src/main/java/com/fox2code/foxloader/client/gui/GuiModList.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

loader/src/main/java/com/fox2code/foxloader/client/gui/GuiModListContainer.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

loader/src/main/java/com/fox2code/foxloader/client/gui/GuiModMenu.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@
3939
import org.lwjgl.Sys;
4040

4141
public class GuiModMenu extends GuiScreen {
42-
private final GuiScreen parent;
4342
private GuiModMenuContainer modListContainer;
4443
GuiModMenuDescription modListDescription;
4544
private GuiSmallButton guiUpdateAll, guiConfigureMod;
4645
private Object guiScreen;
4746
private int selectedBackup = 0;
4847

4948
public GuiModMenu(GuiScreen parent) {
50-
this.parent = parent;
49+
this.parentScreen = parent;
5150
}
5251

5352
@Override
@@ -85,7 +84,7 @@ protected void actionPerformed(GuiButton var1) {
8584
if (var1.id == 0) {
8685
Sys.openURL("file://" + ModLoader.getModsFolder().getPath());
8786
} else if (var1.id == 1) {
88-
this.mc.displayGuiScreen(this.parent);
87+
this.mc.displayGuiScreen(this.parentScreen);
8988
} else if (var1.id == 2) {
9089
UpdateManager.getInstance().doUpdates();
9190
} else if (var1.id == 3) {

loader/src/main/java/com/fox2code/foxloader/loader/ModLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
package com.fox2code.foxloader.loader;
2525

2626
import com.fox2code.foxevents.EventHandler;
27-
import com.fox2code.foxloader.client.gui.GuiButtonCallback;
27+
import com.fox2code.foxloader.client.gui.GuiButtonCallbackUpdate;
2828
import com.fox2code.foxloader.client.gui.GuiConfigProvider;
2929
import com.fox2code.foxloader.client.gui.GuiModMenu;
3030
import com.fox2code.foxloader.energy.FoxPowerUtils;
@@ -190,7 +190,7 @@ public void onInitGui(GuiScreenInitEvent initGuiEvent) {
190190
SidedMetadataAPI.Internal.setActiveMetaData(Collections.emptyMap());
191191
}
192192
if (guiScreen instanceof GuiMainMenu || guiScreen instanceof GuiIngameMenu) {
193-
initGuiEvent.getControlList().add(new GuiButtonCallback(
193+
initGuiEvent.getControlList().add(new GuiButtonCallbackUpdate(
194194
500, guiScreen.width - 62, 2, 60, 20, "Mods", () ->
195195
Minecraft.getInstance().displayGuiScreen(new GuiModMenu(guiScreen))));
196196
}

0 commit comments

Comments
 (0)