feat(text): hover texts come from translation files

What the stations, thralls, the ward and the hive show under the
crosshair now reads its text through ModText.Get, and hover.json holds
50 texts in English and Italian.

The Aswid thralls and the Race Menu Ward wrote the use key as a literal
E; they now use $KEY_Use, which shows the key the player actually bound.
For that to work, ModText.Get runs a second localization pass when a $
is left in the result: Valheim resolves tokens once and never looks
inside what it inserted, and hover texts go to the HUD without another
pass.

The Sverm hive stage names stay English for now: the compendium and the
hive's goods show them too, and those come with the merchants step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-28 13:55:14 +02:00
commit 99a1817eb0
16 changed files with 164 additions and 79 deletions

View file

@ -362,25 +362,21 @@ namespace RacesOfValheim
// upgraded, so there was no way to know the cap was two until ten trophies had gone in.
// Every shelf is now visible whether or not it can be used yet, and says why when it cannot.
string body =
$"\nmelee {alive[SkeletonBonePile.KindMelee]}/{GetSlots(SkeletonBonePile.KindMelee)} of {MeleeCap()}" +
$"\narchers {alive[SkeletonBonePile.KindRanged]}/{GetSlots(SkeletonBonePile.KindRanged)} of {RangedCap()}" +
$"\nrotten {alive[SkeletonBonePile.KindRancid]}/{GetSlots(SkeletonBonePile.KindRancid)} of {RancidCap()}";
ModText.Get("rov_hover_skeleton_melee_archers_rotten", alive[SkeletonBonePile.KindMelee], GetSlots(SkeletonBonePile.KindMelee), MeleeCap(), alive[SkeletonBonePile.KindRanged], GetSlots(SkeletonBonePile.KindRanged), RangedCap(), alive[SkeletonBonePile.KindRancid], GetSlots(SkeletonBonePile.KindRancid), RancidCap());
if (!IsUpgraded()) body += " (needs a Greater Cursed Skull)";
if (!IsUpgraded()) body += ModText.Get("rov_hover_skeleton_needs_greater_cursed_skull");
int bonesToward = m_nview.GetZDO().GetInt(KeyBones);
int placesLeft = TotalCap() - PaidSlots();
body += placesLeft > 0
? $"\nbone {bonesToward}/{SkeletonBonePile.BonesPerSlot} toward the next of {placesLeft} places"
: "\nevery place is bought";
body += (placesLeft > 0 ? ModText.Get("rov_hover_skeleton_bone_toward_next_places", bonesToward, SkeletonBonePile.BonesPerSlot, placesLeft) : ModText.Get("rov_hover_skeleton_every_place_bought"));
if (m_respawnTimer > 0f)
{
int left = Mathf.Max(1, Mathf.CeilToInt(RespawnSeconds() - m_respawnTimer));
body += $"\nnext rises in {left}s";
body += ModText.Get("rov_hover_skeleton_next_rises_s", left);
}
body += "\n[<color=yellow><b>$KEY_Use</b></color>] Bone in hand to buy a place, empty hands to move the line";
body += ModText.Get("rov_hover_skeleton_bone_hand_buy_place_empty");
return Localization.instance.Localize($"{SkeletonBonePile.PieceDisplayName} ({body})");
}