mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
Minor improvements
This commit is contained in:
@@ -204,16 +204,17 @@ public abstract class MidnightConfig {
|
|||||||
public boolean reload = false;
|
public boolean reload = false;
|
||||||
public TabManager tabManager = new TabManager(a -> refresh(), a -> refresh());
|
public TabManager tabManager = new TabManager(a -> refresh(), a -> refresh());
|
||||||
public Tab prevTab;
|
public Tab prevTab;
|
||||||
|
public ButtonWidget done;
|
||||||
|
|
||||||
// Real Time config update //
|
// Real Time config update //
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
tabManager.tick();
|
|
||||||
if (prevTab != null && prevTab != tabManager.getCurrentTab()) {
|
if (prevTab != null && prevTab != tabManager.getCurrentTab()) {
|
||||||
prevTab = tabManager.getCurrentTab();
|
prevTab = tabManager.getCurrentTab();
|
||||||
this.list.clear();
|
this.list.clear();
|
||||||
fillList();
|
fillList();
|
||||||
|
list.setScrollAmount(0);
|
||||||
}
|
}
|
||||||
for (EntryInfo info : entries) {
|
for (EntryInfo info : entries) {
|
||||||
try {info.field.set(null, info.value);} catch (IllegalAccessException ignored) {}
|
try {info.field.set(null, info.value);} catch (IllegalAccessException ignored) {}
|
||||||
@@ -283,10 +284,7 @@ public abstract class MidnightConfig {
|
|||||||
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
this.list = new MidnightConfigListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
||||||
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
if (this.client != null && this.client.world != null) this.list.setRenderBackground(false);
|
||||||
this.addSelectableChild(this.list);
|
this.addSelectableChild(this.list);
|
||||||
this.fillList();
|
done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
|
||||||
}
|
|
||||||
public void fillList() {
|
|
||||||
ButtonWidget done = this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
|
|
||||||
for (EntryInfo info : entries)
|
for (EntryInfo info : entries)
|
||||||
if (info.id.equals(modid)) {
|
if (info.id.equals(modid)) {
|
||||||
try {
|
try {
|
||||||
@@ -296,6 +294,9 @@ public abstract class MidnightConfig {
|
|||||||
write(modid);
|
write(modid);
|
||||||
Objects.requireNonNull(client).setScreen(parent);
|
Objects.requireNonNull(client).setScreen(parent);
|
||||||
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
|
}).dimensions(this.width / 2 + 4, this.height - 28, 150, 20).build());
|
||||||
|
fillList();
|
||||||
|
}
|
||||||
|
public void fillList() {
|
||||||
for (EntryInfo info : entries) {
|
for (EntryInfo info : entries) {
|
||||||
if (info.id.equals(modid) && (info.tab == null || info.tab == tabManager.getCurrentTab())) {
|
if (info.id.equals(modid) && (info.tab == null || info.tab == tabManager.getCurrentTab())) {
|
||||||
Text name = Objects.requireNonNullElseGet(info.name, () -> Text.translatable(translationPrefix + info.field.getName()));
|
Text name = Objects.requireNonNullElseGet(info.name, () -> Text.translatable(translationPrefix + info.field.getName()));
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ public class TexturedOverlayButtonWidget extends TexturedButtonWidget {
|
|||||||
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||||
int i = 66;
|
int i = 66;
|
||||||
if (!this.isNarratable()) {
|
if (!this.isNarratable()) {
|
||||||
i += 40;
|
i += hoveredVOffset * 2;
|
||||||
} else if (this.isHovered()) {
|
} else if (this.isSelected()) {
|
||||||
i += 20;
|
i += hoveredVOffset;
|
||||||
}
|
}
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||||
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
|
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
|
||||||
|
|||||||
Reference in New Issue
Block a user