I'm not sure how to render the buttons in a different way so that they aren't always on top of everything.
In my GUI O'm working on, the text and item tooltips and etc are all covered by buttons (scrollbars included).
I've tried messing around with it to no avail, and I know it has to be possible but I'm not sure how.
And I can't find any materials on it online or a specific difference in vanilla code
Any help is greatly appreciated
I believe GUI elements rendering depends on where they are in the code. So if you render your buttons after your text, the buttons will be in front of the text. If you render your text after your buttons, the text will be in front.
I believe GUI elements rendering depends on where they are in the code. So if you render your buttons after your text, the buttons will be in front of the text. If you render your text after your buttons, the text will be in front.
I have everything within drawScreen layered in order from bg to fore front so that shouldn't be the problem.
Buttons are created in initGui though so it's a different function entirely.
Render your buttons first, then your other components last.
That will make it so buttons are behind your other components. Or so I think.
If that doesn't work, I think using glPushMatrix and glPopMatrix on the buttons, it will make them "group" together.
When I grouped buttons together it didnt change the fact that it's rendered on top and when I view item tooltips the buttons all dim.
So everyone is recommending rendering my buttons first which is the obvious move to make and something I tried, but how can I do it if they are in two separate functions.
Well about moving item tool tips and stuff getting dim, you need to set glColor to white before drawing something with a texture, but maybe you're already doing that and I don't know what I'm talking about.
Edit: actually you're probably using some automated functions to draw the textured rect. In, that case everything should be sorted out for you.
Well about moving item tool tips and stuff getting dim, you need to set glColor to white before drawing something with a texture, but maybe you're already doing that and I don't know what I'm talking about.
Edit: actually you're probably using some automated functions to draw the textured rect. In, that case everything should be sorted out for you.
It still doesn't help with the layering though sadly
[/p]
[p]public void initGui()
{
this.buttonList.clear();
Keyboard.enableRepeatEvents(true);[/p]
[p]int k = (this.width - this.craftingImageWidth) / 2;
int l = (this.height - 159) / 2;
int l2 = (this.height - 130) / 2;
this.buttonList.add(this.buttonNewTab = new GUI_Crafting_Inventory.NewTab(0, k + 7, l + 7, 1));
this.buttonList.add(this.buttonNewTab2 = new GUI_Crafting_Inventory.NewTab(1, k + 73, l + 7, 2));
this.buttonList.add(this.buttonNewTab3 = new GUI_Crafting_Inventory.NewTab(2, k + 139, l + 7, 3));
this.buttonList.add(new GuiSlider(3, k + 64, l2 + 6));
//this.buttonList.add(new GuiSliderHorizontal(3, k + 10, l + 10));
this.buttonList.add(this.buttonCraft = new GUI_Crafting_Inventory.Craft(4, k + 120, l2 + 110));
this.updateButtons();
}[/p]
[p]
is how im adding my buttons (I removed the gl code)
and then a snippet from my drawScreen is
[/p]
[p]public void drawScreen(int par1, int par2, float par3)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);[/p]
[p]this.drawTexturedModalRect(k + 129, l + 8, 0, 175, 17, 17);
if (itemstack1 != null) {
this.drawTexturedModalRect(k + 81, l + 40, 0, 175, 17, 17);
}
if (itemstack2 != null) {
this.drawTexturedModalRect(k + 113, l + 40, 0, 175, 17, 17);
}[/p]
[p]GL11.glPushMatrix();
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glEnable(GL11.GL_LIGHTING);
itemRender.zLevel = 100.0F;[/p]
[p]//Ingredient 8
if (itemstack8 != null) {
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack8, k + 178, l + 68);
itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack8, k + 178, l + 68);
if (itemstack8M > 0) {
etc code
for (int i = 0; i < 36; ++i) {
ItemStack stack = invPlayer.getStackInSlot(i);
if (stack != null && (stack.getItem() == itemstack1.getItem())) {
etc code
}
}
String i0 = (quantityHeld >= itemstack8M ? EnumChatFormatting.BLUE : EnumChatFormatting.RED) + "" + quantityHeld + "/" + itemstack8M;
etc code
int i1 = this.fontRendererObj.getStringWidth(i0);
this.fontRendererObj.drawString(i0, k + 186 - (i1 / 2), l + 86, 0);
}
}[/p]
[p]itemRender.zLevel = 0.0F;
GL11.glDisable(GL11.GL_LIGHTING);[/p]
[p]if (this.func_146978_c(129, 8, 16, 16, par1, par2) && itemstack != null)
{
this.renderToolTip(itemstack, par1, par2);
}
GL11.glPopMatrix();[/p]
[p]
The 2nd code is very very fragmented from the large function, but I'm not sure what to mark as the culprit of this so I tried to include what I thought would be helpful. And ironically from messing around now the dimming when I render tooltips is permanent. I'll mess around with that in the morning
Assuming that this.buttonList is a list of the super class, if I were you I would make a replica of buttonList with a slighly different name and at every drawScreen loop through that list and call drawButton on each element. Because if buttonList belongs to the inherited class it's not surprising that it's doing whatever it wants to with it.
Assuming that this.buttonList is a list of the super class, if I were you I would make a replica of buttonList with a slighly different name and at every drawScreen loop through that list and call drawButton on each element. Because if buttonList belongs to the inherited class it's not surprising that it's doing whatever it wants to with it.
Great idea! Thanks for the help. It works perfectly now.
I'm not sure how to render the buttons in a different way so that they aren't always on top of everything.
In my GUI O'm working on, the text and item tooltips and etc are all covered by buttons (scrollbars included).
I've tried messing around with it to no avail, and I know it has to be possible but I'm not sure how.
And I can't find any materials on it online or a specific difference in vanilla code
Any help is greatly appreciated
Try rendering the text and stuff in a different position than the buttons.
Animate your minecraft builds with Animated Structures: Link Removed
I have but it covers the parts that are beneath the image.
I'm close to resorting to having invisible buttons and updating the background based on the hover state of a button's position.
It adds on extra work though and makes the code sloppier.
I believe GUI elements rendering depends on where they are in the code. So if you render your buttons after your text, the buttons will be in front of the text. If you render your text after your buttons, the text will be in front.
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
What do you mean by 'parts that are beneath the image'?
Animate your minecraft builds with Animated Structures: Link Removed
I have everything within drawScreen layered in order from bg to fore front so that shouldn't be the problem.
Buttons are created in initGui though so it's a different function entirely.
Like if the text starts to the left and is long enough that it intersects with the button then it is covered by the button.
Render your buttons first, then your other components last.
That will make it so buttons are behind your other components. Or so I think.
If that doesn't work, I think using glPushMatrix and glPopMatrix on the buttons, it will make them "group" together.
When I grouped buttons together it didnt change the fact that it's rendered on top and when I view item tooltips the buttons all dim.
So everyone is recommending rendering my buttons first which is the obvious move to make and something I tried, but how can I do it if they are in two separate functions.
Well about moving item tool tips and stuff getting dim, you need to set glColor to white before drawing something with a texture, but maybe you're already doing that and I don't know what I'm talking about.
Edit: actually you're probably using some automated functions to draw the textured rect. In, that case everything should be sorted out for you.
Animate your minecraft builds with Animated Structures: Link Removed
It still doesn't help with the layering though sadly
Maybe you could give more code?
Animate your minecraft builds with Animated Structures: Link Removed
and then a snippet from my drawScreen is
The 2nd code is very very fragmented from the large function, but I'm not sure what to mark as the culprit of this so I tried to include what I thought would be helpful. And ironically from messing around now the dimming when I render tooltips is permanent. I'll mess around with that in the morning
So, where are you actually rendering the buttons?
Animate your minecraft builds with Animated Structures: Link Removed
Oh right. It's reached by
Just one of the buttons used. This and the other buttons are below everything within the class file but that shouldn't change the layering.
I'm thinking I need to have this moved into drawScreen in order to have it work. In which case it'll have to be done differently.
(This method was taken from mc's book gui many weeks ago when I created a diff type of book and liked the button system)
but, do you know when drawButton is being called?
Animate your minecraft builds with Animated Structures: Link Removed
I would assume right as the buttons are initialized. I'll try messing around with it and see if I can fix it
Edit: changing the functions proved to ruin it.
And when testing the order drawScreen is run before either drawButtons are; so it makes sense why the buttons
are on top. I just need to figure out how to change that
Assuming that this.buttonList is a list of the super class, if I were you I would make a replica of buttonList with a slighly different name and at every drawScreen loop through that list and call drawButton on each element. Because if buttonList belongs to the inherited class it's not surprising that it's doing whatever it wants to with it.
Animate your minecraft builds with Animated Structures: Link Removed
Great idea! Thanks for the help. It works perfectly now.
That's great, it was my pleasure.
Animate your minecraft builds with Animated Structures: Link Removed