Skip to content

Commit

Permalink
chore: make tooltips more consistent (TeamGalacticraft#409)
Browse files Browse the repository at this point in the history
* fix: abstracted code for adding shift tooltips to TooltipUtil to reduce redundancy and make it easier to maintain consistency

* fix: bump MachineLib version, remove unnecessary nested interface (Constant.Text.Color), standardize oxygen tank/battery tooltips and adjust color transition of hot throwable meteor chunk tooltip
  • Loading branch information
Roelymole authored Feb 5, 2025
1 parent 331c2a0 commit 6632d8c
Show file tree
Hide file tree
Showing 24 changed files with 204 additions and 132 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ modmenu.version=11.0.1
rei.version=16.0.754
jei.version=19.8.2.99
dynamicdimensions.version=0.8.0+24
machinelib.version=0.7.0+79
machinelib.version=0.7.0+84
badpackets.version=0.8.1
wthit.version=12.3.0
obj.version=0.4.0
Expand Down
12 changes: 10 additions & 2 deletions src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,18 @@
"block.galacticraft.detailed_titanium_decoration_wall": "Detailed Titanium Decoration Wall",
"block.galacticraft.diagonal_light_panel": "Light Panel (Diagonal)",
"block.galacticraft.electric_arc_furnace": "Electric Arc Furnace",
"block.galacticraft.electric_arc_furnace.description": "Electric Arc Furnace is used as a better and faster alternative to both traditional coal and electric furnaces: double output from ores!",
"block.galacticraft.electric_compressor": "Electric Compressor",
"block.galacticraft.electric_compressor.description": "Electric Compressor will process ingots into their compressed equivalents. Compresses two at a time, making it more effective than its predecessor.",
"block.galacticraft.electric_furnace": "Electric Furnace",
"block.galacticraft.electric_furnace.description": "Electric Furnace is used as a faster alternative to traditional coal furnaces.",
"block.galacticraft.energy_storage_module": "Energy Storage Module",
"block.galacticraft.energy_storage_module.description": "Energy Storage Module is used to store large amounts of energy for later use.",
"block.galacticraft.fallen_meteor": "Fallen Meteor",
"block.galacticraft.fluid_pipe_walkway": "Fluid Pipe Walkway",
"block.galacticraft.fuel": "Fuel",
"block.galacticraft.fuel_loader": "Fuel Loader",
"block.galacticraft.fuel_loader.description": "After being connected to a launch pad, a Fuel Loader will allow fuel to passed into the connected Rocket or other vehicle.",
"block.galacticraft.fueling_pad": "Fueling Pad",
"block.galacticraft.galena_ore": "Galena Ore",
"block.galacticraft.glass_fluid_pipe": "Glass Fluid Pipe",
Expand Down Expand Up @@ -204,9 +207,13 @@
"block.galacticraft.oxygen_collector": "Oxygen Collector",
"block.galacticraft.oxygen_collector.description": "Oxygen Collector will store oxygen collected from leaves in the surrounding area.",
"block.galacticraft.oxygen_compressor": "Oxygen Compressor",
"block.galacticraft.oxygen_compressor.description": "Oxygen Compressor will load oxygen from internal storage into an oxygen tank.",
"block.galacticraft.oxygen_decompressor": "Oxygen Decompressor",
"block.galacticraft.oxygen_decompressor.description": "Oxygen Decompressor will unload oxygen into internal storage from an oxygen tank.",
"block.galacticraft.oxygen_sealer": "Oxygen Sealer",
"block.galacticraft.oxygen_sealer.description": "Oxygen Sealer will check for an enclosed space. If the space is enclosed, it will fill with breathable air.",
"block.galacticraft.oxygen_storage_module": "Oxygen Storage Module",
"block.galacticraft.oxygen_storage_module.description": "Oxygen Storage Module is used to store large amounts of oxygen for later use.",
"block.galacticraft.parachest": "Parachest",
"block.galacticraft.parachest.description": "Parachests will fall from the sky after landing on certain planets/moons, such as Earth. Contains rocket, fuel, and cargo from previous launch.",
"block.galacticraft.pink_candle_moon_cheese_wheel": "Moon Cheese Wheel with Pink Candle",
Expand Down Expand Up @@ -588,9 +595,10 @@
"tooltip.galacticraft.glowstone_torch": "Glowstone Torches are best used to light areas when there is no oxygen for wood torches to burn.",
"tooltip.galacticraft.infinite": "Infinite",
"tooltip.galacticraft.oxygen_remaining": "Oxygen Remaining: %s",
"tooltip.galacticraft.press_shift": "Press LSHIFT for more info",
"tooltip.galacticraft.press_shift": "Press LSHIFT for more information.",
"tooltip.galacticraft.seconds_unit": "%ss",
"tooltip.galacticraft.standard_wrench": "Most Galacticraft machines can be rotated by right-clicking with the Standard Wrench.",
"tooltip.galacticraft.time_until_cool": "Time Until Cool: %ss",
"tooltip.galacticraft.time_until_cool": "Time Until Cool: %s",
"ui.galacticraft.airlock.owner": "%s's Airlock Controller",
"ui.galacticraft.airlock.redstone_signal": "Opens on Redstone Signal",
"ui.galacticraft.alpha_warning.content1": "Galacticraft is currently in ALPHA.",
Expand Down
48 changes: 27 additions & 21 deletions src/main/java/dev/galacticraft/mod/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,27 +739,33 @@ interface LootTable {
}

interface Text {
interface Color {
Style DARK_GRAY_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_GRAY);
Style GOLD_STYLE = Style.EMPTY.withColor(ChatFormatting.GOLD);
Style GREEN_STYLE = Style.EMPTY.withColor(ChatFormatting.GREEN);
Style RED_STYLE = Style.EMPTY.withColor(ChatFormatting.RED);
Style BLUE_STYLE = Style.EMPTY.withColor(ChatFormatting.BLUE);
Style AQUA_STYLE = Style.EMPTY.withColor(ChatFormatting.AQUA);
Style GRAY_STYLE = Style.EMPTY.withColor(ChatFormatting.GRAY);
Style DARK_RED_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_RED);
Style LIGHT_PURPLE_STYLE = Style.EMPTY.withColor(ChatFormatting.LIGHT_PURPLE);
Style YELLOW_STYLE = Style.EMPTY.withColor(ChatFormatting.YELLOW);
Style WHITE_STYLE = Style.EMPTY.withColor(ChatFormatting.WHITE);
Style DARK_BLUE_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_BLUE);

static int getStorageLevelColor(double scale) {
return ((int) (255 * scale) << 16) + (((int) (255 * (1.0 - scale))) << 8);
}

static Style getStorageLevelStyle(double scale) {
return Style.EMPTY.withColor(TextColor.fromRgb(getStorageLevelColor(scale)));
}
Style DARK_GRAY_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_GRAY);
Style GOLD_STYLE = Style.EMPTY.withColor(ChatFormatting.GOLD);
Style GREEN_STYLE = Style.EMPTY.withColor(ChatFormatting.GREEN);
Style RED_STYLE = Style.EMPTY.withColor(ChatFormatting.RED);
Style BLUE_STYLE = Style.EMPTY.withColor(ChatFormatting.BLUE);
Style AQUA_STYLE = Style.EMPTY.withColor(ChatFormatting.AQUA);
Style GRAY_STYLE = Style.EMPTY.withColor(ChatFormatting.GRAY);
Style DARK_RED_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_RED);
Style LIGHT_PURPLE_STYLE = Style.EMPTY.withColor(ChatFormatting.LIGHT_PURPLE);
Style YELLOW_STYLE = Style.EMPTY.withColor(ChatFormatting.YELLOW);
Style WHITE_STYLE = Style.EMPTY.withColor(ChatFormatting.WHITE);
Style DARK_BLUE_STYLE = Style.EMPTY.withColor(ChatFormatting.DARK_BLUE);

static int getStorageLevelColor(double scale) {
return ((int) (255 * scale) << 16) + (((int) (255 * (1.0 - scale))) << 8);
}

static Style getStorageLevelStyle(double scale) {
return Style.EMPTY.withColor(TextColor.fromRgb(getStorageLevelColor(scale)));
}

static int getCoolingColor(double scale) {
return (255 << 16) + (((int) (255 * 0.75 * (1.0 - scale))) << 8);
}

static Style getCoolingStyle(double scale) {
return Style.EMPTY.withColor(TextColor.fromRgb(getCoolingColor(scale)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
public class SolarPanelRegistry {
private static final WorldLightSources DEFAULT_LIGHT_SOURCE = new WorldLightSources(
Constant.ScreenTexture.DEFAULT_LIGHT_SOURCES,
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_SUN).setStyle(Constant.Text.Color.YELLOW_STYLE), 1.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_MOON).setStyle(Constant.Text.Color.GRAY_STYLE), 0.07, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_RAIN).setStyle(Constant.Text.Color.BLUE_STYLE), 1.0, 2.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.Color.WHITE_STYLE), 0.0, 1.0));
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_SUN).setStyle(Constant.Text.YELLOW_STYLE), 1.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_MOON).setStyle(Constant.Text.GRAY_STYLE), 0.07, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_RAIN).setStyle(Constant.Text.BLUE_STYLE), 1.0, 2.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.WHITE_STYLE), 0.0, 1.0));
private static final Map<ResourceKey<Level>, WorldLightSources> LIGHT_SOURCES = new HashMap<>();
private static final Map<BlockEntityType<? extends SolarPanel>, ResourceLocation> SOLAR_PANEL_TEXTURES = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, fl
this.textField.setY(this.topPos + 59);

if (this.menu.state.isActive()) {
graphics.drawString(this.font, Component.translatable(Translations.Ui.BUBBLE_CURRENT_SIZE, FORMAT.format(this.menu.size)).setStyle(Constant.Text.Color.DARK_GRAY_STYLE), this.leftPos + 60, this.topPos + 42, ChatFormatting.DARK_GRAY.getColor(), false);
graphics.drawString(this.font, Component.translatable(Translations.Ui.BUBBLE_CURRENT_SIZE, FORMAT.format(this.menu.size)).setStyle(Constant.Text.DARK_GRAY_STYLE), this.leftPos + 60, this.topPos + 42, ChatFormatting.DARK_GRAY.getColor(), false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public class SolarPanelScreen<Machine extends MachineBlockEntity & SolarPanel, M
private static final int SOLAR_PANEL_WIDTH = 16;
private static final int SOLAR_PANEL_HEIGHT = 16;

private static final Component DAY = Component.translatable(Translations.SolarPanel.DAY).setStyle(Constant.Text.Color.YELLOW_STYLE);
private static final Component OVERCAST = Component.translatable(Translations.SolarPanel.OVERCAST).setStyle(Constant.Text.Color.GRAY_STYLE);
private static final Component NIGHT = Component.translatable(Translations.SolarPanel.NIGHT).setStyle(Constant.Text.Color.BLUE_STYLE);
private static final Component BLOCKED = Component.translatable(Translations.SolarPanel.BLOCKED).setStyle(Constant.Text.Color.DARK_RED_STYLE);
private static final Component MISSING_SOURCE = Component.translatable(Translations.SolarPanel.MISSING_SOURCE).setStyle(Constant.Text.Color.WHITE_STYLE);
private static final Component DAY = Component.translatable(Translations.SolarPanel.DAY).setStyle(Constant.Text.YELLOW_STYLE);
private static final Component OVERCAST = Component.translatable(Translations.SolarPanel.OVERCAST).setStyle(Constant.Text.GRAY_STYLE);
private static final Component NIGHT = Component.translatable(Translations.SolarPanel.NIGHT).setStyle(Constant.Text.BLUE_STYLE);
private static final Component BLOCKED = Component.translatable(Translations.SolarPanel.BLOCKED).setStyle(Constant.Text.DARK_RED_STYLE);
private static final Component MISSING_SOURCE = Component.translatable(Translations.SolarPanel.MISSING_SOURCE).setStyle(Constant.Text.WHITE_STYLE);

private final ResourceLocation solarPanelTexture;
private final WorldLightSources lightSource;
Expand Down Expand Up @@ -120,13 +120,13 @@ protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {
GraphicsUtil.highlightElement(graphics, this.leftPos, this.topPos, SOLAR_PANEL_X + x * SOLAR_PANEL_WIDTH, SOLAR_PANEL_Y + y * SOLAR_PANEL_HEIGHT, SOLAR_PANEL_WIDTH, SOLAR_PANEL_HEIGHT, 0x80ffffff);

if (this.menu.getBlockage()[y * 3 + x]) {
graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.Color.GRAY_STYLE).append(BLOCKED), mouseX, mouseY);
graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.GRAY_STYLE).append(BLOCKED), mouseX, mouseY);
} else {
switch (this.menu.getSource()){
case DAY -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.Color.GRAY_STYLE).append(DAY), mouseX, mouseY);
case OVERCAST -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.Color.GRAY_STYLE).append(OVERCAST), mouseX, mouseY);
case NIGHT -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.Color.GRAY_STYLE).append(NIGHT), mouseX, mouseY);
case NO_LIGHT_SOURCE -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.Color.GRAY_STYLE).append(MISSING_SOURCE), mouseX, mouseY);
case DAY -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.GRAY_STYLE).append(DAY), mouseX, mouseY);
case OVERCAST -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.GRAY_STYLE).append(OVERCAST), mouseX, mouseY);
case NIGHT -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.GRAY_STYLE).append(NIGHT), mouseX, mouseY);
case NO_LIGHT_SOURCE -> graphics.renderTooltip(this.font, Component.translatable(Translations.SolarPanel.STATUS).setStyle(Constant.Text.GRAY_STYLE).append(MISSING_SOURCE), mouseX, mouseY);
}
}
return;
Expand All @@ -142,9 +142,9 @@ protected void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {
case NIGHT -> this.lightSource.night();
case NO_LIGHT_SOURCE -> this.lightSource.missing();
};
tooltip.add(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE).setStyle(Constant.Text.Color.AQUA_STYLE).append(source.name()));
tooltip.add(Component.translatable(Translations.SolarPanel.STRENGTH, source.strength()).setStyle(Constant.Text.Color.GREEN_STYLE));
tooltip.add(Component.translatable(Translations.SolarPanel.ATMOSPHERIC_INTERFERENCE, source.atmosphericInterference()).setStyle(Constant.Text.Color.LIGHT_PURPLE_STYLE));
tooltip.add(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE).setStyle(Constant.Text.AQUA_STYLE).append(source.name()));
tooltip.add(Component.translatable(Translations.SolarPanel.STRENGTH, source.strength()).setStyle(Constant.Text.GREEN_STYLE));
tooltip.add(Component.translatable(Translations.SolarPanel.ATMOSPHERIC_INTERFERENCE, source.atmosphericInterference()).setStyle(Constant.Text.LIGHT_PURPLE_STYLE));
graphics.renderComponentTooltip(this.font, tooltip, mouseX, mouseY);
}
}
Expand All @@ -161,7 +161,7 @@ private void drawNormal(GuiGraphics graphics, int x, int y, int normalU, int nor
public void appendEnergyTooltip(List<Component> list) {
super.appendEnergyTooltip(list);
if (this.menu.state.isActive()) {
list.add(Component.translatable(Translations.Ui.GJT, this.menu.getCurrentEnergyGeneration()).setStyle(Constant.Text.Color.LIGHT_PURPLE_STYLE));
list.add(Component.translatable(Translations.Ui.GJT, this.menu.getCurrentEnergyGeneration()).setStyle(Constant.Text.LIGHT_PURPLE_STYLE));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static int teleportToEarth(CommandContext<CommandSourceStack> context) t
player.getYRot(),
player.getXRot());

context.getSource().sendSuccess(() -> Component.translatable(Translations.GcHouston.SUCCESS).setStyle(Constant.Text.Color.GREEN_STYLE), true);
context.getSource().sendSuccess(() -> Component.translatable(Translations.GcHouston.SUCCESS).setStyle(Constant.Text.GREEN_STYLE), true);
} else {
PROMPT_EXPIRY.put(uuid, tickId + (int)(GC_HOUSTON_TIMER_LENGTH * context.getSource().getServer().tickRateManager().millisecondsPerTick()));
context.getSource().sendSuccess(() -> Component.translatable(Translations.GcHouston.CONFIRMATION), false);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dev/galacticraft/mod/content/GCFluids.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ public static void register() {
public static void registerFluidVariantAttributes() {
FluidVariantAttributes.register(CRUDE_OIL, new GCFluidAttribute(
Component.translatable(GCBlocks.CRUDE_OIL.getDescriptionId())
.setStyle(Constant.Text.Color.DARK_GRAY_STYLE),
.setStyle(Constant.Text.DARK_GRAY_STYLE),
FluidConstants.LAVA_VISCOSITY,
false
));
FluidVariantAttributes.register(FUEL, new GCFluidAttribute(
Component.translatable(GCBlocks.FUEL.getDescriptionId())
.setStyle(Constant.Text.Color.YELLOW_STYLE),
.setStyle(Constant.Text.YELLOW_STYLE),
2000,
false
));
FluidVariantAttributes.register(SULFURIC_ACID, new GCFluidAttribute(
Component.translatable(GCBlocks.SULFURIC_ACID.getDescriptionId())
.setStyle(Constant.Text.Color.YELLOW_STYLE),
.setStyle(Constant.Text.YELLOW_STYLE),
FluidConstants.LAVA_VISCOSITY,
false
));
FluidVariantAttributes.register(LIQUID_OXYGEN, new GCFluidAttribute(
Component.translatable("block.galacticraft.oxygen")
.setStyle(Constant.Text.Color.AQUA_STYLE),
.setStyle(Constant.Text.AQUA_STYLE),
500,
true
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
public class GCLightSources {
private static final WorldLightSources MOON = new WorldLightSources(
Constant.ScreenTexture.MOON_LIGHT_SOURCES,
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_SUN).setStyle(Constant.Text.Color.YELLOW_STYLE), 1.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_EARTH).setStyle(Constant.Text.Color.GREEN_STYLE), 0.07, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.Color.BLUE_STYLE), 0.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.Color.WHITE_STYLE), 0.0, 1.0));
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_SUN).setStyle(Constant.Text.YELLOW_STYLE), 1.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_EARTH).setStyle(Constant.Text.GREEN_STYLE), 0.07, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.BLUE_STYLE), 0.0, 1.0),
new LightSource(Component.translatable(Translations.SolarPanel.LIGHT_SOURCE_NONE).setStyle(Constant.Text.WHITE_STYLE), 0.0, 1.0));

public static void register() {
SolarPanelRegistry.registerLightSources(GCDimensions.MOON, MOON);
Expand Down
Loading

0 comments on commit 6632d8c

Please sign in to comment.