Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import meteordevelopment.meteorclient.gui.widgets.pressable.WPressable;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.systems.config.Config;

import java.util.Collection;
import java.util.function.Consumer;
Expand Down Expand Up @@ -76,6 +77,7 @@ private void initTable() {
private WTable abc(Iterable<T> iterable, boolean isLeft, Consumer<T> buttonAction) {
// Create
Cell<WTable> cell = this.table.add(theme.table()).top();
if (Config.get().syncListSettingWidths.get()) cell.group("sync-width");
WTable table = cell.widget();

// Sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package meteordevelopment.meteorclient.gui.utils;

import meteordevelopment.meteorclient.gui.widgets.WWidget;
import org.jetbrains.annotations.Nullable;

public class Cell<T extends WWidget> {
private final T widget;
Expand All @@ -24,6 +25,8 @@ public class Cell<T extends WWidget> {

public boolean expandCellX;

public @Nullable String group;

public Cell(T widget) {
this.widget = widget;
}
Expand Down Expand Up @@ -154,6 +157,12 @@ public Cell<T> expandX() {

// Other

/// Makes this cell's width match the largest cell in the group
public Cell<T> group(String group) {
this.group = group;
return this;
}

public void alignWidget() {
if (expandWidgetX) {
widget.x = x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import meteordevelopment.meteorclient.gui.utils.Cell;
import meteordevelopment.meteorclient.gui.widgets.WWidget;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.*;

public class WTable extends WContainer {
public double horizontalSpacing = 3;
Expand Down Expand Up @@ -160,6 +158,8 @@ private void calculateInfo() {
columnWidths.clear();
rowExpandCellXCounts.clear();

Map<String, IntList> columnGroups = new HashMap<>();

// Loop over rows
for (List<Cell<?>> row : rows) {
double rowHeight = 0;
Expand All @@ -177,6 +177,8 @@ private void calculateInfo() {
if (columnWidths.size() <= i) columnWidths.add(cellWidth);
else columnWidths.set(i, Math.max(columnWidths.getDouble(i), cellWidth));

if (cell.group != null) columnGroups.computeIfAbsent(cell.group, k -> new IntArrayList()).add(i);

// Calculate row expandX count
if (cell.expandCellX) rowExpandXCount++;
}
Expand All @@ -185,5 +187,17 @@ private void calculateInfo() {
rowHeights.add(rowHeight);
rowExpandCellXCounts.add(rowExpandXCount);
}

// Normalize group widths
columnGroups.values().forEach(columns -> {
double maxWidth = Integer.MIN_VALUE;
for (int i : columns) {
maxWidth = Math.max(maxWidth, columnWidths.getDouble(i));
}

for (int i : columns) {
columnWidths.set(i, maxWidth);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public class Config extends System<Config> {
.build()
);

public final Setting<Boolean> syncListSettingWidths = sgVisual.add(new BoolSetting.Builder()
.name("sync-list-setting-widths")
.description("Prevents the list setting screens from moving around as you add & remove elements.")
.defaultValue(false)
.build()
);

// Modules

public final Setting<List<Module>> hiddenModules = sgModules.add(new ModuleListSetting.Builder()
Expand Down