mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 01:27:27 +00:00
Add Special Icons to Side Buttons for Inventory
This commit is contained in:
1 parent
0f95307664
commit
28b92396d0
3 files changed
+37
-8
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomItems;
|
||||
@@ -12,6 +13,8 @@ import tconstruct.client.tabs.TabRegistry;
|
||||
|
||||
public class GuiCNPCInventory extends GuiNPCInterface {
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
public static final ResourceLocation specialIcons = new ResourceLocation("customnpcs","textures/gui/icons.png");
|
||||
|
||||
public static int activeTab = 0;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@@ -26,25 +29,38 @@ public class GuiCNPCInventory extends GuiNPCInterface {
|
||||
super.initGui();
|
||||
guiTop +=10;
|
||||
|
||||
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + 3, 22, 22, "");
|
||||
int y = 3;
|
||||
GuiMenuSideButton questsButton = new GuiMenuSideButton(100, guiLeft + xSize + 37, this.guiTop + y, 22, 22, "");
|
||||
questsButton.rightSided = true;
|
||||
questsButton.active = activeTab == 0;
|
||||
questsButton.renderStack = new ItemStack(CustomItems.letter);
|
||||
questsButton.renderIconPosX = 32;
|
||||
questsButton.renderResource = specialIcons;
|
||||
addButton(questsButton);
|
||||
|
||||
GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + 3 + 21, 22, 22, "");
|
||||
y += 21;
|
||||
GuiMenuSideButton partyButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, "");
|
||||
partyButton.rightSided = true;
|
||||
partyButton.active = activeTab == 1;
|
||||
partyButton.renderStack = new ItemStack(CustomItems.bag);
|
||||
partyButton.renderResource = specialIcons;
|
||||
addButton(partyButton);
|
||||
|
||||
if(ConfigClient.enableFactionTab){
|
||||
GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + 3 + 21*2, 22, 22, "");
|
||||
y += 21;
|
||||
GuiMenuSideButton factionButton = new GuiMenuSideButton(102, guiLeft + xSize + 37, this.guiTop + y, 22, 22, "");
|
||||
factionButton.rightSided = true;
|
||||
factionButton.active = activeTab == 2;
|
||||
factionButton.renderStack = new ItemStack(CustomItems.wallBanner);
|
||||
factionButton.renderIconPosX = 48;
|
||||
factionButton.renderResource = specialIcons;
|
||||
addButton(factionButton);
|
||||
}
|
||||
|
||||
y += 21;
|
||||
GuiMenuSideButton clientButton = new GuiMenuSideButton(101, guiLeft + xSize + 37, this.guiTop + y, 22, 22, "");
|
||||
clientButton.rightSided = true;
|
||||
clientButton.active = activeTab == 3;
|
||||
clientButton.renderIconPosX = 16;
|
||||
clientButton.renderResource = specialIcons;
|
||||
addButton(clientButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@@ -16,6 +17,9 @@ public class GuiMenuSideButton extends GuiNpcButton{
|
||||
public boolean active;
|
||||
public boolean rightSided;
|
||||
public ItemStack renderStack;
|
||||
public ResourceLocation renderResource;
|
||||
public int renderIconPosX = 0;
|
||||
public int renderIconPosY = 0;
|
||||
|
||||
public GuiMenuSideButton(int id, int x, int y, String s){
|
||||
this(id, x, y, 200, 20, s);
|
||||
@@ -54,6 +58,15 @@ public class GuiMenuSideButton extends GuiNpcButton{
|
||||
}
|
||||
mouseDragged(minecraft, i, j);
|
||||
|
||||
// Render Custom Icon
|
||||
if (this.renderResource != null) {
|
||||
this.zLevel = 100.0F;
|
||||
minecraft.renderEngine.bindTexture(renderResource);
|
||||
drawTexturedModalRect(xPosition + 2, yPosition + height/2 - 8, renderIconPosX, renderIconPosY, 16, 16);
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
|
||||
if (this.renderStack != null) {
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
this.zLevel = 100.0F;
|
||||
@@ -71,7 +84,7 @@ public class GuiMenuSideButton extends GuiNpcButton{
|
||||
this.zLevel = 0.0F;
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
}
|
||||
|
||||
|
||||
String text = "";
|
||||
float maxWidth = width * 0.75f;
|
||||
if(fontrenderer.getStringWidth(displayString) > maxWidth){
|
||||
@@ -102,7 +115,7 @@ public class GuiMenuSideButton extends GuiNpcButton{
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int i, int j){
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user