Skip to content

Commit

Permalink
Merge pull request #23 from TomB-134/dev
Browse files Browse the repository at this point in the history
Hypothetically fixed #19 and duplicates, implemented umollu's title s…
  • Loading branch information
TomB-134 authored May 31, 2021
2 parents 5b9c997 + 8659ca5 commit bcd1947
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
12 changes: 0 additions & 12 deletions src/main/java/minimalmenu/MinimalMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ public static void log(Level level, String message){
LOGGER.log(level, "["+MOD_NAME+"] " + message);
}

public static ArrayList<String> allInstalledIDS() {
ArrayList<String> IDs = new ArrayList<>();
for (ModContainer mod : FabricLoader.getInstance().getAllMods()) {
IDs.add(mod.getMetadata().getId());
}
return IDs;
}

public static boolean isModInstalled(String MOD_ID) {
return allInstalledIDS().contains(MOD_ID);
}

public static void printButtonInfo(AbstractButtonWidget buttonWidget, List<AbstractButtonWidget> buttons) {
log(Level.INFO,"-------------------------------------");
log(Level.INFO, "Index of button: " + buttons.indexOf(buttonWidget));
Expand Down
49 changes: 34 additions & 15 deletions src/main/java/minimalmenu/mixin/GameMenuScreenMixin.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package minimalmenu.mixin;

import com.google.common.collect.Lists;
import minimalmenu.MinimalMenu;
import minimalmenu.config.ConfigHandler;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(GameMenuScreen.class)
public class GameMenuScreenMixin extends Screen {
protected GameMenuScreenMixin(Text title) {
Expand All @@ -25,46 +29,61 @@ private void initWidgets(CallbackInfo info) {
}
}

for (AbstractButtonWidget buttonWidget : this.buttons) {
if ((ConfigHandler.REMOVE_LANSP && this.client.isInSingleplayer()) || (ConfigHandler.REMOVE_LANMP && !this.client.isInSingleplayer())) {
if (buttons.indexOf(buttonWidget) == 5) {
buttonWidget.y = buttons.get(8).y;
}else if (buttons.indexOf(buttonWidget) == 6) {

//Establish a list of strings that holds the message key for each button.
List<String> buttonsTypes = Lists.newArrayList(); //Create list
for (AbstractButtonWidget button : this.buttons) { //Loop over each button
buttonsTypes.add(((TranslatableText) button.getMessage()).getKey()); //Add the button's key to the list
if (ConfigHandler.DEV_MODE) {
System.out.println(((TranslatableText) button.getMessage()).getKey());
}
}

for (int i = 0; i < this.buttons.size(); i++) { //Loop over each button
AbstractButtonWidget buttonWidget = this.buttons.get(i); //Button widget of current iteration
String buttonType = buttonsTypes.get(i); //Button type of current iteration

if ((ConfigHandler.REMOVE_LANSP && this.client.isInSingleplayer()) || (ConfigHandler.REMOVE_LANMP && !this.client.isInSingleplayer())) { //Remove open to lan and all associating if else mess
if (buttonType.equals("menu.options")) { //Fix options button position
buttonWidget.y = this.buttons.get(buttonsTypes.indexOf("modmenu.title")).y; //jesus fucking christ i hate it i hate it i hate it (Hack fix for #19)
} else if (buttonType.equals("menu.shareToLan")) { //Remove lan
buttonWidget.visible = false;
} else if (buttons.indexOf(buttonWidget) == 7) {
} else if (buttonType.equals("menu.returnToMenu")) { //Fix return to menu position
buttonWidget.y -= 24;
} else if (buttons.indexOf(buttonWidget) == 8) {
} else if (buttonType.equals("modmenu.title")) { //Resize and reposition mod menu - yes these if else statements are definitely a sustainable development method it's fine it's finnneee
buttonWidget.setWidth(98);
buttonWidget.x = this.width / 2 + 4;
}
}

if (ConfigHandler.REMOVE_FEEDBACK) {
if (buttons.indexOf(buttonWidget) == 3) {
if (buttonType.equals("menu.sendFeedback")) { //Remove feedback button
buttonWidget.visible = false;
}
if (!ConfigHandler.REMOVE_BUGS && buttons.indexOf(buttonWidget) == 4) {

if (!ConfigHandler.REMOVE_BUGS && buttonType.equals("menu.reportBugs")) { //Adjust bugs button to accommodate lack of feedback button
buttonWidget.setWidth(204);
buttonWidget.x = this.width / 2 - 102;
}
}

if (ConfigHandler.REMOVE_BUGS) {
if (buttons.indexOf(buttonWidget) == 4) {
if (buttonType.equals("menu.reportBugs")) { //Remove bugs button
buttonWidget.visible = false;
}
if (!ConfigHandler.REMOVE_FEEDBACK && buttons.indexOf(buttonWidget) == 3) {

if (!ConfigHandler.REMOVE_FEEDBACK && buttonType.equals("menu.sendFeedback")) { //Adjust feedback button to accommodate lack of feedback button
buttonWidget.setWidth(204);
}
}

if (ConfigHandler.REMOVE_FEEDBACK && ConfigHandler.REMOVE_BUGS) {
if (buttons.indexOf(buttonWidget) >= 5) {
buttonWidget.y -= 24;
if (ConfigHandler.REMOVE_FEEDBACK && ConfigHandler.REMOVE_BUGS) { //If both the feedback and bugs button are no more...
if (buttonType.equals("menu.options") || buttonType.equals("menu.shareToLan") || buttonType.equals("menu.returnToMenu") || buttonType.equals("modmenu.title")) {
buttonWidget.y -= 24; //Adjust height of other buttons
}
}

buttonWidget.x -= ConfigHandler.X_OFFSET_PAUSE;
buttonWidget.x -= ConfigHandler.X_OFFSET_PAUSE; //Offsets
buttonWidget.y -= ConfigHandler.Y_OFFSET_PAUSE;
}
}
Expand Down

0 comments on commit bcd1947

Please sign in to comment.