Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package de.eydamos.backpack.factory;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand All @@ -13,6 +15,7 @@
import de.eydamos.backpack.inventory.container.Boundaries;
import de.eydamos.backpack.inventory.container.ContainerAdvanced;
import de.eydamos.backpack.inventory.slot.SlotBackpack;
import de.eydamos.backpack.misc.Localizations;
import de.eydamos.backpack.saves.BackpackSave;
import de.eydamos.guiadvanced.form.Label;
import de.eydamos.guiadvanced.subpart.GuiSlot;
Expand Down Expand Up @@ -85,17 +88,26 @@ public GuiContainer getGuiContainer(BackpackSave backpack, IInventory[] inventor
int slotsPerRow = backpack.getSlotsPerRow();
int inventoryRows = (int) Math.ceil(inventories[1].getSizeInventory() / (float) slotsPerRow);
int textPositionY = 17 + inventoryRows * SLOT + 2;
int inventoryStart = container.getBoundary(Boundaries.INVENTORY);
int hotbarEnd = container.getBoundary(Boundaries.HOTBAR_END);

GuiSlot guiSlot;
for (int i = 0; i < container.inventorySlots.size(); i++) {
Slot slot = (Slot) container.inventorySlots.get(i);
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1);
int yOffset = (i >= inventoryStart && i < hotbarEnd) ? 44 : 0;
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, yOffset);
guiBackpack.addSubPart(guiSlot);
}

int inventorySpaceBefore = (int) Math.round(container.getWidth() / 2. - (SLOT * 9) / 2.);

guiBackpack.addSubPart(new Label(X_SPACING, 6, 0x404040, inventories[1].getInventoryName()));
String baseTitle = I18n.format(inventories[1].getInventoryName());
String guiTitle = baseTitle;
if (StatCollector.canTranslate(Localizations.GUI_TITLE_FORMAT)) {
guiTitle = I18n.format(Localizations.GUI_TITLE_FORMAT, baseTitle);
}

guiBackpack.addSubPart(new Label(X_SPACING, 6, 0x404040, guiTitle));
guiBackpack.addSubPart(new Label(inventorySpaceBefore, textPositionY, 0x404040, "container.inventory"));

return guiBackpack;
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/de/eydamos/backpack/factory/FactoryPersonalSlot.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.eydamos.backpack.factory;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.util.StatCollector;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -102,14 +104,23 @@ public GuiContainer getGuiContainer(PlayerSave player, IInventory[] inventories,
ContainerPersonalSlot container = (ContainerPersonalSlot) getContainer(player, inventories, entityPlayer);
GuiBackpack guiBackpack = new GuiBackpack(container);

int inventoryStart = container.getBoundary(Boundaries.INVENTORY);
int hotbarEnd = container.getBoundary(Boundaries.HOTBAR_END);
GuiSlot guiSlot;
for (int i = 0; i < container.inventorySlots.size(); i++) {
Slot slot = (Slot) container.inventorySlots.get(i);
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1);
int yOffset = (i >= inventoryStart && i < hotbarEnd) ? 44 : 0;
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, yOffset);
guiBackpack.addSubPart(guiSlot);
}

guiBackpack.addSubPart(new Label(X_SPACING, 6, 0x404040, container.getInventoryToSave().getInventoryName()));
String baseTitle = I18n.format(container.getInventoryToSave().getInventoryName());
String guiTitle = baseTitle;
if (StatCollector.canTranslate(Localizations.GUI_TITLE_FORMAT)) {
guiTitle = I18n.format(Localizations.GUI_TITLE_FORMAT, baseTitle);
}

guiBackpack.addSubPart(new Label(X_SPACING, 6, 0x404040, guiTitle));
guiBackpack.addSubPart(new Label(X_SPACING, 38, 0x404040, container.getInventoryPickup().getInventoryName()));

return guiBackpack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,16 @@ public GuiContainer getGuiContainer(BackpackSave backpack, IInventory[] inventor
ContainerAdvanced container = getContainer(backpack, inventories, entityPlayer);
GuiWorkbenchBackpack guiBackpack = new GuiWorkbenchBackpack(container);

int inventoryStart = container.getBoundary(Boundaries.INVENTORY);
int hotbarEnd = container.getBoundary(Boundaries.HOTBAR_END);
GuiSlot guiSlot;
for (int i = 0; i < container.inventorySlots.size(); i++) {
Slot slot = (Slot) container.inventorySlots.get(i);
int yOffset = (i >= inventoryStart && i < hotbarEnd) ? 44 : 0;
if (i == 0) {
guiSlot = new GuiSlot(slot.xDisplayPosition - 5, slot.yDisplayPosition - 5, 26);
guiSlot = new GuiSlot(slot.xDisplayPosition - 5, slot.yDisplayPosition - 5, 26, 26, yOffset);
} else {
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1);
guiSlot = new GuiSlot(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1, 18, 18, yOffset);
}
guiBackpack.addSubPart(guiSlot);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/de/eydamos/backpack/misc/Localizations.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Localizations {

public static final String LABEL_NEW_NAME = "text.backpack.new_name";
public static final String LABEL_BACKPACK_CONFIG = "text.backpack.configuration";
public static final String GUI_TITLE_FORMAT = "text.backpack.title_format";

public static final String BUTTON_OK = "button.backpack.ok";
public static final String BUTTON_CANCEL = "button.backpack.cancel";
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/de/eydamos/guiadvanced/subpart/GuiSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class GuiSlot implements AbstractGuiPart {
protected int relativePositionY;
protected int width;
protected int height;
protected int textureYOffset;

public GuiSlot(int posX, int posY) {
this(posX, posY, 18, 18);
Expand All @@ -24,8 +25,13 @@ public GuiSlot(int posX, int posY, int widthHeight) {
}

public GuiSlot(int posX, int posY, int width, int height) {
this(posX, posY, width, height, 0);
}

public GuiSlot(int posX, int posY, int width, int height, int textureYOffset) {
setWidth(width);
setHeight(height);
this.textureYOffset = textureYOffset;
relativePositionX = posX;
relativePositionY = posY;
}
Expand Down Expand Up @@ -54,46 +60,47 @@ public void setHeight(int value) {
public void draw(Minecraft mc, int mouseX, int mouseY, float something) {
Rectangle rectangle = new Rectangle(1, 1);
rectangle.startDrawing();
int yOffset = textureYOffset;
// draw upper left corner
rectangle.setBackgroundPosition(201, 0);
rectangle.setBackgroundPosition(201, yOffset);
rectangle.addBoxVertices(xPosition, yPosition);
// draw upper right corner
rectangle.setBackgroundPosition(218, 0);
rectangle.setBackgroundPosition(218, yOffset);
rectangle.addBoxVertices(xPosition + width - 1, yPosition);
// draw lower left corner
rectangle.setBackgroundPosition(201, 17);
rectangle.setBackgroundPosition(201, 17 + yOffset);
rectangle.addBoxVertices(xPosition, yPosition + height - 1);
// draw lower right corner
rectangle.setBackgroundPosition(218, 17);
rectangle.setBackgroundPosition(218, 17 + yOffset);
rectangle.addBoxVertices(xPosition + width - 1, yPosition + height - 1);

// borders top/bottom
rectangle.setWidth(width - 2);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_X);
// draw top border
rectangle.setBackgroundPosition(202, 0);
rectangle.setBackgroundPosition(202, yOffset);
rectangle.addBoxVertices(xPosition + 1, yPosition);
// draw bottom border
rectangle.setBackgroundPosition(202, 17);
rectangle.setBackgroundPosition(202, 17 + yOffset);
rectangle.addBoxVertices(xPosition + 1, yPosition + height - 1);

// borders left/right
rectangle.setWidth(1);
rectangle.setHeight(height - 2);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT_Y);
// draw left border
rectangle.setBackgroundPosition(201, 1);
rectangle.setBackgroundPosition(201, 1 + yOffset);
rectangle.addBoxVertices(xPosition, yPosition + 1);
// draw right border
rectangle.setBackgroundPosition(218, 1);
rectangle.setBackgroundPosition(218, 1 + yOffset);
rectangle.addBoxVertices(xPosition + width - 1, yPosition + 1);

// draw background
rectangle.setWidth(width - 2);
rectangle.setHeight(height - 2);
rectangle.setBackgroundSize(14, 14);
rectangle.setBackgroundRepeat(BackgroundRepeat.REPEAT);
rectangle.setBackgroundPosition(202, 1);
rectangle.setBackgroundPosition(202, 1 + yOffset);
rectangle.addBoxVertices(xPosition + 1, yPosition + 1);
rectangle.performDrawing();
}
Expand Down
Binary file modified src/main/resources/assets/backpack/textures/gui/guiCombined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading