Skip to content

Commit

Permalink
fix: Fix transcription tooltip option not working correctly [skip ci] (
Browse files Browse the repository at this point in the history
…#2476)

* chore: Remove discovery transcribe condition

* wip: Fix tooltip option incorrectly transcribing original text

Tooltip does not currently show

* fix: Fix properly
  • Loading branch information
ShadowCat117 committed May 11, 2024
1 parent f9400cf commit 419aebe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void onChat(ChatMessageReceivedEvent event) {

StyledText modified = getStyledTextWithTranscription(styledText, transcribeWynnic, transcribeGavellian, false);

if (styledText.getString().equalsIgnoreCase(modified.getString())) return;
if (styledText.equals(modified)) return;

event.setMessage(modified.getComponent());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import com.wynntils.core.text.PartStyle;
import com.wynntils.core.text.StyledText;
import com.wynntils.core.text.StyledTextPart;
import com.wynntils.models.activities.discoveries.DiscoveryInfo;
import com.wynntils.models.activities.type.ActivitySortOrder;
import com.wynntils.models.wynnalphabet.type.TranscribeCondition;
import com.wynntils.utils.StringUtils;
import com.wynntils.utils.mc.McUtils;
Expand All @@ -19,10 +17,8 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
Expand Down Expand Up @@ -58,8 +54,6 @@ public class WynnAlphabetModel extends Model {
private static final Map<Character, Character> wynnicToEnglishMap = new HashMap<>();
private static final Pattern BRACKET_PATTERN = Pattern.compile("(\\[\\[.*\\]\\])|(<<.*>>)");
private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+");
private static final String GAVELLIAN_TRANSCRIBER_DISCOVERY = "Ne du Valeos du Ellach";
private static final String WYNNIC_TRANSCRIBER_DISCOVERY = "Wynn Plains Monument";
private static final StyledText GAVELLIAN_TRANSCRIBER = StyledText.fromString("§rHigh Gavellian Transcriber");
private static final StyledText WYNNIC_TRANSCRIBER = StyledText.fromString("§fAncient Wynnic Transcriber");

Expand Down Expand Up @@ -96,7 +90,7 @@ public StyledTextPart transcribeMessageFromWynnAlphabet(

PartStyle partStyle = originalPart.getPartStyle();

if (useColors) {
if (useColors && !originalTextAsTooltip) {
partStyle = partStyle.withColor(colorToUse);
}

Expand All @@ -111,7 +105,8 @@ public StyledTextPart transcribeMessageFromWynnAlphabet(
originalString);
partStyle = partStyle.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));

return new StyledTextPart(transcriptedString, partStyle.getStyle(), null, Style.EMPTY);
return new StyledTextPart(
originalTextAsTooltip ? originalString : transcriptedString, partStyle.getStyle(), null, Style.EMPTY);
}

public String transcribeBracketedText(String message) {
Expand Down Expand Up @@ -253,9 +248,6 @@ public boolean shouldTranscribe(TranscribeCondition condition, WynnAlphabet alph
case TRANSCRIBER -> alphabet == WynnAlphabet.WYNNIC
? hasTranscriber(WynnAlphabet.WYNNIC)
: hasTranscriber(WynnAlphabet.GAVELLIAN);
case DISCOVERY -> alphabet == WynnAlphabet.WYNNIC
? hasCompletedDiscovery(WynnAlphabet.WYNNIC)
: hasCompletedDiscovery(WynnAlphabet.GAVELLIAN);
default -> true;
};
}
Expand Down Expand Up @@ -351,21 +343,6 @@ private boolean hasTranscriber(WynnAlphabet transciberToFind) {
return false;
}

private boolean hasCompletedDiscovery(WynnAlphabet discoveryToCheck) {
Stream<DiscoveryInfo> discoveryInfoStream =
Models.Discovery.getAllCompletedDiscoveries(ActivitySortOrder.ALPHABETIC);

String nameToFind = discoveryToCheck == WynnAlphabet.WYNNIC
? WYNNIC_TRANSCRIBER_DISCOVERY
: GAVELLIAN_TRANSCRIBER_DISCOVERY;

Optional<DiscoveryInfo> foundDiscoveryInfo = discoveryInfoStream
.filter(discoveryInfo -> discoveryInfo.getName().equals(nameToFind))
.findFirst();

return foundDiscoveryInfo.map(DiscoveryInfo::isDiscovered).orElse(false);
}

public void setSelectedAlphabet(WynnAlphabet selectedAlphabet) {
this.selectedAlphabet = selectedAlphabet;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright © Wynntils 2023.
* Copyright © Wynntils 2023-2024.
* This file is released under LGPLv3. See LICENSE for full license details.
*/
package com.wynntils.models.wynnalphabet.type;

public enum TranscribeCondition {
ALWAYS,
DISCOVERY,
TRANSCRIBER,
NEVER
}
2 changes: 1 addition & 1 deletion common/src/main/resources/assets/wynntils/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@
"feature.wynntils.transcribeMessages.showTooltip.name": "Show Transcription Tooltip",
"feature.wynntils.transcribeMessages.transcribeChat.description": "Transcribe chat messages containing Gavellian and Wynnic?",
"feature.wynntils.transcribeMessages.transcribeChat.name": "Transcribe chat messages",
"feature.wynntils.transcribeMessages.transcribeCondition.description": "When should Gavellian and Wynnic be transcribed? Discovery - Once you have completed the discovery for the transcriber. Transcriber - If you have the transcriber in your inventory.",
"feature.wynntils.transcribeMessages.transcribeCondition.description": "When should Gavellian and Wynnic be transcribed? Transcriber - If you have the transcriber in your inventory.",
"feature.wynntils.transcribeMessages.transcribeCondition.name": "Transcribe Condition",
"feature.wynntils.transcribeMessages.transcribeNpcs.description": "Transcribe NPC dialogue containing Gavellian and Wynnic?",
"feature.wynntils.transcribeMessages.transcribeNpcs.name": "Transcribe NPC dialogue",
Expand Down

0 comments on commit 419aebe

Please sign in to comment.