mirror of
https://github.com/PuzzleMC/Puzzle.git
synced 2025-12-15 19:35:10 +01:00
Puzzle 1.6.1 for 1.20.4
- Update to 1.20.4 - Re-Use MidnightConfig's list widget -> prettier background
This commit is contained in:
@@ -134,7 +134,7 @@ dependencies {
|
|||||||
modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}")
|
modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}")
|
||||||
modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}")
|
modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}")
|
||||||
modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}")
|
modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}")
|
||||||
modImplementation ("maven.modrinth:exordium:${project.exordium_version}")
|
//modImplementation ("maven.modrinth:exordium:${project.exordium_version}")
|
||||||
|
|
||||||
modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
|
modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
|
||||||
exclude group: 'com.google.code.gson'
|
exclude group: 'com.google.code.gson'
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx4G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=1.20.2
|
minecraft_version=1.20.4
|
||||||
yarn_mappings=1.20.2+build.1
|
yarn_mappings=1.20.4+build.1
|
||||||
loader_version=0.14.22
|
loader_version=0.15.1
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.6.0+1.20.2
|
mod_version = 1.6.1+1.20.4
|
||||||
maven_group = net.puzzlemc
|
maven_group = net.puzzlemc
|
||||||
archives_base_name = puzzle
|
archives_base_name = puzzle
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version=0.89.2+1.20.2
|
fabric_version=0.91.2+1.20.4
|
||||||
mod_menu_version = 7.0.1
|
mod_menu_version = 7.0.1
|
||||||
midnightlib_version = 1.5.0-fabric
|
midnightlib_version = 1.5.2-fabric
|
||||||
|
|
||||||
cull_leaves_version = 3.0.2-fabric
|
cull_leaves_version = 3.0.2-fabric
|
||||||
ldl_version = 2.3.2+1.20.1
|
ldl_version = 2.3.2+1.20.1
|
||||||
@@ -31,8 +31,8 @@ org.gradle.jvmargs=-Xmx4G
|
|||||||
cit_resewn_version = 1.1.3+1.20
|
cit_resewn_version = 1.1.3+1.20
|
||||||
complete_config_version = 2.3.0
|
complete_config_version = 2.3.0
|
||||||
spruceui_version=5.0.0+1.20
|
spruceui_version=5.0.0+1.20
|
||||||
emf_version=1.0.2
|
emf_version=1.2
|
||||||
etf_version=4.5.1
|
etf_version=5.0
|
||||||
exordium_version=1.2.1-1.20.2
|
exordium_version=1.2.1-1.20.2
|
||||||
# Required for LBG
|
# Required for LBG
|
||||||
quilt_loader_version=0.19.0-beta.18
|
quilt_loader_version=0.19.0-beta.18
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ dependencies {
|
|||||||
modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}")
|
modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}")
|
||||||
modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}")
|
modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}")
|
||||||
modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}")
|
modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}")
|
||||||
modImplementation ("maven.modrinth:exordium:${project.exordium_version}")
|
//modImplementation ("maven.modrinth:exordium:${project.exordium_version}")
|
||||||
|
|
||||||
modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
|
modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
|
||||||
exclude group: 'com.google.code.gson'
|
exclude group: 'com.google.code.gson'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import dev.lambdaurora.lambdabettergrass.LBGConfig;
|
|||||||
import dev.lambdaurora.lambdabettergrass.LambdaBetterGrass;
|
import dev.lambdaurora.lambdabettergrass.LambdaBetterGrass;
|
||||||
import dev.lambdaurora.lambdynlights.DynamicLightsConfig;
|
import dev.lambdaurora.lambdynlights.DynamicLightsConfig;
|
||||||
import dev.lambdaurora.lambdynlights.LambDynLights;
|
import dev.lambdaurora.lambdynlights.LambDynLights;
|
||||||
import eu.midnightdust.core.MidnightLibClient;
|
import eu.midnightdust.core.MidnightLib;
|
||||||
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
|
||||||
import eu.midnightdust.lib.util.PlatformFunctions;
|
import eu.midnightdust.lib.util.PlatformFunctions;
|
||||||
import io.github.kvverti.colormatic.Colormatic;
|
import io.github.kvverti.colormatic.Colormatic;
|
||||||
@@ -36,7 +36,7 @@ public class PuzzleClient implements ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
MidnightLibClient.hiddenMods.add("puzzle");
|
MidnightLib.hiddenMods.add("puzzle");
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.of("Puzzle")));
|
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.of("Puzzle")));
|
||||||
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.option.check_for_updates"), (button) -> button.setMessage(PuzzleConfig.checkUpdates ? YES : NO), (button) -> {
|
PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.option.check_for_updates"), (button) -> button.setMessage(PuzzleConfig.checkUpdates ? YES : NO), (button) -> {
|
||||||
@@ -135,11 +135,11 @@ public class PuzzleClient implements ClientModInitializer {
|
|||||||
|
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("LambDynamicLights")));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("LambDynamicLights")));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("lambdynlights.option.mode"), (button) -> button.setMessage(ldlConfig.getDynamicLightsMode().getTranslatedText()), (button) -> ldlConfig.setDynamicLightsMode(ldlConfig.getDynamicLightsMode().next())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("lambdynlights.option.mode"), (button) -> button.setMessage(ldlConfig.getDynamicLightsMode().getTranslatedText()), (button) -> ldlConfig.setDynamicLightsMode(ldlConfig.getDynamicLightsMode().next())));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("").append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.entities")), (button) -> button.setMessage(ldlConfig.getEntitiesLightSource().get() ? YES : NO), (button) -> ldlConfig.getEntitiesLightSource().set(!ldlConfig.getEntitiesLightSource().get())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.empty().append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.entities")), (button) -> button.setMessage(ldlConfig.getEntitiesLightSource().get() ? YES : NO), (button) -> ldlConfig.getEntitiesLightSource().set(!ldlConfig.getEntitiesLightSource().get())));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("").append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.block_entities")), (button) -> button.setMessage(ldlConfig.getBlockEntitiesLightSource().get() ? YES : NO), (button) -> ldlConfig.getBlockEntitiesLightSource().set(!ldlConfig.getBlockEntitiesLightSource().get())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.empty().append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.block_entities")), (button) -> button.setMessage(ldlConfig.getBlockEntitiesLightSource().get() ? YES : NO), (button) -> ldlConfig.getBlockEntitiesLightSource().set(!ldlConfig.getBlockEntitiesLightSource().get())));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("").append("DynLights: ").append(Text.translatable("entity.minecraft.creeper")), (button) -> button.setMessage(ldlConfig.getCreeperLightingMode().getTranslatedText()), (button) -> ldlConfig.setCreeperLightingMode(ldlConfig.getCreeperLightingMode().next())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.empty().append("DynLights: ").append(Text.translatable("entity.minecraft.creeper")), (button) -> button.setMessage(ldlConfig.getCreeperLightingMode().getTranslatedText()), (button) -> ldlConfig.setCreeperLightingMode(ldlConfig.getCreeperLightingMode().next())));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("").append("DynLights: ").append(Text.translatable("block.minecraft.tnt")), (button) -> button.setMessage(ldlConfig.getTntLightingMode().getTranslatedText()), (button) -> ldlConfig.setTntLightingMode(ldlConfig.getTntLightingMode().next())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.empty().append("DynLights: ").append(Text.translatable("block.minecraft.tnt")), (button) -> button.setMessage(ldlConfig.getTntLightingMode().getTranslatedText()), (button) -> ldlConfig.setTntLightingMode(ldlConfig.getTntLightingMode().next())));
|
||||||
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("").append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.water_sensitive_check")), (button) -> button.setMessage(ldlConfig.getWaterSensitiveCheck().get() ? YES : NO), (button) -> ldlConfig.getWaterSensitiveCheck().set(!ldlConfig.getWaterSensitiveCheck().get())));
|
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.empty().append("DynLights: ").append(Text.translatable("lambdynlights.option.light_sources.water_sensitive_check")), (button) -> button.setMessage(ldlConfig.getWaterSensitiveCheck().get() ? YES : NO), (button) -> ldlConfig.getWaterSensitiveCheck().set(!ldlConfig.getWaterSensitiveCheck().get())));
|
||||||
}
|
}
|
||||||
if (isActive("citresewn") && CITResewnConfig.INSTANCE != null) {
|
if (isActive("citresewn") && CITResewnConfig.INSTANCE != null) {
|
||||||
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.of("CIT Resewn")));
|
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.of("CIT Resewn")));
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import net.minecraft.screen.ScreenTexts;
|
|||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.puzzlemc.gui.PuzzleApi;
|
import net.puzzlemc.gui.PuzzleApi;
|
||||||
import net.puzzlemc.gui.PuzzleClient;
|
import net.puzzlemc.gui.PuzzleClient;
|
||||||
import net.puzzlemc.gui.screen.widget.PuzzleOptionListWidget;
|
import net.puzzlemc.gui.screen.widget.*;
|
||||||
import net.puzzlemc.gui.screen.widget.PuzzleWidget;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ public class PuzzleOptionsScreen extends Screen {
|
|||||||
tabNavigation.init();
|
tabNavigation.init();
|
||||||
prevTab = tabManager.getCurrentTab();
|
prevTab = tabManager.getCurrentTab();
|
||||||
this.addDrawableChild(tabNavigation);
|
this.addDrawableChild(tabNavigation);
|
||||||
this.list = new PuzzleOptionListWidget(this.client, this.width, this.height, 32, this.height - 32, 25);
|
this.list = new PuzzleOptionListWidget(this.client, this.width, this.height - 64, 32, 25);
|
||||||
fillList();
|
fillList();
|
||||||
this.addSelectableChild(this.list);
|
this.addSelectableChild(this.list);
|
||||||
|
|
||||||
@@ -87,16 +86,9 @@ public class PuzzleOptionsScreen extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
super.render(context, mouseX, mouseY, delta);
|
if (client != null && client.world != null) super.renderInGameBackground(context);
|
||||||
|
|
||||||
this.list.render(context, mouseX, mouseY, delta);
|
this.list.render(context, mouseX, mouseY, delta);
|
||||||
|
super.render(context, mouseX, mouseY, delta);
|
||||||
if (tooltip != null) {
|
|
||||||
if (this.list.getFocused() != null && (this.list.getHoveredEntry() == null || this.list.getHoveredEntry().button == null || !this.list.getHoveredEntry().button.isMouseOver(mouseX, mouseY))) {
|
|
||||||
context.drawTooltip(textRenderer, tooltip, this.list.getFocused().getX(), this.list.getFocused().getY() + (this.list.getFocused().getHeight() * 2));
|
|
||||||
}
|
|
||||||
else context.drawTooltip(textRenderer, tooltip, mouseX, mouseY);
|
|
||||||
}
|
|
||||||
tooltip = null;
|
|
||||||
}
|
}
|
||||||
|
@Override public void renderBackground(DrawContext c, int x, int y, float d) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.puzzlemc.gui.screen.widget;
|
|||||||
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -15,10 +14,10 @@ public class PuzzleButtonWidget extends ButtonWidget {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
try {
|
try {
|
||||||
title.setTitle(this);
|
title.setTitle(this);
|
||||||
} catch (Exception e) {e.printStackTrace(); this.visible = false;}
|
} catch (Exception e) {e.fillInStackTrace(); this.visible = false;}
|
||||||
super.renderButton(context, mouseX, mouseY, delta);
|
super.renderWidget(context, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,132 +1,74 @@
|
|||||||
package net.puzzlemc.gui.screen.widget;
|
package net.puzzlemc.gui.screen.widget;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.Element;
|
|
||||||
import net.minecraft.client.gui.Selectable;
|
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
|
||||||
import net.minecraft.client.resource.language.I18n;
|
import net.minecraft.client.resource.language.I18n;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableTextContent;
|
import net.minecraft.text.TranslatableTextContent;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.puzzlemc.gui.screen.PuzzleOptionsScreen;
|
import net.puzzlemc.gui.screen.PuzzleOptionsScreen;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class PuzzleOptionListWidget extends ElementListWidget<PuzzleOptionListWidget.ButtonEntry> {
|
public class PuzzleOptionListWidget extends MidnightConfig.MidnightConfigListWidget {
|
||||||
TextRenderer textRenderer;
|
TextRenderer textRenderer;
|
||||||
|
|
||||||
public PuzzleOptionListWidget(MinecraftClient minecraftClient, int i, int j, int k, int l, int m) {
|
public PuzzleOptionListWidget(MinecraftClient minecraftClient, int i, int j, int k, int l) {
|
||||||
super(minecraftClient, i, j, k, l, m);
|
super(minecraftClient, i, j, k, l);
|
||||||
this.centerListVertically = false;
|
this.centerListVertically = false;
|
||||||
textRenderer = minecraftClient.textRenderer;
|
textRenderer = minecraftClient.textRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addButton(ClickableWidget button, Text text) {
|
|
||||||
this.addEntry(ButtonEntry.create(button, text));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAll(List<PuzzleWidget> buttons) {
|
public void addAll(List<PuzzleWidget> buttons) {
|
||||||
for (PuzzleWidget button : buttons) {
|
for (PuzzleWidget button : buttons) {
|
||||||
if (button.buttonType == ButtonType.TEXT) {
|
if (button.buttonType == ButtonType.TEXT) {
|
||||||
this.addButton(null, button.descriptionText);
|
this.addButton(List.of(), Text.literal("> ").append(button.descriptionText).formatted(Formatting.BOLD), new MidnightConfig.EntryInfo());
|
||||||
} else if (button.buttonType == ButtonType.BUTTON) {
|
} else if (button.buttonType == ButtonType.BUTTON) {
|
||||||
this.addButton(new PuzzleButtonWidget(this.width / 2 + 25, 0, 150, 20, button.buttonTextAction, button.onPress), button.descriptionText);
|
this.addButton(List.of(new PuzzleButtonWidget(this.width / 2 + 25, 0, 150, 20, button.buttonTextAction, button.onPress)), button.descriptionText, new MidnightConfig.EntryInfo());
|
||||||
} else if (button.buttonType == ButtonType.SLIDER) {
|
} else if (button.buttonType == ButtonType.SLIDER) {
|
||||||
this.addButton(new PuzzleSliderWidget(button.min, button.max, this.width / 2 + 25, 0, 150, 20, button.defaultSliderValue.getAsInt(), button.buttonTextAction, button.changeSliderValue), button.descriptionText);
|
this.addButton(List.of(new PuzzleSliderWidget(button.min, button.max, this.width / 2 + 25, 0, 150, 20, button.defaultSliderValue.getAsInt(), button.buttonTextAction, button.changeSliderValue)), button.descriptionText, new MidnightConfig.EntryInfo());
|
||||||
} else if (button.buttonType == ButtonType.TEXT_FIELD) {
|
} else if (button.buttonType == ButtonType.TEXT_FIELD) {
|
||||||
this.addButton(new PuzzleTextFieldWidget(textRenderer, this.width / 2 + 25, 0, 150, 20, button.setTextValue, button.changeTextValue), button.descriptionText);
|
this.addButton(List.of(new PuzzleTextFieldWidget(textRenderer, this.width / 2 + 25, 0, 150, 20, button.setTextValue, button.changeTextValue)), button.descriptionText, new MidnightConfig.EntryInfo());
|
||||||
} else
|
} else
|
||||||
LogManager.getLogger("Puzzle").warn("Button " + button + " is missing the buttonType variable. This shouldn't happen!");
|
LogManager.getLogger("Puzzle").warn("Button " + button + " is missing the buttonType variable. This shouldn't happen!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
|
super.renderWidget(context, mouseX, mouseY, delta);
|
||||||
|
MidnightConfig.ButtonEntry e = this.getHoveredEntry();
|
||||||
|
if (client.currentScreen instanceof PuzzleOptionsScreen page && e != null && !e.buttons.isEmpty() && MidnightConfig.ButtonEntry.buttonsWithText.get(e.buttons.get(0)).getContent() instanceof TranslatableTextContent content) {
|
||||||
|
ClickableWidget button = e.buttons.get(0);
|
||||||
|
String key = null;
|
||||||
|
if (I18n.hasTranslation(content.getKey() + ".tooltip")) key = content.getKey() + ".tooltip";
|
||||||
|
else if (I18n.hasTranslation(content.getKey() + ".desc")) key = content.getKey() + ".desc";
|
||||||
|
if (key == null && content.getKey().endsWith(".title")) {
|
||||||
|
String strippedContent = content.getKey().substring(0, content.getKey().length()-6);
|
||||||
|
if (I18n.hasTranslation(strippedContent + ".tooltip")) key = strippedContent + ".tooltip";
|
||||||
|
else if (I18n.hasTranslation(strippedContent + ".desc")) key = strippedContent + ".desc";
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
if (key != null) {
|
||||||
super.clearEntries();
|
List<Text> list = new ArrayList<>();
|
||||||
}
|
for (String str : I18n.translate(key).split("\n"))
|
||||||
public int getRowWidth() {
|
list.add(Text.literal(str));
|
||||||
return 400;
|
page.tooltip = list;
|
||||||
}
|
if (!button.isMouseOver(mouseX, mouseY)) {
|
||||||
|
context.drawTooltip(textRenderer, list, button.getX(), button.getY() + (button.getHeight() * 2));
|
||||||
protected int getScrollbarPositionX() {
|
}
|
||||||
return super.getScrollbarPositionX() + 60;
|
else context.drawTooltip(textRenderer, list, mouseX, mouseY);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ButtonEntry getHoveredEntry() {
|
public MidnightConfig.ButtonEntry getHoveredEntry() {
|
||||||
return super.getHoveredEntry();
|
return super.getHoveredEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ButtonEntry extends ElementListWidget.Entry<ButtonEntry> {
|
|
||||||
private static final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
|
|
||||||
private List<ClickableWidget> buttons = new ArrayList<>();
|
|
||||||
public final ClickableWidget button;
|
|
||||||
public final Text text;
|
|
||||||
private MinecraftClient client = MinecraftClient.getInstance();
|
|
||||||
|
|
||||||
private ButtonEntry(ClickableWidget button, Text text) {
|
|
||||||
if (button != null)
|
|
||||||
this.buttons.add(button);
|
|
||||||
this.button = button;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ButtonEntry create(ClickableWidget button, Text text) {
|
|
||||||
return new ButtonEntry(button, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
|
|
||||||
if (button != null) {
|
|
||||||
button.setY(y);
|
|
||||||
button.render(context, mouseX, mouseY, tickDelta);
|
|
||||||
}
|
|
||||||
if (button == null) context.drawCenteredTextWithShadow(textRenderer, Text.literal("------ ").append(text).append(" ------"),x + 200,y+5,0xFFFFFF);
|
|
||||||
else context.drawTextWithShadow(textRenderer, text,x+15,y+5,0xFFFFFF);
|
|
||||||
|
|
||||||
if (!(client.currentScreen instanceof PuzzleOptionsScreen page)) return;
|
|
||||||
if (button != null && (button.isMouseOver(mouseX, mouseY) || ((page.list.getHoveredEntry() == null || page.list.getHoveredEntry().button == null || !page.list.getHoveredEntry().button.isMouseOver(mouseX, mouseY)) && button.isFocused())) && text.getContent() instanceof TranslatableTextContent content) {
|
|
||||||
String key = null;
|
|
||||||
if (I18n.hasTranslation(content.getKey() + ".tooltip")) key = content.getKey() + ".tooltip";
|
|
||||||
else if (I18n.hasTranslation(content.getKey() + ".desc")) key = content.getKey() + ".desc";
|
|
||||||
if (key == null && content.getKey().endsWith(".title")) {
|
|
||||||
String strippedContent = content.getKey().substring(0, content.getKey().length()-6);
|
|
||||||
if (I18n.hasTranslation(strippedContent + ".tooltip")) key = strippedContent + ".tooltip";
|
|
||||||
else if (I18n.hasTranslation(strippedContent + ".desc")) key = strippedContent + ".desc";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key != null) {
|
|
||||||
List<Text> list = new ArrayList<>();
|
|
||||||
for (String str : I18n.translate(key).split("\n"))
|
|
||||||
list.add(Text.literal(str));
|
|
||||||
page.tooltip = list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int getY() {
|
|
||||||
return button.getY();
|
|
||||||
}
|
|
||||||
public int getX() {
|
|
||||||
return button.getX();
|
|
||||||
}
|
|
||||||
public int getHeight() {
|
|
||||||
return button.getHeight();
|
|
||||||
}
|
|
||||||
public int getWidth() {
|
|
||||||
return button.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<? extends Element> children() {
|
|
||||||
return buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Selectable> selectableChildren() {
|
|
||||||
return buttons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user