Ah - right, yeah, highlighting requires whitespace/punctuation boundaries. Otherwise it could be a real mess highlighting things like, uhh, "the accredited institution pays you X credits" and so on. I mean, one could always go the "add markup to text" route, but that's more of a pain.
Oh right yeah that makes sense! I have it *mostly* working now.
*EDIT* Ok now I really don't understand what's going on... see details below. I seem to be getting inconsistent results from the highlight method. Specifically look at "credit" in the second log and screenshot- "credits" gets the highlight... minus the "s" which debunks the earlier logic. I originally thought credit came before credits but looking again that's incorrect.
Maybe it is only performing the highlight on the first instance? *See below post* The log verifies the logic to pass the correct data into the highlight method is working as intended. I also added a code example of where the logging happens for reference.
Speaking of "X credits", when the replacement token is storing an int and replaces X with the correct amount of credits, passing that amount (as a string) into the highlight method doesn't work for some reason. I have tested other replacement tokens like $HeOrShe, $personName, etc- at both the start of the line and between other logic tokens and all of that works fine. This leads me to believe that the issue is that the replacement token points to an int. *See below post*
Any way to handle this that you can think of? The way the token parser works is that it compiles the list of highlights found into a List (from a comma separated string) and then iterates through the list and passes each highlight into the method. The string it parses through is the returned string from:
responseDialogue = Misc.getStringWithTokenReplacement(responseDialogue, dialog.getInteractionTarget(), memoryMap);
I set up some logging and got:
Log:
Spoiler
68571 [Thread-4] INFO factions.FDialogue_factionTextLoader - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO factions.FDialogue_factionTextLoader - Using default dialogue response for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO util.FDialogue_cellDataManager - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 1
68571 [Thread-4] INFO util.FDialogueTokenParser - Highlights detected in dialogue response: 3981,and,
68572 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: 3981
68572 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: and
68572 [Thread-4] INFO util.FDialogueTokenParser - Highlights detected in dialogue response: Four Cross,
68572 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: Four Cross
68572 [Thread-4] INFO util.FDialogueTokenParser - Highlights detected in dialogue response: She,
68572 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: She
Spoiler
425639 [Thread-4] INFO factions.FDialogue_factionTextLoader - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
425639 [Thread-4] INFO factions.FDialogue_factionTextLoader - Using default dialogue response for: commodityRequestSuccessHaveToPay
425640 [Thread-4] INFO util.FDialogue_cellDataManager - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 2
425640 [Thread-4] INFO util.FDialogueTokenParser - Highlights detected in dialogue response: 4208,credit,
425640 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: 4208
425640 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: credit
425640 [Thread-4] INFO util.FDialogueTokenParser - Highlights detected in dialogue response: lieutenant,and,she,
425640 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: lieutenant
425640 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: and
425641 [Thread-4] INFO util.FDialogueTokenParser - Attempting to highlight: she
Game screenshots of results:
Original cell string:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL$AidRequest_estCost$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHL$personName$ENDHL has you in a tight spot. $NEWLINE$STARTHL$HeOrShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL$AidRequest_estCost$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHL$personRank$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHL$heOrShe$ENDHL has no real reason to help you in the first place.
Spoiler
private static void addDialogueHighlights(String highlights, InteractionDialogAPI dialog) {
if (highlights != null) {
LOG.info("Highlights detected in dialogue response: " + highlights);
List<String> highlightList = Arrays.asList(highlights.split(","));
for (int i = 0; i < highlightList.size(); i++) {
LOG.info("Attempting to highlight: " + highlightList.get(i));
dialog.getTextPanel().highlightInLastPara(Misc.getHighlightColor(), highlightList.get(i));
}
}
}
What I assume the returned string looks like:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL3981$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHLFour Cross$ENDHL has you in a tight spot. $NEWLINE$STARTHLShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL3981$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHLcaptain$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHLShe$ENDHL has no real reason to help you in the first place.