HotkeyHints.cs

Static UI helper that maps CSS class names on panels to hotkey action ids and writes a tooltip title with the localized action label and the key binding. Called by walking a panel tree with Apply(Panel).

using Sandbox.UI;
using Socer;
using System.Collections.Generic;
using System.Linq;

public static class HotkeyHints
{
    static readonly Dictionary<string,string> Actions=new()
    {
        ["pause"]="match.pause",["open-substitutions"]="match.substitutions",["auto-speed"]="match.auto_speed",
        ["speed-one"]="match.normal_speed",["speed-half"]="match.slower",["speed-fast"]="match.faster",
        ["camera-toggle"]="camera.toggle",["vision-toggle"]="view.vision",["speech-toggle"]="view.speech",
        ["manual-standards"]="standards.manual",["club-open"]="app.club",["resume-match"]="app.club",
        ["skip-intro"]="match.skip",["skip-replay"]="match.skip",["settings-gear"]="app.settings",
        ["replay"]="match.rematch",["new-match"]="match.new_match",["finish-in-text"]="match.finish_text",
        ["friendly"]="club.friendly",["preview-opponent"]="club.opponent",["match-mode-text"]="club.mode_text",
        ["training-page-prev"]="ui.previous_page",["training-page-next"]="ui.next_page",
        ["team-counter"]="tactics.counter",["team-balance"]="tactics.balanced",["team-high-press"]="tactics.pressing",
        ["coach-press"]="coach.order_1",["coach-attack"]="coach.order_2",["coach-rest"]="coach.order_3",
        ["auto-strategies"]="play.automatic",["order-press"]="field.press",["order-mark"]="field.mark",
        ["order-zone"]="field.zone",["order-run"]="field.run",["order-clear"]="field.clear",
        ["role-button"]="player.role",["calm-player"]="player.calm",["team-overview"]="club.overview",
        ["team-squad-view"]="club.squad",["team-player-training"]="club.training",["team-equipment"]="club.equipment",
        ["club-page-home"]="club.overview",["club-page-league"]="club.league",["club-page-cup"]="club.cups",
        ["club-page-missions"]="club.missions",["club-page-store"]="club.store",["club-page-catalog"]="club.catalog",
        ["execute-setpiece"]="standard.confirm",["auto-setpiece"]="standard.automatic",
        ["sub-confirm"]="app.confirm",["injury-confirm"]="app.confirm",["confirm-lineup"]="app.confirm",
        ["match-mode-live"]="app.confirm",["hub-play"]="app.confirm",["result-continue"]="app.confirm",
        ["settings-close"]="app.back",["sub-close"]="app.back",["command-close"]="app.back",
        ["cancel-lineup"]="app.back",["mode-back"]="app.back"
    };
    public static void Apply(Panel root)
    {
        if(root==null)return;
        foreach(var panel in root.Descendants)
            foreach(var css in panel.Class)
                if(Actions.TryGetValue(css,out var id))
                {
                    var action=GameHotkeys.Definitions.FirstOrDefault(d=>d.Id==id);
                    if(action!=null)panel.SetAttribute("title",action.Label(GamePreferences.Russian)+" · "+GameHotkeys.Display(id));
                    break;
                }
    }
}