Code Monkey home page Code Monkey logo

Comments (44)

lukflug avatar lukflug commented on May 24, 2024 1

There's no need to edit the library. When instantiating an instance of GuiInterface, you can override the method. Here is the place where it is done in the example mod:
image

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024 1

Dragging it back on to screen is typically done by a "fixgui" command, implemented by the client, which resets the position of panels.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024 1

I'll try it on Linux tomorrow and see if the issue appears there as well.
Otherwise I can't do much about it until I get hold of a Mac or something.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

I do not own a mac, so I can't reproduce that issue and solve it.
Could you send a few screenshots of the issue?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

This screen recording should show enough; if you want me to try anything, just let me know.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Does this only happen on 1.18.2. Could you try running it on 1.17.1?
In any case, the root cause of the problem probably lies in the class GLInterface.
Namely the methods scissor and guiToScreen.
So when instantiating that class, it should work by overriding scissor and guiToScreen in some way.

Could you print out MinecraftClient.getInstance().getWindow().getWidth(), MinecraftClient.getInstance().getWindow().getScaledWidth() (and the corresponding methods for height)?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Output on 1.18.2:

Window width: 854
Window scaled width: 427
Window height: 480
Window scaled height: 240

Output on 1.17.1:

Window width: 854
Window scaled width: 427
Window height: 480
Window scaled height: 240

I didn't include a new visual for 1.17.1, because it produces the same issue.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Does the (non-scaled) width/height approximately correspond to the actual Minecraft window size in pixels?
And is your GUI size set to 2?
Could you try out other GUI sizes?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

The scale lines up, and I've tried all the different GUI scales, (they all render the same error).

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

So when instantiating the Interface here add following method to the anonymous class:

@Override
protected void scissor (Rectangle r) {
    width = MinecraftClient.getInstance().getWindow().getWidth();
    height = MinecraftClient.getInstance().getWindow().getWidth();
    GL11.glScissor(0,0,100,100);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
}

And then open a category and move it around until something appears (it doesn't have to necessarily be inside the category outline). Please report the location and size of the rectangle in which it appears.

Then vary the arguments of glScissor (the first two are x and y position, the last two are width and height):

GL11.glScissor(100,100,100,100);
GL11.glScissor(0,0,width/2,height/2);
GL11.glScissor(width/2,height/2,width/2,height/2);
GL11.glScissor(0,0,width,height);

I hope this information will help me get to the bottom of this issue.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Also, thank you very much for your patience and cooperation so far!

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Of course! However, I'm not quite sure how to add the method you asked, because I can't edit the library (It's included as an external library). Is there a different way I should include the code?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

I found a solution that fixed the background, but on the closing of the category it crashes the game, so I'm gonna keep trying.

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Update: using this method "works," but causes an issue where if a module's settings are open, they will continue to render outside of the category's frame while the module is opened.

@Override
protected void scissor (Rectangle r) {
	if (r==null) {
		GL11.glScissor(0,0,0,0);
		GL11.glEnable(GL11.GL_SCISSOR_TEST);
		return;
	}
	width = MinecraftClient.getInstance().getWindow().getScaledWidth();
	height = MinecraftClient.getInstance().getWindow().getScaledHeight();
	double scaleFactor = MinecraftClient.getInstance().getWindow().getScaleFactor();
	GL11.glScissor((int) (r.x * scaleFactor), (int) -(r.y * scaleFactor), (int) (r.width * scaleFactor), (int) (height * scaleFactor));
	GL11.glEnable(GL11.GL_SCISSOR_TEST);
}

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Yeah, the scissor method is responsible for selecting the right rectangle for it not to do that.
The problem is that the function transforming from GUI coordinates to screen pixels is wrong, so it either display too much or too little.
Does that cut anything or are all modules visible?
The solution to this entire issue is figuring out how the values that one plugs into glScissor map to the screen.

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Sorry, I don't really understand what you're asking for. Could you rephrase that?

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

The glScissor takes x, y, width, height values in pixels. However those pixels do not correspond to the values in the rectangle r passed as an argument for this method. The point of that method it to tell OpenGL to only draw pixels inside the category frame and ignore all pixels outside, so nothing is rendered outside the frame.
For whatever reason it seems to work differently on Macs.
What I'm trying to figure out, is how it behaves.

I was asking whether your solution cuts any part of the category out, or if it just renders all of the modules outside. I suspect it is not doing anything, because the y-value is negative.
This is why I was earlier asking for you to try out all those variants, I need to figure out what coordinates I need to pass to glScissor to obtain each corner.
image

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

It doesn't appear to cut any part of the category out.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Ok, so what happens if you make the y-value positive? I presume it regresses to what you had originally.
So what happens if you scissor a square of 100x100 at 0,0 (i.e. GL11.glScissor(0,0,100,100))?
In what corner of the screen would the content of the category become visible and how large is that square?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024
  1. When the y-value was positive, it flipped the background such that if I placed the category at the top of the screen, the background would be at the bottom (and vice versa). I believe I know why (which you will see in my next answer).
  2. When I scissor a square of 100x100 at (0,0), it places the square in the bottom-left corner and the size varies depending on the gui scale, but it's small/medium sized.

What I can't figure out is that the fourth argument in GL11.glscissor() has to be the window height, not r.height or else the modules' settings will not render (Doesn't make an issue bc I have a solution, but it might help in your problem solving).

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

ok, assuming it's bottom left and scales with GUI scale, this will hopefully work:

GL11.glScissor(r.x,MinecraftClient.getInstance().getWindow().getHeight()-r.y,r.width,r.height);

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Nope:
Screen Shot 2022-03-24 at 3 34 21 PM

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Also, unrelated issue: How do I drag a module back onto the screen when the top of it isn't on the screen?

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

oh, wait, I think I did a mistake, try:

GL11.glScissor(r.x,MinecraftClient.getInstance().getWindow().getHeight()-r.y-r.height,r.width,r.height);

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Still nope :/

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

I can give you another image but it looks pretty much the same

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

I have noticed some parts of Minecraft do it through RenderSystem, maybe all this was a conflict with Minecraft's own bookkeeping:

@override
protected void scissor (Rectangle r) {
	if (r==null) {
		RenderSystem.enableScissor(0,0,0,0);
		return;
	}
	Point a=guiToScreen(r.getLocation()),b=guiToScreen(new Point(r.x+r.width,r.y+r.height));
	if (!clipX) {
		a.x=0;
		b.x=MinecraftClient.getInstance().getWindow().getWidth();
	}
	RenderSystem.enableScissor(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.abs(b.x-a.x),Math.abs(b.y-a.y));
}

@Override
public void restore() {
	if (!clipRect.isEmpty()) {
		clipRect.pop();
		if (clipRect.isEmpty()) RenderSystem.disableScissor();
		else scissor(clipRect.peek());
	}
}

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

clipRect is showing up as an undeclared variable in your second method, so I can't test it...

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

So... I found clipRect's declaration and redeclared it locally.

However...
XD I don't even know what happened, but when I opened the category it made the screen start flashing and nothing was in the right place. Tbh my earlier solution seems pretty good; all I would need to add is a way for children to clip to the frame of their parents.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

all I would need to add is a way for children to clip to the frame of their parents

this is what I'm trying to figure out, the part that was broken is the part that does this clipping
your solution effectively disables it

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

clipRect is showing up as an undeclared variable in your second method, so I can't test it...

Sorry, I forgot to take that into account:

private final Stack<Rectangle> clipRect=new Stack<Rectangle>();

@Override
protected void scissor (Rectangle r) {
	if (r==null) {
		GL11.glScissor(0,0,0,0);
		GL11.glEnable(GL11.GL_SCISSOR_TEST);
		return;
	}
	Point a=guiToScreen(r.getLocation()),b=guiToScreen(new Point(r.x+r.width,r.y+r.height));
	if (!clipX) {
		a.x=0;
		b.x=MinecraftClient.getInstance().getWindow().getWidth();
	}
	GL11.glScissor(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.abs(b.x-a.x),Math.abs(b.y-a.y));
	GL11.glEnable(GL11.GL_SCISSOR_TEST);
}

@Override
public void window (Rectangle r) {
	if (clipRect.isEmpty()) {
		scissor(r);
		clipRect.push(r);
	} else {
		Rectangle top=clipRect.peek();
		if (top==null) {
			scissor(null);
			clipRect.push(null);
		} else {
			int x1,y1,x2,y2;
			x1=Math.max(r.x,top.x);
			y1=Math.max(r.y,top.y);
			x2=Math.min(r.x+r.width,top.x+top.width);
			y2=Math.min(r.y+r.height,top.y+top.height);
			if (x2>x1 && y2>y1) {
				Rectangle rect=new Rectangle(x1,y1,x2-x1,y2-y1);
				scissor(rect);
				clipRect.push(rect);
			} else {
				scissor(null);
				clipRect.push(null);
			}
		}
	}
}

@Override
public void restore() {
	if (!clipRect.isEmpty()) {
		clipRect.pop();
		if (clipRect.isEmpty()) GL11.glDisable(GL11.GL_SCISSOR_TEST);
		else scissor(clipRect.peek());
	}
}

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

That produces both issues:

  1. The first problem I had with rendering the background in the correct position
  2. The second problem of the modules spilling out too far vertically

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Can you check if the modules render outside of the category's frame too far on windows? I can't get to my (windows) laptop rn bc I'm at school, but I want to see if this is an issue outside of macos.

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Ok, I've tested it on Windows, and noticed I pasted the wrong code:

private final Stack<Rectangle> clipRect=new Stack<Rectangle>();

@Override
protected void scissor (Rectangle r) {
	if (r==null) {
		RenderSystem.enableScissor(0,0,0,0);
		return;
	}
	Point a=guiToScreen(r.getLocation()),b=guiToScreen(new Point(r.x+r.width,r.y+r.height));
	if (!clipX) {
		a.x=0;
		b.x=MinecraftClient.getInstance().getWindow().getWidth();
	}
	RenderSystem.enableScissor(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.abs(b.x-a.x),Math.abs(b.y-a.y));
}

@Override
public void window (Rectangle r) {
	if (clipRect.isEmpty()) {
		scissor(r);
		clipRect.push(r);
	} else {
		Rectangle top=clipRect.peek();
		if (top==null) {
			scissor(null);
			clipRect.push(null);
		} else {
			int x1,y1,x2,y2;
			x1=Math.max(r.x,top.x);
			y1=Math.max(r.y,top.y);
			x2=Math.min(r.x+r.width,top.x+top.width);
			y2=Math.min(r.y+r.height,top.y+top.height);
			if (x2>x1 && y2>y1) {
				Rectangle rect=new Rectangle(x1,y1,x2-x1,y2-y1);
				scissor(rect);
				clipRect.push(rect);
			} else {
				scissor(null);
				clipRect.push(null);
			}
		}
	}
}

@Override
public void restore() {
	if (!clipRect.isEmpty()) {
		clipRect.pop();
		if (clipRect.isEmpty()) RenderSystem.disableScissor();
		else scissor(clipRect.peek());
	}
}

The previous one didn't use RenderSystem and was essentially the same as the original.

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

This screwed up the screen even more... It caused Minecraft to only render a little square on the screen and everything else was just a strobe; I managed to exit the world through guess and check of the button's locations and only that little square would show part of the menu (the rest was still the word going crazy).

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

I tested it on Linux and unfortunately it worked fine.
I asked a couple of fellow utility mod devs for assistance.
Unfortunately, I don't know what else to do.
Well, there's one last idea of just overriding screenToGui and using getFramebufferWidth and getFramebufferHeight instead of getWidth and getHeight:

@Override
public Point screenToGui (Point p) {
	int resX=getWindowSize().width;
	int resY=getWindowSize().height;
	return new Point(p.x*resX/MinecraftClient.getInstance().getWindow().getFramebufferWidth(),resY-p.y*resY/MinecraftClient.getInstance().getWindow().getFramebufferHeight()-1);
}

from panelstudio.

master7720 avatar master7720 commented on May 24, 2024

My gui works fine on a Windows laptop, but I tested it on my MacBook and suddenly the modules inside the categories wouldn't render (They seem to be displaced by twice the distance they should be).

heres a fix dont use macOS

from panelstudio.

Z3R0-cmd avatar Z3R0-cmd commented on May 24, 2024

My gui works fine on a Windows laptop, but I tested it on my MacBook and suddenly the modules inside the categories wouldn't render (They seem to be displaced by twice the distance they should be).

heres a fix dont use macOS

vouch, it worked

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

heres a fix dont use macOS

vouch, it worked

First off, I already found a solution I didn’t care to share with people like you. Second, this thread is for people who care enough to contribute helpful comments and suggestions to assist in solving an issue; if all you have to provide is a sarcastic comment that doesn’t lead to the solution, please refrain from submitting any ideas on this issue. Thanks!

from panelstudio.

lukflug avatar lukflug commented on May 24, 2024

Could you please share your solution, so that I might be able to push a fix to the library or assist other people who might have this issue in the future?

from panelstudio.

CjPhoenix avatar CjPhoenix commented on May 24, 2024

Sorry, I didn't see this

I'm using the solution I posted earlier, and then I have the panels pop out on the sides instead of in the main area. It works the same way on Mac and Windows, and the scissor function override I made earlier functions correctly on Mac and Windows.

from panelstudio.

master7720 avatar master7720 commented on May 24, 2024

heres a fix dont use macOS

vouch, it worked

First off, I already found a solution I didn’t care to share with people like you. Second, this thread is for people who care enough to contribute helpful comments and suggestions to assist in solving an issue; if all you have to provide is a sarcastic comment that doesn’t lead to the solution, please refrain from submitting any ideas on this issue. Thanks!

It is a helpful commit dont use macOS

from panelstudio.

srgantmoomoo avatar srgantmoomoo commented on May 24, 2024

heres a fix dont use macOS

vouch, it worked

First off, I already found a solution I didn’t care to share with people like you. Second, this thread is for people who care enough to contribute helpful comments and suggestions to assist in solving an issue; if all you have to provide is a sarcastic comment that doesn’t lead to the solution, please refrain from submitting any ideas on this issue. Thanks!

It is a helpful commit dont use macOS

about as helpful as sending supplies to the Ukraine.

from panelstudio.

master7720 avatar master7720 commented on May 24, 2024

heres a fix dont use macOS

vouch, it worked

First off, I already found a solution I didn’t care to share with people like you. Second, this thread is for people who care enough to contribute helpful comments and suggestions to assist in solving an issue; if all you have to provide is a sarcastic comment that doesn’t lead to the solution, please refrain from submitting any ideas on this issue. Thanks!

It is a helpful commit dont use macOS

about as helpful as sending supplies to the Ukraine.

I mean come on dude macOS is TRASH use linux or windows

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.