andGarrett Posted October 10, 2019 Posted October 10, 2019 I'm thinking about adding a popup window in one of my container screens. would I need to have a screen within a screen, and if so how? Quote
SerpentDagger Posted October 10, 2019 Posted October 10, 2019 It's pretty much up to you. There are a couple different approaches to take. Either you could have another gui class and offload more functions from the main window into the popup one, or you could create something yourself to handle the instructions from the main window that wouldn't be as complicated or sophisticated as a new gui (for example, something that simply drew an image when told to, held its x & y, etc). After doing either of those things, you could have the popup window be contained and controlled by the primary window, which would just involve having them as fields within that class and doing whatever needs to be done to them through that class. Or you could keep the handling of the popup window external, doing things to it alongside the main window. That would leak a little more gui handling into the outside world though. 1 Quote Fancy 3D Graphing Calculator mod, with many different coordinate systems. Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.
andGarrett Posted October 11, 2019 Author Posted October 11, 2019 (edited) On 10/10/2019 at 12:34 AM, SerpentDagger said: It's pretty much up to you. There are a couple different approaches to take. Either you could have another gui class and offload more functions from the main window into the popup one, or you could create something yourself to handle the instructions from the main window that wouldn't be as complicated or sophisticated as a new gui (for example, something that simply drew an image when told to, held its x & y, etc). After doing either of those things, you could have the popup window be contained and controlled by the primary window, which would just involve having them as fields within that class and doing whatever needs to be done to them through that class. Or you could keep the handling of the popup window external, doing things to it alongside the main window. That would leak a little more gui handling into the outside world though. I created my own popup window class that extends "Screen", but it seems to replace the original screen that spawns it. is it possible to have the popup on top of the original screen? I could do what you said about just drawing the popup over the main screen, but then I would have to find a way to disable all mouse click events on the main screen, and that seems tedious. Edited October 11, 2019 by andGarrett Quote
andGarrett Posted October 12, 2019 Author Posted October 12, 2019 can there only be one active "screen" at any given time? Quote
SerpentDagger Posted October 12, 2019 Posted October 12, 2019 15 minutes ago, andGarrett said: can there only be one active "screen" at any given time? Sorry, looking over the code it seems that the method that opens a GUI also closes the current one, and an instance of Minecraft has a single currentScreen field, which is changed when a new screen is opened. However, you can still accomplish the same thing by, instead of calling the opening method of Minecraft, having an instance of your popup window stored in the main one, and calling its key methods through the main window. For example, when the button or trigger activates this popup window, call its initGui()* method, and toggle a boolean that allows its drawScreen()* method to be run during each call of your main window's drawScreen()*. *I think the names of methods may have changed between 1.12 and 1.14, but according to the 1.13/1.14 update primer, the underlying substance hasn't. Let me know if I'm sorely mistaken. Quote Fancy 3D Graphing Calculator mod, with many different coordinate systems. Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.
andGarrett Posted October 12, 2019 Author Posted October 12, 2019 21 minutes ago, SerpentDagger said: Sorry, looking over the code it seems that the method that opens a GUI also closes the current one, and an instance of Minecraft has a single currentScreen field, which is changed when a new screen is opened. However, you can still accomplish the same thing by, instead of calling the opening method of Minecraft, having an instance of your popup window stored in the main one, and calling its key methods through the main window. For example, when the button or trigger activates this popup window, call its initGui()* method, and toggle a boolean that allows its drawScreen()* method to be run during each call of your main window's drawScreen()*. *I think the names of methods may have changed between 1.12 and 1.14, but according to the 1.13/1.14 update primer, the underlying substance hasn't. Let me know if I'm sorely mistaken. Thanks, I decided to write an inner class that does what you described in your first reply. I figured out a few things that make it much easier than I had originally thought. 1 Quote
Recommended Posts
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.