From 8be20d6805ceb09706c27420564d073ba8dc2b7c Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 27 May 2013 10:28:00 -0400 Subject: [PATCH] Add in a pretty sorting error screen --- .../cpw/mods/fml/client/FMLClientHandler.java | 15 +++++- .../mods/fml/client/GuiSortingProblem.java | 48 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 fml/client/cpw/mods/fml/client/GuiSortingProblem.java diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 5b08c1d5a..375c3cd8e 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -71,6 +71,7 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; import cpw.mods.fml.common.registry.IThrowableEntity; import cpw.mods.fml.common.registry.ItemData; import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.common.toposort.ModSortingException; import cpw.mods.fml.relauncher.Side; @@ -113,6 +114,8 @@ public class FMLClientHandler implements IFMLSidedHandler private MissingModsException modsMissing; + private ModSortingException modSorting; + private boolean loading; private WrongMinecraftVersionException wrongMC; @@ -171,6 +174,10 @@ public class FMLClientHandler implements IFMLSidedHandler { modsMissing = missing; } + catch (ModSortingException sorting) + { + modSorting = sorting; + } catch (CustomModLoadingErrorDisplayException custom) { FMLLog.log(Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt"); @@ -197,7 +204,7 @@ public class FMLClientHandler implements IFMLSidedHandler @SuppressWarnings("deprecation") public void finishMinecraftLoading() { - if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null) + if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null) { return; } @@ -237,7 +244,11 @@ public class FMLClientHandler implements IFMLSidedHandler { client.func_71373_a(new GuiDupesFound(dupesFound)); } - else if (customError != null) + else if (modSorting != null) + { + client.func_71373_a(new GuiSortingProblem(modSorting)); + } + else if (customError != null) { client.func_71373_a(new GuiCustomModLoadingErrorScreen(customError)); } diff --git a/fml/client/cpw/mods/fml/client/GuiSortingProblem.java b/fml/client/cpw/mods/fml/client/GuiSortingProblem.java new file mode 100644 index 000000000..95517e4b9 --- /dev/null +++ b/fml/client/cpw/mods/fml/client/GuiSortingProblem.java @@ -0,0 +1,48 @@ +package cpw.mods.fml.client; + +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.toposort.ModSortingException; +import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import net.minecraft.client.gui.GuiScreen; + +public class GuiSortingProblem extends GuiScreen { + private ModSortingException modSorting; + private SortingExceptionData failedList; + + public GuiSortingProblem(ModSortingException modSorting) + { + this.modSorting = modSorting; + this.failedList = modSorting.getExceptionData(); + } + + @Override + public void func_73866_w_() + { + super.func_73866_w_(); + } + + @Override + public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_) + { + this.func_73873_v_(); + int offset = Math.max(85 - (failedList.getVisitedNodes().size() + 3) * 10, 10); + this.func_73732_a(this.field_73886_k, "Forge Mod Loader has found a problem with your minecraft installation", this.field_73880_f / 2, offset, 0xFFFFFF); + offset+=10; + this.func_73732_a(this.field_73886_k, "A mod sorting cycle was detected and loading cannot continue", this.field_73880_f / 2, offset, 0xFFFFFF); + offset+=10; + this.func_73732_a(this.field_73886_k, String.format("The first mod in the cycle is %s", failedList.getFirstBadNode()), this.field_73880_f / 2, offset, 0xFFFFFF); + offset+=10; + this.func_73732_a(this.field_73886_k, "The remainder of the cycle involves these mods", this.field_73880_f / 2, offset, 0xFFFFFF); + offset+=5; + for (ModContainer mc : failedList.getVisitedNodes()) + { + offset+=10; + this.func_73732_a(this.field_73886_k, String.format("%s", mc.toString()), this.field_73880_f / 2, offset, 0xEEEEEE); + } + offset+=20; + this.func_73732_a(this.field_73886_k, "The file 'ForgeModLoader-client-0.log' contains more information", this.field_73880_f / 2, offset, 0xFFFFFF); + } + +}