Skip to content

Commit 0f06b0c

Browse files
committed
Allow showing button tooltips outside of editor screen
1 parent 09b6086 commit 0f06b0c

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Added save-state after server-accelerated operations
66
- Disabled operations and buttons in spectator mode
7+
- Added an option to show button tooltips
78

89
## 2.1.5
910

common/src/main/java/dev/terminalmc/clientsort/client/config/Config.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ public enum ExtraSlotScope {
231231
public static final boolean showButtonsDefault = true;
232232
public boolean showButtons = showButtonsDefault;
233233

234+
public static final boolean showButtonTooltipsDefault = false;
235+
public boolean showButtonTooltips = showButtonTooltipsDefault;
236+
234237
public static final boolean anchorButtonsLeftDefault = false;
235238
public boolean anchorButtonsLeft = anchorButtonsLeftDefault;
236239

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/config/ClothScreenProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,15 @@ else if (val > Config.Options.SOUND_VOLUME_MAX)
512512
.setSaveConsumer(val -> options.showButtons = val)
513513
.build());
514514

515+
buttons.addEntry(eb.startBooleanToggle(
516+
localized("option", "showButtonTooltips"),
517+
options.showButtonTooltips
518+
)
519+
.setTooltip(localized("option", "showButtonTooltips.tooltip"))
520+
.setDefaultValue(Config.Options.showButtonTooltipsDefault)
521+
.setSaveConsumer(val -> options.showButtonTooltips = val)
522+
.build());
523+
515524
buttons.addEntry(eb.startBooleanToggle(
516525
localized("option", "anchorButtonsLeft"),
517526
options.anchorButtonsLeft

common/src/main/java/dev/terminalmc/clientsort/client/gui/widget/TriggerButton.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
import java.util.Collection;
4747

48+
import static dev.terminalmc.clientsort.client.config.Config.options;
4849
import static dev.terminalmc.clientsort.util.Localization.localized;
4950

5051
public abstract class TriggerButton extends Button {
@@ -181,25 +182,29 @@ public void renderWidget(
181182

182183
// Refresh tooltip
183184
if (isMouseOver(mouseX, mouseY)) {
184-
if (Minecraft.getInstance().screen instanceof EditorScreen && getTooltip() == null) {
185-
Component visibilityStatus = localized(
186-
"editor", active ? "enabled" : "disabled")
187-
.withStyle(active
188-
? ChatFormatting.GREEN
189-
: ChatFormatting.RED);
190-
Component operationStatus = localized(
191-
"editor", operationAllowed ? "enabled" : "disabled")
192-
.withStyle(operationAllowed
193-
? ChatFormatting.GREEN
194-
: ChatFormatting.RED);
195-
setTooltip(Tooltip.create(Component.empty().append(name)
196-
.append("\n")
197-
.append(localized("editor", "visibility", visibilityStatus))
198-
.append("\n")
199-
.append(localized("editor", "operation", operationStatus))));
200-
} else {
201-
setTooltip(null);
185+
if (getTooltip() == null) {
186+
if (Minecraft.getInstance().screen instanceof EditorScreen) {
187+
Component visibilityStatus = localized(
188+
"editor", active ? "enabled" : "disabled")
189+
.withStyle(active
190+
? ChatFormatting.GREEN
191+
: ChatFormatting.RED);
192+
Component operationStatus = localized(
193+
"editor", operationAllowed ? "enabled" : "disabled")
194+
.withStyle(operationAllowed
195+
? ChatFormatting.GREEN
196+
: ChatFormatting.RED);
197+
setTooltip(Tooltip.create(Component.empty().append(name)
198+
.append("\n")
199+
.append(localized("editor", "visibility", visibilityStatus))
200+
.append("\n")
201+
.append(localized("editor", "operation", operationStatus))));
202+
} else if (options().showButtonTooltips) {
203+
setTooltip(Tooltip.create(name));
204+
}
202205
}
206+
} else {
207+
setTooltip(null);
203208
}
204209
}
205210

common/src/main/resources/assets/clientsort/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
"option.clientsort.buttons": "Buttons",
134134
"option.clientsort.showButtons": "Show Buttons",
135135
"option.clientsort.showButtons.tooltip": "Whether to show extra buttons on the GUI for inventory operations.",
136+
"option.clientsort.showButtonTooltips": "Show Button Tooltips",
137+
"option.clientsort.showButtonTooltips.tooltip": "Whether to show tooltips when hovering over buttons.",
136138
"option.clientsort.anchorButtonsLeft": "Anchor Left",
137139
"option.clientsort.anchorButtonsLeft.tooltip": "Whether to anchor the buttons to the left side of the inventory.",
138140
"option.clientsort.firstButtonOp": "First Button Operation",

common/src/main/resources/assets/clientsort/lang/ru_ru.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
"option.clientsort.buttons": "Интерфейс",
134134
"option.clientsort.showButtons": "Показывать кнопки",
135135
"option.clientsort.showButtons.tooltip": "Показывать ли дополнительные кнопки в интерфейсе для операций с инвентарём.",
136+
"option.clientsort.showButtonTooltips": "Show Button Tooltips",
137+
"option.clientsort.showButtonTooltips.tooltip": "Whether to show tooltips when hovering over buttons.",
136138
"option.clientsort.anchorButtonsLeft": "Прикрепить слева",
137139
"option.clientsort.anchorButtonsLeft.tooltip": "Определяет, нужно ли закреплять кнопки слева от инвентаря.",
138140
"option.clientsort.firstButtonOp": "Операция первой кнопки",

common/src/main/resources/assets/clientsort/lang/zh_cn.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@
135135
"option.clientsort.buttons": "按钮",
136136
"option.clientsort.showButtons": "显示按钮",
137137
"option.clientsort.showButtons.tooltip": "是否在图形界面上显示用于物品栏操作的额外按钮。",
138+
"option.clientsort.showButtonTooltips": "Show Button Tooltips",
139+
"option.clientsort.showButtonTooltips.tooltip": "Whether to show tooltips when hovering over buttons.",
138140
"option.clientsort.anchorButtonsLeft": "固定在左侧",
139141
"option.clientsort.anchorButtonsLeft.tooltip": "是否将按钮固定在物品栏左侧",
140142
"option.clientsort.firstButtonOp": "第一个按钮操作",

0 commit comments

Comments
 (0)