aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-03 10:43:57 +0100
committerxander <xander@isxander.dev>2022-09-03 10:43:57 +0100
commit0ec15d2b53ccec94b17d9571bc7d4c437df84eae (patch)
tree8ff7ab9569ff32d6427567d015e8d236d48c1c2c /src/main/java
parent7f88ddf36ba7804211e8aae6b3723bd8f37c82c5 (diff)
downloadYetAnotherConfigLib-0ec15d2b53ccec94b17d9571bc7d4c437df84eae.tar.gz
YetAnotherConfigLib-0ec15d2b53ccec94b17d9571bc7d4c437df84eae.tar.bz2
YetAnotherConfigLib-0ec15d2b53ccec94b17d9571bc7d4c437df84eae.zip
fix left column buttons getting too large to render (closes #2)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/dev/isxander/yacl/gui/YACLScreen.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
index 6da1c29..35ec48a 100644
--- a/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
+++ b/src/main/java/dev/isxander/yacl/gui/YACLScreen.java
@@ -43,13 +43,14 @@ public class YACLScreen extends Screen {
categoryButtons.clear();
int columnWidth = width / 3;
int padding = columnWidth / 20;
- Dimension<Integer> categoryDim = Dimension.ofInt(padding, padding, columnWidth - padding * 2, 20);
+ columnWidth = Math.min(columnWidth, 400);
+ Dimension<Integer> categoryDim = Dimension.ofInt(width / 3 / 2, padding, columnWidth - padding * 2, 20);
int idx = 0;
for (ConfigCategory category : config.categories()) {
CategoryWidget categoryWidget = new CategoryWidget(
this,
category,
- categoryDim.x(), categoryDim.y(),
+ categoryDim.x() - categoryDim.width() / 2, categoryDim.y(),
categoryDim.width(), categoryDim.height()
);
if (idx == currentCategoryIdx)
@@ -58,11 +59,11 @@ public class YACLScreen extends Screen {
addDrawableChild(categoryWidget);
idx++;
- categoryDim = categoryDim.moved(0, 21);
+ categoryDim.move(0, 21);
}
- Dimension<Integer> actionDim = Dimension.ofInt(padding, height - padding - 20, columnWidth - padding * 2, 20);
- finishedSaveButton = new ButtonWidget(actionDim.x(), actionDim.y(), actionDim.width(), actionDim.height(), Text.empty(), (btn) -> {
+ Dimension<Integer> actionDim = Dimension.ofInt(width / 3 / 2, height - padding - 20, columnWidth - padding * 2, 20);
+ finishedSaveButton = new ButtonWidget(actionDim.x() - actionDim.width() / 2, actionDim.y(), actionDim.width(), actionDim.height(), Text.empty(), (btn) -> {
saveButtonMessage = null;
if (pendingChanges()) {
@@ -76,8 +77,8 @@ public class YACLScreen extends Screen {
config.saveFunction().run();
} else close();
});
- actionDim = actionDim.moved(0, -22).expanded(-actionDim.width() / 2 - 2, 0);
- cancelResetButton = new ButtonWidget(actionDim.x(), actionDim.y(), actionDim.width(), actionDim.height(), Text.translatable("yacl.gui.cancel"), (btn) -> {
+ actionDim.expand(-actionDim.width() / 2 - 2, 0).move(-actionDim.width() / 2 - 2, -22);
+ cancelResetButton = new ButtonWidget(actionDim.x() - actionDim.width() / 2, actionDim.y(), actionDim.width(), actionDim.height(), Text.translatable("yacl.gui.cancel"), (btn) -> {
if (pendingChanges()) {
OptionUtils.forEachOptions(config, Option::forgetPendingValue);
close();
@@ -86,8 +87,8 @@ public class YACLScreen extends Screen {
}
});
- actionDim = actionDim.moved(actionDim.width() + 4, 0);
- undoButton = new ButtonWidget(actionDim.x(), actionDim.y(), actionDim.width(), actionDim.height(), Text.translatable("yacl.gui.undo"), (btn) -> {
+ actionDim.move(actionDim.width() + 4, 0);
+ undoButton = new ButtonWidget(actionDim.x() - actionDim.width() / 2, actionDim.y(), actionDim.width(), actionDim.height(), Text.translatable("yacl.gui.undo"), (btn) -> {
OptionUtils.forEachOptions(config, Option::forgetPendingValue);
});