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

GUI opens, but wont respond to any mouse events #12

Closed
ghost opened this issue Feb 26, 2021 · 14 comments
Closed

GUI opens, but wont respond to any mouse events #12

ghost opened this issue Feb 26, 2021 · 14 comments

Comments

@ghost
Copy link

ghost commented Feb 26, 2021

image
This is how it looks, but i cannot interact with it in any way. No dragging, no clicking, no expanding etc.

@lukflug
Copy link
Owner

lukflug commented Feb 26, 2021

Could you describe your problem more precisely?

  • What Minecraft version are you using?
  • What instructions have you followed?
  • Could you maybe paste the code you wrote that you think may be the problem?

@ghost
Copy link
Author

ghost commented Feb 26, 2021

Version i am using is 1.16.5, I just followed the general instructions in the readme. this is the whole gui class:

package me.constantindev.ccl.gui;

import com.lukflug.panelstudio.CollapsibleContainer;
import com.lukflug.panelstudio.DraggableContainer;
import com.lukflug.panelstudio.SettingsAnimation;
import com.lukflug.panelstudio.mc16.MinecraftGUI;
import com.lukflug.panelstudio.settings.SimpleToggleable;
import com.lukflug.panelstudio.theme.ColorScheme;
import com.lukflug.panelstudio.theme.GameSenseTheme;
import com.lukflug.panelstudio.theme.Theme;
import me.constantindev.ccl.etc.MType;
import me.constantindev.ccl.etc.base.Module;
import me.constantindev.ccl.etc.config.ClientConfig;
import me.constantindev.ccl.etc.reg.ModuleRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;

import java.awt.*;

public class ClickGUI extends MinecraftGUI {
    private final GUIInterface guiInterface;
    private final Theme theme;
    private final com.lukflug.panelstudio.ClickGUI gui;

    public ClickGUI() {
        guiInterface = new GUIInterface(true) {
            @Override
            protected String getResourcePrefix() {
                return "ccl:gui/";
            }

            @Override
            public void drawString(Point pos, String s, Color c) {
                end();
                MinecraftClient.getInstance().textRenderer.draw(new MatrixStack(), s, pos.x, pos.y, c.getRGB());
                begin();
            }

            @Override
            public int getFontWidth(String s) {
                return MinecraftClient.getInstance().textRenderer.getWidth(s);
            }

            @Override
            public int getFontHeight() {
                return MinecraftClient.getInstance().textRenderer.fontHeight;
            }
        };
        theme = new GameSenseTheme(new ColorScheme() {
            @Override
            public Color getActiveColor() {
                return new Color(20, 255, 255);
            }

            @Override
            public Color getInactiveColor() {
                return new Color(20, 50, 255);
            }

            @Override
            public Color getBackgroundColor() {
                return new Color(40, 40, 40);
            }

            @Override
            public Color getOutlineColor() {
                return new Color(100, 100, 100);
            }

            @Override
            public Color getFontColor() {
                return new Color(255, 40, 40);
            }

            @Override
            public int getOpacity() {
                return 255;
            }
        }, height, 2, 2);
        gui = new com.lukflug.panelstudio.ClickGUI(guiInterface, null);
        for (MType type : MType.ALL) {
            com.lukflug.panelstudio.DraggableContainer container = new DraggableContainer(type.toString(), null, theme.getContainerRenderer(), new SimpleToggleable(true), new SettingsAnimation(ClientConfig.animSpeed), new SimpleToggleable(true), new Point(50, 50), width);
            gui.addComponent(container);
            for (Module m : ModuleRegistry.getAll()) {
                if (m.type != type) continue;
                CollapsibleContainer mc = new CollapsibleContainer(m.name, null, theme.getContainerRenderer(), new SimpleToggleable(false), new SettingsAnimation(ClientConfig.animSpeed), m.isOn);
                container.addComponent(mc);
            }
        }
    }

    @Override
    protected com.lukflug.panelstudio.ClickGUI getGUI() {
        return gui;
    }

    @Override
    protected GUIInterface getInterface() {
        return guiInterface;
    }

    @Override
    protected int getScrollSpeed() {
        return 1;
    }
}

I can imagine some of the values I return like the scroll speed to affect this, since I did not have any true references for these.

@ghost ghost closed this as completed Feb 26, 2021
@ghost
Copy link
Author

ghost commented Feb 26, 2021

Closed by accident, ouch

@lukflug
Copy link
Owner

lukflug commented Feb 26, 2021

How do you open the GUI, do you call the MinecraftClient.getInstance().openScreen() method?

@lukflug lukflug reopened this Feb 26, 2021
@ghost
Copy link
Author

ghost commented Feb 26, 2021

Yes,

if (ModuleRegistry.getByName("clickgui").isOn.isOn()) {
            ModuleRegistry.getByName("clickgui").isOn.setState(false);
            MinecraftClient.getInstance().openScreen(new ClickGUI());
        }

@lukflug
Copy link
Owner

lukflug commented Feb 26, 2021

This is probably not related to the problem, but you should instantiate ClickGUI only once and not every time you open it.

Could you add following to the ClickGUI class and tell me if this print statement shows up when you click, to troubleshoot it?

@Override
public boolean mouseClicked(double mouseX, double mouseY, int clickedButton) {
    // <insert print statement here>
    return super.mouseClicked(mouseX,mousY,clickedButton)
}

@ghost
Copy link
Author

ghost commented Feb 26, 2021

image
it definitely does receive the events

@lukflug
Copy link
Owner

lukflug commented Feb 26, 2021

Ah, ok I just noticed the problem:
}, height, 2, 2);
The height field is inherited from a superclass and is actually zero. Replace height in this line by a number like 12.

@ghost
Copy link
Author

ghost commented Feb 26, 2021

still, nothing

@lukflug
Copy link
Owner

lukflug commented Feb 26, 2021

Could you replace this:
new DraggableContainer(type.toString(), null, theme.getContainerRenderer(), new SimpleToggleable(true), new SettingsAnimation(ClientConfig.animSpeed), new SimpleToggleable(true), new Point(50, 50), width);
by this:

new DraggableContainer(type.toString(), null, theme.getContainerRenderer(), new SimpleToggleable(true), new SettingsAnimation(ClientConfig.animSpeed), new SimpleToggleable(true), new Point(50, 50), width) {
    @Override
    public void render (Context context) {
        super.render(context);
        System.out.println(context.getHeight());
    }
}

@ghost
Copy link
Author

ghost commented Feb 26, 2021

I may have found the issue, lets see if this works

@ghost
Copy link
Author

ghost commented Feb 26, 2021

I found the issue. width is inherited from a superclass aswell and is also 0. Causes the hitbox to be 0 px wide

@ghost
Copy link
Author

ghost commented Feb 26, 2021

Next issue: the categories can somehow be toggled and wont really expand anywhere

@ghost
Copy link
Author

ghost commented Feb 26, 2021

Fixed it, all good now

@ghost ghost closed this as completed Feb 26, 2021
This issue was closed.
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

1 participant