Initial blind port of the mod error screens

This commit is contained in:
mezz 2018-09-09 12:46:56 -07:00
parent dde7dccef1
commit f851b37aa0
19 changed files with 633 additions and 154 deletions

2
.gitignore vendored
View File

@ -33,3 +33,5 @@ changelog.txt
*.py
*.7z
/logs/
/.project

View File

@ -81,7 +81,7 @@ public class ForgeModContainer extends FMLModContainer
} catch (MalformedURLException e) {}
config = null;
File cfgFile = new File(Loader.instance().getConfigDir(), "forge.cfg");
File cfgFile = new File(FMLPaths.FMLCONFIG.get().toFile(), "forge.cfg");
config = new Configuration(cfgFile);
syncConfig(true);

View File

@ -37,6 +37,7 @@ import net.minecraftforge.common.config.Config.Comment;
import net.minecraftforge.common.config.Config.LangKey;
import net.minecraftforge.common.config.Config.Name;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLPaths;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.LoaderException;
import net.minecraftforge.fml.loading.moddiscovery.ModAnnotation.EnumHolder;
@ -144,7 +145,7 @@ public class ConfigManager
{
FMLLog.log.debug("Attempting to inject @Config classes into {} for type {}", modid, type);
ClassLoader mcl = Loader.instance().getModClassLoader();
File configDir = Loader.instance().getConfigDir();
File configDir = FMLPaths.FMLCONFIG.get().toFile();
Multimap<Config.Type, ASMData> map = asm_data.get(modid);
if (map == null)
@ -207,7 +208,7 @@ public class ConfigManager
static Configuration getConfiguration(String modid, String name) {
if (Strings.isNullOrEmpty(name))
name = modid;
File configDir = Loader.instance().getConfigDir();
File configDir = FMLPaths.FMLCONFIG.get().toFile();
File configFile = new File(configDir, name + ".cfg");
return CONFIGS.get(configFile.getAbsolutePath());
}

View File

@ -56,6 +56,7 @@ import net.minecraftforge.fml.client.config.GuiConfigEntries;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.IConfigElement;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.FMLPaths;
import net.minecraftforge.fml.common.Loader;
import org.apache.commons.io.IOUtils;
@ -1287,7 +1288,7 @@ public class Configuration
public static void enableGlobalConfig()
{
PARENT = new Configuration(new File(Loader.instance().getConfigDir(), "global.cfg"));
PARENT = new Configuration(new File(FMLPaths.FMLCONFIG.get().toFile(), "global.cfg"));
PARENT.load();
}

View File

@ -19,19 +19,26 @@
package net.minecraftforge.fml.client.gui;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiCustomModLoadingErrorScreen extends GuiErrorBase
{
private CustomModLoadingErrorDisplayException customException;
public GuiCustomModLoadingErrorScreen(CustomModLoadingErrorDisplayException customException)
{
this.customException = customException;
}
@Override
public void initGui()
{
super.initGui();
this.customException.initGui(this, fontRenderer);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{

View File

@ -19,15 +19,17 @@
package net.minecraftforge.fml.client.gui;
import net.minecraftforge.fml.common.DuplicateModsFoundException;
import net.minecraftforge.fml.ModContainer;
import java.io.File;
import java.util.Map.Entry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.common.DuplicateModsFoundException;
@OnlyIn(Dist.CLIENT)
public class GuiDupesFound extends GuiErrorBase
{
private DuplicateModsFoundException dupes;
public GuiDupesFound(DuplicateModsFoundException dupes)
@ -41,14 +43,14 @@ public class GuiDupesFound extends GuiErrorBase
this.drawDefaultBackground();
int offset = Math.max(85 - dupes.dupes.size() * 10, 10);
this.drawCenteredString(this.fontRenderer, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF);
offset+=10;
offset += 10;
this.drawCenteredString(this.fontRenderer, "You have mod sources that are duplicate within your system", this.width / 2, offset, 0xFFFFFF);
offset+=10;
offset += 10;
this.drawCenteredString(this.fontRenderer, "Mod Id : File name", this.width / 2, offset, 0xFFFFFF);
offset+=5;
offset += 5;
for (Entry<ModContainer, File> mc : dupes.dupes.entries())
{
offset+=10;
offset += 10;
this.drawCenteredString(this.fontRenderer, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.width / 2, offset, 0xEEEEEE);
}
super.drawScreen(mouseX, mouseY, partialTicks);

View File

@ -19,21 +19,25 @@
package net.minecraftforge.fml.client.gui;
import java.awt.Desktop;
import java.io.File;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.resources.I18n;
import java.awt.*;
import java.io.File;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.FMLPaths;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@OnlyIn(Dist.CLIENT)
public class GuiErrorBase extends GuiErrorScreen
{
private static final Logger LOGGER = LogManager.getLogger();
static final File minecraftDir = new File(Loader.instance().getConfigDir().getParent());
static final File minecraftDir = new File(FMLPaths.FMLCONFIG.get().toFile().getParent());
static final File logFile = new File(minecraftDir, "logs/latest.log");
public GuiErrorBase()
{
super(null, null);

View File

@ -20,15 +20,19 @@
package net.minecraftforge.fml.client.gui;
import java.util.List;
import java.util.Optional;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.MissingModsException;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
@OnlyIn(Dist.CLIENT)
public class GuiModsMissing extends GuiErrorBase
{
private MissingModsException modsMissing;
@ -46,7 +50,7 @@ public class GuiModsMissing extends GuiErrorBase
int offset = Math.max(85 - missingModsVersions.size() * 10, 10);
String modMissingDependenciesText = I18n.format("fml.messages.mod.missing.dependencies.compatibility", TextFormatting.BOLD + modsMissing.getModName() + TextFormatting.RESET);
this.drawCenteredString(this.fontRenderer, modMissingDependenciesText, this.width / 2, offset, 0xFFFFFF);
offset+=5;
offset += 5;
for (MissingModsException.MissingModInfo versionInfo : missingModsVersions)
{
ArtifactVersion acceptedVersion = versionInfo.getAcceptedVersion();
@ -64,14 +68,14 @@ public class GuiModsMissing extends GuiErrorBase
String acceptedModVersionString = acceptedVersion.getRangeString();
if (acceptedVersion instanceof DefaultArtifactVersion)
{
DefaultArtifactVersion dav = (DefaultArtifactVersion)acceptedVersion;
DefaultArtifactVersion dav = (DefaultArtifactVersion) acceptedVersion;
if (dav.getRange() != null)
{
acceptedModVersionString = dav.getRange().toStringFriendly();
}
}
ModContainer acceptedMod = Loader.instance().getIndexedModList().get(acceptedModId);
String acceptedModName = acceptedMod != null ? acceptedMod.getName() : acceptedModId;
Optional<? extends ModContainer> acceptedMod = ModList.get().getModContainerById(acceptedModId);
String acceptedModName = acceptedMod.map((mod) -> mod.getModInfo().getDisplayName()).orElse(acceptedModId);
String versionInfoText = String.format(TextFormatting.BOLD + "%s " + TextFormatting.RESET + "%s (%s)", acceptedModName, acceptedModVersionString, missingReason);
String message;
if (versionInfo.isRequired())

View File

@ -24,6 +24,7 @@ import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.common.MissingModsException;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
public class GuiModsMissingForServer extends GuiScreen

View File

@ -19,32 +19,30 @@
package net.minecraftforge.fml.client.gui;
import java.util.List;
import java.util.Optional;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.MissingModsException;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.MultipleModsErrored;
import net.minecraftforge.fml.common.WrongMinecraftVersionException;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.List;
@OnlyIn(Dist.CLIENT)
public class GuiMultipleModsErrored extends GuiErrorBase
{
private final List<WrongMinecraftVersionException> wrongMinecraftExceptions;
private final List<MissingModsException> missingModsExceptions;
private GuiList list;
public GuiMultipleModsErrored(MultipleModsErrored exception)
{
wrongMinecraftExceptions = exception.wrongMinecraftExceptions;
missingModsExceptions = exception.missingModsExceptions;
}
@ -52,12 +50,12 @@ public class GuiMultipleModsErrored extends GuiErrorBase
public void initGui()
{
super.initGui();
int additionalSize = missingModsExceptions.isEmpty() || wrongMinecraftExceptions.isEmpty() ? 20 : 55;
int additionalSize = missingModsExceptions.isEmpty() ? 20 : 55;
for (MissingModsException exception : missingModsExceptions)
{
additionalSize += exception.getMissingModInfos().size() * 10;
}
list = new GuiList(wrongMinecraftExceptions.size() * 10 + missingModsExceptions.size() * 15 + additionalSize);
list = new GuiList(missingModsExceptions.size() * 15 + additionalSize);
}
@Override
@ -65,24 +63,15 @@ public class GuiMultipleModsErrored extends GuiErrorBase
{
this.drawDefaultBackground();
this.list.drawScreen(mouseX, mouseY, partialTicks);
this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.mod.missing.multiple", missingModsExceptions.size() + wrongMinecraftExceptions.size()), this.width/2, 10, 0xFFFFFF);
String missingMultipleModsText = I18n.format("fml.messages.mod.missing.multiple", missingModsExceptions.size());
this.drawCenteredString(this.fontRenderer, missingMultipleModsText, this.width / 2, 10, 0xFFFFFF);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void actionPerformed(GuiButton button)
public boolean mouseScrolled(double scroll)
{
this.list.actionPerformed(button);
super.actionPerformed(button);
}
@Override
public void handleMouseInput() throws IOException
{
super.handleMouseInput();
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
this.list.handleMouseInput(mouseX, mouseY);
return this.list.mouseScrolled(scroll);
}
private class GuiList extends GuiScrollingList
@ -90,13 +79,13 @@ public class GuiMultipleModsErrored extends GuiErrorBase
public GuiList(int entryHeight)
{
super(GuiMultipleModsErrored.this.mc,
GuiMultipleModsErrored.this.width-20,
GuiMultipleModsErrored.this.height -30,
30, GuiMultipleModsErrored.this.height-50,
10,
entryHeight,
GuiMultipleModsErrored.this.width,
GuiMultipleModsErrored.this.height);
GuiMultipleModsErrored.this.width - 20,
GuiMultipleModsErrored.this.height - 30,
30, GuiMultipleModsErrored.this.height - 50,
10,
entryHeight,
GuiMultipleModsErrored.this.width,
GuiMultipleModsErrored.this.height);
}
@Override
@ -106,7 +95,9 @@ public class GuiMultipleModsErrored extends GuiErrorBase
}
@Override
protected void elementClicked(int index, boolean doubleClick) {}
protected void elementClicked(int index, boolean doubleClick)
{
}
@Override
protected boolean isSelected(int index)
@ -125,26 +116,13 @@ public class GuiMultipleModsErrored extends GuiErrorBase
{
int offset = slotTop;
FontRenderer renderer = GuiMultipleModsErrored.this.fontRenderer;
if (!wrongMinecraftExceptions.isEmpty())
{
renderer.drawString(TextFormatting.UNDERLINE + I18n.format("fml.messages.mod.wrongminecraft", Loader.instance().getMinecraftModContainer().getVersion()), this.left, offset, 0xFFFFFF);
offset+=15;
for(WrongMinecraftVersionException exception : wrongMinecraftExceptions)
{
renderer.drawString(I18n.format("fml.messages.mod.wrongminecraft.requirement", TextFormatting.BOLD + exception.mod.getName() + TextFormatting.RESET, exception.mod.getModId(), exception.mod.acceptableMinecraftVersionRange().toStringFriendly()), this.left, offset, 0xFFFFFF);
offset += 10;
}
offset+=5;
renderer.drawString(I18n.format("fml.messages.mod.wrongminecraft.fix.multiple"), this.left, offset, 0xFFFFFF);
offset+=20;
}
if (!missingModsExceptions.isEmpty())
{
renderer.drawString(I18n.format("fml.messages.mod.missing.dependencies.multiple.issues"), this.left, offset, 0xFFFFFF);
offset+=15;
renderer.func_211126_b(I18n.format("fml.messages.mod.missing.dependencies.multiple.issues"), this.left, offset, 0xFFFFFF);
offset += 15;
for (MissingModsException exception : missingModsExceptions)
{
renderer.drawString(exception.getModName() + ":", this.left, offset, 0xFFFFFF);
renderer.func_211126_b(exception.getModName() + ":", this.left, offset, 0xFFFFFF);
for (MissingModsException.MissingModInfo versionInfo : exception.getMissingModInfos())
{
ArtifactVersion acceptedVersion = versionInfo.getAcceptedVersion();
@ -162,14 +140,14 @@ public class GuiMultipleModsErrored extends GuiErrorBase
String acceptedModVersionString = acceptedVersion.getRangeString();
if (acceptedVersion instanceof DefaultArtifactVersion)
{
DefaultArtifactVersion dav = (DefaultArtifactVersion)acceptedVersion;
DefaultArtifactVersion dav = (DefaultArtifactVersion) acceptedVersion;
if (dav.getRange() != null)
{
acceptedModVersionString = dav.getRange().toStringFriendly();
}
}
ModContainer acceptedMod = Loader.instance().getIndexedModList().get(acceptedModId);
String acceptedModName = acceptedMod != null ? acceptedMod.getName() : acceptedModId;
Optional<? extends ModContainer> acceptedMod = ModList.get().getModContainerById(acceptedModId);
String acceptedModName = acceptedMod.map((mod) -> mod.getModInfo().getDisplayName()).orElse(acceptedModId);
String versionInfoText = String.format(TextFormatting.BOLD + "%s " + TextFormatting.RESET + "%s (%s)", acceptedModName, acceptedModVersionString, missingReason);
String message;
if (versionInfo.isRequired())
@ -181,7 +159,7 @@ public class GuiMultipleModsErrored extends GuiErrorBase
message = I18n.format("fml.messages.mod.missing.dependencies.compatible.with", versionInfoText);
}
offset += 10;
renderer.drawString(message, this.left, offset, 0xEEEEEE);
renderer.func_211126_b(message, this.left, offset, 0xEEEEEE);
}
offset += 15;

View File

@ -0,0 +1,378 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.config.GuiUtils;
import org.lwjgl.opengl.GL11;
@OnlyIn(Dist.CLIENT)
public abstract class GuiScrollingList
{
private final Minecraft client;
protected final int listWidth;
protected final int listHeight;
protected final int screenWidth;
protected final int screenHeight;
protected final int top;
protected final int bottom;
protected final int right;
protected final int left;
protected final int slotHeight;
protected int mouseX;
protected int mouseY;
private float initialMouseClickY = -2.0F;
private float scrollFactor;
private float scrollDistance;
protected int selectedIndex = -1;
private long lastClickTime = 0L;
private boolean highlightSelected = true;
private boolean hasHeader;
private int headerHeight;
@Deprecated // We need to know screen size.
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
{
this(client, width, height, top, bottom, left, entryHeight, width, height);
}
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight, int screenWidth, int screenHeight)
{
this.client = client;
this.listWidth = width;
this.listHeight = height;
this.top = top;
this.bottom = bottom;
this.slotHeight = entryHeight;
this.left = left;
this.right = width + this.left;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
}
protected void setHeaderInfo(boolean hasHeader, int headerHeight)
{
this.hasHeader = hasHeader;
this.headerHeight = headerHeight;
if (!hasHeader) this.headerHeight = 0;
}
protected void setHighlightSelected(boolean highlightSelected)
{
this.highlightSelected = highlightSelected;
}
protected abstract int getSize();
protected abstract void elementClicked(int index, boolean doubleClick);
protected abstract boolean isSelected(int index);
protected int getContentHeight()
{
return this.getSize() * this.slotHeight + this.headerHeight;
}
protected abstract void drawBackground();
/**
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
*/
protected abstract void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess);
/**
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
*/
protected void drawHeader(int entryRight, int relativeY, Tessellator tess)
{
}
protected void clickHeader(int x, int y)
{
}
/**
* Draw anything special on the screen. GL_SCISSOR is enabled for anything that
* is rendered outside of the view box. Do not mess with SCISSOR unless you support this.
*/
protected void drawScreen(int mouseX, int mouseY)
{
}
private void applyScrollLimits()
{
int listHeight = this.getContentHeight() - (this.bottom - this.top - 4);
if (listHeight < 0)
{
listHeight /= 2;
}
if (this.scrollDistance < 0.0F)
{
this.scrollDistance = 0.0F;
}
if (this.scrollDistance > (float) listHeight)
{
this.scrollDistance = (float) listHeight;
}
}
/**
* Scroll up a fixed amount, used for button callbacks.
*/
public void scrollUp()
{
this.scrollDistance -= (float) (this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
this.applyScrollLimits();
}
/**
* Scroll down a fixed amount, used for button callbacks.
*/
public void scrollDown()
{
this.scrollDistance += (float) (this.slotHeight * 2 / 3);
this.initialMouseClickY = -2.0F;
this.applyScrollLimits();
}
private boolean isHovering()
{
return mouseX >= this.left && mouseX <= this.left + this.listWidth &&
mouseY >= this.top && mouseY <= this.bottom;
}
public boolean mouseScrolled(double scroll)
{
if (this.isHovering() && scroll != 0)
{
this.scrollDistance += (float) ((-1 * scroll / 120.0F) * this.slotHeight / 2);
return true;
}
return false;
}
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.mouseX = mouseX;
this.mouseY = mouseY;
this.drawBackground();
boolean isHovering = this.isHovering();
int listLength = this.getSize();
int scrollBarWidth = 6;
int scrollBarRight = this.left + this.listWidth;
int scrollBarLeft = scrollBarRight - scrollBarWidth;
int entryLeft = this.left;
int entryRight = scrollBarLeft - 1;
int viewHeight = this.bottom - this.top;
int border = 4;
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.mouseHelper.func_198030_b())
{
if (this.initialMouseClickY == -1.0F)
{
if (isHovering)
{
int mouseListY = mouseY - this.top - this.headerHeight + (int) this.scrollDistance - border;
int slotIndex = mouseListY / this.slotHeight;
if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0 && slotIndex < listLength)
{
this.elementClicked(slotIndex, slotIndex == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L);
this.selectedIndex = slotIndex;
this.lastClickTime = System.currentTimeMillis();
}
else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0)
{
this.clickHeader(mouseX - entryLeft, mouseY - this.top + (int) this.scrollDistance - border);
}
if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight)
{
this.scrollFactor = -1.0F;
int scrollHeight = this.getContentHeight() - viewHeight - border;
if (scrollHeight < 1) scrollHeight = 1;
int var13 = (int) ((float) (viewHeight * viewHeight) / (float) this.getContentHeight());
if (var13 < 32) var13 = 32;
if (var13 > viewHeight - border * 2)
var13 = viewHeight - border * 2;
this.scrollFactor /= (float) (viewHeight - var13) / (float) scrollHeight;
}
else
{
this.scrollFactor = 1.0F;
}
this.initialMouseClickY = mouseY;
}
else
{
this.initialMouseClickY = -2.0F;
}
}
else if (this.initialMouseClickY >= 0.0F)
{
this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
this.initialMouseClickY = (float) mouseY;
}
}
else
{
this.initialMouseClickY = -1.0F;
}
this.applyScrollLimits();
Tessellator tess = Tessellator.getInstance();
BufferBuilder worldr = tess.getBuffer();
MainWindow window = client.field_195558_d;
double scaleW = window.func_198107_o();
double scaleH = window.func_198087_p();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor((int) (left * scaleW), (int) (window.func_198107_o() - (bottom * scaleH)),
(int) (listWidth * scaleW), (int) (viewHeight * scaleH));
if (this.client.world != null)
{
this.drawGradientRect(this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010);
}
else // Draw dark dirt background
{
GlStateManager.disableLighting();
GlStateManager.disableFog();
this.client.renderEngine.bindTexture(Gui.OPTIONS_BACKGROUND);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
final float scale = 32.0F;
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(this.left, this.bottom, 0.0D).tex(this.left / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.right, this.bottom, 0.0D).tex(this.right / scale, (this.bottom + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.right, this.top, 0.0D).tex(this.right / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.left, this.top, 0.0D).tex(this.left / scale, (this.top + (int) this.scrollDistance) / scale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
tess.draw();
}
int baseY = this.top + border - (int) this.scrollDistance;
if (this.hasHeader)
{
this.drawHeader(entryRight, baseY, tess);
}
for (int slotIdx = 0; slotIdx < listLength; ++slotIdx)
{
int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight;
int slotBuffer = this.slotHeight - border;
if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top)
{
if (this.highlightSelected && this.isSelected(slotIdx))
{
int min = this.left;
int max = entryRight;
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableTexture2D();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(min, slotTop + slotBuffer + 2, 0).tex(0, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(max, slotTop + slotBuffer + 2, 0).tex(1, 1).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(max, slotTop - 2, 0).tex(1, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(min, slotTop - 2, 0).tex(0, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(min + 1, slotTop + slotBuffer + 1, 0).tex(0, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(max - 1, slotTop + slotBuffer + 1, 0).tex(1, 1).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(max - 1, slotTop - 1, 0).tex(1, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(min + 1, slotTop - 1, 0).tex(0, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
tess.draw();
GlStateManager.enableTexture2D();
}
this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess);
}
}
GlStateManager.disableDepth();
int extraHeight = (this.getContentHeight() + border) - viewHeight;
if (extraHeight > 0)
{
int height = (viewHeight * viewHeight) / this.getContentHeight();
if (height < 32) height = 32;
if (height > viewHeight - border * 2)
height = viewHeight - border * 2;
int barTop = (int) this.scrollDistance * (viewHeight - height) / extraHeight + this.top;
if (barTop < this.top)
{
barTop = this.top;
}
GlStateManager.disableTexture2D();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(scrollBarLeft, this.bottom, 0.0D).tex(0.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(scrollBarRight, this.bottom, 0.0D).tex(1.0D, 1.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(scrollBarRight, this.top, 0.0D).tex(1.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(scrollBarLeft, this.top, 0.0D).tex(0.0D, 0.0D).color(0x00, 0x00, 0x00, 0xFF).endVertex();
tess.draw();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(scrollBarLeft, barTop + height, 0.0D).tex(0.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(scrollBarRight, barTop + height, 0.0D).tex(1.0D, 1.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(scrollBarRight, barTop, 0.0D).tex(1.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0x80, 0x80, 0x80, 0xFF).endVertex();
tess.draw();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(scrollBarLeft, barTop + height - 1, 0.0D).tex(0.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(scrollBarRight - 1, barTop + height - 1, 0.0D).tex(1.0D, 1.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(scrollBarRight - 1, barTop, 0.0D).tex(1.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
tess.draw();
}
this.drawScreen(mouseX, mouseY);
GlStateManager.enableTexture2D();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableAlpha();
GlStateManager.disableBlend();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
protected void drawGradientRect(int left, int top, int right, int bottom, int color1, int color2)
{
GuiUtils.drawGradientRect(0, left, top, right, bottom, color1, color2);
}
}

View File

@ -1,50 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.WrongMinecraftVersionException;
public class GuiWrongMinecraft extends GuiErrorBase
{
private WrongMinecraftVersionException wrongMC;
public GuiWrongMinecraft(WrongMinecraftVersionException wrongMC)
{
this.wrongMC = wrongMC;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
this.drawDefaultBackground();
int offset = 75;
this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.mod.wrongminecraft", Loader.instance().getMinecraftModContainer().getVersion()), this.width / 2, offset, 0xFFFFFF);
offset+=15;
this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.mod.wrongminecraft.requirement", TextFormatting.BOLD + wrongMC.mod.getName() + TextFormatting.RESET, wrongMC.mod.getModId(), wrongMC.mod.acceptableMinecraftVersionRange().toStringFriendly()), this.width / 2, offset, 0xEEEEEE);
offset+=15;
this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.mod.wrongminecraft.fix", wrongMC.mod.getName()),this.width/2, offset, 0xFFFFFF);
offset+=20;
this.drawCenteredString(this.fontRenderer, I18n.format("fml.messages.mod.missing.dependencies.see.log", GuiErrorBase.logFile.getName()), this.width / 2, offset, 0xFFFFFF);
super.drawScreen(mouseX, mouseY, partialTicks);
}
}

View File

@ -24,15 +24,16 @@ import java.util.Map.Entry;
import com.google.common.collect.SetMultimap;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.GuiDupesFound;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.client.gui.GuiDupesFound;
public class DuplicateModsFoundException extends LoaderException implements IDisplayableError
{
private static final long serialVersionUID = 1L;
public SetMultimap<ModContainer,File> dupes;
public SetMultimap<ModContainer, File> dupes;
public DuplicateModsFoundException(SetMultimap<ModContainer, File> dupes) {
this.dupes = dupes;
@ -50,7 +51,7 @@ public class DuplicateModsFoundException extends LoaderException implements IDis
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public GuiScreen createGui()
{
return new GuiDupesFound(this);

View File

@ -0,0 +1,129 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.common;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.gui.GuiModsMissing;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
public class MissingModsException extends EnhancedRuntimeException implements IDisplayableError
{
private static final long serialVersionUID = 1L;
private final String id;
private final String name;
private final List<MissingModInfo> missingModsInfos;
private final String modName;
public MissingModsException(String id, String name)
{
this.id = id;
this.name = name;
this.missingModsInfos = new ArrayList<>();
this.modName = name;
}
@Override
public String getMessage()
{
Set<ArtifactVersion> missingMods = missingModsInfos.stream().map(MissingModInfo::getAcceptedVersion).collect(Collectors.toSet());
return String.format("Mod %s (%s) requires %s", id, name, missingMods);
}
public void addMissingMod(ArtifactVersion acceptedVersion, @Nullable ArtifactVersion currentVersion, boolean required)
{
MissingModInfo missingModInfo = new MissingModInfo(acceptedVersion, currentVersion, required);
this.missingModsInfos.add(missingModInfo);
}
public String getModName()
{
return modName;
}
public List<MissingModInfo> getMissingModInfos()
{
return Collections.unmodifiableList(this.missingModsInfos);
}
@Override
protected void printStackTrace(WrappedPrintStream stream)
{
stream.println("Missing Mods:");
for (MissingModInfo info : this.missingModsInfos)
{
ArtifactVersion acceptedVersion = info.getAcceptedVersion();
ArtifactVersion currentVersion = info.getCurrentVersion();
String currentString = currentVersion != null ? currentVersion.getVersionString() : "missing";
stream.println(String.format("\t%s : need %s: have %s", acceptedVersion.getVersionString(), acceptedVersion.getRangeString(), currentString));
}
stream.println("");
}
@Override
@OnlyIn(Dist.CLIENT)
public GuiScreen createGui()
{
return new GuiModsMissing(this);
}
public static class MissingModInfo
{
private final ArtifactVersion acceptedVersion;
@Nullable
private final ArtifactVersion currentVersion;
private final boolean required;
private MissingModInfo(ArtifactVersion acceptedVersion, @Nullable ArtifactVersion currentVersion, boolean required)
{
Preconditions.checkNotNull(acceptedVersion, "acceptedVersion");
this.acceptedVersion = acceptedVersion;
this.currentVersion = currentVersion;
this.required = required;
}
@Nullable
public ArtifactVersion getCurrentVersion()
{
return currentVersion;
}
public ArtifactVersion getAcceptedVersion()
{
return acceptedVersion;
}
public boolean isRequired()
{
return required;
}
}
}

View File

@ -22,23 +22,21 @@ package net.minecraftforge.fml.common;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.fml.client.GuiMultipleModsErrored;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.IDisplayableError;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.client.gui.GuiMultipleModsErrored;
public class MultipleModsErrored extends EnhancedRuntimeException implements IDisplayableError
{
public final List<WrongMinecraftVersionException> wrongMinecraftExceptions;
public final List<MissingModsException> missingModsExceptions;
public MultipleModsErrored(List<WrongMinecraftVersionException> wrongMinecraftExceptions, List<MissingModsException> missingModsExceptions)
public MultipleModsErrored(List<MissingModsException> missingModsExceptions)
{
this.wrongMinecraftExceptions = wrongMinecraftExceptions;
this.missingModsExceptions = missingModsExceptions;
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public GuiScreen createGui()
{
return new GuiMultipleModsErrored(this);
@ -47,10 +45,6 @@ public class MultipleModsErrored extends EnhancedRuntimeException implements IDi
@Override
protected void printStackTrace(WrappedPrintStream stream)
{
for (WrongMinecraftVersionException wrongMinecraftVersionException : this.wrongMinecraftExceptions)
{
wrongMinecraftVersionException.printStackTrace(stream);
}
for (MissingModsException missingModsException : this.missingModsExceptions)
{
missingModsException.printStackTrace(stream);

View File

@ -31,4 +31,6 @@ public interface ArtifactVersion
boolean containsVersion(ArtifactVersion source);
String getRangeString();
String getLabel();
}

View File

@ -24,6 +24,10 @@ package net.minecraftforge.fml.common.versioning;
import javax.annotation.Nullable;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* Describes a restriction in versioning.
*
@ -205,13 +209,14 @@ public class Restriction
return buf.toString();
}
/*
//Forge: Added toStringFriendly, uses Minecraft's localization engine to create user friendly localized message.
@OnlyIn(Dist.CLIENT)
public String toStringFriendly()
{
if ( getLowerBound() == null && getUpperBound() == null )
{
return I18n.translateToLocal("fml.messages.version.restriction.any");
return I18n.format("fml.messages.version.restriction.any");
}
else if ( getLowerBound() != null && getUpperBound() != null )
{
@ -223,19 +228,19 @@ public class Restriction
{
if (isLowerBoundInclusive() && isUpperBoundInclusive())
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.bounded.inclusive", getLowerBound(), getUpperBound());
return I18n.format("fml.messages.version.restriction.bounded.inclusive", getLowerBound(), getUpperBound());
}
else if (isLowerBoundInclusive())
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.bounded.upperexclusive", getLowerBound(), getUpperBound());
return I18n.format("fml.messages.version.restriction.bounded.upperexclusive", getLowerBound(), getUpperBound());
}
else if (isUpperBoundInclusive())
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.bounded.lowerexclusive", getLowerBound(), getUpperBound());
return I18n.format("fml.messages.version.restriction.bounded.lowerexclusive", getLowerBound(), getUpperBound());
}
else
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.bounded.exclusive", getLowerBound(), getUpperBound());
return I18n.format("fml.messages.version.restriction.bounded.exclusive", getLowerBound(), getUpperBound());
}
}
}
@ -243,24 +248,23 @@ public class Restriction
{
if ( isLowerBoundInclusive() )
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.lower.inclusive", getLowerBound());
return I18n.format("fml.messages.version.restriction.lower.inclusive", getLowerBound());
}
else
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.lower.exclusive", getLowerBound());
return I18n.format("fml.messages.version.restriction.lower.exclusive", getLowerBound());
}
}
else
{
if ( isUpperBoundInclusive() )
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.upper.inclusive", getUpperBound());
return I18n.format("fml.messages.version.restriction.upper.inclusive", getUpperBound());
}
else
{
return I18n.translateToLocalFormatted("fml.messages.version.restriction.upper.exclusive", getUpperBound());
return I18n.format("fml.messages.version.restriction.upper.exclusive", getUpperBound());
}
}
}
*/
}

View File

@ -28,6 +28,9 @@ import java.util.Iterator;
import java.util.List;
import com.google.common.base.Joiner; //Forge: Add Imports
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
/**
@ -584,4 +587,22 @@ public class VersionRange
return restrictions.size() == 1 ? restrictions.get(0).getLowerBound().getVersionString() : "";
}
//Forge: Added friendly {localized} toString
@OnlyIn(Dist.CLIENT)
public String toStringFriendly()
{
if ( recommendedVersion != null )
{
return recommendedVersion.getVersionString();
}
else
{
List<String> friendlyRestrictions = new ArrayList<String>(restrictions.size());
for (Restriction restriction : restrictions)
{
friendlyRestrictions.add(restriction.toStringFriendly());
}
return Joiner.on(", ").join(friendlyRestrictions);
}
}
}

View File

@ -1,4 +1,4 @@
net.minecraftforge.fml.loading.RuntimeDistCleaner
net.minecraftforge.common.asm.RuntimeEnumExtener
net.minecraftforge.common.asm.RuntimeEnumExtender
net.minecraftforge.common.asm.ObjectHolderDefinalize
net.minecraftforge.common.asm.CapabilityInjectDefinalize