That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.JsonUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -22,11 +23,15 @@ class Image {
|
||||
private int textureWidth, textureHeight;
|
||||
private int u = 0, v = 0;
|
||||
private String caption = "";
|
||||
private boolean border = true;
|
||||
// Derived fields, not specifically defined in JSON
|
||||
private final Set<int[]> instances = new HashSet<>();
|
||||
|
||||
private static final int CAPTION_OFFSET = 4;
|
||||
|
||||
private static final int TEXTURE_INSET_X = 180;
|
||||
private static final int BORDER = 1;
|
||||
|
||||
private Image(ResourceLocation location, int width, int height){
|
||||
this.location = location;
|
||||
this.width = width;
|
||||
@@ -68,6 +73,7 @@ class Image {
|
||||
* @param top The y coordinate of the top of the GUI.
|
||||
*/
|
||||
void draw(FontRenderer font, int doublePage, int left, int top){
|
||||
// Images
|
||||
for(int[] instance : instances){
|
||||
if(GuiWizardHandbook.singleToDoublePage(instance[0]) == doublePage){
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(location);
|
||||
@@ -77,6 +83,29 @@ class Image {
|
||||
top + instance[2] + height + CAPTION_OFFSET, GuiWizardHandbook.colours.get("caption"));
|
||||
}
|
||||
}
|
||||
|
||||
if(border){
|
||||
// Borders - do this after all the images are drawn so we only have to bind the handbook texture again once
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(GuiWizardHandbook.texture);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
for(int[] instance : instances){
|
||||
if(GuiWizardHandbook.singleToDoublePage(instance[0]) == doublePage){
|
||||
// Math.ceil accounts for odd-numbered image dimensions
|
||||
DrawingUtils.drawTexturedFlippedRect(left + instance[1] - BORDER, top + instance[2] - BORDER,
|
||||
TEXTURE_INSET_X, GuiWizardHandbook.GUI_HEIGHT, width / 2 + BORDER, height / 2 + BORDER,
|
||||
GuiWizardHandbook.TEXTURE_WIDTH, GuiWizardHandbook.TEXTURE_HEIGHT, false, false);
|
||||
DrawingUtils.drawTexturedFlippedRect(left + instance[1] + width / 2, top + instance[2] - BORDER,
|
||||
TEXTURE_INSET_X, GuiWizardHandbook.GUI_HEIGHT, MathHelper.ceil(width / 2f) + BORDER, height / 2 + BORDER,
|
||||
GuiWizardHandbook.TEXTURE_WIDTH, GuiWizardHandbook.TEXTURE_HEIGHT, true, false);
|
||||
DrawingUtils.drawTexturedFlippedRect(left + instance[1] - BORDER, top + instance[2] + height / 2,
|
||||
TEXTURE_INSET_X, GuiWizardHandbook.GUI_HEIGHT, width / 2 + BORDER, MathHelper.ceil(height / 2f) + BORDER,
|
||||
GuiWizardHandbook.TEXTURE_WIDTH, GuiWizardHandbook.TEXTURE_HEIGHT, false, true);
|
||||
DrawingUtils.drawTexturedFlippedRect(left + instance[1] + width / 2, top + instance[2] + height / 2,
|
||||
TEXTURE_INSET_X, GuiWizardHandbook.GUI_HEIGHT, MathHelper.ceil(width / 2f) + BORDER, MathHelper.ceil(height / 2f) + BORDER,
|
||||
GuiWizardHandbook.TEXTURE_WIDTH, GuiWizardHandbook.TEXTURE_HEIGHT, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +127,7 @@ class Image {
|
||||
image.textureWidth = JsonUtils.getInt(json, "texture_width", image.width);
|
||||
image.textureHeight = JsonUtils.getInt(json, "texture_height", image.height);
|
||||
image.caption = JsonUtils.getString(json, "caption", "");
|
||||
|
||||
image.border = JsonUtils.getBoolean(json, "border", true);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user