Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory card tooltip not showing P2P frequency #7847

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mithi83
Copy link
Contributor

@Mithi83 Mithi83 commented Apr 30, 2024

A missing translation text of gui.tooltips.ae2.P2PFrequency caused a messed up tooltip for a memory card with P2P information on it.

Memory-Card-Tooltip
Memory-Card-Tooltip-fixed

Some notes for the review: The actual text is a copy of waila.ae2.P2PFrequency. Other duplicates in the translation file make me think that the duplication is the way to go, rather than to change the code in MemoryCardItem.appendHoverText() to use that translatable string as that would be the alternative.

Sidenote: With the 1.20.6 changes the memory card again works correctly with P2P-Tunnels.

@Mari023
Copy link
Contributor

Mari023 commented Apr 30, 2024

en_us.json is made using datagen, if there is something missing it means either the datagen code is wrong, or something is using the wrong string (or not using the constants at all).
also main is 1.20.6, so if this doesn't affect 1.20.6 you probably want to target a different branch

@Mithi83
Copy link
Contributor Author

Mithi83 commented Apr 30, 2024

I'm not familiar with the datagen way to checking for translatable strings. The code using that translatable string is in MemoryCardItem.java, function appendHoverText:

        var p2pFreq = stack.get(AEComponents.EXPORTED_P2P_FREQUENCY);
        if (p2pFreq != null) {
            final String freqTooltip = ChatFormatting.BOLD + Platform.p2p().toHexString(p2pFreq);
            lines.add(Tooltips.of(Component.translatable("gui.tooltips.ae2.P2PFrequency", freqTooltip)));
        }

@Mari023
Copy link
Contributor

Mari023 commented Apr 30, 2024

I'm not familiar with the datagen way to checking for translatable strings.

the Strings are all explicitly registered to datagen (see https://github.com/AppliedEnergistics/Applied-Energistics-2/blob/main/src/main/java/appeng/datagen/providers/localization/LocalizationProvider.java)

the code should either re-use the existing constant, like this:

var p2pFreq = stack.get(AEComponents.EXPORTED_P2P_FREQUENCY);
if (p2pFreq != null) {
    final String freqTooltip = ChatFormatting.BOLD + Platform.p2p().toHexString(p2pFreq)
-   lines.add(Tooltips.of(Component.translatable("gui.tooltips.ae2.P2PFrequency", freqTooltip)));
+   lines.add(Tooltips.of(Component.translatable(InGameTooltip.P2PFrequency.getTranslationKey(), freqTooltip)));
}

or manually add the key, like the others here:

private void generateLocalizations() {
add("ae2.permission_denied", "You lack permission to access this.");
add("biome.ae2.spatial_storage", "Spatial Storage");
add("commands.ae2.ChunkLoggerOff", "Chunk Logging is now off");
add("commands.ae2.ChunkLoggerOn", "Chunk Logging is now on");
add("commands.ae2.permissions", "You do not have adequate permissions to run this command.");
add("commands.ae2.usage",
"Commands provided by Applied Energistics 2 - use /ae2 list for a list, and /ae2 help _____ for help with a command.");
add("entity.minecraft.villager.ae2.fluix_researcher", "Fluix Researcher");
add("gui.ae2.PatternEncoding.primary_processing_result_hint",
"Can be requested through the automated crafting system.");
add("gui.ae2.PatternEncoding.primary_processing_result_tooltip", "Primary Processing Result");
add("gui.ae2.PatternEncoding.secondary_processing_result_hint",
"Can not be directly requested through the automated crafting system, but will be used before stored items in multi-step recipes.");
add("gui.ae2.PatternEncoding.secondary_processing_result_tooltip", "Secondary Processing Result");
add("key.ae2.category", "Applied Energistics 2");
add("key.ae2.portable_fluid_cell", "Open Portable Fluid Cell");
add("key.ae2.portable_item_cell", "Open Portable Item Cell");
add("key.ae2.wireless_terminal", "Open Wireless Terminal");
add("key.ae2.guide", "Open Guide for Items");
add("key.ae2.mouse_wheel_item_modifier", "Modifier for Mouse-Wheel Items");
add("key.toggle_focus.desc", "Toggle search box focus");
add("stat.ae2.items_extracted", "Items extracted from ME Storage");
add("stat.ae2.items_inserted", "Items added to ME Storage");
add("theoneprobe.ae2.channels", "%1$d Channels");
add("theoneprobe.ae2.channels_of", "%1$d of %2$d Channels");
add("theoneprobe.ae2.contains", "Contains");
add("theoneprobe.ae2.crafting", "Crafting: %1$s");
add("theoneprobe.ae2.device_missing_channel", "Device Missing Channel");
add("theoneprobe.ae2.device_offline", "Device Offline");
add("theoneprobe.ae2.device_online", "Device Online");
add("theoneprobe.ae2.locked", "Locked");
add("theoneprobe.ae2.nested_p2p_tunnel", "Error: Nested P2P Tunnel");
add("theoneprobe.ae2.p2p_frequency", "Frequency: %1$s");
add("theoneprobe.ae2.p2p_input_many_outputs", "Linked (Input Side) - %d Outputs");
add("theoneprobe.ae2.p2p_input_one_output", "Linked (Input Side)");
add("theoneprobe.ae2.p2p_output", "Linked (Output Side)");
add("theoneprobe.ae2.p2p_unlinked", "Unlinked");
add("theoneprobe.ae2.showing", "Showing");
add("theoneprobe.ae2.stored_energy", "%1$d / %2$d");
add("theoneprobe.ae2.unlocked", "Unlocked");
}

@Mithi83
Copy link
Contributor Author

Mithi83 commented Apr 30, 2024

Thanks for your explanations! I've updated the branch according to your first suggestion.

A missing translation text of gui.tooltips.ae2.P2PFrequency caused
a messed up tooltip for a memory card with P2P information on it.
@Mithi83
Copy link
Contributor Author

Mithi83 commented Apr 30, 2024

And a minor correction regarding the order of the imports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants