Skip to content

Commit

Permalink
feat: #506 follow-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Snownee committed Nov 25, 2024
1 parent 419d0a8 commit 6abb41e
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 101 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.daemon=false
minecraft_version=1.21.1
archive_minecraft_version=1.21.1
supported_version=1.21.1
loader_version=0.15.11
loader_version=0.16.9

# Mod Properties
mod_version=15.8.3
Expand All @@ -16,7 +16,7 @@ maven_group=snownee.jade
archives_base_name=Jade

# Dependencies
fabric_version=0.102.1+1.21.1
fabric_version=0.109.0+1.21.1
cloth_config_version=7.0.65
modmenu_version=11.0.1
rei_version=9.1.504
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
import java.util.Optional;
import java.util.function.Function;

import com.ibm.icu.text.DisplayContext;

import org.jetbrains.annotations.Nullable;

import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -25,7 +22,6 @@
import snownee.jade.api.config.IPluginConfig;
import snownee.jade.api.config.IWailaConfig;
import snownee.jade.api.ui.BoxStyle;
import snownee.jade.api.ui.DisplayStyle;
import snownee.jade.api.ui.IElementHelper;
import snownee.jade.api.ui.ProgressStyle;
import snownee.jade.api.view.ClientViewGroup;
Expand All @@ -35,6 +31,7 @@
import snownee.jade.api.view.ViewGroup;
import snownee.jade.impl.WailaClientRegistration;
import snownee.jade.impl.WailaCommonRegistration;
import snownee.jade.impl.ui.ElementHelper;
import snownee.jade.util.CommonProxy;
import snownee.jade.util.WailaExceptionHandler;

Expand Down Expand Up @@ -87,34 +84,35 @@ public static void append(ITooltip tooltip, Accessor<?> accessor, IPluginConfig

IElementHelper helper = IElementHelper.get();
boolean renderGroup = groups.size() > 1 || groups.getFirst().shouldRenderGroup();
ClientViewGroup.tooltip(tooltip, groups, renderGroup, (theTooltip, group) -> {
if (renderGroup) {
group.renderHeader(theTooltip);
}
for (var view : group.views) {
Component text;
if (view.overrideText != null) {
text = view.overrideText;
} else {
text = Component.translatable("jade.fe", ChatFormatting.WHITE + view.current, view.max)
.withStyle(ChatFormatting.GRAY);
}

DisplayStyle style = config.getEnum(JadeIds.UNIVERSAL_ENERGY_STORAGE_STYLE);
switch(style) {
case TEXT -> theTooltip.add(Component.translatable("jade.energy.text").append(text));
case SYMBOL -> {
ResourceLocation location = JadeIds.JADE("energy");
theTooltip.add(helper.sprite(location, 7, 7));
theTooltip.append(text);
ClientViewGroup.tooltip(
tooltip, groups, renderGroup, (theTooltip, group) -> {
if (renderGroup) {
group.renderHeader(theTooltip);
}
default -> {
ProgressStyle progressStyle = helper.progressStyle().color(0xFFAA0000, 0xFF660000);
theTooltip.add(helper.progress(view.ratio, text, progressStyle, BoxStyle.getNestedBox(), true));
for (var view : group.views) {
Component text;
if (view.overrideText != null) {
text = view.overrideText;
} else {
text = Component.translatable("jade.fe", view.current, view.max);
}

IWailaConfig.HandlerDisplayStyle style = config.getEnum(JadeIds.UNIVERSAL_ENERGY_STORAGE_STYLE);
switch (style) {
case PLAIN_TEXT -> theTooltip.add(Component.translatable("jade.energy.text", text));
case ICON -> {
theTooltip.add(helper.sprite(JadeIds.JADE("energy"), 10, 10)
.size(ElementHelper.SMALL_ITEM_SIZE)
.translate(ElementHelper.SMALL_ITEM_OFFSET));
theTooltip.append(text);
}
case PROGRESS_BAR -> {
ProgressStyle progressStyle = helper.progressStyle().color(0xFFAA0000, 0xFF660000);
theTooltip.add(helper.progress(view.ratio, text, progressStyle, BoxStyle.getNestedBox(), true));
}
}
}
}
}
});
});
}

public static void putData(Accessor<?> accessor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import snownee.jade.api.TooltipPosition;
import snownee.jade.api.config.IPluginConfig;
import snownee.jade.api.config.IWailaConfig;
import snownee.jade.api.theme.IThemeHelper;
import snownee.jade.api.ui.BoxStyle;
import snownee.jade.api.ui.DisplayStyle;
import snownee.jade.api.ui.IDisplayHelper;
import snownee.jade.api.ui.IElementHelper;
import snownee.jade.api.ui.ProgressStyle;
Expand Down Expand Up @@ -88,42 +88,47 @@ public static void append(ITooltip tooltip, Accessor<?> accessor, IPluginConfig

IElementHelper helper = IElementHelper.get();
boolean renderGroup = groups.size() > 1 || groups.getFirst().shouldRenderGroup();
ClientViewGroup.tooltip(tooltip, groups, renderGroup, (theTooltip, group) -> {
if (renderGroup) {
group.renderHeader(theTooltip);
}
for (var view : group.views) {
Component text;
DisplayStyle style = config.getEnum(JadeIds.UNIVERSAL_FLUID_STORAGE_STYLE);

if (view.overrideText != null) {
text = view.overrideText;
} else if (view.fluidName == null) {
text = Component.literal(view.current);
} else if (accessor.showDetails() || style != DisplayStyle.PROGRESSBAR) {
text = Component.translatable(
"jade.fluid2",
IDisplayHelper.get().stripColor(view.fluidName).withStyle(ChatFormatting.WHITE),
Component.literal(view.current).withStyle(ChatFormatting.WHITE),
view.max).withStyle(ChatFormatting.GRAY);
} else {
text = Component.translatable("jade.fluid", IDisplayHelper.get().stripColor(view.fluidName), view.current);
}

switch(style) {
case TEXT -> theTooltip.add(Component.translatable("jade.fluid.text").append(text));
case SYMBOL -> {
ResourceLocation location = JadeIds.JADE("fluid");
theTooltip.add(helper.smallItem(new ItemStack(Items.BUCKET)));
theTooltip.append(text);
ClientViewGroup.tooltip(
tooltip, groups, renderGroup, (theTooltip, group) -> {
if (renderGroup) {
group.renderHeader(theTooltip);
}
default -> {
ProgressStyle progressStyle = helper.progressStyle().overlay(view.overlay);
theTooltip.add(helper.progress(view.ratio, text, progressStyle, BoxStyle.getNestedBox(), true));
for (var view : group.views) {
Component text;
IWailaConfig.HandlerDisplayStyle style = config.getEnum(JadeIds.UNIVERSAL_FLUID_STORAGE_STYLE);

if (view.overrideText != null) {
text = view.overrideText;
} else if (view.fluidName == null) {
// when do we reach here?
text = IThemeHelper.get().info(view.current);
} else {
Component fluidName = IThemeHelper.get().info(IDisplayHelper.get().stripColor(view.fluidName));
if (accessor.showDetails() || style != IWailaConfig.HandlerDisplayStyle.PROGRESS_BAR) {
text = Component.translatable(
"jade.fluid.with_capacity",
IThemeHelper.get().info(view.current),
view.max);
} else {
text = IThemeHelper.get().info(view.current);
}
String key = style == IWailaConfig.HandlerDisplayStyle.PLAIN_TEXT ? "jade.fluid.text" : "jade.fluid";
text = Component.translatable(key, fluidName, text);
}

switch (style) {
case PLAIN_TEXT -> theTooltip.add(text);
case ICON -> {
theTooltip.add(helper.smallItem(new ItemStack(Items.BUCKET)));
theTooltip.append(text);
}
case PROGRESS_BAR -> {
ProgressStyle progressStyle = helper.progressStyle().overlay(view.overlay);
theTooltip.add(helper.progress(view.ratio, text, progressStyle, BoxStyle.getNestedBox(), true));
}
}
}
}
}
});
});
}

public static void putData(Accessor<?> accessor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import snownee.jade.api.IWailaPlugin;
import snownee.jade.api.JadeIds;
import snownee.jade.api.WailaPlugin;
import snownee.jade.api.ui.DisplayStyle;
import snownee.jade.api.config.IWailaConfig;

@WailaPlugin
public class UniversalPlugin implements IWailaPlugin {
Expand Down Expand Up @@ -40,9 +40,9 @@ public void registerClient(IWailaClientRegistration registration) {
registration.addConfig(JadeIds.UNIVERSAL_ITEM_STORAGE_SHOW_NAME_AMOUNT, 5, 0, 9, true);
registration.addConfig(JadeIds.UNIVERSAL_ITEM_STORAGE_ITEMS_PER_LINE, 9, 3, 27, true);
registration.addConfig(JadeIds.UNIVERSAL_ENERGY_STORAGE_DETAILED, false);
registration.addConfig(JadeIds.UNIVERSAL_ENERGY_STORAGE_STYLE, DisplayStyle.PROGRESSBAR);
registration.addConfig(JadeIds.UNIVERSAL_ENERGY_STORAGE_STYLE, IWailaConfig.HandlerDisplayStyle.PROGRESS_BAR);
registration.addConfig(JadeIds.UNIVERSAL_FLUID_STORAGE_DETAILED, false);
registration.addConfig(JadeIds.UNIVERSAL_FLUID_STORAGE_STYLE, DisplayStyle.PROGRESSBAR);
registration.addConfig(JadeIds.UNIVERSAL_FLUID_STORAGE_STYLE, IWailaConfig.HandlerDisplayStyle.PROGRESS_BAR);

registration.registerBlockComponent(ItemStorageProvider.getBlock(), Block.class);
registration.registerEntityComponent(ItemStorageProvider.getEntity(), Entity.class);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/snownee/jade/api/config/IWailaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ enum PerspectiveMode implements SimpleStringRepresentable {
CAMERA, EYE
}

enum HandlerDisplayStyle implements SimpleStringRepresentable {
PROGRESS_BAR, ICON, PLAIN_TEXT;
}

@NonExtendable
interface IConfigGeneral {

Expand Down
5 changes: 0 additions & 5 deletions src/main/java/snownee/jade/api/ui/DisplayStyle.java

This file was deleted.

13 changes: 9 additions & 4 deletions src/main/java/snownee/jade/impl/ui/SimpleProgressStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.phys.Vec2;
import snownee.jade.api.config.IWailaConfig.IConfigOverlay;
import snownee.jade.api.theme.IThemeHelper;
import snownee.jade.api.ui.Color;
import snownee.jade.api.ui.ScreenDirection;
import snownee.jade.api.ui.ProgressStyle;
import snownee.jade.api.ui.ScreenDirection;
import snownee.jade.overlay.DisplayHelper;
import snownee.jade.overlay.OverlayRenderer;

Expand All @@ -25,7 +26,7 @@ public class SimpleProgressStyle extends ProgressStyle {
public boolean vertical;

public SimpleProgressStyle() {
color(0xFFFFFFFF);
color(-1);
}

private static Vector3f RGBtoHSV(int rgb) {
Expand Down Expand Up @@ -68,7 +69,9 @@ public ProgressStyle color(int color, int color2) {

@Override
public ProgressStyle direction(ScreenDirection direction) {
Preconditions.checkArgument(direction == ScreenDirection.UP || direction == ScreenDirection.RIGHT, "Only UP and RIGHT are supported");
Preconditions.checkArgument(
direction == ScreenDirection.UP || direction == ScreenDirection.RIGHT,
"Only UP and RIGHT are supported");
super.direction(direction);
vertical = direction.isVertical();
return this;
Expand Down Expand Up @@ -131,8 +134,10 @@ public void render(GuiGraphics guiGraphics, float x, float y, float width, float
if (overlay == null && RGBtoHSV(color2).z() > 0.75f) {
textColor = 0xFF000000;
} else {
textColor = 0xFFFFFFFF;
textColor = IThemeHelper.get().getNormalColor();
}
} else if (textColor == -1) {
textColor = IThemeHelper.get().getNormalColor();
}
y += height - font.lineHeight;
if (vertical && font.lineHeight < progress) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/jade/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"config.jade.plugin_minecraft.item_tooltip": "Item-Tooltip",
"jade.locked": "Inventar ist gesperrt",
"jade.fe": "%s / %s",
"jade.energy.text": "Energie: ",
"jade.energy.text": "Energie: %s",
"jade.fluid": "%s %s",
"jade.fluid.empty": "Leer",
"config.jade.plugin_minecraft.lectern": "Lesepult",
Expand Down
24 changes: 11 additions & 13 deletions src/main/resources/assets/jade/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,24 @@
"config.jade.plugin_minecraft.energy_storage": "Energy Storage",
"config.jade.plugin_minecraft.energy_storage.detailed": "Detailed-Only",
"config.jade.plugin_minecraft.energy_storage.detailed_desc": "Only show energy info when ${SHOW_DETAILS} is pressed.",
"config.jade.plugin_minecraft.energy_storage.style": "Display style",
"config.jade.plugin_minecraft.energy_storage.style_text": "Text",
"config.jade.plugin_minecraft.energy_storage.style_symbol": "Symbol",
"config.jade.plugin_minecraft.energy_storage.style_progressbar": "Progressbar",
"config.jade.plugin_minecraft.energy_storage.style_desc": "Choose between the following Display Styles:\n- Progressbar\n- Text\n- Symbol",
"jade.energy.text": "Energy: ",
"config.jade.plugin_minecraft.energy_storage.style": "Display Style",
"config.jade.plugin_minecraft.energy_storage.style_plain_text": "Plain Text",
"config.jade.plugin_minecraft.energy_storage.style_icon": "Icon",
"config.jade.plugin_minecraft.energy_storage.style_progress_bar": "Progress Bar",
"jade.fe": "%s / %s",
"jade.energy.text": "Energy: %s",
"config.jade.plugin_minecraft.fluid_storage": "Fluid Storage",
"config.jade.plugin_minecraft.fluid_storage_extra_msg": "tank,liquid",
"config.jade.plugin_minecraft.fluid_storage.detailed": "Detailed-Only",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "Only show fluid info when ${SHOW_DETAILS} is pressed.",
"config.jade.plugin_minecraft.fluid_storage.style": "Display style",
"config.jade.plugin_minecraft.fluid_storage.style_text": "Text",
"config.jade.plugin_minecraft.fluid_storage.style_symbol": "Symbol",
"config.jade.plugin_minecraft.fluid_storage.style_progressbar": "Progressbar",
"config.jade.plugin_minecraft.fluid_storage.style_desc": "Choose between the following Display Styles:\n- Progressbar\n- Text\n- Symbol",
"jade.fluid.text": "Fluid: ",
"config.jade.plugin_minecraft.fluid_storage.style": "Display Style",
"config.jade.plugin_minecraft.fluid_storage.style_plain_text": "Plain Text",
"config.jade.plugin_minecraft.fluid_storage.style_icon": "Icon",
"config.jade.plugin_minecraft.fluid_storage.style_progress_bar": "Progress Bar",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.with_capacity": "%s / %s",
"jade.fluid.empty": "Empty",
"jade.fluid.text": "%s: %s",
"config.jade.plugin_minecraft.lectern": "Lectern",
"config.jade.plugin_minecraft.animal_owner": "Animal Owner",
"config.jade.plugin_minecraft.animal_owner_extra_msg": "horse,pet",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "Sólo detallado",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "Solo muestra información del fluido cuando se presiona ${SHOW_DETAILS}.",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "Vacío",
"config.jade.plugin_minecraft.lectern": "Atril",
"config.jade.plugin_minecraft.animal_owner": "Dueño del animal",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/jade/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "詳細のみ",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "${SHOW_DETAILS}を押した時にのみ液体情報を表示します。",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s/%s",
"jade.fluid.with_capacity": "%s/%s",
"jade.fluid.empty": "",
"config.jade.plugin_minecraft.lectern": "書見台",
"config.jade.plugin_minecraft.animal_owner": "動物の所有者",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/ko_kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "상세-전용",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "${SHOW_DETAILS} 키를 눌렀을 때만 액체 정보를 표시.",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "비어있음",
"config.jade.plugin_minecraft.lectern": "독서대",
"config.jade.plugin_minecraft.animal_owner": "동물 주인",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/nl_nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "Alleen gedetailleerd",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "Toon alleen vloeistofinformatie wanneer ${SHOW_DETAILS} wordt ingedrukt.",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "Leeg",
"config.jade.plugin_minecraft.lectern": "Lessenaar",
"config.jade.plugin_minecraft.animal_owner": "Diereneigenaar",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "Только детальная информация",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "Показывать информацию о жидкости только при нажатии клавиши ${SHOW_DETAILS}.",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "Пусто",
"config.jade.plugin_minecraft.lectern": "Кафедра",
"config.jade.plugin_minecraft.animal_owner": "Владелец животного",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/uk_ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "Тільки детально",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "Показувати інформацію про рідину лише тоді, коли натиснуто ${SHOW_DETAILS}.",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "Порожньо",
"config.jade.plugin_minecraft.lectern": "Аналой",
"config.jade.plugin_minecraft.animal_owner": "Власник тварини",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/jade/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "仅在细节显示",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "仅在按下${SHOW_DETAILS}时显示。",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s / %s",
"jade.fluid.empty": "",
"config.jade.plugin_minecraft.lectern": "讲台",
"config.jade.plugin_minecraft.animal_owner": "动物主人",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/jade/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
"config.jade.plugin_minecraft.fluid_storage.detailed": "僅詳細資料",
"config.jade.plugin_minecraft.fluid_storage.detailed_desc": "只在按下${SHOW_DETAILS}時顯示流體資訊。",
"jade.fluid": "%s %s",
"jade.fluid2": "%s %s/%s",
"jade.fluid.with_capacity": "%s/%s",
"jade.fluid.empty": "",
"config.jade.plugin_minecraft.lectern": "講台",
"config.jade.plugin_minecraft.animal_owner": "動物主人",
Expand Down
Binary file modified src/main/resources/assets/jade/textures/gui/sprites/energy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6abb41e

Please sign in to comment.