Fix "hover text" info for options in cli conf gui

This commit is contained in:
Stephen Seo 2024-02-02 13:43:48 +09:00
parent 6c2265f184
commit c0e70007f7

View file

@ -6,9 +6,6 @@ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.*; import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.neoforged.neoforge.common.ModConfigSpec; import net.neoforged.neoforge.common.ModConfigSpec;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -153,13 +150,12 @@ public class ClientConfig {
top_offset += widget_height; top_offset += widget_height;
addRenderableWidget( StringWidget stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Silly Music Threshold") widget_width, widget_height, Component.literal("Silly Music Threshold"), font);
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent( stringWidget.setTooltip(Tooltip.create(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal( Component.literal("Ratio of minimum of silly mobs in battle to play silly music")));
"0-100 percentage minimum count of silly mobs to play silly music")))), addRenderableWidget(stringWidget);
font));
if (sillyMusicThresholdSlider == null) { if (sillyMusicThresholdSlider == null) {
sillyMusicThresholdSlider = sillyMusicThresholdSlider =
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width, new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
@ -174,12 +170,13 @@ public class ClientConfig {
top_offset += widget_height; top_offset += widget_height;
addRenderableWidget( stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Affected by Master Vol.") widget_width, widget_height, Component.literal("Affected by Master Vol."),
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent( font);
new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal( stringWidget.setTooltip(Tooltip.create(
"If enabled, volume is affected by global master volume.")))), font)); Component.literal("If enabled, volume is affected by global master volume.")));
addRenderableWidget(stringWidget);
if (affectedByMasterVolCheckbox == null) { if (affectedByMasterVolCheckbox == null) {
affectedByMasterVolCheckbox = Checkbox.builder(Component.literal(""), font) affectedByMasterVolCheckbox = Checkbox.builder(Component.literal(""), font)
.pos(this.width / 2 + widget_x_offset, top_offset).build(); .pos(this.width / 2 + widget_x_offset, top_offset).build();
@ -197,12 +194,12 @@ public class ClientConfig {
top_offset += widget_height; top_offset += widget_height;
addRenderableWidget( stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Affected by Music Vol.") widget_width, widget_height, Component.literal("Affected by Music Vol."), font);
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent( stringWidget.setTooltip(Tooltip.create(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal( Component.literal("If enabled, volume is affected by global music volume.")));
"If enabled, volume is affected by global music volume.")))), font)); addRenderableWidget(stringWidget);
if (affectedByMusicVolCheckbox == null) { if (affectedByMusicVolCheckbox == null) {
affectedByMusicVolCheckbox = Checkbox.builder(Component.literal(""), font) affectedByMusicVolCheckbox = Checkbox.builder(Component.literal(""), font)
.pos(this.width / 2 + widget_x_offset, top_offset).build(); .pos(this.width / 2 + widget_x_offset, top_offset).build();
@ -220,12 +217,12 @@ public class ClientConfig {
top_offset += widget_height; top_offset += widget_height;
addRenderableWidget( stringWidget =
new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset, new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
widget_width, widget_height, Component.literal("Music Volume").setStyle( widget_width, widget_height, Component.literal("Music Volume"), font);
Style.EMPTY.withColor(TextColor.fromRgb(0XFFFFFFFF)).withHoverEvent( stringWidget.setTooltip(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, Tooltip.create(Component.literal("Volume of battle/silly music")));
Component.literal("Volume of battle/silly music")))), font)); addRenderableWidget(stringWidget);
if (volumeSlider == null) { if (volumeSlider == null) {
volumeSlider = volumeSlider =
new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width, new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,