Jump to content

[1.11.2] [SOLVED] Remember which buttons are enabled when resizing Minecraft window


Recommended Posts

Posted (edited)

I am making a GUI in which the player can click various buttons to disable/hide them (similar to the knapping interface in Terrafirmacraft). The problem is that whenever the Minecraft window is resized, the GUI refreshes and redraws all the buttons as enabled. The buttons are all drawn in #initGui which I realize is called every time the screen is resized. But I don't know how else to do it. Is there a way to get the GUI to remember which buttons are disabled when resizing or redrawing the screen? Or should I be drawing them in a different method?

Edited by Daeruin
Marking solved
Posted

Thank you. It's obvious, now that you say it. :)

 

I created a List of Boolean and initialize it in the constructor to an empty ArrayList. I populate it alongside the standard buttonList as I create the buttons in initGui. When a button gets disabled, I update the List so the corresponding boolean there is set to false. When running initGui, as I create each button, I first check to see if that button's boolean in the List is already set to false; if so, the button already exists and needs to be disabled when redrawing the screen.

 

It's working great.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.