Skip to main content

flatland_client_ui/
keybindings.rs

1//! Play-client keybindings — shared by in-game help overlay and `flatland3 keys`.
2
3use crate::map_presentation::format_map_legend_plain;
4
5pub struct KeyBinding {
6    pub keys: &'static str,
7    pub description: &'static str,
8}
9
10pub struct KeyBindingCategory {
11    pub name: &'static str,
12    pub bindings: &'static [KeyBinding],
13}
14
15pub const CATEGORIES: &[KeyBindingCategory] = &[
16    KeyBindingCategory {
17        name: "Movement",
18        bindings: &[
19            KeyBinding {
20                keys: "WASD / arrows",
21                description: "Move (cardinals; hold two for diagonal)",
22            },
23            KeyBinding {
24                keys: "Click map",
25                description: "Auto-walk to clicked cell (A* path); right-click cancels",
26            },
27            KeyBinding {
28                keys: "Shift (hold)",
29                description: "Sprint while moving",
30            },
31            KeyBinding {
32                keys: "x",
33                description: "Toggle sprint mode (faster move, stamina drain)",
34            },
35            KeyBinding {
36                keys: "Shift+Space",
37                description: "Lunge forward (~8.5 m, high stamina)",
38            },
39            KeyBinding {
40                keys: "m",
41                description: "Map target mode — mouse/WASD place X, Enter to auto-walk",
42            },
43            KeyBinding {
44                keys: "u / j",
45                description: "Climb / descend",
46            },
47            KeyBinding {
48                keys: "Space",
49                description: "Stop movement / cancel auto-walk",
50            },
51        ],
52    },
53    KeyBindingCategory {
54        name: "Combat",
55        bindings: &[
56            KeyBinding {
57                keys: "Tab",
58                description: "Cycle T1 target (hostile)",
59            },
60            KeyBinding {
61                keys: "Shift+Tab",
62                description: "Cycle T2 target (allies, then monsters)",
63            },
64            KeyBinding {
65                keys: "0 / Shift+0",
66                description: "Clear T1 / T2 target",
67            },
68            KeyBinding {
69                keys: "1–9",
70                description: "Hotbar — cast bound ability (see client-settings.yaml)",
71            },
72            KeyBinding {
73                keys: "r / Shift+r",
74                description: "Toggle auto rotation for T1 / T2",
75            },
76            KeyBinding {
77                keys: "c",
78                description: "Dodge (i-frames, stamina)",
79            },
80            KeyBinding {
81                keys: "q",
82                description: "Toggle block (melee damage reduction)",
83            },
84            KeyBinding {
85                keys: "l",
86                description: "Loadout — assign rotation preset to T1/T2",
87            },
88            KeyBinding {
89                keys: "o",
90                description: "Rotation editor — create/edit/delete presets",
91            },
92            KeyBinding {
93                keys: "(auto)",
94                description: "T1 auto pursues into weapon range when idle",
95            },
96        ],
97    },
98    KeyBindingCategory {
99        name: "World",
100        bindings: &[
101            KeyBinding {
102                keys: "f",
103                description: "Use nearest — interact, then pickup loot/chest, then harvest/butcher",
104            },
105            KeyBinding {
106                keys: "v",
107                description: "Quest log / withdraw menu",
108            },
109        ],
110    },
111    KeyBindingCategory {
112        name: "Inventory & crafting",
113        bindings: &[
114            KeyBinding {
115                keys: "b",
116                description: "Inventory (worn items by body slot, on-you items, nearby open chests)",
117            },
118            KeyBinding {
119                keys: "n",
120                description: "Craft menu (Enter to craft, Esc to close)",
121            },
122            KeyBinding {
123                keys: ",",
124                description: "Keychain — stow/retrieve chest keys (zero carry mass when stowed)",
125            },
126            KeyBinding {
127                keys: "i",
128                description: "Character stats overlay",
129            },
130            KeyBinding {
131                keys: "↑↓ / jk",
132                description: "Move selection in craft or inventory menus",
133            },
134            KeyBinding {
135                keys: "Enter",
136                description: "Inventory: equip/wear/use selected item, or move it",
137            },
138            KeyBinding {
139                keys: "m / d / x / l",
140                description: "Inventory: move to… picker / drop on ground / destroy permanently / lock nearby chest",
141            },
142        ],
143    },
144    KeyBindingCategory {
145        name: "Chat",
146        bindings: &[
147            KeyBinding {
148                keys: "t",
149                description: "Say to nearby players",
150            },
151            KeyBinding {
152                keys: "g",
153                description: "Whisper (requires whisper_stone)",
154            },
155            KeyBinding {
156                keys: "Enter",
157                description: "Send chat line",
158            },
159            KeyBinding {
160                keys: "Esc",
161                description: "Cancel chat or close overlay",
162            },
163        ],
164    },
165    KeyBindingCategory {
166        name: "Session",
167        bindings: &[
168            KeyBinding {
169                keys: "? or /",
170                description: "Toggle this keybindings help",
171            },
172            KeyBinding {
173                keys: ".",
174                description: "Cycle HUD view — normal → compact → map",
175            },
176            KeyBinding {
177                keys: "Ctrl+Q",
178                description: "Quit client",
179            },
180            KeyBinding {
181                keys: "Ctrl+C",
182                description: "Interrupt / force quit",
183            },
184        ],
185    },
186    KeyBindingCategory {
187        name: "Dev / debug",
188        bindings: &[
189            KeyBinding {
190                keys: "-",
191                description: "Test damage (25 HP) — dev only",
192            },
193        ],
194    },
195];
196
197/// Plain-text reference for `flatland3 keys` and similar CLIs.
198pub fn format_keybindings_plain() -> String {
199    let mut out = String::from("Flatland3 play — keybindings\n\n");
200    for cat in CATEGORIES {
201        out.push_str(cat.name);
202        out.push_str("\n");
203        for b in cat.bindings {
204            out.push_str(&format!("  {:<16} {}\n", b.keys, b.description));
205        }
206        out.push('\n');
207    }
208    out.push_str(&format_map_legend_plain());
209    out.push_str("Wildlife: rabbits north meadow (~95,195); wolves bog (~118,122).\n");
210    out
211}