Skip to content

Commit

Permalink
Reworked wardrobe to have a larger colour palette & something else!
Browse files Browse the repository at this point in the history
  • Loading branch information
RiskyKen committed Mar 1, 2020
1 parent 53ab53a commit e0dab3e
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 39 deletions.
Binary file modified image src/gui/wardrobe.pdn
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import moe.plushie.armourers_workshop.client.lib.LibGuiResources;
import moe.plushie.armourers_workshop.client.texture.PlayerTexture;
import moe.plushie.armourers_workshop.common.data.type.TextureType;
import moe.plushie.armourers_workshop.common.lib.LibModInfo;
Expand All @@ -26,47 +27,63 @@

@SideOnly(Side.CLIENT)
public final class GuiHelper {

private static final ResourceLocation PLAYER_TEXTURE = new ResourceLocation(LibGuiResources.PLAYER_INVENTORY);

private GuiHelper() {}

private GuiHelper() {
}

public static void drawPlayerHead(int x, int y, int size, String username) {

ResourceLocation rl = DefaultPlayerSkin.getDefaultSkinLegacy();
if (!StringUtils.isNullOrEmpty(username)) {
PlayerTexture playerTexture = getPlayerTexture(username, TextureType.USER);
rl = playerTexture.getResourceLocation();
rl = playerTexture.getResourceLocation();
}
Minecraft.getMinecraft().renderEngine.bindTexture(rl);

int sourceSize = 8;

// Face
Gui.drawScaledCustomSizeModalRect(x + 1, y + 1, 8, 8, sourceSize, sourceSize, size, size, 64, 64);
// Overlay
Gui.drawScaledCustomSizeModalRect(x, y, 40, 8, sourceSize, sourceSize, size + 2, size + 2, 64, 64);
}

private static PlayerTexture getPlayerTexture(String textureString, TextureType textureType) {
return ClientProxy.playerTextureDownloader.getPlayerTexture(textureString, textureType);
}


public static void renderPlayerInvTexture(int x, int y) {
Minecraft.getMinecraft().renderEngine.bindTexture(PLAYER_TEXTURE);
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, 176, 98, 256, 256);
}

public static void renderPlayerInvlabel(int x, int y, FontRenderer fontRenderer) {
renderPlayerInvlabel(x, y, fontRenderer, 0x333333);
}

public static void renderPlayerInvlabel(int x, int y, FontRenderer fontRenderer, int colour) {
fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), x + 8, y + 5, colour);
}

public static void renderLocalizedGuiName(FontRenderer fontRenderer, int xSize, String name) {
renderLocalizedGuiName(fontRenderer, xSize, name, null, 0x404040);
}

public static void renderLocalizedGuiName(FontRenderer fontRenderer, int xSize, String name, int colour) {
renderLocalizedGuiName(fontRenderer, xSize, name, null, colour);
}

public static void renderLocalizedGuiName(FontRenderer fontRenderer, int xSize, String name, String append) {
renderLocalizedGuiName(fontRenderer, xSize, name, append, 4210752);
}

public static void renderLocalizedGuiName(FontRenderer fontRenderer, int xSize, String name, String append, int colour) {
String unlocalizedName = "inventory." + LibModInfo.ID.toLowerCase() + ":" + name + ".name";
String localizedName = I18n.format(unlocalizedName);
String renderText = unlocalizedName;
if (!unlocalizedName.equals(localizedName)){
if (!unlocalizedName.equals(localizedName)) {
renderText = localizedName;
}
if (append != null) {
Expand All @@ -75,27 +92,29 @@ public static void renderLocalizedGuiName(FontRenderer fontRenderer, int xSize,
int xPos = xSize / 2 - fontRenderer.getStringWidth(renderText) / 2;
fontRenderer.drawString(renderText, xPos, 6, colour);
}

public static String getLocalizedControlName(String guiName, String controlName) {
String unlocalizedName = "inventory." + LibModInfo.ID.toLowerCase() + ":" + guiName + "." + controlName;
String localizedName = I18n.format(unlocalizedName);
if (!unlocalizedName.equals(localizedName)){
localizedName = localizedName.replace("%n", "\n");
localizedName = localizedName.replace("\\n", "\n");
if (!unlocalizedName.equals(localizedName)) {
return localizedName;
}
return unlocalizedName;
}

public static void drawHoveringText(List textList, int xPos, int yPos, FontRenderer font, int width, int height, float zLevel) {
if (!textList.isEmpty()) {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
//RenderHelper.disableStandardItemLighting();
// RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
int textWidth = 0;
Iterator iterator = textList.iterator();

while (iterator.hasNext()) {
String line = (String)iterator.next();
String line = (String) iterator.next();
int sWidth = font.getStringWidth(line);
if (sWidth > textWidth) {
textWidth = sWidth;
Expand All @@ -117,7 +136,7 @@ public static void drawHoveringText(List textList, int xPos, int yPos, FontRende
if (renderY + textHeight + 6 > height) {
renderY = height - textHeight - 6;
}

if (renderY < 5) {
renderY = 5;
}
Expand All @@ -137,7 +156,7 @@ public static void drawHoveringText(List textList, int xPos, int yPos, FontRende
drawGradientRect(renderX - 3, renderY + textHeight + 2, renderX + textWidth + 3, renderY + textHeight + 3, l1, l1, zLevel);

for (int i2 = 0; i2 < textList.size(); ++i2) {
String line = (String)textList.get(i2);
String line = (String) textList.get(i2);
font.drawStringWithShadow(line, renderX, renderY, -1);
if (i2 == 0) {
renderY += 2;
Expand All @@ -146,13 +165,13 @@ public static void drawHoveringText(List textList, int xPos, int yPos, FontRende
}

zLevel = 0.0F;
//GL11.glEnable(GL11.GL_LIGHTING);
// GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
//RenderHelper.enableGUIStandardItemLighting();
// RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
}

private static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel) {
float f = (startColor >> 24 & 255) / 255.0F;
float f1 = (startColor >> 16 & 255) / 255.0F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void initGui() {

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
//this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
//this.renderHoveredToolTip(mouseX, mouseY);
}

protected void tabChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
import moe.plushie.armourers_workshop.client.gui.style.GuiResourceManager;
import moe.plushie.armourers_workshop.client.gui.style.GuiStyle;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeColourSettings;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeContributor;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeDisplaySettings;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeDyes;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeOutfits;
import moe.plushie.armourers_workshop.client.gui.wardrobe.tab.GuiTabWardrobeSkins;
import moe.plushie.armourers_workshop.client.lib.LibGuiResources;
import moe.plushie.armourers_workshop.client.render.ModRenderHelper;
import moe.plushie.armourers_workshop.common.Contributors;
import moe.plushie.armourers_workshop.common.Contributors.Contributor;
import moe.plushie.armourers_workshop.common.capability.entityskin.EntitySkinCapability;
import moe.plushie.armourers_workshop.common.capability.wardrobe.IWardrobeCap;
import moe.plushie.armourers_workshop.common.capability.wardrobe.player.IPlayerWardrobeCap;
Expand All @@ -34,7 +37,6 @@
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
Expand All @@ -59,6 +61,7 @@ public class GuiWardrobe extends GuiTabbed<ContainerSkinWardrobe> {
private final GuiTabWardrobeDisplaySettings tabDisplaySetting;
private final GuiTabWardrobeColourSettings tabColourSettings;
private final GuiTabWardrobeDyes tabDyes;
private final GuiTabWardrobeContributor tabContributor;

EntitySkinCapability skinCapability;
EntityPlayer player;
Expand All @@ -77,12 +80,13 @@ public GuiWardrobe(InventoryPlayer inventory, EntitySkinCapability skinCapabilit

// Tab size 21
this.xSize = 278;
this.ySize = 240;
this.ySize = 250;

this.player = inventory.player;
this.skinCapability = skinCapability;
isPlayer = wardrobeCapability instanceof IPlayerWardrobeCap;
boolean isCreative = player.capabilities.isCreativeMode;
tabController.setTabsPerSide(5);

tabSkins = new GuiTabWardrobeSkins(tabList.size(), this);
tabList.add(tabSkins);
Expand Down Expand Up @@ -131,10 +135,28 @@ public GuiWardrobe(InventoryPlayer inventory, EntitySkinCapability skinCapabilit
.setPadding(0, 4, 3, 3)
.setVisable(!isPlayer | (isPlayer & (ConfigHandler.wardrobeTabDyes | isCreative))));

Contributor contributor = Contributors.INSTANCE.getContributor(player.getGameProfile());


tabContributor = new GuiTabWardrobeContributor(tabList.size(), this);
tabList.add(tabContributor);
tabController.addTab(new GuiTab(tabController, GuiHelper.getLocalizedControlName(GUI_NAME, "tab.contributor"))
.setIconLocation(32, 128)
.setTabTextureSize(26, 30)
.setPadding(0, 4, 3, 3)
.setVisable(contributor != null));


tabController.setActiveTabIndex(getActiveTab());

tabChanged();
}

@Override
public void initGui() {
super.initGui();
tabController.initGui(getGuiLeft() - 17, guiTop, xSize + 42, ySize);
}

@Override
protected int getActiveTab() {
Expand All @@ -151,6 +173,10 @@ public ContainerSkinWardrobe getContainer() {
return (ContainerSkinWardrobe) inventorySlots;
}

private void setSlotVisibilityPlayerInv(boolean visible) {
setSlotVisibility(getContainer().getPlayerInvStartIndex(), getContainer().getPlayerInvEndIndex(), visible);
}

private void setSlotVisibilitySkins(boolean visible) {
setSlotVisibility(getContainer().getIndexSkinsStart(), getContainer().getIndexSkinsEnd(), visible);
}
Expand All @@ -171,10 +197,15 @@ private void setSlotVisibility(int start, int end, boolean visible) {
}
}
}

private boolean tabNeedsPlayerSlots(int tabId) {
return tabId == tabSkins.getTabId() | tabId == tabOutfits.getTabId() | tabId == tabDyes.getTabId();
}

@Override
protected void tabChanged() {
super.tabChanged();
setSlotVisibilityPlayerInv(tabNeedsPlayerSlots(getActiveTab()));
setSlotVisibilitySkins(getActiveTab() == tabSkins.getTabId());
setSlotVisibilityDyes(getActiveTab() == tabDyes.getTabId());
setSlotVisibilityOutfits(getActiveTab() == tabOutfits.getTabId());
Expand All @@ -185,16 +216,21 @@ protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.enableBlend();
mc.renderEngine.bindTexture(TEXTURE_1);
this.drawTexturedModalRect(getGuiLeft(), getGuiTop(), 0, 0, 256, 240);
this.drawTexturedModalRect(getGuiLeft(), getGuiTop(), 0, 0, 256, 151);
mc.renderEngine.bindTexture(TEXTURE_2);
this.drawTexturedModalRect(getGuiLeft() + 256, getGuiTop(), 0, 0, 22, 151);

for (int i = 0; i < tabList.size(); i++) {
GuiTabPanel tab = tabList.get(i);
if (tab.getTabId() == getActiveTab()) {
tab.drawBackgroundLayer(partialTickTime, mouseX, mouseY);
}
}

if (tabNeedsPlayerSlots(getActiveTab())) {
GuiHelper.renderPlayerInvTexture(getGuiLeft() + 51, getGuiTop() + 152);
}

if (rotatingPlayer) {
playerRotation += mouseX - lastMouseX;
if (playerRotation < 0F) {
Expand All @@ -219,8 +255,9 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
tab.drawForegroundLayer(mouseX, mouseY, 0);
}
}
// Player inventory label.
this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 58, this.ySize - 96 + 2, guiStyle.getColour("text"));
if (tabNeedsPlayerSlots(getActiveTab())) {
GuiHelper.renderPlayerInvlabel(51, 152, fontRenderer, guiStyle.getColour("text"));
}
GL11.glPushMatrix();
GL11.glTranslatef(-guiLeft, -guiTop, 0F);
tabController.drawHoverText(mc, mouseX, mouseY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
@SideOnly(Side.CLIENT)
public class GuiTabWardrobeColourSettings extends GuiTabPanel {

private static final ResourceLocation TEXTURE = new ResourceLocation(LibGuiResources.GUI_WARDROBE_2);
private static final ResourceLocation TEXTURE_1 = new ResourceLocation(LibGuiResources.GUI_WARDROBE_1);
private static final ResourceLocation TEXTURE_2 = new ResourceLocation(LibGuiResources.GUI_WARDROBE_2);
private static final ResourceLocation GUI_JSON = new ResourceLocation(LibGuiResources.JSON_WARDROBE);
private static final ResourceLocation TEXTURE_BUTTONS = new ResourceLocation(LibGuiResources.CONTROL_BUTTONS);

Expand Down Expand Up @@ -236,9 +237,13 @@ public void drawBackgroundLayer(float partialTickTime, int mouseX, int mouseY) {
// Acc colour display
drawColourDisplay(159, 70, colourMisc);
GlStateManager.color(1F, 1F, 1F, 1F);

// Palette
mc.renderEngine.bindTexture(TEXTURE);
this.drawTexturedModalRect(this.x + 83, this.y + 88, 22, 0, 128, 56);
mc.renderEngine.bindTexture(TEXTURE_1);
this.drawTexturedModalRect(this.x, this.y + 152, 0, 152, 256, 98);

mc.renderEngine.bindTexture(TEXTURE_2);
this.drawTexturedModalRect(this.x + 256, this.y + 152, 0, 152, 22, 98);
}

private void drawColourDisplay(int x, int y, Color colour) {
Expand Down Expand Up @@ -277,6 +282,8 @@ public void drawForegroundLayer(int mouseX, int mouseY, float partialTickTime) {
fontRenderer.drawString(GuiHelper.getLocalizedControlName(guiName, "label.eyeColour") + ":", 83, 58, guiStyle.getColour("text"));
fontRenderer.drawString(GuiHelper.getLocalizedControlName(guiName, "label.miscColour") + ":", 159, 58, guiStyle.getColour("text"));

fontRenderer.drawString(GuiHelper.getLocalizedControlName(guiName, "label.palette"), 6, 152 + 5, guiStyle.getColour("text"));

getColours();

if (selectingColourType == ExtraColourType.SKIN & selectingColour != null) {
Expand Down
Loading

0 comments on commit e0dab3e

Please sign in to comment.