Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't figure out how to get IInterface #46

Open
crabmiau opened this issue Jul 8, 2024 · 11 comments
Open

Can't figure out how to get IInterface #46

crabmiau opened this issue Jul 8, 2024 · 11 comments

Comments

@crabmiau
Copy link

crabmiau commented Jul 8, 2024

I'm trying to get the position of the watermark but it requires IInterface, I cant figure out where I can get it

@lukflug
Copy link
Owner

lukflug commented Jul 8, 2024

The instance you used to create the ClickGUI or HUD. If you're using the PanelStudio-MC support library, that's typically an instance of GUIInterface (a sublcass of MinecraftGUI). In the example mod, you can obtain it via the ClickGUI.getInterface() method.

@crabmiau
Copy link
Author

crabmiau commented Jul 9, 2024

I can't get it from another class since it has protected access

@crabmiau
Copy link
Author

crabmiau commented Jul 9, 2024

i figured it out but Point cfgvar5 = WatermarkModule.getComponent().getPosition(gui.getInterface()); returns java.awt.Point[x=1,y=1] even if its not at 1,1

@lukflug
Copy link
Owner

lukflug commented Jul 9, 2024

If it's the WatermarkModule from the example mod, this shouldn't be the case. I can't tell what is causing it without looking at the code tho.
If you're looking to save the positions of the panels in a config file, there's an interface for that. Implement the interface IConfigList, which models the config as a bunch of items representing panels (each represented with IPanelConfig) that have a title (which identifies the panel) and position, and a boolean state, (usually whether the panel is open or closed).
The methods you implement for those interfaces basically save/load the values to/from the config file. To load/save the config you called gui.loadConfig or gui.saveConfig with your IConfigList implementation.

@lukflug
Copy link
Owner

lukflug commented Jul 9, 2024

Also worth noting is that the position you get via getPosition is the top left corner of the component you're rendering to the HUD. This is not necessarily the one that is saved in the config file. For example, ListComponent, which WatermarkModule is based on, will store the x coordinate of the right edge, if it is configured to align to the right instead of the left.

@crabmiau
Copy link
Author

If it's the WatermarkModule from the example mod, this shouldn't be the case. I can't tell what is causing it without looking at the code tho. If you're looking to save the positions of the panels in a config file, there's an interface for that. Implement the interface IConfigList, which models the config as a bunch of items representing panels (each represented with IPanelConfig) that have a title (which identifies the panel) and position, and a boolean state, (usually whether the panel is open or closed). The methods you implement for those interfaces basically save/load the values to/from the config file. To load/save the config you called gui.loadConfig or gui.saveConfig with your IConfigList implementation.

I tried to do it but it seems its not well documented and I don't exactly know how to use it

@crabmiau
Copy link
Author

Are there any more simple examples?

@lukflug
Copy link
Owner

lukflug commented Jul 10, 2024

I don't see how this could get much simpler. Most of the code is related to JSON loading/saving, which will have to be replaced by your own specific loading/saving code anyways.

@crabmiau
Copy link
Author

and the example also seems old

@lukflug
Copy link
Owner

lukflug commented Jul 10, 2024

Whoops, I linked the wrong branch: https://github.com/IUDevman/gamesense-client/blob/d2.3.1/src/main/java/com/gamesense/client/clickgui/GuiConfig.java
At any rate, the interface haven't changed since then, so it shouldn't matter that much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants