Skip to content

Hud screen edit#77

Open
shvaich wants to merge 14 commits into
Alexdoru:masterfrom
shvaich:hud_screen_edit
Open

Hud screen edit#77
shvaich wants to merge 14 commits into
Alexdoru:masterfrom
shvaich:hud_screen_edit

Conversation

@shvaich

@shvaich shvaich commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

made changes to the hud edit screen and the hud button.
also removed 2 icons and added 2 icons

@Alexdoru

Alexdoru commented Jul 16, 2026

Copy link
Copy Markdown
Owner

I would like to keep the reset and move buttons accessible from the config gui screen

@shvaich

shvaich commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

RendererGuiButton UI:
2026-07-16_16 14 25

Buttons UI:
2026-07-16_16 14 55

Buttons Hover UI:
2026-07-16_16 15 03
2026-07-16_16 15 07

Dragging UI (invisible buttons):
2026-07-16_16 15 13

@shvaich

shvaich commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

if you want, I can add another button to the 'renderer edit screen' that when clicked will make all buttons invisible until a key is pressed or something like that

@shvaich

shvaich commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

I merged the updated master branch to this. looking back at previous messages you might've done this for me before

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class RendererGuiButton extends ConfigGuiButton {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the changes in this class, please roll back your changes and keep the two buttons like it was before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but I very much disagree with this.

  1. I am keeping the Move HUD Button but as shown in the image it is no longer an "Image Button" and its text is Position.
    If you like its text can be Move HUD.

  2. There is no reason for the Reset Button to be placed here.
    2.1. I am already creating such a button for use inside the Hud Edit Screen.
    2.2 It is bad placement. Players cannot see where the hud is once they press this button here, they have to press on the Move HUD aswell to see its new position.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok can you change the text to something else than "Position", "Move HUD" would be more explicit, also you might need to add a color to the palette for the text color

private final RendererPosition rendererPosition;
private final GuiScreen parent;
private final ColorPalette colorPalette;
private final Button[] buttons;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't make an array but create mutliple fields

this.rendererPosition.updateAbsolutePosition();
this.adjustBounds();
final ScaledResolution res = new ScaledResolution(mc);
this.rendererPosition.updateAbsolutePosition(res);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mark deprecated the method this.rendererPosition.updateAbsolutePosition(); that is now not used anymore


private GuiUtil() {}

public static final int MOUSE_LEFT = 0;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this field

@shvaich shvaich Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be used throughtout the codebase instead of the magic value when comparing with mouseButton.

This is not just for this pull request but for further onces aswell.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but I dislike it being here, just make it a local variable in the RendererEditGuiScreen

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the ConfigGuiScreen I can add an MouseClick enum or something to remove the magic numbers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this and I will make it a local variable for now.
but think of it like this, many different classes check mouseButton:
ConfigGuiScreen, RendererEditGuiScreen, ColorEditScreen, ConfigGuiButtons, etc...

and it would be convinient and easy to read if this value was shared.
also for developers who create their own elements.
and there is no need to create an enum for this, this is simple enough and very understandable to me and I assume other devs.
later on you can also add MOUSE_RIGHT = 1 if you want

Comment thread src/configlib/java/fr/alexdoru/configlib/lib/gui/GuiUtil.java

private static final class Button extends ClickGuiButton {
private final ResourceLocation icon;
private final String hoveringText;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the hovering text feature to the parrent class click gui button directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do this.
I also have an idea to add possible hovering text to ConfigUIElements like in my codebase.
I will show you what I mean in a different pull request but keep it in mind

drawTexturedModalRect(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16);
}

private static final class Button extends ClickGuiButton {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a standalone class named TexturedButton that draws the icon

if (clickedButtonIdx == 0) rendererPosition.resetToDefault();
else if (clickedButtonIdx == 1) rendererPosition.setRelativePosition(originalRelativeX, originalRelativeY);
else break success;
final ScaledResolution res = new ScaledResolution(mc);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save the scaled resolution as a field that is initializd in initGui

private int prevX, prevY;

public RendererEditGuiScreen(RendererManager rendererManager, IRenderer renderer, GuiScreen parent) {
public RendererEditGuiScreen(RendererManager rendererManager, IRenderer renderer, GuiScreen parent, ColorPalette colorPalette) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to add ColorPalette as a parameter just change the type of the parent parameter to ConfigGuiScreen

}
}
if (clickedButtonIdx != -1) {
success: {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't use labels and break and also this is bugged because if clickedButtonIdx is not 0 or not 1 it will loop infinitely

@shvaich shvaich Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are mistaken, this is not how either works.
the loop I have is itterating over the buttons array, it only breaks early if I find a clicked button because i can only click on one button.

now the label after it is just for simplicity, because if clickedButtonIdx is either 0 or 1 I am updating the relative position and then need to update the absolute position, so what I am doing is updating the relative position, (see if (clickedButtonIdx == 0) and else if (clickedButtonIdx == 1))
and then updating the absolute position and returning from the function to not trigger isDragging.
(see code after else break success)

if clickedButtonIdx isn't 0 or 1 it will simply break from the success block and move on to isDragging logic. (see else break success)

There is nothing in this code that can cause an infinite loop and the only reason its written this way is because if I do decide to add more buttons I can write the logic easily at the end of the success block

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if clickbutton == 2 it will loop indefinitely, also I have never seen labels and breaks outside of loop for a good reason you should not use them outside of loops plase change your code

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your reason for not wanting to use labels so I wont. but you are mistaken in your image.
what happens when you break from a labeled-block is that you go to the end of the block.
what would actually happen in my code if clickButton == 2 is that the code will continue from }.
example:

int clickButton = 2;
success: {
    if (clickButton == 0) {}
    else if (clickButton == 1) {}
    else break success;
    log("0 or 1!");
    return
}
log("not 0 or 1!");

if clickButton is 2, it will log: not 0 or 1!.
if clickButton is 0 or 1 it will log: 0 or 1!

@shvaich shvaich left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with some.
To what I didnt agree I commented.
Whatever you decide on after reading my replays i will do

}
}
if (clickedButtonIdx != -1) {
success: {

@shvaich shvaich Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are mistaken, this is not how either works.
the loop I have is itterating over the buttons array, it only breaks early if I find a clicked button because i can only click on one button.

now the label after it is just for simplicity, because if clickedButtonIdx is either 0 or 1 I am updating the relative position and then need to update the absolute position, so what I am doing is updating the relative position, (see if (clickedButtonIdx == 0) and else if (clickedButtonIdx == 1))
and then updating the absolute position and returning from the function to not trigger isDragging.
(see code after else break success)

if clickedButtonIdx isn't 0 or 1 it will simply break from the success block and move on to isDragging logic. (see else break success)

There is nothing in this code that can cause an infinite loop and the only reason its written this way is because if I do decide to add more buttons I can write the logic easily at the end of the success block


private GuiUtil() {}

public static final int MOUSE_LEFT = 0;

@shvaich shvaich Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field should be used throughtout the codebase instead of the magic value when comparing with mouseButton.

This is not just for this pull request but for further onces aswell.

Comment thread src/configlib/java/fr/alexdoru/configlib/lib/gui/GuiUtil.java
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class RendererGuiButton extends ConfigGuiButton {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand but I very much disagree with this.

  1. I am keeping the Move HUD Button but as shown in the image it is no longer an "Image Button" and its text is Position.
    If you like its text can be Move HUD.

  2. There is no reason for the Reset Button to be placed here.
    2.1. I am already creating such a button for use inside the Hud Edit Screen.
    2.2 It is bad placement. Players cannot see where the hud is once they press this button here, they have to press on the Move HUD aswell to see its new position.


private static final class Button extends ClickGuiButton {
private final ResourceLocation icon;
private final String hoveringText;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do this.
I also have an idea to add possible hovering text to ConfigUIElements like in my codebase.
I will show you what I mean in a different pull request but keep it in mind

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

Successfully merging this pull request may close these issues.

2 participants