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 / leap (~8.5 m; yields to dodge/block, pauses auto)",
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: "Alt + WASD / arrows",
49                description: "Directional jump — leap one cell over a medium cliff (~2 m rise)",
50            },
51            KeyBinding {
52                keys: "Space",
53                description: "Stop movement / cancel auto-walk",
54            },
55        ],
56    },
57    KeyBindingCategory {
58        name: "Combat",
59        bindings: &[
60            KeyBinding {
61                keys: "Tab",
62                description: "Cycle T1 target (hostile)",
63            },
64            KeyBinding {
65                keys: "Shift+Tab",
66                description: "Cycle T2 target (allies, then monsters)",
67            },
68            KeyBinding {
69                keys: "0 / Shift+0",
70                description: "Clear T1 / T2 target",
71            },
72            KeyBinding {
73                keys: "1–9",
74                description: "Hotbar — cast bound ability or use bound consumable",
75            },
76            KeyBinding {
77                keys: "r / Shift+r",
78                description: "Toggle auto rotation for T1 / T2",
79            },
80            KeyBinding {
81                keys: "c",
82                description: "Dodge i-frames (highest priority — cancels casts, pauses auto)",
83            },
84            KeyBinding {
85                keys: "q",
86                description: "Block (pauses offense; yields to dodge)",
87            },
88            KeyBinding {
89                keys: "l",
90                description: "Loadout — assign rotation preset to T1/T2",
91            },
92            KeyBinding {
93                keys: "o",
94                description: "Rotation editor — create/edit/delete presets",
95            },
96            KeyBinding {
97                keys: "(auto)",
98                description: "T1 auto pursues into weapon range when idle",
99            },
100        ],
101    },
102    KeyBindingCategory {
103        name: "World",
104        bindings: &[
105            KeyBinding {
106                keys: "f",
107                description: "Use nearest — interact, then pickup loot/chest, then harvest/butcher",
108            },
109            KeyBinding {
110                keys: "l (at house door)",
111                description: "Lock/unlock player house door (key required; door must be closed)",
112            },
113            KeyBinding {
114                keys: "Enter (open house door)",
115                description: "Go inside when your house door is open; from inside, exit freely even if locked",
116            },
117            KeyBinding {
118                keys: "Shift+m",
119                description: "Relocate nearest owned chest/lodging — 1×1 ghost square, Enter confirm",
120            },
121            KeyBinding {
122                keys: "k",
123                description: "Buy crown land — claim mode: WASD move plot, [ ] size, Enter buy",
124            },
125            KeyBinding {
126                keys: "Shift+c (on farm plot)",
127                description: "Till soil under you (plain c is always dodge)",
128            },
129            KeyBinding {
130                keys: "v",
131                description: "Quest log / withdraw menu",
132            },
133            KeyBinding {
134                keys: "h",
135                description: "Hired workers — hire, dismiss, give items (g), teach recipes (t), toggle companion/job loop",
136            },
137        ],
138    },
139    KeyBindingCategory {
140        name: "Inventory & crafting",
141        bindings: &[
142            KeyBinding {
143                keys: "b",
144                description: "Inventory (worn items by body slot, on-you items, nearby open chests)",
145            },
146            KeyBinding {
147                keys: "p",
148                description: "Equip paperdoll — body slots, hands, mitigation / resists",
149            },
150            KeyBinding {
151                keys: "n",
152                description: "Craft menu — Tab/[ ] tier tabs (Ready default), / search, f favorite, Enter craft",
153            },
154            KeyBinding {
155                keys: ",",
156                description: "Keychain — stow/retrieve chest keys (zero carry mass when stowed)",
157            },
158            KeyBinding {
159                keys: "i",
160                description: "Character stats overlay",
161            },
162            KeyBinding {
163                keys: "↑↓ / jk",
164                description: "Move selection in craft or inventory menus",
165            },
166            KeyBinding {
167                keys: "Enter",
168                description: "Inventory: equip/wear/use selected item, or move it",
169            },
170            KeyBinding {
171                keys: "m / d / x / l",
172                description: "Inventory: move to… / Relocate… (placed chest) / drop / destroy / lock nearby chest",
173            },
174        ],
175    },
176    KeyBindingCategory {
177        name: "Chat",
178        bindings: &[
179            KeyBinding {
180                keys: "t",
181                description: "Nearby chat — focus CHAT column input",
182            },
183            KeyBinding {
184                keys: "g",
185                description: "Whisper-stone contacts in CHAT",
186            },
187            KeyBinding {
188                keys: "f (on player)",
189                description: "Whisper or Trade with nearest player",
190            },
191            KeyBinding {
192                keys: "Y / N",
193                description: "Accept / decline inbound trade request",
194            },
195            KeyBinding {
196                keys: "Enter",
197                description: "Send chat line",
198            },
199            KeyBinding {
200                keys: "Tab",
201                description: "While whispering: return to Nearby speech",
202            },
203            KeyBinding {
204                keys: "Esc",
205                description: "Unfocus chat / cancel trade / close overlay",
206            },
207        ],
208    },
209    KeyBindingCategory {
210        name: "Session & HUD",
211        bindings: &[
212            KeyBinding {
213                keys: "? or /",
214                description: "Help & keybindings",
215            },
216            KeyBinding {
217                keys: "Ctrl+Shift+1",
218                description: "Toggle floating Chat panel",
219            },
220            KeyBinding {
221                keys: "Ctrl+Shift+2",
222                description: "Toggle floating Quest tracker",
223            },
224            KeyBinding {
225                keys: "Ctrl+Shift+3",
226                description: "Toggle floating Location panel",
227            },
228            KeyBinding {
229                keys: "Ctrl+Shift+4",
230                description: "Toggle floating Log panel",
231            },
232            KeyBinding {
233                keys: "Ctrl+Shift+5",
234                description: "Toggle floating Stats (mass/money/attrs)",
235            },
236            KeyBinding {
237                keys: "F2",
238                description: "Connection settings (server host / ports)",
239            },
240            KeyBinding {
241                keys: "Ctrl+Q",
242                description: "Quit client",
243            },
244            KeyBinding {
245                keys: "Ctrl+C",
246                description: "Interrupt / force quit",
247            },
248        ],
249    },
250    KeyBindingCategory {
251        name: "Dev / debug",
252        bindings: &[
253            KeyBinding {
254                keys: "-",
255                description: "Test damage (25 HP) — dev only",
256            },
257            KeyBinding {
258                keys: ";",
259                description: "Toggle harvest / use radius overlay",
260            },
261        ],
262    },
263];
264
265/// Plain-text reference for `flatland3 keys` and similar CLIs.
266pub fn format_keybindings_plain() -> String {
267    let mut out = String::from("Flatland3 play — keybindings\n\n");
268    for cat in CATEGORIES {
269        out.push_str(cat.name);
270        out.push_str("\n");
271        for b in cat.bindings {
272            out.push_str(&format!("  {:<16} {}\n", b.keys, b.description));
273        }
274        out.push('\n');
275    }
276    out.push_str(&format_map_legend_plain());
277    out.push_str("Wildlife: rabbits north meadow (~95,195); wolves bog (~118,122).\n");
278    out
279}