Improved look of tooltips. Changed colors to improve readability. Implemented helper method for adding indent to components.
This commit is contained in:
@ -205,51 +205,51 @@ public abstract class TotemItem extends Item {
|
|||||||
|
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_TARGET.getComponent(
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_TARGET.getComponent(
|
||||||
totemData.getTargetUUID().isPresent()
|
totemData.getTargetUUID().isPresent()
|
||||||
? Component.literal(totemData.getTargetName()).withStyle(ChatFormatting.GRAY)
|
? Component.literal(totemData.getTargetName()).withStyle(ChatFormatting.WHITE)
|
||||||
: LangAsset.GENERAL_NA.getComponent().withStyle(ChatFormatting.RED)
|
: LangAsset.GENERAL_NA.getComponent().withStyle(ChatFormatting.RED)
|
||||||
).withStyle(ChatFormatting.WHITE));
|
).withStyle(ChatFormatting.GRAY));
|
||||||
|
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_TARGET_COST.getComponent(
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_TARGET_COST.getComponent(
|
||||||
Component.literal(String.format("%d", getTargetCost(totemData))).withStyle(
|
Component.literal(String.format("%d", getTargetCost(totemData))).withStyle(
|
||||||
getTargetCost(totemData) <= getMaxCharge()
|
getTargetCost(totemData) <= getMaxCharge()
|
||||||
? ChatFormatting.GRAY
|
? ChatFormatting.WHITE
|
||||||
: ChatFormatting.RED
|
: ChatFormatting.RED
|
||||||
)
|
)
|
||||||
).withStyle(ChatFormatting.WHITE));
|
).withStyle(ChatFormatting.GRAY));
|
||||||
|
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CHARGES.getComponent(
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CHARGES.getComponent(
|
||||||
Component.literal(String.format("%d/%d", totemData.getCharge(), getMaxCharge())).withStyle(ChatFormatting.GRAY)
|
Component.literal(String.format("%d / %d", totemData.getCharge(), getMaxCharge())).withStyle(ChatFormatting.WHITE)
|
||||||
).withStyle(ChatFormatting.WHITE));
|
).withStyle(ChatFormatting.GRAY));
|
||||||
|
|
||||||
tooltipComponents.add(Component.empty());
|
tooltipComponents.add(Component.empty());
|
||||||
if (isChargeCostDynamic()) {
|
if (isChargeCostDynamic()) {
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_DYNAMIC_COST.getComponent(
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_DYNAMIC_COST.getComponent(
|
||||||
Component.literal(String.format("%.2f", getConfig().getChargeCostMultiplier())).withStyle(ChatFormatting.GRAY)
|
Component.literal(String.format("%.2f", getConfig().getChargeCostMultiplier())).withStyle(ChatFormatting.WHITE)
|
||||||
).withStyle(ChatFormatting.WHITE, ChatFormatting.ITALIC));
|
).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
|
||||||
}
|
}
|
||||||
if (getConfig().getCanReviveMoreExpensiveTargets()) {
|
if (getConfig().getCanReviveMoreExpensiveTargets()) {
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CAN_REVIVE_MORE_EXPENSIVE_TARGETS.getComponent().withStyle(ChatFormatting.WHITE, ChatFormatting.ITALIC));
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CAN_REVIVE_MORE_EXPENSIVE_TARGETS.getComponent().withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
|
||||||
}
|
}
|
||||||
if (getConfig().getCanReviveAcrossDimensions()) {
|
if (getConfig().getCanReviveAcrossDimensions()) {
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CAN_REVIVE_ACROSS_DIMENSIONS.getComponent().withStyle(ChatFormatting.WHITE, ChatFormatting.ITALIC));
|
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CAN_REVIVE_ACROSS_DIMENSIONS.getComponent().withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltipComponents.add(Component.empty());
|
tooltipComponents.add(Component.empty());
|
||||||
|
|
||||||
if (InputConstants.isKeyDown(minecraft.getWindow().getWindow(), minecraft.options.keyShift.getKey().getValue())) {
|
if (InputConstants.isKeyDown(minecraft.getWindow().getWindow(), minecraft.options.keyShift.getKey().getValue())) {
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_ADVANCED_TOOLTIP_SHOWN.getComponent().withStyle(ChatFormatting.WHITE, ChatFormatting.UNDERLINE));
|
tooltipComponents.add(LangAsset.TOOLTIP_ADVANCED_TOOLTIP_SHOWN.getComponent().withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.UNDERLINE));
|
||||||
|
|
||||||
tooltipComponents.add(LangAsset.createKeyText(true, new ChatFormatting[]{ChatFormatting.WHITE}, new ChatFormatting[]{ChatFormatting.GRAY}, minecraft.options.keyUse));
|
tooltipComponents.add(LangAsset.createKeyText(false, new ChatFormatting[]{ChatFormatting.GOLD}, new ChatFormatting[]{ChatFormatting.GOLD, ChatFormatting.ITALIC}, minecraft.options.keyUse));
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_REVIVE_INSTRUCTION.getComponent().withStyle(ChatFormatting.WHITE));
|
tooltipComponents.add(LangAsset.addIndentToComponent(LangAsset.TOOLTIP_TOTEM_REVIVE_INSTRUCTION.getComponent().withStyle(ChatFormatting.GRAY), 1));
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CHARGE_INSTRUCTION.getComponent().withStyle(ChatFormatting.WHITE));
|
tooltipComponents.add(LangAsset.addIndentToComponent(LangAsset.TOOLTIP_TOTEM_CHARGE_INSTRUCTION.getComponent().withStyle(ChatFormatting.GRAY), 1));
|
||||||
tooltipComponents.add(Component.empty());
|
tooltipComponents.add(Component.empty());
|
||||||
|
|
||||||
tooltipComponents.add(LangAsset.createKeyText(true, new ChatFormatting[]{ChatFormatting.WHITE}, new ChatFormatting[]{ChatFormatting.GRAY}, minecraft.options.keyShift, minecraft.options.keyUse));
|
tooltipComponents.add(LangAsset.createKeyText(false, new ChatFormatting[]{ChatFormatting.GOLD}, new ChatFormatting[]{ChatFormatting.GOLD, ChatFormatting.ITALIC}, minecraft.options.keyShift, minecraft.options.keyUse));
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_TOTEM_CHANGE_TARGET_INSTRUCTION.getComponent().withStyle(ChatFormatting.WHITE));
|
tooltipComponents.add(LangAsset.addIndentToComponent(LangAsset.TOOLTIP_TOTEM_CHANGE_TARGET_INSTRUCTION.getComponent().withStyle(ChatFormatting.GRAY), 1));
|
||||||
} else {
|
} else {
|
||||||
tooltipComponents.add(LangAsset.TOOLTIP_ADVANCED_TOOLTIP_HIDDEN.getComponent(
|
tooltipComponents.add(LangAsset.TOOLTIP_ADVANCED_TOOLTIP_HIDDEN.getComponent(
|
||||||
LangAsset.createKeyText(true, new ChatFormatting[]{ChatFormatting.WHITE}, new ChatFormatting[]{ChatFormatting.GRAY}, minecraft.options.keyShift)
|
LangAsset.createKeyText(false, new ChatFormatting[]{ChatFormatting.GOLD}, new ChatFormatting[]{ChatFormatting.GOLD, ChatFormatting.ITALIC}, minecraft.options.keyShift)
|
||||||
));
|
).withStyle(ChatFormatting.GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||||
|
|||||||
@ -58,7 +58,14 @@ public enum LangAsset {
|
|||||||
return Component.translatable(String.format("%s.%s.%s", category, TotemOfReviving.MOD_ID, key), args);
|
return Component.translatable(String.format("%s.%s.%s", category, TotemOfReviving.MOD_ID, key), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component createKeyText(boolean isEnclosed, ChatFormatting[] textFormat, ChatFormatting[] keyFormat, KeyMapping...keys) {
|
public static MutableComponent addIndentToComponent(Component component, int indentLevel) {
|
||||||
|
List<Component> components = new ArrayList<>();
|
||||||
|
components.add(Component.literal(" ".repeat(indentLevel)));
|
||||||
|
components.add(component);
|
||||||
|
return (MutableComponent) ComponentUtils.formatList(components, Component.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MutableComponent createKeyText(boolean isEnclosed, ChatFormatting[] textFormat, ChatFormatting[] keyFormat, KeyMapping...keys) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
textComponents.add(isEnclosed ? Component.literal("[").withStyle(textFormat) : Component.empty());
|
textComponents.add(isEnclosed ? Component.literal("[").withStyle(textFormat) : Component.empty());
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
@ -67,6 +74,6 @@ public enum LangAsset {
|
|||||||
}
|
}
|
||||||
textComponents.add(isEnclosed ? Component.literal("]").withStyle(textFormat) : Component.empty());
|
textComponents.add(isEnclosed ? Component.literal("]").withStyle(textFormat) : Component.empty());
|
||||||
|
|
||||||
return ComponentUtils.formatList(textComponents, Component.empty());
|
return (MutableComponent) ComponentUtils.formatList(textComponents, Component.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
"item.totem_of_reviving.iron_charge": "Iron reviving charge",
|
"item.totem_of_reviving.iron_charge": "Iron reviving charge",
|
||||||
"item.totem_of_reviving.diamond_charge": "Diamond reviving charge",
|
"item.totem_of_reviving.diamond_charge": "Diamond reviving charge",
|
||||||
"item.totem_of_reviving.netherite_charge": "Netherite reviving charge",
|
"item.totem_of_reviving.netherite_charge": "Netherite reviving charge",
|
||||||
"tooltip.totem_of_reviving.totem_target": "Target -> %s",
|
"tooltip.totem_of_reviving.totem_target": "Target: %s",
|
||||||
"tooltip.totem_of_reviving.totem_target_cost": "Cost -> %s",
|
"tooltip.totem_of_reviving.totem_target_cost": "Cost: %s",
|
||||||
"tooltip.totem_of_reviving.totem_charges": "Charges -> %s",
|
"tooltip.totem_of_reviving.totem_charges": "Charges: %s",
|
||||||
"tooltip.totem_of_reviving.totem_dynamic_cost": "Dynamic cost (Multiplier: %s).",
|
"tooltip.totem_of_reviving.totem_dynamic_cost": "Dynamic cost (Multiplier: %s).",
|
||||||
"tooltip.totem_of_reviving.totem_can_revive_more_expensive_targets": "Can revive more expensive targets.",
|
"tooltip.totem_of_reviving.totem_can_revive_more_expensive_targets": "Can revive more expensive targets.",
|
||||||
"tooltip.totem_of_reviving.totem_can_revive_across_dimensions": "Can revive across dimensions.",
|
"tooltip.totem_of_reviving.totem_can_revive_across_dimensions": "Can revive across dimensions.",
|
||||||
|
|||||||
Reference in New Issue
Block a user