Hello all, I am relatively new the the Minecrcaft modding scene and I'm looking for a good, 1.10/11 compatible gui library. I've done a little research and obviously I found a lot of things about GuiAPI. Unfortunately it hasn't been updated since 1.5.2. All the other APIs I found seem have suffered the same fate. Does anyone know of a solution for 1.10.x or 1.11.x?
Rollback Post to RevisionRollBack
Check out
my tool that makes fixing key conflicts a lot easier.
Why do you need a GUI library? What's wrong with making your own GUI the normal way?
Mainly because handling events for subclasses of GuiButton is a pain. If I do what I am doing now, which is using GuiScreen.addButton(<T extends GuiButton) and putting logic for the button in the actionPreformed(GuiButton) method of my gui, all the functionality is dependent on the gui and not the button, making a subclass of GuiButton less portable. I was hoping that instead of having to write my own button and screen classes with custom event handling and such, somebody would have already fixed my problem.
Rollback Post to RevisionRollBack
Check out
my tool that makes fixing key conflicts a lot easier.
Why don't you make a class that extends GuiButton that simply just adds a method called something like onClick which you just call from your GuiScreen#actionPerformed. That way it's now dependant on the button
Then any buttons you make, you can just override that method and do what you want.
Why don't you make a class that extends GuiButton that simply just adds a method called something like onClick which you just call from your GuiScreen#actionPerformed. That way it's now dependant on the button
Then any buttons you make, you can just override that method and do what you want.
So if you create a button class which contains this method you can call, and then all of your buttons extend this class, you could call that method for all of your buttons in the actionPerformed method.
So for example, if that button class is called MyButton and it contains a method called buttonClick, you could then in your actionPerformed do something like:
if(button instanceof MyButton)
((MyButton) button).buttonClick();
Sorry about lack of formatting, in doing this on my phone.
So if you create a button class which contains this method you can call, and then all of your buttons extend this class, you could call that method for all of your buttons in the actionPerformed method.
So for example, if that button class is called MyButton and it contains a method called buttonClick, you could then in your actionPerformed do something like:
if(button instanceof MyButton)
((MyButton) button).buttonClick();
Sorry about lack of formatting, in doing this on my phone.
If you look at the code I linked above, that's pretty much what I have. The only problem is that to excess the buttonClick method as you call it means that I have to remove the private modifier on an inner class. My only solution is to create a new class instead of using a nested one, but that seems unnecessary.
Rollback Post to RevisionRollBack
Check out
my tool that makes fixing key conflicts a lot easier.
You don't need that necessarily. If you create a parent button class like bright_spark told you, you can just call the onClick method regardless of the button or the actual implementation.
You don't need that necessarily. If you create a parent button class like bright_spark told you, you can just call the onClick method regardless of the button or the actual implementation.
I see where you are going, but that assumes that I have added the button to the buttonList, which is kind of my problem. I am trying to implement a NEI style drop-down list and the items in the list are instances of an inner class which I would like to be private as it is not used anywhere else. With the solution you and bright_spark are suggesting, I still have to put something in actionPreformed. Take a look:
for (GuiCategorySelector.ListItem item : categoryList.items) {
super.addButton(item);
}
well, then add that list to the gui and handle mouse clicks in the list, to check if a button was clicked. (the GUI knows about the position of the lsit, so you can pass relative coordinates to the list's onClicked method to see if you 've hit a button.
well, then add that list to the gui and handle mouse clicks in the list, to check if a button was clicked. (the GUI knows about the position of the lsit, so you can pass relative coordinates to the list's onClicked method to see if you 've hit a button.
This still requires GuiCategorySelector.ListItem to be visible... I'm just going to override handleMouseInput of GuiScreen and than call the input handler of my list instead. That should do pretty much what what I'm looking for.
Rollback Post to RevisionRollBack
Check out
my tool that makes fixing key conflicts a lot easier.
This still requires GuiCategorySelector.ListItem to be visible... I'm just going to override handleMouseInput of GuiScreen and than call the input handler of my list instead. That should do pretty much what what I'm looking for.
add an access transformer to Forge, that makes the field public
Hello all, I am relatively new the the Minecrcaft modding scene and I'm looking for a good, 1.10/11 compatible gui library. I've done a little research and obviously I found a lot of things about GuiAPI. Unfortunately it hasn't been updated since 1.5.2. All the other APIs I found seem have suffered the same fate. Does anyone know of a solution for 1.10.x or 1.11.x?
Check out
my tool that makes fixing key conflicts a lot easier.
Why do you need a GUI library? What's wrong with making your own GUI the normal way?
Mainly because handling events for subclasses of GuiButton is a pain. If I do what I am doing now, which is using GuiScreen.addButton(<T extends GuiButton) and putting logic for the button in the actionPreformed(GuiButton) method of my gui, all the functionality is dependent on the gui and not the button, making a subclass of GuiButton less portable. I was hoping that instead of having to write my own button and screen classes with custom event handling and such, somebody would have already fixed my problem.
Check out
my tool that makes fixing key conflicts a lot easier.
Why don't you make a class that extends GuiButton that simply just adds a method called something like onClick which you just call from your GuiScreen#actionPerformed. That way it's now dependant on the button
Then any buttons you make, you can just override that method and do what you want.
I've partially implemented this, but unfortunately I can't think of how do it in one specific case. Currently I'm exposing an inner class which is not ideal. You can see the example here: https://github.com/MrNerdy42/KeyboardWizard/blob/upstream/src/main/java/com/github/mrnerdy42/keywizard/gui/GuiKeyWizard.java (look around 77 and 270)
Check out
my tool that makes fixing key conflicts a lot easier.
So if you create a button class which contains this method you can call, and then all of your buttons extend this class, you could call that method for all of your buttons in the actionPerformed method.
So for example, if that button class is called MyButton and it contains a method called buttonClick, you could then in your actionPerformed do something like:
if(button instanceof MyButton)
((MyButton) button).buttonClick();
Sorry about lack of formatting, in doing this on my phone.
If you look at the code I linked above, that's pretty much what I have. The only problem is that to excess the buttonClick method as you call it means that I have to remove the private modifier on an inner class. My only solution is to create a new class instead of using a nested one, but that seems unnecessary.
Check out
my tool that makes fixing key conflicts a lot easier.
You don't need that necessarily. If you create a parent button class like bright_spark told you, you can just call the onClick method regardless of the button or the actual implementation.
I see where you are going, but that assumes that I have added the button to the buttonList, which is kind of my problem. I am trying to implement a NEI style drop-down list and the items in the list are instances of an inner class which I would like to be private as it is not used anywhere else. With the solution you and bright_spark are suggesting, I still have to put something in actionPreformed. Take a look:
And than in my actionPreformed method:
My select method is essentially the onClicked.
Check out
my tool that makes fixing key conflicts a lot easier.
well, then add that list to the gui and handle mouse clicks in the list, to check if a button was clicked. (the GUI knows about the position of the lsit, so you can pass relative coordinates to the list's onClicked method to see if you 've hit a button.
This still requires GuiCategorySelector.ListItem to be visible... I'm just going to override handleMouseInput of GuiScreen and than call the input handler of my list instead. That should do pretty much what what I'm looking for.
Check out
my tool that makes fixing key conflicts a lot easier.
add an access transformer to Forge, that makes the field public
That's not necessary, GuiCategorySelector.ListItem is my own class. It's just makes the code ugly if I make it public.
Check out
my tool that makes fixing key conflicts a lot easier.