Remove old GuiEventHandler and move settings button into forge mod list
This commit is contained in:
@@ -3,12 +3,12 @@ package com.replaymod.core;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.replaymod.core.gui.RestoreReplayGui;
|
||||
import com.replaymod.core.handler.MainMenuHandler;
|
||||
import com.replaymod.replay.ReplaySender;
|
||||
import com.replaymod.replaystudio.util.I18n;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.CrosshairRenderHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.GuiEventHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.MouseInputHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.TickAndRenderListener;
|
||||
import eu.crushedpixel.replaymod.events.handlers.keyboard.KeyInputHandler;
|
||||
@@ -46,7 +46,9 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
@Mod(modid = ReplayMod.MOD_ID, useMetadata = true)
|
||||
@Mod(modid = ReplayMod.MOD_ID,
|
||||
useMetadata = true,
|
||||
guiFactory = "com.replaymod.core.gui.GuiFactory")
|
||||
public class ReplayMod {
|
||||
|
||||
public static ModContainer getContainer() {
|
||||
@@ -74,8 +76,6 @@ public class ReplayMod {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Deprecated
|
||||
public static GuiEventHandler guiEventHandler;
|
||||
@Deprecated
|
||||
public static ReplaySettings replaySettings;
|
||||
@Deprecated
|
||||
@@ -150,7 +150,7 @@ public class ReplayMod {
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(guiEventHandler = new GuiEventHandler());
|
||||
new MainMenuHandler().register();
|
||||
|
||||
FMLCommonHandler.instance().bus().register(keyInputHandler);
|
||||
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
||||
|
||||
44
src/main/java/com/replaymod/core/gui/GuiFactory.java
Normal file
44
src/main/java/com/replaymod/core/gui/GuiFactory.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.replaymod.core.gui;
|
||||
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class GuiFactory implements IModGuiFactory {
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return ConfigGuiWrapper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ConfigGuiWrapper extends GuiScreen {
|
||||
private final GuiScreen parent;
|
||||
|
||||
public ConfigGuiWrapper(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
new GuiReplaySettings(parent, ReplayMod.instance.getSettingsRegistry()).display();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.replaymod.core.handler;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Moves certain buttons on the main menu upwards so we can inject our own.
|
||||
*/
|
||||
public class MainMenuHandler {
|
||||
public void register() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onInit(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (event.gui instanceof GuiMainMenu) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<GuiButton> buttonList = event.buttonList;
|
||||
for (GuiButton button : buttonList) {
|
||||
// Buttons that aren't in a rectangle directly above our space don't need moving
|
||||
if (button.xPosition + button.width < event.gui.width / 2 - 100
|
||||
|| button.xPosition > event.gui.width / 2 + 100
|
||||
|| button.yPosition > event.gui.height / 4 + 10 + 4 * 24) continue;
|
||||
// Move button up to make space for two rows of buttons
|
||||
// and then move back down by 10 to compensate for the space to the exit button that was already there
|
||||
button.yPosition -= 2 * 24 - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user