package openmods.igw.impl.client;

import net.minecraft.client.gui.GuiMainMenu;
import net.minecraftforge.client.event.GuiOpenEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import openmods.igw.OpenModsIGW;

@SideOnly(Side.CLIENT)
public class GuiOpenEventHandler {

	@SubscribeEvent
	@SideOnly(Side.CLIENT)
	@SuppressWarnings("unused")
	//@Explain("Called by Forge, not by us")
	// TODO Move to API
	public void onMainMenuOpen(final GuiOpenEvent event) {
		if (!(event.gui instanceof GuiMainMenu)) return;

		if (WarningGui.shallShow()) {
			event.gui = new WarningGui();
			return;
		}

		if (MismatchingVersionsGui.shouldShow()) {
			event.gui = new MismatchingVersionsGui(OpenModsIGW.proxy().getMismatchingMods());
		}
	}
}

@@ -24,24 +24,70 @@
 pl.client;%0A%0A
+import com.google.common.base.Preconditions;%0A%0A
 import net.m
@@ -328,16 +328,20 @@
 ods.igw.
+api.
 OpenMods
@@ -343,16 +343,119 @@
 nModsIGW
+Api;%0Aimport openmods.igw.api.service.IClassProviderService;%0Aimport openmods.igw.api.service.IGuiService
 ;%0A%0A@Side
@@ -624,29 +624,8 @@
 s%22)%0A
-%09// TODO Move to API%0A
 %09pub
@@ -734,193 +734,555 @@
 %0A%0A%09%09
-if (WarningGui.shallShow()) %7B%0A%09%09%09event.gui = new WarningGui();%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09if (MismatchingVersionsGui.shouldShow()) %7B%0A%09%09%09event.gui = new MismatchingVersionsGui(OpenModsIGW
+final IGuiService it = Preconditions.checkNotNull(OpenModsIGWApi.get().serviceManager()%0A%09%09%09%09.obtainAndCastService(IGuiService.class));%0A%0A%09%09if (it.shouldShow(IGuiService.GUIs.WARNING)) %7B%0A%09%09%09event.gui = it.construct(IGuiService.GUIs.WARNING);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09if (it.shouldShow(IGuiService.GUIs.MISMATCHING_MODS)) %7B%0A%09%09%09event.gui = it.construct(IGuiService.GUIs.MISMATCHING_MODS, Preconditions.checkNotNull(%0A%09%09%09%09%09Preconditions.checkNotNull(%0A%09%09%09%09%09%09%09OpenModsIGWApi.get().serviceManager().obtainAndCastService(IClassProviderService.class)%0A%09%09%09%09%09)
 .proxy()
 .get
@@ -1277,16 +1277,21 @@
 .proxy()
+%0A%09%09%09)
 .getMism

Use API instead of direct calls in GUI event handler