Code Monkey home page Code Monkey logo

Comments (14)

lukflug avatar lukflug commented on May 24, 2024

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?

from panelstudio.

 avatar commented on May 24, 2024

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.

from panelstudio.

 avatar commented on May 24, 2024

Closed by accident, ouch

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

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

from panelstudio.

 avatar commented on May 24, 2024

Yes,

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

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

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)
}

from panelstudio.

 avatar commented on May 24, 2024

image
it definitely does receive the events

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

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.

from panelstudio.

 avatar commented on May 24, 2024

still, nothing

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

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());
    }
}

from panelstudio.

 avatar commented on May 24, 2024

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

from panelstudio.

 avatar commented on May 24, 2024

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

from panelstudio.

 avatar commented on May 24, 2024

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

from panelstudio.

 avatar commented on May 24, 2024

Fixed it, all good now

from panelstudio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.