Skip to content

Commit 920fb79

Browse files
committed
Minor improvements
1 parent cacd351 commit 920fb79

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

common/src/main/java/eu/midnightdust/lib/config/MidnightConfig.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,17 @@ protected MidnightConfigScreen(Screen parent, String modid) {
204204
public boolean reload = false;
205205
public TabManager tabManager = new TabManager(a -> refresh(), a -> refresh());
206206
public Tab prevTab;
207+
public ButtonWidget done;
207208

208209
// Real Time config update //
209210
@Override
210211
public void tick() {
211212
super.tick();
212-
tabManager.tick();
213213
if (prevTab != null && prevTab != tabManager.getCurrentTab()) {
214214
prevTab = tabManager.getCurrentTab();
215215
this.list.clear();
216216
fillList();
217+
list.setScrollAmount(0);
217218
}
218219
for (EntryInfo info : entries) {
219220
try {info.field.set(null, info.value);} catch (IllegalAccessException ignored) {}
@@ -283,10 +284,7 @@ public void init() {
283284
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
284285
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
285286
this.addSelectableChild(this.list);
286-
this.fillList();
287-
}
288-
public void fillList() {
289-
ButtonWidget done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
287+
done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
290288
for (EntryInfo info : entries)
291289
if (info.id.equals(modid)) {
292290
try {
@@ -296,6 +294,9 @@ public void fillList() {
296294
write(modid);
297295
Objects.requireNonNull(client).setScreen(parent);
298296
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
297+
fillList();
298+
}
299+
public void fillList() {
299300
for (EntryInfo info : entries) {
300301
if (info.id.equals(modid) && (info.tab == null || info.tab == tabManager.getCurrentTab())) {
301302
Text name = Objects.requireNonNullElseGet(info.name, () -> Text.translatable(translationPrefix + info.field.getName()));

common/src/main/java/eu/midnightdust/lib/util/screen/TexturedOverlayButtonWidget.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public TexturedOverlayButtonWidget(int x, int y, int width, int height, int u, i
2929
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
3030
int i = 66;
3131
if (!this.isNarratable()) {
32-
i += 40;
33-
} else if (this.isHovered()) {
34-
i += 20;
32+
i += hoveredVOffset * 2;
33+
} else if (this.isSelected()) {
34+
i += hoveredVOffset;
3535
}
3636
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
3737
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);

0 commit comments

Comments
 (0)