mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-04-24 06:15:47 +02:00
Fix positioning of buttons in Controls screen
This commit is contained in:
parent
e748c21efe
commit
38fb2a1f1e
@ -9,6 +9,7 @@ import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.OptionsSubScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.controls.ControlsScreen;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -30,12 +31,18 @@ public abstract class HookControlsScreen extends OptionsSubScreen {
|
||||
|
||||
int leftBottomY = 0;
|
||||
int rightBottomY = 0;
|
||||
AbstractWidget doneButton = null;
|
||||
|
||||
for (final GuiEventListener child : children()) {
|
||||
if (!(child instanceof AbstractWidget widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (widget instanceof Button button && button.getMessage() == CommonComponents.GUI_DONE) {
|
||||
doneButton = widget;
|
||||
continue;
|
||||
}
|
||||
|
||||
final int bottomY = widget.getY() + widget.getHeight();
|
||||
|
||||
if (widget.getX() + widget.getWidth() < center) {
|
||||
@ -48,7 +55,7 @@ public abstract class HookControlsScreen extends OptionsSubScreen {
|
||||
|
||||
final int x, y;
|
||||
|
||||
if (leftBottomY < rightBottomY) {
|
||||
if (leftBottomY <= rightBottomY) {
|
||||
x = center - 155;
|
||||
y = leftBottomY + 4;
|
||||
}
|
||||
@ -59,5 +66,9 @@ public abstract class HookControlsScreen extends OptionsSubScreen {
|
||||
|
||||
final MutableComponent buttonTitle = BetterControlsScreen.TITLE.plainCopy().append("...");
|
||||
addRenderableWidget(Button.builder(buttonTitle, btn -> Minecraft.getInstance().setScreen(new BetterControlsScreen(screen))).pos(x, y).size(150, 20).build());
|
||||
|
||||
if (doneButton != null) {
|
||||
doneButton.setY(y + 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user