Fix: energy icons in custom keyword tooltips outside of a run - #344
Open
sethmcleod wants to merge 1 commit into
Open
Fix: energy icons in custom keyword tooltips outside of a run#344sethmcleod wants to merge 1 commit into
sethmcleod wants to merge 1 commit into
Conversation
Rich keyword tooltips passed an empty energyPrefix, which makes
EnergyIconsFormatter fall back to RunManager.GetLocalCharacterEnergyIconPrefix().
That returns null when there is no RunState, so custom energy icons rendered
correctly during a run but fell back to the colorless icon in the card library
opened from the main menu (and logged "No energy prefix found for
EnergyIconsFormatter!").
The game resolves this from the model rather than the run: CardModel, PowerModel,
PotionModel, RelicModel and EnchantmentModel all populate energyPrefix with
EnergyIconHelper.GetPrefix(this), which falls back to the model's own pool and so
works outside a run. HoverTipFactory.FromKeyword only receives the keyword, so
let the keyword declare its pool:
[KeywordProperties(AutoKeywordPosition.None, Pool = typeof(MyCardPool))]
public static CardKeyword MyKeyword;
Keywords that don't declare a pool keep the previous behaviour.
Fixes Alchyr#337
sethmcleod
force-pushed
the
fix/keyword-tip-energy-prefix
branch
from
July 16, 2026 16:45
caff598 to
27656f2
Compare
Owner
|
Hmmm definitely better than current but the ideal fix would probably be for the tooltip energy icon to be based on the model it's attached to |
Author
|
Thanks for considering! I agree that would be the ideal fix and I'd be happy to take a stab at that if you'd like. Not high priority though since there's a workaround. |
Contributor
|
I wrote a hyper niche hook ages ago that let you modify a card's hover tips dynamically by postfixing the get method. A patch like that would give you the ability to check the model the tip is attached to and perform any logic you wanted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #337.
Problem
Custom keyword tooltips containing energy icons render the correct icon during a run, but fall back to the colorless icon in the card library opened from the main menu, logging:
Cause
CustomTooltips.DynamicKeywordTipspasses an empty prefix:An empty value makes the game's
EnergyIconsFormatterfall back to the character being played:GetLocalCharacterEnergyIconPrefix()readsLocalContext.GetMe(State)?.Character.CardPooland returns null when there is noRunState— which is the case in the card library.The game itself never relies on that fallback:
CardModel,PowerModel,PotionModel,RelicModelandEnchantmentModelall populate the variable withEnergyIconHelper.GetPrefix(this), which resolves from the model's own pool and therefore works outside a run.HoverTipFactory.FromKeywordonly receives the keyword, andKeywordInfocarried no pool, so BaseLib had nothing to resolve from.Change
Let a keyword declare the pool its energy icon comes from:
KeywordPropertiesAttribute.Poolis stored onKeywordInfo.PoolTypeat registration and used to resolve the prefix viaEnergyIconHelper.GetPrefix, matching how the game does it for cards and powers.Opt-in and backwards compatible: keywords that don't declare a pool still pass
""and behave exactly as before.Testing
Tested with a custom character mod (custom
CustomCardPoolModelwithTextEnergyIconPath), hovering keyword tooltips in the card library from the main menu with no run active. Resolved tooltip text:Pooldeclaredcolorless_energy_icon.pngcolorless_energy_icon.png(unchanged)Pool = typeof(AlchemistCardPool)colorless_energy_icon.pngres://Alchemist/images/charui/text_energy.pngThe
No energy prefix foundwarning no longer fires for keywords that declare a pool. Icons in-run are unaffected.Alternative considered: inferring the pool
This PR asks each keyword to name its pool. The alternative is to infer it: BaseLib already knows the keyword's declaring type and its mod prefix (
t.GetPrefix(), used to build the keyword ID), so it could look for a custom card pool registered under that same prefix and use it when exactly one exists, falling back to""otherwise.The upside is real — most character mods have exactly one card pool, so existing mods (including the one in #337) would be fixed with no code change at all.
The trade-offs:
Poolwould still be needed as an override.I went with the explicit version because it's predictable and easy to build on, but I'm happy to add inference on top if you'd rather existing mods heal without changes —
Poolwould stay as the override.